Skip to content

Commit

Permalink
Support arbitrary signal names in prefix of 'DELAYED. Issue #603
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Jan 30, 2023
1 parent 30415ec commit c2e5ca4
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 7 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
- Fixed "failed to suspend thread" crash on macOS.
- Fix incorrect coverage scope nesting with array case statements (from
@Blebowski).
- Expressions like `FOO(X)'DELAYED` now work as expected rather than
producing a fatal error (#603).

## Version 1.8.1 - 2023-01-23
- Initial signal values for certain types were not dumped correctly in
Expand Down
22 changes: 15 additions & 7 deletions src/simp.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,12 @@ static tree_t simp_signal_attribute(tree_t t, attr_kind_t which,
simp_ctx_t *ctx)
{
tree_t name = tree_name(t);
assert(tree_kind(name) == T_REF);

tree_t decl = tree_ref(name);
tree_t ref = name_to_ref(name);
if (ref == NULL)
return t;

tree_t decl = tree_ref(ref);

const tree_kind_t kind = tree_kind(decl);
if (kind != T_SIGNAL_DECL && kind != T_PORT_DECL)
Expand All @@ -391,19 +394,24 @@ static tree_t simp_signal_attribute(tree_t t, attr_kind_t which,
return t;

LOCAL_TEXT_BUF tb = tb_new();
tb_istr(tb, tree_ident(name));
tb_istr(tb, tree_ident(ref));
switch (which) {
case ATTR_TRANSACTION: tb_cat(tb, "$transaction"); break;
case ATTR_DELAYED: tb_printf(tb, "$delayed_%"PRIi64, iparam); break;
default: break;
}

ident_t id = ident_new(tb_get(tb));
ident_t id;
if (ref == name) {
id = ident_new(tb_get(tb));

for (imp_signal_t *it = ctx->imp_signals; it; it = it->next) {
if (it->name == id)
return make_ref(it->signal);
for (imp_signal_t *it = ctx->imp_signals; it; it = it->next) {
if (it->name == id)
return make_ref(it->signal);
}
}
else
id = ident_uniq(tb_get(tb));

tree_t s = tree_new(T_SIGNAL_DECL);
tree_set_loc(s, tree_loc(t));
Expand Down
29 changes: 29 additions & 0 deletions test/regress/issue603.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
entity issue603 is
end entity;

architecture test of issue603 is
signal x : bit_vector(1 to 3);
begin

p1: process is
begin
assert x(1)'delayed = '0';
assert x(2)'delayed = '0';
x <= "100";
wait for 0 ns;
assert x(1)'delayed = '0';
assert x(2)'delayed = '0';
wait for 0 ns;
assert x(1)'delayed = '1';
assert x(2)'delayed = '0';
x(2) <= '1';
wait for 0 ns;
x(2) <= '0';
wait for 0 ns;
assert x(2)'delayed = '1';
wait for 0 ns;
assert x(2)'delayed = '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 @@ -710,3 +710,4 @@ cover9 cover,shell
issue592 normal
cover10 cover,shell
cmdline5 shell
issue603 normal

0 comments on commit c2e5ca4

Please sign in to comment.