2020年4月11日 星期六

2x4 decoder 解碼器 in Verilog with gate level

2x4 decoder  解碼器 in Verilog with gate level


//------------------------------------
// 2-4 Decoder (Gate Level)
// Filename: decoder_2x4.v
//------------------------------------
module decoder_2x4(y, a, b);

// Port Declarations
output [3:0] y;  //outputs are y3, y2, y1, and y0
input a, b;

//Internal signal declarations
wire an, bn;

// Gate instantiations

// Create signals an and bn
not (an, a);
not (bn, b);

// And gates are instantiated
and (y[0], an, bn);
and (y[1], a, bn);
and (y[2], an, b);
and (y[3], a, b);

endmodule

// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps 

module TB;

/*
module decoder_2x4(y, a, b);
// Port Declarations
output [3:0] y;  //outputs are y3, y2, y1, and y0
input a, b; 
*/

//inputs
reg a=1'b0;
reg b=1'b0;

//outputs
wire [3:0] y;

//instantiate the design module and connect to the testbench variables
decoder_2x4 UUT (y, a, b);

initial 
 begin
#50
a=1'b0; b=1'b1;
#50
a=1'b1; b=1'b0;
#50
a=1'b1; b=1'b1;
#50
$stop;
 end
 endmodule
 
 


沒有留言:

張貼留言

Node-Red --> MQTT --> Fuxa 開源碼網頁式圖控平台

Node-Red --> MQTT --> Fuxa      FUXA(一個開源的 Web HMI / SCADA 自動化監控軟體)的專案設定檔 。 這份設定檔完整定義了 HMI 監控畫面的 後端通訊(MQTT 連線、點位標籤) 與 前端網頁圖形介面(SVG 畫布...