scons: Group Source-s based on what SConscript included them.
[gem5.git] / src / cpu / func_unit.cc
1 /*
2 * Copyright (c) 2002-2006 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Steve Raasch
29 */
30
31 #include "cpu/func_unit.hh"
32
33 #include <sstream>
34
35 #include "base/misc.hh"
36
37 using namespace std;
38
39
40 ////////////////////////////////////////////////////////////////////////////
41 //
42 // The funciton unit
43 //
44 FuncUnit::FuncUnit()
45 {
46 opLatencies.fill(0);
47 pipelined.fill(false);
48 capabilityList.reset();
49 }
50
51
52 // Copy constructor
53 FuncUnit::FuncUnit(const FuncUnit &fu)
54 {
55
56 for (int i = 0; i < Num_OpClasses; ++i) {
57 opLatencies[i] = fu.opLatencies[i];
58 pipelined[i] = fu.pipelined[i];
59 }
60
61 capabilityList = fu.capabilityList;
62 }
63
64
65 void
66 FuncUnit::addCapability(OpClass cap, unsigned oplat, bool pipeline)
67 {
68 if (oplat == 0)
69 panic("FuncUnit: you don't really want a zero-cycle latency do you?");
70
71 capabilityList.set(cap);
72
73 opLatencies[cap] = oplat;
74 pipelined[cap] = pipeline;
75 }
76
77 bool
78 FuncUnit::provides(OpClass capability)
79 {
80 return capabilityList[capability];
81 }
82
83 bitset<Num_OpClasses>
84 FuncUnit::capabilities()
85 {
86 return capabilityList;
87 }
88
89 unsigned &
90 FuncUnit::opLatency(OpClass cap)
91 {
92 return opLatencies[cap];
93 }
94
95 bool
96 FuncUnit::isPipelined(OpClass capability)
97 {
98 return pipelined[capability];
99 }
100
101 ////////////////////////////////////////////////////////////////////////////
102 //
103 // The SimObjects we use to get the FU information into the simulator
104 //
105 ////////////////////////////////////////////////////////////////////////////
106
107 //
108 // We use 2 objects to specify this data in the INI file:
109 // (1) OpDesc - Describes the operation class & latencies
110 // (multiple OpDesc objects can refer to the same
111 // operation classes)
112 // (2) FUDesc - Describes the operations available in the unit &
113 // the number of these units
114 //
115 //
116
117
118 //
119 // The operation-class description object
120 //
121 OpDesc *
122 OpDescParams::create()
123 {
124 return new OpDesc(this);
125 }
126
127 //
128 // The FuDesc object
129 //
130 FUDesc *
131 FUDescParams::create()
132 {
133 return new FUDesc(this);
134 }