/*
|
/*
|
Asynchronous SDM NoC
|
Asynchronous SDM NoC
|
(C)2011 Wei Song
|
(C)2011 Wei Song
|
Advanced Processor Technologies Group
|
Advanced Processor Technologies Group
|
Computer Science, the Univ. of Manchester, UK
|
Computer Science, the Univ. of Manchester, UK
|
|
|
Authors:
|
Authors:
|
Wei Song wsong83@gmail.com
|
Wei Song wsong83@gmail.com
|
|
|
License: LGPL 3.0 or later
|
License: LGPL 3.0 or later
|
|
|
Simulation record element.
|
Simulation record element.
|
|
|
History:
|
History:
|
28/06/2010 Initial version. <wsong83@gmail.com>
|
28/06/2010 Initial version. <wsong83@gmail.com>
|
27/05/2011 Clean up for opensource. <wsong83@gmail.com>
|
27/05/2011 Clean up for opensource. <wsong83@gmail.com>
|
|
|
*/
|
*/
|
|
|
#ifndef SIM_RECORD_H_
|
#ifndef SIM_RECORD_H_
|
#define SIM_RECORD_H_
|
#define SIM_RECORD_H_
|
|
|
#include <ostream>
|
#include <ostream>
|
|
|
using namespace std;
|
using namespace std;
|
|
|
template<unsigned int TSIZE>
|
template<unsigned int TSIZE>
|
class sim_record;
|
class sim_record;
|
|
|
template<unsigned int TSIZE>
|
template<unsigned int TSIZE>
|
ostream& operator<< (ostream& os, const sim_record<TSIZE>& mrd) {
|
ostream& operator<< (ostream& os, const sim_record<TSIZE>& mrd) {
|
os << hex << mrd.key << " " << dec;
|
os << hex << mrd.key << " " << dec;
|
for(unsigned int i=0; i<TSIZE; i++)
|
for(unsigned int i=0; i<TSIZE; i++)
|
os << mrd.stamp[i] << " ";
|
os << mrd.stamp[i] << " ";
|
return os;
|
return os;
|
}
|
}
|
|
|
template<unsigned int TSIZE>
|
template<unsigned int TSIZE>
|
class sim_record {
|
class sim_record {
|
|
|
public:
|
public:
|
double stamp [TSIZE]; /* vector to record time information */
|
double stamp [TSIZE]; /* vector to record time information */
|
long key; /* the hash key for searching */
|
long key; /* the hash key for searching */
|
unsigned int index; /* the current stamp index */
|
unsigned int index; /* the current stamp index */
|
sim_record<TSIZE> * next; /* pointer to the next record */
|
sim_record<TSIZE> * next; /* pointer to the next record */
|
sim_record<TSIZE> * pre; /* pointer to the previous record */
|
sim_record<TSIZE> * pre; /* pointer to the previous record */
|
|
|
sim_record()
|
sim_record()
|
: key(0), index(0), next(NULL), pre(NULL)
|
: key(0), index(0), next(NULL), pre(NULL)
|
{}
|
{}
|
|
|
sim_record(double mt, long mkey, sim_record<TSIZE> * mnp = NULL, sim_record<TSIZE> * mpp = NULL)
|
sim_record(double mt, long mkey, sim_record<TSIZE> * mnp = NULL, sim_record<TSIZE> * mpp = NULL)
|
: key(mkey), index(1), next(mnp), pre(mpp) {
|
: key(mkey), index(1), next(mnp), pre(mpp) {
|
for(unsigned int i=0; i<TSIZE; i++)
|
for(unsigned int i=0; i<TSIZE; i++)
|
stamp[i] = mt;
|
stamp[i] = mt;
|
}
|
}
|
|
|
sim_record( const sim_record<TSIZE>& mrd )
|
sim_record( const sim_record<TSIZE>& mrd )
|
: key(mrd.key), index(mrd.index), next(NULL), pre(NULL) {
|
: key(mrd.key), index(mrd.index), next(NULL), pre(NULL) {
|
for(unsigned int i=0; i<TSIZE; i++)
|
for(unsigned int i=0; i<TSIZE; i++)
|
stamp[i] = mrd.stamp[i];
|
stamp[i] = mrd.stamp[i];
|
}
|
}
|
|
|
sim_record<TSIZE>& operator= ( const sim_record<TSIZE>& mrd ) {
|
sim_record<TSIZE>& operator= ( const sim_record<TSIZE>& mrd ) {
|
key = mrd.key;
|
key = mrd.key;
|
index = mrd.index;
|
index = mrd.index;
|
next = NULL;
|
next = NULL;
|
pre = NULL;
|
pre = NULL;
|
for(unsigned int i=0; i<TSIZE; i++)
|
for(unsigned int i=0; i<TSIZE; i++)
|
stamp[i] = mrd.stamp[i];
|
stamp[i] = mrd.stamp[i];
|
}
|
}
|
|
|
~sim_record() {
|
~sim_record() {
|
if(next != NULL) {
|
if(next != NULL) {
|
delete next;
|
delete next;
|
next = NULL;
|
next = NULL;
|
}
|
}
|
pre = NULL;
|
pre = NULL;
|
}
|
}
|
|
|
operator long() const {
|
operator long() const {
|
return key;
|
return key;
|
}
|
}
|
|
|
friend ostream& operator<< <TSIZE> (ostream&, const sim_record<TSIZE>&);
|
friend ostream& operator<< <TSIZE> (ostream&, const sim_record<TSIZE>&);
|
|
|
};
|
};
|
|
|
|
|
#endif
|
#endif
|
|
|