VHDL로 BCD 컨버터 구현중에 루프문에 에러가 떴습니다.
조회수 585회
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity BCD_converter8 is
port(X: in std_logic_vector(7 downto 0);
S: out std_logic_vector(11 downto 0));
end BCD_converter8;
architecture sample of BCD_converter8 is
signal f1, f2, f3: std_logic_vector(3 downto 0);
signal n1, n2, n3: integer;
signal i: integer;
signal a, b: integer;
begin
a <= conv_integer(X, 8);
b <= a / 10;
n1 <= b / 10;
n2 <= b rem 10;
n3 <= a rem 10;
for i in 1 to 3 loop
case ni is
when '0' => fi <= "0000";
when '1' => fi <= "0001";
when '2' => fi <= "0010";
when '3' => fi <= "0011";
when '4' => fi <= "0100";
when '5' => fi <= "0101";
when '6' => fi <= "0110";
when '7' => fi <= "0111";
when '8' => fi <= "1000";
when '9' => fi <= "1001";
when others => null;
end case;
end loop;
S(11 downto 8) <= f1(3 downto 0);
S(7 downto 4) <= f2(3 downto 0);
S(3 downto 0) <= f3(3 downto 0);
end sample;
2진수에서 BCD코드로 변환하는 코드입니다. 10으로 나눠준 후 나머지와 몫을 이용해 각 자릿수를 n1,2,3에 넣어줬습니다.
vhdl에서 loop문을 사용할 때 f1, f2, f3를 fi를 이용해서 반복시킬 수 있는지 궁금합니다.
또 case문과 loop문에서 에러가 뜨는데 에러의 해결방법을 잘 모르겠어서 질문합니다. 에러코드는 아래와 같습니다.
(10500) near text "begin"; expecting "end", of "(", of an identifier ("begin" is a reserved keyword), or a concurrent statement
(10500) near text "when"; expecting "end", of "(", of an identifier ("when" is a reserved keyword), or a concurrent statement
-
(•́ ✖ •̀)
알 수 없는 사용자
댓글 입력