Skip to content

Commit

Permalink
docs table_port_builder.py: black & pylint
Browse files Browse the repository at this point in the history
Signed-off-by: André Sintzoff <[email protected]>
  • Loading branch information
ASintzoff committed Feb 6, 2024
1 parent f383efa commit 8f180fd
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions docs/scripts/table_port_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,23 @@
import re


class portIO:
class PortIO:
def __init__(
self,
name,
direction,
type,
data_type,
description,
connection,
):
self.name = name
self.direction = direction
self.type = type
self.data_type = data_type
self.description = description
self.connection = connection


if __name__ == "__main__":

file = []
file.append("../core/cva6.sv")
file.append("../core/frontend/frontend.sv")
Expand All @@ -41,31 +40,31 @@ def __init__(
file.append("../core/instr_realign.sv")

for filein in file:
a = re.match(".*\/(.*).sv", filein)
a = re.match(r".*\/(.*).sv", filein)
module = a.group(1)
fileout = "./04_cv32a65x_design/source/port_" + module + ".rst"
print("Input file " + filein)
print("Output file " + fileout)
port = []
with open(filein, "r") as fin:
ports = []
with open(filein, "r", encoding="utf-8") as fin:
description = "none"
connection = "none"
for l1 in fin:
e = re.match("^ +(?:(in|out))put ([\S]*(?: [\S]*|)) ([\S]*)\n", l1)
d = re.match("^ +\/\/ (.*) - ([\S]*)\n", l1)
for line in fin:
e = re.match(r"^ +(?:(in|out))put ([\S]*(?: [\S]*|)) ([\S]*)\n", line)
d = re.match(r"^ +\/\/ (.*) - ([\S]*)\n", line)
if d:
description = d.group(1)
connection = d.group(2)
if e:
name = e.group(3)
name = name.split(",")
port.append(
portIO(name[0], e.group(1), e.group(2), description, connection)
ports.append(
PortIO(name[0], e.group(1), e.group(2), description, connection)
)
description = "none"
connection = "none"

with open(fileout, "w") as fout:
with open(fileout, "w", encoding="utf-8") as fout:
fout.write("..\n")
fout.write(" Copyright 2024 Thales DIS France SAS\n")
fout.write(
Expand All @@ -79,19 +78,19 @@ def __init__(
" 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(".. _CVA6_%s:\n\n" % (module))
fout.write(".. list-table:: %s module IO ports\n" % (module))
fout.write(f".. _CVA6_{module}:\n\n")
fout.write(f".. list-table:: {module} module IO ports\n")
fout.write(" :header-rows: 1\n")
fout.write("\n")
fout.write(" * - Signal\n")
fout.write(" - IO\n")
fout.write(" - Connection\n")
fout.write(" - Type\n")
fout.write(" - Description\n")
for i in range(len(port)):
for i, port in enumerate(ports):
fout.write("\n")
fout.write(" * - ``%s``\n" % (port[i].name))
fout.write(" - %s\n" % (port[i].direction))
fout.write(" - %s\n" % (port[i].connection))
fout.write(" - %s\n" % (port[i].type))
fout.write(" - %s\n" % (port[i].description))
fout.write(f" * - ``{port.name}``\n")
fout.write(f" - {port.direction}\n")
fout.write(f" - {port.connection}\n")
fout.write(f" - {port.data_type}\n")
fout.write(f" - {port.description}\n")

0 comments on commit 8f180fd

Please sign in to comment.