forked from umd-memsys/DRAMSim2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClockDomain.h
61 lines (47 loc) · 1.24 KB
/
ClockDomain.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <cmath>
#include <stdint.h>
namespace ClockDomain
{
template <typename ReturnT>
class CallbackBase
{
public:
virtual ReturnT operator()() = 0;
};
template <typename ConsumerT, typename ReturnT>
class Callback: public CallbackBase<ReturnT>
{
private:
typedef ReturnT (ConsumerT::*PtrMember)();
public:
Callback(ConsumerT* const object, PtrMember member) : object(object), member(member) {}
Callback(const Callback<ConsumerT,ReturnT> &e) : object(e.object), member(e.member) {}
ReturnT operator()()
{
return (const_cast<ConsumerT*>(object)->*member)();
}
private:
ConsumerT* const object;
const PtrMember member;
};
typedef CallbackBase <void> ClockUpdateCB;
class ClockDomainCrosser
{
public:
ClockUpdateCB *callback;
uint64_t clock1, clock2;
uint64_t counter1, counter2;
ClockDomainCrosser(ClockUpdateCB *_callback);
ClockDomainCrosser(uint64_t _clock1, uint64_t _clock2, ClockUpdateCB *_callback);
ClockDomainCrosser(double ratio, ClockUpdateCB *_callback);
void update();
};
class TestObj
{
public:
TestObj() {}
void cb();
int test();
};
}