YosysHQ / eqy

Equivalence checking with Yosys
https://yosyshq.readthedocs.io/projects/eqy/en/latest/
Other
29 stars 5 forks source link

Bug in parsing partitions #36

Closed nasahlpa closed 1 year ago

nasahlpa commented 1 year ago

Hi,

I am trying to do equivalence checking (Yosys 0.29 and EQY cc91b457efbebedeb6a24cf787b48eaa41741cbe) with the module attached in the zip file:

$ make
EQY 15:51:21 [script] read_gate: Warning: Replacing memory \mem with list of registers. See ibex_error.v:9281, ibex_error.v:9255
EQY 15:51:23 [script] read_gold: finished (returncode=0)
EQY 15:51:23 [script] read_gate: finished (returncode=0)
EQY 15:51:23 [script] combine: starting process "yosys -ql script/combine.log script/combine.ys"
EQY 15:51:23 [script] combine: finished (returncode=0)
EQY 15:51:24 [script] partition: starting process "cd script; yosys -ql partition.log partition.ys"
EQY 15:51:38 [script] partition: finished (returncode=0)
Traceback (most recent call last):
  File "/usr/local/bin/eqy", line 1208, in <module>
    main()
  File "/usr/local/bin/eqy", line 1181, in main
    make_scripts(ctx.args, ctx, ctx.job, strategies)
  File "/usr/local/bin/eqy", line 1016, in make_scripts
    cfg.partitions.append(EqyPartition(line, args, cfg, job))
  File "/usr/local/bin/eqy", line 999, in __init__
    for key, value in json.load(f).items():
  File "/usr/lib/python3.10/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid \escape: line 9 column 10 (char 158)
make: *** [Makefile:6: ibex_error] Error 1

The problem is that a generated partition json file contains a backslash:

"outbits": {
      "$1\mstatus_d[5:0]": [0]
    },

Which then cannot be parsed here: https://github.com/YosysHQ/eqy/blob/cc91b457efbebedeb6a24cf787b48eaa41741cbe/src/eqy.py#L999

A quick fix could be to remove all backslashes:

        with open(f"{args.workdir}/partitions/{self.name}.json", "r") as f:
            json_data = f.read()
            json_data = json_data.replace("\\","")
            for key, value in json.loads(json_data).items():

But I am not sure whether the generated json file actually should contain a backslash or not.

Thanks, -Pascal

jix commented 1 year ago

Fixed by #44