DSD2 5
DSD2 5
DSD2 5
• Net-list description
– built-in primitives gates
IN1
OUT1
IN2 X
endmodule
MODULE-5 ECE2003 – DIGITAL LOGIC DESIGN 103
DATAFLOW MODELING
❑ Data flow level description of a digital circuit is at higher level, it makes the
circuit description more compact as compared to design through gate
primitives
❑ The assignment statement start with the keyword assign and results are
assigned to nets
❑ Continuous assignment – most basic statement used to drive value onto net
HALF ADDER
module halfadder(s,c,a,b);
input a,b;
output s,c;
assign s=a^b;
assign c=a&b;
endmodule
endmodule
Sum, Cin (A B)
Carry, Cout = AB+ ACin + BCin .
DATAFLOW MODELING
module binary_to_gray(g,b);
input [3:0]b;
output[3:0]g;
assign g[3]= b[3];
assign g[2]= b[2]^b[3];
assign g[1]= b[1]^b[2];
assign g[0]= b[0]^b[1];
endmodule
reg c, d;
always@ (a or b or c)
wire c, d;
begin
assign c =a & b;
c =a & b;
assign d = c |b;
d = c |b;
42 end
Structural Vs Procedural
wire c, d; reg c, d;
assign c =a & b; always@ (a or b or c)
assign d = c |b; begin
c =a & b;
d = c |b;
end
43
BEHAVIORAL MODELING
❑ Behavioral model enables you to describe the system at a higher
level of abstraction
❑ The if, case, for loop, and while loop must appear inside an always
block
❑ For modules that have multiple always blocks all of the always
blocks are executed in parallel
MODULE-5 ECE2003 – DIGITAL LOGIC DESIGN 81
BEHAVIORAL MODELING
PROCEDURAL BLOCK - ALWAYS STATEMENT
❑ Always blocks are repeated executed until simulation is stopped. Similar to
initial block it begin its execution at start of simulation time 0.
module clock_gen;
reg clock, temp;
Blocking Non-blocking
◼ <variable> = <statement> ◼ <variable> <= <statement>
❑ The keywords begin and end are used to group statements into sequential blocks.
❑ Sequential blocks have the following characteristics:
❑ The statements in a sequential block are processed in the order they are specified
❑ A statement is executed only after its preceding statement completes execution
❑ If delay or event control is specified, it is relative to the simulation time when the previous statement in the
block completed execution
//Illustration 1: Sequential block without delay //Illustration 2: Sequential blocks with delay
reg X, Y; reg x, y;
reg [1:0] z, w; reg [1:0] z , w;
initial initial
Begin begin
x = l'bO; x = l'bo; //completes at simulation time 0
y = l‘b1; #5 y = l'bl; //completes at simulation time 5
z = {x, y}; #10 z = {x, y}; //completes at simulation time 15
w = {y, x}; #20 w = {y, x); //completes at simulation time 35
End end