gpt4 book ai didi

function - VHDL:意外结束使用函数

转载 作者:行者123 更新时间:2023-12-04 05:32:20 25 4
gpt4 key购买 nike

我正在尝试合成一些我发现的代码,这些代码基本上将 8 位二进制文​​件转换为 BCD。代码使用函数,我有以下错误;

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;

错误指向我的最后一行“结束行为”。我在这里做错了什么?

亲切的问候

最佳答案

架构的定义如下:

architecture identifier of entity_name is
architecture_declarative_part
begin
architecture_statement_part
end optional(architecture) optional(architecture_simple_name) ;

在说之前 端架构 ,你需要说 开始 ,并做架构声明部分(可以为空)

关于function - VHDL:意外结束使用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12416883/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com