Newer
Older
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
#!/usr/bin/env python3
#------------------------------------------------------------------------------------
# HTML Project Generation Script
# - Generates HTML based on all filelist in PROJECT_DIR/flist/project
# A joint work commissioned on behalf of SoC Labs, under Arm Academic Access license.
#
# Contributors
#
# David Mapstone (d.a.mapstone@soton.ac.uk)
# Copyright (c) 2023, SoC Labs (www.soclabs.org)
#------------------------------------------------------------------------------------
import argparse
import subprocess
import os
def top_mod_find(filelist):
# Open Filelist
f = open(filelist, "r")
filelines = f.readlines()
f.close()
# Iterate over file and find first match for DESIGN_TOP in file comments
for line in filelines:
line_list = line.strip().split()
if len(line_list) > 2:
if (line_list[0] == "//") and (line_list[1] == "DESIGN_TOP"):
return line_list[2]
def bootrom_gen():
# Runs Bootrom generation script in NanoSoC Directory
bootrom_scipt_dir = os.getenv("NANOSOC_TECH_DIR")+"/system"
subprocess.run(["make","-C",bootrom_scipt_dir,"bootrom"])
def html_gen(filelist_path):
filelist = os.path.basename(filelist_path)
filelist_name = os.path.splitext(filelist)[0]
print("Generating HTML for: "+filelist_name)
# Find Top-level module name
top_mod = top_mod_find(filelist_path)
# Work out output Directory
outdir = os.getenv("PROJECT_DIR")+"/"+filelist_name+"/html"
print(outdir)
html_scipt_dir = os.getenv("SOCTOOLS_FLOW_DIR")+"/bin/htmlgen"
subprocess.run(["make","-C",html_scipt_dir,"gen_html","TOP_MODULE="+top_mod,"OUT_DIR="+outdir])
def project_gen(args):
# Has filelist option been passed to script
if args.filelist == None:
# Generate bootrom
bootrom_gen()
# Find all filelist in project filelist directory
for filelist in os.listdir(os.getenv("PROJECT_DIR")+"/flist/project"):
filelist_path = os.getenv("PROJECT_DIR")+"/flist/project/"+filelist
html_gen(filelist_path)
else:
if args.bootrom is True:
# Generate bootrom
bootrom_gen()
# Generate HTML for given filelist
html_gen(args.filelist)
if __name__ == "__main__":
# Capture Arguments from Command Line
parser = argparse.ArgumentParser(description='Generates HTML based on all filelist in PROJECT_DIR/flist/project')
parser.add_argument("-f", "--filelist", type=str, help="Generate only from this List", required=False)
parser.add_argument("-b", "--bootrom", action='store_true', help="Generate Bootrom first", required=False)
parser.add_argument("-o", "--output", type=str, help="Output Filelist location", required=False)
args = parser.parse_args()
project_gen(args)