有哪位EDA或者VHDL高手能帮我改一下下面的程序,是一个五人表决器的程序,本人有急用,非常感谢!!

Library IEEE;
Use IEEE.std_logic_1164.all;
Use IEEE.std_logic_arith.all;
Use IEEE.std_logic_unsigned.all;

Entity vote is
port(D:in STD_LOGIC_VECTOR(4 downto 0);
S:in bit;
ledout:out STD_LOGIC);
End vote;

Architecture votes of vote is
--Signal x:std_logic_vector(4 downto 0);
--signal y:std_logic;
signal count:std_logic_vector(2 downto 0);
Begin
Process(D,s,count)
Variable middle1,middle2,middle3,middle4,middle5:STD_LOGIC;
Begin
--x<="00000";
if S='0' then
middle1:='0';
middle2:='0';
middle3:='0';
middle4:='0';
middle5:='0';
count<="000";
else
middle1:=D(0);
middle2:=D(1);
middle3:=D(2);
middle4:=D(3);
middle5:=D(4);
end if;
if (middle1'event and middle1='1')then
count<=count+1;
end if;
if (middle2'event and middle2='1') then
count<=count+1;
end if;
if (middle3'event and middle3='1') then
count<=count+1;
end if;
if (middle4'event and middle4='1') then
count<=count+1;
end if;
if (middle5'event and middle5='1') then
count<=count+1;
end if;
if(count>="011" and count<="101") then
ledout<='1';
end if;
end process ;
End votes;
在编译的时候总有错误,就是if (middle1'event and middle1='1')then 这一句。

第1个回答  2008-05-02
我感觉是count这个信号有多重时钟驱动了 假如D中有2位以上发生0->1的跳边 count加1就会出现不确定结果
可以想象成一个加法器后面跟一个D触发器,s是异步置位端,而时钟输入居然有5个,你说这样的电路正常吗
解决办法就是把middle1 middle2...这几个信号经过一个或门 然后用这个或门的输出作为DFF的时钟触发 即count+1更新的条件
第2个回答  2014-11-19
参考答案:两个相邻的具有同样名称的音之间的音域叫做八度。本回答被提问者采纳