大数组初始化为 0
Large Array Initialization to 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);
我想把它初始化为0,它是一个整型数组。
谢谢,
是的。您使用 聚合 。为了清楚起见,让我们减少数组的大小:
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));
有没有一种不用一一给所有值的情况下初始化二维数组的方法
我有这样的信号声明:
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);
我想把它初始化为0,它是一个整型数组。
谢谢,
是的。您使用 聚合 。为了清楚起见,让我们减少数组的大小:
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));