Skip to content

Commit f733969

Browse files
committed
Using yosys-slang plugin, works like a charm!
1 parent e893b42 commit f733969

1 file changed

Lines changed: 17 additions & 15 deletions

File tree

tests/test_yosys.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def run_yosys(dlist):
66

77
yosys_template = """
88
# Read the Verilog source file
9-
read_verilog_file_list -f {{ cmdfile }}
9+
read_slang -f {{ cmdfile }} --top {{ topmodule }}
1010
1111
# Set the top module
1212
hierarchy -top {{ topmodule }}
@@ -27,33 +27,32 @@ def run_yosys(dlist):
2727
name = item.name()
2828
cmdfile = f'{name}.f'
2929
netlist = f'{name}.vg'
30-
# create .f cmd file
30+
31+
# create -f cmd file
3132
item.write_fileset(cmdfile, fileset='rtl')
3233
topmodule = item.get_topmodule(fileset='rtl')
3334

34-
# clean up cmd file (yosys bug)
35-
cleanfile = cmdfile + ".clean"
36-
37-
with open(cmdfile, "r") as f_in, open(cleanfile, "w") as f_out:
38-
for line in f_in:
39-
if "//" not in line.strip():
40-
f_out.write(line)
41-
42-
# create yosys script
35+
# create yosys script from template
4336
context = {
4437
'topmodule': topmodule,
45-
'cmdfile': cleanfile,
38+
'cmdfile': cmdfile,
4639
'netlist' : netlist
4740
}
4841
output = template.render(context)
4942
script = f"{name}.ys"
5043
with open(script, 'w') as f:
5144
f.write(output)
52-
# get results
53-
result = subprocess.run(["yosys", "-s", script],
45+
46+
# run yosys
47+
cmd = ["yosys",
48+
"-m", "slang",
49+
"-s", script]
50+
print(' '.join(cmd))
51+
result = subprocess.run(cmd,
5452
check=True,
5553
capture_output=True,
5654
text=True)
55+
5756
#grab stats here if you like
5857
#print(result)
5958

@@ -63,5 +62,8 @@ def test_yosys_basic():
6362
def test_yosys_memory():
6463
run_yosys(common.memory_list)
6564

66-
def test_icarus_arithmetic():
65+
def test_yosys_arithmetic():
6766
run_yosys(common.arithmetic_list)
67+
68+
def test_yosys_blocks():
69+
run_yosys(common.block_list)

0 commit comments

Comments
 (0)