Components and nets
In the last section we created a design with a single component. This section will show you how define components starting from scratch, and connect their pins with nets.
We typically use components to model discrete devices (e.g. resistors, capacitors, op-amps, FPGAs,etc ..). In practice, each component definition captures a whole family of devices. For example, every fuse in this datasheet would be captured by a single component model.
We create a component using the pcb-component
statement and add pins to it using the pin and port statements. Here are definitions for three components needed for our design, a photodiode, an op-amp, and a pin-header.
pcb-component photodiode :
port a
port c
pcb-component op-amp :
port in+
port in-
port out
port v+
port v-
pcb-component three-pin-header :
port p : pin[3]
This code snippet:
- Defines a new component named
photodiode
with two pins nameda
andc
- Defines a new component named
op-amp
with five pins namedin+
,in-
,out
,v+
, andv-
- Defines a new component named
three-pin-header
with a port namedp
, that has three pins. The pins in this port have the namesp[0]
p[1]
andp[2]
.
We can add these components to our design using the inst
statement (short for instantiate). Let's create a small circuit connecting the photodiode to the op-amp, and pins associated with power to the connector.
pcb-module my-design :
inst d : photodiode
inst opa : op-amp
inst connector : three-pin-header
; Set up power connections
net GND (opa.v- connector.p[0])
public net VDD (opa.v+ connector.p[1])
; Connect op-amp
net (d.c opa.in-)
net (GND opa.in+ d.a)
To break this down, we first instantiate our components:
inst d : photodiode
inst opa : op-amp
inst connector : three-pin-header
- One instance of
op-amp
namedopa
- One instance of
photodiode
namedd
- One instance of
three-pin-header
namedconnector
Then we create a net
named GND
that connects the negative supply on the op-amp, and the first pin on the pin-header :
net GND (opa.v- connector.p[0])
This statement creates a new net named GND
. Every pin inside the parentheses will be added to this GND
net. We named the instance of our connector connector
and we can access its pins using the .
operator, so the name of the first pin of the connector is j.p[0]
.
Similarly this statement creates the VDD
net, and connects the positive op-amp supply pin and the second pin on the connector :
public net VDD (opa.v+ connector.p[1])
Then we connect the cathode of the photodiode to the inverting input of the op-amp :
net (d.c opa.in-)
We could give that net a name but it's optional. Nets that we don't name get auto-generated names later.
Finally, we connect the non-inverting op-amp input and the anode of the photodiode to ground :
net (GND opa.in+ d.a)
Notice that we are using the name GND
to add these other pins to the GND
net.
Example code for this design is here. Because we didn't add symbols to our components (yet) we can't generate a schematic to see what our code is doing. Instead, we used some introspection to print out the members of the VDD
net (which we made public for that purpose).
This section showed you how to create new components, instantiate them in a design, and connect them up using the net
statement. However we're still missing some information in the components. There's no symbol or land pattern or sourcing information (the reference has a complete list of component statements). And so even though this is a valid design in JITX, we wouldn't be able to create a schematic (because there are no symbols), or a layout (because there are no land patterns). We will see how to add that information in the next section.