vhdl - 找到运算符“-”的“0”定义,无法确定“-”的精确重载匹配定义
问题描述
如何处理给定代码中的以下错误
找到运算符“-”的“0”定义,无法确定“-”的精确重载匹配定义
代码:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
use IEEE.NUMERIC_STD.ALL;
library STD, WORK;
use STD.STANDARD.all;
entity sqrrootofnum is
Port ( d : in STD_LOGIC_VECTOR (31 downto 0);
`` output : out STD_LOGIC_VECTOR (15 downto 0)
);
end sqrrootofnum;
architecture Behavioral of sqrrootofnum is
signal regi:STD_LOGIC_VECTOR (31 downto 0);
signal q:STD_LOGIC_VECTOR (15 downto 0);
signal j:STD_LOGIC_VECTOR (1 downto 0);
signal z:STD_LOGIC_VECTOR (14 downto 0);
begin
process(d)
begin
j<="01"; if d(31 downto 30) > 01 then
regi(1 downto 0) <= d(31 downto 30)-01; q(15 downto 15)<="1";
else
regi(1 downto 0) <= d(31 downto 30); q(15 downto 15)<="0";
end if;
for k in 2 to 16 loop
if ((regi(2*(k-1)-1 downto 0) & d(2*(k-1) downto 2*(k-1)-1))-(z(k-2 downto 0) & q(15 downto 15-(k-2)) & j)) then
regi(2*(k-1)+1 downto 0)<= ((regi(2*(k-1)-1 downto 0) & d(2*(k-1) downto 2*(k-1)-1))-(z(k-2 downto 0) & q(15 downto 15-(k-2)) & j))
q(15-(k-1) downto 15-(k-1)) <= "1";
else
regi(2*(k-1)+1 downto 0) <= (regi(2*(k-1)-1 downto 0) & d(2*(k-1) downto 2*(k-1)-1));
q(15-(k-1) downto 15-(k-1))<="0";
end if;
end loop;
output <=q;
end process;
end Behavioral;
解决方案
此代码中存在多个问题,但我认为此特定错误是由这一行引起的:
regi(1 downto 0) <= d(31 downto 30) - 01;
d 是一个 std_logic_vector 所以它不能被解释为一个数字 - 因此你不能使用减法运算符。执行此操作时,您要么需要将 d 声明为无符号,要么将其强制转换为无符号。
推荐阅读
- excel - 将多个工作簿中的数据合并到一个工作表中
- excel - 如何在特定文本之后和数字之前删除,然后使用 VBA 删除重复项?
- c++ - CString 回文测试
- xamarin - 使用 rg.plugin.popup 的按钮命令未找到绑定的 ViewModel
- html - 使用 CSS 访问网页的背景
- react-native - 更新到 React Native 0.61.3 后排毒选择器失败
- conditional-statements - 是否有等效于 c# 的 .All 的 javascript?
- react-native - 如何修复自定义反应导航组件中的“navigation.state 未定义”?
- jquery - 只调用一次 'require("jquery")'
- python-3.x - 按数据框分组并查找组