From 3c23c984d2e75e1a455a68e7be1656948c42ef75 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sat, 10 Dec 2022 21:52:48 +0100 Subject: testsuite/gna: add a test for #2216 --- testsuite/gna/issue2216/ent.vhdl | 9 ++++++++ testsuite/gna/issue2216/pkg.vhdl | 41 ++++++++++++++++++++++++++++++++++++ testsuite/gna/issue2216/testsuite.sh | 11 ++++++++++ 3 files changed, 61 insertions(+) create mode 100644 testsuite/gna/issue2216/ent.vhdl create mode 100644 testsuite/gna/issue2216/pkg.vhdl create mode 100755 testsuite/gna/issue2216/testsuite.sh diff --git a/testsuite/gna/issue2216/ent.vhdl b/testsuite/gna/issue2216/ent.vhdl new file mode 100644 index 000000000..c551f5bdd --- /dev/null +++ b/testsuite/gna/issue2216/ent.vhdl @@ -0,0 +1,9 @@ +use work.MemorySupportPkg.all; + +entity ent is +end; + +architecture behav of ent is + constant c : MemBlockType := InitMemoryBaseType_X (3, 2); +begin +end; diff --git a/testsuite/gna/issue2216/pkg.vhdl b/testsuite/gna/issue2216/pkg.vhdl new file mode 100644 index 000000000..4dedf8bb4 --- /dev/null +++ b/testsuite/gna/issue2216/pkg.vhdl @@ -0,0 +1,41 @@ +package MemorySupportPkg is + + subtype MemoryBaseType is integer_vector ; + type MemBlockType is array (integer range <>) of MemoryBaseType ; + + function InitMemoryBaseType_X(BlockWidth, BaseWidth : integer) return MemBlockType ; + +end MemorySupportPkg ; + +package body MemorySupportPkg is + + +-- Works +-- ------------------------------------------------------------ +-- function InitMemoryBaseType_X(BlockWidth, BaseWidth : integer) return MemBlockType is +-- ------------------------------------------------------------ +-- constant BaseU : MemoryBaseType(0 to BaseWidth-1) := (others => -1) ; +-- begin +-- return MemBlockType'(0 to 2**BlockWidth-1 => BaseU) ; +-- end function InitMemoryBaseType_X ; + +-- Fails + ------------------------------------------------------------ + function InitMemoryBaseType_X(BlockWidth, BaseWidth : integer) return MemBlockType is + ------------------------------------------------------------ + constant BaseU : MemoryBaseType := (0 to BaseWidth-1 => -1) ; + begin + return MemBlockType'(0 to 2**BlockWidth-1 => BaseU) ; + end function InitMemoryBaseType_X ; + +-- Fails +-- ------------------------------------------------------------ +-- function InitMemoryBaseType_X(BlockWidth, BaseWidth : integer) return MemBlockType is +-- ------------------------------------------------------------ +-- constant BaseU : MemoryBaseType(0 to BaseWidth-1) := (others => -1) ; +-- constant BlockWidthU : MemBlockType(0 to 2**BlockWidth-1) := (others => BaseU) ; +-- -- --!! Also Fails constant BlockWidthU : MemBlockType := (0 to 2**BlockWidth-1 => BaseU) ; +-- begin +-- return BlockWidthU ; +-- end function InitMemoryBaseType_X ; +end MemorySupportPkg ; diff --git a/testsuite/gna/issue2216/testsuite.sh b/testsuite/gna/issue2216/testsuite.sh new file mode 100755 index 000000000..331a801f8 --- /dev/null +++ b/testsuite/gna/issue2216/testsuite.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +. ../../testenv.sh + +export GHDL_STD_FLAGS=--std=08 +analyze pkg.vhdl ent.vhdl +elab_simulate ent + +clean + +echo "Test successful" -- cgit v1.2.3