module demux_1to4_enable(in,ena,s0,s1,d0,d1,d2,d3);
input in,ena,s0,s1;
output d0,d1,d2,d3;
assign d0=(ena & in & ~s1 &~s0 );
assign d1=(ena & in & ~s1 & s0 );
assign d2=(ena & in & s1 &~s0 );
assign d3=(ena & in & s1 & s0 );
endmodule
// 時間單位 100ns, 時間精確度100 ps
`timescale 100ns/100ps
module tb_demux;
// Inputs
reg in,ena,s0,s1;
// Outputs
wire d0,d1,d2,d3;
// Instantiate the Unit Under Test (UUT)
//demux_1to4_enable(in,ena,s0,s1,d0,d1,d2,d3);
demux_1to4_enable UUT (
.in(in),
.ena(ena),
.s0(s0),
.s1(s1),
.d0(d0),
.d1(d1),
.d2(d2),
.d3(d3)
);
initial begin
//Apply Inputs
in = 1;
ena=1;
{s1,s0} = 0; #100;
{s1,s0} = 1; #100;
{s1,s0} = 2; #100;
{s1,s0} = 3; #100;
in = 0;
//Apply Inputs
in = 1;
ena=0;
{s1,s0} = 0; #100;
{s1,s0} = 1; #100;
{s1,s0} = 2; #100;
{s1,s0} = 3; #100;
in = 0;
end
initial begin
#1000; // 模擬終止時間 100 ns
$stop;
end
endmodule
沒有留言:
張貼留言