中易网

Verilog 语法问题

答案:2  悬赏:10  
解决时间 2021-04-21 14:32
按键消抖程序的一部分
reg [2:0] key_r;
always@(posedge clk or negedge r_est)
begin
if(!r_est) key_r <= 3'b111;
else key_r<={key_3,key_2,key_1};
end
像上边这样写没错
reg [2:0] key_r;
always@(posedge clk or negedge r_est)
begin
if(r_est) key_r<={key_3,key_2,key_1};
else key_r <= 3'b111;
end
改成这样写提示时钟信号有问题,我感觉两段意思是一样的啊,为什么不能互换啊
最佳答案
你是不是错误提示:Error (10200): Verilog HDL Conditional Statement error at ……: cannot match operand(s) in the condition to the corresponding edges in the enclosing event control of the always construct
这是因为,你的“always@(posedge clk or negedge r_est)”表明在clk上升沿或r_est下降沿这两个敏感事件发生时always语句块得以触发;而always中的if条件语句必须至少有一个条件指向其中一个敏感事件(边界标识符);所以写成“if(r_est)...else...”就会出错。

你可以把“always@(posedge clk or negedge r_est)”改为“always@(posedge clk or posedge r_est)”再编译试试,应该就没问题了。

你右键该错误点击“Help”里是这么说的:
CAUSE: In a conditional statement at the specified location in a Verilog Design File (.v), you specified a condition that Quartus II Integrated Synthesis cannot use to classify the edges in the enclosing always construct's event control. When an event control contains multiple edges, Quartus II Integrated Synthesis distinguishes the asynchronous control signals from the clock by analyzing the conditional statements in the always construct. For example, the following code fragment contains an always construct whose event control contains three edges---two asynchronous resets and a clock.
always @ (posedge clk or posedge rst1 or posedge rst2)
begin
if ( rst1 || rst2 )
q <= 1'b0;
else
q <= d;
end
Quartus II Integrated Synthesis uses the if condition to identify the two asynchronous resets and, by implication, the clock. For edge classification, Quartus II Integrated Synthesis requires that a condition fall into one of two categories. It can refer to a single edge identifier (to match posedge events) or its complement (to match negedge events), for example, rst1, !rst1, rst1 == 1'b1, rst1 == 1'b0. It can also OR two or more expressions that each refer to a single edge identifier or its complement, for example, (rst1 || rst2), (!rst1 || !rst2).
You can receive this error if your condition tests for the wrong polarity, or if it tests for the value of a variable that is not an edge in the event control. For example, to match a posedge rst event, the condition must be rst or rst = 1'b1.
Finally, you can receive this error if you are attempting to use a single condition expression to test for both an asynchronous reset/set and a synchronous reset/set condition. The following code fragment contains an example of an illegal condition expression:
always @ (posedge clk or posedge rst)
begin
if ( rst || sync_rst )
q <= 1'b0;
else
q <= d;
end
Quartus II Integrated Synthesis generates this error message when compiling this design because it cannot match sync_rst to an edge on the sensitivity list.

其中关键的语句我摘译一下,不一定译得准确,不过大体意思我想你应该可以了解了:
原因:……指定了一个条件,Quartus II 综合器不能够将该条件用于在封闭的always结构的事件控制中对边界进行区分。当一个事件控制中包含多重边界,Quartus II 综合器通过分析always结构中的条件语句来对时钟和异步控制信号加以区分。……
Quartus II 综合器采用if条件来鉴别两个异步reset信号,并隐含地鉴别了clock信号。为了分类的需要,Quartus II 综合器需要有一个条件落入两个类别之一。它可以指向一个单独的边界标识符(以匹配posedge事件)或它的补语(以匹配negedge事件),例如, rst1, !rst1, rst1 == 1'b1, rst1 == 1'b0。它也可以是OR两个或更多的表达式,其中每一个指向一个单独的边界标识符或它的补语……
当你的条件测试发现错误极性,或者它测试变量的值,但该值在事件控制中并不是一个边界时,你会接到这个错误。例如,为了匹配一个posedge rst事件,条件必须是rst或rst = 1'b1。

编译错误时多看看Help,讲得很详细~
全部回答
verilog hdl是一种硬件描述语言(hdl:hardware description language),以文本形式来描述数字系统硬件的结构和行为的语言,用它可以表示逻辑电路图、逻辑表达式,还可以表示数字逻辑系统所完成的逻辑功能。 verilog hdl和vhdl是世界上最流行的两种硬件描述语言,都是在20世纪80年代中期开发出来的。前者由gateway design automation公司(该公司于1989年被cadence公司收购)开发。两种hdl均为ieee标准。 verilog 硬件描述语言;设计语言;硬件设计语言 例句筛选 1. use verilog hdl to implement a latch with asynchronous reset and set. 实现异步置位和复位的锁存器。 2. experience in ic design project with verilog is preferred; 有一定的ic设计经验或项目参与经验优先;
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
在湖州哪里可以买车
怎样才能获得office帮助???
天津国宏盛通物流有限公司怎么去啊,有知道地
请问风水大师:卧室内能否摆放观音莲类(植物)?
广元苴国路商铺价格是多少
> 邯郸哪个会计培训班比较好
苹乡收费站上高速到长沙还要几个小时
wf符号下有个+是什么意思
为什么喝了红枣姜片红糖水之后会感到体内开始
嘴里有金属牙齿可以做脑部核磁共振吗?
这样让她爱上我呢?
高中会不发毕业证给学生么
2016西安野生动物园大年初一要门票吗
运动之后洗冷水澡还是热水澡好?
有没有容易使用的家庭用的应急电源,在断电的
推荐资讯
关于“五虎将元神”“3、4、5级翅膀”“JS54
哈尔滨西站至香德街怎么走
南宁市兰舍新风系统安装公司在哪里?联系方式
为什么从WORD复制文字到EXCEL表格里,那个表
红99重庆水煮鱼浓缩调料的味道怎样?
戴牙套多少钱
苏宁城市奥特莱斯有咖啡之翼这家店吗?
上海市杨浦区杨树浦路1358-4000弄(双号)邮编
为什么我的QQ音乐不能设置默认播放列表?
我的为什么啤酒肚那么大?
武昌卖厨师工作服的地方
两斤五毛钱打一数学用语
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?