util.isa revision 2239
12SN/A// -*- mode:c++ -*-
21762SN/A
32SN/Alet {{
42SN/Adef LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
52SN/A                  postacc_code = '', base_class = 'Memory',
62SN/A                  decode_template = BasicDecode, exec_template_base = ''):
72SN/A    # Make sure flags are in lists (convert to lists if not).
82SN/A    mem_flags = makeList(mem_flags)
92SN/A    inst_flags = makeList(inst_flags)
102SN/A
112SN/A    # add hook to get effective addresses into execution trace output.
122SN/A    ea_code += '\nif (traceData) { traceData->setAddr(EA); }\n'
132SN/A
142SN/A    # generate code block objects
152SN/A    ea_cblk = CodeBlock(ea_code)
162SN/A    memacc_cblk = CodeBlock(memacc_code)
172SN/A    postacc_cblk = CodeBlock(postacc_code)
182SN/A
192SN/A    # Some CPU models execute the memory operation as an atomic unit,
202SN/A    # while others want to separate them into an effective address
212SN/A    # computation and a memory access operation.  As a result, we need
222SN/A    # to generate three StaticInst objects.  Note that the latter two
232SN/A    # are nested inside the larger "atomic" one.
242SN/A
252SN/A    # generate InstObjParams for EAComp object
262SN/A    ea_iop = InstObjParams(name, Name, base_class, ea_cblk, inst_flags)
272665Ssaidi@eecs.umich.edu
282665Ssaidi@eecs.umich.edu    # generate InstObjParams for MemAcc object
292665Ssaidi@eecs.umich.edu    memacc_iop = InstObjParams(name, Name, base_class, memacc_cblk, inst_flags)
302665Ssaidi@eecs.umich.edu    # in the split execution model, the MemAcc portion is responsible
312SN/A    # for the post-access code.
322SN/A    memacc_iop.postacc_code = postacc_cblk.code
332SN/A
342SN/A    # generate InstObjParams for InitiateAcc, CompleteAcc object
352SN/A    # The code used depends on the template being used
362SN/A    if (exec_template_base == 'Load'):
373971Sgblack@eecs.umich.edu        initiateacc_cblk = CodeBlock(ea_code + memacc_code)
3856SN/A        completeacc_cblk = CodeBlock(memacc_code + postacc_code)
3956SN/A    elif (exec_template_base == 'Store'):
401158SN/A        initiateacc_cblk = CodeBlock(ea_code + memacc_code)
41146SN/A        completeacc_cblk = CodeBlock(postacc_code)
421858SN/A    else:
432680Sktlim@umich.edu        initiateacc_cblk = ''
442378SN/A        completeacc_cblk = ''
452522SN/A
462401SN/A    initiateacc_iop = InstObjParams(name, Name, base_class, initiateacc_cblk,
475154Sgblack@eecs.umich.edu                                    inst_flags)
484762Snate@binkert.org
495512SMichael.Adler@intel.com    completeacc_iop = InstObjParams(name, Name, base_class, completeacc_cblk,
50360SN/A                                    inst_flags)
514434Ssaidi@eecs.umich.edu
52695SN/A    if (exec_template_base == 'Load'):
532093SN/A        initiateacc_iop.ea_code = ea_cblk.code
542378SN/A        initiateacc_iop.memacc_code = memacc_cblk.code
552SN/A        completeacc_iop.memacc_code = memacc_cblk.code
562715Sstever@eecs.umich.edu        completeacc_iop.postacc_code = postacc_cblk.code
572715Sstever@eecs.umich.edu    elif (exec_template_base == 'Store'):
582715Sstever@eecs.umich.edu        initiateacc_iop.ea_code = ea_cblk.code
592715Sstever@eecs.umich.edu        initiateacc_iop.memacc_code = memacc_cblk.code
602715Sstever@eecs.umich.edu        completeacc_iop.postacc_code = postacc_cblk.code
612715Sstever@eecs.umich.edu
622715Sstever@eecs.umich.edu    # generate InstObjParams for unified execution
632715Sstever@eecs.umich.edu    cblk = CodeBlock(ea_code + memacc_code + postacc_code)
642715Sstever@eecs.umich.edu    iop = InstObjParams(name, Name, base_class, cblk, inst_flags)
655335Shines@cs.fsu.edu
665335Shines@cs.fsu.edu    iop.ea_constructor = ea_cblk.constructor
674157Sgblack@eecs.umich.edu    iop.ea_code = ea_cblk.code
684166Sgblack@eecs.umich.edu    iop.memacc_constructor = memacc_cblk.constructor
692715Sstever@eecs.umich.edu    iop.memacc_code = memacc_cblk.code
702715Sstever@eecs.umich.edu    iop.postacc_code = postacc_cblk.code
712715Sstever@eecs.umich.edu
722715Sstever@eecs.umich.edu    if mem_flags:
732715Sstever@eecs.umich.edu        s = '\n\tmemAccessFlags = ' + string.join(mem_flags, '|') + ';'
742SN/A        iop.constructor += s
752107SN/A        memacc_iop.constructor += s
762SN/A
772SN/A    # select templates
782SN/A    memAccExecTemplate = eval(exec_template_base + 'MemAccExecute')
792SN/A    fullExecTemplate = eval(exec_template_base + 'Execute')
802SN/A    initiateAccTemplate = eval(exec_template_base + 'InitiateAcc')
812SN/A    completeAccTemplate = eval(exec_template_base + 'CompleteAcc')
821858SN/A
83360SN/A    # (header_output, decoder_output, decode_block, exec_output)
842SN/A    return (LoadStoreDeclare.subst(iop), LoadStoreConstructor.subst(iop),
852SN/A            decode_template.subst(iop),
862SN/A            EACompExecute.subst(ea_iop)
872SN/A            + memAccExecTemplate.subst(memacc_iop)
882SN/A            + fullExecTemplate.subst(iop)
895154Sgblack@eecs.umich.edu            + initiateAccTemplate.subst(initiateacc_iop)
905183Ssaidi@eecs.umich.edu            + completeAccTemplate.subst(completeacc_iop))
915154Sgblack@eecs.umich.edu}};
922SN/A
935154Sgblack@eecs.umich.edu
945154Sgblack@eecs.umich.eduoutput exec {{
955154Sgblack@eecs.umich.edu
965154Sgblack@eecs.umich.eduusing namespace MipsISA;
975154Sgblack@eecs.umich.edu
985154Sgblack@eecs.umich.edu
995154Sgblack@eecs.umich.edu    /// CLEAR ALL CPU INST/EXE HAZARDS
1005154Sgblack@eecs.umich.edu    inline void
1015154Sgblack@eecs.umich.edu    clear_exe_inst_hazards()
1025154Sgblack@eecs.umich.edu    {
1035154Sgblack@eecs.umich.edu        //CODE HERE
1045154Sgblack@eecs.umich.edu    }
1055154Sgblack@eecs.umich.edu
1065154Sgblack@eecs.umich.edu
1075154Sgblack@eecs.umich.edu    /// Check "FP enabled" machine status bit.  Called when executing any FP
1085154Sgblack@eecs.umich.edu    /// instruction in full-system mode.
1095154Sgblack@eecs.umich.edu    /// @retval Full-system mode: NoFault if FP is enabled, FenFault
1105154Sgblack@eecs.umich.edu    /// if not.  Non-full-system mode: always returns NoFault.
1115154Sgblack@eecs.umich.edu#if FULL_SYSTEM
1125154Sgblack@eecs.umich.edu    inline Fault checkFpEnableFault(%(CPU_exec_context)s *xc)
1135154Sgblack@eecs.umich.edu    {
1145154Sgblack@eecs.umich.edu        Fault fault = NoFault;	// dummy... this ipr access should not fault
1155154Sgblack@eecs.umich.edu        if (!Mips34k::ICSR_FPE(xc->readIpr(MipsISA::IPR_ICSR, fault))) {
1165154Sgblack@eecs.umich.edu            fault = FloatEnableFault;
1174997Sgblack@eecs.umich.edu        }
1182SN/A        return fault;
1195282Srstrong@cs.ucsd.edu    }
1205282Srstrong@cs.ucsd.edu#else
1215282Srstrong@cs.ucsd.edu    inline Fault checkFpEnableFault(%(CPU_exec_context)s *xc)
1225282Srstrong@cs.ucsd.edu    {
1235282Srstrong@cs.ucsd.edu        return NoFault;
1245282Srstrong@cs.ucsd.edu    }
1255282Srstrong@cs.ucsd.edu#endif
1265282Srstrong@cs.ucsd.edu
1275282Srstrong@cs.ucsd.edu    double convert_and_round(float w, int x, int y, int z)
1285282Srstrong@cs.ucsd.edu    {
1295282Srstrong@cs.ucsd.edu        double temp = .34000;
1305282Srstrong@cs.ucsd.edu
1315282Srstrong@cs.ucsd.edu        return temp;
1325282Srstrong@cs.ucsd.edu    }
1335282Srstrong@cs.ucsd.edu
1345282Srstrong@cs.ucsd.edu    enum FPTypes{
1355282Srstrong@cs.ucsd.edu        FP_SINGLE,
1365282Srstrong@cs.ucsd.edu        FP_DOUBLE,
1375282Srstrong@cs.ucsd.edu        FP_LONG,
1385282Srstrong@cs.ucsd.edu        FP_PS_LO,
1395282Srstrong@cs.ucsd.edu        FP_PS_HI,
1402SN/A        FP_WORD,
1412SN/A        RND_NEAREST,
1422SN/A        RND_ZERO,
1435282Srstrong@cs.ucsd.edu        RND_UP,
1445282Srstrong@cs.ucsd.edu        RND_DOWN
1452SN/A    };
1462SN/A}};
1471450SN/A
1481514SN/A
1495184Sgblack@eecs.umich.edu