计数器自动换挡模块VHDL 求找出错误。。。100分~

[复制链接]
查看11 | 回复1 | 2011-6-26 04:10:53 | 显示全部楼层 |阅读模式
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitycornais
port(clr,sig,door:instd_logic;
alm:outstd_logic;
q3,q2,q1,q0,dang:outstd_logic_vector(3downto0));
endcorna;
architecturecorn_arcofcornais
begin
process(door,sig)
variablec0,c1,c2,c3,c4,c5,c6:std_logic_vector(3downto0);
variablex:std_logic;
begin
ifsig\'eventandsig=\'1\'then
ifdoor=\'1\'then
ifc0\"1001\"then
c0:=c01;
else
c0:=\"0000\";
ifc1\"1001\"then
c1:=c11;
else
c1:=\"0000\";
ifc2\"1001\"then
c2:=c21;
else
c2:=\"0000\";
ifc3\"1001\"then
c3:=c31;
else
c3:=\"0000\";
ifc4\"1001\"then
c4:=c41;
else
c4:=\"0000\";
ifc5\"1001\"then
c5:=c51;
else
c5:=\"0000\";
ifc6\"1001\"then
c6:=c61;
else
c6:=\"0000\";
alm=\'1\';
endif;
endif;
endif;
endif;
endif;
endif;
endif;
else
ifclr=\'0\'then
alm=\'0\';
endif;c6:=\"0000\";
c5:=\"0000\";
c4:=\"0000\";
c3:=\"0000\";
c2:=\"0000\";
c1:=\"0000\";
c0:=\"0000\";
endif;
ifc6/=\"0000\"then
q3=c6;
q2=c5;
q1=c4;
q0=c3;
dang=\"0111\";
elsifc5/=\"0000\"then
q3=c5;
q2=c4;
q1=c3;
q0=c2;
dang=\"1011\";
elsifc4/=\"0000\"then
q3=c4;
q2=c3;
q1=c2;
q0=c1;
dang=\"1101\";
elsifc3/=\"0000\"then
q3=c3;
q2=c2;
q1=c1;
q0=c0;
dang=\"1110\";
endif;
endif;
endprocess;
endcorn_arc;
是自动换挡的计数器计数器为十进制加法计数器,当CLR为高电平时,计数器清零;当CLR为低电平,并且DOOR为高电平时,允许计数。次频率计分为4个档位,当计数值大于9999时,频率计处于超量程状态,下一次测量时,量程自动增大1档。当计数值小于0001时,频率计处于欠程状态,下一次测量时,量程自动减小1档。当超量程的时候ALM报警。

这是代码不知道哪错了仿真的时候输出总是0000
回复

使用道具 举报

千问 | 2011-6-26 04:10:53 | 显示全部楼层
你的cqigewei,cqishiwei定义为signal,所以在加1的时候应该是“0001”或者‘1’吧好像。。还有
cqigewei9应该是cqigewei\"1001\"
还有ifcqigewei=1then
ifcqishiwei=2then
能这样写吗写成cqigewei=“0001”和cqishiwei=“0010”,至于你的逻辑应该是对的。。


你修改一下这类错误,,看看对不。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行