chipsalliance / chipsalliance/python-fpga-interchange
Allow patching of StringIdx values
- Dominant language
- Python
- Stars
- 41
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
At the moment, patching of `StringIdx` values fails. Consider the following example:
parameters.yaml:
```
cells:
- cellType: FOO
```
running
```
python -mfpga_interchange.patch --schema_dir ~/fpga-interchange-schema/interchange --patch_path parameterDefs --schema device --patch_format yaml LIFCL-17.device parameters.yaml LIFCL-17-patched.device
```
fails with
```
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/david/python-fpga-interchange/fpga_interchange/patch.py", line 72, in
main()
File "/home/david/python-fpga-interchange/fpga_interchange/patch.py", line 65, in main
patch_capnp(message, patch_path, args.patch_format, f)
File "/home/david/python-fpga-interchange/fpga_interchange/patch.py", line 37, in patch_capnp
read_format_to_message(message_to_populate, patch_format, in_f)
File "/home/david/python-fpga-interchange/fpga_interchange/convert.py", line 83, in read_format_to_message
from_rapidyaml(message, yaml_tree)
File "/home/david/python-fpga-interchange/fpga_interchange/rapidyaml_support.py", line 393, in from_rapidyaml
from_reader(message, data, RapidYamlReader)
File "/home/david/python-fpga-interchange/fpga_interchange/converters.py", line 458, in from_reader
from_reader(
File "/home/david/python-fpga-interchange/fpga_interchange/converters.py", line 479, in from_reader
value = reader.read_scalar(field_which, value)
File "/home/david/python-fpga-interchange/fpga_interchange/rapidyaml_support.py", line 335, in read_scalar
return int(field_data)
ValueError: invalid literal for int() with base 10: 'FOO'
```
As there is no special casing for indexed strings, it is expecting an index into the string pool rather than a string (which isn't feasibly human-writeable). These will need to be handled by looking into, and updating if needed, the list of strings. This is also a prerequisite to fixing SymbiFlow/fpga-interchange-schema#46, hitherto this has been worked around in the schema by using `Text` instead of `StringIdx` where the patching tool needs to be used.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.