Component Library
https://github.com/bhdl/bhdl/master/bhdl-lib/bhdl/private/library-IC.rkt) file for the available components and their pins.
Basic components:
Simple ICs:
ICs:
Aruinos
Other components:
#
Creating (and Contributing!) Your Own LibraryComponents can be defined via the define/IC
syntax:
Notes about the fields:
#:FP
expects 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.#:PREFIX
defines 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
function call (define myled (LED))
. The pins named plus
and 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 make-circuit
document.
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 #:LEFT
and #: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.
#:DIP
#:QFN
. - There are often more than one name for a pin of IC. E.g. For ATTiny-serie
MCUs, the PB0 also functions as
MOSI
,SDA
,PCINT0
, and more. This must be specified in#:ALIAS
to delcare they are aliases for the same pin. All the pin names will be available for making connections.
#
footprintsBHDL can read KiCAD and read EasyEDA footprints. For many components listed on LCSC.com have associated footprints. We thus support getting the footprint directly via the ID. E.g.
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.