-
Notifications
You must be signed in to change notification settings - Fork 0
/
edalize_build.py
executable file
·73 lines (62 loc) · 2.27 KB
/
edalize_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python3
from edalize import *
import os
import glob
import subprocess
build_dir = 'build'
base_dir = os.getcwd()
os.makedirs(build_dir, exist_ok=True)
os.chdir(build_dir)
build_dir = os.getcwd()
base_dir = os.path.relpath(base_dir, build_dir)
def scan_files(path, file_type):
path = os.path.join(base_dir, path)
files = [f for f in glob.iglob(path, recursive=True) if os.path.isfile(f)]
return [{'name': f, 'file_type': file_type} for f in files]
def auto_order(files):
paths = [f['name'] for f in files]
paths = subprocess.check_output(['sv_auto_order', '-i', '../src']+paths).decode().strip().split(' ')
files = []
for p in paths:
f = {'name': p, 'file_type': 'systemVerilogSource'}
if p.endswith('.svh'):
f['is_include_file'] = True
f['include_path'] = os.path.join(base_dir, 'src')
files.append(f)
return files
files = auto_order(scan_files('src/**/*.v', 'systemVerilogSource')
+ scan_files('src/**/*.sv', 'systemVerilogSource')
+ scan_files('src/**/*.svh', 'systemVerilogSource'))
test_files = scan_files('test/**/*.sv', 'systemVerilogSource')
files += test_files
files += scan_files('board/arty/*.sv', 'systemVerilogSource')
files += scan_files('board/arty/*.xdc', 'xdc')
files += scan_files('board/arty/msg_config.tcl', 'tclSource')
constr_files = scan_files('src/**/*.tcl', 'xdc') # TCL constraints
files += constr_files
with open('test_sources.tcl', 'w+') as f:
test_file_names = ' '.join([file['name'] for file in test_files])
f.write('move_files -fileset sim_1 [get_files {' + test_file_names + '}]')
files += [{'name': 'test_sources.tcl', 'file_type': 'tclSource'}]
with open('constr_sources.tcl', 'w+') as f:
file_names = ' '.join([file['name'] for file in constr_files])
f.write('set_property file_type "TCL" [get_files {' + file_names + '}]')
files += [{'name': 'constr_sources.tcl', 'file_type': 'tclSource'}]
tool = 'vivado'
tool_options = {
'vivado': {
'part': 'xc7a100tcsg324-1'
}
}
parameters = {
}
edam = {
'files' : files,
'name' : 'bubbly',
'parameters' : parameters,
'tool_options' : tool_options,
'toplevel' : 'top'
}
backend = get_edatool(tool)(edam=edam, work_root=build_dir)
backend.configure()
# backend.build()