2020年4月11日 星期六

3-8 Decoder using 2x4 decoder with enable (Gate Level)

 3-8 Decoder using 2x4 decoder with enable (Gate Level)


//------------------------------------
// 3-8 Decoder using 2x4 decoder with enable (Gate Level)
// Filename: Decoder_3x8.v
//------------------------------------
module Decoder_3x8(A,Y);

input [2:0]A;
output [7:0]Y;

wire w1;

not u1(w1,A[2]);

Decoder_2x4_en U1 (A[1:0],w1,Y[3:0]);
Decoder_2x4_en U2 (A[1:0],A[2],Y[7:4]);

endmodule

//===================================
module Decoder_2x4_en(in,en,Dout);

input [1:0] in;
input en;
output [3:0] Dout;

wire in0_0,in0_1;

not u1(in0_0,in[0]);
not u2(in0_1,in[1]);

and u4 (Dout[0],en,in0_0,in0_1);
and u5 (Dout[1],en,in[0],in0_1);
and u6 (Dout[2],en,in0_0,in[1]);
and u7 (Dout[3],en,in[0],in[1]);

endmodule
//===================================
// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps
module TB;
/*
module Decoder_3x8(A,Y);
input [2:0]A;
output [7:0]Y;
*/
reg [2:0]A=2'b00;
wire [7:0] Y;

integer i;

 Decoder_3x8 UUT(A,Y);

initial begin 
   for ( i=0;i<=8;i=i+1)
        begin
           A = 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&...