https://github.com/bhdl/bhdl/master/bhdl-lib/bhdl/private/library-IC.rkt) file for the available components and their pins.
Components can be defined via the
Notes about the fields:
#:FPexpects a footprint and pin names. These pin names are arbitrary but the order is important, it will be mapped to the exact order of the corresponding footprint. Refer to footprint document for the definition of the footprint pin order.
#:PREFIXdefines what is the prefix to be appearing on PCB. E.g. R1, LED4
This defines a function called
LED, and an LED instance can be created via the
(define myled (LED)). The pins named
minus can be
accessed to make connections. To enalbe a component to connect in "line
connection syntax", you need to specify the #:LEFT and #:RIGHT pins:
The left and right delcaration makes it possible to use components of more than 2 pins in the line connection syntax. For exampole, 4 pin switches (where 2 groups are connected)
One can change the default left and right orientation easily by defining a
circuit wrapper, more on this on the
Many two-pin non-polarized components do not have meaningful names. E.g. a
resistor just have pin 1 and pin 2. A pin header just have pin 1 2 3 4 ... For
these components, you can write
#:auto-FP in place of
#:FP, and the numbers
(starting from 1) will be added for you based on how many pins the footprint
has. You can use 1 and 2 for
#:RIGHT declaration. E.g.
There may be many footprints for an IC. Thus you are allowed to specify multiple footprints:
You can specify which footprint variant to use via
If not specified, the first one is used.
For ICs, there are two special notes:
- ICs typically have well-defined footprints. For that, some syntax sugar names
can be used, e.g.
- There are often more than one name for a pin of IC. E.g. For ATTiny-serie
MCUs, the PB0 also functions as
PCINT0, and more. This must be specified in
#:ALIASto delcare they are aliases for the same pin. All the pin names will be available for making connections.
If the local library
$BHDL_LIBRARY_PATH/easyeda does not contain the
footprint, it will query EasyEDA website and writes the footprint to
$BHDL_LIBRARY_PATH/easyeda/xxx.json for caching. As we run it for more
components, our repo will be tracking many components.
This makes it easy to define a new component, e.g. the 1N4148W diode can be defined simply as:
The order of footprint pins are defined as the orders of the pin occurance in the KiCAD or EasyEDA footprints, not the name of footprint pins. Although many footprints have numerical 1 2 3 ..., there are also text name, and there's no heuristic to sort them.
The choice of using this order of pins has a caveat: the pin order might not be the actual numerical order. This can be especially comon in KiCAD footprints where the numerical numbers may be mixed in arbitrary order.