简体   繁体   English

具有通用数据宽度VHDL的多维存储器

[英]Multidimensional memory with generic data width VHDL

I would like to know how to declare a 2-dimensional memory with a generic data width 我想知道如何声明具有通用数据宽度的二维存储器

package mem_pkg is
  subtype data is std_logic_vector(7 downto 0);
  type data_vector is array( natural range <> ) of data;
end;
entity mem is
port (
  clk : in std_logic;
  we : in std_logic -- write enable
  a: in unsigned(4 downto 0); -- address
  di : in data; -- data_in
  do : out data -- data_out
 );
 end mem;

Instead of 7, I want the data width to be generic. 而不是7,我希望数据宽度是通用的。

That's not two dimensional - that's a vector of vectors, which is (subtly) different. 那不是二维的-这是向量的向量,这是(微妙的)不同。

A 2D array is 2D数组是

type data_vector is array (natural range <>, natural range <>) of integer;

But, back to your problem: 但是,回到您的问题:

Until "recently" (VHDL 2008) you couldn't have an unconstrained array of an unconstrained array. 直到“最近”(VHDL 2008),您才能拥有不受约束的数组的不受约束的数组。 But now you can do: 但是现在您可以:

type mem is array(natural range <>) of std_logic_vector;
signal store : mem(0 to 15)(7 downto 0);

" VHDL 2008 - just the new stuff " has much more detail: VHDL 2008-只是新东西 ”有更多细节:

http://books.google.co.uk/books?id=ETxLguPMEY0C&lpg=PA241&ots=q7u_Mn0SFR&dq=vhdl%202008%20just%20the%20new%20stuff%20p%20120&pg=PA120#v=snippet&q=alias%20of%20a%20register%20file%20signal&f=false http://books.google.co.uk/books?id=ETxLguPMEY0C&lpg=PA241&ots=q7u_Mn0SFR&dq=vhdl%202008%20just%20the%20new%20stuff%20p%20120&pg=PA120#v=snippet&q=alias%20of%20a% 20register%20file%20signal&f = false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM