VLSI Lab
VLSI Lab
SOFTWARE REQUIRED :
1. Vivado
THEORY:
8-to-1 Multiplexer
1-to-8 Demultiplexer
CODE:
8 to 1 Multiplexer
1.Gatelevel Model:
module mux (a, b, c, i0, i1, i2, i3, i4, i5, i6, i7,o);
output o;
wire p, q, r, s, t, u, v, w;
endmodule
2.Behavioural model:
module mux_behave (a, b, c, i0, i1, i2, i3, i4, i5, i6, i7,o);
input a,b,c, 10, 11, 12, 13, 14, 15, 16, 17;
output reg o;
reg p, q, r, s, t, u, v, w;
always @(a or b or c or 10 or il or i2 or i3 or i4 or i5 or i6 or i7 )
begin
an=-a;
bn=-b;
cn=-c;
p=an&bn&cn&i0;
q=an&bn&c&i1;
r=an&b&cn&i2;
s=an&b&c&i3;
t=a&bn&cn&i4;
u=a&bn&c&i5;
v=a&b&cn&i6;
w=a&b&c&i7;
o=p|q|r|s|t|u|v|w;
end
endmodule
3.Dataflow model:
module mux_dataflow (a, b, c, i0, i1, i2, i3, i4, i5, i6, i7,o);
input a, b, c, i0, i1, i2, i3, i4, i5, i6, i7
output o;
wire p, q, r, s, t, u, v, w;
assign an =~a;
assign bn=~b;
assign cn=~c;
assign p=an&bn&cn&i0;
assign q=an&bn&c&i1;
assign r=an&b&cn&i2;
assign s=an&b&c&i3;
assign t=a&bn&cn&i4;
assign u=a&bn&c&i5;
assign v=a&b&cn&i6;
assign w-=a&b&c&i7;
assign o=p|q|r|st|u|v|w;
endmodule
Testbench:
module mux81_tb;
reg a, b, c, i0, i1, i2, i3, i4, i5, i6, i7;
wire o;
mux xa (a, b, c, i0, i1, i2, i3, i4, i5, i6, i7, 0);
initial begin
end
endmodule
1 to 8 demultiplexer
Gate level:
module demux (i, a, b, c, i0, i1, i2, i3, i4, i5, i6, i7);
input i, a, b, c;
endmodule
2.Behavourial code:
module demux_behav(i, a, b, c, i0, i1, i2, i3, i4, i5, i6, i7);
input i, a,b,c;
output reg i0, i1, i2, i3, i4, i5, i6, i7;
always @(i or a or b or c)
begin
an=~a;
bn=~b;
cn=~c;
i0=an&bn&cn&i;
i1=an&bn&c&i;
i2=an&b&cn&i;
i3=an&b&c&i;
i4=a&bn&cn&i;
i5=a&bn&c&i;
i6=a&b&cn&i;
i7=a&b&c&i;
end
endmodule
3.Dataflow model:
module demux_dataflow(i, a, b, c, i0, i1, i2, i3, i4, i5, i6, i7);
input i,a,b,c;
assign an=~a;
assign bn=~b;
assign cn=~c;
assign i0=an&bn&cn&i;
assign i1=an&bn&c&i;
assign i2=an&b&cn&i;
assign i3=an&b&c&i;
assign i4=a&bn&cn&i;
assign i5=a&bn&c&i;
assign i6=a&b&cn&i;
assign i7=a&b&c&i;
endmodule
Test bench:
module demux81_tb;
reg i, a, b, c;
initial
begin
a = 0; b = 0; c =0; i = 1;#100;
a = 0; b = 1; c =1; i = 0;#100;
a = 1; b = 0; c =0; i = 1;#100;
a = 1; b = 0; c =1; i = 1;#100;
a = 1; b = 1; c = 0;1 = 0;#100;
a = 1; b = 1; c = 1; i = 1;#100;
end
endmodule
OUTPUT:
1. 8-to-1 Multiplexer
2.1 to 8 demultiplexer:
RESULT : Hence, 8 to 1 multiplexer and 1 to 8 demultiplexer are designed.
EXPERIMENT-4
AIM: To Write a Verilog code to design of 4 bit binary to gray code converter.
SOFTWARE REQUIRED :
1. Vivado
THEORY:
CODE:
1.Gate Level:
endmodule
2.Behavioural model:
begin
g3-b3;
g2=b3^b2;
g1=b1^b2;
g0=b1^b0;
end
endmodule
3.Dataflow model:
module bin_gray_dataflow (b3, b2, b1, b0, g3, g2, g1, g0);
assign g3=b3;
assign g2-b3b2;
assign g1=b1^b2;
assign g0=b1^b0;
endmodule
Testbench:
module gray_tb();
initial
begin
b3 = 1; b2 = 1; b1 = 0; b0 =1; # 200;
end
endmodule
OUTPUT:
RESULT: Hence, a 4 bit binary to gray code converter is designed and their
characteristics are observed.