box module#
Box symbol module for JITX Standard Library
This module provides box symbol definitions for creating rectangular symbols with configurable pin layouts and spacing.
- Quick Start:
>>> # Auto-generated symbol >>> class MyComponent(Component): ... GND = Port() ... VCC = Port() ... IN = [Port() for _ in range(3)] ... OUT = [Port() for _ in range(5)] ... symbol = BoxSymbol()
>>> # Custom layout >>> class MyComponent(Component): ... GND = Port() ... VCC = Port() ... IN = [Port() for _ in range(3)] ... OUT = [Port() for _ in range(5)] ... symbol = BoxSymbol( ... rows=[ ... Row(left=PinGroup(IN), right=PinGroup(OUT)), ... ], ... columns=[ ... Column(up=PinGroup(VCC), down=PinGroup(GND)), ... ], ... )
- class SpaceType(*values)[source]#
Bases:
EnumTypes of spaces in box symbol layout
- CORNER = 'corner'#
- ROW_COL_SPACING = 'row_col_spacing'#
- ROW_COL_SPACING_ALIGN = 'row_col_spacing_align'#
- GROUP_SPACING = 'group_spacing'#
- PIN_SPACING = 'pin_spacing'#
- PRE_PIN_SPACING = 'pre_pin_spacing'#
- class PinGroup(pins, *args, pre_margin=None, post_margin=None)[source]#
Bases:
StructurableA group of pins with optional positioning and margins.
>>> # Group of input pins >>> IN = [Port() for _ in range(3)] >>> input_group = PinGroup(IN)
- pins: Sequence[Port]#
- class Row(left=(), right=(), top_margin=None, bottom_margin=None)[source]#
Bases:
StructurableA row in the box symbol grid, containing Left and Right pin groups.
Rows define horizontal arrangements of pins. Pins on the left extend outward to the left, and pins on the right extend outward to the right. Pins are arranged in the order they are given, from top to bottom.
>>> # Single row with inputs on left, outputs on right >>> row = Row( ... left=PinGroup(IN), ... right=PinGroup(OUT) ... )
- Parameters:
- left: Sequence[PinGroup]#
- right: Sequence[PinGroup]#
- top_margin: float | None#
- bottom_margin: float | None#
- class Column(up=(), down=(), left_margin=None, right_margin=None)[source]#
Bases:
StructurableA column in the box symbol grid, containing Up and Down pin groups.
Columns define vertical arrangements of pins. Pins on top extend upward, and pins on bottom extend downward. Pins are arranged in the order they are given, from left to right.
>>> # Column with power pins on top, ground on bottom >>> col = Column( ... up=PinGroup(VCC, VREF), ... down=PinGroup(GND) ... )
- Parameters:
- up: Sequence[PinGroup]#
- down: Sequence[PinGroup]#
- left_margin: float | None#
- right_margin: float | None#
- class BoxConfig(label_config=None, min_width=2.0, min_height=2.0, pin_spacing=2.0, corner_margin=2.0, group_spacing=2.0, row_spacing=2.0, col_spacing=2.0, pin_length=2, pin_name_size=0.65, pad_name_size=0.65)[source]#
Bases:
LabelConfigurableConfiguration for box symbols.
Controls spacing, sizing, and text appearance for box-style schematic symbols. Can be set on a box symbol or globally via SymbolStyleContext.
>>> # Custom configuration for a compact symbol >>> config = BoxConfig( ... pin_spacing=1.0, ... corner_margin=1.0, ... group_spacing=1.0, ... ) >>> symbol = BoxSymbol(rows=rows, columns=columns, config=config)
- Parameters:
- min_width: float = 2.0#
Minimum width of the box, required to be at least 2
- min_height: float = 2.0#
Minimum height of the box, required to be at least 2
- pin_spacing: float = 2.0#
Spacing between pins within the same group, required to be at least 1
- corner_margin: float = 2.0#
Margin from box corners to first/last pins, required to be at least 1
- group_spacing: float = 2.0#
Spacing between pin groups on the same side, required to be at least 1
- row_spacing: float = 2.0#
Spacing between rows in grid layout
- col_spacing: float = 2.0#
Spacing between columns in grid layout
- pin_length: int = 2#
Length of the pin
- pin_name_size: float | None = 0.65#
Size of the pin name text
- pad_name_size: float | None = 0.65#
Size of the pad name text
- class SymbolBox(config)[source]#
Bases:
LabelledSymbolBox-shaped symbol
- Parameters:
config (BoxConfig)
- box: Shape#
- p: tuple[Pin, ...]#
- decorators: tuple[tuple[Shape, ...], ...]#
- class BoxSymbol(rows=(), columns=(), config=None, debug=False, **kwargs)[source]#
Bases:
ContainerContainer for a box-shaped symbol with pins, artwork, labels, and a symbol mapping.
BoxSymbol creates rectangular schematic symbols with pins on all four sides. Pins are organized into Rows of left and right pins and Columns of up and down pins. If no rows/columns are provided, the symbol auto-generates from component ports.
Examples
>>> # Auto-generated symbol from component ports >>> class MyComponent(Component): ... IN = [Port() for _ in range(4)] ... OUT = [Port() for _ in range(4)] ... VCC = Port() ... GND = Port() ... ... def __init__(self): ... self.symbol = BoxSymbol() # Auto-arranges all ports
>>> # Manual layout with rows and columns >>> class MyComponent(Component): ... IN = [Port() for _ in range(8)] ... OUT = [Port() for _ in range(8)] ... CLK = Port() ... RST = Port() ... VCC = Port() ... GND = Port() ... ... def __init__(self): ... self.symbol = BoxSymbol( ... rows=Row( ... left=PinGroup(self.IN), ... right=PinGroup(self.OUT) ... ), ... columns=Column( ... up=PinGroup([self.CLK, self.RST, self.VCC]), ... down=PinGroup(self.GND) ... ) ... )
>>> # Multiple rows for complex layouts >>> symbol = BoxSymbol( ... rows=[ ... Row(left=PinGroup(data_pins), right=PinGroup(status_pins)), ... Row(left=PinGroup(addr_pins), right=PinGroup(control_pins)) ... ], ... columns=Column(up=PinGroup(power_pins), down=PinGroup(gnd_pins)), ... config=BoxConfig(pin_spacing=1.0) ... )
- Parameters:
- width: float#
- height: float#
- mapping: SymbolMapping#
- config: BoxConfig#
- symbol: SymbolBox#