我試圖2。減去STD邏輯矢量,並得到誤差VHDL減法std_logic_vector
p2 <= p1(11 downto 0)- idata(11 downto 0);
錯誤(10327):在sub.vhd VHDL錯誤(32):不能確定操作者的定義「 「 - 」」 - 發現0可能的定義
我已經嘗試添加use IEEE.std_logic_signed.all
或use IEEE.std_logic_unsigned.all
或兩者並已經嘗試過 p2 <= std_logic_vector(unsigned(p1(11 downto 0)) - unsigned(idata(11 downto 0)));
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
--use IEEE.std_logic_signed.all;
--use IEEE.std_logic_unsigned.all;
entity sub is
port (
clk : in std_logic;
rst : in std_logic;
--en : in std_logic;
idata : in std_logic_vector (11 downto 0);
odata : out std_logic_vector (11 downto 0)
);
end sub;
architecture beh of sub is
signal p1,p2 :std_logic_vector (11 downto 0);
begin
process (clk, rst)
begin
if (rst = '1') then
odata <= "000000000000";
elsif (rising_edge (clk)) then
p1 <= idata;
p2 <= p1(11 downto 0)- idata(11 downto 0);
--p2 <= std_logic_vector(unsigned(p1(11 downto 0)) - unsigned(idata(11 downto 0)));
end if;
end process;
odata<=p2;
end beh;
此外,VHDL標準的-2008版本還包含一個numeric_std_unsigned包,它爲std_logic_vector提供了無符號操作包裝。 – user1155120
使用'numeric_std_unsigned'包更新了符合VHDL-2008標準的代碼。 –