-
Notifications
You must be signed in to change notification settings - Fork 0
/
xbuild.py
85 lines (63 loc) · 2.1 KB
/
xbuild.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import os
import subprocess
xvlog = "/opt/Xilinx/Vivado/2023.1/bin/xvlog"
xelab = "/opt/Xilinx/Vivado/2023.1/bin/xelab"
xsim = "/opt/Xilinx/Vivado/2023.1/bin/xsim"
class VivadoBuildError(Exception): pass
if not os.access("xsim_run.tcl", os.R_OK):
raise VivadoBuildError("you should pass a build script for us to run!")
print("starting vivado, please wait...")
proc = subprocess.Popen(f"{xvlog} --sv ./hdl/*",
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while True:
line = proc.stdout.readline()
if not line: break
else: print(str(line.rstrip(), encoding='ascii'))
proc.wait()
if proc.returncode != 0:
#save("vivado.log")
raise VivadoBuildError(f"vivado exited with code {proc.returncode}")
else:
pass
#save("vivado.log")
proc = subprocess.Popen(f"{xelab} -svlog ./sim/convolve_audio_tb.sv --debug wave",
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while True:
line = proc.stdout.readline()
if not line: break
else: print(str(line.rstrip(), encoding='ascii'))
proc.wait()
if proc.returncode != 0:
#save("vivado.log")
raise VivadoBuildError(f"vivado exited with code {proc.returncode}")
else:
pass
#save("vivado.log")
proc = subprocess.Popen(f"{xsim} convolve_audio_tb -t xsim_run.tcl",
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while True:
line = proc.stdout.readline()
if not line: break
else: print(str(line.rstrip(), encoding='ascii'))
proc.wait()
if proc.returncode != 0:
#save("vivado.log")
raise VivadoBuildError(f"vivado exited with code {proc.returncode}")
else:
pass
#save("vivado.log")
proc = subprocess.Popen(f"tar -czvf dump.tar.gz dump.vcd",
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while True:
line = proc.stdout.readline()
if not line: break
else: print(str(line.rstrip(), encoding='ascii'))
proc.wait()
#files to look for:
files = [ "dump.tar.gz","dump.vcd"
]
for file in files:
# look for out.bit, because we've hard coded that for now i guess
if not os.access(f"{file}", os.R_OK):
raise VivadoBuildError(f"vivado suite exited successfully, but no {file} generated")
save(f"{file}")