NAND Gate Behavioral Style
Two-Input NAND Function in Behavioral Style
Design Code
_________________________________________________________________________________
module NAND_function(output f, input a, b);
wire f = a~&b; // Equivalent form
endmodule
________________________________________________________________________________
Test Bench
________________________________________________________________________________
module NAND_test;
reg x, y;
wire z;
NAND_function F1
(.a(x), .b(y), .f(z));
initial
begin
$monitor("a=%b b=%b \t f=%b", x,y,z); // Tab format
x = 1'b0; y =
1'b0;
#5 x = 1'b0; y =
1'b1;
#5 x = 1'b1; y =
1'b0;
#5 x = 1'b1; y =
1'b1;
$finish;
end
endmodule
_________________________________________________________________________________Output
_______________________
a=0 b=0 f=1
a=0 b=1 f=1
a=1 b=0 f=1
a=1 b=1 f=0
_______________________1. Continuous assignment (assign)
- There are two ways of defining continuous assignment
- assign net = net or register; e.g. assign f = a&b;
- net <Variable name> = net or register; e.g. wire f = a&b; It is equivalent to wire f; f= a&b;
2. Strings
- \t : Tab
- \n : new liner
- \\ : \
- \" : "
- %%: %
- \ddd : Octal digits
Comments
Post a Comment