[SOLVED] Verilog waveform question (using online simulation website edaplayfround)

Status
Not open for further replies.

zongya

Newbie level 5
Joined
Mar 5, 2015
Messages
10
Helped
2
Reputation
4
Reaction score
2
Trophy points
3
Activity points
70
Hi all,

I just start to learn verilog and try to simulate AND gate on eda playground.



The module is:
Code:
module andgate (a, b, y);
input a, b;
output y;

assign y = a & b;

endmodule




And testbench is:
Code:
module andgate_tb;
wire t_y;
reg t_a, t_b;

andgate my_gate( .a(t_a), .b(t_b), .y(t_y) );

initial
begin
 
  $dumpfile("dump.vcd");
   
  $dumpvars(0, my_gate);
 
  $monitor("At time %2t, t_a=%d t_b=%d t_y=%d",$time, t_a, t_b, t_y);
 
    t_a = 1'b0;
    t_b = 1'b0;

    #5;
 
    t_a = 1'b0;
    t_b = 1'b1;

    #5;
    t_a = 1'b1;
    t_b = 1'b0;

    #5;
    t_a = 1'b1;
    t_b = 1'b1;
 
    #5;
 
    end

endmodule

However, the waveform I got is only from 0~15 time units. Shouldn't it be 20 units since I put four #5?

I'm using a online simulation website https://www.edaplayground.com/ Tool & Simulators ModelSim 10.1d
 

Re:Verilog waveform question
I did simulation using your testbench code itself and also it runs after 15 time units also in Modelsim 6.3c. Set tour run length as 5 time units.
 
Reactions: zongya

    zongya

    Points: 2
    Helpful Answer Positive Rating
Hi all,
However, the waveform I got is only from 0~15 time units. Shouldn't it be 20 units since I put four #5?
Nope, 0-15 is as it should be. You are monitoring changes. And the last change occurs at t=15. The simulator may run for 20 time units, but if you don't perform a change in the time interval 15-20, then you are not going to see a change during that interval. As an example say you add another #100; at the end, the simulator would now run for a total of 120 time units. But you would still only see actual changes between t=0 and t=15. If you want to see more changes, then you'll have to actually change t_a or t_b somewhere after t = 15.
 
Reactions: zongya

    zongya

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…