Hardware Reference
In-Depth Information
3.6
A Time Slot and the Movement of Time
In Example 3.7 , we noted that the events get scheduled at different times, such as
at time 0 and time 5. Each event is associated with a simulation time, which is the
time maintained by the simulator to account for the delays in the design. Without
the delays in the design, the simulation time will not advance and all events will
occur at time 0.
The time delays in the system are specified with a scale and a precision.
Nonetheless, time is discrete and there exists a global time precision which is the
smallest unit of time in the system being simulated. 1step denotes the smallest time
precision.
Example 3.9. In the module m below, the smallest unit of time (one step) is 1ns .
module m(...);
timeunit 1ns;
...
endmodule :m
t
We have seen how the event queues and the regions establish the order of
processing within a time slot. The time within a time slot remains constant, and
thus, all events scheduled within a time slot refer to the same time. When all events
are processed for a time slot, the simulation control moves to the nearest time slot
containing scheduled events.
Example 3.10. Consider the program test declaration from Example 3.8 .
program test( output logic request, grant, sync);
logic oldreq = 1'b0;
assign grant = oldreq;
initial begin
request = 1'b0;
sync = 1'b0;
for ( int i = 0; i < 100; i++) begin
#5 sync <= !sync;
if (i%2) begin
oldreq <= request;
request <= $random;
end
end
end
endprogram : test
When the execution reaches the statement #5 , an evaluation event is scheduled
for a future time slot. For example, if the current time is 10, the next statement is
scheduled for time step 15 in the Reactive region set. When the simulation control
transitions to time 15, the scheduled event gets executed, etc.
t
Search WWH ::




Custom Search