SConscript revision 2788:73f724ff348f
1955SN/A# -*- mode:python -*- 2955SN/A 31762SN/A# Copyright (c) 2006 The Regents of The University of Michigan 4955SN/A# All rights reserved. 5955SN/A# 6955SN/A# Redistribution and use in source and binary forms, with or without 7955SN/A# modification, are permitted provided that the following conditions are 8955SN/A# met: redistributions of source code must retain the above copyright 9955SN/A# notice, this list of conditions and the following disclaimer; 10955SN/A# redistributions in binary form must reproduce the above copyright 11955SN/A# notice, this list of conditions and the following disclaimer in the 12955SN/A# documentation and/or other materials provided with the distribution; 13955SN/A# neither the name of the copyright holders nor the names of its 14955SN/A# contributors may be used to endorse or promote products derived from 15955SN/A# this software without specific prior written permission. 16955SN/A# 17955SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18955SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19955SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20955SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21955SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22955SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23955SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24955SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25955SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26955SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27955SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu# 292665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt 30955SN/A 31955SN/Aimport os 32955SN/Aimport os.path 331608SN/A 34955SN/A# Import build environment variable from SConstruct. 35955SN/AImport('env') 36955SN/A 37955SN/A################################################################# 38955SN/A# 39955SN/A# Generate StaticInst execute() method signatures. 40955SN/A# 41955SN/A# There must be one signature for each CPU model compiled in. 42955SN/A# Since the set of compiled-in models is flexible, we generate a 43955SN/A# header containing the appropriate set of signatures on the fly. 44955SN/A# 45955SN/A################################################################# 46955SN/A 47955SN/A# CPU model-specific data is contained in cpu_models.py 482023SN/A# Convert to SCons File node to get path handling 49955SN/Amodels_db = File('cpu_models.py') 503089Ssaidi@eecs.umich.edu# slurp in contents of file 51955SN/Aexecfile(models_db.srcnode().abspath) 52955SN/A 53955SN/A# Template for execute() signature. 54955SN/Aexec_sig_template = ''' 55955SN/Avirtual Fault execute(%s *xc, Trace::InstRecord *traceData) const = 0; 56955SN/Avirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const 57955SN/A{ panic("initiateAcc not defined!"); }; 58955SN/Avirtual Fault completeAcc(Packet *pkt, %s *xc, 591031SN/A Trace::InstRecord *traceData) const 60955SN/A{ panic("completeAcc not defined!"); }; 611388SN/A''' 62955SN/A 63955SN/Amem_ini_sig_template = ''' 641296SN/Avirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); }; 65955SN/A''' 66955SN/A 67955SN/Amem_comp_sig_template = ''' 68955SN/Avirtual Fault completeAcc(uint8_t *data, %s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); return NoFault; }; 69955SN/A''' 70955SN/A 71955SN/A# Generate a temporary CPU list, including the CheckerCPU if 72955SN/A# it's enabled. This isn't used for anything else other than StaticInst 73955SN/A# headers. 74955SN/Atemp_cpu_list = env['CPU_MODELS'] 75955SN/Aif env['USE_CHECKER']: 76955SN/A temp_cpu_list.append('CheckerCPU') 77955SN/A 78955SN/A# Generate header. 79955SN/Adef gen_cpu_exec_signatures(target, source, env): 80955SN/A f = open(str(target[0]), 'w') 81955SN/A print >> f, ''' 82955SN/A#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__ 83955SN/A#define __CPU_STATIC_INST_EXEC_SIGS_HH__ 842325SN/A''' 851717SN/A for cpu in temp_cpu_list: 862652Ssaidi@eecs.umich.edu xc_type = CpuModel.dict[cpu].strings['CPU_exec_context'] 87955SN/A print >> f, exec_sig_template % (xc_type, xc_type, xc_type) 882736Sktlim@umich.edu print >> f, ''' 892410SN/A#endif // __CPU_STATIC_INST_EXEC_SIGS_HH__ 90955SN/A''' 912290SN/A 92955SN/A# Generate string that gets printed when header is rebuilt 932683Sktlim@umich.edudef gen_sigs_string(target, source, env): 942683Sktlim@umich.edu return "Generating static_inst_exec_sigs.hh: " \ 952669Sktlim@umich.edu + ', '.join(temp_cpu_list) 962568SN/A 972568SN/A# Add command to generate header to environment. 983012Ssaidi@eecs.umich.eduenv.Command('static_inst_exec_sigs.hh', models_db, 992462SN/A Action(gen_cpu_exec_signatures, gen_sigs_string, 1002568SN/A varlist = temp_cpu_list)) 1012395SN/A 1022405SN/Aenv.Depends('static_inst_exec_sigs.hh', Value(env['USE_CHECKER'])) 1032914Ssaidi@eecs.umich.eduenv.Depends('static_inst_exec_sigs.hh', Value(env['CPU_MODELS'])) 104955SN/A 1052811Srdreslin@umich.edu# List of suppported CPUs by the Checker. Errors out if USE_CHECKER=True 1062811Srdreslin@umich.edu# and one of these are not being used. 1072811Srdreslin@umich.eduCheckerSupportedCPUList = ['AlphaO3CPU', 'OzoneCPU'] 1082811Srdreslin@umich.edu 1092811Srdreslin@umich.edu################################################################# 1102811Srdreslin@umich.edu# 1112811Srdreslin@umich.edu# Include CPU-model-specific files based on set of models 1122811Srdreslin@umich.edu# specified in CPU_MODELS build option. 1132811Srdreslin@umich.edu# 1142811Srdreslin@umich.edu################################################################# 1152811Srdreslin@umich.edu 1162811Srdreslin@umich.edusources = [] 1172811Srdreslin@umich.edu 1182811Srdreslin@umich.eduneed_simple_base = False 1192811Srdreslin@umich.eduif 'AtomicSimpleCPU' in env['CPU_MODELS']: 1202811Srdreslin@umich.edu need_simple_base = True 1212814Srdreslin@umich.edu sources += Split('simple/atomic.cc') 1222811Srdreslin@umich.edu 1232811Srdreslin@umich.eduif 'TimingSimpleCPU' in env['CPU_MODELS']: 1242811Srdreslin@umich.edu need_simple_base = True 1252811Srdreslin@umich.edu sources += Split('simple/timing.cc') 1262811Srdreslin@umich.edu 1272811Srdreslin@umich.eduif need_simple_base: 1282811Srdreslin@umich.edu sources += Split('simple/base.cc') 1292813Srdreslin@umich.edu 1302813Srdreslin@umich.eduif 'FastCPU' in env['CPU_MODELS']: 131955SN/A sources += Split('fast/cpu.cc') 132955SN/A 133955SN/Aif 'AlphaO3CPU' in env['CPU_MODELS']: 1342090SN/A sources += Split(''' 135955SN/A o3/2bit_local_pred.cc 1362763Sstever@eecs.umich.edu o3/alpha_dyn_inst.cc 137955SN/A o3/alpha_cpu.cc 1381696SN/A o3/alpha_cpu_builder.cc 139955SN/A o3/base_dyn_inst.cc 140955SN/A o3/bpred_unit.cc 141955SN/A o3/btb.cc 1421127SN/A o3/commit.cc 143955SN/A o3/decode.cc 144955SN/A o3/fetch.cc 1452379SN/A o3/free_list.cc 146955SN/A o3/fu_pool.cc 147955SN/A o3/cpu.cc 148955SN/A o3/iew.cc 1492155SN/A o3/inst_queue.cc 1502155SN/A o3/lsq_unit.cc 1512155SN/A o3/lsq.cc 1522155SN/A o3/mem_dep_unit.cc 1532155SN/A o3/ras.cc 1542155SN/A o3/rename.cc 1552155SN/A o3/rename_map.cc 1562155SN/A o3/rob.cc 1572155SN/A o3/scoreboard.cc 1582155SN/A o3/store_set.cc 1592155SN/A o3/tournament_pred.cc 1602155SN/A ''') 1612155SN/A if env['USE_CHECKER']: 1622155SN/A sources += Split('o3/checker_builder.cc') 1632155SN/A 1642155SN/Aif 'OzoneSimpleCPU' in env['CPU_MODELS']: 1652155SN/A sources += Split(''' 1662155SN/A ozone/cpu.cc 1672155SN/A ozone/cpu_builder.cc 1682155SN/A ozone/dyn_inst.cc 1692155SN/A ozone/front_end.cc 1702155SN/A ozone/inorder_back_end.cc 1712155SN/A ozone/inst_queue.cc 1722155SN/A ozone/rename_table.cc 1732155SN/A ''') 1742155SN/A 1752155SN/Aif 'OzoneCPU' in env['CPU_MODELS']: 1762155SN/A sources += Split(''' 1772155SN/A ozone/base_dyn_inst.cc 1782155SN/A ozone/bpred_unit.cc 1792155SN/A ozone/lsq_unit.cc 1802155SN/A ozone/lw_back_end.cc 1812155SN/A ozone/lw_lsq.cc 1822155SN/A ''') 1832155SN/A if env['USE_CHECKER']: 1842155SN/A sources += Split('ozone/checker_builder.cc') 1852155SN/A 1862155SN/Aif env['USE_CHECKER']: 1872155SN/A checker_supports = False 1882422SN/A for i in CheckerSupportedCPUList: 1892422SN/A if i in env['CPU_MODELS']: 1902422SN/A checker_supports = True 1912422SN/A if not checker_supports: 1922422SN/A print "Checker only supports CPU models %s, please " \ 1932422SN/A "set USE_CHECKER=False or use one of those CPU models" \ 1942422SN/A % CheckerSupportedCPUList 1952397SN/A Exit(1) 1962397SN/A 1972422SN/A 1982422SN/A# FullCPU sources are included from src/SConscript since they're not 199955SN/A# below this point in the file hierarchy. 200955SN/A 201955SN/A# Convert file names to SCons File objects. This takes care of the 202955SN/A# path relative to the top of the directory tree. 203955SN/Asources = [File(s) for s in sources] 204955SN/A 205955SN/AReturn('sources') 206955SN/A 2071078SN/A