ORM-like definition of new parts
See original GitHub issueDescription
At the moment, I have to go into the KiCad library editor to create a new part. The net connections and net list are generated using skidl, but skidl is still utterly dependent on existing part libraries generated using KiCad.
I would like to see a ‘model’ or library that creates the part itself in python. We see similar models when we look as sqlalchemy classes which define and correspond to tables. In sqlalchemy, most users will create a models.py
file which will entirely contain the SQL structure and my proposal is to implement a similar feature in skidl.
Motivation
This is OK, but it would be much more pythonic - and readable! - to create models using python syntax and use that to instantiate my part. Schematic part creation is great for those who have an existing library, but to use skidl for the workflow, it makes sense to have a ‘from scratch’ skidl option.
Current Part Generation
Using the example ‘pic10f220-i/ot’ from the documentation. The PIC10 has to be created using the schematic editor and skidl has to be configured to find that library and import it. The part definition is then entirely based on the KiCad part definition.
import skidl
pic10 = Part(lib='microchip_pic10mcu', name='pic10f220-i/ot')
Proposed Part Generation
The proposed ORM-like structure would likely consist of a custom library-like file and then the use-case (though it wouldn’t have to be separated).
my_custom_parts.py
import skidl
class Pic10(BasePart):
name = 'pic10f220-i/ot'
pins = [
Pin(num=1, name='ICSPDAT/AN0/GP0', funct=skidl.Pin.BIDIRECTIONAL),
Pin(num=2, name='VSS', funct=skidl.Pin.POWER-IN),
Pin(num=3, name='ICSPCLK/AN1/GP1', funct=skidl.Pin.BIDIRECTIONAL),
Pin(num=4, name='T0CKI/FOSC4/GP2', funct=skidl.Pin.BIDIRECTIONAL),
Pin(num=5, name='VDD', funct=skidl.Pin.POWER-IN),
Pin(num=6, name='Vpp/~MCLR~/GP3', funct=skidl.Pin.INPUT)
]
# more stuff could be added, but wouldn't have to be - manufacturer, part number, etc
my_circuit.py
pic10 = Part(basepart=Pic10)
Additional Features
Assuming that the proposed feature is implemented, it would also be nice to have a ‘lib_to_skidl.py’ script similar in functionality to the existing ‘netlist_to_skidl.py’ that exists now.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:11 (1 by maintainers)
Top GitHub Comments
Hey, thanks for working on this. So, I believe that I have a prototype working, but I am having trouble finding the contribution guidelines. Could you link those from the readme?
Examples of part models:
Just as an idea, it could be nice if you could use dicts instead of
Pin()
and simple strings forfunct
(maybe it looks more “pythonic” that way):Also, it would be great if you could create an instance of that part with:
Instead of: