2

次の型宣言があります。

type cachesubset is record
                      tag     : std_logic_vector(3 downto 0);
                      word0   : w32;
                      word1   : w32;
                      dirty   : std_logic;
                      valid   : std_logic;
                    end record;

type    cacheset is record
                      lru : std_logic;
                      subsets: array(0 to 1) of cachesubset
                    end record;

空のキャッシュセット定数を定義したい:

constant 
empty_cachesubset : cachesubset := (
                                    tag   => "0000",
                                    word0 => "00000000000000000000000000000000",
                                    word1 => "00000000000000000000000000000000",
                                    dirty => '0',
                                    valid => '0'
                                   );

constant 
empty_cacheset    : cacheset    := (
                                    lru     => '0',
                                    subsets => ???
                                   );

ポイントは、配列リテラルの作成方法がわからないことです。

いくつかのメモ...

サブセット内の単語をアドレス指定するために 2 つの別個のフィールドを使用しているという事実を気にしないでください。ただし、キャッシュセットとサブセットに対しても同じことを行う可能性があります。ポイントは、サブセット内の単語にも配列を適用することです。 ...

4

2 に答える 2

2

これは次のように行うことができます。

library ieee;
use ieee.std_logic_1164.all;

package test is
    subtype w32 is std_logic_vector(31 downto 0);

    type cachesubset is record
        tag   : std_logic_vector(3 downto 0);
        word0 : w32;
        word1 : w32;
        dirty : std_logic;
        valid : std_logic;
    end record;

    type subsetst is array (0 to 1) of cachesubset;

    type cacheset is record
        lru     : std_logic;
        subsets : subsetst;
    end record;

    constant empty_cachesubset : cachesubset := (
        tag => (others => '0'),
        word0 => (others => '0'),
        word1 => (others => '0'),
        dirty => '0',
        valid => '0'
    );

    constant empty_cacheset : cacheset := (
        lru         => '0',
        subsets     => (
            0 => empty_cachesubset,
            1 => (
                tag => (others => '0'),
                word0 => (others => '0'),
                word1 => (others => '0'),
                dirty => '0',
                valid => '0'
            )
        )
    );
end package test;
于 2012-11-08T08:35:06.423 に答える
0
subsets => ???

最も簡単な方法は、配列内のすべてのエントリを同じ値に設定することです。

subsets => (others => empty_cachesubset);

他の答えが示すように、個々の要素を異なる値に設定し、「その他」を使用して残りをデフォルトにすることができます。

于 2012-11-15T13:12:57.740 に答える