使用ISE编译一个verilog HDL代码文档出现如下警告:
WARNING:Xst:737 - Found 8-bit latch for signal <count>. Latches may be generated from incomplete case or if statements. We do not recommend the use of latches in FPGA/CPLD designs, as they may lead to timing problems.
该文档内容如下:
module operation(
input rst_n,
input add,
input subtract,
output [7:0] q
);
reg [7:0] count;
always @ (add or subtract or rst_n)
begin
if(!rst_n)
count <= 0;
else if(!add)
count <= count + 1;
else if(!subtract)
count <= count - 1;
end
assign q = count;
endmodule
请问大虾们,这个警告怎么解决呢?先谢谢了。
共2条
1/1 1 跳转至页

额~解决了,代码修改如下:
module operation(
input clk_1M,
input rst_n,
input add,
input subtract,
output [7:0] q
);
reg [7:0] count;
always @ (posedge clk_1M or rst_n)
begin
if(!rst_n)
count <= 0;
else if(!add)
count <= count + 1;
else if(!subtract)
count <= count - 1;
end
assign q = count;
endmodule
说明:这是一个检测按键的module。我之前写成了组合逻辑电路,现改为时序逻辑电路就对了。看来需要深入了解组合逻辑电路和时序逻辑电路的语法以及应用场合。
module operation(
input clk_1M,
input rst_n,
input add,
input subtract,
output [7:0] q
);
reg [7:0] count;
always @ (posedge clk_1M or rst_n)
begin
if(!rst_n)
count <= 0;
else if(!add)
count <= count + 1;
else if(!subtract)
count <= count - 1;
end
assign q = count;
endmodule
说明:这是一个检测按键的module。我之前写成了组合逻辑电路,现改为时序逻辑电路就对了。看来需要深入了解组合逻辑电路和时序逻辑电路的语法以及应用场合。
共2条
1/1 1 跳转至页
回复
打赏帖 | |
---|---|
汽车电子中巡航控制系统的使用被打赏10分 | |
分享汽车电子中巡航控制系统知识被打赏10分 | |
分享安全气囊系统的检修注意事项被打赏10分 | |
分享电子控制安全气囊计算机知识点被打赏10分 | |
【分享开发笔记,赚取电动螺丝刀】【OZONE】使用方法总结被打赏20分 | |
【分享开发笔记,赚取电动螺丝刀】【S32K314】芯片启动流程分析被打赏40分 | |
【分享开发笔记,赚取电动螺丝刀】【S32K146】S32DS RTD 驱动环境搭建被打赏12分 | |
【分享开发笔记,赚取电动螺丝刀】【IAR】libc标注库time相关库函数使用被打赏23分 | |
LP‑MSPM0L1306开发版试用结果被打赏10分 | |
【分享开发笔记,赚取电动螺丝刀】【LP-MSPM0L1306】适配 RT-Thread Nano被打赏23分 |