2020年4月11日 星期六

2-4 Decoder with enable 具有致能的解碼器 (Gate Level)

2-4 Decoder with enable 具有致能的解碼器 (Gate Level)





//------------------------------------
// 2-4 Decoder with enable (Gate Level)
// Filename: decoder_2x4_en.v
//------------------------------------

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_2x4_en(in,en,Dout);
input [1:0] in;
input en;
output [3:0] Dout
*/
reg [1:0]in=2'b00;
reg en=1'b0;
wire [3:0] Dout;

integer i;
decoder_2x4_en UUT(in,en,Dout);
initial begin  
   for ( i=0;i<=8;i=i+1) 
        begin
           {en,in}  = i;
            #1;
        end
end
endmodule

沒有留言:

張貼留言

2024產專班 作業2 (純模擬)

2024產專班 作業2  (純模擬) 1) LED ON,OFF,TIMER,FLASH 模擬 (switch 控制) 2)RFID卡號模擬 (buttom  模擬RFID UID(不從ESP32) Node-Red 程式 [{"id":"d8886...