Professional Documents
Culture Documents
Labt2 IE
Labt2 IE
Labt2 IE
LAB No: 02
Object:
Follow the Verilog system, data types and getting function with design convenient.
Task 01:
To design RS latch with nor gate by using data flow modeling.
Circuit Diagram:
Truth Table:
INPUT OUTPUT
R S Q QB
0 0 x x
0 1 1 0
1 0 0 1
1 1 0 0
Coding:
//desige module
module gate(Q,QB,R,S);
input R,S;
output Q,QB;
assign Q=~(R|QB);
assign QB=~(S|Q);
endmodule
//stimulus module
module talha;
reg R,S;
Task:02
To design SR latch with NAND gate by using data flow modeling.
Circuit Diagram:
INPUT OUTPUT
S R Q QB
0 0 1 1
0 1 1 0
1 0 0 1
1 1 0 1
Coding:
//desige module
module gate(Q,QB,R,S);
input R,S;
output Q,QB;
assign Q=~(R&QB);
assign QB=~(S&Q);
endmodule
//stimulus module
module talha;
reg R,S;
wire Q,QB;
gate g1(Q,QB,R,S);
initial
begin
R=1'b0;S=1'b0;
#20
R=1'b0;S=1'b1;
#20
Result:
Task 3: : To design RS flip flop with AND,NOR gate by using data flow modeling.
Circuit Diagram:
R S Q QB Clk
0 0 X X 0
0 1 1 0 1
1 0 0 1 0
1 1 0 clk 1
Coding:
//desige module
module gate(q,qb,r,s,clk);
input r,s,clk;
output q,qb;
wire a,b;
assign a=(r&clk);
assign b=(s&clk);
assign q=~(a|qb);
assign qb=~(b|q);
endmodule
//stimulus module
module talha;
reg r,s,clk;
wire q,qb;
gate g1(q,qb,r,s,clk);
initial
clk=1'b0;
Result:
Truth Table:
INPUT OUTPUT CLK
S R Q QB Clk
0 0 X X 0
0 1 0 1 1
1 0 1 0 0
1 1 1 clk 1
Coding:
//desige module
module gate(q,qb,s,r,clk);
input s,r,clk;
output q,qb;
wire a,b;
assign a=~(s&clk);
assign b=~(r&clk);
assign q=~(a&qb);
assign qb=~(b&q);
endmodule
//stimulus module
module talha;
Result:
Truth Table:
INPUT OUTPUT
A B Z
0 0 0
0 1 1
1 0 1
1 1 0
Coding:
//desige module
module gate(Z,A,B);
input A,B;
output Z;
assign Z=(A^B);
endmodule
//stimulus module
module talha;
reg A,B;
wire Z;
gate g1(Z,A,B);
initial
Result: