Professional Documents
Culture Documents
Hierarchical Modeling
Hierarchical Modeling
Remember
Through
Verilog
Structural
Dataflow
Behavioral
Patrick Schaumont
Spring 2008
Structural Modeling
Describe
Q
S
Netlist
Patrick Schaumont
Spring 2008
Behavioral Modeling
Describe
input S, R;
output Q, QB;
if ( S == 1) and (R == 0) then
Set Q to 1, set QB to 0
else if ( S == 1) and (R == 1) then
Set Q to 1, set QB to 1
else if ( S == 0) and (R == 0) then
*Hold current state*
else if ( S == 0) and (R == 1) then
Set Q to 0, set QB to 1
ECE 4514 Digital Design II
Lecture 2: Hierarchical Design
Patrick Schaumont
Spring 2008
Rbar
Q
my_flop
Sbar
Structural Description
explains what happens
to Q and Qbar in terms of
a netlist of lower-level
components
Qbar
Behavioral Description
explains what happens
to Q and Qbar in terms of
Rbar and Sbar
Patrick Schaumont
Spring 2008
Q
my_flop
Level 1
Sbar
Qbar
Rbar
NAND
NAND
Qbar
Level 2
Sbar
ECE 4514 Digital Design II
Lecture 2: Hierarchical Design
Patrick Schaumont
Spring 2008
Top-down design
my_pc
motherboard
harddisk
controller
cpu
memory
integer
unit
cache
regfile
ALU
shifter
NAND
NOR
io
controller
Bottom-up design
my_pc
motherboard
harddisk
controller
cpu
memory
integer
unit
cache
regfile
ALU
NAND
ECE 4514 Digital Design II
Lecture 2: Hierarchical Design
io
controller
shifter
NOR
When
In
In
There
Patrick Schaumont
Spring 2008
counter
q0
T-ff
q
q1
T-ff
q
q2
T-ff
q3
T-ff
q
reset
Top-level
Patrick Schaumont
Spring 2008
T flip-flop, behavior
T-ff
clk
q
reset
Patrick Schaumont
Spring 2008
T flip-flop, structure
T-ff
q
reset
D-ff
T-flipflop
D-flipflop
inverter
D
q
reset
Thus,
D flipflop in Verilog
module D_FF(q, d, clk, reset);
output q;
input d, clk, reset;
reg q;
always @(posedge reset or negedge clk)
if (reset)
q <= 1'b0;
else
q <= d;
endmodule
Patrick Schaumont
Spring 2008
D flipflop in Verilog
module D_FF(q, d, clk, reset);
output q; one output port, three input ports
input d, clk, reset;
reg q;
'reg' means that q is a variable
always @(posedge reset or negedge clk)
if (reset)
always @(condition) means: whenever
q <= 1'b0;
(condition) is true, proceed.
else
The '<=' is called a dataflow assignment,
q <= d;
endmodule
Patrick Schaumont
Spring 2008
T flipflop in Verilog
Patrick Schaumont
Spring 2008
T flipflop in Verilog
Patrick Schaumont
Spring 2008
T flipflop in Verilog
Patrick Schaumont
Spring 2008
tff0(q[0],
tff1(q[1],
tff2(q[2],
tff3(q[3],
clk, reset);
q[0], reset);
q[1], reset);
q[2], reset);
endmodule
Patrick Schaumont
Spring 2008
tff0(q[0],
tff1(q[1],
tff2(q[2],
tff3(q[3],
clk, reset);
q[0], reset);
q[1], reset);
q[2], reset);
endmodule
This is a structural description
Patrick Schaumont
Spring 2008
Simulation
In
These
ripple_carry_counter
some
behavioral
code
clk
reset
clk
reset
q[0:3]
q[0:3]
Patrick Schaumont
Spring 2008
Testbench
module stimulus;
reg clk;
reg reset;
wire [3:0] q;
ripple_carry_counter(q, clk,reset);
initial
clk = 1'b0;
always
#5 clk = ~clk;
initial
begin
reset = 1'b1;
#15 reset = 1'b0;
#180 reset = 1'b1;
#10 reset = 1'b0;
#20 $finish;
end
initial
$monitor($time, "
ECE 4514 Digital
Design II
endmodule
Lecture 2: Hierarchical Design
Testbench
module stimulus;
reg clk;
reg reset;
wire [3:0] q;
ripple_carry_counter(q, clk,reset);
initial
clk = 1'b0;
always
#5 clk = ~clk;
initial
begin
reset = 1'b1;
#15 reset = 1'b0;
#180 reset = 1'b1;
#10 reset = 1'b0;
#20 $finish;
end
initial
$monitor($time, "
ECE 4514 Digital
Design II
endmodule
Lecture 2: Hierarchical Design
Patrick Schaumont
Spring 2008
Modelsim
Patrick Schaumont
Spring 2008
Summary
Behavioral
Patrick Schaumont
Spring 2008