gem5 v24.0.0.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 uint64_t _vlenb = 32;
69 VTYPE _vtype = (1ULL << 63); // vtype.vill = 1 at initial;
70 uint32_t _vl = 0;
71
72 public:
73 PCState(const PCState &other) : Base(other),
74 _rvType(other._rvType), _vlenb(other._vlenb),
75 _vtype(other._vtype), _vl(other._vl)
76 {}
77 PCState &operator=(const PCState &other) = default;
78 PCState() = default;
79 explicit PCState(Addr addr) { set(addr); }
80 explicit PCState(Addr addr, RiscvType rvType, uint64_t vlenb)
81 {
82 set(addr);
84 _vlenb = vlenb;
85 }
86
87 PCStateBase *clone() const override { return new PCState(*this); }
88
89 void
90 update(const PCStateBase &other) override
91 {
92 Base::update(other);
93 auto &pcstate = other.as<PCState>();
94 _compressed = pcstate._compressed;
95 _rvType = pcstate._rvType;
96 _vlenb = pcstate._vlenb;
97 _vtype = pcstate._vtype;
98 _vl = pcstate._vl;
99 }
100
101 void compressed(bool c) { _compressed = c; }
102 bool compressed() const { return _compressed; }
103
105 RiscvType rvType() const { return _rvType; }
106
107 void vlenb(uint64_t v) { _vlenb = v; }
108 uint64_t vlenb() const { return _vlenb; }
109
110 void vtype(VTYPE v) { _vtype = v; }
111 VTYPE vtype() const { return _vtype; }
112
113 void vl(uint32_t v) { _vl = v; }
114 uint32_t vl() const { return _vl; }
115
116 uint64_t size() const { return _compressed ? 2 : 4; }
117
118 bool
119 branching() const override
120 {
121 return npc() != pc() + size() || nupc() != upc() + 1;
122 }
123
124 bool
125 equals(const PCStateBase &other) const override
126 {
127 auto &opc = other.as<PCState>();
128 return Base::equals(other) &&
129 _vlenb == opc._vlenb &&
130 _vtype == opc._vtype &&
131 _vl == opc._vl;
132 }
133
134 void
144
145 void
155};
156
157} // namespace RiscvISA
158} // namespace gem5
159
160#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:90
bool branching() const override
Definition pcstate.hh:119
bool equals(const PCStateBase &other) const override
Definition pcstate.hh:125
PCState(Addr addr, RiscvType rvType, uint64_t vlenb)
Definition pcstate.hh:80
void compressed(bool c)
Definition pcstate.hh:101
uint64_t vlenb() const
Definition pcstate.hh:108
PCState(const PCState &other)
Definition pcstate.hh:73
VTYPE vtype() const
Definition pcstate.hh:111
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition pcstate.hh:135
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition pcstate.hh:146
PCState & operator=(const PCState &other)=default
bool compressed() const
Definition pcstate.hh:102
void vlenb(uint64_t v)
Definition pcstate.hh:107
PCStateBase * clone() const override
Definition pcstate.hh:87
GenericISA::UPCState< 4 > Base
Definition pcstate.hh:64
void rvType(RiscvType rvType)
Definition pcstate.hh:104
uint64_t size() const
Definition pcstate.hh:116
uint32_t vl() const
Definition pcstate.hh:114
void vtype(VTYPE v)
Definition pcstate.hh:110
RiscvType rvType() const
Definition pcstate.hh:105
void vl(uint32_t v)
Definition pcstate.hh:113
Bitfield< 12, 11 > set
constexpr enums::RiscvType RV32
Definition pcstate.hh:56
enums::PrivilegeModeSet PrivilegeModeSet
Definition pcstate.hh:59
Bitfield< 0 > v
Definition pagetable.hh:76
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 - Pranith Kumar Copyright (c) 2020 Inria 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 Tue Jun 18 2024 16:23:59 for gem5 by doxygen 1.11.0