gem5  v22.1.0.0
func_unit.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2014 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #include "cpu/minor/func_unit.hh"
39 
40 #include <iomanip>
41 #include <sstream>
42 #include <typeinfo>
43 
44 #include "base/named.hh"
45 #include "base/trace.hh"
46 #include "debug/MinorTiming.hh"
47 #include "enums/OpClass.hh"
48 
49 namespace gem5
50 {
51 
52 MinorOpClassSet::MinorOpClassSet(const MinorOpClassSetParams &params) :
53  SimObject(params),
54  opClasses(params.opClasses),
55  /* Initialise to true for an empty list so that 'fully capable' is
56  * the default */
57  capabilityList(Num_OpClasses, (opClasses.empty() ? true : false))
58 {
59  for (unsigned int i = 0; i < opClasses.size(); i++)
60  capabilityList[opClasses[i]->opClass] = true;
61 }
62 
64  const MinorFUTimingParams &params) :
65  SimObject(params),
66  mask(params.mask),
67  match(params.match),
68  description(params.description),
69  suppress(params.suppress),
70  extraCommitLat(params.extraCommitLat),
71  extraCommitLatExpr(params.extraCommitLatExpr),
72  extraAssumedLat(params.extraAssumedLat),
73  srcRegsRelativeLats(params.srcRegsRelativeLats),
74  opClasses(params.opClasses)
75 { }
76 
78 namespace minor
79 {
80 
81 void
82 QueuedInst::reportData(std::ostream &os) const
83 {
84  inst->reportData(os);
85 }
86 
87 FUPipeline::FUPipeline(const std::string &name, const MinorFU &description_,
88  ClockedObject &timeSource_) :
89  FUPipelineBase(name, "insts", description_.opLat),
90  description(description_),
91  timeSource(timeSource_),
92  nextInsertCycle(Cycles(0))
93 {
94  /* Issue latencies are set to 1 in calls to addCapability here.
95  * Issue latencies are associated with the pipeline as a whole,
96  * rather than instruction classes in Minor */
97 
98  /* All pipelines should be able to execute No_OpClass instructions */
99  addCapability(No_OpClass, description.opLat, 1);
100 
101  /* Add the capabilities listed in the MinorFU for this functional unit */
102  for (unsigned int i = 0; i < description.opClasses->opClasses.size();
103  i++)
104  {
106  description.opLat, 1);
107  }
108 
109  for (unsigned int i = 0; i < description.timings.size(); i++) {
110  MinorFUTiming &timing = *(description.timings[i]);
111 
112  if (debug::MinorTiming) {
113  std::ostringstream lats;
114 
115  unsigned int num_lats = timing.srcRegsRelativeLats.size();
116  unsigned int j = 0;
117  while (j < num_lats) {
118  lats << timing.srcRegsRelativeLats[j];
119 
120  j++;
121  if (j != num_lats)
122  lats << ',';
123  }
124 
125  DPRINTFS(MinorTiming, static_cast<Named *>(this),
126  "Adding extra timing decode pattern %d to FU"
127  " mask: %016x match: %016x srcRegLatencies: %s\n",
128  i, timing.mask, timing.match, lats.str());
129  }
130  }
131 
132  const std::vector<unsigned> &cant_forward =
134 
135  /* Setup the bit vector cantForward... with the set indices
136  * specified in the parameters */
137  for (auto i = cant_forward.begin(); i != cant_forward.end(); ++i) {
138  cantForwardFromFUIndices.resize((*i) + 1, false);
139  cantForwardFromFUIndices[*i] = true;
140  }
141 }
142 
143 Cycles
145 {
147  return Cycles(0);
148  else
150 }
151 
152 bool
154 {
156 }
157 
158 void
160 {
161  bool was_stalled = stalled;
162 
163  /* If an instruction was pushed into the pipeline, set the delay before
164  * the next instruction can follow */
165  if (alreadyPushed()) {
168  }
169  } else if (was_stalled && nextInsertCycle != 0) {
170  /* Don't count stalled cycles as part of the issue latency */
171  ++nextInsertCycle;
172  }
174 }
175 
178 {
179  /*
180  * This will only work on ISAs with an instruction format with a fixed size
181  * which can be categorized using bit masks. This is really only supported
182  * on ARM and is a bit of a hack.
183  */
184  uint64_t mach_inst = inst->getEMI();
185 
186  const std::vector<MinorFUTiming *> &timings =
188  unsigned int num_timings = timings.size();
189 
190  for (unsigned int i = 0; i < num_timings; i++) {
191  MinorFUTiming &timing = *timings[i];
192 
193  if (timing.provides(inst->opClass()) &&
194  (mach_inst & timing.mask) == timing.match)
195  {
196  DPRINTFS(MinorTiming, static_cast<Named *>(this),
197  "Found extra timing match (pattern %d '%s')"
198  " %s %16x (type %s)\n",
199  i, timing.description, inst->disassemble(0), mach_inst,
200  typeid(inst).name());
201 
202  return &timing;
203  }
204  }
205 
206  if (num_timings != 0) {
207  DPRINTFS(MinorTiming, static_cast<Named *>(this),
208  "No extra timing info. found for inst: %s"
209  " mach_inst: %16x\n",
210  inst->disassemble(0), mach_inst);
211  }
212 
213  return NULL;
214 }
215 
216 } // namespace minor
217 } // namespace gem5
#define DPRINTFS(x, s,...)
Definition: trace.hh:193
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
void addCapability(OpClass cap, unsigned oplat, bool pipelined)
Definition: func_unit.cc:64
Extra timing capability to allow individual ops to have their source register dependency latencies tw...
Definition: func_unit.hh:104
std::vector< Cycles > srcRegsRelativeLats
Cycle offsets from the scoreboard delivery times of register values for each of this instruction's so...
Definition: func_unit.hh:136
std::string description
Textual description of the decode's purpose.
Definition: func_unit.hh:112
uint64_t mask
Mask off the ExtMachInst of an instruction before comparing with match.
Definition: func_unit.hh:108
bool provides(OpClass op_class)
Does the extra decode in this object support the given op class.
Definition: func_unit.hh:146
MinorFUTiming(const MinorFUTimingParams &params)
Definition: func_unit.cc:63
A functional unit that can execute any of opClasses operations with a single op(eration)Lat(ency) and...
Definition: func_unit.hh:158
Cycles issueLat
Delay after issuing an operation before the next operation can be issued.
Definition: func_unit.hh:168
std::vector< unsigned int > cantForwardFromFUIndices
FUs which this pipeline can't receive a forwarded (i.e.
Definition: func_unit.hh:172
MinorOpClassSet * opClasses
Definition: func_unit.hh:160
Cycles opLat
Delay from issuing the operation, to it reaching the end of the associated pipeline.
Definition: func_unit.hh:164
std::vector< MinorFUTiming * > timings
Extra timing info to give timings to individual ops.
Definition: func_unit.hh:175
std::vector< MinorOpClass * > opClasses
Definition: func_unit.hh:85
std::vector< bool > capabilityList
Convenience packing of opClasses into a bit vector for easier testing.
Definition: func_unit.hh:89
MinorOpClassSet(const MinorOpClassSetParams &params)
Definition: func_unit.cc:52
Interface for things with names.
Definition: named.hh:39
Abstract superclass for simulation objects.
Definition: sim_object.hh:148
virtual const std::string & disassemble(Addr pc, const loader::SymbolTable *symtab=nullptr) const
Return string representation of disassembled instruction.
Definition: static_inst.cc:60
virtual uint64_t getEMI() const
Definition: static_inst.hh:236
OpClass opClass() const
Operation class. Used to select appropriate function unit in issue.
Definition: static_inst.hh:210
const MinorFU & description
Functional unit description that this pipeline implements.
Definition: func_unit.hh:237
Cycles nextInsertCycle
When can a new instruction be inserted into the pipeline? This is an absolute cycle time unless it is...
Definition: func_unit.hh:253
FUPipeline(const std::string &name, const MinorFU &description_, ClockedObject &timeSource_)
Definition: func_unit.cc:87
std::vector< bool > cantForwardFromFUIndices
FUs which this pipeline can't receive a forwarded (i.e.
Definition: func_unit.hh:247
Cycles cyclesBeforeInsert()
How many cycles must from curCycle before insertion into the pipeline is allowed.
Definition: func_unit.cc:144
bool canInsert() const
Can an instruction be inserted now?
Definition: func_unit.cc:153
void advance()
Step the pipeline.
Definition: func_unit.cc:159
MinorFUTiming * findTiming(const StaticInstPtr &inst)
Find the extra timing information for this instruction.
Definition: func_unit.cc:177
ClockedObject & timeSource
An FUPipeline needs access to curCycle, use this timing source.
Definition: func_unit.hh:240
void reportData(std::ostream &os) const
Report and bubble interfaces.
Definition: func_unit.cc:82
MinorDynInstPtr inst
Definition: func_unit.hh:210
A pipeline simulating class that will stall (not advance when advance() is called) if a non-bubble va...
Definition: buffers.hh:295
bool alreadyPushed()
Have we already pushed onto this pipe without advancing.
Definition: buffers.hh:347
bool stalled
If true, advance will not advance the pipeline.
Definition: buffers.hh:304
void advance()
Try to advance the pipeline.
Definition: buffers.hh:356
constexpr uint64_t mask(unsigned nbits)
Generate a 64-bit mask of 'nbits' 1s, right justified.
Definition: bitfield.hh:63
Execute function unit descriptions and pipeline implementations.
Bitfield< 7 > i
Definition: misc_types.hh:67
Bitfield< 24 > j
Definition: misc_types.hh:57
Bitfield< 17 > os
Definition: misc.hh:810
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
static const OpClass Num_OpClasses
Definition: op_class.hh:108
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
Minor contains all the definitions within the MinorCPU apart from the CPU class itself.
const std::string & name()
Definition: trace.cc:49

Generated on Wed Dec 21 2022 10:22:30 for gem5 by doxygen 1.9.1