Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / api / memsync / src / MemoryAccessEntry.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: MemoryAccessEntry.h
5* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
7*
8* The above named program is free software; you can redistribute it and/or
9* modify it under the terms of the GNU General Public
10* License version 2 as published by the Free Software Foundation.
11*
12* The above named program is distributed in the hope that it will be
13* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this work; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20*
21* ========== Copyright Header End ============================================
22*/
23#ifndef _MEMORYACCESSENTRY_H
24#define _MEMORYACCESSENTRY_H
25/************************************************************************
26**
27** Copyright (C) 2002, Sun Microsystems, Inc.
28**
29** Sun considers its source code as an unpublished, proprietary
30** trade secret and it is available only under strict license provisions.
31** This copyright notice is placed here only to protect Sun in the event
32** the source is deemed a published work. Disassembly, decompilation,
33** or other means of reducing the object code to human readable form
34** is prohibited by the license agreement under which this code is
35** provided to the user or company in possession of this copy."
36**
37*************************************************************************/
38#include <iostream>
39#include <list>
40#include "LoadStoreCmd.h"
41
42
43class MemoryAccessEntry {
44
45 static uint64_t maeid;
46
47 public:
48
49 /**
50 * Default constructor
51 */
52 MemoryAccessEntry();
53
54 MemoryAccessEntry(LoadStoreCmd& cmd);
55
56 /**
57 * Copy constructor
58 *
59 * @param orig The MemoryAccessEntry object to copy.
60 */
61 MemoryAccessEntry( const MemoryAccessEntry &orig );
62
63 /**
64 * Destructor
65 */
66 virtual ~MemoryAccessEntry();
67
68 /**
69 * Equality operator
70 *
71 * @param rhs The right hand side of the equality operator
72 * @return Return true if this objec and rhs are equal,
73 * otherwise return false
74 */
75 bool operator==( const MemoryAccessEntry &rhs ) const;
76
77 /**
78 * Assignment operator
79 *
80 * @param rhs The right hand side of the assignment operator.
81 * @return The lvalue of the assignment.
82 */
83 const MemoryAccessEntry & operator=( const MemoryAccessEntry &rhs );
84
85 /**
86 * Return a string representation of this MemoryAccessEntry object.
87 */
88 std::string toString() const;
89
90 void setMaeId (uint64_t value) { MemoryAccessEntry::maeid = value; }
91
92 void setLink(std::list<MemoryAccessEntry>::iterator link) { link_ = link; vlink_ = true; }
93 void setLinkValid (bool valid) { vlink_ = valid; }
94 void setAddr(uint64_t addr) { addr_ = addr; }
95 void setData(uint64_t data) { data_ = data; }
96 void setThrdId(uint32_t tid) { tid_ = tid; }
97 void setCoreId(uint32_t cid) { cid_ = cid; }
98 void setInv(uint32_t inv) { inv_ = inv; }
99 void setCinv(uint32_t cinv) { cinv_ = cinv; }
100 void setSrcBank (uint32_t srcBank) { srcBank_ = srcBank; }
101 void setSet (uint32_t set) { set_ = set; }
102 void setWay (uint32_t way) { way_ = way; }
103 void setIseq (uint64_t iseq) { iseq_ = iseq; }
104 void setDsrcMid (uint64_t dsrcMid) { dsrcMid_ = dsrcMid; }
105 void setGlobal (uint64_t global) { global_ = global; }
106
107 void setEntryType(enum MEM_CMD etype) { etype_ = etype; }
108 void setItype(enum INSTR_TYPE itype) { itype_ = itype; }
109 void setDsrc(enum DATA_SRC dsrc) { dsrc_ = dsrc; }
110 void setVbyte(uint8_t vbyte) { vbyte_ = vbyte; }
111 void setSizeV(uint8_t vbyte) { vbyte_ = vbyte; }
112 void setCacheL1(bool cacheL1) { cacheL1_ = cacheL1; }
113 void setExecuted(bool executed) { executed_ = executed; }
114 void setValid(bool valid) { valid_ = valid; }
115 void setAcked(bool acked) { acked_ = acked; }
116 void setSwitchData (bool switchData) { switchData_ = switchData; }
117
118 void setLink2(std::list<MemoryAccessEntry>::iterator link2) { link2_ = link2; vlink2_ = true; }
119 void setLink2Valid (bool valid) { vlink2_ = valid; }
120 void setPopped() { popped_ = true; }
121
122 std::list<MemoryAccessEntry>::iterator getLink() const { return link_; }
123 uint64_t getId() const { return id_; }
124 uint64_t getAddr() const { return addr_; }
125 uint64_t getData() const { return data_; }
126 uint32_t getThrdId() const { return tid_; }
127 uint32_t getCoreId() const { return cid_; }
128 uint32_t getInv() const { return inv_; }
129 uint32_t getCinv() const { return cinv_; }
130 uint32_t getSrcBank() const { return srcBank_; }
131 uint32_t getSet() const { return set_; }
132 uint32_t getWay() const { return way_; }
133 uint64_t getIseq() const { return iseq_; }
134 uint64_t getDsrcMid() const { return dsrcMid_; }
135 uint64_t getGlobal() const { return global_; }
136
137 enum MEM_CMD getEntryType() const { return etype_; }
138 enum INSTR_TYPE getItype() const { return itype_; }
139 enum DATA_SRC getDsrc() const { return dsrc_; }
140 uint8_t getVbyte() const { return vbyte_; }
141 uint8_t getSizeV() const { return vbyte_; }
142 bool isCacheL1() const { return cacheL1_; }
143 bool isExecuted() const { return executed_; }
144 bool isValid() const { return valid_; }
145 bool isLinkValid() const { return vlink_; }
146 bool isAcked() const { return acked_; }
147 bool isSwitchData() const { return switchData_; }
148 bool isPopped() const { return popped_; }
149
150 std::list<MemoryAccessEntry>::iterator getLink2() const { return link2_; }
151 bool isLink2Valid() const { return vlink2_; }
152
153 uint32_t addCinv (uint32_t cinv) { cinv_ |= cinv; return cinv_; }
154#ifdef N3MODEL
155 bool isInvDone() { return (((inv_ ^ cinv_) || !acked_) ? false : true); }
156#else
157 bool isInvDone() { return ((inv_ ^ cinv_) ? false : true); }
158#endif
159 /**
160 *
161 */
162 std::list<MemoryAccessEntry>::iterator getEntry();
163
164 /**
165 *
166 */
167 void setEntry(std::list<MemoryAccessEntry>::iterator);
168
169 void setCycle(uint64_t cyc) { cycle_ = cyc; }
170 uint64_t getCycle() { return cycle_; }
171
172 /**
173 * handle error injection corner cases
174 */
175 void setMerged(bool merged) { merged_ = merged; }
176 void setOrigData(uint64_t data) { origData_ = data; }
177 void setOrigSizeV(uint8_t vbyte) { origVbyte_ = vbyte; }
178 bool getMerged() const { return merged_; }
179 uint64_t getOrigData() const { return origData_; }
180 uint8_t getOrigSizeV() const { return origVbyte_; }
181
182 /**
183 * DMA_STORE
184 */
185 void setDmaStore(bool val) { dmaStore = val; }
186 bool getDmaStore() { return dmaStore; }
187 void setTsize(int _tsize) { tsize = _tsize; }
188 int getTsize() { return tsize; }
189 void setWriteBack() { writeBack = true; }
190 bool isWriteBack() { return writeBack; }
191 void setInvSet(bool val) { invSet = val; }
192 bool getInvSet() { return invSet; }
193
194 protected:
195
196 private:
197 std::list<MemoryAccessEntry>::iterator link_; // link to other entry
198 std::list<MemoryAccessEntry>::iterator link2_; // link to other entry
199 uint64_t id_; // sequential id, to indicates the order of reference
200 uint64_t addr_; // physical address
201 uint64_t data_; // 8 byte data
202 uint64_t iseq_; // instruction sequence (for TSOchecker)
203 uint64_t dsrcMid_; // MAE id of data source (for TSOchecker)
204 uint64_t global_; // the last MAE id at which old data is invalidated/updated in all L1$s (for TSOchecker)
205 uint32_t tid_; // thread id
206 uint32_t cid_; // core id
207 uint32_t inv_; // invalidation vector
208 uint32_t cinv_; // core invalidated
209 uint32_t srcBank_; // source bank id, used in EVICT
210 uint32_t set_; // cache set
211 uint32_t way_; // cache way
212 enum MEM_CMD etype_; // entry type
213 enum INSTR_TYPE itype_; // instruction type
214 enum DATA_SRC dsrc_; // load data source
215 uint8_t vbyte_; // valid byte: bit 0 represents byte 0, and so on.
216 bool cacheL1_; // perform L1 line fill?
217 bool executed_; // corresponding instruction executed
218 bool valid_; // valid entry
219 bool vlink_; // valid link
220 bool acked_; // acked by its own used for store instruction, or in imab, storeL2 removed
221 bool vlink2_; // 2nd link
222 bool switchData_; // indicates if the memory data will be changed for an atomic instr
223 bool popped_; // the entry is popped by LOAD_POP
224 uint64_t cycle_; // RTL cycle, i.e., timestamp from testbench
225
226 bool merged_; // true mean we need to re-do data merge
227 uint64_t origData_; // original data before before SC merge
228 uint8_t origVbyte_; // original valid byte vector
229 bool dmaStore; // true - this is a dma_store related SC entry
230 int tsize; // the size of a DMA_STORE operation
231 bool writeBack; // true - a st_commit has been written back to memory before it reaches head of MAB
232 bool invSet; // true - no more evict assoicated with this dma_store
233
234 };
235
236#endif /* _MEMORYACCESSENTRY_H */