在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 18518|回复: 21

VHDL问题,想不明白只好求教了

[复制链接]
发表于 2008-12-3 12:43:12 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
想了很久实在不知道怎么办了
求大家帮帮忙
我想写的这个元件功能是这样的,one_yuan,two_yuan,five_yuan是可重复投币按钮,按一下表示投一次对应钱数,然后在have_pay输出一共投了多少钱,reset高电平时清零
以下是我写的
--------------------------------------------------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity test is
port(one_yuan,two_yuan,five_yuan,reset:in std_logic;
     have_pay:out integer range 0 to 99);
end entity test;
architecture bhv of test is
begin
process(reset,one_yuan,two_yuan,five_yuan)
variable pay_tmp:integer range 0 to 99;
begin
if reset='1' then pay_tmp:=0;
elsif one_yuan'event and one_yuan='1' then pay_tmp:=pay_tmp+1;
elsif two_yuan'event and two_yuan='1' then pay_tmp:=pay_tmp+2;
elsif five_yuan'event and five_yuan='1' then pay_tmp:=pay_tmp+5;
end if;
have_pay<=pay_tmp;&#160; &#160; --如果这句去掉编译就能通过,当然,去掉了have_pay就没有值
end process;
end architecture bhv;
-------------------------------------------------------------------------------------------------------------------------------



按以上编译的错误信息是(错误提示很多,但好像是同一个错误导致)

Error (10820): Netlist error at test.vhd(12): can't infer register for pay_tmp[0] because its behavior depends on the edges of multiple distinct clocks
Error (10818): Can't infer register for "pay_tmp[0]" at test.vhd(12) because it does not hold its value outside the clock edge
Info (10041): Inferred latch for "pay_tmp[0]" at test.vhd(12)
Error (10820): Netlist error at test.vhd(12): can't infer register for pay_tmp[1] because its behavior depends on the edges of multiple distinct clocks
Error (10818): Can't infer register for "pay_tmp[1]" at test.vhd(12) because it does not hold its value outside the clock edge
Info (10041): Inferred latch for "pay_tmp[1]" at test.vhd(12)
Error (10820): Netlist error at test.vhd(12): can't infer register for pay_tmp[2] because its behavior depends on the edges of multiple distinct clocks
Error (10818): Can't infer register for "pay_tmp[2]" at test.vhd(12) because it does not hold its value outside the clock edge
Info (10041): Inferred latch for "pay_tmp[2]" at test.vhd(12)
Error (10820): Netlist error at test.vhd(12): can't infer register for pay_tmp[3] because its behavior depends on the edges of multiple distinct clocks
Error (10818): Can't infer register for "pay_tmp[3]" at test.vhd(12) because it does not hold its value outside the clock edge
Info (10041): Inferred latch for "pay_tmp[3]" at test.vhd(12)
Error (10820): Netlist error at test.vhd(12): can't infer register for pay_tmp[4] because its behavior depends on the edges of multiple distinct clocks
Error (10818): Can't infer register for "pay_tmp[4]" at test.vhd(12) because it does not hold its value outside the clock edge
Info (10041): Inferred latch for "pay_tmp[4]" at test.vhd(12)
Error (10820): Netlist error at test.vhd(12): can't infer register for pay_tmp[5] because its behavior depends on the edges of multiple distinct clocks
Error (10818): Can't infer register for "pay_tmp[5]" at test.vhd(12) because it does not hold its value outside the clock edge
Info (10041): Inferred latch for "pay_tmp[5]" at test.vhd(12)
Error (10820): Netlist error at test.vhd(12): can't infer register for pay_tmp[6] because its behavior depends on the edges of multiple distinct clocks
Error (10818): Can't infer register for "pay_tmp[6]" at test.vhd(12) because it does not hold its value outside the clock edge
Info (10041): Inferred latch for "pay_tmp[6]" at test.vhd(12)
Error (10822): HDL error at test.vhd(13): couldn't implement registers for assignments on this clock edge
Error (10822): HDL error at test.vhd(14): couldn't implement registers for assignments on this clock edge
Error (10822): HDL error at test.vhd(15): couldn't implement registers for assignments on this clock edge
Error: Can't elaborate top-level user hierarchy
Error: Quartus II Analysis & Synthesis was unsuccessful. 18 errors, 0 warnings
&#160; &#160; &#160; &#160; Info: Allocated 155 megabytes of memory during processing
&#160; &#160; &#160; &#160; Error: Processing ended: Wed Dec 03 12:27:24 2008
&#160; &#160; &#160; &#160; Error: Elapsed time: 00:00:03
Error: Quartus II Full Compilation was unsuccessful. 18 errors, 0 warnings

[ 本帖最后由 hjw951 于 2008-12-3 19:21 编辑 ]
 楼主| 发表于 2008-12-3 19:22:44 | 显示全部楼层
没人人出来帮帮我吗
发表于 2008-12-5 11:33:27 | 显示全部楼层
照错误报告看,应该是寄存器多时钟驱动了
发表于 2009-5-4 13:24:32 | 显示全部楼层
我也遇到了这样的问题啊
发表于 2009-5-15 00:01:32 | 显示全部楼层
如果***为非全局时钟引脚,也就是普通IO,建议不要用if ***'event and *** = '1' then 来检测上升下降沿!可以引入全局时钟信号,通过对全局时钟信号的检测,来达到获取IO引脚跳变的目的。
发表于 2009-5-15 09:14:59 | 显示全部楼层


原帖由 ccangler 于 2009-5-15 00:01 发表
如果***为非全局时钟引脚,也就是普通IO,建议不要用if ***'event and *** = '1' then 来检测上升下降沿!可以引入全局时钟信号,通过对全局时钟信号的检测,来达到获取IO引脚跳变的目的。



同意这种说法。
在VHDL中one_yuan'event and one_yuan='1' 这样的描述一般使用在时钟上的。
如果你要找出one_yuan的上升沿的话就用时钟来做
在时钟进程中如果one_yuan = ‘1’  and one_yuan_p1 = '0' 那么就可以判断出一个上升沿事件。--P1为延时后的one_yuan
当然如果你的one_yuan还没有同步到你的时钟域上,你还需要用寄存器对异步的one_yuan信号打两拍来消除亚稳态的隐患。
发表于 2009-5-16 22:20:02 | 显示全部楼层
您写的代码太难为编译器了 无语
发表于 2009-5-17 13:52:29 | 显示全部楼层
建议用状态机写这类逻辑
发表于 2009-5-18 08:33:55 | 显示全部楼层
建议多用时钟使能的方式,少这么写,呵呵
发表于 2009-6-2 15:42:52 | 显示全部楼层
看看是否能用
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /1 下一条

小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-11-16 15:21 , Processed in 0.026530 second(s), 10 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表