SConscript revision 2763
14484Sbinkertn@umich.edu# -*- mode:python -*-
24484Sbinkertn@umich.edu
34484Sbinkertn@umich.edu# Copyright (c) 2006 The Regents of The University of Michigan
44484Sbinkertn@umich.edu# All rights reserved.
54484Sbinkertn@umich.edu#
64484Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without
74484Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are
84484Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright
94484Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer;
104484Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright
114484Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the
124484Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution;
134484Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its
144484Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from
154484Sbinkertn@umich.edu# this software without specific prior written permission.
164484Sbinkertn@umich.edu#
174484Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
184484Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
194484Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
204484Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
214484Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
224484Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
234484Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
244484Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
254484Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
264484Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
274484Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
284484Sbinkertn@umich.edu#
294484Sbinkertn@umich.edu# Authors: Steve Reinhardt
304484Sbinkertn@umich.edu
314494Ssaidi@eecs.umich.eduimport os
324484Sbinkertn@umich.eduimport os.path
336121Snate@binkert.org
344484Sbinkertn@umich.edu# Import build environment variable from SConstruct.
354484Sbinkertn@umich.eduImport('env')
364484Sbinkertn@umich.edu
374484Sbinkertn@umich.edu#################################################################
384781Snate@binkert.org#
394484Sbinkertn@umich.edu# Generate StaticInst execute() method signatures.
404484Sbinkertn@umich.edu#
414484Sbinkertn@umich.edu# There must be one signature for each CPU model compiled in.
424484Sbinkertn@umich.edu# Since the set of compiled-in models is flexible, we generate a
434484Sbinkertn@umich.edu# header containing the appropriate set of signatures on the fly.
444484Sbinkertn@umich.edu#
454484Sbinkertn@umich.edu#################################################################
464484Sbinkertn@umich.edu
474484Sbinkertn@umich.edu# CPU model-specific data is contained in cpu_models.py
484484Sbinkertn@umich.edu# Convert to SCons File node to get path handling
494484Sbinkertn@umich.edumodels_db = File('cpu_models.py')
504484Sbinkertn@umich.edu# slurp in contents of file
514484Sbinkertn@umich.eduexecfile(models_db.srcnode().abspath)
524484Sbinkertn@umich.edu
534484Sbinkertn@umich.edu# Template for execute() signature.
544484Sbinkertn@umich.eduexec_sig_template = '''
554484Sbinkertn@umich.eduvirtual Fault execute(%s *xc, Trace::InstRecord *traceData) const = 0;
564484Sbinkertn@umich.eduvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const
574484Sbinkertn@umich.edu{ panic("initiateAcc not defined!"); };
584484Sbinkertn@umich.eduvirtual Fault completeAcc(Packet *pkt, %s *xc,
594484Sbinkertn@umich.edu                          Trace::InstRecord *traceData) const
604484Sbinkertn@umich.edu{ panic("completeAcc not defined!"); };
614484Sbinkertn@umich.edu'''
624484Sbinkertn@umich.edu
634484Sbinkertn@umich.edumem_ini_sig_template = '''
644484Sbinkertn@umich.eduvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); };
654484Sbinkertn@umich.edu'''
664484Sbinkertn@umich.edu
674484Sbinkertn@umich.edumem_comp_sig_template = '''
684484Sbinkertn@umich.eduvirtual Fault completeAcc(uint8_t *data, %s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); return NoFault; };
694484Sbinkertn@umich.edu'''
704484Sbinkertn@umich.edu
714484Sbinkertn@umich.edu# Generate header.  
724484Sbinkertn@umich.edudef gen_cpu_exec_signatures(target, source, env):
734484Sbinkertn@umich.edu    f = open(str(target[0]), 'w')
744484Sbinkertn@umich.edu    print >> f, '''
754484Sbinkertn@umich.edu#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__
764484Sbinkertn@umich.edu#define __CPU_STATIC_INST_EXEC_SIGS_HH__
774484Sbinkertn@umich.edu'''
784484Sbinkertn@umich.edu    for cpu in env['CPU_MODELS']:
794484Sbinkertn@umich.edu        xc_type = CpuModel.dict[cpu].strings['CPU_exec_context']
804484Sbinkertn@umich.edu        print >> f, exec_sig_template % (xc_type, xc_type, xc_type)
814484Sbinkertn@umich.edu    print >> f, '''
824484Sbinkertn@umich.edu#endif  // __CPU_STATIC_INST_EXEC_SIGS_HH__
834484Sbinkertn@umich.edu'''
844484Sbinkertn@umich.edu
854484Sbinkertn@umich.edu# Generate string that gets printed when header is rebuilt
864484Sbinkertn@umich.edudef gen_sigs_string(target, source, env):
874484Sbinkertn@umich.edu    return "Generating static_inst_exec_sigs.hh: " \
884484Sbinkertn@umich.edu           + ', '.join(env['CPU_MODELS'])
894484Sbinkertn@umich.edu
906121Snate@binkert.org# Add command to generate header to environment.
916121Snate@binkert.orgenv.Command('static_inst_exec_sigs.hh', models_db,
926121Snate@binkert.org            Action(gen_cpu_exec_signatures, gen_sigs_string,
935765Snate@binkert.org                   varlist = ['CPU_MODELS']))
945765Snate@binkert.org
955765Snate@binkert.org# List of suppported CPUs by the Checker.  Errors out if USE_CHECKER=True
965397Ssaidi@eecs.umich.edu# and one of these are not being used.
975274Ssaidi@eecs.umich.eduCheckerSupportedCPUList = ['AlphaO3CPU', 'OzoneCPU']
984494Ssaidi@eecs.umich.edu
994504Ssaidi@eecs.umich.edu#################################################################
1004494Ssaidi@eecs.umich.edu#
1014494Ssaidi@eecs.umich.edu# Include CPU-model-specific files based on set of models
1024496Ssaidi@eecs.umich.edu# specified in CPU_MODELS build option.
1034504Ssaidi@eecs.umich.edu#
1044504Ssaidi@eecs.umich.edu#################################################################
1054500Sbinkertn@umich.edu
1064500Sbinkertn@umich.edusources = []
1074496Ssaidi@eecs.umich.edu
1084496Ssaidi@eecs.umich.eduneed_simple_base = False
1094487Sstever@eecs.umich.eduif 'AtomicSimpleCPU' in env['CPU_MODELS']:
1104487Sstever@eecs.umich.edu    need_simple_base = True
1114484Sbinkertn@umich.edu    sources += Split('simple/atomic.cc')
1124484Sbinkertn@umich.edu
1134484Sbinkertn@umich.eduif 'TimingSimpleCPU' in env['CPU_MODELS']:
1144484Sbinkertn@umich.edu    need_simple_base = True
1154484Sbinkertn@umich.edu    sources += Split('simple/timing.cc')
1164484Sbinkertn@umich.edu
1175601Snate@binkert.orgif need_simple_base:
1185601Snate@binkert.org    sources += Split('simple/base.cc')
1195601Snate@binkert.org
1205601Snate@binkert.orgif 'FastCPU' in env['CPU_MODELS']:
1214484Sbinkertn@umich.edu    sources += Split('fast/cpu.cc')
1226121Snate@binkert.org
1236121Snate@binkert.orgif 'AlphaO3CPU' in env['CPU_MODELS']:
1246121Snate@binkert.org    sources += Split('''
1254494Ssaidi@eecs.umich.edu        base_dyn_inst.cc
126        o3/2bit_local_pred.cc
127        o3/alpha_dyn_inst.cc
128        o3/alpha_cpu.cc
129        o3/alpha_cpu_builder.cc
130        o3/bpred_unit.cc
131        o3/btb.cc
132        o3/commit.cc
133        o3/decode.cc
134        o3/fetch.cc
135        o3/free_list.cc
136        o3/fu_pool.cc
137        o3/cpu.cc
138        o3/iew.cc
139        o3/inst_queue.cc
140        o3/lsq_unit.cc
141        o3/lsq.cc
142        o3/mem_dep_unit.cc
143        o3/ras.cc
144        o3/rename.cc
145        o3/rename_map.cc
146        o3/rob.cc
147        o3/scoreboard.cc
148        o3/store_set.cc
149        o3/tournament_pred.cc
150        ''')
151    if 'CheckerCPU' in env['CPU_MODELS']:
152        sources += Split('checker/o3_builder.cc')
153
154if 'OzoneSimpleCPU' in env['CPU_MODELS']:
155    sources += Split('''
156        ozone/cpu.cc
157        ozone/cpu_builder.cc
158        ozone/dyn_inst.cc
159        ozone/front_end.cc
160        ozone/inorder_back_end.cc
161        ozone/inst_queue.cc
162        ozone/rename_table.cc
163        ''')
164    if 'CheckerCPU' in env['CPU_MODELS']:
165        sources += Split('checker/ozone_builder.cc')
166
167if 'OzoneCPU' in env['CPU_MODELS']:
168    sources += Split('''
169        ozone/lsq_unit.cc
170        ozone/lw_back_end.cc
171        ozone/lw_lsq.cc
172        ''')
173
174if 'CheckerCPU' in env['CPU_MODELS']:
175    sources += Split('checker/cpu.cc')
176    checker_supports = False
177    for i in CheckerSupportedCPUList:
178        if i in env['CPU_MODELS']:
179            checker_supports = True
180    if not checker_supports:
181        print "Checker only supports CPU models %s, please " \
182              "set USE_CHECKER=False or use one of those CPU models" \
183              % CheckerSupportedCPUList
184        Exit(1)
185
186
187# FullCPU sources are included from src/SConscript since they're not
188# below this point in the file hierarchy.
189
190# Convert file names to SCons File objects.  This takes care of the
191# path relative to the top of the directory tree.
192sources = [File(s) for s in sources]
193
194Return('sources')
195
196