Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / api / memsync / src / TsoNode.cc
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T2 Processor File: TsoNode.cc
// Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
//
// The above named program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License version 2 as published by the Free Software Foundation.
//
// The above named program is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this work; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
//
// ========== Copyright Header End ============================================
/************************************************************************
**
** Copyright (C) 2002, Sun Microsystems, Inc.
**
** Sun considers its source code as an unpublished, proprietary
** trade secret and it is available only under strict license provisions.
** This copyright notice is placed here only to protect Sun in the event
** the source is deemed a published work. Disassembly, decompilation,
** or other means of reducing the object code to human readable form
** is prohibited by the license agreement under which this code is
** provided to the user or company in possession of this copy."
**
*************************************************************************/
#include "TsoNode.h"
#include <sstream>
#include "strings.h"
#include "stdio.h"
using namespace std;
using namespace Tso;
////////////////////////////////////////////////
TsoNode::TsoNode()
{
}
////////////////////////////////////////////////
TsoNode::TsoNode( const TsoNode & orig )
{
strcpy(nodeName_, orig.nodeName_);
in_ = orig.in_;
out_ = orig.out_;
iseq_ = orig.iseq_;
commit_ = orig.commit_;
gobs_ = orig.gobs_;
retire_ = orig.retire_;
addr_ = orig.addr_;
data_ = orig.data_;
tid_ = orig.tid_;
itype_ = orig.itype_;
cmd_ = orig.cmd_;
dsrc_ = orig.dsrc_;
sizeV_ = orig.sizeV_;
lastLoad_ = orig.lastLoad_;
lastStore_ = orig.lastStore_;
old_ = orig.old_;
ncnt_ = orig.ncnt_;
}
////////////////////////////////////////////////
TsoNode::TsoNode( const TsoCheckerCmd& cmd )
{
iseq_ = cmd.getIseq();
commit_ = cmd.getMacc();
gobs_ = cmd.getGobs();
retire_ = FOREVER;
addr_ = cmd.getAddr();
data_ = cmd.getData();
tid_ = cmd.getThrdId();
itype_ = cmd.getItype();
cmd_ = cmd.getCmd();
dsrc_ = cmd.getDsrc();
sizeV_ = cmd.getSizeV();
lastLoad_ = false;
lastStore_ = false;
ncnt_ = 1;
old_ = 0;
sprintf (nodeName_, "t%0d_%0lld", tid_, iseq_);
}
////////////////////////////////////////////////
TsoNode::~TsoNode()
{
}
////////////////////////////////////////////////
const TsoNode &
TsoNode::operator=( const TsoNode & rhs )
{
strcpy(nodeName_, rhs.nodeName_);
// in_ = rhs.in_;
// out_ = rhs.out_;
iseq_ = rhs.iseq_;
commit_ = rhs.commit_;
gobs_ = rhs.gobs_;
retire_ = rhs.retire_;
addr_ = rhs.addr_;
data_ = rhs.data_;
tid_ = rhs.tid_;
itype_ = rhs.itype_;
cmd_ = rhs.cmd_;
dsrc_ = rhs.dsrc_;
sizeV_ = rhs.sizeV_;
lastLoad_ = rhs.lastLoad_;
lastStore_ = rhs.lastStore_;
old_ = rhs.old_;
ncnt_ = rhs.ncnt_;
return *this;
}
////////////////////////////////////////////////
bool
TsoNode::operator==( const TsoNode & rhs ) const
{
return false;
}
////////////////////////////////////////////////
string
TsoNode::toString() const
{
ostringstream os;
os << "TsoNode: (";
os << "tid=" << tid_;
os << " iseq=" << iseq_;
os << " i=" << mmitype[itype_];
os << " e=" << mmcmd[cmd_];
os << " a=0x" << hex << addr_;
os << " d=0x" << hex << data_;
os << " vb=0x" << hex << (int) sizeV_;
os << " o=0x" << hex << (int) old_;
os << " dsrc=" << mmdsrc[dsrc_];
os << " ncnt=" << dec << ncnt_;
os << " ma=" << dec << commit_;
os << " gl=" << dec << gobs_;
os << " r=" << retire_;
os << " ll=" << (int) lastLoad_;
os << " ls=" << (int) lastStore_;
os << ")" << endl;
return os.str();
}
void
TsoNode::removeInEdges()
{
list<TsoEdge*>::iterator ei, ei2;
TsoEdge *ep, *ep2;
TsoNode *np;
bool match;
if (inSize() == 0) return;
for (ei = inBegin(); ei != inEnd(); ei++) {
ep = *ei;
np = ep->getSrc();
match = false;
for (ei2 = np->outBegin(); ei2 != np->outEnd(); ei2++) {
ep2 = *ei2;
if (ep2 == ep) {
match = true;
np->outErase(ei2);
break;
}
}
if (!match)
{
MS_ERROR("Remove edges in source node out_ list unsuccessful");
return;
}
delete(ep);
}
inClear();
return;
}
void
TsoNode::removeOutEdges()
{
list<TsoEdge*>::iterator ei, ei2;
TsoEdge *ep, *ep2;
TsoNode *np;
bool match;
if (outSize() == 0) return;
for (ei = outBegin(); ei != outEnd(); ei++) {
ep = *ei;
np = ep->getDst();
match = false;
for (ei2 = np->inBegin(); ei2 != np->inEnd(); ei2++) {
ep2 = *ei2;
if (ep2 == ep) {
match = true;
np->inErase(ei2);
break;
}
}
if (!match)
{
MS_ERROR("Remove edges in destination node in_ list unsuccessful");
return;
}
delete(ep);
}
outClear();
return;
}
void
TsoNode::removeEdges()
{
removeInEdges();
removeOutEdges();
}
bool
TsoNode::allEntriesArrive() {
switch (itype_) {
case ITYPE_LOAD:
case ITYPE_STORE:
case ITYPE_STORE_INIT:
return (ncnt_ == 1);
case ITYPE_BLOCK_LOAD:
case ITYPE_BLOCK_STORE:
// return (ncnt_ == 8); // when add membar implementation, block load/store should be one node
return (ncnt_ == 1); // current implementation, they have 8 nodes per instruction
case ITYPE_DOUBLE_LOAD:
return (ncnt_ == 1);
case ITYPE_ATOMIC:
case ITYPE_QUAD_LOAD:
return (ncnt_ == 2);
default:
return (ncnt_ == 1);
}
}