|
本帖最后由 fpgaw 于 2011-8-17 13:38 编辑
这个代码的testbench对不对,仿真的时候,输出一直是X,帮忙指点一下
module tcount(out,data,load,reset,clk);
output[7:0] out;
input[7:0] data;
input load,clk,reset;
reg[7:0] out;
always @(posedge clk)
begin
if(!reset)
out<=8'h00;
else if (load)
out<=data;
else
out<=out+1;
end
endmodule
测试文件:
`timescale1ns/1ns
module tcount_tp;
reg clk,reset,load;
reg[7:0] data;
wire[7:0] cntout;
integer i;
tcount count(cntout,data,load,reset,clk);
always #10 clk<=~clk;
initial
begin
clk<=0;reset<=0; load<=0;data<=8'h00;
#5 reset<=1;
#10 load<=1;
#10 load<=0;
for(i=0;i<255;i=i+1)
#10 data<=data+1;
#10000$finish;
end
initial
$monitor($time,,,"cntout=%d",cntout);
endmodule |
|