我正在尝试在VHDL中使用多维数组,我在使其正常工作方面遇到了很多麻烦 . 我的问题是我有一个由16个向量组成的数组,它们具有给定大小 . 我想要做的是创建17个寄存器,这些寄存器是16位的32 * std_logic_vector数组(= b,512) . 所以,我试图在寄存器实例化中传递输入和输出的东西,告诉编译器/合成器我想要传递512位的东西......类似于C,如果我有:
int var[COLS][ROWS][ELEMENTS];
memcpy(&var[3].. // I'm talking about 3rd COL here, passing in memory that is ROWS*ELEMENTS long
(我的实际声明在这里:)
type partial_pipeline_registers_type是std_logic_vector的数组(0到16,0到15)(iw - 1 downto 0); signal h_blk_pipelined_input:partial_pipeline_registers_type;
我试过简单地使用h_blk_pipelined_input(0)..直到(16)但这不起作用 . 我得到以下错误,这让我看到我需要双重索引到数组:
ERROR:HDLParsers:821 - (at the register) Wrong index type for h_blk_pipelined_input.
那么我尝试了下面的内容,我得到了这个错误:
ERROR:HDLParsers:164 - (at the register code). parse error, unexpected TO, expecting COMMA or CLOSEPAR
instantiate_h_pipelined_reg : regn
generic map ( N=> b, init => bzeros )
port map ( clk => clk , rst => '0', en => '1',
input => h_blk_pipelined_input((i - 1), 0 to 15),
output=> h_blk_pipelined_input((i), 0 to 15));
-- Changing 0 to 15 to (0 to 15) has no effect...
我正在使用XST,并且从他们的文档(http://www.xilinx.com/itp/xilinx6/books/data/docs/xst/xst0067_9.html)中,上面应该有效:
...declaration:
subtype MATRIX15 is array(4 downto 0, 2 downto 0)
of STD_LOGIC_VECTOR (7 downto 0);
A multi-dimensional array signal or variable can be completely used:
Just a slice of one row can be specified:
MATRIX15 (4,4 downto 1) <= TAB_B (3 downto 0);
另一种选择是我可以创建更多16倍小的寄存器,而不是一次尝试所有“0到15”,我只会再做15次 . 但是,我认为这可能导致合成效率低下,我觉得这不是正确的解决方案 .
EDIT:
试过Ben说的,
instantiate_h_m_qa_pipeline_registers: for i in 1 to 16 generate
instantiate_h_pipelined_reg : regn
generic map ( N=> b, init => bzeros )
port map ( clk => clk , rst => '0', en => '1',
input => h_blk_pipelined_input(i - 1),
output=> h_blk_pipelined_input(i));
end generate instantiate_h_m_qa_pipeline_registers;
信号现在定义为:
type std_logic_block is array (0 to 15) of std_logic_vector(iw - 1 downto 0) ;
type partial_pipeline_registers_type is array (0 to 16) of std_logic_block;
signal h_blk_pipelined_input : partial_pipeline_registers_type;
我从XST得到的错误是:
ERROR:HDLParsers:800 - ((where the register part is)) Type of input is incompatible with type of h_blk_pipelined_input.
我能够做我之前能做的所有事情,使用()()语法代替(,)所以我没有丢失任何东西这样做,但它仍然无法解决我的问题 .
EDIT:
进一步使用转换函数对input =>和output =>参数进行寄存器实例化,使用函数在数组类型和std_logic_vector之间转换我需要的大小 . 它修复了'input =>'部分,但..
Actual associated with Formal OUT mode Signal 'output' may not be a type conversion or function call. (LRM 4.3.2.2)
2 回答
怎么样:
Xilinx网站上的代码显然未经过测试 . 由于
ARRAY OF ...
是类型,而不是子类型,因此它们的代码不应该编译 .编辑:这些自定义类型不能很好地适应现有的IP组件,但没关系,编译器可以很容易地推断寄存器 . 尝试:
为了使事情正常发挥,我不得不使用一个函数来展平和解除与寄存器实例化交互的数据 .
真正的问题归结为我有一个std_logic_vector()数组导致一个大的向量,寄存器实例化需要...然后寄存器给我回到矢量,我需要放入一个数组向量 .
创建一个函数然后执行以下操作非常有效 .