func_unit.cc revision 10936:93890720a932
12SN/A/*
21762SN/A * Copyright (c) 2002-2006 The Regents of The University of Michigan
32SN/A * All rights reserved.
42SN/A *
52SN/A * Redistribution and use in source and binary forms, with or without
62SN/A * modification, are permitted provided that the following conditions are
72SN/A * met: redistributions of source code must retain the above copyright
82SN/A * notice, this list of conditions and the following disclaimer;
92SN/A * redistributions in binary form must reproduce the above copyright
102SN/A * notice, this list of conditions and the following disclaimer in the
112SN/A * documentation and/or other materials provided with the distribution;
122SN/A * neither the name of the copyright holders nor the names of its
132SN/A * contributors may be used to endorse or promote products derived from
142SN/A * this software without specific prior written permission.
152SN/A *
162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Steve Raasch
292665Ssaidi@eecs.umich.edu */
302SN/A
312SN/A#include <sstream>
324183Sgblack@eecs.umich.edu
332439SN/A#include "base/misc.hh"
348229Snate@binkert.org#include "cpu/func_unit.hh"
352680Sktlim@umich.edu
368232Snate@binkert.orgusing namespace std;
378229Snate@binkert.org
384183Sgblack@eecs.umich.edu
398784Sgblack@eecs.umich.edu////////////////////////////////////////////////////////////////////////////
404183Sgblack@eecs.umich.edu//
412SN/A//  The funciton unit
4210417Sandreas.hansson@arm.com//
432201SN/AFuncUnit::FuncUnit()
448784Sgblack@eecs.umich.edu{
458589Sgblack@eecs.umich.edu    opLatencies.fill(0);
468589Sgblack@eecs.umich.edu    pipelined.fill(false);
478589Sgblack@eecs.umich.edu    capabilityList.reset();
488589Sgblack@eecs.umich.edu}
492201SN/A
502612SN/A
5110417Sandreas.hansson@arm.com//  Copy constructor
522612SN/AFuncUnit::FuncUnit(const FuncUnit &fu)
536815SLisa.Hsu@amd.com{
542612SN/A
555004Sgblack@eecs.umich.edu    for (int i = 0; i < Num_OpClasses; ++i) {
5610417Sandreas.hansson@arm.com        opLatencies[i] = fu.opLatencies[i];
578545Ssaidi@eecs.umich.edu        pipelined[i] = fu.pipelined[i];
588545Ssaidi@eecs.umich.edu    }
598545Ssaidi@eecs.umich.edu
608545Ssaidi@eecs.umich.edu    capabilityList = fu.capabilityList;
6110417Sandreas.hansson@arm.com}
624183Sgblack@eecs.umich.edu
638589Sgblack@eecs.umich.edu
648784Sgblack@eecs.umich.eduvoid
658784Sgblack@eecs.umich.eduFuncUnit::addCapability(OpClass cap, unsigned oplat, bool pipeline)
668784Sgblack@eecs.umich.edu{
678784Sgblack@eecs.umich.edu    if (oplat == 0)
688589Sgblack@eecs.umich.edu        panic("FuncUnit:  you don't really want a zero-cycle latency do you?");
694183Sgblack@eecs.umich.edu
704434Ssaidi@eecs.umich.edu    capabilityList.set(cap);
714183Sgblack@eecs.umich.edu
725004Sgblack@eecs.umich.edu    opLatencies[cap] = oplat;
7310417Sandreas.hansson@arm.com    pipelined[cap] = pipeline;
745004Sgblack@eecs.umich.edu}
755004Sgblack@eecs.umich.edu
765004Sgblack@eecs.umich.edubool
77FuncUnit::provides(OpClass capability)
78{
79    return capabilityList[capability];
80}
81
82bitset<Num_OpClasses>
83FuncUnit::capabilities()
84{
85    return capabilityList;
86}
87
88unsigned &
89FuncUnit::opLatency(OpClass cap)
90{
91    return opLatencies[cap];
92}
93
94bool
95FuncUnit::isPipelined(OpClass capability)
96{
97    return pipelined[capability];
98}
99
100////////////////////////////////////////////////////////////////////////////
101//
102//  The SimObjects we use to get the FU information into the simulator
103//
104////////////////////////////////////////////////////////////////////////////
105
106//
107//  We use 2 objects to specify this data in the INI file:
108//    (1) OpDesc - Describes the operation class & latencies
109//                   (multiple OpDesc objects can refer to the same
110//                   operation classes)
111//    (2) FUDesc - Describes the operations available in the unit &
112//                   the number of these units
113//
114//
115
116
117//
118//  The operation-class description object
119//
120OpDesc *
121OpDescParams::create()
122{
123    return new OpDesc(this);
124}
125
126//
127//  The FuDesc object
128//
129FUDesc *
130FUDescParams::create()
131{
132    return new FUDesc(this);
133}
134