| 1 |
8 |
gdevic |
#!/usr/bin/env python3
|
| 2 |
3 |
gdevic |
#
|
| 3 |
|
|
# This script sets up the environment to run ModelSim on each module.
|
| 4 |
|
|
#
|
| 5 |
|
|
# It sets up a relative path to your specific directory mapping by creating
|
| 6 |
|
|
# a file "mgc_location_map". We use the loction mapping so all paths to source
|
| 7 |
|
|
# files are relative.
|
| 8 |
|
|
#
|
| 9 |
|
|
#-------------------------------------------------------------------------------
|
| 10 |
|
|
# Copyright (C) 2014 Goran Devic
|
| 11 |
|
|
#
|
| 12 |
|
|
# This program is free software; you can redistribute it and/or modify it
|
| 13 |
|
|
# under the terms of the GNU General Public License as published by the Free
|
| 14 |
|
|
# Software Foundation; either version 2 of the License, or (at your option)
|
| 15 |
|
|
# any later version.
|
| 16 |
|
|
#
|
| 17 |
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
| 18 |
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
| 19 |
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
| 20 |
|
|
# more details.
|
| 21 |
|
|
#-------------------------------------------------------------------------------
|
| 22 |
|
|
import os
|
| 23 |
|
|
|
| 24 |
|
|
def setup():
|
| 25 |
|
|
# Create mgc_location_map with relative path mapping
|
| 26 |
|
|
# Assumes this directory hierarchy:
|
| 27 |
|
|
# $ROOT/<block>/<module>/simulation/modelsim/work/<this script>.py
|
| 28 |
|
|
with open("mgc_location_map", "w") as f:
|
| 29 |
|
|
f.write("$ROOT\n")
|
| 30 |
|
|
path = os.path.abspath("../../../.")
|
| 31 |
|
|
f.write(os.path.dirname(path))
|
| 32 |
8 |
gdevic |
print ("Setting up", os.getcwd())
|
| 33 |
3 |
gdevic |
|
| 34 |
|
|
# Return to our current directory after each module has been visited
|
| 35 |
|
|
abspath = os.path.abspath(__file__)
|
| 36 |
|
|
dname = os.path.dirname(abspath)
|
| 37 |
|
|
|
| 38 |
|
|
# Visit each ModelSim project directory...
|
| 39 |
|
|
os.chdir("cpu/alu/simulation/modelsim")
|
| 40 |
|
|
setup()
|
| 41 |
|
|
os.chdir(dname)
|
| 42 |
|
|
|
| 43 |
|
|
os.chdir("cpu/bus/simulation/modelsim")
|
| 44 |
|
|
setup()
|
| 45 |
|
|
os.chdir(dname)
|
| 46 |
|
|
|
| 47 |
|
|
os.chdir("cpu/control/simulation/modelsim")
|
| 48 |
|
|
setup()
|
| 49 |
|
|
os.chdir(dname)
|
| 50 |
|
|
|
| 51 |
|
|
os.chdir("cpu/registers/simulation/modelsim")
|
| 52 |
|
|
setup()
|
| 53 |
|
|
os.chdir(dname)
|
| 54 |
|
|
|
| 55 |
|
|
os.chdir("cpu/toplevel/simulation/modelsim")
|
| 56 |
|
|
setup()
|
| 57 |
|
|
os.chdir(dname)
|
| 58 |
|
|
|
| 59 |
8 |
gdevic |
os.chdir("host/basic_de1/simulation/modelsim")
|
| 60 |
3 |
gdevic |
setup()
|
| 61 |
|
|
os.chdir(dname)
|