OpenCores
URL https://opencores.org/ocsvn/async_sdm_noc/async_sdm_noc/trunk

Subversion Repositories async_sdm_noc

[/] [async_sdm_noc/] [trunk/] [common/] [tb/] [sim_record.h] - Blame information for rev 37

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 29 wsong0210
/*
2
 Asynchronous SDM NoC
3
 (C)2011 Wei Song
4
 Advanced Processor Technologies Group
5
 Computer Science, the Univ. of Manchester, UK
6
 
7
 Authors:
8
 Wei Song     wsong83@gmail.com
9
 
10
 License: LGPL 3.0 or later
11
 
12
 Simulation record element.
13
 
14
 History:
15
 28/06/2010  Initial version. <wsong83@gmail.com>
16
 27/05/2011  Clean up for opensource. <wsong83@gmail.com>
17
 
18
*/
19
 
20
#ifndef SIM_RECORD_H_
21
#define SIM_RECORD_H_
22
 
23
#include <ostream>
24
 
25
using namespace std;
26
 
27
template<unsigned int TSIZE>
28
class sim_record;
29
 
30
template<unsigned int TSIZE>
31
ostream& operator<< (ostream& os, const sim_record<TSIZE>& mrd) {
32
  os << hex << mrd.key << " " << dec;
33
  for(unsigned int i=0; i<TSIZE; i++)
34
    os << mrd.stamp[i] << " ";
35
  return os;
36
}
37
 
38
template<unsigned int TSIZE>
39
class sim_record {
40
 
41
 public:
42
  double stamp [TSIZE];         /* vector to record time information */
43
  long key;                     /* the hash key for searching */
44
  unsigned int index;           /* the current stamp index */
45
  sim_record<TSIZE> * next;     /* pointer to the next record */
46
  sim_record<TSIZE> * pre;      /* pointer to the previous record */
47
 
48
  sim_record()
49
    : key(0), index(0), next(NULL), pre(NULL)
50
    {}
51
 
52
 sim_record(double mt, long mkey, sim_record<TSIZE> * mnp = NULL, sim_record<TSIZE> * mpp = NULL)
53
   : key(mkey), index(1), next(mnp), pre(mpp) {
54
    for(unsigned int i=0; i<TSIZE; i++)
55
      stamp[i] = mt;
56
  }
57
 
58
  sim_record( const sim_record<TSIZE>& mrd )
59
    : key(mrd.key), index(mrd.index), next(NULL), pre(NULL) {
60
    for(unsigned int i=0; i<TSIZE; i++)
61
      stamp[i] = mrd.stamp[i];
62
  }
63
 
64
  sim_record<TSIZE>& operator= ( const sim_record<TSIZE>& mrd ) {
65
    key = mrd.key;
66
    index = mrd.index;
67
    next = NULL;
68
    pre = NULL;
69
    for(unsigned int i=0; i<TSIZE; i++)
70
      stamp[i] = mrd.stamp[i];
71
  }
72
 
73
  ~sim_record() {
74
    if(next != NULL) {
75
      delete next;
76
      next = NULL;
77
    }
78
    pre = NULL;
79
  }
80
 
81
  operator long() const {
82
    return key;
83
  }
84
 
85
  friend ostream& operator<< <TSIZE> (ostream&, const sim_record<TSIZE>&);
86
 
87
};
88
 
89
 
90
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.