A room has 4 doors with a light switch next to each door, totaling 4 light
switches. Inside the room there is only one light in the center of the
ceiling. Design a circuit that allows all 4 switches to control that single
center light. Each switch needs to be able to turn the light on if it is off,
and off if it is currently on.
我能够编写代码但我的TA说我不能像计算机科学那样思考,并告诉我用硬件来重写代码
我做了几次尝试仍然无法弄清楚,请帮助
这是我最近的尝试
assign led = (sw[0] & ~sw[1] & ~sw[2] & ~sw[3])|
(~sw[0] & sw[1] & ~sw[2] & ~sw[3])|
(~sw[0] & ~sw[1] & sw[2] & ~sw[3])|
(~sw[0] & ~sw[1] & ~sw[2] & sw[3])|
答案 0 :(得分:0)
A B C D | Light
---------|-------
0 0 0 0 | 0 _ _ _
0 0 0 1 | 1 => A.B.C.D
0 0 1 1 | 0 _ _ _
0 0 1 0 | 1 => A.B.C.D
0 1 1 0 | 0 _
0 1 1 1 | 1 => A.B.C.D
0 1 0 1 | 0 _ _ _
0 1 0 0 | 1 => A.B.C.D
1 1 0 0 | 0 _
1 1 0 1 | 1 => A.B.C.D
1 1 1 1 | 0 _
1 1 1 0 | 1 => A.B.C.D
1 0 1 0 | 0 _
1 0 1 1 | 1 => A.B.C.D
1 0 0 1 | 0 _ _ _
1 0 0 0 | 1 => A.B.C.D
A,B,C和D是开关。真值表以格雷码编码,以便在每行之间仅改变一个输入。初始状态为"所有开关均关闭,指示灯熄灭"。当光为1时,光的等式是所有状态的逻辑或。有8种状态:当只有一个开关打开且只有一个开关关闭时。
目前,当只有一个开关打开时,您只编码了其中的一半。对于所有8个州,等式变为:
assign led = ( sw[0] & ~sw[1] & ~sw[2] & ~sw[3])|
(~sw[0] & sw[1] & ~sw[2] & ~sw[3])|
(~sw[0] & ~sw[1] & sw[2] & ~sw[3])|
(~sw[0] & ~sw[1] & ~sw[2] & sw[3])|
(~sw[0] & sw[1] & sw[2] & sw[3])|
( sw[0] & ~sw[1] & sw[2] & sw[3])|
( sw[0] & sw[1] & ~sw[2] & sw[3])|
( sw[0] & sw[1] & sw[2] & ~sw[3]);