quartus和modelsim-altera联合调试中,modelsim中被调用的模块只显示最后部分波形,其余部分都是no data
`timescale 1 ns/ 1 ns
module tb;
reg clk,rst,pin;
wire led;
delay20_detect_module1 inst1(clk,rst,pin,led);
initial
begin
rst =0;
pin =1;
clk =0;
#20 rst =1;
end
always
begin
#10 clk <= ~clk;
end
always
begin
#25_000_000 pin <= ~pin;
end
endmodule
module delay20_detect_module1
(
clk, rstn, pin, led
);
input clk;
input rstn;
input pin;
output reg led;
parameter T20MS = 16'd1_000_000;//20ns*10^6=20ms
reg [15:0] Count1;
reg count_clear,pin_detect;
always @ ( posedge clk or negedge rstn )//counter20
begin
if( !rstn )//reset
Count1 <= 0;
else if (count_clear == 1)
begin
Count1 <= 0;
end
else
begin
Count1 <= Count1 + 1'b1;
end
end
always @ ( posedge clk or negedge rstn )//pin push down detect
begin
if( !rstn )//reset
begin
pin_detect <= 0;
count_clear <= 0;
end
else if(pin == 0)//counter if full
begin
if(Count1 == T20MS )//counter if full
begin
pin_detect <= 1;
count_clear <= 0;
end
else if(Count1 == 0)//counter if full
begin
count_clear <= 1;
end
else
begin
pin_detect <= 0;
count_clear <= 0;
end
end
end
always @ ( posedge clk )//led
begin
if( !rstn )//reset
led <= 0;
else if (pin_detect == 1)led <= ~ led;
else led <= led;
end
endmodule
https://img-mid.csdnimg.cn/release/static/image/mid/ask/856116380666184.png "#left")
猜测应该是代码内部有问题,但按道理如果模块没被调用,内部也会有不确定值x啊,也不至于no data吧
如何看到全部的波形
代码没问题,是 Modelsim 使用的问题,看看教程学习一下就行了。
你找找复位的按钮,复位后再运行就行了。
还可以保存退出,再打开软件,运行就行了。