Chapter 6 - Behavioral Modeling
Chapter 6 - Behavioral Modeling
assign a = b force a = b
Left-hand • Variable, •Variable, Net,
side • Concatenation of variable • Concatenation of
• Memory word any of above.
• Bit-select, part-select of variable • Memory word
• Bit-select, part-
select of variable
assign – deassign
->apply to variables
Result:
force – release 0 d=0,e=0
-> apply to net and variable 10 d=1,e=1
20 d=0,e=0
Parallel block
-> Implement
a multiplier
//wait control
wait(!enable) #10 a = b;
sensitive list
end end
always creates By adding “@ ( )” to always statement: means
an infinite loop “wait for change of signals listed in the sensitivity
list” and when the change takes place, sequential
block ( from begin to end ) is executed.
UIT Circuit Design with HDL - Chapter 6 32
Procedural timing control
Using with always statement:
negedge: transition from 1 to x, z, or 0,
always @ (………..) and from x or z to 0
posedge: transition from 0 to x, z, or 1,
begin sensitive list and from x or z to 1
description timing
always @ ( posedge clk ) when signal clk rises
• The event_expr block waits for one occurrence of event ev1 and
three occurrences of event trig; plus a delay of d time units, the task
action executes.
• When event reset occurs, regardless of events within the sequential
block, the fork-join block terminates
UIT Circuit Design with HDL - Chapter 6 34
Examples
4 to 1 mux module mux4_to_1 (out, i0, i1, i2, i3, s1, s0);
output out;
input i0, i1, i2, i3;
input s1, s0;
//output declared as register
reg out;
Using blocking assignment – it works here! It’s better to use nonblocking assignment.
But more complex sequential always blocks,
will exhibit the race condition.
Ref: Clifford E. Cummings
UIT Circuit Design with HDL - Chapter 6 45
Coding guidelines
Guideline 2: When modeling combinational logic with an
always block, use blocking assignments
equivalent:
-> Simulate and synthesis is ok, but discourage this coding style
Ref: Clifford E. Cummings
70
Summary
Suggested coding guidelines
Modeling Combinational Circuit
Modeling Sequential Circuit
Synthesizable coding