mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-24 01:25:33 +00:00
cellhelp: Add default format parse for simcells
Since `simcells.v` uses consistent formatting we can handle it specifically to help tidy up sphinx warnings about the truth tables, and instead chuck them in a code block which when printing to rst. Also has the side effect that rst code blocks can be added manually with `//- ::` followed by a blank line.
This commit is contained in:
parent
a2b2904ed8
commit
57cd8d29db
2 changed files with 31 additions and 4 deletions
|
@ -36,6 +36,24 @@ class SimHelper:
|
|||
val += f'cell_code[{json.dumps(self.name + "+")}] = tempCell;'
|
||||
return val
|
||||
|
||||
def simcells_reparse(cell: SimHelper):
|
||||
# cut manual signature
|
||||
cell.desc = cell.desc[3:]
|
||||
|
||||
# code-block truth table
|
||||
new_desc = []
|
||||
indent = ""
|
||||
for line in cell.desc:
|
||||
if line.startswith("Truth table:"):
|
||||
indent = " "
|
||||
new_desc.pop()
|
||||
new_desc.extend(["::", ""])
|
||||
new_desc.append(indent + line)
|
||||
cell.desc = new_desc
|
||||
|
||||
# set version
|
||||
cell.ver = "2a"
|
||||
|
||||
simHelper = SimHelper()
|
||||
|
||||
for line in fileinput.input():
|
||||
|
@ -62,7 +80,12 @@ for line in fileinput.input():
|
|||
# no module definition, ignore line
|
||||
pass
|
||||
if line.startswith("endmodule"):
|
||||
short_filename = Path(fileinput.filename()).name
|
||||
if simHelper.ver == "1" and short_filename == "simcells.v":
|
||||
# default simcells parsing
|
||||
simcells_reparse(simHelper)
|
||||
if not simHelper.desc:
|
||||
# no help
|
||||
simHelper.desc.append("No help message for this cell type found.\n")
|
||||
print(simHelper)
|
||||
simHelper = SimHelper()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue