nand2/07_Operating_System/00_HACK/Switch.v

21 lines
350 B
Coq
Raw Normal View History

2023-01-11 10:13:09 +00:00
/**
* One Bit-register, that can be switched on and off
*
* if (out[t] == 0) and (on[t] == 1) out[t+1] = 1
* if (out[t] == 1) and (off[t] == 1) out[t+1] = 0
*/
`default_nettype none
module Switch(
input clk,
input on,
input off,
output out
);
reg out = 0;
always @(posedge clk)
out <= (on&off)?(~out):(on?1:(off?0:(out?1:0)));
endmodule