SConscript revision 2997
12086SN/A# -*- mode:python -*- 22086SN/A 32086SN/A# Copyright (c) 2006 The Regents of The University of Michigan 42086SN/A# All rights reserved. 52086SN/A# 62086SN/A# Redistribution and use in source and binary forms, with or without 72086SN/A# modification, are permitted provided that the following conditions are 82086SN/A# met: redistributions of source code must retain the above copyright 92086SN/A# notice, this list of conditions and the following disclaimer; 102086SN/A# redistributions in binary form must reproduce the above copyright 112086SN/A# notice, this list of conditions and the following disclaimer in the 122086SN/A# documentation and/or other materials provided with the distribution; 132086SN/A# neither the name of the copyright holders nor the names of its 142086SN/A# contributors may be used to endorse or promote products derived from 152086SN/A# this software without specific prior written permission. 162086SN/A# 172086SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182086SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192086SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202086SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212086SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222086SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232086SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242086SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252086SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262086SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272086SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu# 292665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt 302665Ssaidi@eecs.umich.edu 312086SN/Aimport os 324202Sbinkertn@umich.eduimport os.path 332086SN/A 344202Sbinkertn@umich.edu# Import build environment variable from SConstruct. 355403Shines@cs.fsu.eduImport('env') 365403Shines@cs.fsu.edu 375403Shines@cs.fsu.edu################################################################# 385403Shines@cs.fsu.edu# 394202Sbinkertn@umich.edu# Generate StaticInst execute() method signatures. 404202Sbinkertn@umich.edu# 414202Sbinkertn@umich.edu# There must be one signature for each CPU model compiled in. 424202Sbinkertn@umich.edu# Since the set of compiled-in models is flexible, we generate a 434202Sbinkertn@umich.edu# header containing the appropriate set of signatures on the fly. 444997Sgblack@eecs.umich.edu# 454202Sbinkertn@umich.edu################################################################# 464202Sbinkertn@umich.edu 474997Sgblack@eecs.umich.edu# CPU model-specific data is contained in cpu_models.py 484826Ssaidi@eecs.umich.edu# Convert to SCons File node to get path handling 492086SN/Amodels_db = File('cpu_models.py') 504997Sgblack@eecs.umich.edu# slurp in contents of file 515192Ssaidi@eecs.umich.eduexecfile(models_db.srcnode().abspath) 524997Sgblack@eecs.umich.edu 534202Sbinkertn@umich.edu# Template for execute() signature. 544486Sbinkertn@umich.eduexec_sig_template = ''' 554486Sbinkertn@umich.eduvirtual Fault execute(%s *xc, Trace::InstRecord *traceData) const = 0; 564202Sbinkertn@umich.eduvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const 574202Sbinkertn@umich.edu{ panic("initiateAcc not defined!"); }; 584202Sbinkertn@umich.eduvirtual Fault completeAcc(Packet *pkt, %s *xc, 594202Sbinkertn@umich.edu Trace::InstRecord *traceData) const 604202Sbinkertn@umich.edu{ panic("completeAcc not defined!"); }; 614202Sbinkertn@umich.edu''' 622086SN/A 634202Sbinkertn@umich.edumem_ini_sig_template = ''' 644202Sbinkertn@umich.eduvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); }; 654202Sbinkertn@umich.edu''' 662086SN/A 674202Sbinkertn@umich.edumem_comp_sig_template = ''' 684202Sbinkertn@umich.eduvirtual Fault completeAcc(uint8_t *data, %s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); return NoFault; }; 692086SN/A''' 704202Sbinkertn@umich.edu 714202Sbinkertn@umich.edu# Generate a temporary CPU list, including the CheckerCPU if 724202Sbinkertn@umich.edu# it's enabled. This isn't used for anything else other than StaticInst 734202Sbinkertn@umich.edu# headers. 744202Sbinkertn@umich.edutemp_cpu_list = env['CPU_MODELS'][:] 754202Sbinkertn@umich.edu 76if env['USE_CHECKER']: 77 temp_cpu_list.append('CheckerCPU') 78 79# Generate header. 80def gen_cpu_exec_signatures(target, source, env): 81 f = open(str(target[0]), 'w') 82 print >> f, ''' 83#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__ 84#define __CPU_STATIC_INST_EXEC_SIGS_HH__ 85''' 86 for cpu in temp_cpu_list: 87 xc_type = CpuModel.dict[cpu].strings['CPU_exec_context'] 88 print >> f, exec_sig_template % (xc_type, xc_type, xc_type) 89 print >> f, ''' 90#endif // __CPU_STATIC_INST_EXEC_SIGS_HH__ 91''' 92 93# Generate string that gets printed when header is rebuilt 94def gen_sigs_string(target, source, env): 95 return "Generating static_inst_exec_sigs.hh: " \ 96 + ', '.join(temp_cpu_list) 97 98# Add command to generate header to environment. 99env.Command('static_inst_exec_sigs.hh', models_db, 100 Action(gen_cpu_exec_signatures, gen_sigs_string, 101 varlist = temp_cpu_list)) 102 103env.Depends('static_inst_exec_sigs.hh', Value(env['USE_CHECKER'])) 104env.Depends('static_inst_exec_sigs.hh', Value(env['CPU_MODELS'])) 105 106# List of suppported CPUs by the Checker. Errors out if USE_CHECKER=True 107# and one of these are not being used. 108CheckerSupportedCPUList = ['O3CPU', 'OzoneCPU'] 109 110################################################################# 111# 112# Include CPU-model-specific files based on set of models 113# specified in CPU_MODELS build option. 114# 115################################################################# 116 117# Keep a list of CPU models that support SMT 118env['SMT_CPU_MODELS'] = [] 119 120sources = [] 121 122need_simple_base = False 123if 'AtomicSimpleCPU' in env['CPU_MODELS']: 124 need_simple_base = True 125 sources += Split('simple/atomic.cc') 126 127if 'TimingSimpleCPU' in env['CPU_MODELS']: 128 need_simple_base = True 129 sources += Split('simple/timing.cc') 130 131if need_simple_base: 132 sources += Split('simple/base.cc') 133 134if 'FastCPU' in env['CPU_MODELS']: 135 sources += Split('fast/cpu.cc') 136 137need_bp_unit = False 138if 'O3CPU' in env['CPU_MODELS']: 139 need_bp_unit = True 140 sources += SConscript('o3/SConscript', exports = 'env') 141 sources += Split(''' 142 o3/base_dyn_inst.cc 143 o3/bpred_unit.cc 144 o3/commit.cc 145 o3/decode.cc 146 o3/fetch.cc 147 o3/free_list.cc 148 o3/fu_pool.cc 149 o3/cpu.cc 150 o3/iew.cc 151 o3/inst_queue.cc 152 o3/lsq_unit.cc 153 o3/lsq.cc 154 o3/mem_dep_unit.cc 155 o3/rename.cc 156 o3/rename_map.cc 157 o3/rob.cc 158 o3/scoreboard.cc 159 o3/store_set.cc 160 ''') 161 if env['USE_CHECKER']: 162 sources += Split('o3/checker_builder.cc') 163 else: 164 env['SMT_CPU_MODELS'].append('O3CPU') # Checker doesn't support SMT right now 165 166if 'OzoneCPU' in env['CPU_MODELS']: 167 need_bp_unit = True 168 sources += Split(''' 169 ozone/base_dyn_inst.cc 170 ozone/bpred_unit.cc 171 ozone/cpu.cc 172 ozone/cpu_builder.cc 173 ozone/dyn_inst.cc 174 ozone/front_end.cc 175 ozone/lw_back_end.cc 176 ozone/lw_lsq.cc 177 ozone/rename_table.cc 178 ''') 179 if env['USE_CHECKER']: 180 sources += Split('ozone/checker_builder.cc') 181 182if need_bp_unit: 183 sources += Split(''' 184 o3/2bit_local_pred.cc 185 o3/btb.cc 186 o3/ras.cc 187 o3/tournament_pred.cc 188 ''') 189 190if env['USE_CHECKER']: 191 sources += Split('checker/cpu.cc') 192 checker_supports = False 193 for i in CheckerSupportedCPUList: 194 if i in env['CPU_MODELS']: 195 checker_supports = True 196 if not checker_supports: 197 print "Checker only supports CPU models", 198 for i in CheckerSupportedCPUList: 199 print i, 200 print ", please set USE_CHECKER=False or use one of those CPU models" 201 Exit(1) 202 203 204# FullCPU sources are included from src/SConscript since they're not 205# below this point in the file hierarchy. 206 207# Convert file names to SCons File objects. This takes care of the 208# path relative to the top of the directory tree. 209sources = [File(s) for s in sources] 210 211Return('sources') 212 213