gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
func_unit.cc
Go to the documentation of this file.
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 
41 //
42 // The funciton unit
43 //
45 {
46  opLatencies.fill(0);
47  pipelined.fill(false);
48  capabilityList.reset();
49 }
50 
51 
52 // Copy constructor
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>
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 
102 //
103 // The SimObjects we use to get the FU information into the simulator
104 //
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 }
std::array< bool, Num_OpClasses > pipelined
Definition: func_unit.hh:89
Bitfield< 7 > i
Definition: miscregs.hh:1378
#define panic(...)
Definition: misc.hh:153
void addCapability(OpClass cap, unsigned oplat, bool pipelined)
Definition: func_unit.cc:66
std::bitset< Num_OpClasses > capabilities()
Definition: func_unit.cc:84
bool isPipelined(OpClass capability)
Definition: func_unit.cc:96
bool provides(OpClass capability)
Definition: func_unit.cc:78
FuncUnit()
Definition: func_unit.cc:44
std::bitset< Num_OpClasses > capabilityList
Definition: func_unit.hh:90
Bitfield< 12 > fu
Definition: miscregs.hh:84
static const OpClass Num_OpClasses
Definition: op_class.hh:92
unsigned & opLatency(OpClass capability)
Definition: func_unit.cc:90
std::array< unsigned, Num_OpClasses > opLatencies
Definition: func_unit.hh:88

Generated on Fri Jun 9 2017 13:03:42 for gem5 by doxygen 1.8.6