2020年4月11日 星期六

2-1 Multiplexer 多工器 (Gate Level)

2-1 Multiplexer 多工器 (Gate Level)







//------------------------------------
// 2-1 Multiplexer (Gate Level)
// Filename: mux_2to1.v
//------------------------------------
module  mux_2to1(a,b,s,y);

// Port Declarations
input a, b ,s ; // Data in : a, b;  Select: s
output y;  //output y


//Internal signal declarations
wire s0, sa, sb;

// Gate instantiations
not (s0, s);

// And gates are instantiated
and (sa, a, s0);
and (sb, b, s);
or (y, sa, sb);

endmodule



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

module TB;

/*
module  mux_2to1(a,b,s,y);
input a, b ,s ; // Data in : a, b;  Select: s
output y;  //output y
*/

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

//outputs
wire y;

integer i=0;
//instantiate the design module and connect to the testbench variables
 mux_2to1 UUT (a,b,s,y);

initial
begin
for (i=0;i<=10;i=i+1)
begin
#50
{a,b,s}=i;
end
#50
$stop;

end
endmodule



沒有留言:

張貼留言

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

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