chipsalliance / fpga-interchange-tests

Repository to run extensive tests on the FPGA interchange format
https://chipsalliance.github.io/fpga-interchange-tests
ISC License
8 stars 9 forks source link

Error trying to convert xcvu095-ffva2104-2-e.device to json #127

Open zhilix opened 2 years ago

zhilix commented 2 years ago

I ran this under python-fpga-interchange:

python3 -m fpga_interchange.convert \
    --schema_dir "/home/local/eda15/zhilix/projects/RapidWright/interchange/fpga-interchange-schema/interchange" \
    --schema device \
    --input_format capnp \
    --output_format json \
    xcvu095-ffva2104-2-e.device \
    xcvu095-ffva2104-2-e.json

and got the error:

Traceback (most recent call last):
  File "/home/polaris/zhilix/.pyenv/versions/3.8.4/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/polaris/zhilix/.pyenv/versions/3.8.4/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/local/eda15/zhilix/projects/python-fpga-interchange/fpga_interchange/convert.py", line 210, in <module>
    main()
  File "/home/local/eda15/zhilix/projects/python-fpga-interchange/fpga_interchange/convert.py", line 206, in main
    write_format(message, args.output_format, out_f)
  File "/home/local/eda15/zhilix/projects/python-fpga-interchange/fpga_interchange/convert.py", line 129, in write_format
    json_data = to_json(message)
  File "/home/local/eda15/zhilix/projects/python-fpga-interchange/fpga_interchange/json_support.py", line 127, in to_json
    return to_writer(struct_reader, JsonWriter)
  File "/home/local/eda15/zhilix/projects/python-fpga-interchange/fpga_interchange/converters.py", line 354, in to_writer
    to_writer(
  File "/home/local/eda15/zhilix/projects/python-fpga-interchange/fpga_interchange/converters.py", line 354, in to_writer
    to_writer(
  File "/home/local/eda15/zhilix/projects/python-fpga-interchange/fpga_interchange/converters.py", line 374, in to_writer
    set_value(field_which, deference_fun(value))
  File "/home/local/eda15/zhilix/projects/python-fpga-interchange/fpga_interchange/converters.py", line 326, in <lambda>
    deference_fun = lambda value: writer.dereference_value(
  File "/home/local/eda15/zhilix/projects/python-fpga-interchange/fpga_interchange/json_support.py", line 50, in dereference_value
    return root_writer.get_field_value(annotation_type.field, value)
  File "/home/local/eda15/zhilix/projects/python-fpga-interchange/fpga_interchange/converters.py", line 79, in get_field_value
    assert value < len(self.value_cache[field]), (field, value)
AssertionError: ('pipTimings', 0)
kboronski-ant commented 2 years ago

It's unrecommended to do such conversion for anything that isn't a very small device (ie. testarch). I once attempted to export xczcu7ev to JSON and ran out of memory. If you have something smaller, you may try exporting it to YAML, I believe this method worked better.

What I would recommend (and I personally use) is to load the device in context of python interpreter in REPL mode. I've made a small script for myself to preload when entering REPL mode. It makes it easier to load the device and navigate it.

See: https://github.com/chipsalliance/python-fpga-interchange/pull/164 Make sure you are using 1.0.0 version of capnp package. Newer versions have some breaking changes.