【问题标题】:can't determine definition of operator ""/"" -- found 0 possible definitions无法确定运算符 ""/"" 的定义 -- 找到 0 个可能的定义
【发布时间】:2018-07-24 23:31:47
【问题描述】:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;


port (
  clk, rst : in std_logic;
  data_in : in  std_logic_vector(7 downto 0);
  data_out : out std_logic_vector(7 downto 0)
 );

signal div : std_logic_vector(7 downto 0);

如何解决此行的以下错误:

div <= data_in / "00001011";

错误:无法确定运算符“”/“”的定义——找到 0 可能的定义

【问题讨论】:

  • 你认为std_logic_vector代表什么?这只是一堆电线。你怎么算术呢?使用unsigned 并除以一个整数。不过,除法将需要大量资源……除非它是 2 的幂
  • 您不能(可移植地)混合和匹配 Synopsys 和 IEEE 数学软件包。 std_logic_unsigned 依赖于 Synopsys 包 std_logic_aritth 的无符号类型声明、运算符和函数。 numeric_std 或 std_logic_unsigned 都没有为带有 std_logic_vector 参数和结果的“/”运算符提供声明。在这里使用它们是没有用的。如果您有能力使用 -2008 模式,则可以使用 IEEE 包 numeric_std_unsigned,否则 numeric_std 将参数类型转换为无符号并将赋值右手表达式转换为 std_logic_vector。
  • 对于不同的 VHDL 操作符,由于工具供应商的不同,同一错误有四种常见变体,错误由标准定义。 no function declarations for operator有深入的解释。

标签: vhdl fpga quartus


【解决方案1】:

如果你真的想做这个划分(它是资源密集型的)使用:

div <= std_logic_vector(unsigned(data_in)/unsigned'("00001011"));

VHDL 是强类型的,因此您必须在单位之间显式转换。有些行可能会很长!

【讨论】:

  • data_instd_logic_vector,函数 to_unsigned 将无法编译。
  • @grorel 在我的机器上编译得很好。除非我错过了什么
  • 函数原型是function TO_UNSIGNED (ARG, SIZE : NATURAL) return UNRESOLVED_UNSIGNED;你用的是哪个库?
  • @grorel 我正在使用library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all;
  • @grorel Gah,你完全正确。我不知道我最后的评论来自哪里。更新了答案
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-09-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多