Pages

Tuesday 11 July 2017

Verilog code for NAND gate

Gate Level Modeling

module nand_gate(c,a,b);
input a,b;
output c;
nand (c,a,b);
endmodule

Data Flow Modeling

module nand_data(c,a,b);
input a,b;
output c;
assign c =~(a&b);
endmodule

Behavioral Modeling

module nand_beh(c,a,b);
input a,b;
output c;
reg c;
always@(a,b)

begin
if (a==1 & b==1)
c=0;
else
c=1;
end
endmodule

Test Bench

module nand_test;
reg a,b;
wire c;
nand_gate  nand_test(c,a,b);
initial
begin
#000 a=0;b=0;
#100 a=0;b=1;
#100 a=1;b=0;
#100 a=1;b=1;
end
initial
begin
$monitor($time,"a=%b,b=%b,c=%b",a,b,c);
end
endmodule

Truth Table



Input A
Input B
Output c
0
0
1
0
1
1
1
0
1
1
1
0


RTL Viewer

RTL Simulation

 




1 comment:

  1. We have sell some products of different custom boxes.it is very useful and very low price please visits this site thanks and please share this post with your friends. Gate code

    ReplyDelete