VERILOG BASIC LOGIC GATES
AND GATE
`timescale 1ns / 1ps
module and_gate(
input a,b,
output c
);
assign c = a & b;
endmodule
TEST FIXTURE
`timescale 1ns / 1ps
module tf_testbenchlog;
// Inputs
reg a;
reg b;
// Outputs
wire c;
// Instantiate the Unit Under Test (UUT)
and_gate uut (
.a(a),
.b(b),
.c(c)
);
initial begin
// Initialize Inputs
a = 0;
b = 0;
// Wait 100 ns for global reset to finish
#100;
a = 1'b0;
b = 1'b0;
#100;
a = 1'b0;
b = 1'b1;
#100;
a = 1'b1;
b = 1'b0;
#100;
a = 1'b1;
b = 1'b1;
// Add stimulus here
end
endmodule
OR GATE
`timescale 1ns / 1ps
module or_gate(
input a,b,
output c
);
or (c,a,b);
endmodule
TEST FIXTURE
`timescale 1ns / 1ps
module tf_testfixture;
// Inputs
reg a;
reg b;
// Outputs
wire c;
// Instantiate the Unit Under Test (UUT)
or_gate uut (
.a(a),
.b(b),
.c(c)
);
initial begin
// Initialize Inputs
a = 0;
b = 0;
// Wait 100 ns for global reset to finish
#100;
a = 1'b0;
b = 1'b0;
#100;
a = 1'b0;
b = 1'b1;
#100;
a = 1'b1;
b = 1'b0;
#100;
a = 1'b1;
b = 1'b1;
// Add stimulus here
end
endmodule
NOT GATE
`timescale 1ns / 1ps
module not_gate(
input a,
output y
);
not (y,a);
endmodule
TEST FIXTURE
`timescale 1ns / 1ps
module tf_testfixture;
// Inputs
reg a;
// Outputs
wire y;
// Instantiate the Unit Under Test (UUT)
not_gate uut (
.a(a),
.y(y)
);
initial begin
// Initialize Inputs
a = 0;
// Wait 100 ns for global reset to finish
#100;
a = 1'b0;
#100;
a = 1'b1;
#100;
a = 1'b0;
#100;
a = 1'b1;
// Add stimulus here
end
endmodule
NAND GATE
`timescale 1ns / 1ps
module nand_gate(
input a,b,
output c
);
nand (c,a,b);
endmodule
TEST FIXTURES
`timescale 1ns / 1ps
module tf_testfixtures;
// Inputs
reg a;
reg b;
// Outputs
wire c;
// Instantiate the Unit Under Test (UUT)
nand_gate uut (
.a(a),
.b(b),
.c(c)
);
initial begin
// Initialize Inputs
a = 0;
b = 0;
// Wait 100 ns for global reset to finish
#100;
a = 1'b0;
b = 1'b0;
#100;
a = 1'b0;
b = 1'b1;
#100;
a = 1'b1;
b = 1'b0;
#100;
a = 1'b1;
b = 1'b1;
// Add stimulus here
end
endmodule
NOR GATE
`timescale 1ns / 1ps
module nor_gate(
input a,b,
output c
);
nor (c,a,b);
endmodule
TEST FIXTURE
`timescale 1ns / 1ps
module tf_testfixture;
// Inputs
reg a;
reg b;
// Outputs
wire c;
// Instantiate the Unit Under Test (UUT)
nor_gate uut (
.a(a),
.b(b),
.c(c)
);
initial begin
// Initialize Inputs
a = 0;
b = 0;
// Wait 100 ns for global reset to finish
#100;
a = 1'b0;
b = 1'b0;
#100;
a = 1'b0;
b = 1'b1;
#100;
a = 1'b1;
b = 1'b0;
#100;
a = 1'b1;
b = 1'b1;
// Add stimulus here
end
endmodule
XOR GATE
`timescale 1ns / 1ps
module xor_gate(
input a,b,
output c
);
xor (c,a,b);
endmodule
TEST FIXTURE
`timescale 1ns / 1ps
module tf_testfixture;
// Inputs
reg a;
reg b;
// Outputs
wire c;
// Instantiate the Unit Under Test (UUT)
xor_gate uut (
.a(a),
.b(b),
.c(c)
);
initial begin
// Initialize Inputs
a = 0;
b = 0;
// Wait 100 ns for global reset to finish
#100;
a = 1'b0;
b = 1'b0;
#100;
a = 1'b0;
b = 1'b1;
#100;
a = 1'b1;
b = 1'b0;
#100;
a = 1'b1;
b = 1'b1;
// Add stimulus here
end
endmodule
XNOR GATE
`timescale 1ns / 1ps
module xnor_gate(
input a,b,
output c
);
xnor (c,a,b);
endmodule
TEST FIXTURE
`timescale 1ns / 1ps
module tf_testfixture;
// Inputs
reg a;
reg b;
// Outputs
wire c;
// Instantiate the Unit Under Test (UUT)
xnor_gate uut (
.a(a),
.b(b),
.c(c)
);
initial begin
// Initialize Inputs
a = 0;
b = 0;
// Wait 100 ns for global reset to finish
#100;
a = 1'b0;
b = 1'b0;
#100;
a = 1'b0;
b = 1'b1;
#100;
a = 1'b1;
b = 1'b0;
#100;
a = 1'b1;
b = 1'b1;
// Add stimulus here
end
endmodule
No comments:
Post a Comment