2019年12月30日 星期一

Verilog 3*8 decoder using 2*4 decoder

Verilog 3*8 decoder using 2*4 decoder








module decoder_3to8_2to4(o,i);
    output [7:0]o;
    input [2:0]i;
    wire x;
    not u1(x,i[2]);
    decoder24 u2(o[3:0],i[1],i[0],x);
    decoder24 u3(o[7:4],i[1],i[0],i[2]);
endmodule

module decoder24(c,a,b,en);
    output [3:0]c;
    input a,b,en;
    wire x,y;
    wire [3:0]c1;
    not u1(x,a);
    not u2(y,b);
    and u3(c1[0],x,y);
    and u4(c1[1],x,b);
    and u5(c1[2],a,y);
    and u6(c1[3],a,b);
   
    and u7(c[0],c1[0],en);
    and u8(c[1],c1[1],en);
    and u9(c[2],c1[2],en);
    and u10(c[3],c1[3],en);
endmodule

// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps
module Test_bench;
reg [2:0]i = 3'b000;   //  暫存器資料初值為‘000’
wire [7:0]o;


integer j;

decoder_3to8_2to4  DUT(.o(o),.i(i) );
// initial程序結構區塊, 產生輸入信號波形
initial begin
    $monitor(i,o);
    for (j=0; j<8; j=j+1) begin
        {i} = j;
        #20;
    end
end

initial
begin
  #160;   // 模擬終止時間  160 ns
    $stop;
end

endmodule

沒有留言:

張貼留言

Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3

  Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3 AngularJS 實例 <!DOCTYPE html> <html> <head> <meta charse...