gem5 v24.1.0.1
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 VTYPE _vtype = (1ULL << 63); // vtype.vill = 1 at initial;
69 uint32_t _vl = 0;
70
71 public:
72 PCState(const PCState &other) : Base(other),
73 _rvType(other._rvType), _vtype(other._vtype), _vl(other._vl)
74 {}
75 PCState &operator=(const PCState &other) = default;
76 PCState() = default;
77 explicit PCState(Addr addr) { set(addr); }
79 {
80 set(addr);
82 }
83
84 PCStateBase *clone() const override { return new PCState(*this); }
85
86 void
87 update(const PCStateBase &other) override
88 {
89 Base::update(other);
90 auto &pcstate = other.as<PCState>();
91 _compressed = pcstate._compressed;
92 _rvType = pcstate._rvType;
93 _vtype = pcstate._vtype;
94 _vl = pcstate._vl;
95 }
96
97 void compressed(bool c) { _compressed = c; }
98 bool compressed() const { return _compressed; }
99
101 RiscvType rvType() const { return _rvType; }
102
103 void vtype(VTYPE v) { _vtype = v; }
104 VTYPE vtype() const { return _vtype; }
105
106 void vl(uint32_t v) { _vl = v; }
107 uint32_t vl() const { return _vl; }
108
109 uint64_t size() const { return _compressed ? 2 : 4; }
110
111 bool
112 branching() const override
113 {
114 return npc() != pc() + size() || nupc() != upc() + 1;
115 }
116
117 bool
118 equals(const PCStateBase &other) const override
119 {
120 auto &opc = other.as<PCState>();
121 return Base::equals(other) &&
122 _vtype == opc._vtype &&
123 _vl == opc._vl;
124 }
125
126 void
135
136 void
145};
146
147} // namespace RiscvISA
148} // namespace gem5
149
150#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:87
bool branching() const override
Definition pcstate.hh:112
bool equals(const PCStateBase &other) const override
Definition pcstate.hh:118
void compressed(bool c)
Definition pcstate.hh:97
PCState(const PCState &other)
Definition pcstate.hh:72
VTYPE vtype() const
Definition pcstate.hh:104
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition pcstate.hh:127
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition pcstate.hh:137
PCState & operator=(const PCState &other)=default
bool compressed() const
Definition pcstate.hh:98
PCState(Addr addr, RiscvType rvType)
Definition pcstate.hh:78
PCStateBase * clone() const override
Definition pcstate.hh:84
GenericISA::UPCState< 4 > Base
Definition pcstate.hh:64
void rvType(RiscvType rvType)
Definition pcstate.hh:100
uint64_t size() const
Definition pcstate.hh:109
uint32_t vl() const
Definition pcstate.hh:107
void vtype(VTYPE v)
Definition pcstate.hh:103
RiscvType rvType() const
Definition pcstate.hh:101
void vl(uint32_t v)
Definition pcstate.hh:106
Bitfield< 12, 11 > set
constexpr enums::RiscvType RV32
Definition pcstate.hh:56
enums::RiscvType RiscvType
Definition pcstate.hh:55
Bitfield< 0 > v
Definition pagetable.hh:77
constexpr enums::RiscvType RV64
Definition pcstate.hh:57
enums::PrivilegeModeSet PrivilegeModeSet
Definition pcstate.hh:59
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 Jan 13 2025 04:28:26 for gem5 by doxygen 1.9.8