【发布时间】:2014-09-10 01:32:05
【问题描述】:
我收到以下错误“第 44 行:““If”附近的语法错误。”以及第 65、67、69、73 行中的类似错误(除了一些“Else”和其他“If”) .
这可能是一个非常愚蠢的问题,但有人可以帮忙吗? :)
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;
【问题讨论】:
-
您在适合并发语句的位置使用顺序语句(If 语句)。您的代码还有其他问题。
标签: if-statement syntax vhdl