[FPGA] verilog,遇到个问题,不知道怎么解释

[复制链接]
1182|3
 楼主| 辉色天空 发表于 2017-3-5 10:57 | 显示全部楼层 |阅读模式

if(cnt < 5'd18)
cnt <= cnt + 1;
else cnt<=0;

if(cnt == 1)
init  <= 1;  //改为 init  =1 也不对  ,编译显示这个位置是错的

上面这个代码,怎么编译都不过,显示错误为
Error (10200): Verilog HDL Conditional Statement error at LEDa.v(65): cannot match operand(s) in the condition to the corresponding edges in the enclosing event control of the always construct

但是我改成下面这样就编译通过了,
if(cnt < 5'd18)
begin
        cnt <= cnt + 1;
        if(cnt == 1)
                init  <= 1;
end
else cnt<=0;

就是将错误的那句插入到上面那个if语句里   (插入到其他位置都会报错,只有插入到上面的if语句里才不报错)

请问各位知道这是什么原因吗?
玄德 发表于 2017-3-9 16:58 | 显示全部楼层

同样看不出来什么问题,也许错误不在这里。
试着把出错代码专门编译一下。


LxiaoseI 发表于 2017-3-10 16:38 | 显示全部楼层
时序逻辑时,就不要用组合逻辑了,OK
LxiaoseI 发表于 2017-3-10 16:39 | 显示全部楼层
时序电路里,就不要用组合电路了,OK
您需要登录后才可以回帖 登录 | 注册

本版积分规则

20

主题

34

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部