From 1e052887a2b0522e0a9418364c15af74b9128886 Mon Sep 17 00:00:00 2001 From: Uri Shaked Date: Sat, 30 Mar 2024 01:12:06 +0300 Subject: [PATCH] fix: yowasp-yosys chokes on complex verilog modules reproduces with https://github.com/Lucaz97/tt06_RNG2 as a workaround, we first try to read the first verilog source file, and only if we can't find the top level verilog module there, we read the rest of the files. --- project.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/project.py b/project.py index 5265dab..d51b8ed 100644 --- a/project.py +++ b/project.py @@ -144,8 +144,13 @@ class Project: source_list = " ".join(sources) json_file = "ports.json" - yosys_cmd = f"yowasp-yosys -qp 'read_verilog -lib -sv {source_list}; hierarchy -top {top} ; proc; write_json {json_file}'" + + # Heuristic - try reading just the first source file, if that fails, try all of them + yosys_cmd = f"yowasp-yosys -qp 'read_verilog -lib -sv {sources[0]}; hierarchy -top {top} ; proc; write_json {json_file}' 2> /dev/null" p = subprocess.run(yosys_cmd, shell=True) + if p.returncode != 0: + yosys_cmd = f"yowasp-yosys -qp 'read_verilog -lib -sv {source_list}; hierarchy -top {top} ; proc; write_json {json_file}'" + p = subprocess.run(yosys_cmd, shell=True) if p.returncode != 0: logging.error(f"yosys port read failed for {self}") exit(1)