Skip to content

Commit

Permalink
External names with record signals. Fixes #520
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Aug 19, 2022
1 parent 3cf4c27 commit b93df20
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
- Fixed error with expressions like `X'ELEMENT'LENGTH` (#508).
- Added support for FreeBSD/i386.
- Fixed crash reading resolved value of record signal (#502).
- Improved folding of for-generate expressions (#514).
- Fixed memory leak when forcing signals.
- Fixed crash with type conversion in generic map (#518).
- Fixed crash with expressions like `X'DELAYED'STABLE` (#517).
- External names now work with record signals (#520).

## Version 1.7.0 - 2022-08-07
- *Breaking change:* In-tree builds are no longer supported: use a
Expand Down
20 changes: 16 additions & 4 deletions src/lower.c
Original file line number Diff line number Diff line change
Expand Up @@ -2595,12 +2595,13 @@ static vcode_reg_t lower_external_name(tree_t ref, expr_ctx_t ctx)
vcode_reg_t context = emit_link_instance(path, locus);

tree_t decl = tree_ref(ref);
type_t type = tree_type(decl);
vcode_type_t vtype = lower_var_type(decl);

vcode_reg_t ptr_reg = emit_link_var(context, tree_ident(decl), vtype);
if (lower_have_uarray_ptr(ptr_reg))
return emit_load_indirect(ptr_reg);
else if (tree_class(ref) == C_SIGNAL)
else if (tree_class(ref) == C_SIGNAL && type_is_homogeneous(type))
return emit_load_indirect(ptr_reg);
else
return ptr_reg;
Expand Down Expand Up @@ -5190,6 +5191,18 @@ static void lower_signal_assign(tree_t stmt)
}
}

static void lower_force_field_cb(type_t type, vcode_reg_t ptr,
vcode_reg_t value, void *__ctx)
{
if (type_is_homogeneous(type)) {
vcode_reg_t nets_reg = emit_load_indirect(ptr);
vcode_reg_t count_reg = lower_type_width(type, nets_reg);
emit_force(lower_array_data(nets_reg), count_reg, value);
}
else
lower_for_each_field(type, ptr, value, lower_force_field_cb, NULL);
}

static void lower_force(tree_t stmt)
{
tree_t target = tree_target(stmt);
Expand All @@ -5205,9 +5218,8 @@ static void lower_force(tree_t stmt)
vcode_reg_t data_reg = lower_array_data(value_reg);
emit_force(lower_array_data(nets), count_reg, data_reg);
}
else if (type_is_record(type)) {
assert(false);
}
else if (type_is_record(type))
lower_for_each_field(type, nets, value_reg, lower_force_field_cb, NULL);
else
emit_force(nets, emit_const(vtype_offset(), 1), value_reg);
}
Expand Down
38 changes: 38 additions & 0 deletions test/regress/issue552.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package test_pkg is
type t_if is record
clk : bit;
txd : bit_vector(7 downto 0);
txen : bit;
end record;
end package;

use work.test_pkg.all;

entity test1 is
end entity;

architecture beh of test1 is
signal sig : t_if;
begin
end architecture;

use work.test_pkg.all;

entity issue552 is
end entity;

architecture beh of issue552 is
begin
i_test : entity work.test1;

p_proc : process
alias sig is <<signal i_test.sig : t_if >>;
begin
wait until sig.txen = '1' for 1.1 us;
assert sig.txen = '0';
sig <= force ('1', X"00", '1');
wait for 0 ns;
assert sig.txen = '1';
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 @@ -645,3 +645,4 @@ issue502 normal
elab34 normal,2008
issue508 normal,2008
record37 normal
issue552 normal,2008

0 comments on commit b93df20

Please sign in to comment.