Professional Documents
Culture Documents
Lab-4
OBJECT:-
Intro to dataflow Modeling.
TASK#01(a):-
To design and implement AND gate in Verilog using dataflow modeling.
CIRCUIT DIAGRAM:-
TRUTH TABLE:-
CODING:-
//Design Module
module gate(c,a,b);
input a,b;
output c;
assign c=a&b;
endmodule
//Stimulus Module
module xyz;
RESULT:-
TASK#01(b):-
To design and implement OR gate in Verilog using dataflow modeling.
CIRCUIT DIAGRAM:-
CODING:-
//Design Module
module gate(z,x,y);
input x,y;
output z;
assign z=x|y;
endmodule
//Stimulus Module
module pqr;
reg x,y;
wire z;
gate g1(z,x,y);
initial
begin
x=1'b0;
y=1'b0;
#20
x=1'b0;
y=1'b1;
#20
x=1'b1;
y=1'b0;
#20
x=1'b1;
y=1'b1;
#20
$finish;
end
RESULT:-
TASK#01(c):-
To design and implement NAND gate in Verilog using dataflow modeling.
CIRCUIT DIAGRAM:-
TRUTH TABLE:-
CODING:-
//Design Module
module gate(c,a,b);
input a,b;
output c;
assign c=~(a&b);
endmodule
//Stimulus Module
module Qadeer;
reg a,b;
wire c;
gate g1(c,a,b);
RESULT:-
TASK#01(d):-
To design and implement NOR gate in Verilog using dataflow modeling.
CIRCUIT DIAGRAM:-
TRUTH TABLE:-
//Stimulus Module
module savita;
reg x,y;
wire z;
gate g1(z,x,y);
initial
begin
x=1'b0;
y=1'b0;
#20
x=1'b0;
y=1'b1;
#20
x=1'b1;
y=1'b0;
#20
x=1'b1;
y=1'b1;
#20
$finish;
end
endmodule
RESULT:-
SIR SYED UNIVERSITY OF ENGG. AND TECNOLOGY 6
TASK#01(e):-
To design and implement NOT gate in Verilog using dataflow modeling.
CIRCUIT DIAGRAM:-
TRUTH TABLE:-
CODING:-
//Design Module
module gate(out,x);
input x;
output out;
assign out=~x;
endmodule
//Stimulus Module
module mallu;
reg x;
wire out;
gate g1(out,x);
initial
begin
x=1'b0;
#20
x=1'b1;
RESULT:-
TASK#01(f):-
To design and implement XOR gate in Verilog using dataflow modeling.
CIRCUIT DIAGRAM:-
TRUTH TABLE:-
CODING:-
//Design Module
module gate(r,p,q);
input p,q;
output r;
assign r=p^q;
endmodule
//Stimulus Module
module ikmkb;
RESULT:-
TASK#02:-
To design D Flip Flop.
CIRCUIT DIAGRAM:-
CODING:-
//Design Module
module dff(q,qb,d,clk);
input d,clk;
output q,qb;
wire a,b,dbar;
assign dbar=~d;
assign a=~(d&clk);
assign b=~(dbar&clk);
assign q=~(a&qb);
assign qb=~(b&q);
endmodule
//Stimulus Module
module japan;
RESULT:-
TASK#03:-
To design 1 Bit Full Adder.
CIRCUIT DIAGRAM:-
EQUATIONS:-
Sum=a.b.Cin+a’.b.Cin+a.b’.Cin’
Cout=a.b+b.Cin+a.Cin
CODING:-
//Design Module
module obfa(sum,Cout,a,b,Cin);
input a,b,Cin;
output sum,Cout;
assign sum=(a&b&Cin)|((~a)&b&(~Cin))|(a&(~b)&(~Cin))|((~a)&(~b)&Cin);
assign Cout=(a&b)|(b&Cin)|(a&Cin);
endmodule
//Stimulus Module
module sir;
reg a,b,Cin;
wire sum,Cout;
obfa fa(sum,Cout,a,b,Cin);
initial
begin
a=1'b0;
b=1'b0;
Cin=1'b0;
#20
a=1'b0;
b=1'b1;
TASK#04:-
To design Master Slave JK Flip Flop.
CIRCUIT DIAGRAM:-
TRUTH TABLE:-
J k Clk clr q qb
0 0 0 0 0 1
CODING:-
//Design Module
module MSJKFF(q,qb,j,k,clr,clk);
input j,k,clr,clk;
output q,qb;
wire a,b,c,x,y,z,clkb;
assign a=~(j&clr&clk&qb);
assign b=~(a&y);
assign c=~(b&clkb);
assign q=~(c&qb);
assign x=~(clk&k&q); j=1'b0;
assign y=~(x&b&clr); k=1'b1;
assign z=~(y&clkb); clr=1'b1;
assign qb=~(z&q&clr); clk=1'b1;
assign clkb=~clk; #30
endmodule j=1'b1;
k=1'b0;
//Stimulus Module clk=1'b0;
module bhutto; clr=1'b1;
reg j,k,clr,clk; #30
wire q,qb; j=1'b1;
MSJKFF ff(q,qb,j,k,clk,clr); k=1'b1;
initial clr=1'b1;
begin clk=1'b1;
j=1'b0; #30
k=1'b0; $finish;
clr=1'b0; end
clk=1'b0; endmodule
#30