func_unit.cc revision 11793
16145Snate@binkert.org/*
26145Snate@binkert.org * Copyright (c) 2002-2006 The Regents of The University of Michigan
36145Snate@binkert.org * All rights reserved.
46145Snate@binkert.org *
56145Snate@binkert.org * Redistribution and use in source and binary forms, with or without
66145Snate@binkert.org * modification, are permitted provided that the following conditions are
76145Snate@binkert.org * met: redistributions of source code must retain the above copyright
86145Snate@binkert.org * notice, this list of conditions and the following disclaimer;
96145Snate@binkert.org * redistributions in binary form must reproduce the above copyright
106145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
116145Snate@binkert.org * documentation and/or other materials provided with the distribution;
126145Snate@binkert.org * neither the name of the copyright holders nor the names of its
136145Snate@binkert.org * contributors may be used to endorse or promote products derived from
146145Snate@binkert.org * this software without specific prior written permission.
156145Snate@binkert.org *
166145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276145Snate@binkert.org *
286145Snate@binkert.org * Authors: Steve Raasch
298229Snate@binkert.org */
307056Snate@binkert.org
318615Snilay@cs.wisc.edu#include "cpu/func_unit.hh"
328615Snilay@cs.wisc.edu
338615Snilay@cs.wisc.edu#include <sstream>
348615Snilay@cs.wisc.edu
357632SBrad.Beckmann@amd.com#include "base/misc.hh"
368232Snate@binkert.org
378232Snate@binkert.orgusing namespace std;
388615Snilay@cs.wisc.edu
399104Shestness@cs.utexas.edu
408615Snilay@cs.wisc.edu////////////////////////////////////////////////////////////////////////////
418615Snilay@cs.wisc.edu//
427039Snate@binkert.org//  The funciton unit
437039Snate@binkert.org//
448229Snate@binkert.orgFuncUnit::FuncUnit()
456154Snate@binkert.org{
466154Snate@binkert.org    opLatencies.fill(0);
477550SBrad.Beckmann@amd.com    pipelined.fill(false);
486876Ssteve.reinhardt@amd.com    capabilityList.reset();
497055Snate@binkert.org}
507055Snate@binkert.org
516876Ssteve.reinhardt@amd.com
526876Ssteve.reinhardt@amd.com//  Copy constructor
536285Snate@binkert.orgFuncUnit::FuncUnit(const FuncUnit &fu)
546876Ssteve.reinhardt@amd.com{
556285Snate@binkert.org
567039Snate@binkert.org    for (int i = 0; i < Num_OpClasses; ++i) {
576876Ssteve.reinhardt@amd.com        opLatencies[i] = fu.opLatencies[i];
5810012Snilay@cs.wisc.edu        pipelined[i] = fu.pipelined[i];
596876Ssteve.reinhardt@amd.com    }
606876Ssteve.reinhardt@amd.com
616285Snate@binkert.org    capabilityList = fu.capabilityList;
626876Ssteve.reinhardt@amd.com}
636876Ssteve.reinhardt@amd.com
646876Ssteve.reinhardt@amd.com
656876Ssteve.reinhardt@amd.comvoid
666899SBrad.Beckmann@amd.comFuncUnit::addCapability(OpClass cap, unsigned oplat, bool pipeline)
676876Ssteve.reinhardt@amd.com{
686876Ssteve.reinhardt@amd.com    if (oplat == 0)
696876Ssteve.reinhardt@amd.com        panic("FuncUnit:  you don't really want a zero-cycle latency do you?");
706876Ssteve.reinhardt@amd.com
718171Stushar@csail.mit.edu    capabilityList.set(cap);
728171Stushar@csail.mit.edu
736145Snate@binkert.org    opLatencies[cap] = oplat;
746145Snate@binkert.org    pipelined[cap] = pipeline;
757039Snate@binkert.org}
767039Snate@binkert.org
776145Snate@binkert.orgbool
786145Snate@binkert.orgFuncUnit::provides(OpClass capability)
797039Snate@binkert.org{
807039Snate@binkert.org    return capabilityList[capability];
817039Snate@binkert.org}
829342SAndreas.Sandberg@arm.com
839245Shestness@cs.wisc.edubitset<Num_OpClasses>
847039Snate@binkert.orgFuncUnit::capabilities()
859501Snilay@cs.wisc.edu{
866145Snate@binkert.org    return capabilityList;
877039Snate@binkert.org}
887039Snate@binkert.org
896285Snate@binkert.orgunsigned &
907455Snate@binkert.orgFuncUnit::opLatency(OpClass cap)
917455Snate@binkert.org{
927455Snate@binkert.org    return opLatencies[cap];
937455Snate@binkert.org}
947455Snate@binkert.org
957455Snate@binkert.orgbool
967455Snate@binkert.orgFuncUnit::isPipelined(OpClass capability)
977805Snilay@cs.wisc.edu{
987921SBrad.Beckmann@amd.com    return pipelined[capability];
997805Snilay@cs.wisc.edu}
1008615Snilay@cs.wisc.edu
1019467Smalek.musleh@gmail.com////////////////////////////////////////////////////////////////////////////
1029467Smalek.musleh@gmail.com//
1036145Snate@binkert.org//  The SimObjects we use to get the FU information into the simulator
1046145Snate@binkert.org//
1057455Snate@binkert.org////////////////////////////////////////////////////////////////////////////
1067455Snate@binkert.org
1077455Snate@binkert.org//
1087455Snate@binkert.org//  We use 2 objects to specify this data in the INI file:
1097455Snate@binkert.org//    (1) OpDesc - Describes the operation class & latencies
1107455Snate@binkert.org//                   (multiple OpDesc objects can refer to the same
1117455Snate@binkert.org//                   operation classes)
1127805Snilay@cs.wisc.edu//    (2) FUDesc - Describes the operations available in the unit &
1137921SBrad.Beckmann@amd.com//                   the number of these units
1147805Snilay@cs.wisc.edu//
1158615Snilay@cs.wisc.edu//
1169467Smalek.musleh@gmail.com
1179467Smalek.musleh@gmail.com
1186145Snate@binkert.org//
1196285Snate@binkert.org//  The operation-class description object
1207039Snate@binkert.org//
1217039Snate@binkert.orgOpDesc *
1226145Snate@binkert.orgOpDescParams::create()
1237039Snate@binkert.org{
1247039Snate@binkert.org    return new OpDesc(this);
1257039Snate@binkert.org}
1267039Snate@binkert.org
1279465Snilay@cs.wisc.edu//
1287039Snate@binkert.org//  The FuDesc object
1296145Snate@binkert.org//
1306145Snate@binkert.orgFUDesc *
13110012Snilay@cs.wisc.eduFUDescParams::create()
1329598Snilay@cs.wisc.edu{
13310012Snilay@cs.wisc.edu    return new FUDesc(this);
13410012Snilay@cs.wisc.edu}
13510012Snilay@cs.wisc.edu