110066Sandreas.hansson@arm.com# -*- mode:python -*-
210066Sandreas.hansson@arm.com
310066Sandreas.hansson@arm.com# Copyright (c) 2013 ARM Limited
410066Sandreas.hansson@arm.com# All rights reserved.
510066Sandreas.hansson@arm.com#
610066Sandreas.hansson@arm.com# The license below extends only to copyright in the software and shall
710066Sandreas.hansson@arm.com# not be construed as granting a license to any other intellectual
810066Sandreas.hansson@arm.com# property including but not limited to intellectual property relating
910066Sandreas.hansson@arm.com# to a hardware implementation of the functionality of the software
1010066Sandreas.hansson@arm.com# licensed hereunder.  You may use the software subject to the license
1110066Sandreas.hansson@arm.com# terms below provided that you ensure that this notice is replicated
1210066Sandreas.hansson@arm.com# unmodified and in its entirety in all distributions of the software,
1310066Sandreas.hansson@arm.com# modified or unmodified, in source code or in binary form.
1410066Sandreas.hansson@arm.com#
1510066Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without
1610066Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are
1710066Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright
1810066Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer;
1910066Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright
2010066Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the
2110066Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution;
2210066Sandreas.hansson@arm.com# neither the name of the copyright holders nor the names of its
2310066Sandreas.hansson@arm.com# contributors may be used to endorse or promote products derived from
2410066Sandreas.hansson@arm.com# this software without specific prior written permission.
2510066Sandreas.hansson@arm.com#
2610066Sandreas.hansson@arm.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2710066Sandreas.hansson@arm.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2810066Sandreas.hansson@arm.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2910066Sandreas.hansson@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3010066Sandreas.hansson@arm.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3110066Sandreas.hansson@arm.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3210066Sandreas.hansson@arm.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3310066Sandreas.hansson@arm.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3410066Sandreas.hansson@arm.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3510066Sandreas.hansson@arm.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3610066Sandreas.hansson@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3710066Sandreas.hansson@arm.com#
3810066Sandreas.hansson@arm.com# Authors: Andreas Hansson
3910066Sandreas.hansson@arm.com
4010066Sandreas.hansson@arm.comimport os
4110066Sandreas.hansson@arm.com
4210066Sandreas.hansson@arm.comImport('main')
4310066Sandreas.hansson@arm.com
4410066Sandreas.hansson@arm.com# See if we got a cloned DRAMSim2 repo as a subdirectory and set the
4510066Sandreas.hansson@arm.com# HAVE_DRAMSIM flag accordingly
4610066Sandreas.hansson@arm.comif not os.path.exists(Dir('.').srcnode().abspath + '/DRAMSim2'):
4710066Sandreas.hansson@arm.com    main['HAVE_DRAMSIM'] = False
4810066Sandreas.hansson@arm.com    Return()
4910066Sandreas.hansson@arm.com
5010066Sandreas.hansson@arm.com# We have got the folder, so add the library and build the wrappers
5110066Sandreas.hansson@arm.commain['HAVE_DRAMSIM'] = True
5210066Sandreas.hansson@arm.com
5310066Sandreas.hansson@arm.com# Add the appropriate files. We leave out the trace driven simulator
5410066Sandreas.hansson@arm.comdram_files = []
5510066Sandreas.hansson@arm.com
5610066Sandreas.hansson@arm.comdef DRAMFile(filename):
5710066Sandreas.hansson@arm.com    dram_files.append(File('DRAMSim2/' + filename))
5810066Sandreas.hansson@arm.com
5910066Sandreas.hansson@arm.comDRAMFile('AddressMapping.cpp')
6010066Sandreas.hansson@arm.comDRAMFile('Bank.cpp')
6110066Sandreas.hansson@arm.comDRAMFile('BankState.cpp')
6210066Sandreas.hansson@arm.comDRAMFile('BusPacket.cpp')
6310066Sandreas.hansson@arm.comDRAMFile('ClockDomain.cpp')
6410066Sandreas.hansson@arm.comDRAMFile('CommandQueue.cpp')
6510066Sandreas.hansson@arm.comDRAMFile('IniReader.cpp')
6610066Sandreas.hansson@arm.comDRAMFile('MemoryController.cpp')
6710066Sandreas.hansson@arm.comDRAMFile('MemorySystem.cpp')
6810066Sandreas.hansson@arm.comDRAMFile('MultiChannelMemorySystem.cpp')
6910066Sandreas.hansson@arm.comDRAMFile('Rank.cpp')
7010066Sandreas.hansson@arm.comDRAMFile('SimulatorObject.cpp')
7110066Sandreas.hansson@arm.comDRAMFile('Transaction.cpp')
7210066Sandreas.hansson@arm.com
7310066Sandreas.hansson@arm.com# DRAMSim2 violates some of the warning flags used by gem5, so
7410066Sandreas.hansson@arm.com# we explicitly disable them here
7510066Sandreas.hansson@arm.comdramenv = main.Clone()
7610066Sandreas.hansson@arm.comdramenv.Append(CCFLAGS=['-Wno-unused-value'])
7710066Sandreas.hansson@arm.com
7810130Sandreas.hansson@arm.com# If we are using clang, there are more flags to disable
7910130Sandreas.hansson@arm.comif main['CLANG']:
8011294Sandreas.hansson@arm.com    dramenv.Append(CCFLAGS=['-Wno-unused-private-field',
8111294Sandreas.hansson@arm.com                            '-Wno-tautological-undefined-compare'])
8210130Sandreas.hansson@arm.com
8310066Sandreas.hansson@arm.com# Tell DRAMSim2 to not store any data as this is already covered by
8410066Sandreas.hansson@arm.com# the wrapper
8510066Sandreas.hansson@arm.comdramenv.Append(CCFLAGS=['-DNO_STORAGE'])
8610066Sandreas.hansson@arm.com
8710130Sandreas.hansson@arm.comdramenv.Library('dramsim2', [dramenv.SharedObject(f) for f in dram_files])
8810066Sandreas.hansson@arm.com
8910066Sandreas.hansson@arm.commain.Prepend(CPPPATH=Dir('.'))
9010066Sandreas.hansson@arm.commain.Append(LIBS=['dramsim2'])
9110066Sandreas.hansson@arm.commain.Prepend(LIBPATH=[Dir('.')])
92