SConscript revision 2623
16657Snate@binkert.org# -*- mode:python -*-
211888Sleolson@google.com
36657Snate@binkert.org# Copyright (c) 2006 The Regents of The University of Michigan
46657Snate@binkert.org# All rights reserved.
56657Snate@binkert.org#
66657Snate@binkert.org# Redistribution and use in source and binary forms, with or without
76657Snate@binkert.org# modification, are permitted provided that the following conditions are
86657Snate@binkert.org# met: redistributions of source code must retain the above copyright
96657Snate@binkert.org# notice, this list of conditions and the following disclaimer;
106657Snate@binkert.org# redistributions in binary form must reproduce the above copyright
116657Snate@binkert.org# notice, this list of conditions and the following disclaimer in the
126657Snate@binkert.org# documentation and/or other materials provided with the distribution;
136657Snate@binkert.org# neither the name of the copyright holders nor the names of its
146657Snate@binkert.org# contributors may be used to endorse or promote products derived from
156657Snate@binkert.org# this software without specific prior written permission.
166657Snate@binkert.org#
176657Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
186657Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
196657Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
206657Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
216657Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
226657Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
236657Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
246657Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
256657Snate@binkert.org# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
266657Snate@binkert.org# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
276657Snate@binkert.org# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
286657Snate@binkert.org
2911888Sleolson@google.comimport os
306657Snate@binkert.orgimport os.path
316657Snate@binkert.org
326657Snate@binkert.org# Import build environment variable from SConstruct.
336657Snate@binkert.orgImport('env')
346657Snate@binkert.org
356999Snate@binkert.org#################################################################
368452Snate@binkert.org#
376657Snate@binkert.org# Generate StaticInst execute() method signatures.
386657Snate@binkert.org#
396657Snate@binkert.org# There must be one signature for each CPU model compiled in.
406657Snate@binkert.org# Since the set of compiled-in models is flexible, we generate a
416657Snate@binkert.org# header containing the appropriate set of signatures on the fly.
426657Snate@binkert.org#
439219Spower.jg@gmail.com#################################################################
448454Snate@binkert.org
458454Snate@binkert.org# CPU model-specific data is contained in cpu_models.py
468453Snate@binkert.org# Convert to SCons File node to get path handling
476999Snate@binkert.orgmodels_db = File('cpu_models.py')
489219Spower.jg@gmail.com# slurp in contents of file
496999Snate@binkert.orgexecfile(models_db.srcnode().abspath)
508454Snate@binkert.org
518454Snate@binkert.org# Template for execute() signature.
528454Snate@binkert.orgexec_sig_template = '''
538454Snate@binkert.orgvirtual Fault execute(%s *xc, Trace::InstRecord *traceData) const = 0;
548454Snate@binkert.orgvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const
558454Snate@binkert.org{ panic("initiateAcc not defined!"); };
568454Snate@binkert.orgvirtual Fault completeAcc(Packet *pkt, %s *xc,
578453Snate@binkert.org                          Trace::InstRecord *traceData) const
588453Snate@binkert.org{ panic("completeAcc not defined!"); };
598453Snate@binkert.org'''
608453Snate@binkert.org
616999Snate@binkert.org# Generate header.  
626999Snate@binkert.orgdef gen_cpu_exec_signatures(target, source, env):
636999Snate@binkert.org    f = open(str(target[0]), 'w')
646999Snate@binkert.org    print >> f, '''
656657Snate@binkert.org#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__
668453Snate@binkert.org#define __CPU_STATIC_INST_EXEC_SIGS_HH__
678454Snate@binkert.org'''
686657Snate@binkert.org    for cpu in env['CPU_MODELS']:
699219Spower.jg@gmail.com        xc_type = CpuModel.dict[cpu].strings['CPU_exec_context']
709219Spower.jg@gmail.com        print >> f, exec_sig_template % (xc_type, xc_type, xc_type)
716657Snate@binkert.org    print >> f, '''
728453Snate@binkert.org#endif  // __CPU_STATIC_INST_EXEC_SIGS_HH__
738453Snate@binkert.org'''
746657Snate@binkert.org
756657Snate@binkert.org# Generate string that gets printed when header is rebuilt
7611283Santhony.gutierrez@amd.comdef gen_sigs_string(target, source, env):
776657Snate@binkert.org    return "Generating static_inst_exec_sigs.hh: " \
788454Snate@binkert.org           + ', '.join(env['CPU_MODELS'])
796657Snate@binkert.org
806714Ssteve.reinhardt@amd.com# Add command to generate header to environment.
816657Snate@binkert.orgenv.Command('static_inst_exec_sigs.hh', models_db,
826657Snate@binkert.org            Action(gen_cpu_exec_signatures, gen_sigs_string,
836657Snate@binkert.org                   varlist = ['CPU_MODELS']))
846657Snate@binkert.org
856657Snate@binkert.org#################################################################
866657Snate@binkert.org#
876657Snate@binkert.org# Include CPU-model-specific files based on set of models
886657Snate@binkert.org# specified in CPU_MODELS build option.
896657Snate@binkert.org#
906657Snate@binkert.org#################################################################
916657Snate@binkert.org
926657Snate@binkert.orgsources = []
936657Snate@binkert.org
946657Snate@binkert.orgneed_simple_base = False
956657Snate@binkert.orgif 'AtomicSimpleCPU' in env['CPU_MODELS']:
966657Snate@binkert.org    need_simple_base = True
976657Snate@binkert.org    sources += Split('simple/atomic.cc')
988454Snate@binkert.org
998454Snate@binkert.orgif 'TimingSimpleCPU' in env['CPU_MODELS']:
1006657Snate@binkert.org    need_simple_base = True
1016657Snate@binkert.org    sources += Split('simple/timing.cc')
1026657Snate@binkert.org
1036657Snate@binkert.orgif need_simple_base:
1046657Snate@binkert.org    sources += Split('simple/base.cc')
1056657Snate@binkert.org
1066657Snate@binkert.orgif 'FastCPU' in env['CPU_MODELS']:
1076657Snate@binkert.org    sources += Split('fast/cpu.cc')
1086657Snate@binkert.org
1098086SBrad.Beckmann@amd.comif 'AlphaFullCPU' in env['CPU_MODELS']:
1106657Snate@binkert.org    sources += Split('''
1117567SBrad.Beckmann@amd.com        o3/2bit_local_pred.cc
1126657Snate@binkert.org        o3/alpha_dyn_inst.cc
1136657Snate@binkert.org        o3/alpha_cpu.cc
11410981SBrad.Beckmann@amd.com        o3/alpha_cpu_builder.cc
1156657Snate@binkert.org        o3/bpred_unit.cc
11614097Spfotouhi@ucdavis.edu        o3/btb.cc
1176882SBrad.Beckmann@amd.com        o3/commit.cc
1186657Snate@binkert.org        o3/decode.cc
1197839Snilay@cs.wisc.edu        o3/fetch.cc
1207839Snilay@cs.wisc.edu        o3/free_list.cc
1216657Snate@binkert.org        o3/cpu.cc
1226657Snate@binkert.org        o3/iew.cc
1236657Snate@binkert.org        o3/inst_queue.cc
1246657Snate@binkert.org        o3/ldstq.cc
1257839Snilay@cs.wisc.edu        o3/mem_dep_unit.cc
1266657Snate@binkert.org        o3/ras.cc
1276657Snate@binkert.org        o3/rename.cc
1286657Snate@binkert.org        o3/rename_map.cc
1296657Snate@binkert.org        o3/rob.cc
1306657Snate@binkert.org        o3/sat_counter.cc
1316657Snate@binkert.org        o3/store_set.cc
1326657Snate@binkert.org        o3/tournament_pred.cc
1336657Snate@binkert.org        ''')
1349692Snilay@cs.wisc.edu
1356657Snate@binkert.org# FullCPU sources are included from m5/SConscript since they're not
1366657Snate@binkert.org# below this point in the file hierarchy.
1376657Snate@binkert.org
1386657Snate@binkert.org# Convert file names to SCons File objects.  This takes care of the
1396657Snate@binkert.org# path relative to the top of the directory tree.
1406657Snate@binkert.orgsources = [File(s) for s in sources]
1416657Snate@binkert.org
1426657Snate@binkert.orgReturn('sources')
1436657Snate@binkert.org
1446657Snate@binkert.org