gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
pcstate.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013 ARM Limited
3 * Copyright (c) 2014 Sven Karlsson
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating
9 * to a hardware implementation of the functionality of the software
10 * licensed hereunder. You may use the software subject to the license
11 * terms below provided that you ensure that this notice is replicated
12 * unmodified and in its entirety in all distributions of the software,
13 * modified or unmodified, in source code or in binary form.
14 *
15 * Copyright (c) 2017 The University of Virginia
16 * All rights reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are
20 * met: redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer;
22 * redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution;
25 * neither the name of the copyright holders nor the names of its
26 * contributors may be used to endorse or promote products derived from
27 * this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 */
41
42#ifndef __ARCH_RISCV_PCSTATE_HH__
43#define __ARCH_RISCV_PCSTATE_HH__
44
47#include "enums/PrivilegeModeSet.hh"
48#include "enums/RiscvType.hh"
49
50namespace gem5
51{
52namespace RiscvISA
53{
54
55using RiscvType = enums::RiscvType;
56constexpr enums::RiscvType RV32 = enums::RV32;
57constexpr enums::RiscvType RV64 = enums::RV64;
58
59using PrivilegeModeSet = enums::PrivilegeModeSet;
60
62{
63 protected:
65
66 bool _compressed = false;
68 bool _new_vconf = false;
69 VTYPE _vtype = (1ULL << 63); // vtype.vill = 1 at initial;
70 uint32_t _vl = 0;
71 bool _zcmtSecondFetch = false;
73
74 public:
75 PCState(const PCState &other) : Base(other),
77 _rvType(other._rvType), _new_vconf(other._new_vconf), _vtype(other._vtype),
79 {}
80 PCState &operator=(const PCState &other) = default;
81 PCState() = default;
82 explicit PCState(Addr addr) { set(addr); }
84 {
85 set(addr);
87 }
88
89 PCStateBase *clone() const override { return new PCState(*this); }
90
91 void
92 update(const PCStateBase &other) override
93 {
94 Base::update(other);
95 auto &pcstate = other.as<PCState>();
96 _compressed = pcstate._compressed;
97 _rvType = pcstate._rvType;
98 _new_vconf = pcstate._new_vconf;
99 _vtype = pcstate._vtype;
100 _vl = pcstate._vl;
101 _zcmtSecondFetch = pcstate._zcmtSecondFetch;
102 _zcmtPc = pcstate._zcmtPc;
103 }
104
105 void compressed(bool c) { _compressed = c; }
106 bool compressed() const { return _compressed; }
107
109 RiscvType rvType() const { return _rvType; }
110
111 void new_vconf(bool v) { _new_vconf = v; }
112 bool new_vconf() const { return _new_vconf; }
113
114 void vtype(VTYPE v) { _vtype = v; }
115 VTYPE vtype() const { return _vtype; }
116
117 void vl(uint32_t v) { _vl = v; }
118 uint32_t vl() const { return _vl; }
119
121 bool zcmtSecondFetch() const { return _zcmtSecondFetch; }
122
123 void zcmtPc(Addr a) { _zcmtPc = a; }
124 Addr zcmtPc() const { return _zcmtPc; }
125
126 uint64_t size() const { return _compressed ? 2 : 4; }
127
128 bool
129 branching() const override
130 {
131 return npc() != pc() + size() || nupc() != upc() + 1;
132 }
133
134 bool
135 equals(const PCStateBase &other) const override
136 {
137 auto &opc = other.as<PCState>();
138 return Base::equals(other) &&
139 (_new_vconf == opc._new_vconf) &&
140 (!_new_vconf || (_vtype == opc._vtype && _vl == opc._vl)) &&
141 _zcmtSecondFetch == opc._zcmtSecondFetch &&
142 _zcmtPc == opc._zcmtPc;
143 }
144
145 void
157
158 void
170};
171
172} // namespace RiscvISA
173} // namespace gem5
174
175#endif // __ARCH_RISCV_PCSTATE_HH__
virtual bool equals(const PCStateBase &other) const
Definition pcstate.hh:97
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition pcstate.hh:148
Target & as()
Definition pcstate.hh:73
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition pcstate.hh:141
virtual void update(const PCStateBase &other)
Definition pcstate.hh:87
void update(const PCStateBase &other) override
Definition pcstate.hh:92
bool branching() const override
Definition pcstate.hh:129
bool equals(const PCStateBase &other) const override
Definition pcstate.hh:135
void compressed(bool c)
Definition pcstate.hh:105
Addr zcmtPc() const
Definition pcstate.hh:124
PCState(const PCState &other)
Definition pcstate.hh:75
VTYPE vtype() const
Definition pcstate.hh:115
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition pcstate.hh:146
bool zcmtSecondFetch() const
Definition pcstate.hh:121
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition pcstate.hh:159
PCState & operator=(const PCState &other)=default
bool compressed() const
Definition pcstate.hh:106
PCState(Addr addr, RiscvType rvType)
Definition pcstate.hh:83
void new_vconf(bool v)
Definition pcstate.hh:111
PCStateBase * clone() const override
Definition pcstate.hh:89
void zcmtPc(Addr a)
Definition pcstate.hh:123
GenericISA::UPCState< 4 > Base
Definition pcstate.hh:64
void zcmtSecondFetch(bool z)
Definition pcstate.hh:120
void rvType(RiscvType rvType)
Definition pcstate.hh:108
uint64_t size() const
Definition pcstate.hh:126
uint32_t vl() const
Definition pcstate.hh:118
bool new_vconf() const
Definition pcstate.hh:112
void vtype(VTYPE v)
Definition pcstate.hh:114
RiscvType rvType() const
Definition pcstate.hh:109
void vl(uint32_t v)
Definition pcstate.hh:117
Bitfield< 11 > z
Bitfield< 12, 11 > set
constexpr enums::RiscvType RV32
Definition pcstate.hh:56
enums::PrivilegeModeSet PrivilegeModeSet
Definition pcstate.hh:59
Bitfield< 6 > a
Definition pagetable.hh:72
Bitfield< 0 > v
Definition pagetable.hh:79
enums::RiscvType RiscvType
Definition pcstate.hh:55
constexpr enums::RiscvType RV64
Definition pcstate.hh:57
Bitfield< 4 > pc
Bitfield< 5, 3 > c
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
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
#define UNSERIALIZE_SCALAR(scalar)
Definition serialize.hh:575
#define SERIALIZE_SCALAR(scalar)
Definition serialize.hh:568

Generated on Mon May 26 2025 09:19:05 for gem5 by doxygen 1.13.2