2
본질적으로 8 비트 바이너리를 BCD로 변환하는 코드를 합성하려고합니다. 이 코드는 함수를 사용하며 다음과 같은 오류가 발생합니다.VHDL : 예기치 않은 END 함수 사용
Line #: parse error, unexpected END
다음은 내 코드의 일부입니다.
architecture Behavioral of bintobcd is
function to_bcd (bin : std_logic_vector(7 downto 0)) return std_logic_vector is
variable i : integer:=0;
variable bcd : std_logic_vector(11 downto 0) := (others => '0');
variable bint : std_logic_vector(7 downto 0) := bin;
begin
for i in 0 to 7 loop -- repeating 8 times.
bcd(11 downto 1) := bcd(10 downto 0); --shifting the bits.
bcd(0) := bint(7);
bint(7 downto 1) := bint(6 downto 0);
bint(0) :='0';
if (i < 7 and bcd(3 downto 0) > "0100") then --add 3 if BCD digit is greater than 4.
bcd(3 downto 0) := bcd(3 downto 0) + "0011";
end if;
if (i < 7 and bcd(7 downto 4) > "0100") then --add 3 if BCD digit is greater than 4.
bcd(7 downto 4) := bcd(7 downto 4) + "0011";
end if;
if (i < 7 and bcd(11 downto 8) > "0100") then --add 3 if BCD digit is greater than 4.
bcd(11 downto 8) := bcd(11 downto 8) + "0011";
end if;
end loop;
return bcd;
end to_bcd;
end Behavioral;
오류는 마지막 행의 "end behavioral"을 가리 킵니다. 여기서 내가 뭘 잘못하고 있니? 하는 수 (
architecture identifier of entity_name is
architecture_declarative_part
begin
architecture_statement_part
endoptional(architecture) optional(architecture_simple_name) ;
당신은 끝이 아키텍처, 당신은 이을 시작하고, 아키텍처 문 부분을 말할 필요가 말을하기 전에 :
종류는 다음과 같이 아키텍처의 정의는
고마워요, 고쳐 주셨습니다. 필자는 아키텍처 문 내부의 함수를 선언했지만 본질적으로 선언적 부분에 있어야했습니다. – Triple777er