gem5  v20.0.0.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/mips/types.hh"
34 #include "base/logging.hh"
35 #include "base/types.hh"
36 #include "cpu/static_inst.hh"
37 
38 namespace MipsISA
39 {
40 
41 class ISA;
42 class Decoder
43 {
44  protected:
45  //The extended machine instruction being generated
47  bool instDone;
48 
49  public:
50  Decoder(ISA* isa = nullptr) : instDone(false)
51  {}
52 
53  void
55  {
56  }
57 
58  void
60  {
61  instDone = false;
62  }
63 
64  //Use this to give data to the decoder. This should be used
65  //when there is control flow.
66  void
67  moreBytes(const PCState &pc, Addr fetchPC, MachInst inst)
68  {
69  emi = letoh(inst);
70  instDone = true;
71  }
72 
73  bool
75  {
76  return true;
77  }
78 
79  bool
81  {
82  return instDone;
83  }
84 
85  void takeOverFrom(Decoder *old) {}
86 
87  protected:
90 
91  public:
93 
99  {
100  return defaultCache.decode(this, mach_inst, addr);
101  }
102 
105  {
106  if (!instDone)
107  return NULL;
108  instDone = false;
109  return decode(emi, nextPC.instAddr());
110  }
111 };
112 
113 } // namespace MipsISA
114 
115 #endif // __ARCH_MIPS_DECODER_HH__
void takeOverFrom(Decoder *old)
Definition: decoder.hh:85
Addr instAddr() const
Returns the memory address the bytes of this instruction came from.
Definition: types.hh:68
void process()
Definition: decoder.hh:54
uint64_t ExtMachInst
Definition: types.hh:39
StaticInstPtr decode(MipsISA::PCState &nextPC)
Definition: decoder.hh:104
ExtMachInst emi
Definition: decoder.hh:46
ip6_addr_t addr
Definition: inet.hh:330
bool instReady()
Definition: decoder.hh:80
T letoh(T value)
Definition: byteswap.hh:141
uint32_t MachInst
Definition: types.hh:38
StaticInstPtr decodeInst(ExtMachInst mach_inst)
Bitfield< 4 > pc
void reset()
Definition: decoder.hh:59
static GenericISA::BasicDecodeCache defaultCache
A cache of decoded instruction objects.
Definition: decoder.hh:89
StaticInstPtr decode(ExtMachInst mach_inst, Addr addr)
Decode a machine instruction.
Definition: decoder.hh:98
StaticInstPtr decode(TheISA::Decoder *const decoder, TheISA::ExtMachInst mach_inst, Addr addr)
Decode a machine instruction.
Definition: decode_cache.cc:40
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
bool needMoreBytes()
Definition: decoder.hh:74
void moreBytes(const PCState &pc, Addr fetchPC, MachInst inst)
Definition: decoder.hh:67
Decoder(ISA *isa=nullptr)
Definition: decoder.hh:50

Generated on Thu May 28 2020 16:11:00 for gem5 by doxygen 1.8.13