edalize icon indicating copy to clipboard operation
edalize copied to clipboard

Yosys: `configure_main` should check for "file_type" in fileset, or provide a default

Open Isweet opened this issue 10 months ago • 0 comments

I'm trying to take an existing set of core files and perform setup with Yosys (fusesoc --cores-root=. run --setup --tool yosys ...), and I'm getting the following KeyError:

Traceback (most recent call last):
  File "/home/isweet/.local/bin/fusesoc", line 8, in <module>
    sys.exit(main())
  File "/home/isweet/.local/lib/python3.10/site-packages/fusesoc/main.py", line 835, in main
    fusesoc(args)
  File "/home/isweet/.local/lib/python3.10/site-packages/fusesoc/main.py", line 825, in fusesoc
    args.func(cm, args)
  File "/home/isweet/.local/lib/python3.10/site-packages/fusesoc/main.py", line 401, in run
    run_backend(
  File "/home/isweet/.local/lib/python3.10/site-packages/fusesoc/main.py", line 506, in run_backend
    backend.configure([])
  File "/home/isweet/.local/lib/python3.10/site-packages/edalize/edatool.py", line 198, in configure
    self.configure_main()
  File "/home/isweet/.local/lib/python3.10/site-packages/edalize/yosys.py", line 70, in configure_main
    if f["file_type"].startswith("verilogSource"):
KeyError: 'file_type'

I believe that edalize/yosys.py should have configure_main either check for this as an error condition explicitly, or provide a default like "". I patched this locally by instead calling self._get_fileset_files() but I'm not sure if that's correct. It correctly specifies a default, and allows file_type to be accessed as a field of File rather than by key in a map.

I recommend providing a default, since existing core files that are compatible with e.g. the Verilator backend do not always provide a file_type.

Let me know if you need any additional information, thanks!

Isweet avatar Apr 09 '24 14:04 Isweet