gpt4 book ai didi

compiler-errors - “'附近” : syntax error

转载 作者:行者123 更新时间:2023-12-02 11:14:33 26 4
gpt4 key购买 nike

我在VHDL中编写了以下代码:

library IEEE ;
use IEEE.STD_LOGIC_1164.all ;


entity encoder is
port(
x : in std_logic_vector (7 downto 0);
en : in std_logic ;
y : out std_logic_vector (2 downto 0));
end encoder;

architecture enc_arch of encoder is
begin

process(en,x)
begin
if (en ='0') then
y<= "000";
else
y<= "001" when (x = '00000010') else
'010' when (x = '00000100') else
'011' when (x = '00001000') else
'100' when (x = '00010000') else
'101' when (x = '00100000') else
'110' when (x = '01000000') else
'111' when (x = '10000000') else
'000' ;
end if ;
end process ;

end enc_arch;
错误是:

vhd(20): near "'": syntax error

vhd(30): VHDL Compiler exiting


谁能帮助我解决这些问题?

最佳答案

(x = '10000000')(以及所有类似的行)应将''更改为“”:(x = "10000000")
这是因为单引号用于std_logic,而双引号用于std_logic_vector。

也:
{library IEEE ;应该是:library IEEE ;
并且end enc_arch;}应该是end enc_arch;

关于compiler-errors - “'附近” : syntax error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48262775/

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