Circuit builder API Documentation
Overview
The CircuitBuilder class represents an automatic placer/optimizer for circuit schematics. The solver keeps the original public API but internally uses a much leaner CP‑SAT model that focuses on the essentials:
- bounding‑box packing with optional spacing / relative rules
- optional H/V flips for every device
- Manhattan length minimisation for all nets
- canvas area minimisation (maxX·maxY surrogate)
The more exotic cost tweaks (alignment bonuses, bend penalties, pin‑side heuristics …) have been removed – the same effects now emerge naturally from the primary length objective which is simpler and easier to reason about.
Members
Align
Type: Enum
Values: SameRow, SameColumn
Description:
Alignment rules for a group of devices.
Usage Example:
1 2 3 4 5 6 7 | |
DeviceOrientation
Type: Enum
Values: Horizontal, Vertical
Description:
Orientation preference for a device.
Usage Example:
1 2 3 4 5 6 7 | |
LayoutDirection
Type: Enum
Values: LeftToRight, RightToLeft, TopToBottom, BottomToTop
Description:
Direction of layout for multiple devices.
Usage Example:
1 2 3 4 5 6 7 | |
Side
Type: Enum
Values: North, South, East, West
Description:
Orientation preference for a pin.
Usage Example:
1 2 3 4 5 6 7 | |
Methods
Device AddDevice(string libraryName)
Arguments: string libraryName Library item name of the device to add.
Description:
Add a device to the circuit builder.
Usage Example:
1 2 3 4 | |
void AddConnection(IEnumerable<DevicePin> Pins)
Arguments: IEnumerable<DevicePin> Pins List of pins to consider.
Description:
Create a connection between the pins.
Usage Example:
1 2 3 4 5 6 7 | |
void Constrain(IEnumerable<Device> devices, <T> rule)
Arguments: IEnumerable<Device> devices List of devices to consider.
<T> rule The rule to apply. Can be a Align, DeviceOrientation or LayoutDirection.
Description:
Add a constrain to a list of devices
Usage Example:
1 2 3 4 5 | |
void ConstrainPinSide(IEnumerable<DevicePin> pins, Side side)
Arguments: IEnumerable<DevicePin> pins List of pins to consider.
Side side The side to apply.
Description:
Add a constrain to a list of devices
Usage Example:
1 2 3 4 5 | |
void DefineZone(string name, IEnumerable<Device> devices)
Arguments: string name Name of the zone.
IEnumerable<Device> devices List of devices to consider.
Description:
Defines or augments a layout zone by name and assigns the given devices to it.
Zones are optional. When present, the solver enforces that the bounding rectangles of different zones do not overlap.
A device can belong to at most one zone.
Usage Example:
1 2 3 4 5 6 | |
void StartZone(string name) / void EndZone()
Arguments: string name Name of the zone.
Description:
Begin assigning subsequently added devices to the named zone until EndZone() is called.
Usage Example:
1 2 3 4 5 6 | |
Circuit Build()
Arguments:
Description:
Starts building the circuit defined in the builder.
Usage Example:
1 2 3 4 5 6 7 8 | |
Example Usage
Here's a typical example of how to use the CircuitBuilder API in a Python project.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |