From 5b688c3a7fc164800c95a2133c1aaa5cf80c84c0 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Mon, 15 Nov 2021 07:55:34 +0100 Subject: testsuite/gna: add a test for previous commit --- testsuite/gna/bug0125/gen.py | 33 +++++++++++++++++++++++++++++++++ testsuite/gna/bug0125/repro.vhdl | 17 +++++++++++++++++ testsuite/gna/bug0125/tb.vhdl | 23 +++++++++++++++++++++++ testsuite/gna/bug0125/testsuite.sh | 10 ++++++++++ 4 files changed, 83 insertions(+) create mode 100755 testsuite/gna/bug0125/gen.py create mode 100644 testsuite/gna/bug0125/repro.vhdl create mode 100644 testsuite/gna/bug0125/tb.vhdl create mode 100755 testsuite/gna/bug0125/testsuite.sh diff --git a/testsuite/gna/bug0125/gen.py b/testsuite/gna/bug0125/gen.py new file mode 100755 index 000000000..c058f748b --- /dev/null +++ b/testsuite/gna/bug0125/gen.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# Generate a big aggregate + +import sys +import random + +out = sys.stdout + + +depth = 1024 +width = 6 + +out.write(""" +package repro is + type array2d is array(0 to {}, 0 to {}) of integer; + + constant cst : array2d := + ( +""".format(depth - 1, width - 1)) + +for i in range(depth): + if i != 0: + out.write(',\n') + out.write (' (') + for j in range(width): + if j != 0: + out.write(', ') + out.write('{}'.format(random.randint(0, 1<<31))) + out.write(')') +out.write(""" + ); +end repro; +""") diff --git a/testsuite/gna/bug0125/repro.vhdl b/testsuite/gna/bug0125/repro.vhdl new file mode 100644 index 000000000..c7a995553 --- /dev/null +++ b/testsuite/gna/bug0125/repro.vhdl @@ -0,0 +1,17 @@ +package repro is + type array2d is array( integer range 0 to 7, integer range 14 downto 1) + of natural; + + constant cst : array2d := + ( + (1,1,1,1,1,1,1,1,1,1,1,1,1,1), + (2,3,5,9,17,33,65,129,257,513,1025,2049,4097,1), + (3,5,9,17,33,65,129,257,513,1025,2049,4097,1,1), + (4,7,13,25,49,97,193,385,769,1537,3073,6145,4097,1), + (5,9,17,33,65,129,257,513,1025,2049,4097,1,1,1), + (6,11,21,41,81,161,321,641,1281,2561,5121,2049,4097,1), + (7,13,25,49,97,193,385,769,1537,3073,6145,4097,1,1), + (8,15,29,57,113,225,449,897,1793,3585,7169,6145,4097,1) + ); + +end repro; diff --git a/testsuite/gna/bug0125/tb.vhdl b/testsuite/gna/bug0125/tb.vhdl new file mode 100644 index 000000000..caa3ac0d4 --- /dev/null +++ b/testsuite/gna/bug0125/tb.vhdl @@ -0,0 +1,23 @@ +entity tb is +end; + +use work.repro.all; + +architecture behav of tb +is +begin + process + variable sum : natural; + begin + sum := 0; + + for i in cst'range(1) loop + for j in cst'range(2) loop + sum := (sum + cst(i, j)) mod 4096; + end loop; + end loop; + + report "sum: " & natural'image(sum); + wait; + end process; +end behav; diff --git a/testsuite/gna/bug0125/testsuite.sh b/testsuite/gna/bug0125/testsuite.sh new file mode 100755 index 000000000..ddb73a841 --- /dev/null +++ b/testsuite/gna/bug0125/testsuite.sh @@ -0,0 +1,10 @@ +#! /bin/sh + +. ../../testenv.sh + +analyze repro.vhdl tb.vhdl +elab_simulate tb + +clean + +echo "Test successful" -- cgit v1.2.3