From 6eb8df61ef4aa152cf5947efc3e091bc4c74fafe Mon Sep 17 00:00:00 2001 From: markhummel Date: Thu, 22 May 2008 15:00:54 +0000 Subject: [PATCH] Fixed bug 1716620: constant expressions on primitive ports were not being propagaged at time 0. --- src/exec.cc | 9 +++++++++ src/gates.cc | 19 +++++++++++++++++-- src/schedule.h | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/exec.cc b/src/exec.cc index a92ed77..621cd29 100644 --- a/src/exec.cc +++ b/src/exec.cc @@ -1040,6 +1040,15 @@ tree exec_(tree pc) } } break; + case GATE_INSTANCE: + { + SCB* scb = readylist; + if( scb->here.marker ) { + NotifyEvent( scb->here.marker, ZERO, 0 ); + } + pc = dispatch_pc(FREE_LIST); + } + break; case 0: printf_error_V("Attempt to execute NULL instruction!\n"); diff --git a/src/gates.cc b/src/gates.cc index 818c0b7..c2c2e57 100644 --- a/src/gates.cc +++ b/src/gates.cc @@ -275,7 +275,6 @@ void initialize_gates(void) tree gate; enum logical_value was_output; - for (gate = PeekGate(); gate; gate = PeekGate()) { ASSERT(TREE_CODE(gate) == GATE_INSTANCE); RemoveGate(gate); @@ -286,6 +285,22 @@ void initialize_gates(void) if (was_output != X) { handle_gate(gate); } + /* + * Create an scb and schedule to run at time 0. + * Link all inputs on a marker chain to cause + * all input to reevaluated. + */ + SCB* scb = BuildSCB(gate, NOLIST); + scb->here.marker = NULL; + for (tree t = GATE_INPUT_LIST(gate); t; t = TREE_CHAIN(t)) { + Marker* marker = (Marker *) xmalloc(sizeof(Marker)); + marker->next = scb->here.marker; + scb->here.marker = marker; + marker->scb = (SCB*)gate; + marker->flags = (enum marker_flags) (M_PRIM|M_FIXED); + marker->expr.arg = t; + } + Schedule(0,scb,0); } } @@ -1300,12 +1315,12 @@ void xnor_exec(struct Marker *marker) void buf_exec(struct Marker *marker) { + ASSERT(marker != NULL); tree gate = (tree) marker->scb; tree arg; enum logical_value in_new, in_old, out_new, out_old; nbits_t nbits; - ASSERT(marker != NULL); ASSERT(gate != NULL); /* This is the arg expression, code, and last value */ diff --git a/src/schedule.h b/src/schedule.h index 01ef334..8223933 100644 --- a/src/schedule.h +++ b/src/schedule.h @@ -89,6 +89,7 @@ typedef struct SCB { struct SCB *scb; /* In case there are many SCBs waiting on the same event */ struct context_member *fork_list; /* If at fork, point to members */ union tree_node *decl; /* for nonblock assigns */ + Marker* marker; /* used for gate intialization */ } here; /* This is valid while waiting at a particular place */ } SCB;