Verilog - Multiplexer PDF
Verilog - Multiplexer PDF
The purposes of the lab activity described here are as follows: 1) 2) 3) To learn about digital system design using Verilog HDL. To design Adder, decoder, multiplexer using Verilog HDL. To observe the simulation output of the Verilog design module using test bench.
Theory:
Verilog HDL is one of the two most common Hardware Description Languages (HDL) used by integrated circuit (IC) designers. The other one is VHDL. The hardware description language is used to describe a digital system such as a network switch, a flip flop or a memory. It implies that any hardware can be described at any level using HDL.
Verilog as well as test bench coding for 4:1 multiplexer is module Mux(a,b,c,s,s1,s2,d); input a,b,c,s,s1,s2; output d; reg d; always @(s1 or s2) if (s1==1'b0 && s2==1'b0)begin d=a; end else if (s1==1'b0 && s2==1'b1)begin d=b; end else if (s1==1'b1 && s2==1'b0)begin d=c; end else begin d=s; end endmodule
module tb_Mux(); reg a1,b1,c1,s5,s15,s25; wire d1; initial begin a1=2'b00;b1=2'b01;c1=2'b10;s5=2'b11; s15=1'b0;s25=1'b0; #10; s15=1'b0;s25=1'b1; #10; s15=1'b1;s25=1'b0; #10; s15=1'b1;s25=1'b1; #10; s15=1'b0;s25=1'b0; end Mux tt(.a(a1),.b(b1),.c(c1),.s(s5),.s1(s15),.s2(s25),.d(d1)); endmodule
Verilog as well as test bench coding for 2:4 Decoder is module decoder(a,b,w,x,y,z); input a,b; output w,x,y,z; reg w,x,y,z; always @(a or b) if (a==1'b0 && b==1'b0) begin w=1;x=0;y=0;z=0; end else if (a==1'b0 && b==1'b1) begin w=0;x=1;y=0;z=0; end else if (a==1'b1 && b==1'b0) begin w=0;x=0;y=1;z=0; end else begin w=0;x=0;y=0;z=1; end endmodule module tb_decer(); reg a1,b1; wire w1,x1,y1,z1; initial begin a1=1'b0;b1=1'b0; #10; a1=1'b0;b1=1'b1; #10; a1=1'b1;b1=1'b0; #10; a1=1'b1;b1=1'b1; end decoder tt(.a(a1),.b(b1),.w(w1),.x(x1),.y(y1),.z(z1)); endmodule
Discussion:
Finally in this lab, we had been introduced with Verilog Hardware Description Language. We gathered knowledge about designing adder, multiplexer, decoder circuit using Verilog HDL. We also verified truth table of these circuits using test bench timing diagram.