I am writing constants for stimulus and having a problem with building constant form other constants.
UPDATE: in the example below (provided by user1155120)
library ieee;
use ieee.std_logic_1164.all;
package snippet_pkg is
type pixel is record
x: std_logic_vector(3 downto 0);
y: std_logic_vector(3 downto 0);
end record;
type array_pixel is array (natural range <>) of pixel;
constant array_1 : array_pixel(0 to 2) :=
(0 => (x"0", x"0"),
1 => (x"1", x"1"),
2 => (x"2", x"2")
);
constant array_2 : array_pixel(0 to 3) :=
(array_1'range => array_1,
3 => pixel'(x"3", x"3")
);
constant element : pixel := (x => x"3", y => x"3");
constant array_3 : array_pixel(0 to 3) := array_1 & element;
constant array_4 : array_pixel(0 to 3) := array_1 & pixel'(x => x"3", y => x"3");
end package;
library ieee;
use ieee.std_logic_1164.all;
use work.snippet_pkg.all;
entity snippet_test is
end entity;
architecture foo of snippet_test is
begin
PASSIVE: process
begin
for i in 0 to 2 loop
report "array_1(" & integer'image(i) & ").x = " & to_string(array_1(i).x);
report "array_1(" & integer'image(i) & ").y = " & to_string(array_1(i).y);
end loop;
for i in 0 to 3 loop
report "array_2(" & integer'image(i) & ").x = " & to_string(array_2(i).x);
report "array_2(" & integer'image(i) & ").y = " & to_string(array_2(i).y);
end loop;
wait;
end process;
end architecture;
I have an array of records like below:
type pixel is record
x : std_logic_vector(3 downto 0);
y : std_logic_vector(3 downto 0);
end record;
type array_pixel is array (natural range <>) of pixel;
and then I build a constant from this like this:
constant array_1 : array_pixel(0 to 2) :=
(0 => (x"0" , x"0"),
1 => (x"1" , x"1"),
2 => (x"2" , x"2")
);
Now I want to build another array with a bigger index using array_1 like this:
constant array_2 : array_pixel(0 to 3) :=
(0 to 2 => array_1,
3 => (x"3" , x"3")
);
but I am getting this error in ModelSim:
fatal: (SIGSEGV) Bad pointer access. fatal: vsimk is exiting with code 211.
I am compiling via VUnit. Is this a bug in ModelSim or wrong VHDL coding?
UPDATE: ModelSim mentor graphic doesn't produce this error but it gives wrong values as below:
# ** Note: array_1(0).x = 0000
# ** Note: array_1(0).y = 0000
# ** Note: array_1(1).x = 0001
# ** Note: array_1(1).y = 0001
# ** Note: array_1(2).x = 0010
# ** Note: array_1(2).y = 0010
# ** Note: array_2(0).x = ?(16) U ?(66) ?(9)
# ** Note: array_2(0).y = ?(164) U ?(76) 1
# ** Note: array_2(1).x = ?(208) ?(81) ?(147) 0
# ** Note: array_2(1).y = ?(85) ?(88) U X
# ** Note: array_2(2).x = ?(238) ?(255) ?(238) ?(255)
# ** Note: array_2(2).y = 0UUU
# ** Note: array_2(3).x = 0011
# ** Note: array_2(3).y = 0011
only last index is right and the one which are assigned by 0 to 2 => array_1
are wrong.