Verilog "Stratified Event Queue"
The Verilog event queue is a conceptual model, which helps us understand how various events like blocking assignments, nonblocking assignments function.
According to the Verilog IEEE standard, the Verilog event queue is logically segmented into five different regions.
1) Active Events :
Events which occur at the current simulation time and can be executed in any order. These include blocking assignments, continuous assignments, $display commands, evaluation of instance and primitive inputs followed by updates of primitive and instance outputs, and the evaluation of nonblocking RHS expressions.
2) Inactive Events.
Events which are processed after the processing of active events. In this queue, #0 delay assignments are scheduled.
3) Nonblocking assign update events
Events that were evaluated during previous simulation time, but are assigned at this simulation time after the processing of active and inactive events. It is these queue where the LHS of nonblocking assignment is updated.
4) Monitor Events
Events that are processed after all the active, inactive and nonblocking assign update events have been processed. This queue contains $monitor and $strobe assignments.
5) Future Events
Events to occur at future simulation time.
Verilog Event Queue model |
Example :
What will be the output of following piece of code?
initial
begin
a = 1'b0;
a <= 1'b1;
$display("\nValue of a is :%b", a);
end
Many of us think that the the value of a displayed will be '1', but it is not correct. Using the Verilog event queue,
I) a = 1'b0;
This will be placed in the active events, so the assignment will take place immediately. Hence, at this time , the value of a is '0'.
II) a <= 1'b1;
As you remember from our previous post on nonblocking assignments, the nonblocking assignment is a two step process, so only RHS evaluation will be scheduled in active event. At this point the LHS will not be updated, so the value of a still remains '0'.
III) $display("\nValue of a is :%b",a);
Since, it is a display statement the statement will be placed in active events and processed immediately, so we get the value of a printed as '0'.
IV) In this step, the LHS of nonblocking statement in II will be updated, at this time the value of a will change from '0' to '1'.
simple n sweet dude
ReplyDelete