VHDL 中数组的硬件表示

发布于 2024-08-24 10:10:56 字数 99 浏览 6 评论 0原文

使用 VHDL,我想要一些寄存器,每个寄存器存储 16 位。 所以我发现VHDL有一个内置数组,我想用它来存储iy中每个元素的16位,所以我想知道VHDL是否将此数组映射到实际寄存器?

Using VHDL i want to have a some registers that store 16 bit in each one.
So i found that VHDL have a built in array,and i want to use it to store 16 bit in each element in iy so i want to know if VHDL map this array to actual registers or not?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

℡Ms空城旧梦 2024-08-31 10:10:56

简短的回答是否定的 - 数组类型不映射到寄存器。

长答案:

VHDL 中的数组类型只是相同类型元素的索引集合。在您的情况下,您可能会使用数组作为寄存器组的输出。

因此,假设您有一组 8 个寄存器,每个寄存器保存 16 位。该组的输出将是一个 16 位向量的数组(大小为 8)。该寄存器组的组件声明如下所示:

 component reg8x16
  port(
   clock: in std_logic;
   reset: in std_logic;
   enable: in std_logic;
   rout : out r_array(0 to 7)
   );
 end component; 

rout 是寄存器组中已注册输出的数组。因此,您可以使用 rout(0) 从存储体取消引用寄存器 0 的输出,其类型为 std_logic_vector(15 downto 0)

另外,不要忘记在某处声明数组类型(通常在包文件中)。它看起来像:

type r_array is array (integer range <>) of std_logic_vector(15 downto 0);

(integer range <>) 语句是数组索引范围的一种占位符 - 稍后当使用数组类型时(例如在上面的组件声明中),它将被填充。

我不确定这是否回答了你的问题。我不会详细介绍如何创建 reg8x16 组件。基本上,您只需创建一个 16 位寄存器,其输出类型为 std_logic_vector(15 downto 0); (您可以在线查找如何执行此操作...这是非常基本的 VHDL)。然后,您只需实例化其中 8 个寄存器,并将它们放入名为 reg8x16 的组件中。

The short answer is no - the array type does not map to a register.

The long answer:

The array type in VHDL is just an indexed collection of elements of the same type. In your case, you'd probably use an array as the output from a register bank.

So, say you have a bank of 8 registers each holding 16 bits. The output from this bank would be an array (of size 8) of 16-bit vectors. The component declaration for this register bank would look something like this:

 component reg8x16
  port(
   clock: in std_logic;
   reset: in std_logic;
   enable: in std_logic;
   rout : out r_array(0 to 7)
   );
 end component; 

rout is your array of registered outputs from the register bank. So you can dereference the output of register 0 from the bank using rout(0), which is of type std_logic_vector(15 downto 0).

Also, don't forget to declare the array type somewhere (usually in a package file). It would look something like:

type r_array is array (integer range <>) of std_logic_vector(15 downto 0);

The (integer range <>) statement is a kind of placeholder for the array index range - it will be filled in later when the array type is used (such as in our component declaration above).

I'm not sure if this answers your question or not. I won't go into the specifics of how to create the reg8x16 component. Basically, you just create a 16-bit register whose output is of type std_logic_vector(15 downto 0); (you can look up how to do this online...it's pretty basic VHDL). Then you just instantiate 8 of those registers, and put them in the component named reg8x16.

物价感观 2024-08-31 10:10:56

数组就像任何其他变量或信号一样:如果您描述一种行为,这意味着它必须记住从一个时钟周期到另一个时钟周期的状态,那么合成器将推断出触发器(或内存块,如果条件正确)。

An array is just like any other variable or signal: If you describe a behaviour which means it must remember its state from one clock tick to another, then flipflops (or memory blocks, if the conditions are right) will be inferred by the synthesiser.

梨涡少年 2024-08-31 10:10:56

任何具有有效范围的数组都将映射到生成的网表中的连线。这是相当明显的——硬件只包含门和电线。像 a(3 downto 0)(1 to 0) 这样的东西会形成 4x2 或 8 位大小的线。现在,您将像 a(3)(1) 这样的单独访问映射到这个一维数组中的索引。所以 a(3)(1) 基本上就是 a(7)。

Any array with a valid range would map to wires in generated netlist. This is fairly obvious- hardware contains only gates and wires. Something like a(3 downto 0)(1 to 0) would make to a 4x2 or 8-bit size wire. You now map individual accesses like a(3)(1) to indices in this 1-dimensional array. So a(3)(1) is basically a(7).

绝不放开 2024-08-31 10:10:56

检查页面,另请检查注册 vhdl

基本上它是一个具有所需长度的 std_logic_vector 数组

check this page, also check the register vhdl

basically it is an array of std_logic_vector with the required lengths

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文