"); //-->
Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_arith.all;
Entity Exercise_4_13 IS
Port(
Din : in std_logic_vector(6 downto 0); --7人表决信号输入,同意为‘1’,不同意为‘0’
Red,Green: out std_logic --表决通过绿指示灯亮,表决不通过红指示灯亮
);
End Entity Exercise_4_13;
Architecture Art3 OF Exercise_4_13 IS
Signal sum: integer range 0 to 7;
Begin
U1: Process(Din)
Begin
sum <= conv_integer(Din(0)) + conv_integer(Din(1)) + conv_integer(Din(2)) + conv_integer(Din(3)) + conv_integer(Din(4)) + conv_integer(Din(5)) + conv_integer(Din(6));
--sum <= Din(0) + Din(1) + Din(2) + Din(3) + Din(4) + Din(5) + Din(6); --这种加法运算没有定义
End Process U1;
U2: Process(sum)
Begin
if sum >= 4 then
Green <= '1';
Red <= '0';
else
Green <= '0';
Red <= '1';
end if;
End Process U2;
End Architecture Art3;
*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。