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.
This commit is contained in:
Uri Shaked
2024-03-30 01:12:06 +03:00
parent e3fac0ab40
commit 1e052887a2
+6 -1
View File
@@ -144,8 +144,13 @@ class Project:
source_list = " ".join(sources) source_list = " ".join(sources)
json_file = "ports.json" 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) 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: if p.returncode != 0:
logging.error(f"yosys port read failed for {self}") logging.error(f"yosys port read failed for {self}")
exit(1) exit(1)