2019年12月30日 星期一

VERILOG PROGRAM- 1:4 Demultiplexer with enable

VERILOG PROGRAM- 1:4 Demultiplexer with enable



module demux_1to4_enable(in,ena,s0,s1,d0,d1,d2,d3);
input in,ena,s0,s1;
output d0,d1,d2,d3;

assign d0=(ena & in &  ~s1 &~s0 );
assign d1=(ena & in &  ~s1 & s0 );
assign d2=(ena & in &   s1 &~s0 );
assign d3=(ena & in &   s1 & s0 );

endmodule

// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps     
module tb_demux;
    // Inputs
    reg in,ena,s0,s1;
    // Outputs
    wire d0,d1,d2,d3;


    // Instantiate the Unit Under Test (UUT)
    //demux_1to4_enable(in,ena,s0,s1,d0,d1,d2,d3);
   demux_1to4_enable UUT (
        .in(in),
        .ena(ena),
        .s0(s0),
        .s1(s1),
        .d0(d0),
        .d1(d1),
        .d2(d2),
        .d3(d3)
    );

    initial begin
        //Apply Inputs
        in = 1;
        ena=1;
        {s1,s0} = 0;    #100;
        {s1,s0} = 1;    #100;
        {s1,s0} = 2;    #100;
        {s1,s0} = 3;    #100;
        in = 0;
        //Apply Inputs
        in = 1;
        ena=0;
        {s1,s0} = 0;    #100;
        {s1,s0} = 1;    #100;
        {s1,s0} = 2;    #100;
        {s1,s0} = 3;    #100;
        in = 0;
    end 
    initial begin
      #1000;   // 模擬終止時間  100 ns
    $stop;
end
     
endmodule

沒有留言:

張貼留言

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

2024產專班 作業2  (純模擬) 1) LED ON,OFF,TIMER,FLASH 模擬 (switch 控制) 2)RFID卡號模擬 (buttom  模擬RFID UID(不從ESP32) 3) 使用database需先create建立資料庫 Node-Red 程式 [...