Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / api / memsync / src / LoadStoreEntry.cc
CommitLineData
920dae64
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: LoadStoreEntry.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 "LoadStoreEntry.h"
35#include <sstream>
36
37using namespace std;
38////////////////////////////////////////////////
39
40LoadStoreEntry::LoadStoreEntry()
41{
42}
43
44LoadStoreEntry::LoadStoreEntry (LoadStoreCmd& cmd)
45{
46 itype_ = cmd.getItype();
47 id_ = cmd.getId();
48 addr_ = cmd.getAddr();
49 data_ = cmd.getData();
50 dsrc_ = cmd.getDsrc();
51 vbyte_ = cmd.getVbyte();
52 size_ = cmd.getSize();
53 tid_ = cmd.getThrdId();
54 cid_ = cmd.getCoreId();
55 state_ = LS_NEW;
56 valid_ = true;
57 vlink_ = false;
58 executed_ = false;
59 switchData_ = cmd.isSwitchData();
60 iseq_ = 0;
61
62 vlink2_ = false;
63 // cerr << toString();
64}
65////////////////////////////////////////////////
66
67LoadStoreEntry::LoadStoreEntry( const LoadStoreEntry & orig )
68{
69 link_ = orig.link_;
70 itype_ = orig.itype_;
71 state_ = orig.state_;
72 id_ = orig.id_;
73 size_ = orig.size_;
74 addr_ = orig.addr_;
75 data_ = orig.data_;
76 dsrc_ = orig.dsrc_;
77 cid_ = orig.cid_;
78 tid_ = orig.tid_;
79 vbyte_ = orig.vbyte_;
80 valid_ = orig.valid_;
81 vlink_ = orig.vlink_;
82 executed_ = orig.executed_;
83 link2_ = orig.link2_;
84 vlink2_ = orig.vlink2_;
85 iseq_ = orig.iseq_;
86 switchData_ = orig.switchData_;
87}
88
89////////////////////////////////////////////////
90
91LoadStoreEntry::~LoadStoreEntry()
92{
93}
94
95////////////////////////////////////////////////
96
97const LoadStoreEntry &
98LoadStoreEntry::operator=( const LoadStoreEntry & rhs )
99{
100
101 return *this;
102}
103
104////////////////////////////////////////////////
105
106bool
107LoadStoreEntry::operator==( const LoadStoreEntry & rhs ) const
108{
109 return false;
110}
111
112////////////////////////////////////////////////
113
114string
115LoadStoreEntry::toString() const
116{
117 ostringstream os;
118
119 os << "LSE ";
120 os << "(";
121 os << "v=" << valid_;
122 os << " i=" << mmitype[itype_];
123 os << " iseq=" << dec << iseq_;
124 os << " id=" << dec << id_;
125 os << " cid=" << cid_;
126 os << " tid=" << tid_;
127 os << " a=0x" << hex << addr_;
128 os << " d=0x" << data_;
129 os << " dsrc=" << mmdsrc[dsrc_];
130 os << " vb=" << (int) vbyte_;
131 os << " sz=" << dec << (int) size_;
132 os << " cas=" << dec << (int) switchData_;
133 os << " st=" << lstate[state_];
134 os << " exe=" << (int) executed_;
135 if (vlink_) {
136 os << " l:id=" << dec << link_->getId();
137 os << " l:tid=" << link_->getThrdId();
138 os << " l:i=" << mmcmd[link_->getEntryType()];
139 os << " l:a=0x" << hex << link_->getAddr();
140 os << " l:d=0x" << hex << link_->getData();
141 }
142 if (vlink2_) {
143 os << " l2:id=" << dec << link2_->getId();
144 os << " l2:tid=" << link2_->getThrdId();
145 os << " l2:i=" << mmcmd[link2_->getEntryType()];
146 os << " l2:a=0x" << hex << link2_->getAddr();
147 os << " l2:d=0x" << hex << link2_->getData();
148 }
149 os << ")";
150 os << endl;
151
152 return os.str();
153}
154
155void
156LoadStoreEntry::setData (uint64_t data) {
157 MSYNC_DEBUG(1, "setData old_data=0x%llx new_data=0x%llx", data_, data);
158
159 data_ = data;
160
161 MSYNC_DEBUG(1, "%s", toString().c_str());
162
163 /* the following statement should be only used in n1 swerver-memory environment,
164 see LoadStoreEntry.h for more details. */
165
166 /* Note that the original link may have been removed and reused. Considering
167 the following case:
168 (1) STORE_ISSUE -> (2) LOAD_DATA STB -> (3) LOAD STEP -> (4) setData() for 1
169 Step (2) creates a new MAB entry, and can also plase its pointer to the
170 Store buffer entry of 1. When the LOAD STEP is executed, the head MAB entries,
171 possible include the step (2) entry. Hence, when step (4) setData() is called,
172 the link is actually not the original link.
173 */
174
175 if (vlink2_) {
176 link2_->setData(data);
177 // cerr << link2_->toString();
178 }
179}