Skip to content

Commit

Permalink
preliminary cause tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
rmanohar committed Jul 19, 2024
1 parent 0e8a47d commit 59760a5
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 62 deletions.
6 changes: 3 additions & 3 deletions actsim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1839,7 +1839,7 @@ void ActSimCore::incFanout (int off, int type, SimDES *who)
nfo[off]++;
}

void ActSimObj::propagate ()
void ActSimObj::propagate (void *cause)
{
/* by default, wake me up if stalled on something shared */
sWakeup ();
Expand Down Expand Up @@ -2904,10 +2904,10 @@ int ActSimCore::initTrace (int fmt, const char *file)
if (type == 0) {
int v = getBool (off);
if (v == 0) {
v = ACT_SIG_BOOL_TRUE;
v = ACT_SIG_BOOL_FALSE;
}
else if (v == 1) {
v = ACT_SIG_BOOL_FALSE;
v = ACT_SIG_BOOL_TRUE;
}
else if (v == 2) {
v = ACT_SIG_BOOL_X;
Expand Down
18 changes: 16 additions & 2 deletions actsim.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ class ActSimState {
class ActSimDES : public SimDES {
public:
virtual ~ActSimDES() { };
virtual void propagate () { };
virtual void propagate (void *cause = NULL) { };
virtual void sPrintCause (char *buf, int sz) {
buf[0] = '\0';
}

};

class ActSimObj;
Expand Down Expand Up @@ -161,7 +165,7 @@ class ActSimObj : public ActSimDES {
virtual unsigned long getArea () { return 0; }
virtual void printStatus (int val, bool io_glob = false) { }

virtual void propagate ();
virtual void propagate (void *cause = NULL);
virtual void computeFanout() { printf ("should not be here\n"); }

/* manipulate object watchpoint, using local index values */
Expand All @@ -176,6 +180,16 @@ class ActSimObj : public ActSimDES {
void sRemove() { _shared->DelObject (this); }
int sWaiting() { return _shared->isWaiting (this); }

virtual void sPrintCause (char *buf, int sz) {
// by default, the instance causes the change!
if (getName()) {
getName()->sPrint (buf, sz);
}
else {
buf[0] = '\0';
}
}

protected:
state_counts _o; /* my state offsets for all local
state */
Expand Down
78 changes: 56 additions & 22 deletions chpsim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ int ChpSim::Step (Event *ev)
#if 0
printf (" [bglob=%d]", off);
#endif
if (chkWatchBreakPt (0, my_loff, off, v)) {
if (chkWatchBreakPt (0, my_loff, off, v, ev->getCause())) {
_breakpt = 1;
}
_sc->setBool (off, v.getVal (0));
Expand All @@ -1247,7 +1247,7 @@ int ChpSim::Step (Event *ev)
v.setWidth (stmt->u.assign.isint);
v.toStatic ();

if (chkWatchBreakPt (1, my_loff, off, v)) {
if (chkWatchBreakPt (1, my_loff, off, v, ev->getCause())) {
_breakpt = 1;
}
v.setWidth (stmt->u.assign.isint);
Expand Down Expand Up @@ -1342,7 +1342,7 @@ int ChpSim::Step (Event *ev)
#if 0
printf (" [glob=%d]", off);
#endif
if (chkWatchBreakPt (0, id, off, v)) {
if (chkWatchBreakPt (0, id, off, v, ev->getCause())) {
_breakpt = 1;
}
_sc->setBool (off, v.getVal (0));
Expand All @@ -1353,7 +1353,7 @@ int ChpSim::Step (Event *ev)
#if 0
printf (" [glob=%d]", off);
#endif
if (chkWatchBreakPt (1, id, off, v)) {
if (chkWatchBreakPt (1, id, off, v, ev->getCause())) {
_breakpt = 1;
}
v.setWidth (stmt->u.sendrecv.width);
Expand All @@ -1378,6 +1378,7 @@ int ChpSim::Step (Event *ev)
}
}
if (chkWatchBreakPt (3, stmt->u.sendrecv.chvar, goff, v,
ev->getCause(),
(frag ? 1 : 0) | ((rv ? 1 : (flag ? 2 : 0)) << 1))) {
_breakpt = 1;
}
Expand Down Expand Up @@ -1431,6 +1432,7 @@ int ChpSim::Step (Event *ev)
}
/*-- attempt to receive value --*/
if (chkWatchBreakPt (2, stmt->u.sendrecv.chvar, goff, v,
ev->getCause(),
((rv ? 1 : (flag ? 2 : 0)) << 1))) {
_breakpt = 1;
}
Expand All @@ -1453,7 +1455,7 @@ int ChpSim::Step (Event *ev)
#if 0
printf (" [glob=%d]", off);
#endif
if (chkWatchBreakPt (0, id, off, v)) {
if (chkWatchBreakPt (0, id, off, v, ev->getCause())) {
_breakpt = 1;
}
_sc->setBool (off, v.getVal (0));
Expand All @@ -1464,7 +1466,7 @@ int ChpSim::Step (Event *ev)
#if 0
printf (" [glob=%d]", off);
#endif
if (chkWatchBreakPt (1, id, off, v)) {
if (chkWatchBreakPt (1, id, off, v, ev->getCause())) {
_breakpt = 1;
}

Expand Down Expand Up @@ -1928,7 +1930,7 @@ int ChpSim::varSend (int pc, int wakeup, int id, int off, int flavor,
*skipwrite = c->skip_action;
c->skip_action = 0;
}
c->w->Notify (c->recv_here-1);
c->w->Notify (c->recv_here-1, this);
c->recv_here = 0;
if (c->send_here != 0) {
act_connection *x;
Expand Down Expand Up @@ -1960,7 +1962,7 @@ int ChpSim::varSend (int pc, int wakeup, int id, int off, int flavor,
#ifdef DUMP_ALL
printf (" [waiting-recvprobe %d]", c->recv_here-1);
#endif
c->probe->Notify (c->recv_here-1);
c->probe->Notify (c->recv_here-1, this);
c->recv_here = 0;
c->receiver_probe = 0;
}
Expand Down Expand Up @@ -2164,7 +2166,7 @@ int ChpSim::varRecv (int pc, int wakeup, int id, int off, int flavor,
if (bidir) {
c->data = xchg;
}
c->w->Notify (c->send_here-1);
c->w->Notify (c->send_here-1, this);
c->send_here = 0;
Assert (c->recv_here == 0 && c->receiver_probe == 0 &&
c->sender_probe == 0, "What?");
Expand All @@ -2178,7 +2180,7 @@ int ChpSim::varRecv (int pc, int wakeup, int id, int off, int flavor,
#ifdef DUMP_ALL
printf (" [waiting-sendprobe %d]", c->send_here-1);
#endif
c->probe->Notify (c->send_here-1);
c->probe->Notify (c->send_here-1, this);
c->send_here = 0;
c->sender_probe = 0;
}
Expand Down Expand Up @@ -5689,9 +5691,9 @@ unsigned long ChpSim::getArea (void)
return _area_cost;
}

void ChpSim::propagate (void)
void ChpSim::propagate (void *cause)
{
ActSimObj::propagate ();
ActSimObj::propagate (cause);
}


Expand Down Expand Up @@ -5918,7 +5920,7 @@ void ChpSim::boolProp (int glob_off)
printf ("\n");
#endif
#endif
p->propagate ();
p->propagate (this);
}
}

Expand Down Expand Up @@ -5955,7 +5957,7 @@ void ChpSim::intProp (int glob_off)
printf ("\n");
#endif
#endif
p->propagate ();
p->propagate (this);
}
}

Expand All @@ -5969,7 +5971,7 @@ void ChpSim::intProp (int glob_off)
: 2 = completed
*/
int ChpSim::chkWatchBreakPt (int type, int loff, int goff, const BigInt& v,
int flag)
void *cause, int flag)
{
int verb = 0;
int ret_break = 0;
Expand All @@ -5988,8 +5990,14 @@ int ChpSim::chkWatchBreakPt (int type, int loff, int goff, const BigInt& v,
if (oval != v.getVal (0)) {
if (verb & 1) {
msgPrefix ();
printf ("%s := %c\n", nm->s, (v.getVal (0) == 2 ? 'X' : ((char)v.getVal (0) + '0')));

printf ("%s := %c", nm->s, (v.getVal (0) == 2 ? 'X' : ((char)v.getVal (0) + '0')));
if (cause) {
char buf[1024];
ActSimDES *x = (ActSimDES *) cause;
x->sPrintCause (buf, 1024);
printf (" [by %s]", buf);
}
printf ("\n");
_sc->recordTrace (nm, type, ACT_CHAN_IDLE, v);
}
if (verb & 2) {
Expand All @@ -6008,8 +6016,14 @@ int ChpSim::chkWatchBreakPt (int type, int loff, int goff, const BigInt& v,
v.decPrint (stdout);
printf (" (0x");
v.hexPrint (stdout);
printf (")\n");

printf (")");
if (cause) {
char buf[1024];
ActSimDES *x = (ActSimDES *) cause;
x->sPrintCause (buf, 1024);
printf (" [by %s]", buf);
}
printf ("\n");
_sc->recordTrace (nm, type, ACT_CHAN_IDLE, v);
}
if (verb & 2) {
Expand All @@ -6031,7 +6045,7 @@ int ChpSim::chkWatchBreakPt (int type, int loff, int goff, const BigInt& v,
printf ("%s: recv", nm->s);

if (umode == 1) {
printf ("-blocked\n");
printf ("-blocked");
_sc->recordTrace (nm, 2, ACT_CHAN_RECV_BLOCKED, v);
}
else if (umode == 0 || umode == 2) {
Expand All @@ -6042,8 +6056,15 @@ int ChpSim::chkWatchBreakPt (int type, int loff, int goff, const BigInt& v,
v.decPrint (stdout);
printf (" (0x");
v.hexPrint (stdout);
printf (")\n");
printf (")");
}
if (cause) {
char buf[1024];
ActSimDES *x = (ActSimDES *) cause;
x->sPrintCause (buf, 1024);
printf (" [by %s]", buf);
}
printf ("\n");
}
if (verb & 2) {
msgPrefix ();
Expand All @@ -6069,6 +6090,12 @@ int ChpSim::chkWatchBreakPt (int type, int loff, int goff, const BigInt& v,
v.hexPrint (stdout);
printf (")");
}
if (cause) {
char buf[1024];
ActSimDES *x = (ActSimDES *) cause;
x->sPrintCause (buf, 1024);
printf (" [by %s]", buf);
}
printf ("\n");
if (umode == 1) {
_sc->recordTrace (nm, 2, ACT_CHAN_SEND_BLOCKED, v);
Expand All @@ -6084,7 +6111,14 @@ int ChpSim::chkWatchBreakPt (int type, int loff, int goff, const BigInt& v,
else {
ChanTraceDelayed *obj = new ChanTraceDelayed (nm);
new Event (obj, SIM_EV_MKTYPE (0, 0), 1);
printf ("%s : send complete\n", nm->s);
printf ("%s : send complete", nm->s);
if (cause) {
char buf[1024];
ActSimDES *x = (ActSimDES *) cause;
x->sPrintCause (buf, 1024);
printf (" [by %s]", buf);
}
printf ("\n");
}

if (verb & 2) {
Expand Down
14 changes: 11 additions & 3 deletions chpsim.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class ChpSim : public ActSimObj {

int computeOffset (const struct chpsimderef *d);

virtual void propagate (void);
virtual void propagate (void *cause);

void zeroInit ();

Expand All @@ -208,8 +208,16 @@ class ChpSim : public ActSimObj {

void setHseMode() { _hse_mode = 1; }
int isHseMode() { return _hse_mode; }


void sPrintCause (char *buf, int sz) {
if (_npc == 0) {
snprintf (buf, sz, "chan-method");
}
else {
ActSimObj::sPrintCause (buf, sz);
}
}

private:
int _npc; /* # of program counters */
int _pcused; /* # of _pc[] slots currently being
Expand Down Expand Up @@ -266,7 +274,7 @@ class ChpSim : public ActSimObj {
expr_multires *v, int bidir, expr_multires &xchg, int *frag,
int *skipwrite);

int chkWatchBreakPt (int type, int loff, int goff, const BigInt &v, int flag = 0);
int chkWatchBreakPt (int type, int loff, int goff, const BigInt &v, void *cause, int flag = 0);


int _updatepc (int pc);
Expand Down
Loading

0 comments on commit 59760a5

Please sign in to comment.