Your code ran fine for me on one simulator (Cadence), but it behaved the way you described on another simulator (Synopsys VCS).
VCS showed me this message:
No TimeScale specified
Warning-[DRTZ] Detect delay value roundoff to 0
Delay from design or SDF file roundoff to 0 based on timescale
Please use switch -diag timescale to dump detailed information.
That made me wonder what timescale was being used, so I added the $printtimescale
task to each module. Cadence uses 1ns for both the time unit and precision by default, and VCS uses 1s. For VCS, since your delays (1000ns and 100ns) are smaller than the default precision (1s), the delays are set to 0.
Since the IEEE Std 1800-2017 does not specify the default timescale, you must set it explicitly. One way is to use the `timescale
compiler directive as shown below (refer to IEEE Std 1800-2017, section 22.7 `timescale):
`timescale 1ns/1ns
module dut_top;
wire [31:0] ctrl_32bit;
wire ctrl_1bit;
assign ctrl_32bit = 0;
assign ctrl_1bit = 0;
initial $printtimescale;
initial begin #1000ns; end
endmodule
program automatic test;
initial begin
$printtimescale;
$monitor($time,, dut_top.ctrl_1bit,, dut_top.ctrl_32bit[0]);
repeat(5) begin
#100ns;
force dut_top.ctrl_32bit[0] = ~dut_top.ctrl_32bit[0]; //LINE 1
force dut_top.ctrl_1bit = ~dut_top.ctrl_1bit; //LINE 2
force dut_top.ctrl_32bit[0] = dut_top.ctrl_1bit; //LINE 3
end
end
endprogram
Here is the VCS output for me (runnable on EDA playground):
TimeScale of dut_top is 1 ns / 1 ns
TimeScale of test is 1 ns / 1 ns
0 0 0
100 1 1
200 0 0
300 1 1
400 0 0
500 1 1
$finish at simulation time 500
I added the $monitor
task to display the output. As you can see, both bits are toggling, as expected. There is no problem with your force
statements.