There are two types of procedural assignment statements: blocking and non-blocking
1. Blocking Assignments:
Blocking assignment statements are executed in the order they are specified in a sequential block. A blocking assignment will not block execution of statements that follow in a parallel block. The = operator is used to specify blocking assignments.
Example:
reg x, y, z;
reg [15:0] reg_a, reg_b;
integer count;
//All behavioral statements must be inside an initial or always block
initial
begin
x = 0;
y = 1;
z = 1; //Scalar assignments
count = 0; //Assignment to integer variables
reg_a = 16'b0; reg_b = reg_a; //initialize vectors
#10 reg_a[2] = 1'b1; //Bit select assignment with delay
#15 reg_b[15:13] = {x, y, z} //Assign result of concatenation to
// part select of a vector
count = count + 1; //Assignment to an integer (increment)
end
In the given example, the statement y = 1 is executed only after x = 0 is executed. The
behavior in a particular block is sequential in a begin-end block if blocking statements are
used, because the statements can execute only in sequence.
The statement count = count + 1 is executed last.
The simulation times at which the statements are executed are as follows:
• All statements x = 0 through reg_b = reg_a are executed at time 0
• Statement reg_a[2] = 0 at time = 10
• Statement reg_b[15:13] = {x, y, z} at time = 25
• Statement count = count + 1 at time = 25
• Since there is a delay of 10 and 15 in the preceding statements, count = count + 1
will be executed at time = 25 units
Note that for procedural assignments to registers, if the right-hand side has more bits than
the register variable, the right-hand side is truncated to match the width of the register
variable. The least significant bits are selected and the most significant bits are discarded.
If the right-hand side has fewer bits, zeros are filled in the most significant bits of the
register variable.
Ref: S. Palnitkar
Comments
Post a Comment