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

Generated on Fri Jun 9 2017 13:03:42 for gem5 by doxygen 1.8.6