NAND GATE MODELLING METHODS:
Data Flow Modelling:
`timescale 1ns / 1ps module nandGate(output z, input x,y); assign z= ~(x&y); endmodule
Behavioral Modeling:
`timescale 1ns / 1ps module nandGate(output reg z, input x,y); always @ (x or y) begin if (x == 1'b1 & y == 1'b1) begin z = 1'b0; end else z = 1'b1; end endmodule
Gate Level Modelling:
`timescale 1ns / 1ps module nandGate(output z, input x,y); nand(z, x, y); endmodule
TESTBENCH:
`timescale 1ns / 1ps module nandGateTB(); reg tx,ty; wire tz; nandGate DUT(.z(tz),.x(tx),.y(ty)); initial begin tx=0; ty=0; #2 tx=0; ty=1; #2 tx=1; ty=0; #2 tx=1; ty=1; #2 $finish; end initial begin $monitor ($time, " tx=%d, ty=%d, tz=%d",tx,ty,tz); end initial begin $dumpfile("nandGateTB.vcd"); $dumpvars; end endmodule
Output:
0 tx=0, ty=0, tz=1 2 tx=0, ty=1, tz=1 4 tx=1, ty=0, tz=1 6 tx=1, ty=1, tz=0