版主: 51FPGA

分享到:
共2条 1/1 1   

verilog HDL语法警告

    [您是本帖的第2308位阅读者]
502593045
我是GG
高级会员

最后登陆时间:2015-01-28 15:14:39

直达楼层
1# 发表于 2012-06-29 16:53:58
使用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

请问大虾们,这个警告怎么解决呢?先谢谢了。



关键词:verilog    语法    警告    

中华小虾。

RE: verilog HDL语法警告

502593045
我是GG
高级会员

最后登陆时间:2015-01-28 15:14:39

2# 发表于 2012-06-29 21:13:16
额~解决了,代码修改如下:
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   
快速回复主题
  • 匿名不能发帖!请先 [ 登陆 注册 ]