2020年4月12日 星期日

1x4 demux using 1x2 demux (解多工器) gate level

1x4 demux using 1x2 demux (解多工器) gate level 











//-------------------------------------------------------------
// 1-4 DeMux using 1x2 DeMux (Gate Level)
// Filename: decoder_2x4.v
//-------------------------------------------------------------
module DeMux_1x4(Din,S,Y);
input Din;
input [1:0]S;
output [3:0]Y;

wire [1:0]w;

DeMux_1x2 U1(Din,S[1],w[1:0]);
DeMux_1x2 U2(w[0],S[0],Y[1:0]);
DeMux_1x2 U3(w[1],S[0],Y[3:2]);

endmodule
//------------------------------------
// 1-2 DeMux (Gate Level)
// Filename: DeMux_1x2.v
//------------------------------------
module DeMux_1x2(D,S,Y);
input D,S;
output [1:0]Y;

wire s_bar;
not u1(s_bar,S);

and U2(Y[0],s_bar,D);
and U3(Y[1],S,D);

endmodule

// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps 
module TB;
/*
module DeMux_1x4(Din,S,Y);
input D;
input [1:0]S;
output [3:0]Y;
*/
reg Din;
reg [1:0]S;
wire [3:0] Y;

integer i;
 
DeMux_1x4 UUT(Din,S,Y);
 
initial begin  
   for ( i=0;i<=8;i=i+1) 
        begin
           {Din,S}  = i;
            #1;
        end
end
endmodule

沒有留言:

張貼留言

WOKWI DHT22 & LED , Node-Red + SQLite database

 WOKWI DHT22 & LED , Node-Red + SQLite database Node-Red程式 [{"id":"6f0240353e534bbd","type":"comment&...