代码如下:
always @(negedge rst_n or posedge clk) begin
if(!rst_n) begin
index <= 5'd0;
else begin
if(wrreq) begin
index <= index + 5'd8;
end
end
end
很简单的代码,但quaruts7.2 综合时提示index产生了锁存器,我觉得这个语句块用了时钟沿,
肯定会综合成触发器的,难以理解。更加难以理解的是如果我改成:
index <= index + 5'd7
或
index <= index + 5'd9,软件综合时就没有锁存器提示了。
这种莫名奇妙的问题会不会是Quartus软件本身的问题?以前我也有发现quartus综合得出的结
果与其它工具不同的情况。



最新回复
wu.weihai (2008-8-06 13:32:49)
[ 本帖最后由 wu.weihai 于 2008-8-6 13:34 编辑 ]
wu.weihai (2008-8-06 13:35:22)
if(!rst_n) begin
index <= 5'd0;
else begin
if(wrreq) begin
index <= index + 5'd8;
end
end
end
wu.weihai (2008-8-06 13:39:12)
end
不配对
wu.weihai (2008-8-06 13:40:09)
ericwang622 (2008-8-06 13:52:22)
if(!rst_n) begin
index <= 5'd0;
end
else begin
if(wrreq)
index <= index + 5'd8;
end
end
[ 本帖最后由 ericwang622 于 2008-8-6 13:53 编辑 ]
tonylzez (2008-8-06 22:10:39)
lujunfeng111 (2008-8-06 22:28:40)
xu2006 (2008-8-06 23:06:12)
tonylzez (2008-8-07 10:11:47)
mulan (2008-8-07 10:59:57)
jiemoyang (2008-8-07 11:14:45)
if(wrreq)
index <= index + 5'd8;
没有说明else的情况,当然会生成锁存器了
yky3489 (2008-8-07 12:38:20)
tonylzez (2008-8-07 13:26:52)
ericwang622 (2008-8-07 14:44:07)
因为index的后3位一直是0,所以优化的时候把后三位的reg优化掉了,直接tie到0。
不仅仅是+8的时候出现,只要是偶数都会有这种优化,只要有至少一位不会变化。
声明的时候就将index声明成2位的reg可以避免,低三位hard wire到0。
ishock (2008-8-07 14:53:18)
wangling300 (2008-8-07 20:29:06)
(
rst_n,
clk,
wrreq,
index
);
input rst_n;
input clk;
input wrreq;
output [5:0] index;
reg [5:0] index;
always @(negedge rst_n or posedge clk)
begin
if(!rst_n)
begin
index <= 5'd0;
end
else
begin
if(wrreq)
index <= index + 5'd8;
end
end
endmodule
//用synplify综合为时序逻辑
lijinsong1986 (2008-8-07 20:40:01)
wangling300 (2008-8-07 22:01:32)
module test
(
rst_n,
clk,
wrreq,
index
);
input rst_n;
input clk;
input wrreq;
output [5:0] index;
reg [5:0] index;
always @(negedge rst_n or posedge clk)
begin
if(!rst_n)
begin
index <= 5'd0;
end
else
begin
if(wrreq)
index <= index + 5'd8;
else
index <= index;
end
end
endmodule
tooth (2008-8-07 22:05:33)
QUOTE:
对绝大多数综合软件来说,上面的代码不加esle也不会生成锁存器的。wangling300 (2008-8-07 22:13:50)