用红、黄、绿三个指示灯表示三台设备的工作情况:绿灯亮表示全部正常;红灯亮表示有一台不正常,黄灯亮表示两台不正常;红、黄灯全亮表示三台都不正常,设备正常用1表示,设备不正常用0表示;灯亮用1表示,灯灭用0表示。用Verilog HDL编程实现上述功上述功能并给出测试文件
时间: 2024-06-03 11:08:18 浏览: 235
module indicator_led (
input wire green,
input wire yellow,
input wire red,
output wire [2:0] status
);
assign status = {red, yellow, green};
endmodule
module test_indicator_led;
reg green, yellow, red;
wire [2:0] status;
indicator_led uut (
.green(green),
.yellow(yellow),
.red(red),
.status(status)
);
initial begin
// Test case 1: All equipment normal
green = 1;
yellow = 0;
red = 0;
#10 $display("Test case 1: All equipment normal");
#10 $display("Status: %b", status);
// Test case 2: One equipment not normal
green = 0;
yellow = 0;
red = 1;
#10 $display("Test case 2: One equipment not normal");
#10 $display("Status: %b", status);
// Test case 3: Two equipment not normal
green = 0;
yellow = 1;
red = 1;
#10 $display("Test case 3: Two equipment not normal");
#10 $display("Status: %b", status);
// Test case 4: All equipment not normal
green = 0;
yellow = 1;
red = 1;
#10 $display("Test case 4: All equipment not normal");
#10 $display("Status: %b", status);
end
endmodule
阅读全文