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
|