util.isa revision 2135
12SN/A// -*- mode:c++ -*- 21762SN/A 32SN/Alet {{ 42SN/Adef UncondCtrlBase(name, Name, base_class, npc_expr, flags): 52SN/A # Declare basic control transfer w/o link (i.e. link reg is R31) 62SN/A nolink_code = 'NPC = %s;\n' % npc_expr 72SN/A nolink_iop = InstObjParams(name, Name, base_class, 82SN/A CodeBlock(nolink_code), flags) 92SN/A header_output = BasicDeclare.subst(nolink_iop) 102SN/A decoder_output = BasicConstructor.subst(nolink_iop) 112SN/A exec_output = BasicExecute.subst(nolink_iop) 122SN/A 132SN/A # Generate declaration of '*AndLink' version, append to decls 142SN/A link_code = 'Ra = NPC & ~3;\n' + nolink_code 152SN/A link_iop = InstObjParams(name, Name + 'AndLink', base_class, 162SN/A CodeBlock(link_code), flags) 172SN/A header_output += BasicDeclare.subst(link_iop) 182SN/A decoder_output += BasicConstructor.subst(link_iop) 192SN/A exec_output += BasicExecute.subst(link_iop) 202SN/A 212SN/A # need to use link_iop for the decode template since it is expecting 222SN/A # the shorter version of class_name (w/o "AndLink") 232SN/A 242SN/A return (header_output, decoder_output, 252SN/A JumpOrBranchDecode.subst(nolink_iop), exec_output) 262SN/A 272665Ssaidi@eecs.umich.edudef LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags, 282665Ssaidi@eecs.umich.edu postacc_code = '', base_class = 'Memory', 292665Ssaidi@eecs.umich.edu decode_template = BasicDecode, exec_template_base = ''): 302SN/A # Make sure flags are in lists (convert to lists if not). 312SN/A mem_flags = makeList(mem_flags) 322SN/A inst_flags = makeList(inst_flags) 332SN/A 34330SN/A # add hook to get effective addresses into execution trace output. 3556SN/A ea_code += '\nif (traceData) { traceData->setAddr(EA); }\n' 361031SN/A 37330SN/A # generate code block objects 38330SN/A ea_cblk = CodeBlock(ea_code) 39938SN/A memacc_cblk = CodeBlock(memacc_code) 4056SN/A postacc_cblk = CodeBlock(postacc_code) 41330SN/A 42695SN/A # Some CPU models execute the memory operation as an atomic unit, 432SN/A # while others want to separate them into an effective address 442SN/A # computation and a memory access operation. As a result, we need 452SN/A # to generate three StaticInst objects. Note that the latter two 462SN/A # are nested inside the larger "atomic" one. 472SN/A 482SN/A # generate InstObjParams for EAComp object 492SN/A ea_iop = InstObjParams(name, Name, base_class, ea_cblk, inst_flags) 502SN/A 512SN/A # generate InstObjParams for MemAcc object 522SN/A memacc_iop = InstObjParams(name, Name, base_class, memacc_cblk, inst_flags) 532SN/A # in the split execution model, the MemAcc portion is responsible 542SN/A # for the post-access code. 552SN/A memacc_iop.postacc_code = postacc_cblk.code 562SN/A 572SN/A # generate InstObjParams for InitiateAcc, CompleteAcc object 582SN/A # The code used depends on the template being used 592SN/A if (exec_template_base == 'Load'): 602SN/A initiateacc_cblk = CodeBlock(ea_code + memacc_code) 614762Snate@binkert.org completeacc_cblk = CodeBlock(memacc_code + postacc_code) 621553SN/A elif (exec_template_base == 'Store'): 632SN/A initiateacc_cblk = CodeBlock(ea_code + memacc_code) 641031SN/A completeacc_cblk = CodeBlock(postacc_code) 651031SN/A else: 661031SN/A initiateacc_cblk = '' 671031SN/A completeacc_cblk = '' 681553SN/A 692901Ssaidi@eecs.umich.edu initiateacc_iop = InstObjParams(name, Name, base_class, initiateacc_cblk, 701553SN/A inst_flags) 711553SN/A 724762Snate@binkert.org completeacc_iop = InstObjParams(name, Name, base_class, completeacc_cblk, 734762Snate@binkert.org inst_flags) 744762Snate@binkert.org 754762Snate@binkert.org if (exec_template_base == 'Load'): 764762Snate@binkert.org initiateacc_iop.ea_code = ea_cblk.code 774762Snate@binkert.org initiateacc_iop.memacc_code = memacc_cblk.code 784762Snate@binkert.org completeacc_iop.memacc_code = memacc_cblk.code 794762Snate@binkert.org completeacc_iop.postacc_code = postacc_cblk.code 804762Snate@binkert.org elif (exec_template_base == 'Store'): 811553SN/A initiateacc_iop.ea_code = ea_cblk.code 824762Snate@binkert.org initiateacc_iop.memacc_code = memacc_cblk.code 831553SN/A completeacc_iop.postacc_code = postacc_cblk.code 841553SN/A 851553SN/A # generate InstObjParams for unified execution 861553SN/A cblk = CodeBlock(ea_code + memacc_code + postacc_code) 871553SN/A iop = InstObjParams(name, Name, base_class, cblk, inst_flags) 882SN/A 892901Ssaidi@eecs.umich.edu iop.ea_constructor = ea_cblk.constructor 902SN/A iop.ea_code = ea_cblk.code 912SN/A iop.memacc_constructor = memacc_cblk.constructor 92465SN/A iop.memacc_code = memacc_cblk.code 93465SN/A iop.postacc_code = postacc_cblk.code 94465SN/A 95465SN/A if mem_flags: 96465SN/A s = '\n\tmemAccessFlags = ' + string.join(mem_flags, '|') + ';' 972SN/A iop.constructor += s 982SN/A memacc_iop.constructor += s 992SN/A 1002SN/A # select templates 1012SN/A memAccExecTemplate = eval(exec_template_base + 'MemAccExecute') 1022SN/A fullExecTemplate = eval(exec_template_base + 'Execute') 1032SN/A initiateAccTemplate = eval(exec_template_base + 'InitiateAcc') 1042SN/A completeAccTemplate = eval(exec_template_base + 'CompleteAcc') 1052SN/A 1062SN/A # (header_output, decoder_output, decode_block, exec_output) 1072SN/A return (LoadStoreDeclare.subst(iop), LoadStoreConstructor.subst(iop), 1082SN/A decode_template.subst(iop), 1092SN/A EACompExecute.subst(ea_iop) 110330SN/A + memAccExecTemplate.subst(memacc_iop) 111330SN/A + fullExecTemplate.subst(iop) 112330SN/A + initiateAccTemplate.subst(initiateacc_iop) 113330SN/A + completeAccTemplate.subst(completeacc_iop)) 114330SN/A}}; 1152SN/A 11653SN/A 11753SN/Aoutput exec {{ 11853SN/A 1192SN/A /// CLEAR ALL CPU INST/EXE HAZARDS 120334SN/A inline void 121334SN/A clear_exe_inst_hazards() 122334SN/A { 123334SN/A //CODE HERE 124334SN/A } 125334SN/A}}; 126334SN/A