Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / api / memsync / src / LoadStoreEntry.cc
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T2 Processor File: LoadStoreEntry.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 "LoadStoreEntry.h"
#include <sstream>
using namespace std;
////////////////////////////////////////////////
LoadStoreEntry::LoadStoreEntry()
{
}
LoadStoreEntry::LoadStoreEntry (LoadStoreCmd& cmd)
{
itype_ = cmd.getItype();
id_ = cmd.getId();
addr_ = cmd.getAddr();
data_ = cmd.getData();
dsrc_ = cmd.getDsrc();
vbyte_ = cmd.getVbyte();
size_ = cmd.getSize();
tid_ = cmd.getThrdId();
cid_ = cmd.getCoreId();
state_ = LS_NEW;
valid_ = true;
vlink_ = false;
executed_ = false;
switchData_ = cmd.isSwitchData();
iseq_ = 0;
vlink2_ = false;
// cerr << toString();
}
////////////////////////////////////////////////
LoadStoreEntry::LoadStoreEntry( const LoadStoreEntry & orig )
{
link_ = orig.link_;
itype_ = orig.itype_;
state_ = orig.state_;
id_ = orig.id_;
size_ = orig.size_;
addr_ = orig.addr_;
data_ = orig.data_;
dsrc_ = orig.dsrc_;
cid_ = orig.cid_;
tid_ = orig.tid_;
vbyte_ = orig.vbyte_;
valid_ = orig.valid_;
vlink_ = orig.vlink_;
executed_ = orig.executed_;
link2_ = orig.link2_;
vlink2_ = orig.vlink2_;
iseq_ = orig.iseq_;
switchData_ = orig.switchData_;
}
////////////////////////////////////////////////
LoadStoreEntry::~LoadStoreEntry()
{
}
////////////////////////////////////////////////
const LoadStoreEntry &
LoadStoreEntry::operator=( const LoadStoreEntry & rhs )
{
return *this;
}
////////////////////////////////////////////////
bool
LoadStoreEntry::operator==( const LoadStoreEntry & rhs ) const
{
return false;
}
////////////////////////////////////////////////
string
LoadStoreEntry::toString() const
{
ostringstream os;
os << "LSE ";
os << "(";
os << "v=" << valid_;
os << " i=" << mmitype[itype_];
os << " iseq=" << dec << iseq_;
os << " id=" << dec << id_;
os << " cid=" << cid_;
os << " tid=" << tid_;
os << " a=0x" << hex << addr_;
os << " d=0x" << data_;
os << " dsrc=" << mmdsrc[dsrc_];
os << " vb=" << (int) vbyte_;
os << " sz=" << dec << (int) size_;
os << " cas=" << dec << (int) switchData_;
os << " st=" << lstate[state_];
os << " exe=" << (int) executed_;
if (vlink_) {
os << " l:id=" << dec << link_->getId();
os << " l:tid=" << link_->getThrdId();
os << " l:i=" << mmcmd[link_->getEntryType()];
os << " l:a=0x" << hex << link_->getAddr();
os << " l:d=0x" << hex << link_->getData();
}
if (vlink2_) {
os << " l2:id=" << dec << link2_->getId();
os << " l2:tid=" << link2_->getThrdId();
os << " l2:i=" << mmcmd[link2_->getEntryType()];
os << " l2:a=0x" << hex << link2_->getAddr();
os << " l2:d=0x" << hex << link2_->getData();
}
os << ")";
os << endl;
return os.str();
}
void
LoadStoreEntry::setData (uint64_t data) {
MSYNC_DEBUG(1, "setData old_data=0x%llx new_data=0x%llx", data_, data);
data_ = data;
MSYNC_DEBUG(1, "%s", toString().c_str());
/* the following statement should be only used in n1 swerver-memory environment,
see LoadStoreEntry.h for more details. */
/* Note that the original link may have been removed and reused. Considering
the following case:
(1) STORE_ISSUE -> (2) LOAD_DATA STB -> (3) LOAD STEP -> (4) setData() for 1
Step (2) creates a new MAB entry, and can also plase its pointer to the
Store buffer entry of 1. When the LOAD STEP is executed, the head MAB entries,
possible include the step (2) entry. Hence, when step (4) setData() is called,
the link is actually not the original link.
*/
if (vlink2_) {
link2_->setData(data);
// cerr << link2_->toString();
}
}