regfile.hh
来自「linux下基于c++的处理器仿真平台。具有处理器流水线」· HH 代码 · 共 639 行 · 第 1/2 页
HH
639 行
/* * Copyright (c) 2004, 2005 * The Regents of The University of Michigan * All Rights Reserved * * This code is part of the M5 simulator, developed by Nathan Binkert, * Erik Hallnor, Steve Raasch, and Steve Reinhardt, with contributions * from Ron Dreslinski, Dave Greene, Lisa Hsu, Kevin Lim, Ali Saidi, * and Andrew Schultz. * * Permission is granted to use, copy, create derivative works and * redistribute this software and such derivative works for any * purpose, so long as the copyright notice above, this grant of * permission, and the disclaimer below appear in all copies made; and * so long as the name of The University of Michigan is not used in * any advertising or publicity pertaining to the use or distribution * of this software without specific, written prior authorization. * * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION FROM THE * UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY PURPOSE, AND * WITHOUT WARRANTY BY THE UNIVERSITY OF MICHIGAN OF ANY KIND, EITHER * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. THE REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE * LIABLE FOR ANY DAMAGES, INCLUDING DIRECT, SPECIAL, INDIRECT, * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM * ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF SUCH * DAMAGES. */#ifndef __CPU_O3_CPU_REGFILE_HH__#define __CPU_O3_CPU_REGFILE_HH__// @todo: Destructor#include "arch/alpha/isa_traits.hh"#include "base/trace.hh"#include "config/full_system.hh"#include "cpu/o3/comm.hh"#if FULL_SYSTEM#include "arch/alpha/ev5.hh"#include "kern/kernel_stats.hh"using namespace EV5;#endif// This really only depends on the ISA, and not the Impl. It might be nicer// to see if I can make it depend on nothing...// Things that are in the ifdef FULL_SYSTEM are pretty dependent on the ISA,// and should go in the AlphaFullCPU.template <class Impl>class PhysRegFile{ //Note that most of the definitions of the IntReg, FloatReg, etc. exist //within the Impl/ISA class and not within this PhysRegFile class. //Will need some way to allow stuff like swap_palshadow to access the //correct registers. Might require code changes to swap_palshadow and //other execution contexts. //Will make these registers public for now, but they probably should //be private eventually with some accessor functions. public: typedef typename Impl::ISA ISA; typedef typename Impl::FullCPU FullCPU; PhysRegFile(unsigned _numPhysicalIntRegs, unsigned _numPhysicalFloatRegs); //Everything below should be pretty well identical to the normal //register file that exists within AlphaISA class. //The duplication is unfortunate but it's better than having //different ways to access certain registers. //Add these in later when everything else is in place// void serialize(std::ostream &os);// void unserialize(Checkpoint *cp, const std::string §ion); uint64_t readIntReg(PhysRegIndex reg_idx) { assert(reg_idx < numPhysicalIntRegs); DPRINTF(IEW, "RegFile: Access to int register %i, has data " "%i\n", int(reg_idx), intRegFile[reg_idx]); return intRegFile[reg_idx]; } float readFloatRegSingle(PhysRegIndex reg_idx) { // Remove the base Float reg dependency. reg_idx = reg_idx - numPhysicalIntRegs; assert(reg_idx < numPhysicalFloatRegs + numPhysicalIntRegs); DPRINTF(IEW, "RegFile: Access to float register %i as single, has " "data %8.8f\n", int(reg_idx), (float)floatRegFile[reg_idx].d); return (float)floatRegFile[reg_idx].d; } double readFloatRegDouble(PhysRegIndex reg_idx) { // Remove the base Float reg dependency. reg_idx = reg_idx - numPhysicalIntRegs; assert(reg_idx < numPhysicalFloatRegs + numPhysicalIntRegs); DPRINTF(IEW, "RegFile: Access to float register %i as double, has " " data %8.8f\n", int(reg_idx), floatRegFile[reg_idx].d); return floatRegFile[reg_idx].d; } uint64_t readFloatRegInt(PhysRegIndex reg_idx) { // Remove the base Float reg dependency. reg_idx = reg_idx - numPhysicalIntRegs; assert(reg_idx < numPhysicalFloatRegs + numPhysicalIntRegs); DPRINTF(IEW, "RegFile: Access to float register %i as int, has data " "%lli\n", int(reg_idx), floatRegFile[reg_idx].q); return floatRegFile[reg_idx].q; } void setIntReg(PhysRegIndex reg_idx, uint64_t val) { assert(reg_idx < numPhysicalIntRegs); DPRINTF(IEW, "RegFile: Setting int register %i to %lli\n", int(reg_idx), val); intRegFile[reg_idx] = val; } void setFloatRegSingle(PhysRegIndex reg_idx, float val) { // Remove the base Float reg dependency. reg_idx = reg_idx - numPhysicalIntRegs; assert(reg_idx < numPhysicalFloatRegs + numPhysicalIntRegs); DPRINTF(IEW, "RegFile: Setting float register %i to %8.8f\n", int(reg_idx), val); floatRegFile[reg_idx].d = (double)val; } void setFloatRegDouble(PhysRegIndex reg_idx, double val) { // Remove the base Float reg dependency. reg_idx = reg_idx - numPhysicalIntRegs; assert(reg_idx < numPhysicalFloatRegs + numPhysicalIntRegs); DPRINTF(IEW, "RegFile: Setting float register %i to %8.8f\n", int(reg_idx), val); floatRegFile[reg_idx].d = val; } void setFloatRegInt(PhysRegIndex reg_idx, uint64_t val) { // Remove the base Float reg dependency. reg_idx = reg_idx - numPhysicalIntRegs; assert(reg_idx < numPhysicalFloatRegs + numPhysicalIntRegs); DPRINTF(IEW, "RegFile: Setting float register %i to %lli\n", int(reg_idx), val); floatRegFile[reg_idx].q = val; } uint64_t readPC() { return pc; } void setPC(uint64_t val) { pc = val; } void setNextPC(uint64_t val) { npc = val; } //Consider leaving this stuff and below in some implementation specific //file as opposed to the general register file. Or have a derived class. uint64_t readUniq() { return miscRegs.uniq; } void setUniq(uint64_t val) { miscRegs.uniq = val; } uint64_t readFpcr() { return miscRegs.fpcr; } void setFpcr(uint64_t val) { miscRegs.fpcr = val; }#if FULL_SYSTEM uint64_t readIpr(int idx, Fault &fault); Fault setIpr(int idx, uint64_t val); InternalProcReg *getIpr() { return ipr; } int readIntrFlag() { return intrflag; } void setIntrFlag(int val) { intrflag = val; }#endif // These should be private eventually, but will be public for now // so that I can hack around the initregs issue. public: /** (signed) integer register file. */ IntReg *intRegFile; /** Floating point register file. */ FloatReg *floatRegFile; /** Miscellaneous register file. */ MiscRegFile miscRegs; /** Program counter. */ Addr pc; /** Next-cycle program counter. */ Addr npc;#if FULL_SYSTEM private: // This is ISA specifc stuff; remove it eventually once ISAImpl is used IntReg palregs[NumIntRegs]; // PAL shadow registers InternalProcReg ipr[NumInternalProcRegs]; // internal processor regs int intrflag; // interrupt flag bool pal_shadow; // using pal_shadow registers#endif private: FullCPU *cpu; public: void setCPU(FullCPU *cpu_ptr) { cpu = cpu_ptr; } unsigned numPhysicalIntRegs; unsigned numPhysicalFloatRegs;};template <class Impl>PhysRegFile<Impl>::PhysRegFile(unsigned _numPhysicalIntRegs, unsigned _numPhysicalFloatRegs) : numPhysicalIntRegs(_numPhysicalIntRegs), numPhysicalFloatRegs(_numPhysicalFloatRegs){ intRegFile = new IntReg[numPhysicalIntRegs]; floatRegFile = new FloatReg[numPhysicalFloatRegs]; memset(intRegFile, 0, sizeof(*intRegFile)); memset(floatRegFile, 0, sizeof(*floatRegFile));}#if FULL_SYSTEM//Problem: This code doesn't make sense at the RegFile level because it//needs things such as the itb and dtb. Either put it at the CPU level or//the DynInst level.template <class Impl>uint64_tPhysRegFile<Impl>::readIpr(int idx, Fault &fault){ uint64_t retval = 0; // return value, default 0 switch (idx) { case ISA::IPR_PALtemp0: case ISA::IPR_PALtemp1: case ISA::IPR_PALtemp2: case ISA::IPR_PALtemp3: case ISA::IPR_PALtemp4: case ISA::IPR_PALtemp5: case ISA::IPR_PALtemp6: case ISA::IPR_PALtemp7: case ISA::IPR_PALtemp8: case ISA::IPR_PALtemp9: case ISA::IPR_PALtemp10: case ISA::IPR_PALtemp11: case ISA::IPR_PALtemp12: case ISA::IPR_PALtemp13: case ISA::IPR_PALtemp14: case ISA::IPR_PALtemp15: case ISA::IPR_PALtemp16: case ISA::IPR_PALtemp17: case ISA::IPR_PALtemp18: case ISA::IPR_PALtemp19: case ISA::IPR_PALtemp20: case ISA::IPR_PALtemp21: case ISA::IPR_PALtemp22: case ISA::IPR_PALtemp23: case ISA::IPR_PAL_BASE: case ISA::IPR_IVPTBR: case ISA::IPR_DC_MODE: case ISA::IPR_MAF_MODE: case ISA::IPR_ISR: case ISA::IPR_EXC_ADDR: case ISA::IPR_IC_PERR_STAT: case ISA::IPR_DC_PERR_STAT: case ISA::IPR_MCSR: case ISA::IPR_ASTRR:
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?