2020年5月13日 星期三

Combinational Logic with always ----4x16 Decoder

Combinational Logic with always ----4x16 Decoder






//4x16 Decoder
module Deocder_4x16 ( en,in,out);

 input   en;
 input   [3:0]in;
 output  reg [15:0]out;

  always @ (en or in) begin
    out = en ? 1 << in: 0;
  end

endmodule

//=================================
`timescale 100ns/10ns

  module tb;
  reg en;
  reg [3:0] in;
  wire [15:0] out;
  integer i;

  Deocder_4x16  UUT ( .en(en), .in(in), .out(out));

  initial begin
    en <= 0;
    in <= 0;

    $monitor("en=%0b in=0x%0h out=0x%0h", en, in, out);

    for (i = 0; i <=32; i = i + 1) begin
      {en, in} = i;
      #10;
    end
  end

endmodule



沒有留言:

張貼留言

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

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