forked from openhwgroup/cva6
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparameters_extractor.py
More file actions
107 lines (91 loc) · 3.79 KB
/
parameters_extractor.py
File metadata and controls
107 lines (91 loc) · 3.79 KB
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
# Copyright 2024 Thales DIS France SAS
#
# Licensed under the Solderpad Hardware License, Version 2.1 (the "License");
# you may not use this file except in compliance with the License.
# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
# You may obtain a copy of the License at https://solderpad.org/licenses/
#
# Original Author: Jean-Roch COULON - Thales
#!/usr/bin/env python3
import sys
import os
import re
from classes import Parameter
sys.path.append(os.getcwd() + "/../util")
from user_config import get_config
def parameters_extractor(target):
parameters = {}
file_in = "../core/include/config_pkg.sv"
print("Input file " + file_in)
with open(file_in, "r", encoding="utf-8") as fin:
print_enable = 0
descript = "TO_BE_COMPLETED"
for line in fin:
if "typedef struct packed" in line:
print_enable = 1
if "cva6_user_cfg_t" in line:
print_enable = 0
break
d = re.match(r"^ *(.*) ([\S]*);\n", line)
h = re.match(r"^ *\/\/ (.*)\n", line)
if h and print_enable:
descript = h.group(1)
if d and print_enable:
parameters[d.group(2)] = Parameter(
d.group(1), descript, "TO_BE_COMPLETED"
)
descript = "TO_BE_COMPLETED"
config = get_config(f"../core/include/{target}_config_pkg.sv")
for name, parameter in parameters.items():
parameter.value = config[name]
return parameters
def writeout_parameter_table(fileout, parameters, module):
with open(fileout, "w") as fout:
fout.write("..\n")
fout.write(" Copyright 2024 Thales DIS France SAS\n")
fout.write(
' Licensed under the Solderpad Hardware License, Version 2.1 (the "License");\n'
)
fout.write(
" you may not use this file except in compliance with the License.\n"
)
fout.write(" SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1\n")
fout.write(
" You may obtain a copy of the License at https://solderpad.org/licenses/\n\n"
)
fout.write(" Original Author: Jean-Roch COULON - Thales\n\n")
fout.write(f".. _{module}_PARAMETERS:\n\n")
fout.write(f".. list-table:: {module} parameter configuration\n")
fout.write(" :header-rows: 1\n")
fout.write("\n")
fout.write(" * - Name\n")
fout.write(" - description\n")
fout.write(" - Value\n")
for name in parameters:
fout.write("\n")
fout.write(f" * - {name}\n")
fout.write(f" - {parameters[name].description}\n")
fout.write(f" - {parameters[name].value}\n")
def writeout_parameter_table_adoc(fileout, parameters, module):
with open(fileout, "w") as fout:
fout.write("////\n")
fout.write(" Copyright 2024 Thales DIS France SAS\n")
fout.write(
' Licensed under the Solderpad Hardware License, Version 2.1 (the "License");\n'
)
fout.write(
" you may not use this file except in compliance with the License.\n"
)
fout.write(" SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1\n")
fout.write(
" You may obtain a copy of the License at https://solderpad.org/licenses/\n\n"
)
fout.write(" Original Author: Jean-Roch COULON - Thales\n")
fout.write("////\n\n")
fout.write(f"[[{module}_PARAMETERS]]\n\n")
fout.write(f".{module} parameter configuration\n")
fout.write("|===\n")
fout.write("|Name | description | description\n\n")
for name in parameters:
fout.write(f"|{name} | {parameters[name].description} | {parameters[name].value}\n")
fout.write("|===\n")