Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor netlist generation #243

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

shanemmattner
Copy link
Contributor

@shanemmattner shanemmattner commented Jan 26, 2025

The only changes are to src/skidl/scripts/netlist_to_skidl_main.py and to src/skidl/netlist_to_skidl.py. Other files include an example kicad project, netlists from kicad and skidl, and the output folder containing generated skidl python files

This logic changes the Kicad netlist to SKiDL logic so that the SKiDL project is generated in hierarchical fashion mirroring the KiCAD schematic. Take a look at example_kicad_project_SKIDL directory for the output from example_kicad_project.net, which is the Kicad export from the project in example_kicad_project/. main.net is the SKiDL exported netlist that succesfully imports to Kicad and has the same connections as the based project.

Here is how you can try this logic:

(venv) shanemattner@Shanes-MacBook-Pro skidl % Applications/KiCad/KiCad.app/Contents/MacOS/kicad-cli sch export netlist -o example_kicad_project.net example_kicad_project/example_kicad_project.kicad_sch
(venv) shanemattner@Shanes-MacBook-Pro skidl % netlist_to_skidl -i example_kicad_project.net --output example_kicad_project_SKIDL

=== Extracting Sheet Info ===

=== Assigning Components to Sheets ===

=== Analyzing Nets ===
Wrote sheet file: example_kicad_project_SKIDL/esp32s3mini1.py
Wrote sheet file: example_kicad_project_SKIDL/_3v3_regulator.py
Wrote sheet file: example_kicad_project_SKIDL/resistor_divider1.py
Wrote sheet file: example_kicad_project_SKIDL/USB.py
(venv) shanemattner@Shanes-MacBook-Pro skidl % python3 example_kicad_project_SKIDL/main.py                  
INFO: No errors or warnings found while generating netlist.

(venv) shanemattner@Shanes-MacBook-Pro skidl % 

The core logic works as expected connection wise and could be used with the LLM logic as is. But there's still a bit of work to do to make a completely transparent Kicad > Skidl > Kicad loop. I'll try merging in this fix tomorrow to fix the component reference issue. I also need to tweak the output net names I believe.

@devbisme
Copy link
Owner

I pulled this into a new branch called netlist_to_skidl. This branch already includes the fix for issue #238. Once we have netlist_to_skidl working as we want, we can merge it into development and llm.

I moved your example into tests/examples/netlist_to_skidl. I wasn't able to convert the netlist extracted from the kicad project; there was some complaint from pyparsing about the .net file. I'm not sure why since it worked correctly for you. This is one reason I want to get rid of pyparsing: it's too hard to debug when it hits an error in the file it's parsing.

@shanemmattner
Copy link
Contributor Author

Maybe you exported the netlist in a non-default format? I just checked out the branch you made and it seems to work well for me. Can you try generating the netlist to test with the command line tool? For me that is running:

(venv) shanemattner@Shanes-MacBook-Pro skidl % Applications/KiCad/KiCad.app/Contents/MacOS/kicad-cli sch export netlist -o example_kicad_project.net example_kicad_project/example_kicad_project.kicad_sch

I made a 2 updates to this PR and this feature should be ready now: I can succesfully export a Kicad project netlist, import it to a SKiDL based project folder, then run the SKiDL code to produce a netlist which does not change the original Kicad PCB connections. See report.txt for the import report.

@devbisme
Copy link
Owner

Can you try generating the netlist to test with the command line tool?

I tried those commands (except the KiCad project is in directory kicad_project instead of example_kicad_project) and I got the same error. I'm using KiCad 8.0.8 on Ubuntu 22.04.1. I'll have to look at it more closely and see if I can spot the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants