2017-06-01 7 views
2

すべての値を1つずつ与えずに2次元配列を初期化する方法はありますか?大規模配列の初期化を0にする

私のような信号宣言があります。私はそれが整数配列である0にこれを初期化したい

type t_id_data is array (integer range <>) of integer; 
    type t_image_data is array (integer range <>) of t_id_data; 
    signal s_image_data : t_image_data (0 to 30) (0 to 720); 

を。

おかげで、

答えて

3

はい。 集約を使用します。

type t_id_data is array (integer range <>) of integer; 
type t_image_data is array (integer range <>) of t_id_data; 

-- this sets element 0 to {0, 10, 100} and elements 1,2 to {0, 11, 0} 
-- using NAMED ASSOCIATION 
signal s_image_data : t_image_data (0 to 2) (0 to 2) 
    := (0 => (0 => 0, 1 => 10, 2 => 100), 
     others => (1 => 11, others => 0)); 

-- this sets all the elements to 0 
signal another_signal : t_image_data (0 to 2) (0 to 2) 
    := (others => (others => 0)); 

-- this sets element 0 to {0, 10, 100} and elements 1,2 to {0, 11, 0} 
-- using POSITIONAL ASSOCIATION 
signal yet_another : t_image_data (0 to 2) (0 to 2) 
    := ((0, 10, 100), others => (0, 11, 0)); 
+0

ありがとう、これは参考になりました。 – user3094049