util.isa revision 2124
1// -*- mode:c++ -*-
2
3let {{
4def UncondCtrlBase(name, Name, base_class, npc_expr, flags):
5    # Declare basic control transfer w/o link (i.e. link reg is R31)
6    nolink_code = 'NPC = %s;\n' % npc_expr
7    nolink_iop = InstObjParams(name, Name, base_class,
8                               CodeBlock(nolink_code), flags)
9    header_output = BasicDeclare.subst(nolink_iop)
10    decoder_output = BasicConstructor.subst(nolink_iop)
11    exec_output = BasicExecute.subst(nolink_iop)
12
13    # Generate declaration of '*AndLink' version, append to decls
14    link_code = 'Ra = NPC & ~3;\n' + nolink_code
15    link_iop = InstObjParams(name, Name + 'AndLink', base_class,
16                             CodeBlock(link_code), flags)
17    header_output += BasicDeclare.subst(link_iop)
18    decoder_output += BasicConstructor.subst(link_iop)
19    exec_output += BasicExecute.subst(link_iop)
20
21    # need to use link_iop for the decode template since it is expecting
22    # the shorter version of class_name (w/o "AndLink")
23
24    return (header_output, decoder_output,
25            JumpOrBranchDecode.subst(nolink_iop), exec_output)
26
27def LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
28                  postacc_code = '', base_class = 'Memory',
29                  decode_template = BasicDecode, exec_template_base = ''):
30    # Make sure flags are in lists (convert to lists if not).
31    mem_flags = makeList(mem_flags)
32    inst_flags = makeList(inst_flags)
33
34    # add hook to get effective addresses into execution trace output.
35    ea_code += '\nif (traceData) { traceData->setAddr(EA); }\n'
36
37    # generate code block objects
38    ea_cblk = CodeBlock(ea_code)
39    memacc_cblk = CodeBlock(memacc_code)
40    postacc_cblk = CodeBlock(postacc_code)
41
42    # Some CPU models execute the memory operation as an atomic unit,
43    # while others want to separate them into an effective address
44    # computation and a memory access operation.  As a result, we need
45    # to generate three StaticInst objects.  Note that the latter two
46    # are nested inside the larger "atomic" one.
47
48    # generate InstObjParams for EAComp object
49    ea_iop = InstObjParams(name, Name, base_class, ea_cblk, inst_flags)
50
51    # generate InstObjParams for MemAcc object
52    memacc_iop = InstObjParams(name, Name, base_class, memacc_cblk, inst_flags)
53    # in the split execution model, the MemAcc portion is responsible
54    # for the post-access code.
55    memacc_iop.postacc_code = postacc_cblk.code
56
57    # generate InstObjParams for InitiateAcc, CompleteAcc object
58    # The code used depends on the template being used
59    if (exec_template_base == 'Load'):
60        initiateacc_cblk = CodeBlock(ea_code + memacc_code)
61        completeacc_cblk = CodeBlock(memacc_code + postacc_code)
62    elif (exec_template_base == 'Store'):
63        initiateacc_cblk = CodeBlock(ea_code + memacc_code)
64        completeacc_cblk = CodeBlock(postacc_code)
65    else:
66        initiateacc_cblk = ''
67        completeacc_cblk = ''
68
69    initiateacc_iop = InstObjParams(name, Name, base_class, initiateacc_cblk,
70                                    inst_flags)
71
72    completeacc_iop = InstObjParams(name, Name, base_class, completeacc_cblk,
73                                    inst_flags)
74
75    if (exec_template_base == 'Load'):
76        initiateacc_iop.ea_code = ea_cblk.code
77        initiateacc_iop.memacc_code = memacc_cblk.code
78        completeacc_iop.memacc_code = memacc_cblk.code
79        completeacc_iop.postacc_code = postacc_cblk.code
80    elif (exec_template_base == 'Store'):
81        initiateacc_iop.ea_code = ea_cblk.code
82        initiateacc_iop.memacc_code = memacc_cblk.code
83        completeacc_iop.postacc_code = postacc_cblk.code
84
85    # generate InstObjParams for unified execution
86    cblk = CodeBlock(ea_code + memacc_code + postacc_code)
87    iop = InstObjParams(name, Name, base_class, cblk, inst_flags)
88
89    iop.ea_constructor = ea_cblk.constructor
90    iop.ea_code = ea_cblk.code
91    iop.memacc_constructor = memacc_cblk.constructor
92    iop.memacc_code = memacc_cblk.code
93    iop.postacc_code = postacc_cblk.code
94
95    if mem_flags:
96        s = '\n\tmemAccessFlags = ' + string.join(mem_flags, '|') + ';'
97        iop.constructor += s
98        memacc_iop.constructor += s
99
100    # select templates
101    memAccExecTemplate = eval(exec_template_base + 'MemAccExecute')
102    fullExecTemplate = eval(exec_template_base + 'Execute')
103    initiateAccTemplate = eval(exec_template_base + 'InitiateAcc')
104    completeAccTemplate = eval(exec_template_base + 'CompleteAcc')
105
106    # (header_output, decoder_output, decode_block, exec_output)
107    return (LoadStoreDeclare.subst(iop), LoadStoreConstructor.subst(iop),
108            decode_template.subst(iop),
109            EACompExecute.subst(ea_iop)
110            + memAccExecTemplate.subst(memacc_iop)
111            + fullExecTemplate.subst(iop)
112            + initiateAccTemplate.subst(initiateacc_iop)
113            + completeAccTemplate.subst(completeacc_iop))
114}};
115
116
117output exec {{
118
119    /// CLEAR ALL CPU INST/EXE HAZARDS
120    inline void
121    clear_exe_inst_hazards()
122    {
123        //CODE HERE
124    }
125}
126