From 8c6510da973dc0b53be7728630f8609132d474ba Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sun, 12 Feb 2023 22:04:59 +0000 Subject: [PATCH] Handle enumeration subtypes in generic arguments. Issue #618 --- NEWS.md | 2 ++ src/elab.c | 5 ++++- test/regress/issue618.vhd | 19 +++++++++++++++++++ test/regress/testlist.txt | 1 + 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 test/regress/issue618.vhd diff --git a/NEWS.md b/NEWS.md index 98695762..a10c82b6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,8 @@ producing a fatal error (#603). - Fixed a bug where data was not propagated through inout ports in certain conditions (#609). +- The `-gNAME=VALUE` option to set generic values from the command line + now works correctly for subtypes of enumeration types (#618). ## Version 1.8.1 - 2023-01-23 - Initial signal values for certain types were not dumped correctly in diff --git a/src/elab.c b/src/elab.c index ab9cd080..1f0d0fa5 100644 --- a/src/elab.c +++ b/src/elab.c @@ -1697,10 +1697,13 @@ static tree_t elab_generic_parse(tree_t generic, const char *str) str, type_pp(type), istr(tree_ident(generic))); if (type_is_enum(type)) { + type_t base = type_base_recur(type); + tree_t lit = type_enum_literal(base, value.integer); + tree_t result = tree_new(T_REF); tree_set_type(result, type); tree_set_ident(result, ident_new(str)); - tree_set_ref(result, type_enum_literal(type, value.integer)); + tree_set_ref(result, lit); return result; } diff --git a/test/regress/issue618.vhd b/test/regress/issue618.vhd new file mode 100644 index 00000000..3d285d80 --- /dev/null +++ b/test/regress/issue618.vhd @@ -0,0 +1,19 @@ +library ieee ; +use ieee.std_logic_1164.all ; + +entity issue618 is + generic ( + A : std_logic := '0' ; + B : std_logic := '1' + ) ; +end entity; + +architecture test of issue618 is +begin + p1: process is + begin + assert A = '1'; + assert B = '0'; + wait; + end process; +end architecture; diff --git a/test/regress/testlist.txt b/test/regress/testlist.txt index 253d2258..1b0d8625 100644 --- a/test/regress/testlist.txt +++ b/test/regress/testlist.txt @@ -712,3 +712,4 @@ cover10 cover,shell cmdline5 shell issue603 normal issue609 normal +issue618 normal,gA='1',gB='0' -- 2.39.2