SConscript revision 2935
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# 294762Snate@binkert.org# Authors: Steve Reinhardt 30955SN/A 315522Snate@binkert.orgimport os 326143Snate@binkert.orgimport os.path 334762Snate@binkert.org 345522Snate@binkert.org# Import build environment variable from SConstruct. 35955SN/AImport('env') 365522Snate@binkert.org 37955SN/A################################################################# 385522Snate@binkert.org# 394202Sbinkertn@umich.edu# Generate StaticInst execute() method signatures. 405742Snate@binkert.org# 41955SN/A# There must be one signature for each CPU model compiled in. 424381Sbinkertn@umich.edu# Since the set of compiled-in models is flexible, we generate a 434381Sbinkertn@umich.edu# header containing the appropriate set of signatures on the fly. 448334Snate@binkert.org# 45955SN/A################################################################# 46955SN/A 474202Sbinkertn@umich.edu# CPU model-specific data is contained in cpu_models.py 48955SN/A# Convert to SCons File node to get path handling 494382Sbinkertn@umich.edumodels_db = File('cpu_models.py') 504382Sbinkertn@umich.edu# slurp in contents of file 514382Sbinkertn@umich.eduexecfile(models_db.srcnode().abspath) 526654Snate@binkert.org 535517Snate@binkert.org# Template for execute() signature. 548614Sgblack@eecs.umich.eduexec_sig_template = ''' 557674Snate@binkert.orgvirtual Fault execute(%s *xc, Trace::InstRecord *traceData) const = 0; 566143Snate@binkert.orgvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const 576143Snate@binkert.org{ panic("initiateAcc not defined!"); }; 586143Snate@binkert.orgvirtual Fault completeAcc(Packet *pkt, %s *xc, 598233Snate@binkert.org Trace::InstRecord *traceData) const 608233Snate@binkert.org{ panic("completeAcc not defined!"); }; 618233Snate@binkert.org''' 628233Snate@binkert.org 638233Snate@binkert.orgmem_ini_sig_template = ''' 648334Snate@binkert.orgvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); }; 658334Snate@binkert.org''' 668233Snate@binkert.org 678233Snate@binkert.orgmem_comp_sig_template = ''' 688233Snate@binkert.orgvirtual Fault completeAcc(uint8_t *data, %s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); return NoFault; }; 698233Snate@binkert.org''' 708233Snate@binkert.org 718233Snate@binkert.org# Generate a temporary CPU list, including the CheckerCPU if 726143Snate@binkert.org# it's enabled. This isn't used for anything else other than StaticInst 738233Snate@binkert.org# headers. 748233Snate@binkert.orgtemp_cpu_list = env['CPU_MODELS'][:] 758233Snate@binkert.org 766143Snate@binkert.orgif env['USE_CHECKER']: 776143Snate@binkert.org temp_cpu_list.append('CheckerCPU') 786143Snate@binkert.org 796143Snate@binkert.org# Generate header. 808233Snate@binkert.orgdef gen_cpu_exec_signatures(target, source, env): 818233Snate@binkert.org f = open(str(target[0]), 'w') 828233Snate@binkert.org print >> f, ''' 836143Snate@binkert.org#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__ 848233Snate@binkert.org#define __CPU_STATIC_INST_EXEC_SIGS_HH__ 858233Snate@binkert.org''' 868233Snate@binkert.org for cpu in temp_cpu_list: 878233Snate@binkert.org xc_type = CpuModel.dict[cpu].strings['CPU_exec_context'] 886143Snate@binkert.org print >> f, exec_sig_template % (xc_type, xc_type, xc_type) 896143Snate@binkert.org print >> f, ''' 906143Snate@binkert.org#endif // __CPU_STATIC_INST_EXEC_SIGS_HH__ 914762Snate@binkert.org''' 926143Snate@binkert.org 938233Snate@binkert.org# Generate string that gets printed when header is rebuilt 948233Snate@binkert.orgdef gen_sigs_string(target, source, env): 958233Snate@binkert.org return "Generating static_inst_exec_sigs.hh: " \ 968233Snate@binkert.org + ', '.join(temp_cpu_list) 978233Snate@binkert.org 986143Snate@binkert.org# Add command to generate header to environment. 998233Snate@binkert.orgenv.Command('static_inst_exec_sigs.hh', models_db, 1008233Snate@binkert.org Action(gen_cpu_exec_signatures, gen_sigs_string, 1018233Snate@binkert.org varlist = temp_cpu_list)) 1028233Snate@binkert.org 1036143Snate@binkert.orgenv.Depends('static_inst_exec_sigs.hh', Value(env['USE_CHECKER'])) 1046143Snate@binkert.orgenv.Depends('static_inst_exec_sigs.hh', Value(env['CPU_MODELS'])) 1056143Snate@binkert.org 1066143Snate@binkert.org# List of suppported CPUs by the Checker. Errors out if USE_CHECKER=True 1076143Snate@binkert.org# and one of these are not being used. 1086143Snate@binkert.orgCheckerSupportedCPUList = ['O3CPU', 'OzoneCPU'] 1096143Snate@binkert.org 1106143Snate@binkert.org################################################################# 1116143Snate@binkert.org# 1127065Snate@binkert.org# Include CPU-model-specific files based on set of models 1136143Snate@binkert.org# specified in CPU_MODELS build option. 1148233Snate@binkert.org# 1158233Snate@binkert.org################################################################# 1168233Snate@binkert.org 1178233Snate@binkert.org# Keep a list of CPU models that support SMT 1188233Snate@binkert.orgenv['SMT_CPU_MODELS'] = [] 1198233Snate@binkert.org 1208233Snate@binkert.orgsources = [] 1218233Snate@binkert.org 1228233Snate@binkert.orgneed_simple_base = False 1238233Snate@binkert.orgif 'AtomicSimpleCPU' in env['CPU_MODELS']: 1248233Snate@binkert.org need_simple_base = True 1258233Snate@binkert.org sources += Split('simple/atomic.cc') 1268233Snate@binkert.org 1278233Snate@binkert.orgif 'TimingSimpleCPU' in env['CPU_MODELS']: 1288233Snate@binkert.org need_simple_base = True 1298233Snate@binkert.org sources += Split('simple/timing.cc') 1308233Snate@binkert.org 1318233Snate@binkert.orgif need_simple_base: 1328233Snate@binkert.org sources += Split('simple/base.cc') 1338233Snate@binkert.org 1348233Snate@binkert.orgif 'FastCPU' in env['CPU_MODELS']: 1358233Snate@binkert.org sources += Split('fast/cpu.cc') 1368233Snate@binkert.org 1378233Snate@binkert.orgneed_bp_unit = False 1388233Snate@binkert.orgif 'O3CPU' in env['CPU_MODELS']: 1398233Snate@binkert.org need_bp_unit = True 1408233Snate@binkert.org sources += SConscript('o3/SConscript', exports = 'env') 1418233Snate@binkert.org sources += Split(''' 1428233Snate@binkert.org o3/base_dyn_inst.cc 1438233Snate@binkert.org o3/bpred_unit.cc 1448233Snate@binkert.org o3/commit.cc 1456143Snate@binkert.org o3/decode.cc 1466143Snate@binkert.org o3/fetch.cc 1476143Snate@binkert.org o3/free_list.cc 1486143Snate@binkert.org o3/fu_pool.cc 1496143Snate@binkert.org o3/cpu.cc 1506143Snate@binkert.org o3/iew.cc 1516143Snate@binkert.org o3/inst_queue.cc 1526143Snate@binkert.org o3/lsq_unit.cc 1536143Snate@binkert.org o3/lsq.cc 1548945Ssteve.reinhardt@amd.com o3/mem_dep_unit.cc 1558233Snate@binkert.org o3/rename.cc 1568233Snate@binkert.org o3/rename_map.cc 1576143Snate@binkert.org o3/rob.cc 1588945Ssteve.reinhardt@amd.com o3/scoreboard.cc 1596143Snate@binkert.org o3/store_set.cc 1606143Snate@binkert.org ''') 1616143Snate@binkert.org if env['USE_CHECKER']: 1626143Snate@binkert.org sources += Split('o3/checker_builder.cc') 1635522Snate@binkert.org env['SMT_CPU_MODELS'].append('O3CPU') 1646143Snate@binkert.org 1656143Snate@binkert.orgif 'OzoneCPU' in env['CPU_MODELS']: 1666143Snate@binkert.org need_bp_unit = True 1676143Snate@binkert.org sources += Split(''' 1688233Snate@binkert.org ozone/base_dyn_inst.cc 1698233Snate@binkert.org ozone/bpred_unit.cc 1708233Snate@binkert.org ozone/cpu.cc 1716143Snate@binkert.org ozone/cpu_builder.cc 1726143Snate@binkert.org ozone/dyn_inst.cc 1736143Snate@binkert.org ozone/front_end.cc 1746143Snate@binkert.org ozone/lw_back_end.cc 1755522Snate@binkert.org ozone/lw_lsq.cc 1765522Snate@binkert.org ozone/rename_table.cc 1775522Snate@binkert.org ''') 1785522Snate@binkert.org if env['USE_CHECKER']: 1795604Snate@binkert.org sources += Split('ozone/checker_builder.cc') 1805604Snate@binkert.org 1816143Snate@binkert.orgif need_bp_unit: 1826143Snate@binkert.org sources += Split(''' 1834762Snate@binkert.org o3/2bit_local_pred.cc 1844762Snate@binkert.org o3/btb.cc 1856143Snate@binkert.org o3/ras.cc 1866727Ssteve.reinhardt@amd.com o3/tournament_pred.cc 1876727Ssteve.reinhardt@amd.com ''') 1886727Ssteve.reinhardt@amd.com 1894762Snate@binkert.orgif env['USE_CHECKER']: 1906143Snate@binkert.org sources += Split('checker/cpu.cc') 1916143Snate@binkert.org checker_supports = False 1926143Snate@binkert.org for i in CheckerSupportedCPUList: 1936143Snate@binkert.org if i in env['CPU_MODELS']: 1946727Ssteve.reinhardt@amd.com checker_supports = True 1956143Snate@binkert.org if not checker_supports: 1967674Snate@binkert.org print "Checker only supports CPU models", 1977674Snate@binkert.org for i in CheckerSupportedCPUList: 1985604Snate@binkert.org print i, 1996143Snate@binkert.org print ", please set USE_CHECKER=False or use one of those CPU models" 2006143Snate@binkert.org Exit(1) 2016143Snate@binkert.org 2024762Snate@binkert.org 2036143Snate@binkert.org# FullCPU sources are included from src/SConscript since they're not 2044762Snate@binkert.org# below this point in the file hierarchy. 2054762Snate@binkert.org 2064762Snate@binkert.org# Convert file names to SCons File objects. This takes care of the 2076143Snate@binkert.org# path relative to the top of the directory tree. 2086143Snate@binkert.orgsources = [File(s) for s in sources] 2094762Snate@binkert.org 2108233Snate@binkert.orgReturn('sources') 2118233Snate@binkert.org 2128233Snate@binkert.org