gem5  v21.1.0.2
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_SPARC_DECODER_HH__
30 #define __ARCH_SPARC_DECODER_HH__
31 
33 #include "arch/generic/decoder.hh"
34 #include "arch/sparc/types.hh"
35 #include "cpu/static_inst.hh"
36 #include "debug/Decode.hh"
37 
38 namespace gem5
39 {
40 
41 namespace SparcISA
42 {
43 
44 class ISA;
45 class Decoder : public InstDecoder
46 {
47  protected:
48  // The extended machine instruction being generated
50  uint32_t machInst;
51  bool instDone;
53 
54  public:
55  Decoder(ISA* isa=nullptr) : InstDecoder(&machInst), instDone(false), asi(0)
56  {}
57 
58  void process() {}
59 
60  void
62  {
63  instDone = false;
64  }
65 
66  // Use this to give data to the predecoder. This should be used
67  // when there is control flow.
68  void
69  moreBytes(const PCState &pc, Addr fetchPC)
70  {
71  emi = betoh(machInst);
72  // The I bit, bit 13, is used to figure out where the ASI
73  // should come from. Use that in the ExtMachInst. This is
74  // slightly redundant, but it removes the need to put a condition
75  // into all the execute functions
76  if (emi & (1 << 13)) {
77  emi |= (static_cast<ExtMachInst>(
78  asi << (sizeof(machInst) * 8)));
79  } else {
80  emi |= (static_cast<ExtMachInst>(bits(emi, 12, 5))
81  << (sizeof(machInst) * 8));
82  }
83  instDone = true;
84  }
85 
86  bool
88  {
89  return true;
90  }
91 
92  bool
94  {
95  return instDone;
96  }
97 
98  void
100  {
101  asi = _asi;
102  }
103 
104  void takeOverFrom(Decoder *old) {}
105 
106  protected:
110 
112 
118  {
119  StaticInstPtr si = defaultCache.decode(this, mach_inst, addr);
120  DPRINTF(Decode, "Decode: Decoded %s instruction: %#x\n",
121  si->getName(), mach_inst);
122  return si;
123  }
124 
125  public:
128  {
129  if (!instDone)
130  return NULL;
131  instDone = false;
132  return decode(emi, nextPC.instAddr());
133  }
134 };
135 
136 } // namespace SparcISA
137 } // namespace gem5
138 
139 #endif // __ARCH_SPARC_DECODER_HH__
gem5::SparcISA::Decoder
Definition: decoder.hh:45
gem5::RegVal
uint64_t RegVal
Definition: types.hh:173
gem5::SparcISA::ExtMachInst
uint64_t ExtMachInst
Definition: types.hh:42
gem5::SparcISA::Decoder::asi
RegVal asi
Definition: decoder.hh:52
gem5::SparcISA::Decoder::decode
StaticInstPtr decode(SparcISA::PCState &nextPC)
Definition: decoder.hh:127
decode_cache.hh
gem5::SparcISA::Decoder::instReady
bool instReady()
Definition: decoder.hh:93
gem5::SparcISA::Decoder::moreBytes
void moreBytes(const PCState &pc, Addr fetchPC)
Definition: decoder.hh:69
gem5::SparcISA::Decoder::needMoreBytes
bool needMoreBytes()
Definition: decoder.hh:87
gem5::betoh
T betoh(T value)
Definition: byteswap.hh:175
gem5::GenericISA::BasicDecodeCache
Definition: decode_cache.hh:43
gem5::SparcISA::Decoder::Decoder
Decoder(ISA *isa=nullptr)
Definition: decoder.hh:55
gem5::SparcISA::Decoder::reset
void reset()
Definition: decoder.hh:61
gem5::SparcISA::Decoder::defaultCache
static GenericISA::BasicDecodeCache< Decoder, ExtMachInst > defaultCache
A cache of decoded instruction objects.
Definition: decoder.hh:108
gem5::RefCountingPtr< StaticInst >
gem5::SparcISA::Decoder::instDone
bool instDone
Definition: decoder.hh:51
gem5::SparcISA::Decoder::decodeInst
StaticInstPtr decodeInst(ExtMachInst mach_inst)
gem5::SparcISA::Decoder::emi
ExtMachInst emi
Definition: decoder.hh:49
decoder.hh
gem5::InstDecoder
Definition: decoder.hh:39
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:186
gem5::SparcISA::ISA
Definition: isa.hh:53
gem5::bits
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:76
static_inst.hh
types.hh
gem5::ArmISA::si
Bitfield< 6 > si
Definition: misc_types.hh:772
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::SparcISA::Decoder::machInst
uint32_t machInst
Definition: decoder.hh:50
gem5::SparcISA::Decoder::process
void process()
Definition: decoder.hh:58
gem5::GenericISA::DelaySlotUPCState
Definition: types.hh:384
gem5::MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:243
gem5::SparcISA::Decoder::takeOverFrom
void takeOverFrom(Decoder *old)
Definition: decoder.hh:104
gem5::GenericISA::PCStateBase::instAddr
Addr instAddr() const
Returns the memory address the bytes of this instruction came from.
Definition: types.hh:73
gem5::SparcISA::Decoder::setContext
void setContext(RegVal _asi)
Definition: decoder.hh:99
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::SparcISA::Decoder::decode
StaticInstPtr decode(ExtMachInst mach_inst, Addr addr)
Decode a machine instruction.
Definition: decoder.hh:117
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84

Generated on Tue Sep 21 2021 12:24:21 for gem5 by doxygen 1.8.17