Example 1: Agent 驱动时序修复
Agent 检测到时序违规后,自主调用 iSTA 诊断根因、iTO 生成 ECO 方案、iSTA 验证修复效果——形成完整的闭环优化。
场景描述
Post-Route 阶段发现关键路径 WNS = -0.15ns。Agent 使用 iSTA 诊断出 3 条违规路径的根因:两条 buffer delay 过大(需要 resize)、一条绕线过长(需要局部 reroute)。
Agent 决策链
Step 1: iSTA.diagnose(WNS, path) → 根因: buffer_oversized x2, route_detour x1
Step 2: iTO.propose(resize=2, reroute=1) → 3 candidates
Step 3: Evaluation.gate(candidates) → candidate_2 selected (best WNS+area trade-off)
Step 4: iSTA.verify(candidate_2) → WNS=-0.02ns, PASS
Python 实现
from ieda import AgentClient from ieda.evaluation import Gate client = AgentClient() # Step 1: Diagnose timing root causes timing = client.call("iSTA.analyze", design_ref="post_route_snap") if timing.wns < 0: # Step 2: Get diagnostic & generate ECO diagnosis = client.call("iSTA.diagnose", path=timing.critical_paths[0]) eco = client.call("iTO.propose", diagnosis=diagnosis) # Step 3: Evaluate all candidates through gate for candidate in eco.candidates: result = client.call("iTO.apply", candidate=candidate) gate = Gate.judge(before="post_route_snap", after=result.design_ref) if gate.wns >= -0.05 and gate.drc_count == 0: best_candidate = candidate break # Step 4: Verify and commit verify = client.call("iSTA.verify", design_ref=best_candidate.design_ref) print(f"Timing closed: WNS={verify.wns}ns") client.call("iDB.commit", design_ref=best_candidate.design_ref)
Example 2: Agent 驱动布局优化
Agent 在布局完成后检测到局部拥塞和时序违规,自主迭代 iPL 局部优化 + iSTA 增量分析,形成反馈闭环。
场景描述
iPL 全局布局完成后,Agent 通过 iSTA 分析发现某区域既有高拥塞又有 setup time violation。Agent 使用 iPL 的 local move 能力进行定向优化——在不影响全局 HPWL 的情况下,通过微调局部单元位置同时改善拥塞和时序。
Agent 决策链
Step 1: iPL.place(region) + iSTA.analyze(snap) → 拥塞热点 + WNS violation
Step 2: iPL.propose_local_move(hotspot, max_displacement=50um) → 5 candidates
Step 3: iSTA.incremental(candidates, dirty_set) → candidate_3: WNS=-0.01ns, congestion 改善 30%
Step 4: iDB.commit(candidate_3) → 局部优化完成,全局 HPWL 仅增加 0.3%
Python 实现
from ieda import AgentClient client = AgentClient() # Step 1: Global place + analyze place = client.call("iPL.place", design_ref="snap_fp") timing = client.call("iSTA.analyze", design_ref=place.design_ref) # Step 2: Detect hotspot region hotspot = (timing.wns < 0 and place.congestion_map["max_bin"] > 0.85) if hotspot: # Step 3: Iterative local optimization with feedback loop best_hpwl = place.hpwl for iteration in range(5): move = client.call( "iPL.propose_local_move", design_ref=place.design_ref, region=hotspot.bbox, max_displacement_nm=50000, ) incr = client.call( "iSTA.analyze", design_ref=move.design_ref, incremental=True, dirty_set=move.dirty_set, ) if incr.wns >= 0 and move.hpwl <= best_hpwl * 1.05: best_hpwl = min(best_hpwl, move.hpwl) client.call("iDB.commit", design_ref=move.design_ref) print(f"Iteration {iteration}: WNS={incr.wns}, HPWL={move.hpwl}") break
Example 3: Agent 做全流程
Agent 从 RTL 出发,驱动完整的物理设计流程——综合、布图规划、电源、布局、时钟树、优化、布线、时序分析、DRC——每个阶段自主决策并在 Evaluation gate 下推进。
全流程工具链
iMap (综合) → iFP (布图) → iPDN (电源) → iPL (布局) → iCTS (时钟) → iTO (优化) → iRT (布线) → iSTA (时序) → iDRC (检查)
每个阶段之间 Agent 通过 Evaluation gate 判断是否进入下一步或回退重做。
Agent 在全流程中的角色
Agent 不是被动执行脚本——它在每个阶段检查中间结果、比较多个候选方案、决定是否回退到上一阶段重做、或跳过某些阶段(如设计已经满足 DRC 要求则跳过修复)。全流程由 Agent Planner 编排,Runtime 管理分支与事务。
Python 实现(全流程骨架)
from ieda import AgentClient from ieda.planner import FlowPlanner client = AgentClient() planner = FlowPlanner(client) # Define the full flow with exit criteria at each stage flow = [ {"tool": "iMap", "op": "synthesize", "gate": {"area": "< 1.2e6"}}, {"tool": "iFP", "op": "floorplan", "gate": {"util": "< 0.80"}}, {"tool": "iPDN", "op": "power_grid", "gate": {"ir_drop": "< 5%"}}, {"tool": "iPL", "op": "place", "gate": {"density": "< 0.85"}}, {"tool": "iCTS", "op": "build_clock", "gate": {"skew": "< 50ps"}}, {"tool": "iTO", "op": "optimize", "gate": {"wns": ">= -0.05"}}, {"tool": "iRT", "op": "route", "gate": {"drc_count": "== 0"}}, {"tool": "iSTA", "op": "signoff", "gate": {"wns": ">= 0"}}, {"tool": "iDRC", "op": "signoff", "gate": {"drc_count": "== 0"}}, ] # Execute flow: Agent Planner handles retry, rollback, branch result = planner.execute( flow=flow, design_ref="riscv_core", auto_recover=True, max_retries_per_stage=3, ) if result.all_stages_passed: print("Full RTL-to-GDS flow completed successfully!") print(f"Final design_ref: {result.design_ref}") else: print(f"Failed at stage: {result.failed_stage}") print(f"Gate failures: {result.gate_failures}")