SConscript revision 2821
15148SN/A# -*- mode:python -*-
25148SN/A
35148SN/A# Copyright (c) 2006 The Regents of The University of Michigan
410036SAli.Saidi@ARM.com# All rights reserved.
58835SAli.Saidi@ARM.com#
610036SAli.Saidi@ARM.com# Redistribution and use in source and binary forms, with or without
77873SN/A# modification, are permitted provided that the following conditions are
87873SN/A# met: redistributions of source code must retain the above copyright
97873SN/A# notice, this list of conditions and the following disclaimer;
105148SN/A# redistributions in binary form must reproduce the above copyright
115148SN/A# notice, this list of conditions and the following disclaimer in the
125148SN/A# documentation and/or other materials provided with the distribution;
1310315Snilay@cs.wisc.edu# neither the name of the copyright holders nor the names of its
148835SAli.Saidi@ARM.com# contributors may be used to endorse or promote products derived from
159885Sstever@gmail.com# this software without specific prior written permission.
169885Sstever@gmail.com#
1710036SAli.Saidi@ARM.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1811312Santhony.gutierrez@amd.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
198835SAli.Saidi@ARM.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
208835SAli.Saidi@ARM.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2110315Snilay@cs.wisc.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
228835SAli.Saidi@ARM.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2310315Snilay@cs.wisc.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
245148SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
259481Snilay@cs.wisc.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
268673SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2710736Snilay@cs.wisc.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2811219Snilay@cs.wisc.edu#
298721SN/A# Authors: Steve Reinhardt
308835SAli.Saidi@ARM.com
318835SAli.Saidi@ARM.comimport os
327935SN/Aimport os.path
337935SN/A
347935SN/A# Import build environment variable from SConstruct.
357935SN/AImport('env')
367935SN/A
377935SN/A#################################################################
387935SN/A#
398983Snate@binkert.org# Generate StaticInst execute() method signatures.
405148SN/A#
419885Sstever@gmail.com# There must be one signature for each CPU model compiled in.
429885Sstever@gmail.com# Since the set of compiled-in models is flexible, we generate a
439885Sstever@gmail.com# header containing the appropriate set of signatures on the fly.
4410315Snilay@cs.wisc.edu#
4510036SAli.Saidi@ARM.com#################################################################
4610315Snilay@cs.wisc.edu
479885Sstever@gmail.com# CPU model-specific data is contained in cpu_models.py
489885Sstever@gmail.com# Convert to SCons File node to get path handling
495148SN/Amodels_db = File('cpu_models.py')
505148SN/A# slurp in contents of file
519885Sstever@gmail.comexecfile(models_db.srcnode().abspath)
5210315Snilay@cs.wisc.edu
535876SN/A# Template for execute() signature.
549885Sstever@gmail.comexec_sig_template = '''
555148SN/Avirtual Fault execute(%s *xc, Trace::InstRecord *traceData) const = 0;
565876SN/Avirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const
578835SAli.Saidi@ARM.com{ panic("initiateAcc not defined!"); };
585876SN/Avirtual Fault completeAcc(Packet *pkt, %s *xc,
595148SN/A                          Trace::InstRecord *traceData) const
6010036SAli.Saidi@ARM.com{ panic("completeAcc not defined!"); };
618983Snate@binkert.org'''
625148SN/A
635148SN/Amem_ini_sig_template = '''
648835SAli.Saidi@ARM.comvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); };
659481Snilay@cs.wisc.edu'''
665148SN/A
675148SN/Amem_comp_sig_template = '''
685148SN/Avirtual Fault completeAcc(uint8_t *data, %s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); return NoFault; };
695148SN/A'''
705148SN/A
715540SN/A# Generate a temporary CPU list, including the CheckerCPU if
728835SAli.Saidi@ARM.com# it's enabled.  This isn't used for anything else other than StaticInst
735148SN/A# headers.
749885Sstever@gmail.comtemp_cpu_list = env['CPU_MODELS']
755509SN/Aif env['USE_CHECKER']:
765509SN/A    temp_cpu_list.append('CheckerCPU')
7710315Snilay@cs.wisc.edu
789481Snilay@cs.wisc.edu# Generate header.  
795148SN/Adef gen_cpu_exec_signatures(target, source, env):
805148SN/A    f = open(str(target[0]), 'w')
815148SN/A    print >> f, '''
825148SN/A#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__
838983Snate@binkert.org#define __CPU_STATIC_INST_EXEC_SIGS_HH__
848983Snate@binkert.org'''
855148SN/A    for cpu in temp_cpu_list:
869885Sstever@gmail.com        xc_type = CpuModel.dict[cpu].strings['CPU_exec_context']
879885Sstever@gmail.com        print >> f, exec_sig_template % (xc_type, xc_type, xc_type)
889885Sstever@gmail.com    print >> f, '''
899885Sstever@gmail.com#endif  // __CPU_STATIC_INST_EXEC_SIGS_HH__
9010036SAli.Saidi@ARM.com'''
919885Sstever@gmail.com
925148SN/A# Generate string that gets printed when header is rebuilt
936024SN/Adef gen_sigs_string(target, source, env):
948835SAli.Saidi@ARM.com    return "Generating static_inst_exec_sigs.hh: " \
9510036SAli.Saidi@ARM.com           + ', '.join(temp_cpu_list)
965148SN/A
978835SAli.Saidi@ARM.com# Add command to generate header to environment.
988835SAli.Saidi@ARM.comenv.Command('static_inst_exec_sigs.hh', models_db,
998835SAli.Saidi@ARM.com            Action(gen_cpu_exec_signatures, gen_sigs_string,
1008835SAli.Saidi@ARM.com                   varlist = temp_cpu_list))
1019885Sstever@gmail.com
10210036SAli.Saidi@ARM.comenv.Depends('static_inst_exec_sigs.hh', Value(env['USE_CHECKER']))
1039885Sstever@gmail.comenv.Depends('static_inst_exec_sigs.hh', Value(env['CPU_MODELS']))
1048835SAli.Saidi@ARM.com
1058983Snate@binkert.org# List of suppported CPUs by the Checker.  Errors out if USE_CHECKER=True
1068835SAli.Saidi@ARM.com# and one of these are not being used.
1078835SAli.Saidi@ARM.comCheckerSupportedCPUList = ['AlphaO3CPU', 'OzoneCPU']
1088835SAli.Saidi@ARM.com
1099885Sstever@gmail.com#################################################################
11010036SAli.Saidi@ARM.com#
1118835SAli.Saidi@ARM.com# Include CPU-model-specific files based on set of models
1128835SAli.Saidi@ARM.com# specified in CPU_MODELS build option.
1139213Snilay@cs.wisc.edu#
1148835SAli.Saidi@ARM.com#################################################################
1158983Snate@binkert.org
1168983Snate@binkert.orgsources = []
1178983Snate@binkert.org
1185148SN/Aneed_simple_base = False
1199481Snilay@cs.wisc.eduif 'AtomicSimpleCPU' in env['CPU_MODELS']:
1209481Snilay@cs.wisc.edu    need_simple_base = True
12110036SAli.Saidi@ARM.com    sources += Split('simple/atomic.cc')
1229481Snilay@cs.wisc.edu
1235148SN/Aif 'TimingSimpleCPU' in env['CPU_MODELS']:
1246024SN/A    need_simple_base = True
1258835SAli.Saidi@ARM.com    sources += Split('simple/timing.cc')
12610036SAli.Saidi@ARM.com
1275148SN/Aif need_simple_base:
1288835SAli.Saidi@ARM.com    sources += Split('simple/base.cc')
1298835SAli.Saidi@ARM.com
1308835SAli.Saidi@ARM.comif 'FastCPU' in env['CPU_MODELS']:
1318835SAli.Saidi@ARM.com    sources += Split('fast/cpu.cc')
1329885Sstever@gmail.com
13310036SAli.Saidi@ARM.comneed_bp_unit = False
1349885Sstever@gmail.comif 'AlphaO3CPU' in env['CPU_MODELS']:
1358835SAli.Saidi@ARM.com    need_bp_unit = True
1368983Snate@binkert.org    sources += Split('''
1375148SN/A        o3/alpha_dyn_inst.cc
1385148SN/A        o3/alpha_cpu.cc
1395148SN/A        o3/alpha_cpu_builder.cc
14010036SAli.Saidi@ARM.com        o3/base_dyn_inst.cc
1415148SN/A        o3/bpred_unit.cc
1425148SN/A        o3/commit.cc
1435148SN/A        o3/decode.cc
1445148SN/A        o3/fetch.cc
1455148SN/A        o3/free_list.cc
14610645Snilay@cs.wisc.edu        o3/fu_pool.cc
1475148SN/A        o3/cpu.cc
1485148SN/A        o3/iew.cc
1495516SN/A        o3/inst_queue.cc
1505148SN/A        o3/lsq_unit.cc
15110036SAli.Saidi@ARM.com        o3/lsq.cc
15211268Satgutier@umich.edu        o3/mem_dep_unit.cc
1535148SN/A        o3/rename.cc
1545148SN/A        o3/rename_map.cc
15510645Snilay@cs.wisc.edu        o3/rob.cc
1565176SN/A        o3/scoreboard.cc
1575148SN/A        o3/store_set.cc
1585148SN/A        ''')
1595148SN/A    if env['USE_CHECKER']:
1605410SN/A        sources += Split('o3/checker_builder.cc')
1615148SN/A
1625148SN/Aif 'OzoneCPU' in env['CPU_MODELS']:
16310451Snilay@cs.wisc.edu    need_bp_unit = True
1645148SN/A    sources += Split('''
1659885Sstever@gmail.com        ozone/base_dyn_inst.cc
1669885Sstever@gmail.com        ozone/bpred_unit.cc
1679885Sstever@gmail.com        ozone/cpu.cc
16810315Snilay@cs.wisc.edu        ozone/cpu_builder.cc
16910036SAli.Saidi@ARM.com        ozone/dyn_inst.cc
17010315Snilay@cs.wisc.edu        ozone/front_end.cc
1719885Sstever@gmail.com        ozone/lw_back_end.cc
1729885Sstever@gmail.com        ozone/lw_lsq.cc
17310315Snilay@cs.wisc.edu        ozone/rename_table.cc
17410315Snilay@cs.wisc.edu        ''')
17510315Snilay@cs.wisc.edu    if env['USE_CHECKER']:
17610315Snilay@cs.wisc.edu        sources += Split('ozone/checker_builder.cc')
17710315Snilay@cs.wisc.edu
17810315Snilay@cs.wisc.eduif need_bp_unit:
17910315Snilay@cs.wisc.edu    sources += Split('''
18010315Snilay@cs.wisc.edu        o3/2bit_local_pred.cc
1815148SN/A        o3/btb.cc
18210451Snilay@cs.wisc.edu        o3/ras.cc
1839885Sstever@gmail.com        o3/tournament_pred.cc
18410036SAli.Saidi@ARM.com        ''')
18510736Snilay@cs.wisc.edu
18610736Snilay@cs.wisc.eduif env['USE_CHECKER']:
18710736Snilay@cs.wisc.edu    sources += Split('checker/cpu.cc')
18810451Snilay@cs.wisc.edu    checker_supports = False
18910736Snilay@cs.wisc.edu    for i in CheckerSupportedCPUList:
1909583Snilay@cs.wisc.edu        if i in env['CPU_MODELS']:
1917524SN/A            checker_supports = True
19210736Snilay@cs.wisc.edu    if not checker_supports:
1939150SAli.Saidi@ARM.com        print "Checker only supports CPU models %s, please " \
1948983Snate@binkert.org              "set USE_CHECKER=False or use one of those CPU models" \
1955148SN/A              % CheckerSupportedCPUList
1965148SN/A        Exit(1)
1978983Snate@binkert.org
1989373Snilay@cs.wisc.edu
1999885Sstever@gmail.com# FullCPU sources are included from src/SConscript since they're not
2009885Sstever@gmail.com# below this point in the file hierarchy.
20110036SAli.Saidi@ARM.com
2028983Snate@binkert.org# Convert file names to SCons File objects.  This takes care of the
2035540SN/A# path relative to the top of the directory tree.
2045410SN/Asources = [File(s) for s in sources]
2055509SN/A
2065148SN/AReturn('sources')
2078983Snate@binkert.org
2085148SN/A