-
Notifications
You must be signed in to change notification settings - Fork 0
/
electronicmessage.cpp
101 lines (87 loc) · 2.34 KB
/
electronicmessage.cpp
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* electronicmessage.cpp
* PhoenixSim
*
* Created by Johnnie Chan on 6/6/11.
* Copyright 2011 Johnnie Chan. All rights reserved.
*
*/
#include "electronicmessage.h"
#include "systemc.h"
using namespace std;
using namespace PhoenixSim;
ElectronicMessage::ElectronicMessage()
{
messageId = -1;
sequenceId = 0;
messageType = "default";
messageSize = 0;
beginTime = sc_time_stamp();
data = NULL;
messageComplete = false;
}
bool ElectronicMessage::operator ==(const ElectronicMessage & rhs) const
{
if(messageId == -1 && rhs.messageId == -1)
{
return true;
}
else
{
return messageId == rhs.messageId && sequenceId == rhs.sequenceId && sourceAddress == rhs.sourceAddress && destinationAddress == rhs.destinationAddress &&
virtualChannelId == rhs.virtualChannelId && beginTime == rhs.beginTime && endTime == rhs.endTime && messageComplete == rhs.messageComplete && data == rhs.data &&
messageType == rhs.messageType && messageSize == rhs.messageSize;
}
}
bool ElectronicMessage::operator !=(const ElectronicMessage & rhs) const
{
return !((*this) == rhs);
}
ElectronicMessage& ElectronicMessage::operator =(const ElectronicMessage & rhs)
{
messageId = rhs.messageId;
sequenceId = rhs.sequenceId;
messageType = rhs.messageType;
messageSize = rhs.messageSize;
sourceAddress = rhs.sourceAddress;
destinationAddress = rhs.destinationAddress;
virtualChannelId = rhs.virtualChannelId;
beginTime = rhs.beginTime;
endTime = rhs.endTime;
messageComplete = rhs.messageComplete;
data = rhs.data;
return *this;
}
bool ElectronicMessage::IsNullMessage() const
{
return messageId == -1;
}
void PhoenixSim::sc_trace (sc_trace_file *tf, const ElectronicMessage &v, const string &NAME)
{
sc_trace(tf, v.messageId, NAME + ".messageId");
//sc_trace(tf, v.sourceId, NAME + ".sourceId");
//sc_trace(tf, v.destinationId, NAME + ".destinationId");
sc_trace(tf, v.virtualChannelId, NAME + ".virtualChannelId");
}
void PhoenixSim::sc_trace (sc_trace_file *tf, const ElectronicMessage* v, const string &NAME)
{
//
if(v == NULL)
{
}
else
{
sc_trace(tf, long(v), NAME);
}
}
ostream& PhoenixSim::operator<<(ostream& os, ElectronicMessage const &v)
{
if(v.messageId == -1)
{
return os<<"ElectronicMessage: NULL";
}
else
{
return os<<"ElectronicMessage: id="<<v.messageId; //<<" sourceId="<<v.sourceId<<" destinationId="<<v.destinationId;
}
}