gem5  [DEVELOP-FOR-23.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/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 
77 namespace minor
78 {
79 
80 void
81 QueuedInst::reportData(std::ostream &os) const
82 {
83  inst->reportData(os);
84 }
85 
86 FUPipeline::FUPipeline(const std::string &name, const MinorFU &description_,
87  ClockedObject &timeSource_) :
88  FUPipelineBase(name, "insts", description_.opLat),
89  description(description_),
90  timeSource(timeSource_),
91  nextInsertCycle(Cycles(0))
92 {
93  /* Issue latencies are set to 1 in calls to addCapability here.
94  * Issue latencies are associated with the pipeline as a whole,
95  * rather than instruction classes in Minor */
96 
97  /* All pipelines should be able to execute No_OpClass instructions */
98  addCapability(No_OpClass, description.opLat, 1);
99 
100  /* Add the capabilities listed in the MinorFU for this functional unit */
101  for (unsigned int i = 0; i < description.opClasses->opClasses.size();
102  i++)
103  {
105  description.opLat, 1);
106  }
107 
108  for (unsigned int i = 0; i < description.timings.size(); i++) {
109  MinorFUTiming &timing = *(description.timings[i]);
110 
111  if (debug::MinorTiming) {
112  std::ostringstream lats;
113 
114  unsigned int num_lats = timing.srcRegsRelativeLats.size();
115  unsigned int j = 0;
116  while (j < num_lats) {
117  lats << timing.srcRegsRelativeLats[j];
118 
119  j++;
120  if (j != num_lats)
121  lats << ',';
122  }
123 
124  DPRINTFS(MinorTiming, static_cast<Named *>(this),
125  "Adding extra timing decode pattern %d to FU"
126  " mask: %016x match: %016x srcRegLatencies: %s\n",
127  i, timing.mask, timing.match, lats.str());
128  }
129  }
130 
131  const std::vector<unsigned> &cant_forward =
133 
134  /* Setup the bit vector cantForward... with the set indices
135  * specified in the parameters */
136  for (auto i = cant_forward.begin(); i != cant_forward.end(); ++i) {
137  cantForwardFromFUIndices.resize((*i) + 1, false);
138  cantForwardFromFUIndices[*i] = true;
139  }
140 }
141 
142 Cycles
144 {
146  return Cycles(0);
147  else
149 }
150 
151 bool
153 {
155 }
156 
157 void
159 {
160  bool was_stalled = stalled;
161 
162  /* If an instruction was pushed into the pipeline, set the delay before
163  * the next instruction can follow */
164  if (alreadyPushed()) {
167  }
168  } else if (was_stalled && nextInsertCycle != 0) {
169  /* Don't count stalled cycles as part of the issue latency */
170  ++nextInsertCycle;
171  }
173 }
174 
177 {
178  /*
179  * This will only work on ISAs with an instruction format with a fixed size
180  * which can be categorized using bit masks. This is really only supported
181  * on ARM and is a bit of a hack.
182  */
183  uint64_t mach_inst = inst->getEMI();
184 
185  const std::vector<MinorFUTiming *> &timings =
187  unsigned int num_timings = timings.size();
188 
189  for (unsigned int i = 0; i < num_timings; i++) {
190  MinorFUTiming &timing = *timings[i];
191 
192  if (timing.provides(inst->opClass()) &&
193  (mach_inst & timing.mask) == timing.match)
194  {
195  DPRINTFS(MinorTiming, static_cast<Named *>(this),
196  "Found extra timing match (pattern %d '%s')"
197  " %s %16x (type %s)\n",
198  i, timing.description, inst->disassemble(0), mach_inst,
199  typeid(inst).name());
200 
201  return &timing;
202  }
203  }
204 
205  if (num_timings != 0) {
206  DPRINTFS(MinorTiming, static_cast<Named *>(this),
207  "No extra timing info. found for inst: %s"
208  " mach_inst: %16x\n",
209  inst->disassemble(0), mach_inst);
210  }
211 
212  return NULL;
213 }
214 
215 } // namespace minor
216 } // namespace gem5
gem5::minor::SelfStallingPipeline::stalled
bool stalled
If true, advance will not advance the pipeline.
Definition: buffers.hh:303
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:209
named.hh
gem5::minor::FUPipeline::FUPipeline
FUPipeline(const std::string &name, const MinorFU &description_, ClockedObject &timeSource_)
Definition: func_unit.cc:86
minor
gem5::minor::FUPipeline::advance
void advance()
Step the pipeline.
Definition: func_unit.cc:158
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:239
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:67
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:252
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:210
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:81
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:217
name
const std::string & name()
Definition: trace.cc:48
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:236
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:60
gem5::minor::FUPipeline::description
const MinorFU & description
Functional unit description that this pipeline implements.
Definition: func_unit.hh:236
gem5::X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:810
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:152
gem5::minor::SelfStallingPipeline::advance
void advance()
Try to advance the pipeline.
Definition: buffers.hh:355
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:246
gem5::Num_OpClasses
static const OpClass Num_OpClasses
Definition: op_class.hh:137
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:143
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: gpu_translation_state.hh:37
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:293
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:346
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:176

Generated on Sun Jul 30 2023 01:56:52 for gem5 by doxygen 1.8.17