gem5  v22.0.0.2
decoder.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2020 Google, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer;
8  * redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution;
11  * neither the name of the copyright holders nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef __ARCH_GENERIC_DECODER_HH__
29 #define __ARCH_GENERIC_DECODER_HH__
30 
31 #include "arch/generic/pcstate.hh"
32 #include "base/bitfield.hh"
33 #include "base/intmath.hh"
34 #include "base/types.hh"
35 #include "cpu/static_inst_fwd.hh"
36 #include "params/InstDecoder.hh"
37 #include "sim/sim_object.hh"
38 
39 namespace gem5
40 {
41 
42 class InstDecoder : public SimObject
43 {
44  protected:
48 
49  bool instDone = false;
50  bool outOfBytes = true;
51 
52  public:
53  template <typename MoreBytesType>
54  InstDecoder(const InstDecoderParams &params, MoreBytesType *mb_buf) :
55  SimObject(params), _moreBytesPtr(mb_buf),
56  _moreBytesSize(sizeof(MoreBytesType)),
58  {}
59 
61  MicroPC micropc, StaticInstPtr curMacroop);
62  virtual void
64  {
65  instDone = false;
66  outOfBytes = true;
67  }
68 
69  template <class Type>
70  Type &
71  as()
72  {
73  return *static_cast<Type *>(this);
74  }
75 
76  template <class Type>
77  const Type &
78  as() const
79  {
80  return *static_cast<const Type *>(this);
81  }
82 
88  virtual void
90  {
91  instDone = old->instDone;
92  outOfBytes = old->outOfBytes;
93  }
94 
95  void *moreBytesPtr() const { return _moreBytesPtr; }
96  size_t moreBytesSize() const { return _moreBytesSize; }
97  Addr pcMask() const { return _pcMask; }
98 
107  bool instReady() const { return instDone; }
108 
116  bool needMoreBytes() const { return outOfBytes; }
117 
143  virtual void moreBytes(const PCStateBase &pc, Addr fetchPC) = 0;
144 
156  virtual StaticInstPtr decode(PCStateBase &pc) = 0;
157 };
158 
159 } // namespace gem5
160 
161 #endif // __ARCH_DECODER_GENERIC_HH__
gem5::InstDecoder::moreBytes
virtual void moreBytes(const PCStateBase &pc, Addr fetchPC)=0
Feed data to the decoder.
gem5::InstDecoder::InstDecoder
InstDecoder(const InstDecoderParams &params, MoreBytesType *mb_buf)
Definition: decoder.hh:54
gem5::InstDecoder::fetchRomMicroop
virtual StaticInstPtr fetchRomMicroop(MicroPC micropc, StaticInstPtr curMacroop)
Definition: decoder.cc:36
gem5::InstDecoder::takeOverFrom
virtual void takeOverFrom(InstDecoder *old)
Take over the state from an old decoder when switching CPUs.
Definition: decoder.hh:89
gem5::InstDecoder::as
Type & as()
Definition: decoder.hh:71
gem5::InstDecoder::moreBytesPtr
void * moreBytesPtr() const
Definition: decoder.hh:95
gem5::floorLog2
static constexpr std::enable_if_t< std::is_integral_v< T >, int > floorLog2(T x)
Definition: intmath.hh:59
gem5::auxv::Type
Type
Definition: aux_vector.hh:65
gem5::RefCountingPtr< StaticInst >
gem5::mask
constexpr uint64_t mask(unsigned nbits)
Generate a 64-bit mask of 'nbits' 1s, right justified.
Definition: bitfield.hh:63
gem5::MicroPC
uint16_t MicroPC
Definition: types.hh:149
bitfield.hh
gem5::SimObject::params
const Params & params() const
Definition: sim_object.hh:176
sim_object.hh
gem5::InstDecoder
Definition: decoder.hh:42
gem5::InstDecoder::outOfBytes
bool outOfBytes
Definition: decoder.hh:50
gem5::InstDecoder::as
const Type & as() const
Definition: decoder.hh:78
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::InstDecoder::reset
virtual void reset()
Definition: decoder.hh:63
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
pcstate.hh
gem5::InstDecoder::moreBytesSize
size_t moreBytesSize() const
Definition: decoder.hh:96
gem5::InstDecoder::pcMask
Addr pcMask() const
Definition: decoder.hh:97
gem5::InstDecoder::instReady
bool instReady() const
Is an instruction ready to be decoded?
Definition: decoder.hh:107
gem5::InstDecoder::instDone
bool instDone
Definition: decoder.hh:49
gem5::InstDecoder::needMoreBytes
bool needMoreBytes() const
Can the decoder accept more data?
Definition: decoder.hh:116
gem5::InstDecoder::decode
virtual StaticInstPtr decode(PCStateBase &pc)=0
Decode an instruction or fetch it from the code cache.
types.hh
static_inst_fwd.hh
gem5::MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:243
gem5::InstDecoder::_pcMask
Addr _pcMask
Definition: decoder.hh:47
gem5::PCStateBase
Definition: pcstate.hh:57
gem5::InstDecoder::_moreBytesSize
size_t _moreBytesSize
Definition: decoder.hh:46
intmath.hh
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::InstDecoder::_moreBytesPtr
void * _moreBytesPtr
Definition: decoder.hh:45

Generated on Thu Jul 28 2022 13:32:22 for gem5 by doxygen 1.8.17