The following is some modelsim code:
begin
tb_in_top = 0;
#5 tb_in_top = 4'b0000;#5 tb_in_top = 4'b0001;
#5 tb_in_top = 4'b0010;#5 tb_in_top = 4'b0011;
#5 tb_in_top = 4'b0100;#5 tb_in_top = 4'b0101;
#5 tb_in_top = 4'b0110;#5 tb_in_top = 4'b0111;
#5 tb_in_top = 4'b1000;#5 tb_in_top = 4'b1001;
#5 tb_in_top = 4'b1010;#5 tb_in_top = 4'b1011;
#5 tb_in_top = 4'b1100;#5 tb_in_top = 4'b1101;
#5 tb_in_top = 4'b1110;#5 tb_in_top = 4'b1111;
#100 $finish;
end
What does the #5 and #100 represent? Are those line numbers? Is there something wrong with this code?
It’s not "ModelSim" code any more than something is "Visual Studio" code. It’s Verilog.
The
#token signifies a delay in nanoseconds.So what this code means is:
(… keep counting up, incrementing tb_in_top by 1 every 5 ns …)
Yes, Verilog has
forloops, and yes, that should be one.Addendum
The
forloop would look like:Finally, note that Verilog that uses the
#time-delay operation cannot be synthesized to logic; it can only be used for simulation.