gpt4 book ai didi

arrays - 如何: multidimensional arrays in vhdl

转载 作者:行者123 更新时间:2023-12-02 06:53:55 25 4
gpt4 key购买 nike

我正在尝试在 VHDL 中创建一个 5 维数组,但我不确定如何设置和初始化这些位。

这是我到目前为止所拥有的:

    type \1-line\ is array (4 - 1 downto 0) of unsigned (32 - 1 downto 0);
type square is array (4 - 1 downto 0) of \1-line\;
type cube is array (4 - 1 downto 0) of square;
type hypercube is array (4 - 1 downto 0) of cube;
type \5-cube\ is array (4 - 1 downto 0) of cube;

signal mega_array : \5-cube\;
begin
process (clock, reset) begin
if (reset == '1') then
mega_array <= '0';
end if;
end process;
end behv;

最佳答案

一种方法是使用“(others =>'0')”。这是一种将向量的所有位设置为“0”的干净且安全的方法。您必须对阵列的每一层执行此操作。

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity test is
port (
clock : in std_logic;
reset : in std_logic);
end entity test;

architecture behv of test is

type \1-line\ is array (4 - 1 downto 0) of unsigned (32 - 1 downto 0);
type square is array (4 - 1 downto 0) of \1-line\;
type cube is array (4 - 1 downto 0) of square;
type \5-cube\ is array (4 - 1 downto 0) of cube;

signal mega_array : \5-cube\;

begin

process (clock, reset)
begin
if (reset = '1') then -- note: not '=='
mega_array <= (others => (others => (others => (others => (others => '0')))));
end if;
end process;

end architecture behv;

请注意,虽然 \1-... 命名是正确的 VHDL,但我不会使用它来避免讨厌的工具问题。我不确定它们会来,但避免它们比解决它们更好。我会使用 t_1line 来代替。

关于arrays - 如何: multidimensional arrays in vhdl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14894204/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com