Chapter 6
Chapter 6
Samir Palnitkar
Dataflow modeling
► Gate level modeling works well for small
circuits
► As gate densities on chip increasing rapidly
dataflow modeling has become very
important
► Dataflow: In terms of the data flow between
registers and how a designing processes
data rather than instantiation of individual
gates
Dr. Behnam Arad 2
EEE/CSC-273
Continuous assignment
► Most basic statement in dataflow modeling
► Drives a value onto a net
► Nets: connections between hardware elements
Declared with wire
Default value z
Get output of drivers (no value = z)
Class net
► Wire, wand, wor, tri, triand, trior, trireg
Continuous assignment replaces gates
In1
In2
Out (?)
10 20 30 60 70 80 85
Dr. Behnam Arad 7
EEE/CSC-273
Delays
In1
In2
xxxx
out
10 20 30 60 70 80 85
Dr. Behnam Arad 8
EEE/CSC-273
Delays (continue..)
► Implicit continuous assignment delay
wire out;
Assign #10 out = in1 & in2;
wire out;
Assign #10 out = in1 & in2;
► Value set: 0, 1, x, z
► Parameter port_id = 5
► Expression returns 0 or 1 or x
► === , !== Æ 0 , 1
Can compare x and z values
►Z is treated as an x
► Take on eoperand
► 1_bit result
► {4{A}} Æ 4’b1111;
► e.g.
assign addr_bus = drive_enable ? Addr_out : 32’bz;
assign out = control ? in1 : in0;
// 4-to-1 multiplexer. Port list is taken exactly from the I/O diagram.
module mux4_to_1 (out, i0, i1, i2, i3, s1, s0);
endmodule
endmodule
endmodule
// Set up variables
reg [3:0] A, B;
reg C_IN;
wire [3:0] SUM;
wire C_OUT;
// Stimulate inputs
initial begin
A = 4'd0; B = 4'd0; C_IN = 1'b0;
#5 A = 4'd3; B = 4'd4;
#5 A = 4'd2; B = 4'd5;
#5 A = 4'd9; B = 4'd9;
#5 A = 4'd10; B = 4'd15;
#5 A = 4'd10; B = 4'd5; C_IN = 1'b1;
end
endmodule
Dr. Behnam Arad 28
EEE/CSC-273
Example 6-5 4-bit Full Adder With Carry Lookahead
// Internal wires
wire p0,g0, p1,g1, p2,g2, p3,g3;
wire c4, c3, c2, c1;
// Compute Sum
assign sum[0] = p0 ^ c_in,
sum[1] = p1 ^ c1,
sum[2] = p2 ^ c2,
sum[3] = p3 ^ c3;
endmodule
Dr. Behnam Arad 30
EEE/CSC-273
Example 6-6 Verilog Code for Ripple Counter
// Ripple counter
module counter(Q , clock, clear);
// I/O ports
output [3:0] Q;
input clock, clear;
endmodule
// I/O ports
output q;
input clk, clear;
endmodule
// Internal variables
wire s, sbar, r, rbar,cbar;
// Input latches
assign sbar = ~(rbar & s),
s = ~(sbar & cbar & ~clk),
r = ~(rbar & ~clk & s),
rbar = ~(r & cbar & d);
// Output latch
assign q = ~(s & qbar),
qbar = ~(q & r & cbar);
endmodule
initial
$monitor($time, " Count Q = %b Clear= %b", Q[3:0],CLEAR);
initial
$gr_waves("clk", CLOCK, "Clear", CLEAR,"Q", Q[3:0],"Q0", Q[0],"Q1", Q[1],"Q2", Q[2],Q3", Q[3]);
► endmodule
Dr. Behnam Arad 35
EEE/CSC-273
Dr. Behnam Arad 36
EEE/CSC-273