Skip to content

Commit

Permalink
Fix crash with signal alias in generic package. Fixes #946
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Aug 20, 2024
1 parent 199a67b commit 0087f5a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
associations in VHDL-2019 mode.
- Type checking was not performed correctly for conversion function
actuals in port maps (#945).
- Fixed a crash with signal aliases inside an instantiated generic
package (#946).

## Version 1.13.2 - 2024-08-11
- Fixed an incorrect bounds check error when a constant declaration has
Expand Down
12 changes: 12 additions & 0 deletions src/lower.c
Original file line number Diff line number Diff line change
Expand Up @@ -2981,6 +2981,18 @@ static vcode_reg_t lower_alias_ref(lower_unit_t *lu, tree_t alias,
return lower_link_var(lu, alias);
}
}
else if (var & INSTANCE_BIT) {
// This alias is declared in an instantiated package
vcode_var_t pkg_var = var & ~INSTANCE_BIT;
vcode_reg_t pkg_reg;
if (hops == 0)
pkg_reg = emit_load(pkg_var);
else
pkg_reg = emit_load_indirect(emit_var_upref(hops, pkg_var));

vcode_type_t vtype = lower_alias_type(alias);
return emit_link_var(pkg_reg, tree_ident(alias), vtype);
}

if (hops == 0)
return emit_load(var);
Expand Down
40 changes: 40 additions & 0 deletions test/regress/issue946.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package pack is
generic ( width : natural );
type t_rec is record
f : integer_vector(1 to width);
end record;
signal s : t_rec;
alias a is s.f;
procedure get (index : positive; result : out integer);
end package;

package body pack is
procedure get (index : positive; result : out integer) is
begin
result := a(index);
end procedure;
end package body;

-------------------------------------------------------------------------------

entity issue946 is
end entity;

architecture test of issue946 is
package pack6 is new work.pack generic map ( 3 );
use pack6.all;
begin

check: process is
variable result : integer;
begin
a <= (1, 2, 3);
wait for 0 ns;
for i in 1 to 3 loop
get(i, result);
assert result = i;
end loop;
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 @@ -1023,3 +1023,4 @@ issue943 normal,2008
mixed3 mixed
vlog10 verilog
vlog11 verilog
issue946 normal,2008

0 comments on commit 0087f5a

Please sign in to comment.