forked from pulp-platform/pulp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-scripts
executable file
·109 lines (88 loc) · 4.17 KB
/
generate-scripts
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env python3
# Francesco Conti <[email protected]>
#
# Copyright (C) 2016-2018 ETH Zurich, University of Bologna.
# All rights reserved.
from ipstools_cfg import *
import fileinput
import argparse
parser = argparse.ArgumentParser(
prog='PULP generate script',
description="""generate build/compile/synthesis scripts for PULPissimo""")
parser.add_argument('--rt-dpi', action='store_true',
help="""Use the PULP Runtime DPI to emulate peripherals""")
parser.add_argument('--i2c-vip', action='store_true',
help="""Use the i2c model (24FC1025).
Needs to be installed.""")
parser.add_argument('--flash-vip', action='store_true',
help="""Use the flash model (S25FS256).
Needs to be installed.""")
parser.add_argument('--i2s-vip', action='store_true',
help="""Use the i2s model (24FC1025).
Needs to be installed.""")
parser.add_argument('--verbose', action='store_true',
help='Show more information about commands')
args = parser.parse_args()
execute("mkdir -p sim/vcompile/ips")
execute("rm -rf sim/vcompile/ips/*")
execute("mkdir -p sim/vcompile/rtl")
execute("rm -rf sim/vcompile/rtl/*")
execute("mkdir -p sim/vcompile/tb")
execute("rm -rf sim/vcompile/tb/*")
execute("mkdir -p fpga/pulpissimo/tcl")
execute("rm -rf fpga/pulpissimo/tcl/*")
execute("mkdir -p sim/ncompile/ips")
execute("rm -rf sim/ncompile/ips/*")
execute("mkdir -p sim/ncompile/rtl")
execute("rm -rf sim/ncompile/rtl/*")
execute("mkdir -p sim/ncompile/tb")
execute("rm -rf sim/ncompile/tb/*")
# creates an IPApproX database
ipdb = ipstools.IPDatabase(rtl_dir='rtl', ips_dir='ips', vsim_dir='sim',
load_cache=True, verbose=args.verbose)
# setting defines
if args.rt_dpi:
ipdb.rtl_dic['tb'].sub_ips['tb'].defines = ['USE_DPI']
# handling VIPs
# assume by default that the user didn't install the proprietary VIPs so we
# remove the IP keys
if not args.i2c_vip:
del (ipdb.rtl_dic['vip'].sub_ips['24FC1025_model'])
if not args.flash_vip:
del (ipdb.rtl_dic['vip'].sub_ips['S25FS256_model'])
if not args.i2s_vip:
del (ipdb.rtl_dic['vip'].sub_ips['i2s_model'])
# generate ModelSim/QuestaSim compilation scripts
ipdb.export_make(script_path="sim/vcompile/ips")
ipdb.export_make(script_path="sim/vcompile/rtl", source='rtl')
# generate vsim.tcl with ModelSim/QuestaSim "linking" script
ipdb.generate_vsim_tcl("sim/tcl_files/config/vsim_ips.tcl")
ipdb.generate_vsim_tcl("sim/tcl_files/config/vsim_rtl.tcl", source='rtl')
# generate script to compile all IPs for ModelSim/QuestaSim
ipdb.generate_makefile("sim/vcompile/ips.mk")
ipdb.generate_makefile("sim/vcompile/rtl.mk", source='rtl')
# generate XCELIUM compilation scripts
ipdb.export_make(script_path="sim/ncompile/ips", simulator='ncsim')
ipdb.export_make(script_path="sim/ncompile/rtl", simulator='ncsim', source='rtl')
ipdb.generate_makefile("sim/ncompile/ips.mk")
ipdb.generate_makefile("sim/ncompile/rtl.mk", source='rtl')
ipdb.generate_ncsim_command_list(script_path="./sim/ncompile/src_ips_files.f",
root='.', source='ips')
ipdb.generate_ncsim_command_list(script_path="./sim/ncompile/src_rtl_files.f",
root='.', source='rtl')
# small hack to remove bad tb files until changes propagate
# this is sed -i '/tb\/tb_hwpe/d' sim/ncompile/src_ips_files.f
for line in fileinput.input("sim/ncompile/src_ips_files.f", inplace=True):
line = line.strip('\n')
if not 'tb/tb_hwpe' in line:
print(line)
# Generate FPGA scripts
# generate Vivado src_files.tcl
ipdb.export_vivado(script_path="fpga/pulpissimo/tcl/ips_src_files.tcl", domain='soc')
ipdb.export_vivado(script_path="fpga/pulpissimo/tcl/rtl_src_files.tcl", domain='soc', source='rtl')
# generate Vivado add_files.tcl
ipdb.generate_vivado_add_files("fpga/pulpissimo/tcl/ips_add_files.tcl", domain='soc')
ipdb.generate_vivado_add_files("fpga/pulpissimo/tcl/rtl_add_files.tcl", domain='soc', source='rtl')
# generate Vivado inc_dirs.tcl
ipdb.generate_vivado_inc_dirs("fpga/pulpissimo/tcl/ips_inc_dirs.tcl", domain='soc')
print(tcolors.OK + "Generated new scripts for IPs!" + tcolors.ENDC)