2

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;
4

2 に答える 2

6

それを行う方法は、'(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します。

于 2013-02-15T13:08:26.507 に答える
1

集約はあなたが必要とするものです:

(others => '0')ベクトル内のすべてのビットを「0」に設定します

(others => (others => '0'))ベクトルの配列のすべての要素をすべてのビット「0」に設定します

(others => (others => (others => '0')))...など:)

于 2013-02-18T13:53:10.037 に答える