SConscript revision 2315
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
292665Ssaidi@eecs.umich.eduimport os
30955SN/Aimport os.path
31955SN/A
32955SN/A# Import build environment variable from SConstruct.
331608SN/AImport('env')
34955SN/A
35955SN/A#################################################################
36955SN/A#
37955SN/A# Generate StaticInst execute() method signatures.
38955SN/A#
39955SN/A# There must be one signature for each CPU model compiled in.
40955SN/A# Since the set of compiled-in models is flexible, we generate a
41955SN/A# header containing the appropriate set of signatures on the fly.
42955SN/A#
43955SN/A#################################################################
44955SN/A
45955SN/A# CPU model-specific data is contained in cpu_models.py
46955SN/A# Convert to SCons File node to get path handling
47955SN/Amodels_db = File('cpu_models.py')
482023SN/A# slurp in contents of file
49955SN/Aexecfile(models_db.srcnode().abspath)
50955SN/A
51955SN/A# Template for execute() signature.
52955SN/Aexec_sig_template = '''
53955SN/Avirtual Fault execute(%s *xc, Trace::InstRecord *traceData) const = 0;
54955SN/A'''
55955SN/A
56955SN/Amem_ini_sig_template = '''
57955SN/Avirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); };
581031SN/A'''
59955SN/A
601388SN/Amem_comp_sig_template = '''
61955SN/Avirtual Fault completeAcc(uint8_t *data, %s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); return NoFault; };
62955SN/A'''
631296SN/A
64955SN/A# Generate header.  
65955SN/Adef gen_cpu_exec_signatures(target, source, env):
66955SN/A    f = open(str(target[0]), 'w')
67955SN/A    print >> f, '''
68955SN/A#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__
69955SN/A#define __CPU_STATIC_INST_EXEC_SIGS_HH__
70955SN/A'''
71955SN/A    for cpu in env['CPU_MODELS']:
72955SN/A        xc_type = CpuModel.dict[cpu].strings['CPU_exec_context']
73955SN/A        print >> f, exec_sig_template % xc_type
74955SN/A        print >> f, mem_ini_sig_template % xc_type
75955SN/A        print >> f, mem_comp_sig_template % xc_type
76955SN/A    print >> f, '''
77955SN/A#endif  // __CPU_STATIC_INST_EXEC_SIGS_HH__
78955SN/A'''
79955SN/A
80955SN/A# Generate string that gets printed when header is rebuilt
81955SN/Adef gen_sigs_string(target, source, env):
82955SN/A    return "Generating static_inst_exec_sigs.hh: " \
832325SN/A           + ', '.join(env['CPU_MODELS'])
841717SN/A
852652Ssaidi@eecs.umich.edu# Add command to generate header to environment.
86955SN/Aenv.Command('static_inst_exec_sigs.hh', models_db,
872736Sktlim@umich.edu            Action(gen_cpu_exec_signatures, gen_sigs_string,
882410SN/A                   varlist = ['CPU_MODELS']))
89955SN/A
902290SN/A#################################################################
91955SN/A#
922683Sktlim@umich.edu# Include CPU-model-specific files based on set of models
932683Sktlim@umich.edu# specified in CPU_MODELS build option.
942669Sktlim@umich.edu#
952568SN/A#################################################################
962568SN/A
972462SN/Asources = []
982568SN/A
992395SN/Aif 'SimpleCPU' in env['CPU_MODELS']:
1002405SN/A    sources += Split('simple/cpu.cc')
101955SN/A
1022811Srdreslin@umich.eduif 'FastCPU' in env['CPU_MODELS']:
1032811Srdreslin@umich.edu    sources += Split('fast/cpu.cc')
1042811Srdreslin@umich.edu
1052811Srdreslin@umich.eduif 'AlphaFullCPU' in env['CPU_MODELS']:
1062811Srdreslin@umich.edu    sources += Split('''
1072811Srdreslin@umich.edu        o3/2bit_local_pred.cc
1082811Srdreslin@umich.edu        o3/alpha_dyn_inst.cc
1092811Srdreslin@umich.edu        o3/alpha_cpu.cc
1102811Srdreslin@umich.edu        o3/alpha_cpu_builder.cc
1112811Srdreslin@umich.edu        o3/bpred_unit.cc
1122811Srdreslin@umich.edu        o3/btb.cc
1132811Srdreslin@umich.edu        o3/commit.cc
1142811Srdreslin@umich.edu        o3/decode.cc
1152811Srdreslin@umich.edu        o3/fetch.cc
1162811Srdreslin@umich.edu        o3/free_list.cc
1172811Srdreslin@umich.edu        o3/fu_pool.cc
1182814Srdreslin@umich.edu        o3/cpu.cc
1192811Srdreslin@umich.edu        o3/iew.cc
1202811Srdreslin@umich.edu        o3/inst_queue.cc
1212811Srdreslin@umich.edu        o3/lsq_unit.cc
1222811Srdreslin@umich.edu        o3/lsq.cc
1232811Srdreslin@umich.edu        o3/mem_dep_unit.cc
1242811Srdreslin@umich.edu        o3/ras.cc
1252811Srdreslin@umich.edu        o3/rename.cc
1262813Srdreslin@umich.edu        o3/rename_map.cc
1272813Srdreslin@umich.edu        o3/rob.cc
128955SN/A        o3/sat_counter.cc
129955SN/A        o3/scoreboard.cc
130955SN/A        o3/store_set.cc
1312090SN/A        o3/tournament_pred.cc
132955SN/A        ''')
1332763Sstever@eecs.umich.edu
134955SN/Aif 'OzoneSimpleCPU' in env['CPU_MODELS']:
1351696SN/A    sources += Split('''
136955SN/A        ozone/cpu.cc
137955SN/A        ozone/cpu_builder.cc
138955SN/A        ozone/dyn_inst.cc
1391127SN/A        ozone/front_end.cc
140955SN/A        ozone/inorder_back_end.cc
141955SN/A        ozone/inst_queue.cc
1422379SN/A        ozone/rename_table.cc
143955SN/A        ''')
144955SN/A
145955SN/Aif 'OzoneCPU' in env['CPU_MODELS']:
1462155SN/A    sources += Split('''
1472155SN/A        ozone/back_end.cc
1482155SN/A        ozone/lsq_unit.cc
1492155SN/A        ozone/lw_back_end.cc
1502155SN/A        ozone/lw_lsq.cc
1512155SN/A        ''')
1522155SN/A
1532155SN/Aif 'CheckerCPU' in env['CPU_MODELS']:
1542155SN/A    sources += Split('''
1552155SN/A        checker/cpu.cc
1562155SN/A        checker/cpu_builder.cc
1572155SN/A        checker/o3_cpu_builder.cc
1582155SN/A        ''')
1592155SN/A
1602155SN/A# FullCPU sources are included from m5/SConscript since they're not
1612155SN/A# below this point in the file hierarchy.
1622155SN/A
1632155SN/A# Convert file names to SCons File objects.  This takes care of the
1642155SN/A# path relative to the top of the directory tree.
1652155SN/Asources = [File(s) for s in sources]
1662155SN/A
1672155SN/AReturn('sources')
1682155SN/A
1692155SN/A