isa.hh revision 13610
16313Sgblack@eecs.umich.edu/*
26313Sgblack@eecs.umich.edu * Copyright (c) 2009 The Regents of The University of Michigan
36313Sgblack@eecs.umich.edu * All rights reserved.
46313Sgblack@eecs.umich.edu *
56313Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
66313Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
76313Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
86313Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
96313Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
106313Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
116313Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
126313Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
136313Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
146313Sgblack@eecs.umich.edu * this software without specific prior written permission.
156313Sgblack@eecs.umich.edu *
166313Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176313Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186313Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196313Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206313Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216313Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226313Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236313Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246313Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256313Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266313Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276313Sgblack@eecs.umich.edu *
286313Sgblack@eecs.umich.edu * Authors: Gabe Black
296313Sgblack@eecs.umich.edu */
306313Sgblack@eecs.umich.edu
316313Sgblack@eecs.umich.edu#ifndef __ARCH_MIPS_ISA_HH__
326313Sgblack@eecs.umich.edu#define __ARCH_MIPS_ISA_HH__
336313Sgblack@eecs.umich.edu
348229Snate@binkert.org#include <queue>
356334Sgblack@eecs.umich.edu#include <string>
366334Sgblack@eecs.umich.edu#include <vector>
376334Sgblack@eecs.umich.edu
386334Sgblack@eecs.umich.edu#include "arch/mips/registers.hh"
396313Sgblack@eecs.umich.edu#include "arch/mips/types.hh"
4012106SRekai.GonzalezAlberquilla@arm.com#include "cpu/reg_class.hh"
416334Sgblack@eecs.umich.edu#include "sim/eventq.hh"
429384SAndreas.Sandberg@arm.com#include "sim/sim_object.hh"
436313Sgblack@eecs.umich.edu
446334Sgblack@eecs.umich.educlass BaseCPU;
456313Sgblack@eecs.umich.educlass Checkpoint;
466313Sgblack@eecs.umich.educlass EventManager;
479384SAndreas.Sandberg@arm.comstruct MipsISAParams;
486334Sgblack@eecs.umich.educlass ThreadContext;
496313Sgblack@eecs.umich.edu
506313Sgblack@eecs.umich.edunamespace MipsISA
516313Sgblack@eecs.umich.edu{
529384SAndreas.Sandberg@arm.com    class ISA : public SimObject
536313Sgblack@eecs.umich.edu    {
546334Sgblack@eecs.umich.edu      public:
556334Sgblack@eecs.umich.edu        // The MIPS name for this file is CP0 or Coprocessor 0
566334Sgblack@eecs.umich.edu        typedef ISA CP0;
576334Sgblack@eecs.umich.edu
589384SAndreas.Sandberg@arm.com        typedef MipsISAParams Params;
599384SAndreas.Sandberg@arm.com
606313Sgblack@eecs.umich.edu      protected:
618181Sksewell@umich.edu        // Number of threads and vpes an individual ISA state can handle
628181Sksewell@umich.edu        uint8_t numThreads;
638181Sksewell@umich.edu        uint8_t numVpes;
648181Sksewell@umich.edu
656334Sgblack@eecs.umich.edu        enum BankType {
666334Sgblack@eecs.umich.edu            perProcessor,
676334Sgblack@eecs.umich.edu            perThreadContext,
686334Sgblack@eecs.umich.edu            perVirtProcessor
696334Sgblack@eecs.umich.edu        };
706334Sgblack@eecs.umich.edu
716334Sgblack@eecs.umich.edu        std::vector<std::vector<MiscReg> > miscRegFile;
726334Sgblack@eecs.umich.edu        std::vector<std::vector<MiscReg> > miscRegFile_WriteMask;
736334Sgblack@eecs.umich.edu        std::vector<BankType> bankType;
746334Sgblack@eecs.umich.edu
756313Sgblack@eecs.umich.edu      public:
768181Sksewell@umich.edu        void clear();
776334Sgblack@eecs.umich.edu
788181Sksewell@umich.edu        void configCP();
796334Sgblack@eecs.umich.edu
8010698Sandreas.hansson@arm.com        unsigned getVPENum(ThreadID tid) const;
816334Sgblack@eecs.umich.edu
826334Sgblack@eecs.umich.edu        //////////////////////////////////////////////////////////
836334Sgblack@eecs.umich.edu        //
846334Sgblack@eecs.umich.edu        // READ/WRITE CP0 STATE
856334Sgblack@eecs.umich.edu        //
866334Sgblack@eecs.umich.edu        //
876334Sgblack@eecs.umich.edu        //////////////////////////////////////////////////////////
886334Sgblack@eecs.umich.edu        //@TODO: MIPS MT's register view automatically connects
896334Sgblack@eecs.umich.edu        //       Status to TCStatus depending on current thread
906334Sgblack@eecs.umich.edu        void updateCP0ReadView(int misc_reg, ThreadID tid) { }
9110698Sandreas.hansson@arm.com        MiscReg readMiscRegNoEffect(int misc_reg, ThreadID tid = 0) const;
926334Sgblack@eecs.umich.edu
936334Sgblack@eecs.umich.edu        //template <class TC>
946334Sgblack@eecs.umich.edu        MiscReg readMiscReg(int misc_reg,
956334Sgblack@eecs.umich.edu                            ThreadContext *tc, ThreadID tid = 0);
966334Sgblack@eecs.umich.edu
9713582Sgabeblack@google.com        MiscReg filterCP0Write(int misc_reg, int reg_sel, MiscReg val);
9813582Sgabeblack@google.com        void setRegMask(int misc_reg, MiscReg val, ThreadID tid = 0);
9913582Sgabeblack@google.com        void setMiscRegNoEffect(int misc_reg, MiscReg val, ThreadID tid=0);
1006334Sgblack@eecs.umich.edu
1016334Sgblack@eecs.umich.edu        //template <class TC>
10213582Sgabeblack@google.com        void setMiscReg(int misc_reg, MiscReg val,
10313582Sgabeblack@google.com                        ThreadContext *tc, ThreadID tid=0);
1046334Sgblack@eecs.umich.edu
1056334Sgblack@eecs.umich.edu        //////////////////////////////////////////////////////////
1066334Sgblack@eecs.umich.edu        //
1076334Sgblack@eecs.umich.edu        // DECLARE INTERFACE THAT WILL ALLOW A MiscRegFile (Cop0)
1086334Sgblack@eecs.umich.edu        // TO SCHEDULE EVENTS
1096334Sgblack@eecs.umich.edu        //
1106334Sgblack@eecs.umich.edu        //////////////////////////////////////////////////////////
1116334Sgblack@eecs.umich.edu
1126334Sgblack@eecs.umich.edu        // Flag that is set when CP0 state has been written to.
1136334Sgblack@eecs.umich.edu        bool cp0Updated;
1146334Sgblack@eecs.umich.edu
1156334Sgblack@eecs.umich.edu        // Enumerated List of CP0 Event Types
1166334Sgblack@eecs.umich.edu        enum CP0EventType {
1176334Sgblack@eecs.umich.edu            UpdateCP0
1186334Sgblack@eecs.umich.edu        };
1196334Sgblack@eecs.umich.edu
12012124Sspwilson2@wisc.edu        /** Process a CP0 event */
12112124Sspwilson2@wisc.edu        void processCP0Event(BaseCPU *cpu, CP0EventType);
1226334Sgblack@eecs.umich.edu
1236334Sgblack@eecs.umich.edu        // Schedule a CP0 Update Event
1249180Sandreas.hansson@arm.com        void scheduleCP0Update(BaseCPU *cpu, Cycles delay = Cycles(0));
1256334Sgblack@eecs.umich.edu
1266334Sgblack@eecs.umich.edu        // If any changes have been made, then check the state for changes
1276334Sgblack@eecs.umich.edu        // and if necessary alert the CPU
1286806Sgblack@eecs.umich.edu        void updateCPU(BaseCPU *cpu);
1296334Sgblack@eecs.umich.edu
1306334Sgblack@eecs.umich.edu        static std::string miscRegNames[NumMiscRegs];
1316334Sgblack@eecs.umich.edu
1326334Sgblack@eecs.umich.edu      public:
1339461Snilay@cs.wisc.edu        void startup(ThreadContext *tc) {}
1349461Snilay@cs.wisc.edu
1359553Sandreas.hansson@arm.com        /// Explicitly import the otherwise hidden startup
1369553Sandreas.hansson@arm.com        using SimObject::startup;
1379553Sandreas.hansson@arm.com
1389384SAndreas.Sandberg@arm.com        const Params *params() const;
1399384SAndreas.Sandberg@arm.com
1409384SAndreas.Sandberg@arm.com        ISA(Params *p);
1416313Sgblack@eecs.umich.edu
14212106SRekai.GonzalezAlberquilla@arm.com        RegId flattenRegId(const RegId& regId) const { return regId; }
14312106SRekai.GonzalezAlberquilla@arm.com
1446313Sgblack@eecs.umich.edu        int
14510035Sandreas.hansson@arm.com        flattenIntIndex(int reg) const
1466313Sgblack@eecs.umich.edu        {
1476313Sgblack@eecs.umich.edu            return reg;
1486313Sgblack@eecs.umich.edu        }
1496313Sgblack@eecs.umich.edu
1506313Sgblack@eecs.umich.edu        int
15110035Sandreas.hansson@arm.com        flattenFloatIndex(int reg) const
1526313Sgblack@eecs.umich.edu        {
1536313Sgblack@eecs.umich.edu            return reg;
1546313Sgblack@eecs.umich.edu        }
1559920Syasuko.eckert@amd.com
15612109SRekai.GonzalezAlberquilla@arm.com        int
15712109SRekai.GonzalezAlberquilla@arm.com        flattenVecIndex(int reg) const
15812109SRekai.GonzalezAlberquilla@arm.com        {
15912109SRekai.GonzalezAlberquilla@arm.com            return reg;
16012109SRekai.GonzalezAlberquilla@arm.com        }
16112109SRekai.GonzalezAlberquilla@arm.com
16212109SRekai.GonzalezAlberquilla@arm.com        int
16312109SRekai.GonzalezAlberquilla@arm.com        flattenVecElemIndex(int reg) const
16412109SRekai.GonzalezAlberquilla@arm.com        {
16512109SRekai.GonzalezAlberquilla@arm.com            return reg;
16612109SRekai.GonzalezAlberquilla@arm.com        }
16712109SRekai.GonzalezAlberquilla@arm.com
16813610Sgiacomo.gabrielli@arm.com        int
16913610Sgiacomo.gabrielli@arm.com        flattenVecPredIndex(int reg) const
17013610Sgiacomo.gabrielli@arm.com        {
17113610Sgiacomo.gabrielli@arm.com            return reg;
17213610Sgiacomo.gabrielli@arm.com        }
17313610Sgiacomo.gabrielli@arm.com
1749920Syasuko.eckert@amd.com        // dummy
1759920Syasuko.eckert@amd.com        int
17610035Sandreas.hansson@arm.com        flattenCCIndex(int reg) const
1779920Syasuko.eckert@amd.com        {
1789920Syasuko.eckert@amd.com            return reg;
1799920Syasuko.eckert@amd.com        }
18010033SAli.Saidi@ARM.com
18110033SAli.Saidi@ARM.com        int
18210035Sandreas.hansson@arm.com        flattenMiscIndex(int reg) const
18310033SAli.Saidi@ARM.com        {
18410033SAli.Saidi@ARM.com            return reg;
18510033SAli.Saidi@ARM.com        }
18610033SAli.Saidi@ARM.com
1876313Sgblack@eecs.umich.edu    };
1886313Sgblack@eecs.umich.edu}
1896313Sgblack@eecs.umich.edu
1906313Sgblack@eecs.umich.edu#endif
191