跳到主要内容

API 参考

iEDA.ai 提供 Python / MCP / Tcl 三种协议的完整 API。同一份 iDB 设计状态通过三种方式访问——返回相同类型的结果、遵循相同的安全模型。

iMapsynthesisiFPfloorplaniPDNpoweriPLplacementiCTSclockiTOoptimizationiRTroutingiSTAtimingAiEDAdesign dataiPCLlayout modeliMapsynthesisiFPfloorplaniPDNpoweriPLplacementiCTSclockiTOoptimizationiRTroutingiSTAtimingAiEDAdesign dataiPCLlayout model

Python SDK

Python SDK 是面向数据科学家和 AI 工程师的主入口。所有类型都有完整的 IDE 自动补全支持。

AgentClient

Agent 访问 iEDA 平台的入口类。管理会话、连接和配置。

class AgentClient(
    host: str = "localhost",
    port: int = 9090,
    protocol: str = "python",
    tracing: bool = False,
    timeout_ms: int = 30000,
)
# host:         iEDA Platform 服务地址
# port:         Interface gateway 端口
# protocol:     "python" | "mcp" | "tcl"
# tracing:      是否启用性能追踪
# timeout_ms:   默认工具调用超时(毫秒)

# Methods
def connect() -> None
def disconnect() -> None
def load_design(name: str, tech: str) -> DesignHandle
def call(tool: str, **kwargs) -> ToolResult
def list_tools(filter: Optional[str] = None) -> List[ToolDef]
def snapshot(design: DesignHandle, label: Optional[str] = None) -> SnapshotRef

load_design

def load_design(
    name: str,                   # 设计名称, e.g. "aes_core"
    tech: str,                   # 工艺库, e.g. "sky130", "nangate45"
    config: Optional[DesignConfig] = None,
) -> DesignHandle

# Example
client = AgentClient()
client.connect()
design = client.load_design("aes_core", tech="sky130")
print(f"Loaded: {design.cell_count} cells, {design.net_count} nets")

call

def call(
    tool: str,                   # 工具名称, e.g. "iPL.place", "iSTA.analyze"
    design: Optional[DesignHandle] = None,
    snap: Optional[SnapshotRef] = None,
    **kwargs,                    # 工具特定参数
) -> ToolResult

# Example
result = client.call(
    "iPL.place",
    design=design,
    effort="standard",
    congestion_weight=0.3,
)
print(result.hpwl)     # 1.25e7
print(result.density)  # 0.78

list_tools

def list_tools(
    filter: Optional[str] = None,  # 按名称前缀过滤, e.g. "iPL.*"
) -> List[ToolDef]

# Example
tools = client.list_tools(filter="iDB.*")
for t in tools:
    print(f"{t.name}: {t.description}")

MCP 协议

基于 Model Context Protocol 的标准化工具调用接口。适用于 AI 平台和 LLM 框架集成。

// List available tools
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/list"
}

// Response
{
  "tools": [
    {"name": "iDB.snapshot", "description": "...", "inputSchema": {...}},
    {"name": "iPL.place", "description": "...", "inputSchema": {...}}
  ]
}

// Call a tool
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "iPL.place",
    "arguments": {
      "design_ref": "aes_core@sky130",
      "effort": "standard"
    }
  }
}

// Error response
{
  "jsonrpc": "2.0",
  "id": 2,
  "error": {
    "code": -32602,
    "message": "Invalid params: 'effort' must be one of: quick, standard, exhaustive"
  }
}

Tcl 接口

面向 IC 工程师的传统 Tcl 命令行接口。与 Python SDK 和 MCP 访问同一个 iDB 实例。

# Load design
iDB::load_design aes_core sky130

# Take snapshot
iDB::snapshot -label "baseline"

# Place cells
iPL::place -effort standard -congestion_weight 0.3

# Analyze timing
iSTA::analyze -corners {ss_125c tt_25c}

# Get results
puts "WNS: [iSTA::get_wns]"
puts "TNS: [iSTA::get_tns]"
puts "HPWL: [iPL::get_hpwl]"

通用模式

错误处理

# Python — structured error handling
try:
    result = client.call("iPL.place", design=design, effort="invalid")
except ValidationError as e:
    print(f"Invalid parameter: {e.field} — {e.message}")
except TimeoutError:
    print(f"Tool call timed out after {client.timeout_ms}ms")
except GateFailure as e:
    print(f"Evaluation gate failed: {e.failures}")
except CASConflict as e:
    print(f"CAS conflict — rebase to {e.conflict_with}")

重试策略

from ieda import retry

result = retry(
    lambda: client.call("iSTA.analyze", snap=snap.id),
    max_attempts=3,
    backoff_ms=1000,
    on="TimeoutError",
)

分页

# Large result sets are paginated
cells = client.call("iDB.query", type="cell", page_size=10000)
while cells.has_next:
    print(f"Processing {len(cells.items)} cells...")
    cells = cells.next_page()

异步调用

import asyncio

client = AgentClient()
async def parallel_analysis():
    snap = client.call("iDB.snapshot", design=design)
    timing, drc = await asyncio.gather(
        client.async_call("iSTA.analyze", snap=snap.id),
        client.async_call("iDRC.check", snap=snap.id),
    )
    return timing, drc

准备好接入 iEDA Platform 了?

从 Quickstart 开始,五分钟让大模型驱动芯片布局。