EE5530 Lecture8 Concurrency
EE5530 Lecture8 Concurrency
Concurrency
in
SystemVerilog
Memory Read
❑Interfaces
Interface : Advantages
An interface is ideal for design reuse. When two blocks communicate with
a specified protocol using more than two signals, consider using an
interface.
The interface takes the jumble of signals that you declare over and over
in every module or program and puts it in a central location, reducing the
possibility of misconnecting signals.
To add a new signal, you just have to declare it once in the interface, not
in higher-level modules, once again reducing errors.
You must now use the interface name in addition to the signal name, possibly
making the modules more verbose.
If you are connecting two design blocks with a unique protocol that will not be
reused, interfaces may be more work than just wiring together the ports.
Time is the ability to represent how the internal state of a design evolves over
time and to control its progression and rate. This concept is different from
execution time which is a simple measure of how long a program runs.
Concurrency is the ability to describe actions that occur at the same time,
independently of each other.
In SystemVerilog
Multi-processor machines are relatively easy to build but, they proved much more
difficult to program.
Human beings are adept at performing relatively complex tasks in parallel. But it
seems that we are better at describing a process or following instructions in a
sequential manner.
Every always and initial block, every continuous assignment and every forked
statement in a SystemVerilog model execute in parallel with each other, but
internally each executes sequentially.
Emulating Parallelism on a Sequential Processor
During normal day-to-day use, you are very likely to have several windows
open at once, each of them running a different application. The applications
running in all of these windows appear to work all in parallel even though
there is a single sequential processor to execute them.
Each application uses the entire processor for small portions of time.
If the performance of the processor and operating system is high enough, the
interruptions in the execution of a program are below our threshold of detection
It appears as if each program runs smoothly 100% of the time, in parallel with all
the others.
A simulator works using the same principle. Each always and initial block or thread
has the simulation engine for some portion of time. They appear to run in parallel.
Verilog Execution Semantics
Verilog Execution Semantics
Verilog Execution Semantics
Verilog Execution Semantics
Verilog Execution Semantics
Verilog Execution Semantics
Verilog Execution Semantics
Verilog Execution Semantics
Updates trigger other events (1) to be added to active
event queue, but B does not see the new value from A
since B has already evaluated its RHS
Verilog Execution Semantics
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.
Time Slot Regions
Rationale:
“Do it now!" is too vague. Need to prioritize.
Active Region:
Events that the simulator is currently working on.
Only the current time slot has this region.
Inactive Region:
Contains normally scheduled events. Current and
future time slots have this region.
initial begin
// i-a.0
a = 1;
#3;
// i-a.1
a = 2;
end
initial begin
// i-b.0
b = 10;
1: Verilog puts all initial blocks in t = 0's inactive region. #1;
2: Active region is empty, and so inactive copied to active. // i-b.1
3: Event i-a.0 executes and schedules event c for t = 0 : : : b = a;
: : : and i-a.1 for t = 3. End
4: Event i-a.0 removed from active region (it is now not scheduled anywhere). // c
assign c = a + b;
initial begin
// i-a.0
a = 1;
#3;
// i-a.1
a = 2;
end
initial begin
// i-b.0
b = 10;
5,6: Event i-b.0 executes and schedules i-b.1 for t = 1. #1;
7,8: Since active region is empty, inactive region is bulk-copied to active region. // i-b.1
9: Event c executes. b = a;
10-12: Since all regions in time slot 0 are empty, move to next time slot, t = 1. End
// c
assign c = a + b;
Event Types
Evaluation Event:
Update Event:
Types of Scheduling
b++;
// Label L1
// Label L2;
a = b;
Sensitivity List Scheduled
When an object in a sensitivity list changes….
…. schedule a resume or check-and-resume event for code associated with sensitivity list….
……in the inactive region of current time step.
// 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
end
Continuous assignment:
always_comb begin
y <= a + b; // Schedule an update-y event in NBA region, keep executing.
e = y + g; // Uses old y.
end
Example: Non-blocking assignments
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;
always_ff @( posedge clk ) begin // Label: alf
a <= b + c;
z = a + j;
g = z;
end
always_comb // Label: alc
e = a * f;
endmodule
Example's Sensitivity Lists and Update Events
Step 27: If nothing else happens simulation ends. always_comb // Label: alc
e = a * f;
Delta Cycles
As threads are simulated and new values are assigned after zero delays, the state of the
simulation evolves and progresses, but time does not advance. Since time does not advance,
but the state of the simulation evolves, these zero-delay cycles where threads are evaluated
and zero-delay nonblocking values are assigned are called delta-cycles. The simulation
progresses first along the delta axis then along the real-time axis.