Skip to content

Commit

Permalink
Handle enumeration subtypes in generic arguments. Issue #618
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Feb 12, 2023
1 parent 666c009 commit 8c6510d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/elab.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
19 changes: 19 additions & 0 deletions test/regress/issue618.vhd
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions test/regress/testlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -712,3 +712,4 @@ cover10 cover,shell
cmdline5 shell
issue603 normal
issue609 normal
issue618 normal,gA='1',gB='0'

0 comments on commit 8c6510d

Please sign in to comment.