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