๐Ÿงช Python Model โ€” Reference Implementation for AITL Architecture

PID ร— FSM ร— LLM baseline model used across all downstream hardware flows

This document explains the Python implementation of the AITL architecture as built in Chapter 1.
It describes the structure, design rationale, and execution flow of each component, forming the behavioral golden model for RTL, ASIC, and SPICE verification.


๐ŸŽฏ Purpose of This Document


๐Ÿงฑ Python Model Structure

chapter1_python_model/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ pid.py
โ”‚   โ”œโ”€โ”€ fsm.py
โ”‚   โ”œโ”€โ”€ aitl_controller.py
โ”‚   โ””โ”€โ”€ llm_placeholder.py
โ”œโ”€โ”€ sim/
โ”‚   โ”œโ”€โ”€ run_step_response.py
โ”‚   โ””โ”€โ”€ run_fault_scenario.py
โ”œโ”€โ”€ plots/
โ”œโ”€โ”€ tests/
โ””โ”€โ”€ main.py

Each file has a strict role, matching the separation of concerns used later in RTL and ASIC design.


1๏ธโƒฃ PID Controller (pid.py)

The PID controller is implemented as a class maintaining its own internal memory:

class PID:
    def __init__(self, kp, ki, kd, dt):
        self.kp, self.ki, self.kd = kp, ki, kd
        self.dt = dt
        self._integral = 0
        self._prev = 0

๐Ÿ” Key Behavioral Rules

1. Error computation

e = setpoint - measured

2. Integral accumulation

_integral += e * dt

3. Derivative term

d = (e - _prev) / dt

4. Output

u = kp*e + ki*integral + kd*d

5. Memory update

_prev = e

6. Execution Timing

PID runs only when FSM state is STARTUP or RUN.

7. Disabled Output

In IDLE and FAULT:
โ†’ PID output must be 0, internal memory preserved unless explicitly reset.

These rules must be preserved 1:1 in Verilog.


2๏ธโƒฃ FSM โ€” Supervisory Logic (fsm.py)

The FSM defines four stable states:

class AITLState(Enum):
    IDLE = auto()
    STARTUP = auto()
    RUN = auto()
    FAULT = auto()

๐Ÿ”„ Canonical Transition Logic

The FSM transition function:

def update_fsm(self):
    if state == IDLE:
        if start_cmd: โ†’ STARTUP

    if state == STARTUP:
        if error_detected: โ†’ FAULT
        elif startup_done: โ†’ RUN

    if state == RUN:
        if error_detected: โ†’ FAULT

    if state == FAULT:
        if reset_cmd: โ†’ IDLE

These transitions are canonical

Meaning:

No additional transitions are permitted.


3๏ธโƒฃ AITL Controller Integration (aitl_controller.py)

This module binds PID + FSM into a single executable control unit.

class AITLControllerA:
    def __init__(self, pid):
        self.pid = pid
        self.state = AITLState.IDLE

๐Ÿงฉ Responsibilities

  1. Manage command inputs:
    • start_cmd
    • reset_cmd
    • error_detected
    • startup_done
  2. Handle setpoint and measurement

  3. Call FSM update function

  4. Enable/disable PID

  5. Produce control output

Execution Logic (step() function)

def step(self, measured):
    self.measured = measured
    self._update_fsm()
    
    if self.state in (STARTUP, RUN):
        self.control_output = self.pid.update(self.setpoint, measured)
    else:
        self.control_output = 0

    return self.control_output

Step Execution Timeline

  1. Inputs latched
  2. FSM transition executed
  3. PID enabled or disabled
  4. Control output computed
  5. Return output for simulation or logging

This execution order MUST remain unchanged in RTL.


4๏ธโƒฃ LLM Layer (Placeholder) (llm_placeholder.py)

This module is intentionally minimal:

Purpose:

RTL implementation simply ignores this module.


5๏ธโƒฃ Simulation Scripts (sim/)

Two simulation scenarios validate controller behavior.


๐Ÿ“ˆ Step Response (run_step_response.py)

Simulates plant response to a setpoint step input.

Verifies:

Plot saved into:

plots/step_response_YYYYMMDD_HHMMSS.png

โš ๏ธ Fault Scenario (run_fault_scenario.py)

Injects faults during execution:

This scenario validates supervisory logic under failure.


6๏ธโƒฃ Testing (tests/)

Provides Python unit tests:

These tests prevent regressions before RTL development begins.


๐Ÿงฉ Alignment With Downstream Hardware Design

This Python model acts as the behavioral golden model for:

Stage Relation
RTL (Ch.2) Must replicate PID + FSM behavior cycle-by-cycle
OpenLane (Ch.3) Controller logic becomes hardware blocks
Magic (Ch.4) Extracted parasitics must not break function
SPICE (Ch.5) Waveforms must match Python baseline

If Python behavior changes, all downstream verification must restart.


๐Ÿ“ฆ Summary of Guarantees

The Python model provides:

This ensures a stable pathway from software to silicon.


๐Ÿš€ Next

Continue to:

๐Ÿ‘‰ fsm.md โ€” Formal state transition rules and canonical table (for RTL)
๐Ÿ‘‰ api.md โ€” Programmatic interface specification


ยฉ AITL Silicon Pathway Project