This is my main code. The function is switching the light on or off when I toggle. Maybe the t filp-flop can help?
module demo(
input switch1,switch2,
output reg light=1'b0
);
always@(switch1 or switch2)
begin
light <= ~light;
end
endmodule
And the testbench
`timescale 1ns/100ps
module demo_test;
reg switch1,switch2;
wire light;
demo d1(.switch1(switch1),
.switch2(switch2),
.light(light));
initial
begin: in_set_blk
#0 switch1 =1'b0;
switch2 =1'b0;
$display ($time, "light=%d \n",light);
#10 switch1 =1'b1;
switch2 =1'b0;
$display ($time, "light=%d \n",light);
#10 switch1 =1'b0;
switch2 =1'b0;
$display ($time, "light=%d \n",light);
#10 switch1 =1'b0;
switch2 =1'b1;
$display ($time, "light=%d \n",light);
#10 switch1 =1'b0;
switch2 =1'b0;
$display ($time, "light=%d \n",light);
#10 $stop;
#10 $finish;
end
endmodule
This is the modelsim waveform diagram; I think it works well:
This is the diagram in RTL viewer; that is the strange part:
Diagram in RTL viewer is so strange; the input even didn't connect to the inverter.
Any error in my main Verilog code?

