Updated DSDV Lab Manual - 2023
Updated DSDV Lab Manual - 2023
CHICKBALLAPUR-562101
SEMESTER: III
YEAR: II
PREPARED BY
VISION OF DEPARTMENT
MISSION OF DEPARTMENT
Establishing State of the Art Laboratory facilities and Infrastructure to develop the spirit of
Innovation and Entrepreneurship
Nurturing the Students with Technical Expertise along with Professional Ethics to provide
solutions for Social Needs
Encourage Life Long Learning And Research among the Students and Faculty
PEO1: Graduates of the program will have successful technical and professional career in
PEO3: Graduates of the program will exhibit good interpersonal skills, leadership qualities
and adapt themselves for lifelong learning.
PROGRAMME OUTCOMES:
1. Engineering Knowledge: Apply knowledge of mathematics, science, engineering fundamentals
and an engineering specialization to the solution of complex engineering problems.
2. Problem Analysis: Identify, formulate, research literature and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences
and engineering sciences
3. Design/ Development of Solutions: Design solutions for complex engineering problems and
design system components or processes that meet specified needs with appropriate consideration
for public health and safety, cultural, societal and environmental considerations.
4. Conduct investigations of complex problems using research-based knowledge and research
methods including design of experiments, analysis and interpretation of data and synthesis of
information to provide valid conclusions.
5. Modern Tool Usage: Create, select and apply appropriate techniques, resources and modern
engineering and IT tools including prediction and modeling to complex engineering activities with an
under- standing of the limitations.
6. The Engineer and Society: Apply reasoning informed by contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to
professional engineering practice.
CO – PSO MAPPING
CO PSO1 PSO2
CO202.1:Apply optimization techniques to simplify Boolean function. 2 -
CO202.2:Analyze and design combinational logic circuits. 3 -
CO202.3:Apply the knowledge of digital electronics to construct Combinational
3 -
and Sequential systems useful for digital system design.
CO202.4:Model Combinational (adders, subtractors, multiplexers) and
3 2
sequential circuits using Verilog
CO202.5:Develop a simple digital system using modern tool 3 2
avg 2.8 2
1: Slightly 2: Moderately 3: Substantially
FOR 25 MARKS
1. CONTINUOUS EVALUATION 15
module sop(y,a,b,c,d);
output y;
input a,b,c,d;
wire w1,w2;
assign w1=b&d;
assign w2=a&d;
assign y=w1|w2;
endmodule
module tb;
reg a,b,c,d;
wire y;
sop uut(y,a,b,c,d);
initial
begin
a=0;b=0;c=0;d=0;
#100 a=0;b=0;c=0;d=1;
#100 a=0;b=0;c=0;d=1;
#100 a=0;b=0;c=1;d=1;
#100 a=0;b=1;c=0;d=1;
#100 a=0;b=1;c=1;d=0;
#100 a=0;b=1;c=1;d=1;
#100 a=1;b=0;c=0;d=1;
#100 a=0;b=1;c=1;d=1;
#100 a=1;b=1;c=0;d=1;
#100 a=1;b=0;c=1;d=1;
end
endmodule
module tb1();
wire y;
reg a,b,c,d;
pos uut(.y(y),.a(a),.b(b),.c(c),.d(d));initial
begin a=0;b=0;c=0;d=0;
#100 a=0;b=0;c=0;d=1;
#100 a=0;b=0;c=0;d=1;
#100 a=0;b=0;c=1;d=1;
#100 a=0;b=1;c=0;d=1;
#100 a=0;b=1;c=1;d=0;
#100 a=0;b=1;c=1;d=1;
#100 a=1;b=0;c=0;d=1;
#100 a=0;b=1;c=1;d=1;
#100 a=1;b=1;c=0;d=1;
#100 a=1;b=0;c=1;d=1;
end
endmodule
module ha(a,b,sum,ca);
input a,b;
output sum,ca;
assign sum=a^b;
assign ca=a&b; endmodule
module tb2;
reg a,b;
wire sum,ca;
ha uut(.a(a),.b(b),.sum(sum),.ca(ca));
initial
begin
a=0;b=0;
#100; a=0;b=1;
#100; a=1;b=0;
#100; a=1;b=1;
end
endmodule
2)b)Realize full adder circuit using verilog dataflow description.
module fa(a,b,c,sum,ca);
input a,b,c;
output sum,ca;
assign sum=a^b^c;
assign ca=(a&b)|(b&c)|(c&a);endmodule
module tb3;
reg a,b,c;
wire sum,ca;
fa uut(a,b,c,sum,ca);
initial
begin a=0;b=0;c=0;
#100 a=0;b=0;c=1;
#100 a=0;b=1;c=0;
#100 a=0;b=1;c=1;
#100 a=1;b=0;c=0;
#100 a=1;b=0;c=1;
#100 a=1;b=1;c=0;
#100 a=1;b=1;c=1;
end
endmodule
module tb2;
reg a,b;
wire dif,br;
ha uut(.a(a),.b(b),.dif(dif),.br(br));
initial
begin a=0;b=0;
#100; a=0;b=1;
#100; a=1;b=0;
#100; a=1;b=1;
end
endmodule
module tb4;
reg a,b,c;
wire dif,br;
fs uut(a,b,c,dif,br);
initial
begin a=0;b=0;c=0;
#100 a=0;b=0;c=1;
#100 a=0;b=1;c=0;
#100 a=0;b=1;c=1;
#100 a=1;b=0;c=0;
#100 a=1;b=0;c=1;
#100 a=1;b=1;c=0;
#100 a=1;b=1;c=1;
end
endmodule
module tbalu;
reg [3:0]a,b,opcode;
reg enable;
wire [7:0]y;
alu uut(.a(a),.b(b),.opcode(opcode),.enable(enable),.y(y));
initial
begin a=4'b1010;b=4'b0111;opcode=4'b0001;enable=1;
#100; opcode=4'b0001; #100;opcode=4'b0010;
b3 b2 b1 b0
g3 g2 g1 g0
module bintogray(b,g);
input [3:0] b;
output [3:0] g;
reg [3:0] g;
always@(b)
begin
g[3]=b[3];
g[2]=b[3] ^ b[2];
g[1]=b[2] ^ b[1];
g[0]=b[1] ^ b[0];
end
endmodule
module btog;
reg [3:0] b;
wire [3:0] g;
bintogray uut(b,g);
initial
begin
b=4'b0101;
#100 b=4'b1100;
SJCIT , ECE Department Page 12
Digital System Design using Verilog Lab [BEC302]
#100 b=4'b1011;
#100 b=4'b1001;
#100 b=4'b0111;
end
endmodule
g3 g2 g1 g0
+ + +
b3 b2 b1 b0
module graytobin(b,g);
input [3:0] g;
output [3:0] b;
reg [3:0] b;
always@(g)
begin
b[3]=g[3];
b[2]=g[3] ^ g[2];
b[1]=g[3] ^ g[2] ^ g[1];
b[0]=g[3] ^ g[2] ^ g[1] ^ g[0];
end
endmodule
module gtob;
reg [3:0] g;
wire [3:0] b;
graytobin uut(b,g);
initial
begin
g=4'b0101;
#100 g=4'b1100;
#100 g=4'b1011;
#100 g=4'b1001;
#100 g=4'b0111;
end
endmodule
module tb;
reg [3:0]b;
wire [3:0]e;
btoe utt(b,e);
initial
begin
b=4'b0010; #100
b=4'b100;
#100 b=4'b1010;
#100 b=4'b1100;
end
endmodule
module tb11;
reg [3:0]e;
wire [3:0]b;
etob utt(b,e);
initial
begin
e=4'b0010; #100
e=4'b100;
#100 e=4'b1010;
#100 e=4'b1100;
end
endmodule
I0
8:1 Mux
I1 OUTPUT
I7
S2 S1 S0
3'd5 : y = d[5];
3'd6 : y = d[6];
3'd7 : y = d[7];
endcase
end
end
endmodule
module tb;
reg [7:0]d;
reg reset;
reg [2:0]sel;
wire y;
mux uut(d,reset,sel,y);
initial
begin
reset=1’b1;
sel=0;
d=8’b110010x0;
#10 reset=0;
#10 sel=3’d1;
#10 sel=3’d2;
#10 sel=3’d3;
#10 sel=3’d4;
#10 sel=3’d5;
#10 sel=3’d6;
#10 sel=3’d7;
end
endmodule
module encoder(din,reset,dout);
input [7:0] din;
input reset; output
[2:0] dout;
reg [2:0] dout;
always @(din,reset)
begin
if (reset == 1'b1)
dout = 3'b000; else
begin
case (din)
8'b00000001 : dout=3'b000;
8'b00000010 : dout=3'b001;
8'b00000100 : dout=3'b010;
8'b00001000 : dout=3'b011;
8'b00010000 : dout=3'b100;
8'b00100000 : dout=3'b101;
8'b01000000 : dout=3'b110;
8'b10000000 : dout=3'b111;
default : dout=3'b000;
endcase
end
end
endmodule
module tb22;
reg [7:0] din;
reg reset;
wire [2:0] dout;
encoder uut(din,reset,dout);
initial
begin
reset=1;
din=8’b00000001;
#100 reset=0;
#100 din=8’b00000001;
#100 din=8’b00000010;
#100 din=8’b00000100;
#100 din=8’b00001000;
#100 din=8’b00010000;
#100 din=8’b00100000;
#100 din=8’b01000000;
#100 din=8’b10000000;
end
endmodule
module encoder(din,reset,dout);
input [7:0] din;
input reset; output
[2:0] dout;
reg [2:0] dout;
always @(din,reset)
begin
if (reset == 1'b1)
dout = 3'b000; else
begin
case (din)
8'bxxxxxxx1:dout=3'b000;
8'bxxxxxx10:dout=3'b001;
8'bxxxxx100:dout=3'b010;
8'bxxxx1000:dout=3'b011;
8'bxxx10000:dout=3'b100;
8'bxx100000:dout=3'b101;
8'bx1000000 : dout=3'b110;
8'b10000000 : dout=3'b111;
default : dout=3'b000;
endcase
end
end
endmodule
module tb22;
reg [7:0] din;
reg reset;
wire [2:0] dout;
encoder uut(din,reset,dout);
initial
begin
reset=1;
din=8’b00000001;
#100 reset=0;
#100 din=8’b11000001;
#100 din=8’b00010010;
#100 din=8’b01100100;
#100 din=8’b11101000;
#100 din=8’b11110000;
#100 din=8’b01100000;
#100 din=8’b11000000;
#100 din=8’b10000000;
end
endmodule
module tb13;
reg y,rst;
reg [2:0]sel;
wire [7:0]d;
demux ttt(.rst(rst),.y(y),.sel(sel),.d(d));
initial
begin
rst=1;sel=0;
#100;
#50 rst=0;y=1;
#50 sel=3'd0;
#50 sel=3'd1;
#50 sel=3'd2;
#50 sel=3'd3;
#50 sel=3'd4;
#50 sel=3'd5;
#50 sel=3'd6;
#50 sel=3'd7;
end
endmodule
module tb22;
reg en;
reg [2:0]ip;
wire [7:0]op;
decoder uut(ip,op,en);initial
begin
en=1;
#100 ip=3'b010;
#100 en=0;
#100 ip=3'd1;
#100 ip=3'd2;
#100 ip=3'd3;
#100 ip=3'd4;
#100 ip=3'd5;
#100 ip=3'd6;
#100 ip=3'd7;
end
initial
$monitor ($time,"output is %b",op);
endmodule
6) c) 2 bit comparator:
module comparator(a,b,en,aeqb,agtb,altb);input [1:0]a;
input [1:0]b;
input en;
output aeqb,agtb,altb;reg
aeqb,agtb,altb;
always@(a,b,en) begin
if(en==1)
begin
if(a==b)
begin
aeqb=1;
agtb=0;
altb=0;
end
if(a>b)
begin
aeqb=0;
agtb=1;
altb=0;
end
if(a<b)
begin
aeqb=0;
agtb=0;
altb=1;
end
end
module tstbench();
reg [1:0]A;
reg [1:0]B;
reg EN;
wire e,g,l;
comparator n1(.a(A),.b(B),.en(EN),.aeqb(e),.agtb(g),.altb(l));
initial
begin
A=2'b00;B=2'b00;EN=0;
#100;EN=1;
#10 A=2'b00;B=2'b01;
#10 A=2'b10;B=2'b10;
#10 A=2'b11;B=2'b01;
end
endmodule
end
qb = ~q;
end
endmodule
module stimulus;
reg [1:0]sr;
reg clk,rst;
wire q,qb;
srff ff1(.sr(sr),.clk(clk),.rst(rst),.q(q),.qb(qb));
initial
begin
$monitor($time, "rst=%b sr=%b, clk=%b, q=%b qb=%b",rst,sr,clk,q,qb);
sr=2'b00;
clk=0;
rst=0;
#50 rst=1;
sr=2'b01;
#50 rst=0;
sr=2'b01;
#50 sr=2'b10;
#50 sr=2'b11;
#50 sr=2'b00;
#50 sr=2'b10;
#50 sr=2'b01;
#50 sr=2'b10;
#50 sr=2'b11;
#50 sr=2'b00;
#50 sr=2'b01;
#50 sr=2'b10;
end
always #5 clk=~clk;
endmodule
b) D Flipflop
module dff(d,clk,rst,q,qb);
input d;
input clk,rst;
output q,qb; reg
q,qb;
always@(posedge clk or posedge rst)
begin
if(rst==1'b1)
begin
q<=1'd0;
qb<=1'd1;
end
else
begin
q<=d; qb<=~d;
end
end
endmodule
module stimulus1;reg
d,clk,rst;
wire q,qb;
dff d1(d,clk,rst,q,qb);
initial
begin
clk=0;
rst=1;
#10 rst=0;
d=0;
#10 d=1;
#10 d=0;
#10 rst=1;
d=0;
#10 rst=1;
d=1;
#10 rst=0;
d=1;
end
always #5 clk=~clk;
endmodule
c) T Flipflop:
module tff(t,clk,rst,q,qb);
input t;
input clk,rst;
output q,qb;
reg q,qb;
always@(posedge clk )
begin
if(rst==1'b1)
begin
q<=1'd0;
qb<=1'd1;
end
else
begin
if(t==1'b1)
q=~q;
else q=q;
end
qb=~q;
end
endmodule
module stimulus2;
reg t,clk,rst;
wire q,qb;
tff t1(t,clk,rst,q,qb);
initial
begin
clk=0;rst=1; #10
rst=0; t=0;
#10 t=1;
#10 t=0;
#10 rst=1; t=0;
#10 rst=1; t=1;
#10 rst=0; t=1;
#100 rst=0; t=0;
end
always #10 clk=~clk;
endmodule
d) JK Flipflop:
module jkff(jk,clk,rst,q,qb);
input [1:0]jk;
input clk;
input rst;
output q,qb;
reg q,qb;
always@(posedge clk)
begin
if(rst==1'b1)
q=1'd0;
else
begin
case(jk)
2'b00:q=q;
2'b01:q=1'd0;
2'b10:q=1'd1;
2'b11:q=~q;
endcase end
qb=~q; end
endmodule
module test;
reg [1:0]jk;
reg clk,rst;
wire q,qb;
jkff ff2(jk,clk,rst,q,qb);
initial
begin
jk=2'b01;
clk=0;
rst=0;#50
#10 jk=2'b10;
rst=1;
#30 jk=2'b01;
#30 rst=0;jk=2'b00;
#30 jk=2'b01;
#30 jk=2'b10;
#30 jk=2'b11;
#100;
#30 jk=2'b00;
#30 jk=2'b10;
end
always #10 clk=~clk;
endmodule
begin
if(rst==1'b1)
qout=4'b0000;
else
qout=qout+1;
end
endmodule
module test;
reg clk,rst;
wire [3:0]qout;
counter1 uut(clk,rst,qout);
initial
begin
clk=0; rst=1;
#10 rst=0;
#200 rst=1;
end
always #5 clk=~clk;
endmodule
module stimulus;
reg rst,clk;
wire [3:0]qout;
counter4 tb(rst,clk,qout);initial
begin clk=0;
rst=1;
#10;
#10 rst=0;
#200 rst=1;
end
always #5 clk=~clk;
endmodule