Professional Documents
Culture Documents
DEMUX
DEMUX
DEMUX
B. Case statement
module demux18 (sel, I, Y);
input [2:0] sel;
input I;
output [7:0] Y;
reg Y;
always @ (sel or I)
begin
case (sel)
3’b000 : Y[0]=I;
3’b001 : Y[1]=I;
3’b010 : Y[2]=I;
3’b011 : Y[3]=I;
3’b100 : Y[4]=I;
3’b101 : Y[5]=I;
3’b110 : Y[6]=I;
3’b111 : Y[7]=I;
default : Y[0]=I;
endcase
end
endmodule
C. Dataflow Modeling
D. Ternary Operator
E. Structural Modeling
input i;
input s0;
input s1;
output y0;
output y1;
output y2;
output y3;
wire s0b,s1b;
not(s1b,s1);
not(s0b,s0);
and(y0,i,s1b,s0b);
and(y1,i,s1b,s0);
and(y2,i,s1,s0b);
and(y3,i,s1,s0);
endmodule
2) DataFlow Modelling :
input I;
input S0;
input S1;
output Y0;
output Y1;
output Y2;
output Y3;
wire s0b,s1b;
assign S0b=~S0;
assign S1b=~S1;
Cummins College Of Engineering For women, Pune-52 E&TC
endmodule
3) Behavioural Modelling :
input I;
input [1:0] S;
always@(I,S)
begin
case({S[0],S[1]})
default: $display("Invalid");
endcase
end
endmodule
Gate level
module 8x1_mux_using_2_4x1_mux{O,s,i);
input [7:0]i;
input[2:0]s;
output O;
not n(w3,s[2]);
and an(w4,w1,w3):
and an1(w5,w2,s[2]):
nor n1(o,w4,w5):
endmodule
BEHAVE
input[1:0] sel;
input[3:0] in;
output out;
reg output;
always @( sel or in )
begin
if( sel == 0)
out = in[0];
out = in[1];
out = in[2];
out = in[3];
else
out=1’bX
end
endmodule