SConscript revision 2652
16157Snate@binkert.org# -*- mode:python -*-
26157Snate@binkert.org
36157Snate@binkert.org# Copyright (c) 2006 The Regents of The University of Michigan
46157Snate@binkert.org# All rights reserved.
56157Snate@binkert.org#
66157Snate@binkert.org# Redistribution and use in source and binary forms, with or without
76157Snate@binkert.org# modification, are permitted provided that the following conditions are
86157Snate@binkert.org# met: redistributions of source code must retain the above copyright
96157Snate@binkert.org# notice, this list of conditions and the following disclaimer;
106157Snate@binkert.org# redistributions in binary form must reproduce the above copyright
116157Snate@binkert.org# notice, this list of conditions and the following disclaimer in the
126157Snate@binkert.org# documentation and/or other materials provided with the distribution;
136157Snate@binkert.org# neither the name of the copyright holders nor the names of its
146157Snate@binkert.org# contributors may be used to endorse or promote products derived from
156157Snate@binkert.org# this software without specific prior written permission.
166157Snate@binkert.org#
176157Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
186157Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
196157Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
206157Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
216157Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
226157Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
236157Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
246157Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
256157Snate@binkert.org# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
266157Snate@binkert.org# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
276157Snate@binkert.org# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
286157Snate@binkert.org
296157Snate@binkert.orgimport os
306157Snate@binkert.orgimport os.path
316157Snate@binkert.org
326157Snate@binkert.org# Import build environment variable from SConstruct.
336157Snate@binkert.orgImport('env')
346157Snate@binkert.org
356157Snate@binkert.org#################################################################
366157Snate@binkert.org#
376157Snate@binkert.org# Generate StaticInst execute() method signatures.
386157Snate@binkert.org#
396157Snate@binkert.org# There must be one signature for each CPU model compiled in.
406168Snate@binkert.org# Since the set of compiled-in models is flexible, we generate a
416168Snate@binkert.org# header containing the appropriate set of signatures on the fly.
426168Snate@binkert.org#
436286Snate@binkert.org#################################################################
446157Snate@binkert.org
456157Snate@binkert.org# CPU model-specific data is contained in cpu_models.py
466157Snate@binkert.org# Convert to SCons File node to get path handling
476157Snate@binkert.orgmodels_db = File('cpu_models.py')
486157Snate@binkert.org# slurp in contents of file
496157Snate@binkert.orgexecfile(models_db.srcnode().abspath)
506157Snate@binkert.org
516157Snate@binkert.org# Template for execute() signature.
526157Snate@binkert.orgexec_sig_template = '''
536157Snate@binkert.orgvirtual Fault execute(%s *xc, Trace::InstRecord *traceData) const = 0;
546157Snate@binkert.orgvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const
556157Snate@binkert.org{ panic("initiateAcc not defined!"); };
566157Snate@binkert.orgvirtual Fault completeAcc(Packet *pkt, %s *xc,
576157Snate@binkert.org                          Trace::InstRecord *traceData) const
586157Snate@binkert.org{ panic("completeAcc not defined!"); };
596157Snate@binkert.org'''
606157Snate@binkert.org
616157Snate@binkert.org# Generate header.  
626157Snate@binkert.orgdef gen_cpu_exec_signatures(target, source, env):
636157Snate@binkert.org    f = open(str(target[0]), 'w')
646157Snate@binkert.org    print >> f, '''
656157Snate@binkert.org#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__
666157Snate@binkert.org#define __CPU_STATIC_INST_EXEC_SIGS_HH__
676157Snate@binkert.org'''
686157Snate@binkert.org    for cpu in env['CPU_MODELS']:
696157Snate@binkert.org        xc_type = CpuModel.dict[cpu].strings['CPU_exec_context']
706157Snate@binkert.org        print >> f, exec_sig_template % (xc_type, xc_type, xc_type)
716157Snate@binkert.org    print >> f, '''
726157Snate@binkert.org#endif  // __CPU_STATIC_INST_EXEC_SIGS_HH__
736157Snate@binkert.org'''
746157Snate@binkert.org
756157Snate@binkert.org# Generate string that gets printed when header is rebuilt
766157Snate@binkert.orgdef gen_sigs_string(target, source, env):
776157Snate@binkert.org    return "Generating static_inst_exec_sigs.hh: " \
786157Snate@binkert.org           + ', '.join(env['CPU_MODELS'])
796157Snate@binkert.org
806157Snate@binkert.org# Add command to generate header to environment.
816157Snate@binkert.orgenv.Command('static_inst_exec_sigs.hh', models_db,
826157Snate@binkert.org            Action(gen_cpu_exec_signatures, gen_sigs_string,
836157Snate@binkert.org                   varlist = ['CPU_MODELS']))
846157Snate@binkert.org
856157Snate@binkert.org#################################################################
866157Snate@binkert.org#
876157Snate@binkert.org# Include CPU-model-specific files based on set of models
886157Snate@binkert.org# specified in CPU_MODELS build option.
896157Snate@binkert.org#
906157Snate@binkert.org#################################################################
916157Snate@binkert.org
926157Snate@binkert.orgsources = []
936157Snate@binkert.org
946157Snate@binkert.orgneed_simple_base = False
956157Snate@binkert.orgif 'AtomicSimpleCPU' in env['CPU_MODELS']:
966157Snate@binkert.org    need_simple_base = True
976157Snate@binkert.org    sources += Split('simple/atomic.cc')
986286Snate@binkert.org
996286Snate@binkert.orgif 'TimingSimpleCPU' in env['CPU_MODELS']:
1006286Snate@binkert.org    need_simple_base = True
1016286Snate@binkert.org    sources += Split('simple/timing.cc')
1026286Snate@binkert.org
1036286Snate@binkert.orgif need_simple_base:
1046157Snate@binkert.org    sources += Split('simple/base.cc')
1056157Snate@binkert.org
1066157Snate@binkert.orgif 'FastCPU' in env['CPU_MODELS']:
1076157Snate@binkert.org    sources += Split('fast/cpu.cc')
1086157Snate@binkert.org
1096286Snate@binkert.orgif 'AlphaFullCPU' in env['CPU_MODELS']:
1106157Snate@binkert.org    sources += Split('''
1116286Snate@binkert.org        o3/2bit_local_pred.cc
1126157Snate@binkert.org        o3/alpha_dyn_inst.cc
1136157Snate@binkert.org        o3/alpha_cpu.cc
1146157Snate@binkert.org        o3/alpha_cpu_builder.cc
1156157Snate@binkert.org        o3/bpred_unit.cc
1166157Snate@binkert.org        o3/btb.cc
1176797SBrad.Beckmann@amd.com        o3/commit.cc
1186157Snate@binkert.org        o3/decode.cc
1196157Snate@binkert.org        o3/fetch.cc
1206157Snate@binkert.org        o3/free_list.cc
121        o3/cpu.cc
122        o3/iew.cc
123        o3/inst_queue.cc
124        o3/ldstq.cc
125        o3/mem_dep_unit.cc
126        o3/ras.cc
127        o3/rename.cc
128        o3/rename_map.cc
129        o3/rob.cc
130        o3/sat_counter.cc
131        o3/store_set.cc
132        o3/tournament_pred.cc
133        ''')
134
135# FullCPU sources are included from m5/SConscript since they're not
136# below this point in the file hierarchy.
137
138# Convert file names to SCons File objects.  This takes care of the
139# path relative to the top of the directory tree.
140sources = [File(s) for s in sources]
141
142Return('sources')
143
144