3 // Copyright
\eN) 2007 MIPS Technologies, Inc. All Rights Reserved
5 // This software is part of the M5 simulator.
7 // THIS IS A LEGAL AGREEMENT. BY DOWNLOADING, USING, COPYING, CREATING
8 // DERIVATIVE WORKS, AND/OR DISTRIBUTING THIS SOFTWARE YOU ARE AGREEING
9 // TO THESE TERMS AND CONDITIONS.
11 // Permission is granted to use, copy, create derivative works and
12 // distribute this software and such derivative works for any purpose,
13 // so long as (1) the copyright notice above, this grant of permission,
14 // and the disclaimer below appear in all copies and derivative works
15 // made, (2) the copyright notice above is augmented as appropriate to
16 // reflect the addition of any new copyrightable work in a derivative
17 // work (e.g., Copyright
\eN) <Publication Year> Copyright Owner), and (3)
18 // the name of MIPS Technologies, Inc. (
\e$(B!H
\e(BMIPS
\e$(B!I
\e(B) is not used in any
19 // advertising or publicity pertaining to the use or distribution of
20 // this software without specific, written prior authorization.
22 // THIS SOFTWARE IS PROVIDED
\e$(B!H
\e(BAS IS.
\e$(B!I
\e(B MIPS MAKES NO WARRANTIES AND
23 // DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, STATUTORY, IMPLIED OR
24 // OTHERWISE, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
26 // NON-INFRINGEMENT OF THIRD PARTY RIGHTS, REGARDING THIS SOFTWARE.
27 // IN NO EVENT SHALL MIPS BE LIABLE FOR ANY DAMAGES, INCLUDING DIRECT,
28 // INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL, OR PUNITIVE DAMAGES OF
29 // ANY KIND OR NATURE, ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT,
30 // THIS SOFTWARE AND/OR THE USE OF THIS SOFTWARE, WHETHER SUCH LIABILITY
31 // IS ASSERTED ON THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE OR
32 // STRICT LIABILITY), OR OTHERWISE, EVEN IF MIPS HAS BEEN WARNED OF THE
33 // POSSIBILITY OF ANY SUCH LOSS OR DAMAGE IN ADVANCE.
35 //Authors: Korey L. Sewell
38 ////////////////////////////////////////////////////////////////////
40 // DSP integer operate instructions
46 * Base class for integer operations.
48 class DspIntOp : public MipsStaticInst
53 DspIntOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
54 MipsStaticInst(mnem, _machInst, __opClass)
59 class DspHiLoOp : public MipsStaticInst
64 DspHiLoOp(const char *mnem, MachInst _machInst, OpClass __opClass) :
65 MipsStaticInst(mnem, _machInst, __opClass)
71 // Dsp instruction class execute method template.
72 def template DspExecute {{
73 Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
75 Fault fault = NoFault;
88 fault = new DspStateDisabledFault();
93 fault = new ReservedInstructionFault();
104 // DspHiLo instruction class execute method template.
105 def template DspHiLoExecute {{
106 Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
108 Fault fault = NoFault;
112 if (isDspPresent(xc))
114 if (isDspEnabled(xc))
121 fault = new DspStateDisabledFault();
126 fault = new ReservedInstructionFault();
132 //If there are 2 Destination Registers then
133 //concatenate the values for the traceData
134 if(traceData && _numDestRegs == 2) {
135 // FIXME - set the trace value correctly here
136 //uint64_t hilo_final_val = (uint64_t)HI_RD_SEL << 32 | LO_RD_SEL;
137 //traceData->setData(hilo_final_val);
144 //Outputs to decoder.cc
149 bool isDspEnabled(%(CPU_exec_context)s *xc)
152 if( bits( xc->readMiscReg(MipsISA::Status), 24, 24 ) == 0 )
155 //printf("Syscall Emulation Mode: isDspEnabled() check defaults to TRUE\n");
162 bool isDspPresent(%(CPU_exec_context)s *xc)
165 if( bits( xc->readMiscReg(MipsISA::Config3), 10, 10 ) == 0 )
168 //printf("Syscall Emulation Mode: isDspPresent() check defaults to TRUE\n");
174 // add code to fetch the DSPControl register
175 // and write it back after execution, giving
176 // the instruction the opportunity to modify
178 def format DspIntOp(code, *opt_flags) {{
180 decl_code = 'uint32_t dspctl;\n'
181 decl_code += 'dspctl = DSPControl;\n'
183 write_code = 'DSPControl = dspctl;\n'
185 code = decl_code + code + write_code
187 opt_flags += ('IsDspOp',)
189 iop = InstObjParams(name, Name, 'DspIntOp', code, opt_flags)
190 header_output = BasicDeclare.subst(iop)
191 decoder_output = BasicConstructor.subst(iop)
192 decode_block = BasicDecode.subst(iop)
193 exec_output = DspExecute.subst(iop)
196 // add code to fetch the DSPControl register
197 // and write it back after execution, giving
198 // the instruction the opportunity to modify
199 // it if necessary; also, fetch the appropriate
200 // HI/LO register pair, based on the AC
201 // instruction field.
203 def format DspHiLoOp(code, *opt_flags) {{
205 decl_code = 'int64_t dspac;\n'
206 decl_code += 'uint32_t dspctl;\n'
208 fetch_code = 'dspctl = DSPControl;\n'
209 fetch_code += 'dspac = HI_RD_SEL;\n'
210 fetch_code += 'dspac = dspac << 32 | LO_RD_SEL;\n'
212 write_code = 'DSPControl = dspctl;\n'
213 write_code += 'HI_RD_SEL = dspac<63:32>;\n'
214 write_code += 'LO_RD_SEL = dspac<31:0>;\n'
216 code = decl_code + fetch_code + code + write_code
218 opt_flags += ('IsDspOp',)
220 iop = InstObjParams(name, Name, 'DspHiLoOp', code, opt_flags)
221 header_output = BasicDeclare.subst(iop)
222 decoder_output = BasicConstructor.subst(iop)
223 decode_block = BasicDecode.subst(iop)
224 exec_output = DspHiLoExecute.subst(iop)