Skip to content

Commit

Permalink
remove_me needs to check if it is pending
Browse files Browse the repository at this point in the history
  • Loading branch information
rmanohar committed Mar 20, 2023
1 parent 285b014 commit 8521c71
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions actsim.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class ActSimObj : public ActSimDES {
void sWakeup() { _shared->Notify (MAX_LOCAL_PCS); }
void sStall () { _shared->AddObject (this); }
void sRemove() { _shared->DelObject (this); }
int sWaiting() { return _shared->isWaiting (this); }

protected:
state_counts _o; /* my state offsets for all local
Expand Down
25 changes: 15 additions & 10 deletions chpsim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1029,11 +1029,14 @@ void ChpSim::_remove_me (int pc)
listitem_t *li;
listitem_t *prev = NULL;

for (li = list_first (_stalled_pc); li; li = list_next (li)) {
if (list_ivalue (li) == pc) {
list_delete_next (_stalled_pc, prev);
sRemove ();
return;
if (sWaiting ()) {
for (li = list_first (_stalled_pc); li; li = list_next (li)) {
if (list_ivalue (li) == pc) {
list_delete_next (_stalled_pc, prev);
sRemove ();
return;
}
prev = li;
}
}
}
Expand Down Expand Up @@ -1492,10 +1495,11 @@ int ChpSim::Step (Event *ev)
_energy_cost += stmt->energy_cost;

if (flag) {
int tmpret;
/*-- release wait conditions in case there are multiple --*/
if ((stmt->u.cond.is_shared || stmt->u.cond.is_probe) &&
(_add_waitcond (&stmt->u.cond.c, pc, 1) || stmt->u.cond.is_shared)) {
_remove_me (pc);
tmpret = _add_waitcond (&stmt->u.cond.c, pc, 1);
if (stmt->u.cond.is_shared || tmpret) {
_remove_me (pc);
}
}

Expand Down Expand Up @@ -1566,9 +1570,10 @@ int ChpSim::Step (Event *ev)
if (stmt->type == CHPSIM_COND || stmt->type == CHPSIM_CONDARB) {
/* selection: we just try again later: add yourself to
probed signals */
int tmpret;
forceret = 1;
if ((stmt->u.cond.is_shared || stmt->u.cond.is_probe) &&
(_add_waitcond (&stmt->u.cond.c, pc) || stmt->u.cond.is_shared)) {
tmpret = _add_waitcond (&stmt->u.cond.c, pc);
if (stmt->u.cond.is_shared || tmpret) {
#ifdef DUMP_ALL
printf (" [stall-sh]");
#endif
Expand Down

0 comments on commit 8521c71

Please sign in to comment.