Skip to content

Commit 8e3e554

Browse files
authored
Update spec.mdx (#273)
1 parent 1bdcb7c commit 8e3e554

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

docs/pages/spec.mdx

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,35 @@ ChildBoard(name="Board1")
12631263
- Modifiers are inherited through the entire module hierarchy
12641264
- Common uses: vendor policies, DNP rules, property validation, debug tagging
12651265

1266+
### match_component(match, parts)
1267+
1268+
**Stdlib helper function** (from `@stdlib/bom/helpers.zen`) for creating component modifiers that assign MPNs based on property matching.
1269+
1270+
**Parameters:**
1271+
- `match`: Dict of property names to values (all must match)
1272+
- `parts`: Tuple `(mpn, manufacturer)` or list of tuples (first is primary, rest are alternatives)
1273+
1274+
**Example:**
1275+
```python
1276+
load("@stdlib/bom/helpers.zen", "match_component")
1277+
1278+
Board(
1279+
name="MyBoard",
1280+
layers=4,
1281+
modifiers=[
1282+
match_component(
1283+
match={"resistance": "10k", "package": "0603"},
1284+
parts=[
1285+
("ERJ-3EKF1002V", "Panasonic"), # Primary
1286+
("RC0603FR-0710KL", "Yageo"), # Alternative
1287+
]
1288+
),
1289+
]
1290+
)
1291+
```
1292+
1293+
Use to override default BOM matching or assign board-specific part numbers. Modifiers run before BOM profile.
1294+
12661295
### builtin.current_module_path()
12671296

12681297
**Built-in function** that returns the current module's path as a list of strings.
@@ -1314,7 +1343,7 @@ load("@stdlib/board_config.zen",
13141343
)
13151344
```
13161345

1317-
### Board(name, layout_path, config=None, layers=None, layout_hints=None, default=False)
1346+
### Board(name, layout_path, config=None, layers=None, layout_hints=None, default=False, modifiers=None, bom_profile=add_default_bom_profile)
13181347

13191348
**Stdlib function** for declaring board configurations for PCB layout generation.
13201349

@@ -1366,6 +1395,41 @@ Board(
13661395
config=config,
13671396
default=True
13681397
)
1398+
1399+
# BOM customization with custom part matching
1400+
load("@stdlib/bom/helpers.zen", "match_component")
1401+
1402+
Board(
1403+
name="ProductionBoard",
1404+
layout_path="layout/",
1405+
layers=4,
1406+
default=True,
1407+
# Custom modifiers run BEFORE default BOM matching
1408+
modifiers=[
1409+
# Override specific components with preferred vendors
1410+
match_component(
1411+
match={"resistance": "10k", "package": "0603"},
1412+
parts=[
1413+
("ERJ-3EKF1002V", "Panasonic"),
1414+
("RC0603FR-0710KL", "Yageo"), # Alternative
1415+
]
1416+
),
1417+
match_component(
1418+
match={"capacitance": "100nF", "voltage": "50V", "package": "0402"},
1419+
parts=("GCM155R71H104KE02D", "Murata")
1420+
),
1421+
]
1422+
# bom_profile defaults to add_default_bom_profile,
1423+
# which handles standard resistors/capacitors
1424+
)
1425+
1426+
# Disable automatic BOM matching entirely
1427+
Board(
1428+
name="CustomBoard",
1429+
layout_path="layout/",
1430+
layers=4,
1431+
bom_profile=lambda: None # No automatic BOM matching
1432+
)
13691433
```
13701434

13711435
**Parameters:**
@@ -1380,6 +1444,8 @@ Board(
13801444
- `layers=8`: 8-layer board (1.6mm, 1oz outer/0.5oz inner, SIG/GND/SIG/PWR/GND/SIG/GND/SIG)
13811445
- `layout_hints`: Optional list of layout optimization hints
13821446
- `default`: If True, this becomes the default board config for the project
1447+
- `modifiers`: Optional list of component modifier functions that run **before** BOM profile modifiers. Use this to override BOM matching or set custom part numbers for specific components. Functions are registered only at the root module level.
1448+
- `bom_profile`: Function that registers BOM matching modifiers (default: `add_default_bom_profile`). The default profile automatically assigns manufacturer part numbers to generic resistors and capacitors. Pass `lambda: None` to disable BOM matching.
13831449

13841450
**Note:** Either `config` or `layers` must be provided, but not both. If neither is provided, an error will be raised.
13851451

0 commit comments

Comments
 (0)