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

沒有留言:

張貼留言

台中公車雙向即時資訊系統 (TaichungBusLiveQuery)- Node-red 程式

  台中公車雙向即時資訊系統 ( TaichungBusLiveQuery )   Node-red 程式 Python Tkinter 是單機桌面 UI 程式,主動發起 API 請求並渲染視窗。 Node-RED 是基於事件驅動的流程(Flow-based)系統,適合在背...