SystemVerilog Event Scheduling Algorithm
While simulating System Verilog design and its test-bench including assertions, events has to be dynamically scheduled, executed, and removed as the simulator advances time. To have this feature, simulator has to maintain a data structure and usually would be a time ordered linked list. That means, at any point of time during simulation, event has one execution time which is current time or future time.
All scheduled events at a specific time define a time slot. A time slot is divided into a set of ordered regions, as Preponed, Pre-Active, Active, Inactive, Pre-NBA, NBA, Post-NBA, Pre-Observed, Observed, Post-Observed, Reactive, Re-Inactive, Pre-Re-NBA, Re-NBA, Post-Re-NBA, Pre-Postponed & Postponed.
REGION GROUPS
There are groups of event regions that are used to help define the scheduling of System Verilog activity.
Active region: Events scheduled in the Active, Inactive, Pre-NBA, NBA, and Post-NBA regions are active region set events.
Reactive region: Events scheduled in the Reactive, Re-Inactive, Pre- Re-NBA, Re-NBA, and Post-Re-NBA regions are reactive region set events.
Iterative regions: The Active, Inactive, Pre-NBA, NBA, Post-NBA, Pre-Observed, Observed, Post- Observed, Reactive, Re-Inactive, Pre-Re-NBA, Re-NBA, Post-Re-NBA, and Pre-Postponed regions are known as the iterative regions.
Simulation region: The simulation regions of a time slot are the Preponed, Active, Inactive, NBA, Observed, Reactive, Re-Inactive, Re-NBA and Postponed regions.
Simulator executes and removes all events in the current simulation time slot before moving to next time slot. In an even based simulator, a time slot is divided into a set of ordered regions to provide predictable interactions between the design and test-bench code.
PREPONED
Sampling in the preponed region is same as the sampling in the previous postponed region. All nets and variables used in concurrent assertions are sampled here.
The #1step sampling delay provides the ability to sample data immediately before entering the current time slot. #1step sampling is identical to taking the data samples in the Preponed region of the current time slot.
ACTIVE REGION
Sampling of blocking assignments (out = in), continuous assignments (assign out=in) and RHS of non-blocking assignments (out <= in) are evaluated in this region. If intra-assignment delay exist for blocking assignment, it first computes RHS value and then suspend the executing process and schedule as future event. Delay 0 will be scheduled for inactive region.
INACTIVE REGION
The Inactive region holds the events to be evaluated after all the Active events are processed.
#0 delay statements are executed in this region.
out = #0 in
An explicit #0 delay control requires the process to be suspended and an event to be scheduled into the Inactive region of the current time slot so that the process can be resumed in the next Inactive to Active iteration.
NBA
RHS of non-blocking assignment are occurred in active region and update of LHS will happen in NBA region.
The NBA region holds the events to be evaluated after all the Inactive events are processed. If events are being executed in the active region set, a non-blocking assignment creates an event in the NBA region scheduled for the current or a later simulation time.
OBSERVED REGION
The Observed region is for evaluation of property expressions when it is triggered. During property evaluation, pass/fail code shall be scheduled in the Reactive region of the current time slot. PLI callbacks are not allowed in the Observed region.
RE-ACTIVE REGION
The pass/fail code (code in action blocks of concurrent assertions) is scheduled in this region. The code specified by blocking assignments in program blocks is also scheduled in this region.
The Reactive region is the reactive region set dual of the Active region.
RE-INACTIVE REGION
#0 delay statements related to program block are scheduled in this region.The Re-Inactive region holds the events to be evaluated after all the Reactive events are processed.
The Re-Inactive region is the reactive region set dual of the Inactive region.
RE-NBA REGION
The Re-NBA region holds the events to be evaluated after all the Re-Inactive events are processed.
Update of LHS will happen in this region for the statements its RHS of non-blocking assignment occurred in re-active region.The Re-NBA region is the reactive region set dual of the NBA region.
POSTPONED
Write values to any net or variable or scheduling an event in any previous region within the current time slot are illegal in this region. $monitor, $strobe, and other similar events are scheduled here.