-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
50 lines (36 loc) · 1.09 KB
/
build.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
import sys
import subprocess
import os
def compile(lib, filename, compile_folder):
cmd = "ghdl -a --std=08 --workdir={} --work={} {}".format(compile_folder, lib, filename)
# print(cmd)
subprocess.run(cmd)
def run_tb(lib, filename, compile_folder):
cmd = "ghdl -e --std=08 --workdir={} --work={} {}".format(compile_folder, lib, filename)
# print(cmd)
subprocess.run(cmd)
cmd = "ghdl -r --std=08 --workdir={} --work={} {} --vcd={}.vcd".format(compile_folder, lib, filename, filename)
# print(cmd)
subprocess.run(cmd)
# for i in range(len(sys.argv)):
# print(sys.argv[i])
filename = sys.argv[1]
path = sys.argv[2]
cmd = sys.argv[3]
compile_folder = sys.argv[4] + "\\build"
if not os.path.exists(compile_folder):
os.makedirs(compile_folder)
library = "work"
for folder in path.split("\\"):
#print(folder)
if "_lib" in folder:
library = folder
compile(library, filename, compile_folder)
if "tb_" in filename:
file = filename.split("\\")[-1]
entity = file.split(".")[0]
# print(entity)
run_tb(library, entity, compile_folder)
# print(library)
# if cmd == "compile":
# elif cmd == "run_tb":