Skip to content

Commit

Permalink
Fix crash printing active drivers at iteration limit. Fixes #885
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed May 3, 2024
1 parent 2549ea8 commit 2a1e9d9
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 12 deletions.
44 changes: 32 additions & 12 deletions src/rt/model.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ static inline void deferq_do(deferq_t *dq, defer_fn_t fn, void *arg)
static void deferq_scan(deferq_t *dq, scan_fn_t fn, void *arg)
{
for (int i = 0; i < dq->count; i++)
(*fn)(NULL, dq->tasks[i].arg, arg);
(*fn)(dq->tasks[i].fn, dq->tasks[i].arg, arg);
}

static void deferq_shuffle(deferq_t *dq)
Expand Down Expand Up @@ -3104,26 +3104,46 @@ static void update_implicit_signal(rt_model_t *m, rt_implicit_t *imp)
}
}

static void iteration_limit_proc_cb(void *context, void *arg, void *extra)
static void iteration_limit_proc_cb(void *fn, void *arg, void *extra)
{
rt_proc_t *proc = arg;
diag_t *d = extra;
rt_proc_t *proc = NULL;

if (fn == async_run_process)
proc = arg;
else if (fn == async_transfer_signal) {
rt_transfer_t *t = arg;
proc = t->proc;
}

if (proc == NULL)
return;

const loc_t *l = tree_loc(proc->where);
diag_hint(d, l, "process %s is active", istr(proc->name));
const loc_t *loc = tree_loc(proc->where);
diag_hint(d, loc, "process %s is active", istr(proc->name));
}

static void iteration_limit_driver_cb(void *context, void *arg, void *extra)
static void iteration_limit_driver_cb(void *fn, void *arg, void *extra)
{
rt_source_t *src = arg;
diag_t *d = extra;
tree_t decl = NULL;

if (src->tag == SOURCE_DRIVER) {
tree_t decl = src->u.driver.nexus->signal->where;
diag_hint(d, tree_loc(decl), "driver for %s %s is active",
tree_kind(decl) == T_PORT_DECL ? "port" : "signal",
istr(tree_ident(decl)));
if (fn == async_update_driver || fn == async_fast_driver) {
rt_source_t *src = arg;
if (src->tag == SOURCE_DRIVER)
decl = src->u.driver.nexus->signal->where;
}
else if (fn == async_fast_all_drivers) {
rt_signal_t *s = arg;
decl = s->where;
}

if (decl == NULL)
return;

diag_hint(d, tree_loc(decl), "driver for %s %s is active",
tree_kind(decl) == T_PORT_DECL ? "port" : "signal",
istr(tree_ident(decl)));
}

static void reached_iteration_limit(rt_model_t *m)
Expand Down
11 changes: 11 additions & 0 deletions test/regress/gold/issue885.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
0ms+10000: limit of 10000 delta cycles reached
|
12 | signal c : std_logic;
| ^ driver for signal C is active
...
28 | b : out std_logic_vector(1 downto 0) := "00"
| ^ driver for port B is active
...
46 | signal b : std_logic_vector(1 downto 0);
| ^ driver for signal B is active
|
62 changes: 62 additions & 0 deletions test/regress/issue885.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
library ieee;
use ieee.std_logic_1164.all;

entity first is
port (
a : in std_logic_vector(1 downto 0);
b : out std_logic_vector(1 downto 0)
);
end entity;

architecture rtl of first is
signal c : std_logic;

begin
b <= a;
c <= a(0);

end architecture;

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

library ieee;
use ieee.std_logic_1164.all;

entity second is
port (
a : in std_logic_vector(1 downto 0);
b : out std_logic_vector(1 downto 0) := "00"
);
end entity;

architecture rtl of second is
begin
b <= a;
end architecture;

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

library ieee;
use ieee.std_logic_1164.all;

entity issue885 is
end entity;

architecture arch of issue885 is
signal b : std_logic_vector(1 downto 0);
signal a : std_logic_vector(1 downto 0);

begin
first : entity work.first(rtl)
port map(
b => b,
a => a
);

second : entity work.second(rtl)
port map(
a => b,
b => a
);

end architecture;
1 change: 1 addition & 0 deletions test/regress/testlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -970,3 +970,4 @@ ivtest3 verilog
vlog9 verilog
issue881 normal,2008
issue884 normal,2008
issue885 fail,gold

0 comments on commit 2a1e9d9

Please sign in to comment.