SConscript revision 2932:eba74420a01c
16019Shines@cs.fsu.edu# -*- mode:python -*-
26019Shines@cs.fsu.edu
313168Smatt.horsnell@arm.com# Copyright (c) 2006 The Regents of The University of Michigan
47100Sgblack@eecs.umich.edu# All rights reserved.
57100Sgblack@eecs.umich.edu#
67100Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
77100Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are
87100Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright
97100Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
107100Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
117100Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
127100Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution;
137100Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its
147100Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from
156019Shines@cs.fsu.edu# this software without specific prior written permission.
166019Shines@cs.fsu.edu#
176019Shines@cs.fsu.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
186019Shines@cs.fsu.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
196019Shines@cs.fsu.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
206019Shines@cs.fsu.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
216019Shines@cs.fsu.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
226019Shines@cs.fsu.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
236019Shines@cs.fsu.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
246019Shines@cs.fsu.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
256019Shines@cs.fsu.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
266019Shines@cs.fsu.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
276019Shines@cs.fsu.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
286019Shines@cs.fsu.edu#
296019Shines@cs.fsu.edu# Authors: Steve Reinhardt
306019Shines@cs.fsu.edu
316019Shines@cs.fsu.eduimport os
326019Shines@cs.fsu.eduimport os.path
336019Shines@cs.fsu.edu
346019Shines@cs.fsu.edu# Import build environment variable from SConstruct.
356019Shines@cs.fsu.eduImport('env')
366019Shines@cs.fsu.edu
376019Shines@cs.fsu.edu#################################################################
386019Shines@cs.fsu.edu#
396019Shines@cs.fsu.edu# Generate StaticInst execute() method signatures.
406019Shines@cs.fsu.edu#
416019Shines@cs.fsu.edu# There must be one signature for each CPU model compiled in.
426757SAli.Saidi@ARM.com# Since the set of compiled-in models is flexible, we generate a
436019Shines@cs.fsu.edu# header containing the appropriate set of signatures on the fly.
446019Shines@cs.fsu.edu#
456019Shines@cs.fsu.edu#################################################################
466019Shines@cs.fsu.edu
476019Shines@cs.fsu.edu# CPU model-specific data is contained in cpu_models.py
4811320Ssteve.reinhardt@amd.com# Convert to SCons File node to get path handling
496019Shines@cs.fsu.edumodels_db = File('cpu_models.py')
509022Sgblack@eecs.umich.edu# slurp in contents of file
516019Shines@cs.fsu.eduexecfile(models_db.srcnode().abspath)
5212640Sgiacomo.travaglini@arm.com
5310037SARM gem5 Developers# Template for execute() signature.
5410037SARM gem5 Developersexec_sig_template = '''
557170Sgblack@eecs.umich.eduvirtual Fault execute(%s *xc, Trace::InstRecord *traceData) const = 0;
566253Sgblack@eecs.umich.eduvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const
5710037SARM gem5 Developers{ panic("initiateAcc not defined!"); };
587202Sgblack@eecs.umich.eduvirtual Fault completeAcc(Packet *pkt, %s *xc,
5910037SARM gem5 Developers                          Trace::InstRecord *traceData) const
606253Sgblack@eecs.umich.edu{ panic("completeAcc not defined!"); };
6110611SAndreas.Sandberg@ARM.com'''
626253Sgblack@eecs.umich.edu
637396Sgblack@eecs.umich.edumem_ini_sig_template = '''
6410037SARM gem5 Developersvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); };
6513168Smatt.horsnell@arm.com'''
668745Sgblack@eecs.umich.edu
677405SAli.Saidi@ARM.commem_comp_sig_template = '''
6810461SAndreas.Sandberg@ARM.comvirtual Fault completeAcc(uint8_t *data, %s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); return NoFault; };
698782Sgblack@eecs.umich.edu'''
708782Sgblack@eecs.umich.edu
718782Sgblack@eecs.umich.edu# Generate a temporary CPU list, including the CheckerCPU if
7210810Sbr@bsdpad.com# it's enabled.  This isn't used for anything else other than StaticInst
7310810Sbr@bsdpad.com# headers.
7410810Sbr@bsdpad.comtemp_cpu_list = env['CPU_MODELS'][:]
757259Sgblack@eecs.umich.edu
768757Sgblack@eecs.umich.eduif env['USE_CHECKER']:
7710461SAndreas.Sandberg@ARM.com    temp_cpu_list.append('CheckerCPU')
788782Sgblack@eecs.umich.edu
798757Sgblack@eecs.umich.edu# Generate header.  
8012531Sandreas.sandberg@arm.comdef gen_cpu_exec_signatures(target, source, env):
818777Sgblack@eecs.umich.edu    f = open(str(target[0]), 'w')
828782Sgblack@eecs.umich.edu    print >> f, '''
838756Sgblack@eecs.umich.edu#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__
8410037SARM gem5 Developers#define __CPU_STATIC_INST_EXEC_SIGS_HH__
8510037SARM gem5 Developers'''
866019Shines@cs.fsu.edu    for cpu in temp_cpu_list:
8712605Sgiacomo.travaglini@arm.com        xc_type = CpuModel.dict[cpu].strings['CPU_exec_context']
886757SAli.Saidi@ARM.com        print >> f, exec_sig_template % (xc_type, xc_type, xc_type)
898757Sgblack@eecs.umich.edu    print >> f, '''
906019Shines@cs.fsu.edu#endif  // __CPU_STATIC_INST_EXEC_SIGS_HH__
918745Sgblack@eecs.umich.edu'''
929384SAndreas.Sandberg@arm.com
936397Sgblack@eecs.umich.edu# Generate string that gets printed when header is rebuilt
9412531Sandreas.sandberg@arm.comdef gen_sigs_string(target, source, env):
958782Sgblack@eecs.umich.edu    return "Generating static_inst_exec_sigs.hh: " \
966019Shines@cs.fsu.edu           + ', '.join(temp_cpu_list)
9710461SAndreas.Sandberg@ARM.com
986397Sgblack@eecs.umich.edu# Add command to generate header to environment.
998335Snate@binkert.orgenv.Command('static_inst_exec_sigs.hh', models_db,
10012531Sandreas.sandberg@arm.com            Action(gen_cpu_exec_signatures, gen_sigs_string,
1019023Sgblack@eecs.umich.edu                   varlist = temp_cpu_list))
1029023Sgblack@eecs.umich.edu
10310461SAndreas.Sandberg@ARM.comenv.Depends('static_inst_exec_sigs.hh', Value(env['USE_CHECKER']))
1048335Snate@binkert.orgenv.Depends('static_inst_exec_sigs.hh', Value(env['CPU_MODELS']))
1056019Shines@cs.fsu.edu
10610196SCurtis.Dunham@arm.com# List of suppported CPUs by the Checker.  Errors out if USE_CHECKER=True
10712222Sgabeblack@google.com# and one of these are not being used.
10813579Sciro.santilli@arm.comCheckerSupportedCPUList = ['O3CPU', 'OzoneCPU']
10913579Sciro.santilli@arm.com
11013579Sciro.santilli@arm.com#################################################################
11113579Sciro.santilli@arm.com#
11213579Sciro.santilli@arm.com# Include CPU-model-specific files based on set of models
11313579Sciro.santilli@arm.com# specified in CPU_MODELS build option.
11413579Sciro.santilli@arm.com#
115#################################################################
116
117# Keep a list of CPU models that support SMT
118env['SMT_CPU_MODELS'] = []
119
120sources = []
121
122need_simple_base = False
123if 'AtomicSimpleCPU' in env['CPU_MODELS']:
124    need_simple_base = True
125    sources += Split('simple/atomic.cc')
126
127if 'TimingSimpleCPU' in env['CPU_MODELS']:
128    need_simple_base = True
129    sources += Split('simple/timing.cc')
130
131if need_simple_base:
132    sources += Split('simple/base.cc')
133
134if 'FastCPU' in env['CPU_MODELS']:
135    sources += Split('fast/cpu.cc')
136
137need_bp_unit = False
138if 'O3CPU' in env['CPU_MODELS']:
139    need_bp_unit = True
140    sources += SConscript('o3/SConscript', exports = 'env')
141    sources += Split('''
142        o3/base_dyn_inst.cc
143        o3/bpred_unit.cc
144        o3/commit.cc
145        o3/decode.cc
146        o3/fetch.cc
147        o3/free_list.cc
148        o3/fu_pool.cc
149        o3/cpu.cc
150        o3/iew.cc
151        o3/inst_queue.cc
152        o3/lsq_unit.cc
153        o3/lsq.cc
154        o3/mem_dep_unit.cc
155        o3/rename.cc
156        o3/rename_map.cc
157        o3/rob.cc
158        o3/scoreboard.cc
159        o3/store_set.cc
160        ''')
161    if env['USE_CHECKER']:
162        sources += Split('o3/checker_builder.cc')
163    else:
164        env['SMT_CPU_MODELS'].append('O3CPU') # Checker doesn't support SMT right now
165
166if 'OzoneCPU' in env['CPU_MODELS']:
167    need_bp_unit = True
168    sources += Split('''
169        ozone/base_dyn_inst.cc
170        ozone/bpred_unit.cc
171        ozone/cpu.cc
172        ozone/cpu_builder.cc
173        ozone/dyn_inst.cc
174        ozone/front_end.cc
175        ozone/lw_back_end.cc
176        ozone/lw_lsq.cc
177        ozone/rename_table.cc
178        ''')
179    if env['USE_CHECKER']:
180        sources += Split('ozone/checker_builder.cc')
181
182if need_bp_unit:
183    sources += Split('''
184        o3/2bit_local_pred.cc
185        o3/btb.cc
186        o3/ras.cc
187        o3/tournament_pred.cc
188        ''')
189
190if env['USE_CHECKER']:
191    sources += Split('checker/cpu.cc')
192    checker_supports = False
193    for i in CheckerSupportedCPUList:
194        if i in env['CPU_MODELS']:
195            checker_supports = True
196    if not checker_supports:
197        print "Checker only supports CPU models",
198        for i in CheckerSupportedCPUList:
199            print i,
200        print ", please set USE_CHECKER=False or use one of those CPU models"              
201        Exit(1)
202
203
204# FullCPU sources are included from src/SConscript since they're not
205# below this point in the file hierarchy.
206
207# Convert file names to SCons File objects.  This takes care of the
208# path relative to the top of the directory tree.
209sources = [File(s) for s in sources]
210
211Return('sources')
212
213