Vhdl habilitar sin pregunta de reloj

0

Hice este código y me pregunto qué debo hacer para poner una habilitación sin un reloj.

¿Tengo que poner cada línea por una si? Gracias por adelantado. ¿Me gusta esto?

if(enable = '1') then
            if(binInput = "0001") then 
            decOut_n <= "1111001"


library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity Bin7SegDecoder is
    port( enable   : in std_logic;
            binInput : in std_logic_vector(3 downto 0);
            decOut_n : out std_logic_vector(6 downto 0));
end Bin7SegDecoder;

architecture Behavioral of Bin7SegDecoder is
begin
        decOut_n <= "1111001" when (binInput = "0001") else --1
                        "0100100" when (binInput = "0010") else --2
                        "0110000" when (binInput = "0011") else --3
                        "0011001" when (binInput = "0100") else --4
                        "0010010" when (binInput = "0101") else --5
                        "0000010" when (binInput = "0110") else --6
                        "1111000" when (binInput = "0111") else --7
                        "0000000" when (binInput = "1000") else --8
                        "0010000" when (binInput = "1001") else --9
                        "0001000" when (binInput = "1010") else --A
                        "0000011" when (binInput = "1011") else --B
                        "1000110" when (binInput = "1100") else --C
                        "0100001" when (binInput = "1101") else --D
                        "0000110" when (binInput = "1110") else --E
                        "0001110" when (binInput = "1111") else --F
                        "1000000"; --0

    end if;
end Behavioral;
    
pregunta João

1 respuesta

0

Puede insertar una condición en cada línea:

library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity Bin7SegDecoder is
    port( 
        enable   : in std_logic;
        binInput : in std_logic_vector(3 downto 0);
        decOut_n : out std_logic_vector(6 downto 0)
    );
end Bin7SegDecoder;

architecture Behavioral of Bin7SegDecoder is
begin
    process(binInput, enable)
    begin
        decOut_n <= "1111001" when (binInput = "0001") and enable = '1' else --1
                    "0100100" when (binInput = "0010") and enable = '1' else --2
                    "0110000" when (binInput = "0011") and enable = '1' else --3
                    "0011001" when (binInput = "0100") and enable = '1' else --4
                    "0010010" when (binInput = "0101") and enable = '1' else --5
                    "0000010" when (binInput = "0110") and enable = '1' else --6
                    "1111000" when (binInput = "0111") and enable = '1' else --7
                    "0000000" when (binInput = "1000") and enable = '1' else --8
                    "0010000" when (binInput = "1001") and enable = '1' else --9
                    "0001000" when (binInput = "1010") and enable = '1' else --A
                    "0000011" when (binInput = "1011") and enable = '1' else --B
                    "1000110" when (binInput = "1100") and enable = '1' else --C
                    "0100001" when (binInput = "1101") and enable = '1' else --D
                    "0000110" when (binInput = "1110") and enable = '1' else --E
                    "0001110" when (binInput = "1111") and enable = '1' else --F
                    "1000000"; --0
    end process;

end Behavioral;

O haga un if para todas las declaraciones:

...
architecture Behavioral of Bin7SegDecoder is
begin
    process(binInput, enable)
    begin
        if enable = '1' then
            decOut_n <= "1111001" when (binInput = "0001") else --1
                        "0100100" when (binInput = "0010") else --2
                        "0110000" when (binInput = "0011") else --3
                        "0011001" when (binInput = "0100") else --4
                        "0010010" when (binInput = "0101") else --5
                        "0000010" when (binInput = "0110") else --6
                        "1111000" when (binInput = "0111") else --7
                        "0000000" when (binInput = "1000") else --8
                        "0010000" when (binInput = "1001") else --9
                        "0001000" when (binInput = "1010") else --A
                        "0000011" when (binInput = "1011") else --B
                        "1000110" when (binInput = "1100") else --C
                        "0100001" when (binInput = "1101") else --D
                        "0000110" when (binInput = "1110") else --E
                        "0001110" when (binInput = "1111") else --F
                        "1000000"; --0
        end if;
    end process;

end Behavioral;

Pero de todos modos no deberías poner if fuera de
architecture Behavioral of Bin7SegDecoder is begin ... end Behavioral
esta parte del código

    
respondido por el Roman

Lea otras preguntas en las etiquetas