gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
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
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
49namespace gem5
50{
51
52MinorOpClassSet::MinorOpClassSet(const MinorOpClassSetParams &params) :
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
76
77namespace minor
78{
79
80void
81QueuedInst::reportData(std::ostream &os) const
82{
83 inst->reportData(os);
84}
85
86FUPipeline::FUPipeline(const std::string &name, const MinorFU &description_,
87 ClockedObject &timeSource_) :
88 FUPipelineBase(name, "insts", description_.opLat),
89 description(description_),
90 timeSource(timeSource_),
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 {
104 addCapability(description.opClasses->opClasses[i]->opClass,
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 =
132 description.cantForwardFromFUIndices;
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);
139 }
140}
141
142Cycles
144{
145 if (nextInsertCycle == 0 || timeSource.curCycle() > nextInsertCycle)
146 return Cycles(0);
147 else
148 return nextInsertCycle - timeSource.curCycle();
149}
150
151bool
153{
154 return nextInsertCycle == 0 || timeSource.curCycle() >= nextInsertCycle;
155}
156
157void
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()) {
165 if (nextInsertCycle <= timeSource.curCycle()) {
166 nextInsertCycle = timeSource.curCycle() + description.issueLat;
167 }
168 } else if (was_stalled && nextInsertCycle != 0) {
169 /* Don't count stalled cycles as part of the issue latency */
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 =
186 description.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
#define DPRINTFS(x, s,...)
Definition trace.hh:216
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Cycles is a wrapper class for representing cycle counts, i.e.
Definition types.hh:79
void addCapability(OpClass cap, unsigned oplat, bool pipelined)
Definition func_unit.cc:64
std::string name
Definition func_unit.hh:110
Extra timing capability to allow individual ops to have their source register dependency latencies tw...
Definition func_unit.hh:104
TimingExpr * extraCommitLatExpr
Definition func_unit.hh:121
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
std::string description
Textual description of the decode's purpose.
Definition func_unit.hh:112
uint64_t mask
Mask off the ExtMachInst of an instruction before comparing with match.
Definition func_unit.hh:108
bool provides(OpClass op_class)
Does the extra decode in this object support the given op class.
Definition func_unit.hh:146
Cycles extraAssumedLat
Extra delay that results should show in the scoreboard after leaving the pipeline.
Definition func_unit.hh:127
MinorOpClassSet * opClasses
Extra opClasses check (after the FU one)
Definition func_unit.hh:139
bool suppress
If true, instructions matching this mask/match should not be issued in this FU.
Definition func_unit.hh:116
Cycles extraCommitLat
Extra latency that the instruction should spend at the end of the pipeline.
Definition func_unit.hh:120
MinorFUTiming(const MinorFUTimingParams &params)
Definition func_unit.cc:63
A functional unit that can execute any of opClasses operations with a single op(eration)Lat(ency) and...
Definition func_unit.hh:158
std::vector< MinorOpClass * > opClasses
Definition func_unit.hh:85
std::vector< bool > capabilityList
Convenience packing of opClasses into a bit vector for easier testing.
Definition func_unit.hh:89
MinorOpClassSet(const MinorOpClassSetParams &params)
Definition func_unit.cc:52
Named(std::string_view name_)
Definition named.hh:57
virtual const std::string & disassemble(Addr pc, const loader::SymbolTable *symtab=nullptr) const
Return string representation of disassembled instruction.
virtual uint64_t getEMI() const
OpClass opClass() const
Operation class. Used to select appropriate function unit in issue.
const MinorFU & description
Functional unit description that this pipeline implements.
Definition func_unit.hh:236
Cycles nextInsertCycle
When can a new instruction be inserted into the pipeline?
Definition func_unit.hh:252
FUPipeline(const std::string &name, const MinorFU &description_, ClockedObject &timeSource_)
Definition func_unit.cc:86
std::vector< bool > cantForwardFromFUIndices
FUs which this pipeline can't receive a forwarded (i.e.
Definition func_unit.hh:246
Cycles cyclesBeforeInsert()
How many cycles must from curCycle before insertion into the pipeline is allowed.
Definition func_unit.cc:143
bool canInsert() const
Can an instruction be inserted now?
Definition func_unit.cc:152
void advance()
Step the pipeline.
Definition func_unit.cc:158
MinorFUTiming * findTiming(const StaticInstPtr &inst)
Find the extra timing information for this instruction.
Definition func_unit.cc:176
ClockedObject & timeSource
An FUPipeline needs access to curCycle, use this timing source.
Definition func_unit.hh:239
void reportData(std::ostream &os) const
Report and bubble interfaces.
Definition func_unit.cc:81
MinorDynInstPtr inst
Definition func_unit.hh:209
STL vector class.
Definition stl.hh:37
const Params & params() const
SimObject(const Params &p)
Definition sim_object.cc:58
Execute function unit descriptions and pipeline implementations.
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 17 > os
Definition misc.hh:838
SelfStallingPipeline< QueuedInst, ReportTraitsAdaptor< QueuedInst > > FUPipelineBase
Functional units have pipelines which stall when an inst gets to their ends allowing Execute::commit ...
Definition func_unit.hh:229
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
static const OpClass Num_OpClasses
Definition op_class.hh:135
RefCountingPtr< StaticInst > StaticInstPtr
Minor contains all the definitions within the MinorCPU apart from the CPU class itself.

Generated on Mon May 26 2025 09:19:07 for gem5 by doxygen 1.13.2