API Reference
This section documents ALY’s Python API for programmatic access.
Overview
ALY’s API is organized into modules:
Figure 26 API Module Structure
Configuration API
ProjectConfig
- class aly.config.ProjectConfig[source]
Bases:
objectUnified configuration manager and component registry for ALY projects.
Loads configuration from .aly/ directory and discovers components through manifest.yaml files in configured paths. Provides unified access to all project settings and components.
Example
config = ProjectConfig.load(“.”)
# Access project info print(config.info.name)
# Get RTL block cpu = config.get_rtl_block(“cpu”)
# Get testbench tb = config.get_testbench(“tb_alu”)
# List all components rtl_blocks = config.list_rtl_blocks()
# Resolve dependencies deps = config.resolve_rtl_deps(tb)
- classmethod load(project_root)[source]
Load configuration from project root.
- Parameters:
- Returns:
Loaded ProjectConfig instance
- Raises:
SystemExit – If configuration is missing or invalid
- Return type:
- discover_all()[source]
Scan all configured paths for manifest.yaml files.
This is the main discovery method that populates the component registry. It’s called lazily on first access to any get/list method.
- Return type:
None
- get_unit(kind, name)[source]
Get a unit (rtl_module, testbench, firmware_build, …) by kind and name.
- get_rtl_module(name)[source]
Get a single RTL module unit by name.
- Parameters:
name (str)
- Return type:
UnitRef | None
- iter_rtl_modules()[source]
Iterate over all RTL module units.
- Yields:
UnitRef objects for each RTL module.
- get_rtl_module_objects()[source]
Get all RTL modules with their parent manifests.
- Returns:
module_name -> (module_obj, parent_manifest)
- Return type:
Dict
- get_rtl_module_files(module_name)[source]
Get compilation files (packages + module files) for a given RTL module.
Module is looked up project-wide, by name.
- get_rtl_module_package_files(module_name)[source]
Get package files that apply to a given RTL module.
- get_testbench_unit(name)[source]
Get a single testbench unit by name.
Requires that TestbenchManifest exposes a testbenches list and that _register() populates _units[“testbench”].
- Parameters:
name (str)
- Return type:
UnitRef | None
- get_testbench(name)[source]
Get a testbench by name (returns Testbench object).
This is a convenience method that returns the testbench object directly, rather than the UnitRef wrapper.
- iter_testbenches()[source]
Iterate over all testbench units.
- Yields:
UnitRef objects for each testbench.
- resolve_rtl_deps(unit, _visited=None)[source]
Recursively resolve RTL dependencies for a unit (testbench or RTL module).
- Parameters:
- Returns:
List of UnitRef objects (containing both RTLModule obj and RTLManifest manifest) in dependency order (dependencies before dependents)
- Return type:
List[UnitRef]
- resolve_package_dep_files(testbench)[source]
Resolve package dependencies for a testbench and return file paths.
- get_package_unit(name)[source]
Get a package unit by name.
- Parameters:
name (str) – The package name to look up.
- Returns:
UnitRef containing the RTLPackage obj and parent RTLManifest.
- Return type:
UnitRef | None
- get_package(name)[source]
Get a package by name (returns RTLPackage object).
This is a convenience method that returns the package object directly, rather than the UnitRef wrapper.
- Parameters:
name (str)
- Return type:
RTLPackage | None
- iter_packages()[source]
Iterate over all package units.
- Yields:
UnitRef objects for each named package.
- get_package_files_by_names(names)[source]
Get package files by their names (for dependency resolution).
- get_firmware_build(name)[source]
Get a single firmware build unit by name.
Requires that FirmwareManifest exposes a builds list and that _register() populates _units[“firmware_build”].
- Parameters:
name (str)
- Return type:
UnitRef | None
- get_firmware(name)[source]
Get a firmware build by name (returns FirmwareBuild object).
This is a convenience method that returns the build object directly, rather than the UnitRef wrapper.
- Parameters:
name (str)
- Return type:
FirmwareBuild | None
- list_firmware()[source]
List all firmware build names.
Convenience alias for list_firmware_builds().
- iter_firmware_builds()[source]
Iterate over all firmware build units.
- Yields:
UnitRef objects for each firmware build.
- get_toolchain(name)[source]
Get a toolchain by name.
- Parameters:
name (str)
- Return type:
Toolchain | None
- get_ip(name)[source]
Get an IP manifest by name.
- Parameters:
name (str)
- Return type:
IPManifest | None
- property sim: SimConfig
Simulation configuration.
- property synth: SynthConfig
Synthesis configuration.
- property lint: LintConfig
Lint configuration.
- property constraints: ConstraintsConfig
Constraints configuration.
- property fpga: FPGAConfig
FPGA configuration.
- get_sim_tool(name=None)[source]
Get simulator tool configuration.
- Parameters:
name (str | None)
- Return type:
SimToolConfig | None
The main configuration class for loading and accessing project settings.
Example:
from aly.config import ProjectConfig
# Load project configuration
config = ProjectConfig.load()
# Access project info
print(f"Project: {config.project.name}")
print(f"Version: {config.project.version}")
# Get simulation config
sim_config = config.simulation
print(f"Default simulator: {sim_config.default_tool}")
Model Classes
RTLManifest
- class aly.config.models.RTLManifest
RTL component manifest.
- packages: List[RTLPackage]
SystemVerilog packages
- classmethod load(path: Path) RTLManifest
Load manifest from YAML file.
- get_all_files() List[Path]
Get all RTL source files.
Example:
from pathlib import Path
from aly.config.models import RTLManifest
# Load RTL manifest
manifest = RTLManifest.load(Path("rtl/manifest.yaml"))
# Iterate modules
for module in manifest.modules:
print(f"Module: {module.name}")
for f in module.get_files():
print(f" - {f}")
RTLModule
TestbenchManifest
- class aly.config.models.TestbenchManifest
Testbench manifest for simulation.
- test_suites: List[TestSuite]
Test suite groupings
- classmethod load(path: Path) TestbenchManifest
Load from YAML file.
Testbench
FirmwareManifest
- class aly.config.models.FirmwareManifest
Firmware build manifest.
- toolchain: Toolchain
Compiler toolchain config
- builds: List[FirmwareBuild]
Build definitions
- classmethod load(path: Path) FirmwareManifest
Load from YAML file.
IPManifest
- class aly.config.models.IPManifest
Vendor IP block manifest.
- classmethod load(path: Path) IPManifest
Load from YAML file.
- get_rtl_files() List[Path]
Get RTL source files.
Backend API
Backends provide tool abstraction for simulation and synthesis.
Figure 27 Backend Class Hierarchy
SimulatorBackend
Base interface for simulation backends.
SynthBackend
Base interface for synthesis backends.
Utility Functions
Logging
Configuration Utilities
Template System
Usage Examples
Loading a Project
from aly.config import ProjectConfig
from aly.configuration import find_project_root
# Find and load project
root = find_project_root()
if root:
config = ProjectConfig.load(root)
print(f"Loaded project: {config.project.name}")
Running Simulation
from pathlib import Path
from aly.config import ProjectConfig
from aly.config.models import RTLManifest, TestbenchManifest
from aly.sim_xsim import XSimBackend
# Load configuration
config = ProjectConfig.load()
# Load manifests
rtl = RTLManifest.load(Path("rtl/manifest.yaml"))
tb = TestbenchManifest.load(Path("tb/manifest.yaml"))
# Get testbench
testbench = tb.get_testbench("tb_counter")
# Collect sources
sources = []
for dep in testbench.rtl_deps:
module = rtl.get_module(dep)
sources.extend(module.get_files())
sources.extend(testbench.get_files())
# Run simulation
backend = XSimBackend(config.simulation)
backend.compile(sources, {"waves": True})
backend.elaborate(testbench.top, {})
result = backend.simulate({"timeout": "1ms"})
print(f"Simulation {'passed' if result.passed else 'failed'}")
Programmatic Synthesis
from pathlib import Path
from aly.config import ProjectConfig
from aly.config.models import RTLManifest
from aly.synth_vivado import VivadoBackend
# Load configuration
config = ProjectConfig.load()
rtl = RTLManifest.load(Path("rtl/manifest.yaml"))
# Get target configuration
target = config.synthesis.get_target("arty_a7")
# Collect all RTL files
sources = rtl.get_all_files()
# Run synthesis
backend = VivadoBackend(config.synthesis)
backend.synthesize(
sources=sources,
top=target.top,
part=target.part,
constraints=target.constraints
)
Next Steps
Command Reference - CLI reference
Architecture - Internal architecture
Examples - More examples