【发布时间】:2017-04-08 05:44:30
【问题描述】:
我正在尝试在 VHDL 中创建一个 std_logic_vectors 数组。该数组在生成语句中用于制作桶形移位器。数组的每个元素(数组、向量)都应该是一个可单独寻址的位。这是我的一些代码。
信号声明:
type stage_t is array( 4 downto 0 ) of std_logic_vector ( 15 downto 0);
signal stages: stage_t;
在架构中:
test_stage: for st in 0 to 4 generate
test_bit_assign: for st_bit in 0 to 15 generate
test_stagemux: entity work.mux2_1 port map (
S => amt(st),
M0 => stages(st,st_bit), M1 => stages(st,st_bit+log_w),
O => stages(st+1,st_bit)
);
end generate;
2:1 多路复用器的实体:
entity mux2_1 is
generic ( n : INTEGER := 8);
port (
S : in std_logic; -- select
M0, M1 : in std_logic;
O : out std_logic
);
end mux2_1;
我得到的错误:
Indexed name prefix type stage_t expects 1 dimensions
这发生在我读取或写入阶段数组的任何地方。如何寻址其中一个向量的位?
【问题讨论】:
-
您还可以将类型 stage_t 声明为
type stage_t is array( 4 downto 0, 15 downto 0) of std_logic;并使其成为一个二维数组,在端口映射中保留您的关联。如果没有Minimal, Complete and Verifiable example,很难准确预测您将遇到的下一个问题。 -
Stages 是一维类型 (stage_t)。尝试按照
M0 => stages(st)(st_bit),的行,其中维度索引中的st,stages(st) 是一个索引名称,指定stage_t 的哪个元素,并且是使用st_bit 作为std_logic_vector 元素的索引命名的索引的前缀t。您正在尝试将阶段作为多维数组来处理,但事实并非如此。它的元素恰好是一个数组类型。 -
@J.H.Bonarius 是的,有些用户坚持在 cmets 中回答问题:/
标签: arrays vhdl xilinx-ise digital-logic