gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
decoder.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 Google
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef __ARCH_MIPS_DECODER_HH__
30 #define __ARCH_MIPS_DECODER_HH__
31 
33 #include "arch/generic/decoder.hh"
34 #include "arch/mips/types.hh"
35 #include "base/logging.hh"
36 #include "base/types.hh"
37 #include "cpu/static_inst.hh"
38 #include "debug/Decode.hh"
39 #include "params/MipsDecoder.hh"
40 
41 namespace gem5
42 {
43 
44 class BaseISA;
45 
46 namespace MipsISA
47 {
48 
49 class Decoder : public InstDecoder
50 {
51  protected:
52  //The extended machine instruction being generated
54  uint32_t machInst;
55 
56  public:
57  Decoder(const MipsDecoderParams &p) : InstDecoder(p, &machInst)
58  {}
59 
60  //Use this to give data to the decoder. This should be used
61  //when there is control flow.
62  void
63  moreBytes(const PCStateBase &pc, Addr fetchPC) override
64  {
65  emi = letoh(machInst);
66  instDone = true;
67  }
68 
69  protected:
73 
75 
81  {
82  StaticInstPtr si = defaultCache.decode(this, mach_inst, addr);
83  DPRINTF(Decode, "Decode: Decoded %s instruction: %#x\n",
84  si->getName(), mach_inst);
85  return si;
86  }
87 
88  public:
90  decode(PCStateBase &next_pc) override
91  {
92  if (!instDone)
93  return NULL;
94  instDone = false;
95  return decode(emi, next_pc.instAddr());
96  }
97 };
98 
99 } // namespace MipsISA
100 } // namespace gem5
101 
102 #endif // __ARCH_MIPS_DECODER_HH__
gem5::PCStateBase::instAddr
Addr instAddr() const
Returns the memory address of the instruction this PC points to.
Definition: pcstate.hh:107
gem5::MipsISA::Decoder::defaultCache
static GenericISA::BasicDecodeCache< Decoder, ExtMachInst > defaultCache
A cache of decoded instruction objects.
Definition: decoder.hh:71
types.hh
decode_cache.hh
gem5::MipsISA::Decoder
Definition: decoder.hh:49
gem5::GenericISA::BasicDecodeCache
Definition: decode_cache.hh:43
gem5::RefCountingPtr< StaticInst >
gem5::letoh
T letoh(T value)
Definition: byteswap.hh:173
gem5::MipsISA::Decoder::moreBytes
void moreBytes(const PCStateBase &pc, Addr fetchPC) override
Feed data to the decoder.
Definition: decoder.hh:63
decoder.hh
gem5::InstDecoder
Definition: decoder.hh:42
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:210
gem5::MipsISA::ExtMachInst
uint64_t ExtMachInst
Definition: types.hh:43
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::MipsISA::Decoder::decode
StaticInstPtr decode(ExtMachInst mach_inst, Addr addr)
Decode a machine instruction.
Definition: decoder.hh:80
gem5::MipsISA::Decoder::machInst
uint32_t machInst
Definition: decoder.hh:54
static_inst.hh
gem5::ArmISA::si
Bitfield< 6 > si
Definition: misc_types.hh:914
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::InstDecoder::instDone
bool instDone
Definition: decoder.hh:49
types.hh
gem5::MipsISA::Decoder::Decoder
Decoder(const MipsDecoderParams &p)
Definition: decoder.hh:57
gem5::MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:243
logging.hh
gem5::MipsISA::Decoder::decode
StaticInstPtr decode(PCStateBase &next_pc) override
Decode an instruction or fetch it from the code cache.
Definition: decoder.hh:90
gem5::PCStateBase
Definition: pcstate.hh:57
gem5::MipsISA::Decoder::emi
ExtMachInst emi
Definition: decoder.hh:53
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84
gem5::MipsISA::Decoder::decodeInst
StaticInstPtr decodeInst(ExtMachInst mach_inst)

Generated on Sun Jul 30 2023 01:56:47 for gem5 by doxygen 1.8.17