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



沒有留言:

張貼留言

Galois LFSR

  在密碼學與數位訊號處理中, LFSR(線性回饋移位暫存器,Linear Feedback Shift Register) 是用來產生偽隨機序列(也就是串流加密中所需的金鑰流)最核心的硬體架構。 LFSR 主要分為兩種實現架構: Fibonacci(斐波那契) 與 Galo...