func_unit.cc revision 12334
19913Ssteve.reinhardt@amd.com/*
29913Ssteve.reinhardt@amd.com * Copyright (c) 2002-2006 The Regents of The University of Michigan
39913Ssteve.reinhardt@amd.com * All rights reserved.
49913Ssteve.reinhardt@amd.com *
59913Ssteve.reinhardt@amd.com * Redistribution and use in source and binary forms, with or without
69913Ssteve.reinhardt@amd.com * modification, are permitted provided that the following conditions are
79913Ssteve.reinhardt@amd.com * met: redistributions of source code must retain the above copyright
89913Ssteve.reinhardt@amd.com * notice, this list of conditions and the following disclaimer;
99913Ssteve.reinhardt@amd.com * redistributions in binary form must reproduce the above copyright
109913Ssteve.reinhardt@amd.com * notice, this list of conditions and the following disclaimer in the
119913Ssteve.reinhardt@amd.com * documentation and/or other materials provided with the distribution;
129913Ssteve.reinhardt@amd.com * neither the name of the copyright holders nor the names of its
139913Ssteve.reinhardt@amd.com * contributors may be used to endorse or promote products derived from
149913Ssteve.reinhardt@amd.com * this software without specific prior written permission.
159913Ssteve.reinhardt@amd.com *
169913Ssteve.reinhardt@amd.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
179913Ssteve.reinhardt@amd.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
189913Ssteve.reinhardt@amd.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
199913Ssteve.reinhardt@amd.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
209913Ssteve.reinhardt@amd.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
219913Ssteve.reinhardt@amd.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
229913Ssteve.reinhardt@amd.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
239913Ssteve.reinhardt@amd.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
249913Ssteve.reinhardt@amd.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
259913Ssteve.reinhardt@amd.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
269913Ssteve.reinhardt@amd.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
279913Ssteve.reinhardt@amd.com *
289913Ssteve.reinhardt@amd.com * Authors: Steve Raasch
299913Ssteve.reinhardt@amd.com */
309913Ssteve.reinhardt@amd.com
319913Ssteve.reinhardt@amd.com#include "cpu/func_unit.hh"
329913Ssteve.reinhardt@amd.com
339913Ssteve.reinhardt@amd.com#include <sstream>
349913Ssteve.reinhardt@amd.com
359913Ssteve.reinhardt@amd.com#include "base/logging.hh"
369913Ssteve.reinhardt@amd.com
379913Ssteve.reinhardt@amd.comusing namespace std;
38
39
40////////////////////////////////////////////////////////////////////////////
41//
42//  The funciton unit
43//
44FuncUnit::FuncUnit()
45{
46    opLatencies.fill(0);
47    pipelined.fill(false);
48    capabilityList.reset();
49}
50
51
52//  Copy constructor
53FuncUnit::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
65void
66FuncUnit::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
77bool
78FuncUnit::provides(OpClass capability)
79{
80    return capabilityList[capability];
81}
82
83bitset<Num_OpClasses>
84FuncUnit::capabilities()
85{
86    return capabilityList;
87}
88
89unsigned &
90FuncUnit::opLatency(OpClass cap)
91{
92    return opLatencies[cap];
93}
94
95bool
96FuncUnit::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//
121OpDesc *
122OpDescParams::create()
123{
124    return new OpDesc(this);
125}
126
127//
128//  The FuDesc object
129//
130FUDesc *
131FUDescParams::create()
132{
133    return new FUDesc(this);
134}
135