gem5  v20.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 "debug/MinorTiming.hh"
45 #include "enums/OpClass.hh"
46 
48 MinorOpClassParams::create()
49 {
50  return new MinorOpClass(this);
51 }
52 
54 MinorOpClassSetParams::create()
55 {
56  return new MinorOpClassSet(this);
57 }
58 
60 MinorFUTimingParams::create()
61 {
62  return new MinorFUTiming(this);
63 }
64 
65 MinorFU *
66 MinorFUParams::create()
67 {
68  return new MinorFU(this);
69 }
70 
72 MinorFUPoolParams::create()
73 {
74  return new MinorFUPool(this);
75 }
76 
77 MinorOpClassSet::MinorOpClassSet(const MinorOpClassSetParams *params) :
78  SimObject(params),
79  opClasses(params->opClasses),
80  /* Initialise to true for an empty list so that 'fully capable' is
81  * the default */
82  capabilityList(Num_OpClasses, (opClasses.empty() ? true : false))
83 {
84  for (unsigned int i = 0; i < opClasses.size(); i++)
85  capabilityList[opClasses[i]->opClass] = true;
86 }
87 
89  const MinorFUTimingParams *params) :
90  SimObject(params),
91  mask(params->mask),
92  match(params->match),
93  description(params->description),
94  suppress(params->suppress),
95  extraCommitLat(params->extraCommitLat),
96  extraCommitLatExpr(params->extraCommitLatExpr),
97  extraAssumedLat(params->extraAssumedLat),
98  srcRegsRelativeLats(params->srcRegsRelativeLats),
99  opClasses(params->opClasses)
100 { }
101 
102 namespace Minor
103 {
104 
105 void
106 QueuedInst::reportData(std::ostream &os) const
107 {
108  inst->reportData(os);
109 }
110 
111 FUPipeline::FUPipeline(const std::string &name, const MinorFU &description_,
112  ClockedObject &timeSource_) :
113  FUPipelineBase(name, "insts", description_.opLat),
114  description(description_),
115  timeSource(timeSource_),
116  nextInsertCycle(Cycles(0))
117 {
118  /* Issue latencies are set to 1 in calls to addCapability here.
119  * Issue latencies are associated with the pipeline as a whole,
120  * rather than instruction classes in Minor */
121 
122  /* All pipelines should be able to execute No_OpClass instructions */
123  addCapability(No_OpClass, description.opLat, 1);
124 
125  /* Add the capabilities listed in the MinorFU for this functional unit */
126  for (unsigned int i = 0; i < description.opClasses->opClasses.size();
127  i++)
128  {
130  description.opLat, 1);
131  }
132 
133  for (unsigned int i = 0; i < description.timings.size(); i++) {
134  MinorFUTiming &timing = *(description.timings[i]);
135 
136  if (DTRACE(MinorTiming)) {
137  std::ostringstream lats;
138 
139  unsigned int num_lats = timing.srcRegsRelativeLats.size();
140  unsigned int j = 0;
141  while (j < num_lats) {
142  lats << timing.srcRegsRelativeLats[j];
143 
144  j++;
145  if (j != num_lats)
146  lats << ',';
147  }
148 
149  DPRINTFS(MinorTiming, static_cast<Named *>(this),
150  "Adding extra timing decode pattern %d to FU"
151  " mask: %016x match: %016x srcRegLatencies: %s\n",
152  i, timing.mask, timing.match, lats.str());
153  }
154  }
155 
156  const std::vector<unsigned> &cant_forward =
158 
159  /* Setup the bit vector cantForward... with the set indices
160  * specified in the parameters */
161  for (auto i = cant_forward.begin(); i != cant_forward.end(); ++i) {
162  cantForwardFromFUIndices.resize((*i) + 1, false);
163  cantForwardFromFUIndices[*i] = true;
164  }
165 }
166 
167 Cycles
169 {
171  return Cycles(0);
172  else
174 }
175 
176 bool
178 {
180 }
181 
182 void
184 {
185  bool was_stalled = stalled;
186 
187  /* If an instruction was pushed into the pipeline, set the delay before
188  * the next instruction can follow */
189  if (alreadyPushed()) {
192  }
193  } else if (was_stalled && nextInsertCycle != 0) {
194  /* Don't count stalled cycles as part of the issue latency */
195  ++nextInsertCycle;
196  }
198 }
199 
202 {
203 #if THE_ISA == ARM_ISA
204  /* This should work for any ISA with a POD mach_inst */
205  TheISA::ExtMachInst mach_inst = inst->machInst;
206 #else
207  /* Just allow extra decode based on op classes */
208  uint64_t mach_inst = 0;
209 #endif
210 
211  const std::vector<MinorFUTiming *> &timings =
213  unsigned int num_timings = timings.size();
214 
215  for (unsigned int i = 0; i < num_timings; i++) {
216  MinorFUTiming &timing = *timings[i];
217 
218  if (timing.provides(inst->opClass()) &&
219  (mach_inst & timing.mask) == timing.match)
220  {
221  DPRINTFS(MinorTiming, static_cast<Named *>(this),
222  "Found extra timing match (pattern %d '%s')"
223  " %s %16x (type %s)\n",
224  i, timing.description, inst->disassemble(0), mach_inst,
225  typeid(inst).name());
226 
227  return &timing;
228  }
229  }
230 
231  if (num_timings != 0) {
232  DPRINTFS(MinorTiming, static_cast<Named *>(this),
233  "No extra timing info. found for inst: %s"
234  " mach_inst: %16x\n",
235  inst->disassemble(0), mach_inst);
236  }
237 
238  return NULL;
239 }
240 
241 }
Num_OpClasses
static const OpClass Num_OpClasses
Definition: op_class.hh:105
MinorFUTiming::MinorFUTiming
MinorFUTiming(const MinorFUTimingParams *params)
Definition: func_unit.cc:88
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:126
FuncUnit::addCapability
void addCapability(OpClass cap, unsigned oplat, bool pipelined)
Definition: func_unit.cc:64
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:106
Minor::SelfStallingPipeline::advance
void advance()
Try to advance the pipeline.
Definition: buffers.hh:349
Minor::SelfStallingPipeline::stalled
bool stalled
If true, advance will not advance the pipeline.
Definition: buffers.hh:297
MinorFUTiming
Extra timing capability to allow individual ops to have their source register dependency latencies tw...
Definition: func_unit.hh:93
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:242
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:136
Minor::FUPipeline::canInsert
bool canInsert() const
Can an instruction be inserted now?
Definition: func_unit.cc:177
DTRACE
#define DTRACE(x)
Definition: debug.hh:146
MinorFUTiming::description
std::string description
Textual description of the decode's purpose.
Definition: func_unit.hh:102
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:168
StaticInst::opClass
OpClass opClass() const
Operation class. Used to select appropriate function unit in issue.
Definition: static_inst.hh:225
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:154
Minor::FUPipeline::FUPipeline
FUPipeline(const std::string &name, const MinorFU &description_, ClockedObject &timeSource_)
Definition: func_unit.cc:111
MinorOpClassSet::MinorOpClassSet
MinorOpClassSet(const MinorOpClassSetParams *params)
Definition: func_unit.cc:77
Minor::SelfStallingPipeline
A pipeline simulating class that will stall (not advance when advance() is called) if a non-bubble va...
Definition: buffers.hh:287
Minor::FUPipeline::cantForwardFromFUIndices
std::vector< bool > cantForwardFromFUIndices
FUs which this pipeline can't receive a forwarded (i.e.
Definition: func_unit.hh:236
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:340
Minor::FUPipeline::advance
void advance()
Step the pipeline.
Definition: func_unit.cc:183
func_unit.hh
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:75
MinorFUTiming::mask
uint64_t mask
Mask off the ExtMachInst of an instruction before comparing with match.
Definition: func_unit.hh:98
MinorFU::timings
std::vector< MinorFUTiming * > timings
Extra timing info to give timings to individual ops.
Definition: func_unit.hh:165
MinorFU::issueLat
Cycles issueLat
Delay after issuing an operation before the next operation can be issued.
Definition: func_unit.hh:158
Minor::FUPipeline::timeSource
ClockedObject & timeSource
An FUPipeline needs access to curCycle, use this timing source.
Definition: func_unit.hh:229
Minor::QueuedInst::inst
MinorDynInstPtr inst
Definition: func_unit.hh:199
name
const std::string & name()
Definition: trace.cc:50
Named
Definition: trace.hh:147
StaticInst::machInst
const ExtMachInst machInst
The binary machine instruction.
Definition: static_inst.hh:243
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:121
MinorFUTiming::match
uint64_t match
Definition: func_unit.hh:99
MinorFU
A functional unit that can execute any of opClasses operations with a single op(eration)Lat(ency) and...
Definition: func_unit.hh:147
MinorOpClass
Boxing for MinorOpClass to get around a build problem with C++11 but also allow for future additions ...
Definition: func_unit.hh:59
DPRINTFS
#define DPRINTFS(x,...)
Definition: trace.hh:235
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
Minor::FUPipeline::description
const MinorFU & description
Functional unit description that this pipeline implements.
Definition: func_unit.hh:226
RefCountingPtr< StaticInst >
MinorFUPool
A collection of MinorFUs.
Definition: func_unit.hh:179
MinorFU::opClasses
MinorOpClassSet * opClasses
Definition: func_unit.hh:150
MinorOpClassSet
Wrapper for a matchable set of op classes.
Definition: func_unit.hh:72
Minor::FUPipeline::findTiming
MinorFUTiming * findTiming(const StaticInstPtr &inst)
Find the extra timing information for this instruction.
Definition: func_unit.cc:201
MinorFU::cantForwardFromFUIndices
std::vector< unsigned int > cantForwardFromFUIndices
FUs which this pipeline can't receive a forwarded (i.e.
Definition: func_unit.hh:162
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:79
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92
MipsISA::ExtMachInst
uint64_t ExtMachInst
Definition: types.hh:39

Generated on Wed Sep 30 2020 14:02:08 for gem5 by doxygen 1.8.17