用红、黄、绿三个指示灯表示三台设备的工作情况:绿灯亮表示全部正常;红灯亮表示有一台不正常,黄灯亮表示两台不正常;红、黄灯全亮表示三台都不正常,设备正常用1表示,设备不正常用0表示;灯亮用1表示,灯灭用0表示。用Verilog HDL编程实现上述功能
时间: 2024-06-06 11:07:48 浏览: 153
module indicator(input wire green, input wire yellow, input wire red, output reg device1, output reg device2, output reg device3);
always @(*) begin
if (green == 1 && yellow == 0 && red == 0) begin
device1 = 1;
device2 = 1;
device3 = 1;
end
else if (green == 0 && yellow == 1 && red == 0) begin
device1 = 1;
device2 = 1;
device3 = 0;
end
else if (green == 0 && yellow == 0 && red == 1) begin
device1 = 1;
device2 = 0;
device3 = 0;
end
else if (green == 0 && yellow == 1 && red == 1) begin
device1 = 1;
device2 = 0;
device3 = 0;
end
else if (green == 1 && yellow == 0 && red == 1) begin
device1 = 0;
device2 = 0;
device3 = 0;
end
else begin
device1 = 0;
device2 = 0;
device3 = 0;
end
end
endmodule
阅读全文