SConscript revision 2972
12155SN/A# -*- mode:python -*-
22155SN/A
32155SN/A# Copyright (c) 2006 The Regents of The University of Michigan
42155SN/A# All rights reserved.
52155SN/A#
62155SN/A# Redistribution and use in source and binary forms, with or without
72155SN/A# modification, are permitted provided that the following conditions are
82155SN/A# met: redistributions of source code must retain the above copyright
92155SN/A# notice, this list of conditions and the following disclaimer;
102155SN/A# redistributions in binary form must reproduce the above copyright
112155SN/A# notice, this list of conditions and the following disclaimer in the
122155SN/A# documentation and/or other materials provided with the distribution;
132155SN/A# neither the name of the copyright holders nor the names of its
142155SN/A# contributors may be used to endorse or promote products derived from
152155SN/A# this software without specific prior written permission.
162155SN/A#
172155SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182155SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192155SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202155SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212155SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222155SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232155SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242155SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252155SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262155SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272155SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu#
292665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt
302155SN/A
312155SN/Aimport os
322155SN/Aimport os.path
332155SN/A
342155SN/A# Import build environment variable from SConstruct.
352155SN/AImport('env')
362155SN/A
372178SN/A#################################################################
382178SN/A#
392178SN/A# Generate StaticInst execute() method signatures.
402178SN/A#
412178SN/A# There must be one signature for each CPU model compiled in.
422178SN/A# Since the set of compiled-in models is flexible, we generate a
432178SN/A# header containing the appropriate set of signatures on the fly.
442178SN/A#
452178SN/A#################################################################
462178SN/A
472178SN/A# CPU model-specific data is contained in cpu_models.py
482178SN/A# Convert to SCons File node to get path handling
492155SN/Amodels_db = File('cpu_models.py')
502178SN/A# slurp in contents of file
512155SN/Aexecfile(models_db.srcnode().abspath)
522155SN/A
532178SN/A# Template for execute() signature.
542155SN/Aexec_sig_template = '''
552155SN/Avirtual Fault execute(%s *xc, Trace::InstRecord *traceData) const = 0;
562623SN/Avirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const
572623SN/A{ panic("initiateAcc not defined!"); };
582623SN/Avirtual Fault completeAcc(Packet *pkt, %s *xc,
592623SN/A                          Trace::InstRecord *traceData) const
602623SN/A{ panic("completeAcc not defined!"); };
612155SN/A'''
622155SN/A
632292SN/Amem_ini_sig_template = '''
642292SN/Avirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); };
652292SN/A'''
662292SN/A
672292SN/Amem_comp_sig_template = '''
682292SN/Avirtual Fault completeAcc(uint8_t *data, %s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); return NoFault; };
692292SN/A'''
702292SN/A
712766Sktlim@umich.edu# Generate a temporary CPU list, including the CheckerCPU if
722766Sktlim@umich.edu# it's enabled.  This isn't used for anything else other than StaticInst
732766Sktlim@umich.edu# headers.
742921Sktlim@umich.edutemp_cpu_list = env['CPU_MODELS'][:]
752921Sktlim@umich.edu
762766Sktlim@umich.eduif env['USE_CHECKER']:
772766Sktlim@umich.edu    temp_cpu_list.append('CheckerCPU')
782766Sktlim@umich.edu
792178SN/A# Generate header.  
802155SN/Adef gen_cpu_exec_signatures(target, source, env):
812155SN/A    f = open(str(target[0]), 'w')
822155SN/A    print >> f, '''
832155SN/A#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__
842155SN/A#define __CPU_STATIC_INST_EXEC_SIGS_HH__
852155SN/A'''
862766Sktlim@umich.edu    for cpu in temp_cpu_list:
872155SN/A        xc_type = CpuModel.dict[cpu].strings['CPU_exec_context']
882623SN/A        print >> f, exec_sig_template % (xc_type, xc_type, xc_type)
892155SN/A    print >> f, '''
902155SN/A#endif  // __CPU_STATIC_INST_EXEC_SIGS_HH__
912155SN/A'''
922155SN/A
932178SN/A# Generate string that gets printed when header is rebuilt
942178SN/Adef gen_sigs_string(target, source, env):
952178SN/A    return "Generating static_inst_exec_sigs.hh: " \
962766Sktlim@umich.edu           + ', '.join(temp_cpu_list)
972178SN/A
982178SN/A# Add command to generate header to environment.
992178SN/Aenv.Command('static_inst_exec_sigs.hh', models_db,
1002178SN/A            Action(gen_cpu_exec_signatures, gen_sigs_string,
1012766Sktlim@umich.edu                   varlist = temp_cpu_list))
1022766Sktlim@umich.edu
1032766Sktlim@umich.eduenv.Depends('static_inst_exec_sigs.hh', Value(env['USE_CHECKER']))
1042788Sktlim@umich.eduenv.Depends('static_inst_exec_sigs.hh', Value(env['CPU_MODELS']))
1052178SN/A
1062733Sktlim@umich.edu# List of suppported CPUs by the Checker.  Errors out if USE_CHECKER=True
1072733Sktlim@umich.edu# and one of these are not being used.
1082817Sksewell@umich.eduCheckerSupportedCPUList = ['O3CPU', 'OzoneCPU']
1092733Sktlim@umich.edu
1102178SN/A#################################################################
1112178SN/A#
1122178SN/A# Include CPU-model-specific files based on set of models
1132178SN/A# specified in CPU_MODELS build option.
1142178SN/A#
1152178SN/A#################################################################
1162155SN/A
1172929Sktlim@umich.edu# Keep a list of CPU models that support SMT
1182929Sktlim@umich.eduenv['SMT_CPU_MODELS'] = []
1192929Sktlim@umich.edu
1202155SN/Asources = []
1212155SN/A
1222623SN/Aneed_simple_base = False
1232623SN/Aif 'AtomicSimpleCPU' in env['CPU_MODELS']:
1242623SN/A    need_simple_base = True
1252623SN/A    sources += Split('simple/atomic.cc')
1262623SN/A
1272623SN/Aif 'TimingSimpleCPU' in env['CPU_MODELS']:
1282623SN/A    need_simple_base = True
1292623SN/A    sources += Split('simple/timing.cc')
1302623SN/A
1312623SN/Aif need_simple_base:
1322623SN/A    sources += Split('simple/base.cc')
1332155SN/A
1342155SN/Aif 'FastCPU' in env['CPU_MODELS']:
1352155SN/A    sources += Split('fast/cpu.cc')
1362155SN/A
1372821Sktlim@umich.eduneed_bp_unit = False
1382817Sksewell@umich.eduif 'O3CPU' in env['CPU_MODELS']:
1392821Sktlim@umich.edu    need_bp_unit = True
1402817Sksewell@umich.edu    sources += SConscript('o3/SConscript', exports = 'env')
1412155SN/A    sources += Split('''
1422765Sktlim@umich.edu        o3/base_dyn_inst.cc
1432155SN/A        o3/bpred_unit.cc
1442155SN/A        o3/commit.cc
1452155SN/A        o3/decode.cc
1462155SN/A        o3/fetch.cc
1472155SN/A        o3/free_list.cc
1482292SN/A        o3/fu_pool.cc
1492155SN/A        o3/cpu.cc
1502155SN/A        o3/iew.cc
1512155SN/A        o3/inst_queue.cc
1522292SN/A        o3/lsq_unit.cc
1532292SN/A        o3/lsq.cc
1542155SN/A        o3/mem_dep_unit.cc
1552155SN/A        o3/rename.cc
1562155SN/A        o3/rename_map.cc
1572155SN/A        o3/rob.cc
1582292SN/A        o3/scoreboard.cc
1592155SN/A        o3/store_set.cc
1602155SN/A        ''')
1612766Sktlim@umich.edu    if env['USE_CHECKER']:
1622765Sktlim@umich.edu        sources += Split('o3/checker_builder.cc')
1632932Sktlim@umich.edu    else:
1642932Sktlim@umich.edu        env['SMT_CPU_MODELS'].append('O3CPU') # Checker doesn't support SMT right now
1652155SN/A
1662792Sktlim@umich.eduif 'OzoneCPU' in env['CPU_MODELS']:
1672821Sktlim@umich.edu    need_bp_unit = True
1682292SN/A    sources += Split('''
1692792Sktlim@umich.edu        ozone/base_dyn_inst.cc
1702792Sktlim@umich.edu        ozone/bpred_unit.cc
1712292SN/A        ozone/cpu.cc
1722292SN/A        ozone/cpu_builder.cc
1732292SN/A        ozone/dyn_inst.cc
1742292SN/A        ozone/front_end.cc
1752297SN/A        ozone/lw_back_end.cc
1762297SN/A        ozone/lw_lsq.cc
1772792Sktlim@umich.edu        ozone/rename_table.cc
1782292SN/A        ''')
1792766Sktlim@umich.edu    if env['USE_CHECKER']:
1802765Sktlim@umich.edu        sources += Split('ozone/checker_builder.cc')
1812292SN/A
1822821Sktlim@umich.eduif need_bp_unit:
1832821Sktlim@umich.edu    sources += Split('''
1842821Sktlim@umich.edu        o3/2bit_local_pred.cc
1852821Sktlim@umich.edu        o3/btb.cc
1862821Sktlim@umich.edu        o3/ras.cc
1872821Sktlim@umich.edu        o3/tournament_pred.cc
1882821Sktlim@umich.edu        ''')
1892821Sktlim@umich.edu
1902766Sktlim@umich.eduif env['USE_CHECKER']:
1912789Sktlim@umich.edu    sources += Split('checker/cpu.cc')
1922733Sktlim@umich.edu    checker_supports = False
1932733Sktlim@umich.edu    for i in CheckerSupportedCPUList:
1942733Sktlim@umich.edu        if i in env['CPU_MODELS']:
1952733Sktlim@umich.edu            checker_supports = True
1962733Sktlim@umich.edu    if not checker_supports:
1972874Sktlim@umich.edu        print "Checker only supports CPU models",
1982874Sktlim@umich.edu        for i in CheckerSupportedCPUList:
1992874Sktlim@umich.edu            print i,
2002874Sktlim@umich.edu        print ", please set USE_CHECKER=False or use one of those CPU models"              
2012733Sktlim@umich.edu        Exit(1)
2022733Sktlim@umich.edu
2032315SN/A
2042761Sstever@eecs.umich.edu# FullCPU sources are included from src/SConscript since they're not
2052155SN/A# below this point in the file hierarchy.
2062155SN/A
2072155SN/A# Convert file names to SCons File objects.  This takes care of the
2082155SN/A# path relative to the top of the directory tree.
2092155SN/Asources = [File(s) for s in sources]
2102155SN/A
2112155SN/AReturn('sources')
2122155SN/A
213