aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth/issue1993/bug.vhdl
blob: ab4eca23117436d1303fc9fa7be78e31b9f43846 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;

entity bug is
	port (
		clk :  in std_ulogic
	);
end bug;

architecture struct of bug is

	type a_t is record
		value : unsigned;
	end record;

	type a_array_t is array(natural range<>) of a_t;

	type b_t is record
		a : a_array_t;
	end record;

	type b_array_t is array(natural range<>) of b_t;

	type table_t is array (natural range<>, natural range<>) of a_t;

	function make_b return b_array_t is
		variable ret : b_array_t(0 to 0)(a(0 to 31)(value(31 downto 0)));
	begin
		return ret;
	end function;

	function calculate_b return b_array_t is
		function calculate_b(prefix : b_array_t; cur_value : natural) return b_array_t is
		begin
			if cur_value > 0 then
				return prefix;
			else
				return calculate_b(prefix & make_b, cur_value + 1);
			end if;
		end function;

		variable empty : b_array_t(0 to -1)(a(0 to 31)(value(31 downto 0)));
	begin
		return calculate_b(empty, 0);
	end function;

	function calculate_table(b : b_array_t) return table_t is
		variable ret : table_t(0 to b'length-1, 0 to b(0).a'length-1)(value(31 downto 0));
	begin
		return ret;
	end function;

	constant b     : b_array_t := calculate_b;
	constant table : table_t := calculate_table(b);
begin

end architecture;