SConscript revision 2292
15081Sgblack@eecs.umich.edu# -*- mode:python -*- 25081Sgblack@eecs.umich.edu 35081Sgblack@eecs.umich.edu# Copyright (c) 2006 The Regents of The University of Michigan 47087Snate@binkert.org# All rights reserved. 57087Snate@binkert.org# 67087Snate@binkert.org# Redistribution and use in source and binary forms, with or without 77087Snate@binkert.org# modification, are permitted provided that the following conditions are 87087Snate@binkert.org# met: redistributions of source code must retain the above copyright 97087Snate@binkert.org# notice, this list of conditions and the following disclaimer; 107087Snate@binkert.org# redistributions in binary form must reproduce the above copyright 117087Snate@binkert.org# notice, this list of conditions and the following disclaimer in the 125081Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution; 137087Snate@binkert.org# neither the name of the copyright holders nor the names of its 147087Snate@binkert.org# contributors may be used to endorse or promote products derived from 157087Snate@binkert.org# this software without specific prior written permission. 167087Snate@binkert.org# 177087Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 187087Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 197087Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 207087Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 215081Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 227087Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 235081Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 245081Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 255081Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 265081Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 275081Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 285081Sgblack@eecs.umich.edu 295081Sgblack@eecs.umich.eduimport os 305081Sgblack@eecs.umich.eduimport os.path 315081Sgblack@eecs.umich.edu 325081Sgblack@eecs.umich.edu# Import build environment variable from SConstruct. 335081Sgblack@eecs.umich.eduImport('env') 345081Sgblack@eecs.umich.edu 355081Sgblack@eecs.umich.edu################################################################# 365081Sgblack@eecs.umich.edu# 375081Sgblack@eecs.umich.edu# Generate StaticInst execute() method signatures. 385920Sgblack@eecs.umich.edu# 395920Sgblack@eecs.umich.edu# There must be one signature for each CPU model compiled in. 405920Sgblack@eecs.umich.edu# Since the set of compiled-in models is flexible, we generate a 415920Sgblack@eecs.umich.edu# header containing the appropriate set of signatures on the fly. 425920Sgblack@eecs.umich.edu# 435920Sgblack@eecs.umich.edu################################################################# 445920Sgblack@eecs.umich.edu 455920Sgblack@eecs.umich.edu# CPU model-specific data is contained in cpu_models.py 465920Sgblack@eecs.umich.edu# Convert to SCons File node to get path handling 475920Sgblack@eecs.umich.edumodels_db = File('cpu_models.py') 485920Sgblack@eecs.umich.edu# slurp in contents of file 495920Sgblack@eecs.umich.eduexecfile(models_db.srcnode().abspath) 505920Sgblack@eecs.umich.edu 515920Sgblack@eecs.umich.edu# Template for execute() signature. 525920Sgblack@eecs.umich.eduexec_sig_template = ''' 535920Sgblack@eecs.umich.eduvirtual Fault execute(%s *xc, Trace::InstRecord *traceData) const = 0; 545920Sgblack@eecs.umich.edu''' 555920Sgblack@eecs.umich.edu 565920Sgblack@eecs.umich.edumem_ini_sig_template = ''' 575920Sgblack@eecs.umich.eduvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); }; 585920Sgblack@eecs.umich.edu''' 595920Sgblack@eecs.umich.edu 605920Sgblack@eecs.umich.edumem_comp_sig_template = ''' 6112463Sswapnilster@gmail.comvirtual Fault completeAcc(uint8_t *data, %s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); return NoFault; }; 6212463Sswapnilster@gmail.com''' 6312463Sswapnilster@gmail.com 6412463Sswapnilster@gmail.com# Generate header. 6512463Sswapnilster@gmail.comdef gen_cpu_exec_signatures(target, source, env): 6612463Sswapnilster@gmail.com f = open(str(target[0]), 'w') 6712463Sswapnilster@gmail.com print >> f, ''' 6812463Sswapnilster@gmail.com#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__ 6912463Sswapnilster@gmail.com#define __CPU_STATIC_INST_EXEC_SIGS_HH__ 7012463Sswapnilster@gmail.com''' 7112463Sswapnilster@gmail.com for cpu in env['CPU_MODELS']: 7212463Sswapnilster@gmail.com xc_type = CpuModel.dict[cpu].strings['CPU_exec_context'] 7312463Sswapnilster@gmail.com print >> f, exec_sig_template % xc_type 7412463Sswapnilster@gmail.com print >> f, mem_ini_sig_template % xc_type 7512463Sswapnilster@gmail.com print >> f, mem_comp_sig_template % xc_type 7612463Sswapnilster@gmail.com print >> f, ''' 7712463Sswapnilster@gmail.com#endif // __CPU_STATIC_INST_EXEC_SIGS_HH__ 7812463Sswapnilster@gmail.com''' 7912463Sswapnilster@gmail.com 8012463Sswapnilster@gmail.com# Generate string that gets printed when header is rebuilt 8112463Sswapnilster@gmail.comdef gen_sigs_string(target, source, env): 8212463Sswapnilster@gmail.com return "Generating static_inst_exec_sigs.hh: " \ 8312463Sswapnilster@gmail.com + ', '.join(env['CPU_MODELS']) 8412463Sswapnilster@gmail.com 8512463Sswapnilster@gmail.com# Add command to generate header to environment. 8612463Sswapnilster@gmail.comenv.Command('static_inst_exec_sigs.hh', models_db, 8712463Sswapnilster@gmail.com Action(gen_cpu_exec_signatures, gen_sigs_string, 8812463Sswapnilster@gmail.com varlist = ['CPU_MODELS'])) 8912463Sswapnilster@gmail.com 9012463Sswapnilster@gmail.com################################################################# 9112463Sswapnilster@gmail.com# 9212463Sswapnilster@gmail.com# Include CPU-model-specific files based on set of models 9312463Sswapnilster@gmail.com# specified in CPU_MODELS build option. 9412463Sswapnilster@gmail.com# 9512463Sswapnilster@gmail.com################################################################# 965920Sgblack@eecs.umich.edu 975920Sgblack@eecs.umich.edusources = [] 985081Sgblack@eecs.umich.edu 995081Sgblack@eecs.umich.eduif 'SimpleCPU' in env['CPU_MODELS']: 1005543Ssaidi@eecs.umich.edu sources += Split('simple/cpu.cc') 1015081Sgblack@eecs.umich.edu 1025543Ssaidi@eecs.umich.eduif 'FastCPU' in env['CPU_MODELS']: 1035081Sgblack@eecs.umich.edu sources += Split('fast/cpu.cc') 1045543Ssaidi@eecs.umich.edu 1055081Sgblack@eecs.umich.eduif 'AlphaFullCPU' in env['CPU_MODELS']: 1065543Ssaidi@eecs.umich.edu sources += Split(''' 1075081Sgblack@eecs.umich.edu o3/2bit_local_pred.cc 1085543Ssaidi@eecs.umich.edu o3/alpha_dyn_inst.cc 1095081Sgblack@eecs.umich.edu o3/alpha_cpu.cc 110 o3/alpha_cpu_builder.cc 111 o3/bpred_unit.cc 112 o3/btb.cc 113 o3/commit.cc 114 o3/decode.cc 115 o3/fetch.cc 116 o3/free_list.cc 117 o3/fu_pool.cc 118 o3/cpu.cc 119 o3/iew.cc 120 o3/inst_queue.cc 121 o3/lsq_unit.cc 122 o3/lsq.cc 123 o3/mem_dep_unit.cc 124 o3/ras.cc 125 o3/rename.cc 126 o3/rename_map.cc 127 o3/rob.cc 128 o3/sat_counter.cc 129 o3/scoreboard.cc 130 o3/store_set.cc 131 o3/tournament_pred.cc 132 ''') 133 134if 'OzoneSimpleCPU' in env['CPU_MODELS']: 135 sources += Split(''' 136 ozone/cpu.cc 137 ozone/cpu_builder.cc 138 ozone/dyn_inst.cc 139 ozone/front_end.cc 140 ozone/inorder_back_end.cc 141 ozone/inst_queue.cc 142 ozone/rename_table.cc 143 ''') 144 145if 'OzoneCPU' in env['CPU_MODELS']: 146 sources += Split(''' 147 ozone/back_end.cc 148 ozone/lsq_unit.cc 149 ''') 150 151# FullCPU sources are included from m5/SConscript since they're not 152# below this point in the file hierarchy. 153 154# Convert file names to SCons File objects. This takes care of the 155# path relative to the top of the directory tree. 156sources = [File(s) for s in sources] 157 158Return('sources') 159 160