gem5 v24.0.0.0
Loading...
Searching...
No Matches
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 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are
12 * met: redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer;
14 * redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution;
17 * neither the name of the copyright holders nor the names of its
18 * contributors may be used to endorse or promote products derived from
19 * this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifndef __ARCH_RISCV_ISA_HH__
35#define __ARCH_RISCV_ISA_HH__
36
37#include <unordered_map>
38#include <vector>
39
40#include "arch/generic/isa.hh"
41#include "arch/riscv/pcstate.hh"
43#include "arch/riscv/types.hh"
44#include "base/types.hh"
45
46namespace gem5
47{
48
49struct RiscvISAParams;
50class Checkpoint;
51
52namespace RiscvISA
53{
54
56{
57 PRV_U = 0,
58 PRV_S = 1,
59 PRV_M = 3
60};
61
63{
64 OFF = 0,
66 CLEAN = 2,
67 DIRTY = 3,
68};
69
71
72class ISA : public BaseISA
73{
74 protected:
78
79 bool hpmCounterEnabled(int counter) const;
80
81 // Load reserve - store conditional monitor
82 const int WARN_FAILURE = 10000;
84 std::unordered_map<int, Addr> load_reservation_addrs;
85
89 unsigned vlen;
90
94 unsigned elen;
95
100
101 public:
102 using Params = RiscvISAParams;
103
104 void clear() override;
105
107 newPCState(Addr new_inst_addr=0) const override
108 {
109 unsigned vlenb = vlen >> 3;
110 return new PCState(new_inst_addr, _rvType, vlenb);
111 }
112
113 public:
114 RegVal readMiscRegNoEffect(RegIndex idx) const override;
115 RegVal readMiscReg(RegIndex idx) override;
116 void setMiscRegNoEffect(RegIndex idx, RegVal val) override;
117 void setMiscReg(RegIndex idx, RegVal val) override;
118
119 // Derived class could provide knowledge of non-standard CSRs to other
120 // components by overriding the two getCSRxxxMap here and properly
121 // implementing the corresponding read/set function. However, customized
122 // maps should always be compatible with the standard maps.
123 virtual const std::unordered_map<int, CSRMetadata>&
125 {
126 return CSRData;
127 }
128 virtual const std::unordered_map<int, RegVal>&
130 {
132 }
133
134 bool inUserMode() const override;
135 void copyRegsFrom(ThreadContext *src) override;
136
137 void serialize(CheckpointOut &cp) const override;
138 void unserialize(CheckpointIn &cp) override;
139
140 ISA(const Params &p);
141
142 void handleLockedRead(const RequestPtr &req) override;
143
144 bool handleLockedWrite(const RequestPtr &req,
145 Addr cacheBlockMask) override;
146
147 void handleLockedSnoop(PacketPtr pkt, Addr cacheBlockMask) override;
148
149 void globalClearExclusive() override;
150
151 void resetThread() override;
152
153 RiscvType rvType() const { return _rvType; }
154
155 bool getEnableRvv() const { return enableRvv; }
156
157 void
159 {
160 Addr& load_reservation_addr = load_reservation_addrs[cid];
161 load_reservation_addr = INVALID_RESERVATION_ADDR;
162 }
163
165 unsigned getVecLenInBits() { return vlen; }
166 unsigned getVecLenInBytes() { return vlen >> 3; }
167 unsigned getVecElemLenInBits() { return elen; }
168
169 int64_t getVectorLengthInBytes() const override { return vlen >> 3; }
170
172
174 RegIndex idx, uint64_t cause, bool intr) const;
175};
176
177} // namespace RiscvISA
178} // namespace gem5
179
180std::ostream &operator<<(std::ostream &os, gem5::RiscvISA::PrivilegeMode pm);
181
182#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
virtual const std::unordered_map< int, CSRMetadata > & getCSRDataMap() const
Definition isa.hh:124
void setMiscReg(RegIndex idx, RegVal val) override
Definition isa.cc:649
void handleLockedSnoop(PacketPtr pkt, Addr cacheBlockMask) override
Definition isa.cc:902
virtual const std::unordered_map< int, RegVal > & getCSRMaskMap() const
Definition isa.hh:129
RegVal readMiscReg(RegIndex idx) override
Definition isa.cc:420
void globalClearExclusive() override
Definition isa.cc:974
const int WARN_FAILURE
Definition isa.hh:82
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition isa.cc:886
void resetThread() override
Definition isa.cc:982
PrivilegeModeSet _privilegeModeSet
The combination of privilege modes in Privilege Levels section of RISC-V privileged spec.
Definition isa.hh:99
void setMiscRegNoEffect(RegIndex idx, RegVal val) override
Definition isa.cc:639
PCStateBase * newPCState(Addr new_inst_addr=0) const override
Definition isa.hh:107
RegVal readMiscRegNoEffect(RegIndex idx) const override
Definition isa.cc:410
bool hpmCounterEnabled(int counter) const
Definition isa.cc:381
unsigned elen
Length of each vector element in bits.
Definition isa.hh:94
void copyRegsFrom(ThreadContext *src) override
Definition isa.cc:290
RiscvType rvType() const
Definition isa.hh:153
bool handleLockedWrite(const RequestPtr &req, Addr cacheBlockMask) override
Definition isa.cc:926
unsigned vlen
Length of each vector register in bits.
Definition isa.hh:89
void clear() override
Definition isa.cc:315
bool getEnableRvv() const
Definition isa.hh:155
unsigned getVecElemLenInBits()
Definition isa.hh:167
std::vector< RegVal > miscRegFile
Definition isa.hh:76
unsigned getVecLenInBits()
Methods for getting VLEN, VLENB and ELEN values.
Definition isa.hh:165
bool inUserMode() const override
Definition isa.cc:284
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition isa.cc:895
const Addr INVALID_RESERVATION_ADDR
Definition isa.hh:83
virtual Addr getFaultHandlerAddr(RegIndex idx, uint64_t cause, bool intr) const
Definition isa.cc:988
int64_t getVectorLengthInBytes() const override
This function returns the vector length of the Vector Length Agnostic extension of the ISA.
Definition isa.hh:169
void clearLoadReservation(ContextID cid)
Definition isa.hh:158
unsigned getVecLenInBytes()
Definition isa.hh:166
std::unordered_map< int, Addr > load_reservation_addrs
Definition isa.hh:84
RiscvType _rvType
Definition isa.hh:75
PrivilegeModeSet getPrivilegeModeSet()
Definition isa.hh:171
RiscvISAParams Params
Definition isa.hh:102
ISA(const Params &p)
Definition isa.cc:259
void handleLockedRead(const RequestPtr &req) override
Definition isa.cc:916
ThreadContext is the external interface to all thread state for anything outside of the CPU.
STL vector class.
Definition stl.hh:37
GenericISA::DelaySlotPCState< 4 > PCState
Definition pcstate.hh:40
Bitfield< 0 > p
enums::PrivilegeModeSet PrivilegeModeSet
Definition pcstate.hh:59
enums::RiscvType RiscvType
Definition pcstate.hh:55
const std::unordered_map< int, CSRMetadata > CSRData
Definition misc.hh:536
const std::unordered_map< int, RegVal > CSRMasks[enums::Num_RiscvType][enums::Num_PrivilegeModeSet]
Definition misc.hh:1503
Bitfield< 63 > val
Definition misc.hh:804
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint16_t RegIndex
Definition types.hh:176
std::shared_ptr< Request > RequestPtr
Definition request.hh:94
uint64_t RegVal
Definition types.hh:173
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
int ContextID
Globally unique thread context ID.
Definition types.hh:239
std::ostream & operator<<(std::ostream &os, gem5::RiscvISA::PrivilegeMode pm)
Definition isa.cc:1001

Generated on Tue Jun 18 2024 16:23:57 for gem5 by doxygen 1.11.0