2020年4月12日 星期日

4-bit 2 to 1 multiplexer using conditional operator dataflow level

4-bit 2 to 1 multiplexer using conditional operator dataflow level




//---------------------------------------------------
//4-bit 2 to 1 multiplexer using conditional operator
//filename :mux_2x1_4bit.v
//---------------------------------------------------
module mux_2x1_4bit(a,b,sel,y);

input [3:0] a, b;       // 4-bit input data
input sel;                // selection line
output [3:0] y;

assign y = (sel) ? a : b;

endmodule

// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps 
module TB;
/*
module mux_2x1_4bit(a,b,sel,y);
input [3:0] a, b;       // 4-bit input data
input sel;                // selection line
output [3:0] y;

*/
reg [3:0] a, b;
reg sel;
wire [3:0] y;

integer i;
 
mux_2x1_4bit UUT(a,b,sel,y);
 
initial begin
   b=4'b0; sel=1'b1;
   for ( i=0;i<=15;i=i+1) 
        begin
            a=i;
            #10;
        end
   a=4'b0; sel=1'b0;
   for ( i=0;i<=15;i=i+1) 
        begin
            b=i;
            #10;
        end
   #10
$stop;
end
endmodule

沒有留言:

張貼留言

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

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