vhdl - 不支持的属性错误
问题描述
我编写了一个 VHDL 函数vectorize()
来将 std_logic_vector 数组(slv_1d_array_type
在我的代码中输入)转换为 std_logic_vector。
Vivado 2018.2[Synth 8-5882] found unsupported attribute ["test_top.vhd":41]
使用以下示例生成此错误。我已将 Vivado 配置为使用 VHDL-2008。
如何使这些'length
属性起作用以避免传递数组大小?
-- Libraries
------------
library ieee;
use ieee.std_logic_1164.all;
------------------------------------------------------------------------------------------------------------------------
-- Entity
------------------------------------------------------------------------------------------------------------------------
entity test_top is
generic(
DATA_WIDTH : positive := 32
);
port(
O_DATA : out std_logic_vector(DATA_WIDTH - 1 downto 0)
);
end entity test_top;
------------------------------------------------------------------------------------------------------------------------
-- Architecture
------------------------------------------------------------------------------------------------------------------------
architecture rtl of test_top is
--------------------------------------------------------------------------------------------------------------------
-- Types definition
--------------------------------------------------------------------------------------------------------------------
type slv_1d_array_type is array (natural range <>) of std_logic_vector; -- One-dimensional std_logic_vector array type.
--------------------------------------------------------------------------------------------------------------------
-- Functions declaration
--------------------------------------------------------------------------------------------------------------------
function vectorize(constant SLV_1D_ARRAY : in slv_1d_array_type) return std_logic_vector is
variable vector_v : std_logic_vector(SLV_1D_ARRAY'length * SLV_1D_ARRAY'element'length - 1 downto 0);
begin
for i in SLV_1D_ARRAY'range loop
vector_v(SLV_1D_ARRAY'element'length * (i + 1) - 1 downto SLV_1D_ARRAY'element'length * i) := SLV_1D_ARRAY(i);
end loop;
return vector_v;
end function vectorize;
--------------------------------------------------------------------------------------------------------------------
-- Signals declaration
--------------------------------------------------------------------------------------------------------------------
signal data_r : slv_1d_array_type(0 to DATA_WIDTH / 8 - 1)(7 downto 0) := (others => (others => '0'));
begin
O_DATA <= vectorize(data_r);
end architecture rtl;
解决方案
根据UG901第 6 章“ VHDL-2008 语言支持”,没有提及'element
属性。所以官方不支持。
来自 Xilinx 论坛的这个帖子声明它受到严重支持,并已从 Vivado 2016.3 开始删除。
但是,上面的代码示例被 ModelSim 10.6c 接受。
@Juergen 提供的解决方法在 Vivado 2018.2 中按预期工作。这是示例的更新版本,包括解决方法:
-- Libraries
------------
library ieee;
use ieee.std_logic_1164.all;
------------------------------------------------------------------------------------------------------------------------
-- Entity
------------------------------------------------------------------------------------------------------------------------
entity test_top is
generic(
DATA_WIDTH : positive := 32
);
port(
O_DATA : out std_logic_vector(DATA_WIDTH - 1 downto 0)
);
end entity test_top;
------------------------------------------------------------------------------------------------------------------------
-- Architecture
------------------------------------------------------------------------------------------------------------------------
architecture rtl of test_top is
--------------------------------------------------------------------------------------------------------------------
-- Types definition
--------------------------------------------------------------------------------------------------------------------
type slv_1d_array_type is array (natural range <>) of std_logic_vector; -- One-dimensional std_logic_vector array type.
--------------------------------------------------------------------------------------------------------------------
-- Functions declaration
--------------------------------------------------------------------------------------------------------------------
function vectorize(constant SLV_1D_ARRAY : in slv_1d_array_type) return std_logic_vector is
variable vector_v : std_logic_vector(SLV_1D_ARRAY'length * SLV_1D_ARRAY(SLV_1D_ARRAY'low)'length - 1 downto 0);
begin
for i in SLV_1D_ARRAY'range loop
vector_v(SLV_1D_ARRAY(SLV_1D_ARRAY'low)'length * (i + 1) - 1 downto SLV_1D_ARRAY(SLV_1D_ARRAY'low)'length * i) := SLV_1D_ARRAY(i);
end loop;
return vector_v;
end function vectorize;
--------------------------------------------------------------------------------------------------------------------
-- Signals declaration
--------------------------------------------------------------------------------------------------------------------
signal data_r : slv_1d_array_type(0 to DATA_WIDTH / 8 - 1)(7 downto 0) := (others => (others => '0'));
begin
O_DATA <= vectorize(data_r);
end architecture rtl;
推荐阅读
- java - 将日期从 java 传递到 ireports 时出现异常
- sql - 如何获取按月排序的数据
- javascript - 为什么不能设置null显示的属性innerhtml
- .net - 此主机上安装了哪个 .NET 版本?
- keras - 在 Keras 中,在模型中使用 Lambda 时无法保存模型检查点。报错 ValueError: can only convert a array of size 1 to a Python scalar
- jquery - 单击复选框时禁用和启用 Jquery Button
- java - Kotlin 生成私有字段:@MyAnnotation 字段不能是私有或静态的
- javascript - 如何处理从父 Promise 链返回的具有各种可能结果的 Promise
- sql - 如何在oracle sql developer中获取用户的FID
- javascript - 如何在运行时跟踪 DIV 的子元素计数?