This document describes the syntax of the CodeYourPCB domain-specific language (DSL).
- Version Declaration
- Board Definition
- Component Definition
- Net Definition
- Zone Definition
- Trace Definition
- Custom Footprint Definition
- Comments
- Units
Every .cypcb file should start with a version declaration:
version 1
This specifies the DSL version and enables future syntax evolution.
Define the physical PCB properties:
board <name> {
size <width> x <height>
layers <count>
}
Example:
board my_circuit {
size 50mm x 30mm
layers 2
}
Properties:
size: Board dimensions (width x height) with unitslayers: Number of copper layers (2, 4, 6, etc.)
Place components on the board:
component <refdes> <type> "<footprint>" {
value "<value>"
at <x>, <y>
rotate <angle>
pin.<number> = <net>
}
Example:
component R1 resistor "0402" {
value "330"
at 15mm, 10mm
rotate 90
pin.1 = VCC
pin.2 = LED_ANODE
}
Component Types:
resistor,capacitor,inductoric,led,diode,transistorconnector,crystal,generic
Properties:
value: Component value as string (e.g., "330", "100nF", "ATmega328P")at: Position in board coordinates (x, y)rotate: Rotation angle in degrees (optional, defaults to 0)pin.<N> = <NET>: Inline net assignment for specific pins (optional)
Footprint Examples:
- SMD resistors/capacitors: "0402", "0603", "0805", "1206"
- ICs: "SOIC8", "SOIC14", "SOT23", "TQFP32"
- Through-hole: "DIP-8", "PIN-HDR-1x2"
See examples/ directory for more component examples.
Define electrical connections between component pins.
net <name> {
<component>.<pin>
<component>.<pin>
...
}
Example:
net GND {
R1.2
C1.2
LED1.K
}
IMPORTANT: Net constraints must be placed in square brackets BEFORE the braces.
net <name> [<constraint1> <constraint2> ...] {
<component>.<pin>
...
}
CORRECT - Constraints in square brackets before braces:
net VCC [current 100mA width 0.3mm] {
R1.1
C1.1
J1.1
}
INCORRECT - Constraints cannot go inside braces:
net VCC {
R1.1
C1.1
current 100mA // ERROR: unexpected token
}
Current Constraint: Specifies the expected current flow through the net.
current <value><unit>
Units: mA (milliamps) or A (amps)
Examples:
net VCC [current 500mA] { ... }
net MOTOR_POWER [current 2A] { ... }
Width Constraint: Specifies the minimum trace width for this net.
width <dimension>
Example:
net VCC [width 0.5mm] { ... }
Clearance Constraint: Specifies the minimum clearance to other nets.
clearance <dimension>
Example:
net HIGH_VOLTAGE [clearance 1mm] { ... }
Multiple Constraints: You can combine multiple constraints in the same square brackets:
net VCC [current 500mA width 0.4mm clearance 0.3mm] {
R1.1
C1.1
}
Pin References: Pin identifiers can be numbers or names:
R1.1,R1.2(numeric pins)LED1.A,LED1.K(named pins: anode, cathode)U1.VCC,U1.GND(IC named pins)
See examples/power-indicator.cypcb for net constraint examples.
Define keepout areas or copper pour zones:
Prevents component placement in a specific area:
keepout <name> {
bounds <x1>, <y1> to <x2>, <y2>
layer <layer>
}
Example:
keepout mounting_hole {
bounds 5mm, 5mm to 8mm, 8mm
layer all
}
Defines a copper pour area (future):
zone <name> {
bounds <x1>, <y1> to <x2>, <y2>
layer <layer>
net <netname>
}
Layers:
top: Top copper layerbottom: Bottom copper layerall: All layers
Manually define routed traces:
trace <net> {
from <component>.<pin>
to <component>.<pin>
via <x>, <y>
layer <layer>
width <dimension>
locked
}
Example:
trace VCC {
from R1.1
to C1.1
via 12mm, 10mm
layer Top
width 0.3mm
locked
}
Properties:
from: Starting pin referenceto: Ending pin referencevia: Waypoint coordinates for routing (optional, can repeat)layer: Copper layer (Top, Bottom, Inner1-4)width: Trace width (optional, defaults to DRC minimum)locked: Prevents autorouter from modifying this trace
Locked traces are preserved during auto-routing and exported as fixed wires.
Define custom footprints inline:
footprint <name> {
description "<text>"
courtyard <width> x <height>
pad <number> <shape> at <x>, <y> size <w> x <h> [drill <d>]
...
}
Example:
footprint MY_CONNECTOR {
description "Custom 3-pin connector"
courtyard 5mm x 3mm
pad 1 rect at -2mm, 0mm size 1mm x 1.5mm drill 0.8mm
pad 2 circle at 0mm, 0mm size 1mm x 1mm drill 0.8mm
pad 3 rect at 2mm, 0mm size 1mm x 1.5mm drill 0.8mm
}
Pad Shapes:
rect: Rectangular padcircle: Circular padroundrect: Rounded rectangleoblong: Oval/stadium shape
Drill:
- If
drillis specified, pad is through-hole (THT) - Without
drill, pad is surface-mount (SMD)
Line comments:
// This is a line comment
Block comments:
/*
* This is a block comment
* spanning multiple lines
*/
All dimensions require explicit units:
mm- millimeters (most common)mil- thousandths of an inchin- inchesnm- nanometers (internal precision)
Examples:
size 50mm x 30mm
at 1.5in, 20mil
width 0.254mm
Negative dimensions are supported for pad offsets:
pad 1 rect at -1mm, 0mm size 0.5mm x 0.8mm
Complete working examples can be found in the examples/ directory:
examples/blink.cypcb- Simple LED blink circuitexamples/power-indicator.cypcb- Power indicator with current constraintsexamples/drc-test.cypcb- DRC rule demonstrationsexamples/routing-test.cypcb- Manual trace definitions
Wrong:
net VCC {
R1.1
current 500mA // ERROR!
}
Correct:
net VCC [current 500mA] {
R1.1
}
Wrong:
at 15, 10 // Missing units
Correct:
at 15mm, 10mm
Wrong:
component R1 resistor 0402 { ... } // Missing quotes
Correct:
component R1 resistor "0402" { ... }
Validate your .cypcb files with the CLI:
cypcb check my_board.cypcbThis checks for:
- Syntax errors
- Unknown footprints
- Duplicate component references
- Undefined net references
- DRC violations
- Review example files in
examples/ - Run
cypcb checkon your designs - Use
cypcb routeto auto-route traces - Export Gerber files with
cypcb export
For more information, see the main project README.