pcb
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePCB
PCB
Zener is a Starlark-based HDL for PCB design. files define components, nets, interfaces, and modules. Key concepts:
.zen- Net: electrical connection between pins
- Component: physical part with symbol, footprint, pins
- Interface: reusable grouped connection pattern (e.g., ,
Spi,I2c)Uart - Module: hierarchical subcircuit, instantiated with
Module("path.zen")
IMPORTANT: Before writing or modifying .zen code, run to read the language specification. The spec covers syntax, built-in functions, type system, and common patterns. For specific topics: shows all sections, reads one section.
pcb doc specpcb doc spec --listpcb doc spec/<section>Prefer stdlib generics () over specific components when possible. Generics like , , are parameterized by value/package and resolved to real parts at build time.
@stdlib/generics/ResistorCapacitorLedCommon imports: for standard net types and interfaces.
load("@stdlib/interfaces.zen", "Power", "Ground", "Spi", "I2c", ...)Zener是一种基于Starlark的PCB设计硬件描述语言(HDL)。文件用于定义元器件、网络、接口和模块。核心概念:
.zen- Net:引脚之间的电气连接
- Component:带有符号、封装、引脚的物理元器件
- Interface:可复用的分组连接模式(例如、
Spi、I2c)Uart - Module:分层子电路,通过实例化
Module("path.zen")
**重要提示:在编写或修改.zen代码之前,请运行查看语言规范。**该规范涵盖语法、内置函数、类型系统和常见模式。如需查看特定主题:会显示所有章节,可查看单个章节。
pcb doc specpcb doc spec --listpcb doc spec/<section>优先使用标准库泛型()而非特定元器件。、、等泛型可通过参数指定参数值/封装,并在构建时解析为实际元器件。
@stdlib/generics/ResistorCapacitorLed常见导入语句:使用导入标准网络类型和接口。
load("@stdlib/interfaces.zen", "Power", "Ground", "Spi", "I2c", ...)Datasheets
数据手册
Use when a task depends on a datasheet or technical PDF.
pcb scan- Input: local path or
.pdfURLhttp(s) - Command:
pcb scan <input> - Output: stdout is the resolved markdown path
- Next step: read the markdown file, not the raw PDF
- Images are linked from the markdown
Examples:
bash
pcb scan ./TPS54331.pdf
pcb scan https://www.ti.com/lit/gpn/tca9554当任务需要依赖数据手册或技术PDF时,请使用命令。
pcb scan- 输入:本地文件路径或
.pdfURLhttp(s) - 命令:
pcb scan <input> - 输出:标准输出为解析后的markdown文件路径
- 下一步:查看markdown文件,而非原始PDF
- 图片会从markdown文件中链接
示例:
bash
pcb scan ./TPS54331.pdf
pcb scan https://www.ti.com/lit/gpn/tca9554CLI Commands
CLI命令
bash
undefinedbash
undefinedscaffolding
脚手架
pcb new workspace <NAME> --repo <URL> # Create new workspace with git init
pcb new board <NAME> # Add board to existing workspace (boards/<NAME>/)
pcb new package <PATH> # Create package at path (modules, etc.)
```bash
pcb build [PATH] # Build and validate (default: cwd)
pcb fmt [PATH] # Format .zen files (default: cwd)
pcb bom <FILE> -f json # Generate BOM as JSON with availability data
pcb fork add <URL> # Fork dependency for local dev
pcb fork remove <URL> # Remove forkpcb new workspace <NAME> --repo <URL> # 创建新工作区并初始化git
pcb new board <NAME> # 向现有工作区添加电路板(路径:boards/<NAME>/)
pcb new package <PATH> # 在指定路径创建包(如模块等)
```bash
pcb build [PATH] # 构建并验证(默认:当前工作目录)
pcb fmt [PATH] # 格式化.zen文件(默认:当前工作目录)
pcb bom <FILE> -f json # 生成包含供货数据的JSON格式BOM
pcb fork add <URL> # 复刻依赖包用于本地开发
pcb fork remove <URL> # 移除复刻的依赖包Component Search & Add
元器件搜索与添加
bash
pcb search -m registry:modules buck -f json
pcb search -m registry:components usb-c -f json
pcb search -m web:components STM32F103C8T6 -f json
pcb new component --component-id <ID> --part-number <MPN> --manufacturer <MFR>- : Search registry modules and reference designs. Includes descriptions, package URLs, dependencies/dependents, and availability data for component-backed results.
pcb search -m registry:modules ... -f json - : Search registry components. Includes MPN/manufacturer metadata, availability, supplier metadata, and dependency/dependent context.
pcb search -m registry:components ... -f json - : Search Diode's web component database. Includes
pcb search -m web:components ... -f json, pricing/stock/offers, datasheets, model availability, and source.component_id - : Download a web component into the current workspace.
pcb new component --component-id ...and--part-numberare optional fallbacks.--manufacturer
bash
pcb search -m registry:modules buck -f json
pcb search -m registry:components usb-c -f json
pcb search -m web:components STM32F103C8T6 -f json
pcb new component --component-id <ID> --part-number <MPN> --manufacturer <MFR>- :搜索注册表中的模块和参考设计。结果包含描述、包URL、依赖/被依赖关系,以及元器件相关的供货数据。
pcb search -m registry:modules ... -f json - :搜索注册表中的元器件。结果包含制造商零件编号(MPN)、制造商元数据、供货情况、供应商元数据,以及依赖/被依赖上下文。
pcb search -m registry:components ... -f json - :搜索Diode的在线元器件数据库。结果包含
pcb search -m web:components ... -f json、价格/库存/报价、数据手册、型号供货情况和来源。component_id - :将在线元器件下载到当前工作区。
pcb new component --component-id ...和--part-number为可选备选参数。--manufacturer
MCP Tools
MCP工具
| Tool | Use |
|---|---|
| Read structured KiCad symbol metadata ( |
| Strict full-write of symbol metadata. Input becomes the full metadata state (unset fields/properties are removed). Supports |
| RFC 7396 JSON Merge Patch update for metadata. Use for incremental edits (object keys set/replace, |
Metadata tool notes:
- These metadata tools are intended for scripted/structured metadata edits.
pcb mcp eval - Prefer first, then choose either strict
read_kicad_symbol_metadataor incrementalwrite_kicad_symbol_metadata.merge_kicad_symbol_metadata - Canonical KiCad mapping lives under :
metadata.primary- <->
Referenceprimary.reference - <->
Valueprimary.value - <->
Footprintprimary.footprint - <->
Datasheetprimary.datasheet - <->
Descriptionprimary.description - <->
ki_keywords(array in JSON, space-separated string inprimary.keywords).kicad_sym - <->
ki_fp_filters(array in JSON, space-separated string inprimary.footprint_filters).kicad_sym
- is only for non-canonical properties. Do not put canonical keys there.
custom_properties - Legacy note: older symbols may use . Reads normalize it to
ki_descriptionwhen canonicalprimary.descriptionis absent; writes emit canonicalDescription.Description - Common gotcha:
- Wrong:
metadata_patch: {custom_properties: {ki_keywords: "powerline transceiver CAN"}} - Right:
metadata_patch: {primary: {keywords: ["powerline", "transceiver", "CAN"]}}
- Wrong:
| 工具 | 用途 |
|---|---|
| 从 |
| 严格全量写入符号元数据。输入内容将成为完整的元数据状态(未设置的字段/属性会被移除)。支持 |
| 基于RFC 7396 JSON合并补丁更新元数据。用于增量编辑(对象键设置/替换, |
元数据工具说明:
- 这些元数据工具用于脚本化/结构化的元数据编辑。
pcb mcp eval - 建议先使用读取元数据,然后选择严格全量写入的
read_kicad_symbol_metadata或增量编辑的write_kicad_symbol_metadata。merge_kicad_symbol_metadata - KiCad标准元数据映射位于下:
metadata.primary- <->
Referenceprimary.reference - <->
Valueprimary.value - <->
Footprintprimary.footprint - <->
Datasheetprimary.datasheet - <->
Descriptionprimary.description - <->
ki_keywords(JSON中为数组,primary.keywords中为空格分隔的字符串).kicad_sym - <->
ki_fp_filters(JSON中为数组,primary.footprint_filters中为空格分隔的字符串).kicad_sym
- 仅用于存储非标准属性。请勿将标准键放置在此处。
custom_properties - 遗留说明:较旧的符号可能使用。当标准
ki_description不存在时,读取操作会将其标准化为Description;写入操作会输出标准的primary.description。Description - 常见误区:
- 错误写法:
metadata_patch: {custom_properties: {ki_keywords: "powerline transceiver CAN"}} - 正确写法:
metadata_patch: {primary: {keywords: ["powerline", "transceiver", "CAN"]}}
- 错误写法:
Documentation
文档
bash
pcb doc spec # Full language specification
pcb doc spec --list # List all spec sections
pcb doc spec/<section> # Read specific section (e.g., spec/io, spec/module)
pcb doc packages # Dependency management docs
pcb doc docs_bringup # Guide on writing bringup docs in markdown
pcb doc docs_changelog # Guide on writing a changelog after every changePackage docs (stdlib, registry packages):
bash
pcb doc --package @stdlib # Standard library docs
pcb doc --package @stdlib --list # List files as tree
pcb doc --package @stdlib/generics # Filter to subdirectory
pcb doc --package github.com/diodeinc/registry/module/<xyz>@0.1.0 # Remote packagebash
pcb doc spec # 完整语言规范
pcb doc spec --list # 列出所有规范章节
pcb doc spec/<section> # 查看特定章节(例如spec/io、spec/module)
pcb doc packages # 依赖管理文档
pcb doc docs_bringup # 关于用markdown编写调试文档的指南
pcb doc docs_changelog # 关于每次更改后编写变更日志的指南包文档(标准库、注册表包):
bash
pcb doc --package @stdlib # 标准库文档
pcb doc --package @stdlib --list # 以树形结构列出文件
pcb doc --package @stdlib/generics # 筛选子目录
pcb doc --package github.com/diodeinc/registry/module/<xyz>@0.1.0 # 远程包文档Part Sourcing & BOM Matching
元器件采购与BOM匹配
Generic components are matched to "house parts" (pre-qualified, good availability). Warnings like or mean no house part matches the spec—adjust the spec or specify + to use a specific part.
No house cap found for ...No house resistor found for ...mpnmanufacturerpcb bom <FILE> -f jsonavailability_tier"plenty""limited""insufficient"offers泛型元器件会与"内部认证元器件"(预先认证、供货稳定)进行匹配。如果出现或等警告,说明没有符合规格的内部认证元器件——此时需要调整规格,或指定(制造商零件编号)和(制造商)来使用特定元器件。
No house cap found for ...No house resistor found for ...mpnmanufacturerpcb bom <FILE> -f jsonavailability_tier"plenty""limited""insufficient"offers