具有动态宽度的通用 std_logic_vector 的位顺序
Bit order for generaic std_logic_vector with dynamic width
我有一个通用的 std_logic_vector
,这里建议使用动态长度:
entity lfsr is
generic(
INIT : std_logic_vector
);
[...]
end entity;
稍后,我想以顺序重要的方式单独访问 INIT
的位。我怎样才能确保 INIT
的位顺序将始终是 downto
位顺序(例如 3 downto 0
当具有 4 位长度时)而不是 to
顺序(对于例如 0 to 3
)?
假设您的矢量稍后将连接到外部块,您无法确保任何事情。当你连接它时,你只需要关心它。
ASSERT INIT'left >= INIT'right REPORT "INIT Bit Order Error" SEVERITY FAILURE;
如果你的测试平台成功阐述,你知道顺序是正确的。
您可以使用对象别名提供确定性下降范围:
library ieee;
use ieee.std_logic_1164.all;
entity lfsr is
generic (
INIT: std_logic_vector
);
-- In the entity declarative part:
alias DINIT: std_logic_vector(INIT'LENGTH - 1 downto 0) is INIT;
end entity lfsr;
在您之前使用 INIT 的架构中使用 DINIT。
您可以在通用声明范围内的体系结构块声明部分或体系结构中的任何声明区域(例如过程语句、块语句、generic_statement、子程序定义)中为 INIT 添加别名:
library ieee;
use ieee.std_logic_1164.all;
entity lfsr is
generic (
INIT: std_logic_vector
);
end entity lfsr;
architecture foo of lfsr is
alias DINIT: std_logic_vector(INIT'LENGTH - 1 downto 0) is INIT;
begin
end architecture;
我有一个通用的 std_logic_vector
,这里建议使用动态长度:
entity lfsr is
generic(
INIT : std_logic_vector
);
[...]
end entity;
稍后,我想以顺序重要的方式单独访问 INIT
的位。我怎样才能确保 INIT
的位顺序将始终是 downto
位顺序(例如 3 downto 0
当具有 4 位长度时)而不是 to
顺序(对于例如 0 to 3
)?
假设您的矢量稍后将连接到外部块,您无法确保任何事情。当你连接它时,你只需要关心它。
ASSERT INIT'left >= INIT'right REPORT "INIT Bit Order Error" SEVERITY FAILURE;
如果你的测试平台成功阐述,你知道顺序是正确的。
您可以使用对象别名提供确定性下降范围:
library ieee;
use ieee.std_logic_1164.all;
entity lfsr is
generic (
INIT: std_logic_vector
);
-- In the entity declarative part:
alias DINIT: std_logic_vector(INIT'LENGTH - 1 downto 0) is INIT;
end entity lfsr;
在您之前使用 INIT 的架构中使用 DINIT。
您可以在通用声明范围内的体系结构块声明部分或体系结构中的任何声明区域(例如过程语句、块语句、generic_statement、子程序定义)中为 INIT 添加别名:
library ieee;
use ieee.std_logic_1164.all;
entity lfsr is
generic (
INIT: std_logic_vector
);
end entity lfsr;
architecture foo of lfsr is
alias DINIT: std_logic_vector(INIT'LENGTH - 1 downto 0) is INIT;
begin
end architecture;