D
dbwalker0min@gmail.com
Guest
Parch,
You may be surprised that the monitor statement doesn't trigger
immediately after the assignment:
#2 a = 1;
Instead it seems to fall through and execute the following display
statements and maybe "a" is somehow not assigned. Rest assured that it
is. The reason the monitor statement doesn't print the message is that
monitor events don't get executed until all active and inactive events
get executed. After the blocking assignment takes place, the display
statements are active so the monitor message won't be printed until
the very end of the timestep 2. Take a look at the section on
"Scheduling Semantics" in the LRM or a book like Thomas & Moorsby for
details on how events are scheduled.
David Walker
Parch wrote:
You may be surprised that the monitor statement doesn't trigger
immediately after the assignment:
#2 a = 1;
Instead it seems to fall through and execute the following display
statements and maybe "a" is somehow not assigned. Rest assured that it
is. The reason the monitor statement doesn't print the message is that
monitor events don't get executed until all active and inactive events
get executed. After the blocking assignment takes place, the display
statements are active so the monitor message won't be printed until
the very end of the timestep 2. Take a look at the section on
"Scheduling Semantics" in the LRM or a book like Thomas & Moorsby for
details on how events are scheduled.
David Walker
Parch wrote:
Hello,
Can anyone justify why display statement is getting executed after the
blocking assignment in the below mentioned program?
module test;
reg a;
reg b;
initial begin
$monitor("Time: %d, a = %b b = %b",$time,a,b);
a = 0;
b = 1;
$display("Before the block St");
#2 a = 1; //bds
$display("1. After the block St");
$display("2. After the block St");
$display("3. After the block St");
$display("4. After the block St");
$display("Time is %d",$time);
a = #2 0; //bsd
$display("Time is %d",$time);
a <= #3 b; //nbsd
$display("Time is %d",$time);
#1 b = 0; //bds
$display("Time is %d",$time);
#5 $finish;
end
endmodule
Output
Running...
Before the block St
Time: 0, a = 0 b = 1
1. After the block St
2. After the block St
3. After the block St
4. After the block St
Time is 2
Time: 2, a = 1 b = 1
Time is 4
Time is 4
Time: 4, a = 0 b = 1
Time is 5
Time: 5, a = 0 b = 0
Time: 7, a = 1 b = 0
Exiting TestBencher Pro at simulation time 10000
0 Errors, 0 Warnings
Compile time = 0.00000, Load time = 0.01600, Execution time = 0.01600
Normal exit