Event Queue
Event Queue
Consider
eq-1 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-1
Introduction Terminology
Terminology
Event:
Sort of a to-do item for simulator. May include running a bit of Verilog code or updating an object’s value.
Event Queue:
Sort of a to-do list for simulator. It is divided into time slots and time slot regions.
Time Slot:
A section of the event queue in which all events have the same time stamp.
Scheduling:
Determining when an event should execute. The when consists of a time slot and a time slot region.
Update Events:
The changing of an object’s value. Will cause *sensitive* objects to be scheduled.
eq-2 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-2
Introduction Terminology
Event 103
eq-3 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-3
Introduction Terminology
Inactive
(5) When all regions
Event 2 in this time slot empty
advance to next time slot.
Event 103
eq-4 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-4
Example Showing Active and Inactive Regions
4: Event i-a.0 removed from active region (it is now not scheduled anywhere). assign c = a + b; // c
eq-5 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-5
Example Showing Active and Inactive Regions
10-12: Since all regions in time slot 0 are empty, move to next time slot, t = 1.
assign c = a + b; // c
eq-6 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-6
Example Showing Active and Inactive Regions NBA and Postponed Regions
NBA Region:
Update events from non-blocking assignments.
Postponed Region:
Events scheduled using $watch system task.
eq-7 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-7
Event Scheduling Event Types
Event Types
Evaluation Event
Indicates that a piece of code is to be executed or resumed.
Sometimes just referred to as events, or resume events.
All events from the previous event queue example were evaluation events.
Update Event
Indicates that the value of an object is to be changed.
eq-8 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-8
Event Scheduling Event Scheduling
Event Scheduling
Event Scheduling:
The placing of an event in the event queue.
Types of Scheduling
eq-9 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-9
Event Scheduling Types of Scheduling and Related Events Time-Delay Scheduled
Event Scheduling
Time-Delay Scheduled
b++;
// Label L1
#4; // Schedule resume event for L2 at time t+4.
// Label L2;
a = b;
eq-10 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-10
Event Scheduling Types of Scheduling and Related Events Sensitivity List Scheduled
// Label: L0
@( x ); // Put a check-@-condition event in sensitivity list of x ..
// .. event will resume at L1 if condition satisfied ..
// .. meaning any change in x.
// Label: L1
@( posedge clk ); // Put a check-@-condition event in sensitivity list of clk ..
// .. event will resume at L2 if condition satisfied ..
// .. meaning 0->1 transition.
// Label: L2
wait( stop_raining ); // Put a check-wait-condition event in sensitivity list of stop_raining ..
// .. event wil resume at L3 if stop_raining != 0.
// Label: L3
eq-11 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-11
Event Scheduling Types of Scheduling and Related Events Sensitivity List Scheduled
Continuous assignment:
eq-12 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-12
Event Scheduling Types of Scheduling and Related Events Sensitivity List Scheduled
Primitive ports:
eq-13 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-13
Event Scheduling Types of Scheduling and Related Events Permanently Schedule
Permanently Scheduled
eq-14 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-14
Examples Example 1 Verilog Code
Show the state of the event queue for the module below . . .
. . . starting at t = 10 and given the external events described below.
logic [n-1:0] z;
eq-15 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-15
Examples Example 1 Example’s Sensitivity Lists and Update Events
eq-16 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-16
Examples Example 1 Conditions and External Events
eq-17 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-17
Examples Example 1 Event Queue Changes
eq-18 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-18
Examples Example 1 Event Queue Changes
eq-19 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-19
Examples Example 1 Event Queue Changes
eq-20 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-20
Examples Example 1 Event Queue Changes
eq-21 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-21
Examples Example: Non-blocking assignments 2 Verilog Code
module eq;
Example: Non-Blocking Assignments 2 logic [7:0] a, b, c, d, x, y;
logic [7:0] x1, x2, y1, y2, z2;
Consider the code to the right.
always_comb begin // C1
x1 = a + b;
y1 = 2 * b;
end
assign x2 = 100 + a + b; // C2
assign y2 = 4 * b; // C3
assign z2 = y2 + 1; // C4
initial begin
// C5a
a = 0;
b = 10;
#2;
// C5b
a = 1;
b <= 11;
#2;
// C5c
a = 2;
b = 12;
end
endmodule
eq-22 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-22
Examples Example: Non-blocking assignments 2 Verilog Code
module eq;
Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 logic [7:0] a, b, c, d, x, y;
t=0 t=0 t=0 t=0 t=0 t=0 t=0 t=0 t=2 logic [7:0] x1, x2, y1, y2, z2;
Active Active Active Active Active Active Active Active Active
C5a% C1% C2% C3% C4% C5b%
always_comb begin // C1
x1 = a + b;
Inactive Inactive C2 C3 Inactive Inactive Inactive Inactive Inactive y1 = 2 * b;
C1 C3 Inactive C4 end
NBA C2 Inactive NBA NBA NBA NBA NBA
C3 NBA assign x2 = 100 + a + b; // C2
NBA NBA t=2 t=2 t=2 t=2 assign y2 = 4 * b; // C3
Inactive Inactive Inactive Inactive assign z2 = y2 + 1; // C4
t=2
t=2 t=2 Inactive C5b C5b C5b C5b
initial begin
Inactive Inactive C5b // C5a
C5b C5b a = 0;
b = 10;
#2;
// C5b
a = 1;
b <= 11;
#2;
// C5c
a = 2;
b = 12;
end
endmodule
eq-23 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-23
Examples Example: Non-blocking assignments 2 Verilog Code
module eq;
logic [7:0] a, b, c, d, x, y;
Step 10 Step 11 Step 12 Step 13 Step 14 Step 15 Step 16 Step 17
logic [7:0] x1, x2, y1, y2, z2;
t=2 t=2 t=2 t=2 t=2 t=2 t=2 t=2
Active Active Active Active Active Active Active Active always_comb begin // C1
C1% C2% b← 11% C1% C2% x1 = a + b;
Inactive C2 Inactive Inactive Inactive Inactive C2 C3 y1 = 2 * b;
C1 Inactive C1 Inactive end
C3
C2 NBA NBA NBA C2 Inactive assign x2 = 100 + a + b; // C2
NBA NBA b← 11 b← 11 C3 NBA assign y2 = 4 * b; // C3
b← 11 b← 11 t=4 t=4 t=4 NBA NBA assign z2 = y2 + 1; // C4
t=4 t=4 Inactive Inactive Inactive t=4
Inactive Inactive C5c C5c C5c t=4 t=4 Inactive initial begin
C5c C5c Inactive Inactive C5c // C5a
a = 0;
C5c C5c
b = 10;
#2;
// C5b
a = 1;
b <= 11;
#2;
// C5c
a = 2;
b = 12;
end
endmodule
eq-24 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-24
Examples Example: Non-blocking assignments 2 Verilog Code
module eq;
Step 18 Step 19 Step 20 Step 21 Step 22 logic [7:0] a, b, c, d, x, y;
t=2 t=2 t=2 t=2 t=4 logic [7:0] x1, x2, y1, y2, z2;
Active Active Active Active Active
C3% C4% C5c%
always_comb begin // C1
x1 = a + b;
Inactive Inactive Inactive Inactive Inactive y1 = 2 * b;
C4 end
NBA NBA NBA NBA NBA
assign x2 = 100 + a + b; // C2
t=4 t=4 t=4 t=4 assign y2 = 4 * b; // C3
Inactive Inactive Inactive Inactive assign z2 = y2 + 1; // C4
C5c C5c C5c C5c
initial begin
// C5a
a = 0;
b = 10;
#2;
// C5b
a = 1;
b <= 11;
#2;
// C5c
a = 2;
b = 12;
end
endmodule
eq-25 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-25
Event Queue Diagrams
SCHED DONE
NBA
Event 162
eq-26 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-26
Event Queue Diagrams
SCHED DONE
Inactive
Event 2 Inactive
and NBA
regions
NBA
are empty.
Event 12
eq-27 EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-27
Event Queue Diagrams
SCHED DONE
Inactive Re-inactive
Event 2 and re-NBA
Inactive
empty BUT
and NBA
events in
regions
NBA inactive or
are empty.
Event 12 NBA region.
SCHED DONE
Re-Inactive
Event 712 Inactive,
re-inactive,
NBA, and
Re-NBA re-NBA regions
Event 122 are all empty.
eq-28 Time slot t=19 Initiate next time slot. EE 4755 Lecture Transparency. Formatted 17:46, 11 December 2019 from lsli-event-q-TeXize. eq-28