π API Reference β AITL Python Baseline Model
PID Γ FSM Γ Controller interface documentation
This API reference defines the public interfaces, attributes, methods, and behavioral contracts for the Python implementation of the AITL hybrid control architecture.
These APIs are the canonical reference for RTL designers, testbench writers, and anyone extending the AITL system.
π§© Modules Overview
The Python model consists of the following modules:
| File | Contains |
|---|---|
pid.py |
PID controller class |
fsm.py |
State enum + finite state machine logic |
aitl_controller.py |
Top-level controller combining PID + FSM |
llm_placeholder.py |
Stubs for future adaptation layer |
Only documented functions and fields below should be considered βpublic API.β
1οΈβ£ PID Class (pid.py)
PID(kp, ki, kd, dt)
Initializes a discrete-time PID controller.
π Attributes
| Attribute | Type | Description |
|---|---|---|
kp |
float | Proportional gain |
ki |
float | Integral gain |
kd |
float | Derivative gain |
dt |
float | Sampling interval |
_integral |
float | Accumulated integral term |
_prev |
float | Previous error (for derivative term) |
_integral and _prev must persist across control steps unless explicitly reset.
π Methods
update(setpoint, measured) β float
Compute control output for the current timestep.
Steps:
e = setpoint - measured- Accumulate integral:
_integral += e * dt - Compute derivative:
d = (e - _prev) / dt - Output:
u = kp*e + ki*_integral + kd*d - Update memory:
_prev = e
π Behavioral Contract
- Must run only when the FSM allows (STARTUP, RUN).
- Output must be exactly zero in IDLE and FAULT (handled by controller).
- Internal memory must never reset unless FSM or controller performs a reset.
- Arithmetic behavior must be preserved in RTL (Chapter 2).
2οΈβ£ FSM Logic (fsm.py)
AITLState(Enum)
Defines the four supervisory states:
IDLE, STARTUP, RUN, FAULT
π Transition Function
FSM transitions are implemented inside the controller, but rules are as follows:
From IDLE
if start_cmd β STARTUP
else remain in IDLE
From STARTUP
if error_detected β FAULT
elif startup_done β RUN
else remain in STARTUP
From RUN
if error_detected β FAULT
else remain in RUN
From FAULT
if reset_cmd β IDLE
else remain in FAULT
These rules are canonical and must not be changed in downstream implementations.
3οΈβ£ AITLControllerA (aitl_controller.py)
The top-level controller orchestrating FSM + PID.
AITLControllerA(pid: PID)
π Attributes
| Attribute | Description |
|---|---|
pid |
PID instance used for control |
state |
Current FSM state |
setpoint |
Target value for PID |
measured |
Latest measurement |
control_output |
Current control output |
start_cmd |
Boolean command to start system |
reset_cmd |
Boolean command to clear FAULT |
startup_done |
Boolean flag signaling adequate initialization |
error_detected |
Boolean fault input |
All these fields may be toggled externally by simulation or higher-level logic.
π Methods
step(measured) β float
Runs a single cycle of controller logic:
- Latch measurement:
self.measured = measured - Update FSM state
- If
state β {STARTUP, RUN}β compute PID output - Otherwise β output = 0
- Return control output
This function is the core behavioral loop and must be preserved exactly in RTL.
_update_fsm()
Internal helper implementing transition logic.
Not intended for external use.
reset()
Resets controller to safe IDLE configuration.
Internal PID memory is not cleared unless explicitly desired.
4οΈβ£ LLM Placeholder (llm_placeholder.py)
Current implementation is intentionally empty:
class LLMModule:
def update(self, controller_state):
pass
Purpose:
- Reserve interface for future intelligent behavior
- Avoid influence on deterministic baseline model
- Allow future PID tuning / FSM rewriting modules to hook in
NOT translated to RTL.
5οΈβ£ Module Interactions
External Inputs β FSM β PID β Control Output
β
βββββ LLM (future)
Behavioral Summary
| Component | Role |
|---|---|
| PID | Computes control output |
| FSM | Determines whether PID may run |
| Controller | Coordinates timing and safety |
| LLM | Placeholder |
6οΈβ£ Error & Reset Behavior
| Condition | Result |
|---|---|
error_detected = True |
FSM β FAULT, PID disabled |
reset_cmd = True |
FSM β IDLE, output = 0 |
start_cmd = True |
FSM β STARTUP |
startup_done = True |
FSM β RUN |
No side effects or hidden transitions permitted.
π Summary
This API defines the official behavioral contract for the AITL Python model.
Downstream RTL must replicate:
- methods
- internal memory behavior
- enable/disable logic
- FSM transitions
- PID computations
This ensures functional equivalence across Python β RTL β ASIC β SPICE.
β Next Document
π getting_started.md β Installation, execution, simulation usage