4个开关控制1个led,如果一个开关改变值led改变值
4 switches control 1 led, if a switch change in value led change in value
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.
我能写代码,但我的助教说我不能从计算机科学的角度思考,让我从硬件的角度重写代码
试了几次还是没搞明白,求助
这是我最近的尝试
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])|
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是开关。真相 table 用格雷码编码,每行之间只有一个输入发生变化。初始状态为"all switches are off, the light is off"。当光为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]);
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.
我能写代码,但我的助教说我不能从计算机科学的角度思考,让我从硬件的角度重写代码
试了几次还是没搞明白,求助
这是我最近的尝试
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])|
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是开关。真相 table 用格雷码编码,每行之间只有一个输入发生变化。初始状态为"all switches are off, the light is off"。当光为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]);