gem5  v21.1.0.2
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
gem5::minor::SelfStallingPipeline::stalled
bool stalled
If true, advance will not advance the pipeline.
Definition: buffers.hh:304
gem5::Clocked::curCycle
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
Definition: clocked_object.hh:195
gem5::minor::QueuedInst::inst
MinorDynInstPtr inst
Definition: func_unit.hh:210
named.hh
gem5::minor::FUPipeline::FUPipeline
FUPipeline(const std::string &name, const MinorFU &description_, ClockedObject &timeSource_)
Definition: func_unit.cc:87
minor
gem5::minor::FUPipeline::advance
void advance()
Step the pipeline.
Definition: func_unit.cc:159
std::vector< unsigned >
gem5::MinorFUTiming::description
std::string description
Textual description of the decode's purpose.
Definition: func_unit.hh:112
gem5::MinorFUTiming
Extra timing capability to allow individual ops to have their source register dependency latencies tw...
Definition: func_unit.hh:103
gem5::MinorFU::issueLat
Cycles issueLat
Delay after issuing an operation before the next operation can be issued.
Definition: func_unit.hh:168
gem5::minor::FUPipeline::timeSource
ClockedObject & timeSource
An FUPipeline needs access to curCycle, use this timing source.
Definition: func_unit.hh:240
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:66
gem5::MinorFU::cantForwardFromFUIndices
std::vector< unsigned int > cantForwardFromFUIndices
FUs which this pipeline can't receive a forwarded (i.e.
Definition: func_unit.hh:172
gem5::RefCountingPtr< StaticInst >
gem5::mask
constexpr uint64_t mask(unsigned nbits)
Generate a 64-bit mask of 'nbits' 1s, right justified.
Definition: bitfield.hh:63
gem5::MinorOpClassSet::opClasses
std::vector< MinorOpClass * > opClasses
Definition: func_unit.hh:85
gem5::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:253
gem5::Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:78
gem5::Named
Interface for things with names.
Definition: named.hh:38
gem5::StaticInst::opClass
OpClass opClass() const
Operation class. Used to select appropriate function unit in issue.
Definition: static_inst.hh:232
gem5::ArmISA::j
Bitfield< 24 > j
Definition: misc_types.hh:57
gem5::minor::QueuedInst::reportData
void reportData(std::ostream &os) const
Report and bubble interfaces.
Definition: func_unit.cc:82
gem5::MinorFU
A functional unit that can execute any of opClasses operations with a single op(eration)Lat(ency) and...
Definition: func_unit.hh:157
func_unit.hh
gem5::FuncUnit::addCapability
void addCapability(OpClass cap, unsigned oplat, bool pipelined)
Definition: func_unit.cc:64
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::MinorFUTiming::provides
bool provides(OpClass op_class)
Does the extra decode in this object support the given op class.
Definition: func_unit.hh:146
gem5::MinorFUTiming::mask
uint64_t mask
Mask off the ExtMachInst of an instruction before comparing with match.
Definition: func_unit.hh:108
DPRINTFS
#define DPRINTFS(x, s,...)
Definition: trace.hh:193
gem5::GEM5_DEPRECATED_NAMESPACE
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
name
const std::string & name()
Definition: trace.cc:49
gem5::ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:234
gem5::MinorFUTiming::MinorFUTiming
MinorFUTiming(const MinorFUTimingParams &params)
Definition: func_unit.cc:63
gem5::MinorFU::opLat
Cycles opLat
Delay from issuing the operation, to it reaching the end of the associated pipeline.
Definition: func_unit.hh:164
gem5::StaticInst::getEMI
virtual uint64_t getEMI() const
Definition: static_inst.hh:258
gem5::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:75
gem5::minor::FUPipeline::description
const MinorFU & description
Functional unit description that this pipeline implements.
Definition: func_unit.hh:237
gem5::X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:809
gem5::MinorOpClassSet::MinorOpClassSet
MinorOpClassSet(const MinorOpClassSetParams &params)
Definition: func_unit.cc:52
gem5::minor::FUPipeline::canInsert
bool canInsert() const
Can an instruction be inserted now?
Definition: func_unit.cc:153
gem5::minor::SelfStallingPipeline::advance
void advance()
Try to advance the pipeline.
Definition: buffers.hh:356
gem5::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:136
gem5::minor::FUPipeline::cantForwardFromFUIndices
std::vector< bool > cantForwardFromFUIndices
FUs which this pipeline can't receive a forwarded (i.e.
Definition: func_unit.hh:247
gem5::Num_OpClasses
static const OpClass Num_OpClasses
Definition: op_class.hh:108
trace.hh
gem5::minor::FUPipeline::cyclesBeforeInsert
Cycles cyclesBeforeInsert()
How many cycles must from curCycle before insertion into the pipeline is allowed.
Definition: func_unit.cc:144
gem5::MinorOpClassSet::capabilityList
std::vector< bool > capabilityList
Convenience packing of opClasses into a bit vector for easier testing.
Definition: func_unit.hh:89
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::MinorFU::opClasses
MinorOpClassSet * opClasses
Definition: func_unit.hh:160
gem5::minor::SelfStallingPipeline
A pipeline simulating class that will stall (not advance when advance() is called) if a non-bubble va...
Definition: buffers.hh:294
gem5::MinorFU::timings
std::vector< MinorFUTiming * > timings
Extra timing info to give timings to individual ops.
Definition: func_unit.hh:175
gem5::minor::SelfStallingPipeline::alreadyPushed
bool alreadyPushed()
Have we already pushed onto this pipe without advancing.
Definition: buffers.hh:347
gem5::MinorFUTiming::match
uint64_t match
Definition: func_unit.hh:109
gem5::minor::FUPipeline::findTiming
MinorFUTiming * findTiming(const StaticInstPtr &inst)
Find the extra timing information for this instruction.
Definition: func_unit.cc:177

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