2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * Copyright (c) 2007 MIPS Technologies, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef __ARCH_MIPS_REGFILE_REGFILE_HH__
35 #define __ARCH_MIPS_REGFILE_REGFILE_HH__
37 #include "arch/mips/types.hh"
38 #include "arch/mips/isa_traits.hh"
39 #include "arch/mips/mt.hh"
40 #include "arch/mips/regfile/int_regfile.hh"
41 #include "arch/mips/regfile/float_regfile.hh"
42 #include "arch/mips/regfile/misc_regfile.hh"
43 #include "sim/faults.hh"
48 using namespace MipsISA
;
57 void RegFile::reset(std::string core_name
, unsigned num_threads
, unsigned num_vpes
)
59 bzero(&intRegFile
, sizeof(intRegFile
));
60 bzero(&floatRegFile
, sizeof(floatRegFile
));
61 miscRegFile
.reset(core_name
, num_threads
, num_vpes
);
64 IntReg
RegFile::readIntReg(int intReg
)
66 return intRegFile
.readReg(intReg
);
69 Fault
RegFile::setIntReg(int intReg
, const IntReg
&val
)
71 return intRegFile
.setReg(intReg
, val
);
74 MiscReg
RegFile::readMiscRegNoEffect(int miscReg
, unsigned tid
= 0)
76 return miscRegFile
.readRegNoEffect(miscReg
, tid
);
79 MiscReg
RegFile::readMiscReg(int miscReg
, ThreadContext
*tc
,
82 return miscRegFile
.readReg(miscReg
, tc
, tid
);
85 void RegFile::setMiscRegNoEffect(int miscReg
, const MiscReg
&val
, unsigned tid
= 0)
87 miscRegFile
.setRegNoEffect(miscReg
, val
, tid
);
90 void RegFile::setMiscReg(int miscReg
, const MiscReg
&val
,
91 ThreadContext
* tc
, unsigned tid
= 0)
93 miscRegFile
.setReg(miscReg
, val
, tc
, tid
);
96 FloatRegVal
RegFile::readFloatReg(int floatReg
)
98 return floatRegFile
.readReg(floatReg
,SingleWidth
);
101 FloatRegVal
RegFile::readFloatReg(int floatReg
, int width
)
103 return floatRegFile
.readReg(floatReg
,width
);
106 FloatRegBits
RegFile::readFloatRegBits(int floatReg
)
108 return floatRegFile
.readRegBits(floatReg
,SingleWidth
);
111 FloatRegBits
RegFile::readFloatRegBits(int floatReg
, int width
)
113 return floatRegFile
.readRegBits(floatReg
,width
);
116 Fault
RegFile::setFloatReg(int floatReg
, const FloatRegVal
&val
)
118 return floatRegFile
.setReg(floatReg
, val
, SingleWidth
);
121 Fault
RegFile::setFloatReg(int floatReg
, const FloatRegVal
&val
, int width
)
123 return floatRegFile
.setReg(floatReg
, val
, width
);
126 Fault
RegFile::setFloatRegBits(int floatReg
, const FloatRegBits
&val
)
128 return floatRegFile
.setRegBits(floatReg
, val
, SingleWidth
);
131 Fault
RegFile::setFloatRegBits(int floatReg
, const FloatRegBits
&val
, int width
)
133 return floatRegFile
.setRegBits(floatReg
, val
, width
);
136 Addr
RegFile::readPC()
141 void RegFile::setPC(Addr val
)
146 Addr
RegFile::readNextPC()
151 void RegFile::setNextPC(Addr val
)
156 Addr
RegFile::readNextNPC()
161 void RegFile::setNextNPC(Addr val
)
167 RegFile::serialize(std::ostream
&os
)
169 intRegFile
.serialize(os
);
170 floatRegFile
.serialize(os
);
171 miscRegFile
.serialize(os
);
173 SERIALIZE_SCALAR(pc
);
174 SERIALIZE_SCALAR(npc
);
175 SERIALIZE_SCALAR(nnpc
);
180 RegFile::unserialize(Checkpoint
*cp
, const std::string
§ion
)
182 intRegFile
.unserialize(cp
, section
);
183 floatRegFile
.unserialize(cp
, section
);
184 miscRegFile
.unserialize(cp
, section
);
185 UNSERIALIZE_SCALAR(pc
);
186 UNSERIALIZE_SCALAR(npc
);
187 UNSERIALIZE_SCALAR(nnpc
);
191 static inline int flattenIntIndex(ThreadContext
* tc
, int reg
)
197 MipsISA::copyRegs(ThreadContext
*src
, ThreadContext
*dest
)
199 panic("Copy Regs Not Implemented Yet\n");
203 MipsISA::copyMiscRegs(ThreadContext
*src
, ThreadContext
*dest
)
205 panic("Copy Misc. Regs Not Implemented Yet\n");