Skip to content

LangGraph Migration Plan for SoC Designer

In progress · updated 2026-10-30 · embodied-ai-architect/docs/plan/langgraph-migration-plan.md

This document outlines the migration from the current sequential Orchestrator pattern to a LangGraph-based state machine for SoC optimization workflows.

AspectCrewAILangGraph
Execution ModelRole-based agents in sequence/hierarchyExplicit state graph with conditional edges
State ManagementImplicit via context passingExplicit TypedDict state with full control
Cycles/LoopsAwkward (Flows try to add this)Native add_conditional_edges
CheckpointingNot built-inPostgreSQL/Redis checkpointers
Human-in-the-loopManual implementationinterrupt_before built-in
Long-running jobsPoor supportAsync + checkpointing designed for this
DebuggingLimited“Time travel” state inspection
Orchestrator.process()
→ ModelAnalyzer.execute()
→ HardwareProfile.execute()
→ Benchmark.execute()
→ ReportSynthesis.execute()
StateGraph[SoCDesignState]
┌─────────────┐
│ architect │ ←──────────────┐
└──────┬──────┘ │
↓ │
┌─────────────┐ │
│ linter │ ───(fail)──────┤
└──────┬──────┘ │
↓ (pass) │
┌─────────────┐ │
│ synthesis │ ───(fail)──────┤
└──────┬──────┘ │
↓ (pass) │
┌─────────────┐ │
│ validation │ ───(fail)──────┤
└──────┬──────┘ │
↓ (pass) │
┌─────────────┐ │
│ critic │ ───(iterate)───┘
└──────┬──────┘
↓ (success)
[END]
class SoCDesignState(TypedDict):
# Design artifacts
rtl_code: str # Current Verilog source
top_module: str # Top-level module name
testbench: Optional[str] # Testbench for validation
# Constraints and metrics
constraints: dict # Target PPA
baseline_metrics: Optional[dict] # Original design metrics
current_metrics: Optional[dict] # Latest synthesis results
# Optimization state
iteration: int # Current iteration count
max_iterations: int # Safety limit
history: List[dict] # Log of all changes
# Routing control
next_action: Literal[
"architect", "lint", "synthesize",
"validate", "critique", "sign_off", "abort"
]
# Error tracking
last_error: Optional[str]
lint_errors: List[str]
synthesis_errors: List[str]
  • Uses LLM to analyze current design and propose optimizations
  • Strategies: pipelining, resource sharing, logic restructuring
  • Outputs modified RTL code
  • Uses Verilator --lint-only for sub-second feedback
  • Catches syntax errors before expensive synthesis
  • Routes back to architect on failure
  • Uses Yosys for gate-level synthesis
  • Extracts PPA metrics (area, cell count)
  • Stores baseline on first run
  • Uses Icarus Verilog for functional simulation
  • Ensures optimized design is functionally correct
  • Catches semantic errors LLM might introduce
  • Analyzes PPA metrics against constraints
  • Determines if design meets targets or needs iteration
  • Routes to architect for another attempt or to END on success
  • Add langgraph to dependencies
  • Create src/embodied_ai_architect/langgraph/ package
  • Implement SoCDesignState schema
  • Port existing tools to work as LangGraph nodes
  • Implement the 5 core nodes
  • Build state graph with conditional routing
  • Add basic CLI command
  • Test with RISC-V ALU example
  • Add PostgreSQL checkpointing
  • Implement human-in-the-loop breakpoints
  • Add WebSocket streaming for progress
  • Create experience cache
  • Integrate with existing CLI
  • Add visualization (LangSmith or custom)
  • Containerize EDA tools
  • Documentation

The initial test case is a simple ALU with known optimization opportunities:

module alu_core (
input [31:0] a, b, c, d,
output [31:0] result
);
// Deep combinational path - will fail timing at high freq
assign result = (a * b) + (c * d);
endmodule

Expected optimization: Pipeline the multipliers to meet timing.

[project.optional-dependencies]
langgraph = [
"langgraph>=0.2.0",
"langchain-anthropic>=0.3.0",
"langgraph-checkpoint-postgres>=0.1.0",
]