gem5  v21.0.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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/trace.hh"
45 #include "debug/MinorTiming.hh"
46 #include "enums/OpClass.hh"
47 
48 MinorOpClassSet::MinorOpClassSet(const MinorOpClassSetParams &params) :
49  SimObject(params),
50  opClasses(params.opClasses),
51  /* Initialise to true for an empty list so that 'fully capable' is
52  * the default */
53  capabilityList(Num_OpClasses, (opClasses.empty() ? true : false))
54 {
55  for (unsigned int i = 0; i < opClasses.size(); i++)
56  capabilityList[opClasses[i]->opClass] = true;
57 }
58 
60  const MinorFUTimingParams &params) :
61  SimObject(params),
62  mask(params.mask),
63  match(params.match),
64  description(params.description),
65  suppress(params.suppress),
66  extraCommitLat(params.extraCommitLat),
67  extraCommitLatExpr(params.extraCommitLatExpr),
68  extraAssumedLat(params.extraAssumedLat),
69  srcRegsRelativeLats(params.srcRegsRelativeLats),
70  opClasses(params.opClasses)
71 { }
72 
73 namespace Minor
74 {
75 
76 void
77 QueuedInst::reportData(std::ostream &os) const
78 {
79  inst->reportData(os);
80 }
81 
82 FUPipeline::FUPipeline(const std::string &name, const MinorFU &description_,
83  ClockedObject &timeSource_) :
84  FUPipelineBase(name, "insts", description_.opLat),
85  description(description_),
86  timeSource(timeSource_),
87  nextInsertCycle(Cycles(0))
88 {
89  /* Issue latencies are set to 1 in calls to addCapability here.
90  * Issue latencies are associated with the pipeline as a whole,
91  * rather than instruction classes in Minor */
92 
93  /* All pipelines should be able to execute No_OpClass instructions */
94  addCapability(No_OpClass, description.opLat, 1);
95 
96  /* Add the capabilities listed in the MinorFU for this functional unit */
97  for (unsigned int i = 0; i < description.opClasses->opClasses.size();
98  i++)
99  {
101  description.opLat, 1);
102  }
103 
104  for (unsigned int i = 0; i < description.timings.size(); i++) {
105  MinorFUTiming &timing = *(description.timings[i]);
106 
107  if (DTRACE(MinorTiming)) {
108  std::ostringstream lats;
109 
110  unsigned int num_lats = timing.srcRegsRelativeLats.size();
111  unsigned int j = 0;
112  while (j < num_lats) {
113  lats << timing.srcRegsRelativeLats[j];
114 
115  j++;
116  if (j != num_lats)
117  lats << ',';
118  }
119 
120  DPRINTFS(MinorTiming, static_cast<Named *>(this),
121  "Adding extra timing decode pattern %d to FU"
122  " mask: %016x match: %016x srcRegLatencies: %s\n",
123  i, timing.mask, timing.match, lats.str());
124  }
125  }
126 
127  const std::vector<unsigned> &cant_forward =
129 
130  /* Setup the bit vector cantForward... with the set indices
131  * specified in the parameters */
132  for (auto i = cant_forward.begin(); i != cant_forward.end(); ++i) {
133  cantForwardFromFUIndices.resize((*i) + 1, false);
134  cantForwardFromFUIndices[*i] = true;
135  }
136 }
137 
138 Cycles
140 {
142  return Cycles(0);
143  else
145 }
146 
147 bool
149 {
151 }
152 
153 void
155 {
156  bool was_stalled = stalled;
157 
158  /* If an instruction was pushed into the pipeline, set the delay before
159  * the next instruction can follow */
160  if (alreadyPushed()) {
163  }
164  } else if (was_stalled && nextInsertCycle != 0) {
165  /* Don't count stalled cycles as part of the issue latency */
166  ++nextInsertCycle;
167  }
169 }
170 
173 {
174  /*
175  * This will only work on ISAs with an instruction format with a fixed size
176  * which can be categorized using bit masks. This is really only supported
177  * on ARM and is a bit of a hack.
178  */
179  uint64_t mach_inst = inst->getEMI();
180 
181  const std::vector<MinorFUTiming *> &timings =
183  unsigned int num_timings = timings.size();
184 
185  for (unsigned int i = 0; i < num_timings; i++) {
186  MinorFUTiming &timing = *timings[i];
187 
188  if (timing.provides(inst->opClass()) &&
189  (mach_inst & timing.mask) == timing.match)
190  {
191  DPRINTFS(MinorTiming, static_cast<Named *>(this),
192  "Found extra timing match (pattern %d '%s')"
193  " %s %16x (type %s)\n",
194  i, timing.description, inst->disassemble(0), mach_inst,
195  typeid(inst).name());
196 
197  return &timing;
198  }
199  }
200 
201  if (num_timings != 0) {
202  DPRINTFS(MinorTiming, static_cast<Named *>(this),
203  "No extra timing info. found for inst: %s"
204  " mach_inst: %16x\n",
205  inst->disassemble(0), mach_inst);
206  }
207 
208  return NULL;
209 }
210 
211 }
Num_OpClasses
static const OpClass Num_OpClasses
Definition: op_class.hh:105
MinorFUTiming::srcRegsRelativeLats
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:133
FuncUnit::addCapability
void addCapability(OpClass cap, unsigned oplat, bool pipelined)
Definition: func_unit.cc:61
X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:803
Minor::QueuedInst::reportData
void reportData(std::ostream &os) const
Report and bubble interfaces.
Definition: func_unit.cc:77
Minor::SelfStallingPipeline::advance
void advance()
Try to advance the pipeline.
Definition: buffers.hh:351
StaticInst::getEMI
virtual uint64_t getEMI() const
Definition: static_inst.hh:261
Minor::SelfStallingPipeline::stalled
bool stalled
If true, advance will not advance the pipeline.
Definition: buffers.hh:299
MinorFUTiming
Extra timing capability to allow individual ops to have their source register dependency latencies tw...
Definition: func_unit.hh:100
Minor::FUPipeline::nextInsertCycle
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:249
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
MinorFUTiming::provides
bool provides(OpClass op_class)
Does the extra decode in this object support the given op class.
Definition: func_unit.hh:143
Minor::FUPipeline::canInsert
bool canInsert() const
Can an instruction be inserted now?
Definition: func_unit.cc:148
StaticInst::disassemble
virtual const std::string & disassemble(Addr pc, const Loader::SymbolTable *symtab=nullptr) const
Return string representation of disassembled instruction.
Definition: static_inst.cc:117
DTRACE
#define DTRACE(x)
Definition: debug.hh:156
MinorFUTiming::description
std::string description
Textual description of the decode's purpose.
Definition: func_unit.hh:109
std::vector< unsigned >
Minor::FUPipeline::cyclesBeforeInsert
Cycles cyclesBeforeInsert()
How many cycles must from curCycle before insertion into the pipeline is allowed.
Definition: func_unit.cc:139
StaticInst::opClass
OpClass opClass() const
Operation class. Used to select appropriate function unit in issue.
Definition: static_inst.hh:229
Minor
Definition: activity.cc:44
ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:231
MinorFU::opLat
Cycles opLat
Delay from issuing the operation, to it reaching the end of the associated pipeline.
Definition: func_unit.hh:161
Minor::FUPipeline::FUPipeline
FUPipeline(const std::string &name, const MinorFU &description_, ClockedObject &timeSource_)
Definition: func_unit.cc:82
Minor::SelfStallingPipeline
A pipeline simulating class that will stall (not advance when advance() is called) if a non-bubble va...
Definition: buffers.hh:289
Minor::FUPipeline::cantForwardFromFUIndices
std::vector< bool > cantForwardFromFUIndices
FUs which this pipeline can't receive a forwarded (i.e.
Definition: func_unit.hh:243
ArmISA::j
Bitfield< 24 > j
Definition: miscregs_types.hh:54
Minor::SelfStallingPipeline::alreadyPushed
bool alreadyPushed()
Have we already pushed onto this pipe without advancing.
Definition: buffers.hh:342
MinorOpClassSet::MinorOpClassSet
MinorOpClassSet(const MinorOpClassSetParams &params)
Definition: func_unit.cc:48
Minor::FUPipeline::advance
void advance()
Step the pipeline.
Definition: func_unit.cc:154
func_unit.hh
MinorFUTiming::MinorFUTiming
MinorFUTiming(const MinorFUTimingParams &params)
Definition: func_unit.cc:59
Clocked::curCycle
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
Definition: clocked_object.hh:192
MinorOpClassSet::opClasses
std::vector< MinorOpClass * > opClasses
Definition: func_unit.hh:82
MinorFUTiming::mask
uint64_t mask
Mask off the ExtMachInst of an instruction before comparing with match.
Definition: func_unit.hh:105
MinorFU::timings
std::vector< MinorFUTiming * > timings
Extra timing info to give timings to individual ops.
Definition: func_unit.hh:172
MinorFU::issueLat
Cycles issueLat
Delay after issuing an operation before the next operation can be issued.
Definition: func_unit.hh:165
Minor::FUPipeline::timeSource
ClockedObject & timeSource
An FUPipeline needs access to curCycle, use this timing source.
Definition: func_unit.hh:236
Minor::QueuedInst::inst
MinorDynInstPtr inst
Definition: func_unit.hh:206
name
const std::string & name()
Definition: trace.cc:48
Named
Definition: trace.hh:150
MinorFUTiming::match
uint64_t match
Definition: func_unit.hh:106
MinorFU
A functional unit that can execute any of opClasses operations with a single op(eration)Lat(ency) and...
Definition: func_unit.hh:154
DPRINTFS
#define DPRINTFS(x,...)
Definition: trace.hh:238
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
Minor::FUPipeline::description
const MinorFU & description
Functional unit description that this pipeline implements.
Definition: func_unit.hh:233
RefCountingPtr< StaticInst >
trace.hh
MinorFU::opClasses
MinorOpClassSet * opClasses
Definition: func_unit.hh:157
Minor::FUPipeline::findTiming
MinorFUTiming * findTiming(const StaticInstPtr &inst)
Find the extra timing information for this instruction.
Definition: func_unit.cc:172
MinorFU::cantForwardFromFUIndices
std::vector< unsigned int > cantForwardFromFUIndices
FUs which this pipeline can't receive a forwarded (i.e.
Definition: func_unit.hh:169
ArmISA::mask
Bitfield< 28, 24 > mask
Definition: miscregs_types.hh:711
MinorOpClassSet::capabilityList
std::vector< bool > capabilityList
Convenience packing of opClasses into a bit vector for easier testing.
Definition: func_unit.hh:86
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:141

Generated on Tue Jun 22 2021 15:28:26 for gem5 by doxygen 1.8.17