這裏是我的一個簡單的ALU是加減類型不匹配錯誤,如何解決這個
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
library IEEE;
use IEEE.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity alu is
Port (A : in STD_LOGIC_VECTOR (15 downto 0);
B : in STD_LOGIC_VECTOR (15 downto 0);
funct: in STD_LOGIC;
op: in STD_LOGIC_VECTOR (1 downto 0);
Result : out STD_LOGIC_VECTOR (15 downto 0));
end alu;
architecture Behavioral of alu is
begin
process (op, funct)
begin
case op is
when "00" => Result <= A+B;
when "01" => Result <= A-B;
when others => case funct is
when "0" => Result <= A+B;
when "1" => Result <= A-B;
when others => null;
end case;
`end case;
end process;
end Behavioral;
我收到以下錯誤
ERROR:HDLParsers:800 - "E:/Xilinx Projects/alu/alu.vhd" Line 51. Type of funct is incompatible with type of 0.
ERROR:HDLParsers:800 - "E:/Xilinx Projects/alu/alu.vhd" Line 52. Type of funct is incompatible with type of 1.
ERROR:HDLParsers:163 - "E:/Xilinx Projects/alu/alu.vhd" Line 55. Unexpected symbol read: `.
代碼,我知道這事做類型不匹配的'功能'和'結果',但我不知道如何解決它,任何想法?
'0'是一個字符字面量或std_logic字面量。 「0」是一個字符串。這些有不同的類型。 –
另外,在第二個結尾的情況之前有一個嚴重的重音字符;'。您的代碼片段行數不匹配,我們可能會認爲是第55行。正如Brian所說,應該將這些「0」和「1」字符串分別更改爲字符文字「0」和「1」,並刪除嚴重重音字符你的代碼會分析。只有在IEEE Std 1076-2008的VHDL中才有重音符號,用於表示工具指令。 – user1155120
你們是對的,非常感謝您的幫助,嚴重的口音被誤輸入了! – alexhilton