SConscript revision 2517
14484Sbinkertn@umich.edu# -*- mode:python -*-
24484Sbinkertn@umich.edu
34484Sbinkertn@umich.edu# Copyright (c) 2006 The Regents of The University of Michigan
44484Sbinkertn@umich.edu# All rights reserved.
54484Sbinkertn@umich.edu#
64484Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without
74484Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are
84484Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright
94484Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer;
104484Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright
114484Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the
124484Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution;
134484Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its
144484Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from
154484Sbinkertn@umich.edu# this software without specific prior written permission.
164484Sbinkertn@umich.edu#
174484Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
184484Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
194484Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
204484Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
214484Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
224484Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
234484Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
244484Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
254484Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
264484Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
274484Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
284484Sbinkertn@umich.edu
294484Sbinkertn@umich.eduimport os
304484Sbinkertn@umich.eduimport os.path
314494Ssaidi@eecs.umich.edu
324484Sbinkertn@umich.edu# Import build environment variable from SConstruct.
336121Snate@binkert.orgImport('env')
344484Sbinkertn@umich.edu
354484Sbinkertn@umich.edu#################################################################
364484Sbinkertn@umich.edu#
374484Sbinkertn@umich.edu# Generate StaticInst execute() method signatures.
384781Snate@binkert.org#
394484Sbinkertn@umich.edu# There must be one signature for each CPU model compiled in.
404484Sbinkertn@umich.edu# Since the set of compiled-in models is flexible, we generate a
414484Sbinkertn@umich.edu# header containing the appropriate set of signatures on the fly.
424484Sbinkertn@umich.edu#
438349Sgblack@eecs.umich.edu#################################################################
448349Sgblack@eecs.umich.edu
454484Sbinkertn@umich.edu# CPU model-specific data is contained in cpu_models.py
464484Sbinkertn@umich.edu# Convert to SCons File node to get path handling
474484Sbinkertn@umich.edumodels_db = File('cpu_models.py')
484484Sbinkertn@umich.edu# slurp in contents of file
494484Sbinkertn@umich.eduexecfile(models_db.srcnode().abspath)
504484Sbinkertn@umich.edu
514484Sbinkertn@umich.edu# Template for execute() signature.
524484Sbinkertn@umich.eduexec_sig_template = '''
534484Sbinkertn@umich.eduvirtual Fault execute(%s *xc, Trace::InstRecord *traceData) const = 0;
544484Sbinkertn@umich.edu'''
554484Sbinkertn@umich.edu
564484Sbinkertn@umich.edu# Generate header.  
574484Sbinkertn@umich.edudef gen_cpu_exec_signatures(target, source, env):
584484Sbinkertn@umich.edu    f = open(str(target[0]), 'w')
594484Sbinkertn@umich.edu    print >> f, '''
604484Sbinkertn@umich.edu#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__
614484Sbinkertn@umich.edu#define __CPU_STATIC_INST_EXEC_SIGS_HH__
624484Sbinkertn@umich.edu'''
634484Sbinkertn@umich.edu    for cpu in env['CPU_MODELS']:
644484Sbinkertn@umich.edu        xc_type = CpuModel.dict[cpu].strings['CPU_exec_context']
654484Sbinkertn@umich.edu        print >> f, exec_sig_template % xc_type
664484Sbinkertn@umich.edu    print >> f, '''
674484Sbinkertn@umich.edu#endif  // __CPU_STATIC_INST_EXEC_SIGS_HH__
684484Sbinkertn@umich.edu'''
694484Sbinkertn@umich.edu
704484Sbinkertn@umich.edu# Generate string that gets printed when header is rebuilt
714484Sbinkertn@umich.edudef gen_sigs_string(target, source, env):
724484Sbinkertn@umich.edu    return "Generating static_inst_exec_sigs.hh: " \
734484Sbinkertn@umich.edu           + ', '.join(env['CPU_MODELS'])
744484Sbinkertn@umich.edu
754484Sbinkertn@umich.edu# Add command to generate header to environment.
764484Sbinkertn@umich.eduenv.Command('static_inst_exec_sigs.hh', models_db,
774484Sbinkertn@umich.edu            Action(gen_cpu_exec_signatures, gen_sigs_string,
784484Sbinkertn@umich.edu                   varlist = ['CPU_MODELS']))
794484Sbinkertn@umich.edu
804484Sbinkertn@umich.edu#################################################################
814484Sbinkertn@umich.edu#
824484Sbinkertn@umich.edu# Include CPU-model-specific files based on set of models
834484Sbinkertn@umich.edu# specified in CPU_MODELS build option.
844484Sbinkertn@umich.edu#
854484Sbinkertn@umich.edu#################################################################
864484Sbinkertn@umich.edu
874484Sbinkertn@umich.edusources = []
884484Sbinkertn@umich.edu
894484Sbinkertn@umich.eduif 'SimpleCPU' in env['CPU_MODELS']:
904484Sbinkertn@umich.edu    sources += Split('simple/cpu.cc')
914484Sbinkertn@umich.edu
926121Snate@binkert.orgif 'FastCPU' in env['CPU_MODELS']:
936121Snate@binkert.org    sources += Split('fast/cpu.cc')
946121Snate@binkert.org
955765Snate@binkert.orgif 'AlphaFullCPU' in env['CPU_MODELS']:
965765Snate@binkert.org    sources += Split('''
975765Snate@binkert.org        o3/2bit_local_pred.cc
985397Ssaidi@eecs.umich.edu        o3/alpha_dyn_inst.cc
995274Ssaidi@eecs.umich.edu        o3/alpha_cpu.cc
1004494Ssaidi@eecs.umich.edu        o3/alpha_cpu_builder.cc
1014504Ssaidi@eecs.umich.edu        o3/bpred_unit.cc
1024494Ssaidi@eecs.umich.edu        o3/btb.cc
1034494Ssaidi@eecs.umich.edu        o3/commit.cc
1044496Ssaidi@eecs.umich.edu        o3/decode.cc
1054504Ssaidi@eecs.umich.edu        o3/fetch.cc
1064504Ssaidi@eecs.umich.edu        o3/free_list.cc
1074500Sbinkertn@umich.edu        o3/cpu.cc
1084500Sbinkertn@umich.edu        o3/iew.cc
1094496Ssaidi@eecs.umich.edu        o3/inst_queue.cc
1104496Ssaidi@eecs.umich.edu        o3/ldstq.cc
1117739Sgblack@eecs.umich.edu        o3/mem_dep_unit.cc
1124487Sstever@eecs.umich.edu        o3/ras.cc
1134484Sbinkertn@umich.edu        o3/rename.cc
1144484Sbinkertn@umich.edu        o3/rename_map.cc
1154484Sbinkertn@umich.edu        o3/rob.cc
1164484Sbinkertn@umich.edu        o3/sat_counter.cc
1174484Sbinkertn@umich.edu        o3/store_set.cc
1184484Sbinkertn@umich.edu        o3/tournament_pred.cc
1195601Snate@binkert.org        ''')
1205601Snate@binkert.org
1215601Snate@binkert.org# FullCPU sources are included from m5/SConscript since they're not
1225601Snate@binkert.org# below this point in the file hierarchy.
1234484Sbinkertn@umich.edu
1246121Snate@binkert.org# Convert file names to SCons File objects.  This takes care of the
1256121Snate@binkert.org# path relative to the top of the directory tree.
1266121Snate@binkert.orgsources = [File(s) for s in sources]
1274494Ssaidi@eecs.umich.edu
128Return('sources')
129
130