我有以下代码
module POLY(CLK,RESET_n,IN_VALID,IN,OUT_VALID,OUT);
input CLK,RESET_n,IN_VALID;
input [ 3:0] IN;
output OUT_VALID;
output [12:0] OUT;
reg OUT_VALID;
reg [12:0] OUT;
reg OUT_VALID_w;
reg [12:0] OUT_w;
reg [ 1:0] COUNT_IN, COUNT_IN_w;
reg [ 2:0] COUNT_DO, COUNT_DO_w;
always @(posedge CLK or negedge RESET_n)
begin
if(!RESET_n)
begin
COUNT_IN <= 2'd0;
COUNT_DO <= 3'd0;
end
else
begin
COUNT_IN <= COUNT_IN_w;
COUNT_DO <= COUNT_DO_w;
end
end
always @(*)
begin
if(IN_VALID == 1'b0)
begin
if(COUNT_DO == 3'd7)
begin
COUNT_DO_w = COUNT_DO;
end
else
begin
COUNT_DO_w = COUNT_DO + 1'b1;
end
end
else
begin
COUNT_DO_w = 3'd0;
end
end
我想问的是为什么COUNT_DO
不跳到 1 in 14ns
?
我认为由于第二个 always 块中的敏感列表是COUNT_DO
and IN_VALID
,所以在开始时,复位信号首先触发 always 阻止并设置COUNT_DO = 0
,这将COUNT_DO
值从高阻抗更改为 0。因此,它触发了第二个 always 块COUNT_DO_w = 0 + 1 = 1
。并且,在下一个正边沿时钟中,它触发了第一个 always 块做COUNT_DO <= COUNT_DO_w
。但它似乎延迟了一个时钟来分配它(22ns
)。我试图弄清楚但仍然无法解决,为什么它会延迟一个时钟?
提前谢谢。