gem5 v24.0.0.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) :
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
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_),
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);
139 }
140}
141
142Cycles
144{
146 return Cycles(0);
147 else
149}
150
151bool
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()) {
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 =
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:217
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
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
Extra timing capability to allow individual ops to have their source register dependency latencies tw...
Definition func_unit.hh:104
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
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
Cycles issueLat
Delay after issuing an operation before the next operation can be issued.
Definition func_unit.hh:168
std::vector< unsigned int > cantForwardFromFUIndices
FUs which this pipeline can't receive a forwarded (i.e.
Definition func_unit.hh:172
MinorOpClassSet * opClasses
Definition func_unit.hh:160
Cycles opLat
Delay from issuing the operation, to it reaching the end of the associated pipeline.
Definition func_unit.hh:164
std::vector< MinorFUTiming * > timings
Extra timing info to give timings to individual ops.
Definition func_unit.hh:175
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
Interface for things with names.
Definition named.hh:39
Abstract superclass for simulation objects.
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? This is an absolute cycle time unless it is...
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
A pipeline simulating class that will stall (not advance when advance() is called) if a non-bubble va...
Definition buffers.hh:294
bool alreadyPushed()
Have we already pushed onto this pipe without advancing.
Definition buffers.hh:346
bool stalled
If true, advance will not advance the pipeline.
Definition buffers.hh:303
void advance()
Try to advance the pipeline.
Definition buffers.hh:355
STL vector class.
Definition stl.hh:37
Execute function unit descriptions and pipeline implementations.
Bitfield< 3, 0 > mask
Definition pcstate.hh:63
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 17 > os
Definition misc.hh:838
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
static const OpClass Num_OpClasses
Definition op_class.hh:135
Minor contains all the definitions within the MinorCPU apart from the CPU class itself.
const std::string & name()
Definition trace.cc:48

Generated on Tue Jun 18 2024 16:24:01 for gem5 by doxygen 1.11.0