Escolar Documentos
Profissional Documentos
Cultura Documentos
LAB # 01
TASK# 01: To implement AND-gate using gate level modeling in Verilog HDL
Figure 1 AND-gate
CODING:
// design module module SAROSH; a=1'b0; b=1'b1; #20
module andgate(out,a,b); reg a,b; a=1'b1; b=1'b0; #20
input a,b; wire out; a=1'b1; b=1'b1; #20
output out; andgate g1(out,a,b); $finish;
and a1(out,a,b); initial end
endmodule begin endmodule
//stimulus module a=1'b0; b=1'b0; #20
TIMING DIAGRAM:
SSUET Page 1
INTEGRATED ELECTRONICS 2016-EE-105
TASK# 02: To implement NAND-gate using gate level modeling in Verilog HDL
CODING:
// design module //stimulus module a=1'b0; b=1'b0; #20
module nandgate(out,a,b); module SAROSH; a=1'b0; b=1'b1; #20
input a,b; reg a,b; a=1'b1; b=1'b0; #20
output out; wire out; a=1'b1; b=1'b1; #20
nand a1(out,a,b); nandgate g1(out,a,b); $finish;
endmodule initial end
begin endmodule
TIMING DIAGRAM:
TASK# 03: To implement OR-gate using gate level modeling in Verilog HDL
A+B
CODING:
SSUET Page 2
INTEGRATED ELECTRONICS 2016-EE-105
TIMING DIAGRAM:
TASK# 04: To implement NOR -gate using gate level modeling in Verilog HDL
CIRCUIT DIAGRAM:
A+B
TRUTH TABLE:
Table 3 NOR-gate truth table
CODING:
//design module
module norgate(out,a,b);
input a,b;
output out;
nor a1(out,a,b);
endmodule
//stimulus module
module SAROSH;
reg a,b;
wire out;
SSUET Page 3
INTEGRATED ELECTRONICS 2016-EE-105
norgate a2(out,a,b);
initial
begin
a=1'b0; b=1'b0;
#20
a=1'b0; b=1'b1;
#20
a=1'b1; b=1'b0;
#20
a=1'b1; b=1'b1;
#20
$finish;
end
endmodule
Timing Diagram:
TASK# 05: To implement XOR-gate using gate level modeling in Verilog HDL
CIRCUIT DIAGRAM:
TRUTH TABLE:
module xorgate(out,a,b);
input a,b;
output out;
wire x,y,c,d;
SSUET Page 4
INTEGRATED ELECTRONICS 2016-EE-105
not n1(c,b);
not n2(d,a);
and a1(x,a,c);
and a2(y,b,d);
or o1(out,x,y);
endmodule
//stimulus
module SAROSH;
reg a,b;
wire out;
xorgate b1(out,a,b);
initial
begin
a=1'b0;b=1'b0;#20
a=1'b0;b=1'b1;#20
a=1'b1;b=1'b0;#20
a=1'b1;b=1'b1;#20
$finish;
end
endmodule
TIMING DIAGRAM:
SSUET Page 5
INTEGRATED ELECTRONICS 2016-EE-105
TASK# 06: To implement Not-gate using gate level modeling in Verilog HDL
Ciruit diagram :
Coding
//Design Module
module gate(c,a);
input a;
output c;
not a1(c,a);
endmodule
//Stimulus Module
module SAROSH;
reg a;
wire c;
gate g1(c,a);
initial
begin
a=1'b0;
#20
a=1'b1;
#20
$finish;
end
endmodule
SSUET Page 6