From: Clifford Wolf Date: Sat, 17 Aug 2019 09:29:37 +0000 (+0200) Subject: Add pmgen "fallthrough" statement X-Git-Tag: working-ls180~1124^2~5 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f95853c8228ec8310a1142fe29eea85b765ea3b4;p=yosys.git Add pmgen "fallthrough" statement Signed-off-by: Clifford Wolf --- diff --git a/passes/pmgen/README.md b/passes/pmgen/README.md index be908ef0b..5f6a8ab1b 100644 --- a/passes/pmgen/README.md +++ b/passes/pmgen/README.md @@ -315,6 +315,9 @@ state variables used to pass arguments. Subpatterns cann be called recursively. +If a `subpattern` statement is preceded by a `fallthrough` statement, this is +equivalent to calling the subpattern at the end of the preceding block. + Generate Blocks --------------- diff --git a/passes/pmgen/pmgen.py b/passes/pmgen/pmgen.py index 6950a99c0..8401e1295 100644 --- a/passes/pmgen/pmgen.py +++ b/passes/pmgen/pmgen.py @@ -141,12 +141,23 @@ def process_pmgfile(f, filename): assert current_pattern is not None - if cmd == "subpattern": + if cmd == "fallthrough": block = dict() - block["type"] = "final" - block["pattern"] = (current_pattern, current_subpattern) + block["type"] = "fallthrough" blocks.append(block) line = line.split() + assert len(line) == 1 + continue + + if cmd == "subpattern": + if len(blocks) == 0 or blocks[-1]["type"] != "fallthrough": + block = dict() + block["type"] = "final" + block["pattern"] = (current_pattern, current_subpattern) + blocks.append(block) + elif len(blocks) and blocks[-1]["type"] == "fallthrough": + del blocks[-1] + line = line.split() assert len(line) == 2 current_subpattern = line[1] subpattern_args[(current_pattern, current_subpattern)] = list()