Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / api / memsync / src / TsoNode.cc
CommitLineData
920dae64
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: TsoNode.cc
4// Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
5// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
6//
7// The above named program is free software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public
9// License version 2 as published by the Free Software Foundation.
10//
11// The above named program is distributed in the hope that it will be
12// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// General Public License for more details.
15//
16// You should have received a copy of the GNU General Public
17// License along with this work; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19//
20// ========== Copyright Header End ============================================
21/************************************************************************
22**
23** Copyright (C) 2002, Sun Microsystems, Inc.
24**
25** Sun considers its source code as an unpublished, proprietary
26** trade secret and it is available only under strict license provisions.
27** This copyright notice is placed here only to protect Sun in the event
28** the source is deemed a published work. Disassembly, decompilation,
29** or other means of reducing the object code to human readable form
30** is prohibited by the license agreement under which this code is
31** provided to the user or company in possession of this copy."
32**
33*************************************************************************/
34#include "TsoNode.h"
35#include <sstream>
36#include "strings.h"
37#include "stdio.h"
38
39using namespace std;
40using namespace Tso;
41////////////////////////////////////////////////
42
43TsoNode::TsoNode()
44{
45
46}
47
48////////////////////////////////////////////////
49
50TsoNode::TsoNode( const TsoNode & orig )
51{
52 strcpy(nodeName_, orig.nodeName_);
53 in_ = orig.in_;
54 out_ = orig.out_;
55 iseq_ = orig.iseq_;
56 commit_ = orig.commit_;
57 gobs_ = orig.gobs_;
58 retire_ = orig.retire_;
59 addr_ = orig.addr_;
60 data_ = orig.data_;
61 tid_ = orig.tid_;
62 itype_ = orig.itype_;
63 cmd_ = orig.cmd_;
64 dsrc_ = orig.dsrc_;
65 sizeV_ = orig.sizeV_;
66 lastLoad_ = orig.lastLoad_;
67 lastStore_ = orig.lastStore_;
68 old_ = orig.old_;
69 ncnt_ = orig.ncnt_;
70}
71
72////////////////////////////////////////////////
73
74TsoNode::TsoNode( const TsoCheckerCmd& cmd )
75{
76 iseq_ = cmd.getIseq();
77 commit_ = cmd.getMacc();
78 gobs_ = cmd.getGobs();
79 retire_ = FOREVER;
80 addr_ = cmd.getAddr();
81 data_ = cmd.getData();
82 tid_ = cmd.getThrdId();
83 itype_ = cmd.getItype();
84 cmd_ = cmd.getCmd();
85 dsrc_ = cmd.getDsrc();
86 sizeV_ = cmd.getSizeV();
87 lastLoad_ = false;
88 lastStore_ = false;
89 ncnt_ = 1;
90 old_ = 0;
91
92 sprintf (nodeName_, "t%0d_%0lld", tid_, iseq_);
93}
94
95////////////////////////////////////////////////
96
97TsoNode::~TsoNode()
98{
99
100}
101
102////////////////////////////////////////////////
103
104const TsoNode &
105TsoNode::operator=( const TsoNode & rhs )
106{
107 strcpy(nodeName_, rhs.nodeName_);
108 // in_ = rhs.in_;
109 // out_ = rhs.out_;
110 iseq_ = rhs.iseq_;
111 commit_ = rhs.commit_;
112 gobs_ = rhs.gobs_;
113 retire_ = rhs.retire_;
114 addr_ = rhs.addr_;
115 data_ = rhs.data_;
116 tid_ = rhs.tid_;
117 itype_ = rhs.itype_;
118 cmd_ = rhs.cmd_;
119 dsrc_ = rhs.dsrc_;
120 sizeV_ = rhs.sizeV_;
121 lastLoad_ = rhs.lastLoad_;
122 lastStore_ = rhs.lastStore_;
123 old_ = rhs.old_;
124 ncnt_ = rhs.ncnt_;
125
126 return *this;
127}
128
129////////////////////////////////////////////////
130
131bool
132TsoNode::operator==( const TsoNode & rhs ) const
133{
134 return false;
135}
136
137////////////////////////////////////////////////
138
139string
140TsoNode::toString() const
141{
142 ostringstream os;
143 os << "TsoNode: (";
144 os << "tid=" << tid_;
145 os << " iseq=" << iseq_;
146 os << " i=" << mmitype[itype_];
147 os << " e=" << mmcmd[cmd_];
148 os << " a=0x" << hex << addr_;
149 os << " d=0x" << hex << data_;
150 os << " vb=0x" << hex << (int) sizeV_;
151 os << " o=0x" << hex << (int) old_;
152 os << " dsrc=" << mmdsrc[dsrc_];
153 os << " ncnt=" << dec << ncnt_;
154 os << " ma=" << dec << commit_;
155 os << " gl=" << dec << gobs_;
156 os << " r=" << retire_;
157 os << " ll=" << (int) lastLoad_;
158 os << " ls=" << (int) lastStore_;
159 os << ")" << endl;
160 return os.str();
161}
162
163void
164TsoNode::removeInEdges()
165{
166 list<TsoEdge*>::iterator ei, ei2;
167 TsoEdge *ep, *ep2;
168 TsoNode *np;
169 bool match;
170
171 if (inSize() == 0) return;
172
173 for (ei = inBegin(); ei != inEnd(); ei++) {
174 ep = *ei;
175 np = ep->getSrc();
176 match = false;
177 for (ei2 = np->outBegin(); ei2 != np->outEnd(); ei2++) {
178 ep2 = *ei2;
179 if (ep2 == ep) {
180 match = true;
181 np->outErase(ei2);
182 break;
183 }
184 }
185 if (!match)
186 {
187 MS_ERROR("Remove edges in source node out_ list unsuccessful");
188 return;
189 }
190 delete(ep);
191 }
192
193 inClear();
194
195 return;
196}
197
198void
199TsoNode::removeOutEdges()
200{
201 list<TsoEdge*>::iterator ei, ei2;
202 TsoEdge *ep, *ep2;
203 TsoNode *np;
204 bool match;
205
206 if (outSize() == 0) return;
207
208 for (ei = outBegin(); ei != outEnd(); ei++) {
209 ep = *ei;
210 np = ep->getDst();
211 match = false;
212 for (ei2 = np->inBegin(); ei2 != np->inEnd(); ei2++) {
213 ep2 = *ei2;
214 if (ep2 == ep) {
215 match = true;
216 np->inErase(ei2);
217 break;
218 }
219 }
220 if (!match)
221 {
222 MS_ERROR("Remove edges in destination node in_ list unsuccessful");
223 return;
224 }
225 delete(ep);
226 }
227
228 outClear();
229
230 return;
231}
232
233void
234TsoNode::removeEdges()
235{
236 removeInEdges();
237 removeOutEdges();
238}
239
240bool
241TsoNode::allEntriesArrive() {
242 switch (itype_) {
243 case ITYPE_LOAD:
244 case ITYPE_STORE:
245 case ITYPE_STORE_INIT:
246 return (ncnt_ == 1);
247 case ITYPE_BLOCK_LOAD:
248 case ITYPE_BLOCK_STORE:
249 // return (ncnt_ == 8); // when add membar implementation, block load/store should be one node
250 return (ncnt_ == 1); // current implementation, they have 8 nodes per instruction
251 case ITYPE_DOUBLE_LOAD:
252 return (ncnt_ == 1);
253 case ITYPE_ATOMIC:
254 case ITYPE_QUAD_LOAD:
255 return (ncnt_ == 2);
256 default:
257 return (ncnt_ == 1);
258 }
259}