“If”(VHDL)附近的语法错误

时间:2014-09-10 01:32:05

标签: if-statement syntax vhdl

我收到以下错误“第44行:”“If”附近的语法错误。“和65,67,69,73行中的类似内容(除了一些”Else“和其他”If“s) 。

这可能是一个非常愚蠢的问题,但任何人都可以提供帮助吗? :)

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity Four_Bit_Adder_Decimal_Output is
    Port ( A : in  STD_LOGIC_VECTOR (3 downto 0);
           B : in  STD_LOGIC_VECTOR (3 downto 0);
           Cin : in  STD_LOGIC;
           Res : out  STD_LOGIC_VECTOR (4 downto 0);
           Cout : out  STD_LOGIC;
           Dsp : out  STD_LOGIC_VECTOR (3 downto 0);
           Seg : out  STD_LOGIC_VECTOR (6 downto 0));
end Four_Bit_Adder_Decimal_Output;  

architecture Four_Bit_Adder_Decimal_Output_Arch of Four_Bit_Adder_Decimal_Output is
    --Embedded signals
    signal Tmp : STD_LOGIC_VECTOR (4 downto 0);

begin
    --Display Selection
    Dsp <= "0111";

    --Check if any of the 4-bit inputs are bigger than 9
    If ((A < 9) and (B < 9)) = '1' Then
        Tmp   <= ("00000" & A) + (B & "00000") + ("00000" & Cin);
        Res   <= Tmp;
        Cout    <= Tmp(4);
        --Output must be in decimal, so you print the first digit in the display
        seg     <= "1000000" when (Tmp = X"0") else
                   "1111001" when (Tmp = X"1") else
                   "0100100" when (Tmp = X"2") else
                   "0110000" when (Tmp = X"3") else
                   "0011001" when (Tmp = X"4") else
                   "0010010" when (Tmp = X"5") else
                   "0000010" when (Tmp = X"6") else
                   "1111000" when (Tmp = X"7") else
                   "0000000" when (Tmp = X"8") else
                   "0010000" when (Tmp = X"9") else
                   "1000000" when (Tmp = X"A") else
                   "1111001" when (Tmp = X"B") else
                   "0100100" when (Tmp = X"C") else
                   "0011001" when (Tmp = X"D") else
                   "0010010" when (Tmp = X"F");
        --Check if result has 2 digits, then turn ON Cout
        If (Tmp >= 10) Then
            Cout <= '1';
        Else
            Cout <= '0';
        End If;
    Else          -- If any of the inputs is bigger than 9, throw an error
        --Put "E" in the display
        Seg <= "0000110";
    End If;
end Four_Bit_Adder_Decimal_Output_Arch;

1 个答案:

答案 0 :(得分:1)

if语句始终用作顺序语句。您可以在诸如进程或子程序(函数/过程)之类的位置找到顺序语句。

architecture Four_Bit_Adder_Decimal_Output_Arch of Four_Bit_Adder_Decimal_Output is
    ...
begin
    ...
    process(all) is begin
        if ((A < 9) and (B < 9)) = '1' then
        ...
        end if;
    end process;
end architecture Four_Bit_Adder_Decimal_Output_Arch;

-daniel

相关问题