gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
32#include "base/bitfield.hh"
33#include "base/intmath.hh"
34#include "base/types.hh"
36#include "params/InstDecoder.hh"
37#include "sim/sim_object.hh"
38
39namespace gem5
40{
41
42class 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) :
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 &
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;
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
157};
158
159} // namespace gem5
160
161#endif // __ARCH_DECODER_GENERIC_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
virtual StaticInstPtr decode(PCStateBase &pc)=0
Decode an instruction or fetch it from the code cache.
virtual StaticInstPtr fetchRomMicroop(MicroPC micropc, StaticInstPtr curMacroop)
Definition decoder.cc:36
virtual void takeOverFrom(InstDecoder *old)
Take over the state from an old decoder when switching CPUs.
Definition decoder.hh:89
InstDecoder(const InstDecoderParams &params, MoreBytesType *mb_buf)
Definition decoder.hh:54
void * moreBytesPtr() const
Definition decoder.hh:95
size_t moreBytesSize() const
Definition decoder.hh:96
bool needMoreBytes() const
Can the decoder accept more data?
Definition decoder.hh:116
bool instReady() const
Is an instruction ready to be decoded?
Definition decoder.hh:107
virtual void reset()
Definition decoder.hh:63
virtual void moreBytes(const PCStateBase &pc, Addr fetchPC)=0
Feed data to the decoder.
void * _moreBytesPtr
Definition decoder.hh:45
const Type & as() const
Definition decoder.hh:78
size_t _moreBytesSize
Definition decoder.hh:46
Addr pcMask() const
Definition decoder.hh:97
Abstract superclass for simulation objects.
static constexpr std::enable_if_t< std::is_integral_v< T >, int > floorLog2(T x)
Definition intmath.hh:59
const Params & params() const
Bitfield< 3, 0 > mask
Definition pcstate.hh:63
Bitfield< 4 > pc
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint16_t MicroPC
Definition types.hh:149

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