fu_pool.hh (10814:46b6043bd32c) fu_pool.hh (11365:83c3e117464e)
1/*
2 * Copyright (c) 2012-2013 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 * Copyright (c) 2006 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 * Authors: Kevin Lim
41 */
42
43#ifndef __CPU_O3_FU_POOL_HH__
44#define __CPU_O3_FU_POOL_HH__
45
46#include <array>
47#include <bitset>
48#include <list>
49#include <string>
50#include <vector>
51
52#include "cpu/op_class.hh"
53#include "params/FUPool.hh"
54#include "sim/sim_object.hh"
55
56class FUDesc;
57class FuncUnit;
58
59/**
60 * Pool of FU's, specific to the new CPU model. The old FU pool had lists of
61 * free units and busy units, and whenever a FU was needed it would iterate
62 * through the free units to find a FU that provided the capability. This pool
63 * has lists of units specific to each of the capabilities, and whenever a FU
64 * is needed, it iterates through that list to find a free unit. The previous
65 * FU pool would have to be ticked each cycle to update which units became
66 * free. This FU pool lets the IEW stage handle freeing units, which frees
67 * them as their scheduled execution events complete. This limits units in this
68 * model to either have identical issue and op latencies, or 1 cycle issue
69 * latencies.
70 */
71class FUPool : public SimObject
72{
73 private:
74 /** Maximum op execution latencies, per op class. */
75 std::array<Cycles, Num_OpClasses> maxOpLatencies;
76 /** Whether op is pipelined or not. */
77 std::array<bool, Num_OpClasses> pipelined;
78
79 /** Bitvector listing capabilities of this FU pool. */
80 std::bitset<Num_OpClasses> capabilityList;
81
82 /** Bitvector listing which FUs are busy. */
83 std::vector<bool> unitBusy;
84
85 /** List of units to be freed at the end of this cycle. */
86 std::vector<int> unitsToBeFreed;
87
88 /**
89 * Class that implements a circular queue to hold FU indices. The hope is
90 * that FUs that have been just used will be moved to the end of the queue
91 * by iterating through it, thus leaving free units at the head of the
92 * queue.
93 */
94 class FUIdxQueue {
95 public:
96 /** Constructs a circular queue of FU indices. */
97 FUIdxQueue()
98 : idx(0), size(0)
99 { }
100
101 /** Adds a FU to the queue. */
102 inline void addFU(int fu_idx);
103
104 /** Returns the index of the FU at the head of the queue, and changes
105 * the index to the next element.
106 */
107 inline int getFU();
108
109 private:
110 /** Circular queue index. */
111 int idx;
112
113 /** Size of the queue. */
114 int size;
115
116 /** Queue of FU indices. */
117 std::vector<int> funcUnitsIdx;
118 };
119
120 /** Per op class queues of FUs that provide that capability. */
121 FUIdxQueue fuPerCapList[Num_OpClasses];
122
123 /** Number of FUs. */
124 int numFU;
125
126 /** Functional units. */
127 std::vector<FuncUnit *> funcUnits;
128
129 typedef std::vector<FuncUnit *>::iterator fuListIterator;
130
131 public:
132 typedef FUPoolParams Params;
133 /** Constructs a FU pool. */
134 FUPool(const Params *p);
135 ~FUPool();
136
1/*
2 * Copyright (c) 2012-2013 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 * Copyright (c) 2006 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 * Authors: Kevin Lim
41 */
42
43#ifndef __CPU_O3_FU_POOL_HH__
44#define __CPU_O3_FU_POOL_HH__
45
46#include <array>
47#include <bitset>
48#include <list>
49#include <string>
50#include <vector>
51
52#include "cpu/op_class.hh"
53#include "params/FUPool.hh"
54#include "sim/sim_object.hh"
55
56class FUDesc;
57class FuncUnit;
58
59/**
60 * Pool of FU's, specific to the new CPU model. The old FU pool had lists of
61 * free units and busy units, and whenever a FU was needed it would iterate
62 * through the free units to find a FU that provided the capability. This pool
63 * has lists of units specific to each of the capabilities, and whenever a FU
64 * is needed, it iterates through that list to find a free unit. The previous
65 * FU pool would have to be ticked each cycle to update which units became
66 * free. This FU pool lets the IEW stage handle freeing units, which frees
67 * them as their scheduled execution events complete. This limits units in this
68 * model to either have identical issue and op latencies, or 1 cycle issue
69 * latencies.
70 */
71class FUPool : public SimObject
72{
73 private:
74 /** Maximum op execution latencies, per op class. */
75 std::array<Cycles, Num_OpClasses> maxOpLatencies;
76 /** Whether op is pipelined or not. */
77 std::array<bool, Num_OpClasses> pipelined;
78
79 /** Bitvector listing capabilities of this FU pool. */
80 std::bitset<Num_OpClasses> capabilityList;
81
82 /** Bitvector listing which FUs are busy. */
83 std::vector<bool> unitBusy;
84
85 /** List of units to be freed at the end of this cycle. */
86 std::vector<int> unitsToBeFreed;
87
88 /**
89 * Class that implements a circular queue to hold FU indices. The hope is
90 * that FUs that have been just used will be moved to the end of the queue
91 * by iterating through it, thus leaving free units at the head of the
92 * queue.
93 */
94 class FUIdxQueue {
95 public:
96 /** Constructs a circular queue of FU indices. */
97 FUIdxQueue()
98 : idx(0), size(0)
99 { }
100
101 /** Adds a FU to the queue. */
102 inline void addFU(int fu_idx);
103
104 /** Returns the index of the FU at the head of the queue, and changes
105 * the index to the next element.
106 */
107 inline int getFU();
108
109 private:
110 /** Circular queue index. */
111 int idx;
112
113 /** Size of the queue. */
114 int size;
115
116 /** Queue of FU indices. */
117 std::vector<int> funcUnitsIdx;
118 };
119
120 /** Per op class queues of FUs that provide that capability. */
121 FUIdxQueue fuPerCapList[Num_OpClasses];
122
123 /** Number of FUs. */
124 int numFU;
125
126 /** Functional units. */
127 std::vector<FuncUnit *> funcUnits;
128
129 typedef std::vector<FuncUnit *>::iterator fuListIterator;
130
131 public:
132 typedef FUPoolParams Params;
133 /** Constructs a FU pool. */
134 FUPool(const Params *p);
135 ~FUPool();
136
137 static constexpr auto NoCapableFU = -2;
138 static constexpr auto NoFreeFU = -1;
137 /**
139 /**
138 * Gets a FU providing the requested capability. Will mark the unit as busy,
139 * but leaves the freeing of the unit up to the IEW stage.
140 * Gets a FU providing the requested capability. Will mark the
141 * unit as busy, but leaves the freeing of the unit up to the IEW
142 * stage.
143 *
140 * @param capability The capability requested.
144 * @param capability The capability requested.
141 * @return Returns -2 if the FU pool does not have the capability, -1 if
142 * there is no free FU, and the FU's index otherwise.
145 * @return Returns NoCapableFU if the FU pool does not have the
146 * capability, NoFreeFU if there is no free FU, and the FU's index
147 * otherwise.
143 */
144 int getUnit(OpClass capability);
145
146 /** Frees a FU at the end of this cycle. */
147 void freeUnitNextCycle(int fu_idx);
148
149 /** Frees all FUs on the list. */
150 void processFreeUnits();
151
152 /** Returns the total number of FUs. */
153 int size() { return numFU; }
154
155 /** Debugging function used to dump FU information. */
156 void dump();
157
158 /** Returns the operation execution latency of the given capability. */
159 Cycles getOpLatency(OpClass capability) {
160 return maxOpLatencies[capability];
161 }
162
163 /** Returns the issue latency of the given capability. */
164 bool isPipelined(OpClass capability) {
165 return pipelined[capability];
166 }
167
168 /** Have all the FUs drained? */
169 bool isDrained() const;
170
171 /** Takes over from another CPU's thread. */
172 void takeOverFrom() {};
173};
174
175#endif // __CPU_O3_FU_POOL_HH__
148 */
149 int getUnit(OpClass capability);
150
151 /** Frees a FU at the end of this cycle. */
152 void freeUnitNextCycle(int fu_idx);
153
154 /** Frees all FUs on the list. */
155 void processFreeUnits();
156
157 /** Returns the total number of FUs. */
158 int size() { return numFU; }
159
160 /** Debugging function used to dump FU information. */
161 void dump();
162
163 /** Returns the operation execution latency of the given capability. */
164 Cycles getOpLatency(OpClass capability) {
165 return maxOpLatencies[capability];
166 }
167
168 /** Returns the issue latency of the given capability. */
169 bool isPipelined(OpClass capability) {
170 return pipelined[capability];
171 }
172
173 /** Have all the FUs drained? */
174 bool isDrained() const;
175
176 /** Takes over from another CPU's thread. */
177 void takeOverFrom() {};
178};
179
180#endif // __CPU_O3_FU_POOL_HH__