isa.hh revision 12124
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
976334Sgblack@eecs.umich.edu        MiscReg filterCP0Write(int misc_reg, int reg_sel, const MiscReg &val);
986334Sgblack@eecs.umich.edu        void setRegMask(int misc_reg, const MiscReg &val, ThreadID tid = 0);
996334Sgblack@eecs.umich.edu        void setMiscRegNoEffect(int misc_reg, const MiscReg &val,
1006334Sgblack@eecs.umich.edu                                ThreadID tid = 0);
1016334Sgblack@eecs.umich.edu
1026334Sgblack@eecs.umich.edu        //template <class TC>
1036334Sgblack@eecs.umich.edu        void setMiscReg(int misc_reg, const MiscReg &val,
1046334Sgblack@eecs.umich.edu                        ThreadContext *tc, ThreadID tid = 0);
1056334Sgblack@eecs.umich.edu
1066334Sgblack@eecs.umich.edu        //////////////////////////////////////////////////////////
1076334Sgblack@eecs.umich.edu        //
1086334Sgblack@eecs.umich.edu        // DECLARE INTERFACE THAT WILL ALLOW A MiscRegFile (Cop0)
1096334Sgblack@eecs.umich.edu        // TO SCHEDULE EVENTS
1106334Sgblack@eecs.umich.edu        //
1116334Sgblack@eecs.umich.edu        //////////////////////////////////////////////////////////
1126334Sgblack@eecs.umich.edu
1136334Sgblack@eecs.umich.edu        // Flag that is set when CP0 state has been written to.
1146334Sgblack@eecs.umich.edu        bool cp0Updated;
1156334Sgblack@eecs.umich.edu
1166334Sgblack@eecs.umich.edu        // Enumerated List of CP0 Event Types
1176334Sgblack@eecs.umich.edu        enum CP0EventType {
1186334Sgblack@eecs.umich.edu            UpdateCP0
1196334Sgblack@eecs.umich.edu        };
1206334Sgblack@eecs.umich.edu
12112124Sspwilson2@wisc.edu        /** Process a CP0 event */
12212124Sspwilson2@wisc.edu        void processCP0Event(BaseCPU *cpu, CP0EventType);
1236334Sgblack@eecs.umich.edu
1246334Sgblack@eecs.umich.edu        // Schedule a CP0 Update Event
1259180Sandreas.hansson@arm.com        void scheduleCP0Update(BaseCPU *cpu, Cycles delay = Cycles(0));
1266334Sgblack@eecs.umich.edu
1276334Sgblack@eecs.umich.edu        // If any changes have been made, then check the state for changes
1286334Sgblack@eecs.umich.edu        // and if necessary alert the CPU
1296806Sgblack@eecs.umich.edu        void updateCPU(BaseCPU *cpu);
1306334Sgblack@eecs.umich.edu
1316334Sgblack@eecs.umich.edu        static std::string miscRegNames[NumMiscRegs];
1326334Sgblack@eecs.umich.edu
1336334Sgblack@eecs.umich.edu      public:
1349461Snilay@cs.wisc.edu        void startup(ThreadContext *tc) {}
1359461Snilay@cs.wisc.edu
1369553Sandreas.hansson@arm.com        /// Explicitly import the otherwise hidden startup
1379553Sandreas.hansson@arm.com        using SimObject::startup;
1389553Sandreas.hansson@arm.com
1399384SAndreas.Sandberg@arm.com        const Params *params() const;
1409384SAndreas.Sandberg@arm.com
1419384SAndreas.Sandberg@arm.com        ISA(Params *p);
1426313Sgblack@eecs.umich.edu
14312106SRekai.GonzalezAlberquilla@arm.com        RegId flattenRegId(const RegId& regId) const { return regId; }
14412106SRekai.GonzalezAlberquilla@arm.com
1456313Sgblack@eecs.umich.edu        int
14610035Sandreas.hansson@arm.com        flattenIntIndex(int reg) const
1476313Sgblack@eecs.umich.edu        {
1486313Sgblack@eecs.umich.edu            return reg;
1496313Sgblack@eecs.umich.edu        }
1506313Sgblack@eecs.umich.edu
1516313Sgblack@eecs.umich.edu        int
15210035Sandreas.hansson@arm.com        flattenFloatIndex(int reg) const
1536313Sgblack@eecs.umich.edu        {
1546313Sgblack@eecs.umich.edu            return reg;
1556313Sgblack@eecs.umich.edu        }
1569920Syasuko.eckert@amd.com
15712109SRekai.GonzalezAlberquilla@arm.com        int
15812109SRekai.GonzalezAlberquilla@arm.com        flattenVecIndex(int reg) const
15912109SRekai.GonzalezAlberquilla@arm.com        {
16012109SRekai.GonzalezAlberquilla@arm.com            return reg;
16112109SRekai.GonzalezAlberquilla@arm.com        }
16212109SRekai.GonzalezAlberquilla@arm.com
16312109SRekai.GonzalezAlberquilla@arm.com        int
16412109SRekai.GonzalezAlberquilla@arm.com        flattenVecElemIndex(int reg) const
16512109SRekai.GonzalezAlberquilla@arm.com        {
16612109SRekai.GonzalezAlberquilla@arm.com            return reg;
16712109SRekai.GonzalezAlberquilla@arm.com        }
16812109SRekai.GonzalezAlberquilla@arm.com
1699920Syasuko.eckert@amd.com        // dummy
1709920Syasuko.eckert@amd.com        int
17110035Sandreas.hansson@arm.com        flattenCCIndex(int reg) const
1729920Syasuko.eckert@amd.com        {
1739920Syasuko.eckert@amd.com            return reg;
1749920Syasuko.eckert@amd.com        }
17510033SAli.Saidi@ARM.com
17610033SAli.Saidi@ARM.com        int
17710035Sandreas.hansson@arm.com        flattenMiscIndex(int reg) const
17810033SAli.Saidi@ARM.com        {
17910033SAli.Saidi@ARM.com            return reg;
18010033SAli.Saidi@ARM.com        }
18110033SAli.Saidi@ARM.com
1826313Sgblack@eecs.umich.edu    };
1836313Sgblack@eecs.umich.edu}
1846313Sgblack@eecs.umich.edu
1856313Sgblack@eecs.umich.edu#endif
186