New Text Document
New Text Document
Design Verilog HDL to implement simple circuits using structural, data flow and
behavioural model.
module LogicGates(a,b,c,d,e);
input a,b,c;
output d,e;
wire w1;
and(w1,a,b);
not(e,c);
or(d,w1,e);
endmodule
testbench code
module TestModule;
// Inputs
reg a,b,c;
// Outputs
wire d,e;
// Instantiate the Unit Under Test (UUT)
LogicGates uut (.a(a),.b(b),.c(c),.d(d),.e(e));
initial begin
$dumpfile("dump.vcd");
$dumpvars(1);
end
initial begin
// Initialize Inputs
a = 0;b = 0;c = 0;
#5 a = 0;b = 0;c = 1;
#5 a = 0;b = 1;c = 0;
#5 a = 0;b = 1;c = 1;
#5 a = 1;b = 0;c = 0;
#5 a = 1;b = 0;c = 1;
#5 a = 1;b = 1;c = 0;
#5 a = 1;b = 1;c = 1;
#5;
$finish;
end
endmodule
Verilog code for dataflow model
module LogicGates(a,b,c,d,e);
input a,b,c;
output d,e;
assign d = (a&&b)||(!c);
assign e = !c;
endmodule