gem5 v24.1.0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
isa.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 The Regents of The University of Michigan
3 * Copyright (c) 2009 The University of Edinburgh
4 * Copyright (c) 2014 Sven Karlsson
5 * Copyright (c) 2016 RISC-V Foundation
6 * Copyright (c) 2016 The University of Virginia
7 * Copyright (c) 2020 Barkhausen Institut
8 * Coypright (c) 2024 University of Rostock
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are
13 * met: redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer;
15 * redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution;
18 * neither the name of the copyright holders nor the names of its
19 * contributors may be used to endorse or promote products derived from
20 * this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#ifndef __ARCH_RISCV_ISA_HH__
36#define __ARCH_RISCV_ISA_HH__
37
38#include <unordered_map>
39#include <vector>
40
41#include "arch/generic/isa.hh"
42#include "arch/riscv/pcstate.hh"
44#include "arch/riscv/types.hh"
45#include "base/types.hh"
46
47namespace gem5
48{
49
50struct RiscvISAParams;
51class Checkpoint;
52
53namespace RiscvISA
54{
55
57{
58 PRV_U = 0,
59 PRV_S = 1,
60 PRV_M = 3
61};
62
64{
65 OFF = 0,
67 CLEAN = 2,
68 DIRTY = 3,
69};
70
72
73class ISA : public BaseISA
74{
75 protected:
79
80 bool hpmCounterEnabled(int counter) const;
81
82 // Load reserve - store conditional monitor
83 const int WARN_FAILURE = 10000;
85 std::unordered_map<int, Addr> load_reservation_addrs;
86
90 unsigned vlen;
91
95 unsigned elen;
96
101
110
118
119 public:
120 using Params = RiscvISAParams;
121
122 void clear() override;
123
125 newPCState(Addr new_inst_addr=0) const override
126 {
127 return new PCState(rvSext(new_inst_addr), _rvType);
128 }
129
130 public:
131 RegVal readMiscRegNoEffect(RegIndex idx) const override;
132 RegVal readMiscReg(RegIndex idx) override;
133 void setMiscRegNoEffect(RegIndex idx, RegVal val) override;
134 void setMiscReg(RegIndex idx, RegVal val) override;
135
136 // Derived class could provide knowledge of non-standard CSRs to other
137 // components by overriding the two getCSRxxxMap here and properly
138 // implementing the corresponding read/set function. However, customized
139 // maps should always be compatible with the standard maps.
140 virtual const std::unordered_map<int, CSRMetadata>&
142 {
143 return CSRData;
144 }
145 virtual const std::unordered_map<int, RegVal>&
147 {
149 }
150
151 bool inUserMode() const override;
152 void copyRegsFrom(ThreadContext *src) override;
153
154 void serialize(CheckpointOut &cp) const override;
155 void unserialize(CheckpointIn &cp) override;
156
157 ISA(const Params &p);
158
159 void handleLockedRead(const RequestPtr &req) override;
160
161 bool handleLockedWrite(const RequestPtr &req,
162 Addr cacheBlockMask) override;
163
164 void handleLockedSnoop(PacketPtr pkt, Addr cacheBlockMask) override;
165
166 void globalClearExclusive() override;
167
168 void resetThread() override;
169
170 RiscvType rvType() const { return _rvType; }
171
172 bool getEnableRvv() const { return enableRvv; }
173
174 void
176 {
177 Addr& load_reservation_addr = load_reservation_addrs[cid];
178 load_reservation_addr = INVALID_RESERVATION_ADDR;
179 }
180
182 unsigned getVecLenInBits() { return vlen; }
183 unsigned getVecLenInBytes() { return vlen >> 3; }
184 unsigned getVecElemLenInBits() { return elen; }
185
186 int64_t getVectorLengthInBytes() const override { return vlen >> 3; }
187
189
191
192 bool enableZcd() { return _enableZcd; }
193
195 RegIndex idx, uint64_t cause, bool intr) const;
196
198 {
199 return (_rvType == RV32) ? sext<32>(addr) : addr;
200 }
201};
202
203} // namespace RiscvISA
204} // namespace gem5
205
206std::ostream &operator<<(std::ostream &os, gem5::RiscvISA::PrivilegeMode pm);
207
208#endif // __ARCH_RISCV_ISA_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
const bool _wfiResumeOnPending
The WFI instruction can halt the execution of a hart.
Definition isa.hh:109
virtual const std::unordered_map< int, CSRMetadata > & getCSRDataMap() const
Definition isa.hh:141
void setMiscReg(RegIndex idx, RegVal val) override
Definition isa.cc:651
void handleLockedSnoop(PacketPtr pkt, Addr cacheBlockMask) override
Definition isa.cc:924
virtual const std::unordered_map< int, RegVal > & getCSRMaskMap() const
Definition isa.hh:146
RegVal readMiscReg(RegIndex idx) override
Definition isa.cc:423
void globalClearExclusive() override
Definition isa.cc:996
const int WARN_FAILURE
Definition isa.hh:83
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition isa.cc:908
void resetThread() override
Definition isa.cc:1004
PrivilegeModeSet _privilegeModeSet
The combination of privilege modes in Privilege Levels section of RISC-V privileged spec.
Definition isa.hh:100
Addr rvSext(Addr addr) const
Definition isa.hh:197
void setMiscRegNoEffect(RegIndex idx, RegVal val) override
Definition isa.cc:641
PCStateBase * newPCState(Addr new_inst_addr=0) const override
Definition isa.hh:125
RegVal readMiscRegNoEffect(RegIndex idx) const override
Definition isa.cc:413
bool enableZcd()
Definition isa.hh:192
bool hpmCounterEnabled(int counter) const
Definition isa.cc:384
unsigned elen
Length of each vector element in bits.
Definition isa.hh:95
void copyRegsFrom(ThreadContext *src) override
Definition isa.cc:293
RiscvType rvType() const
Definition isa.hh:170
bool handleLockedWrite(const RequestPtr &req, Addr cacheBlockMask) override
Definition isa.cc:948
unsigned vlen
Length of each vector register in bits.
Definition isa.hh:90
void clear() override
Definition isa.cc:318
bool getEnableRvv() const
Definition isa.hh:172
unsigned getVecElemLenInBits()
Definition isa.hh:184
std::vector< RegVal > miscRegFile
Definition isa.hh:77
unsigned getVecLenInBits()
Methods for getting VLEN, VLENB and ELEN values.
Definition isa.hh:182
bool inUserMode() const override
Definition isa.cc:287
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition isa.cc:917
const Addr INVALID_RESERVATION_ADDR
Definition isa.hh:84
bool resumeOnPending()
Definition isa.hh:190
bool _enableZcd
Enable Zcd extensions.
Definition isa.hh:117
virtual Addr getFaultHandlerAddr(RegIndex idx, uint64_t cause, bool intr) const
Definition isa.cc:1010
int64_t getVectorLengthInBytes() const override
This function returns the vector length of the Vector Length Agnostic extension of the ISA.
Definition isa.hh:186
void clearLoadReservation(ContextID cid)
Definition isa.hh:175
unsigned getVecLenInBytes()
Definition isa.hh:183
std::unordered_map< int, Addr > load_reservation_addrs
Definition isa.hh:85
RiscvType _rvType
Definition isa.hh:76
PrivilegeModeSet getPrivilegeModeSet()
Definition isa.hh:188
RiscvISAParams Params
Definition isa.hh:120
void handleLockedRead(const RequestPtr &req) override
Definition isa.cc:938
ThreadContext is the external interface to all thread state for anything outside of the CPU.
STL vector class.
Definition stl.hh:37
Bitfield< 0 > p
constexpr enums::RiscvType RV32
Definition pcstate.hh:56
enums::RiscvType RiscvType
Definition pcstate.hh:55
const std::unordered_map< int, CSRMetadata > CSRData
Definition misc.hh:538
const std::unordered_map< int, RegVal > CSRMasks[enums::Num_RiscvType][enums::Num_PrivilegeModeSet]
Definition misc.hh:1522
enums::PrivilegeModeSet PrivilegeModeSet
Definition pcstate.hh:59
Bitfield< 63 > val
Definition misc.hh:804
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
std::shared_ptr< Request > RequestPtr
Definition request.hh:94
uint16_t RegIndex
Definition types.hh:176
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
std::ostream & operator<<(std::ostream &os, const BaseSemihosting::InPlaceArg &ipa)
int ContextID
Globally unique thread context ID.
Definition types.hh:239
uint64_t RegVal
Definition types.hh:173

Generated on Mon Jan 13 2025 04:28:22 for gem5 by doxygen 1.9.8