06-Verilog Behavioral Modeling
06-Verilog Behavioral Modeling
Verilog® HDL
Behavioral Modeling (1)
Maziar Goudarzi
Today program
Behavioral Modeling
Concepts
Constructs
initial
begin
#5 a=1’b1;
#25 b=1’b0;
end
initial
begin
#10 x=1’b0;
#25 y=1’b1;
end
initial
What happens if such a
#1000 $finish; $finish is not included?
endmodule
2005 Verilog HDL 7
Procedural Assignments
<lvalue> can be
reg, integer, real, time
A bit-select of the above (e.g., addr[0])
A part-select of the above (e.g., addr[31:16])
A concatenation of any of the above
<expression> is the same as introduced in dataflow modeling
What happens if the widths do not match?
LHS wider than RHS => RHS is zero-extended
RHS wider than LHS => RHS is truncated (Least significant part is kept)
if (<expression>) true_statement;
else false_statement;
if (<expression>) true_statement1;
else if (<expression>) true_statement2;
else if (<expression>) true_statement3;
else default_statement;
True is 1 or non-zero
False is 0 or ambiguous (x or z)
More than one statement: begin end
if (alu_control==0)
y = x+z;
else if (alu_control==1)
y = x-z;
else if (alu_control==2)
y = x*z;
else
$display(“Invalid ALU control signal.”);
Recommendation
Concurrent data transfers => race condition
Use non-blocking assignments wherever
concurrent data transfers
Example: pipeline modeling
Disadvantage:
Lower simulation performance
Higher memory usage in the simulator
Homework 5
Chapter 7 exercises 1-4, 10, 12, 13, 14, 15
Due date: Next Sunday (Azar 6th)