inout
[3:0]dbus;
input enab;
input
[3:0]inputval;
assign dbus =
enab ? inputval : 4'bZ;
endmodule
以De2-70 實現 P3-15 功能
modelsim simulation
`timescale 1us/1us
module testbench();
// Inputs
reg enab;
reg inputval;
// Outputs
wire dbus;
// Instantiate the UUT
// tribuff(dbus,enab,inputval);;
tribuff tribuffer(
.dbus(dbus),
.enab(enab),
.inputval(inputval)
);
initial
$monitor ($time, "enab=%b,inputval=%b,dbus=%b", enab,inputval,dbus);
initial //Initialize input signals
begin
inputval = 4'b0; //0-50
enab = 0;
end
initial
begin
#50 enab=0 ; inputval=4'b1111; //50-100
#50 enab=1 ; inputval=4'b1111; //100-150
#50 enab=0 ; inputval=4'b1010; //150-200
#50 enab=1 ; inputval=4'b1010; //200-250
#50 enab=0 ; inputval=4'b0101; //250-300
#50 enab=1 ; inputval=4'b0101; //300-350
end
initial #400 $finish; //Complete simulation after 250us
endmodule
`timescale 1us/1us
module testbench();
// Inputs
reg enab;
reg inputval;
// Outputs
wire dbus;
// Instantiate the UUT
// tribuff(dbus,enab,inputval);;
tribuff tribuffer(
.dbus(dbus),
.enab(enab),
.inputval(inputval)
);
initial
$monitor ($time, "enab=%b,inputval=%b,dbus=%b", enab,inputval,dbus);
initial //Initialize input signals
begin
inputval = 4'b0; //0-50
enab = 0;
end
initial
begin
#50 enab=0 ; inputval=4'b1111; //50-100
#50 enab=1 ; inputval=4'b1111; //100-150
#50 enab=0 ; inputval=4'b1010; //150-200
#50 enab=1 ; inputval=4'b1010; //200-250
#50 enab=0 ; inputval=4'b0101; //250-300
#50 enab=1 ; inputval=4'b0101; //300-350
end
initial #400 $finish; //Complete simulation after 250us
endmodule
沒有留言:
張貼留言