Skip to main content

Domain Specific Language for Instruction Set Architecture descriptions

Project description

ISA DSL - Instruction Set Architecture Domain Specific Language

A powerful Domain Specific Language (DSL) for describing Instruction Set Architectures (ISA) using textX. This DSL enables you to specify instruction formats, registers, instruction encodings, and behavior in RTL (Register Transfer Level) notation, with automatic code generation for simulators, assemblers, disassemblers, and documentation.

Features

  • Complete ISA Specification: Define instruction formats, registers (GPRs, SFRs, and vector registers), and instruction encodings
  • RTL Behavior: Specify instruction behavior using Register Transfer Level notation with support for:
    • Arithmetic and logical operations
    • Conditional statements
    • Memory access operations
    • Vector/SIMD operations
  • Automatic Code Generation: Generate production-ready tools:
    • Python-based instruction simulators
    • Assemblers for your ISA
    • Disassemblers for binary code
    • Markdown documentation
  • SIMD Support: Built-in support for vector registers and SIMD instructions
  • Validation: Comprehensive semantic validation of ISA specifications

Installation

Prerequisites

  • Python 3.8 or higher
  • UV (recommended) or pip

Using UV (Recommended)

UV is a fast Python package manager. Install it first:

# Install UV
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or on Windows: powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

Then install the project:

# Clone the repository
git clone <repository-url>
cd isa-dsl

# Install the project and dependencies
uv sync

# Or install in development mode with test dependencies
uv sync --dev

Using pip (Alternative)

# Clone the repository
git clone <repository-url>
cd isa-dsl

# Install dependencies
pip install -r requirements.txt

# Or install in editable mode
pip install -e .

Quick Start

  1. Define your ISA in a .isa file (see examples/arm_cortex_a9.isa for a multi-file example)

  2. Generate tools:

# Using UV
uv run isa-dsl generate examples/arm_cortex_a9.isa --output output/

# Or using Python directly
python -m isa_dsl.cli generate examples/arm_cortex_a9.isa --output output/
  1. Use the generated tools:
# Validate your ISA
uv run isa-dsl validate examples/arm_cortex_a9.isa

# Get ISA information
uv run isa-dsl info examples/arm_cortex_a9.isa

# Run the generated simulator
python output/simulator.py program.bin

Documentation

All technical documentation is available in the docs/ folder:

  • INDEX.md: Documentation index and navigation guide - Start here to find what you need
  • DSL_Specification.md: Complete DSL specification covering all features including syntax, registers, formats, instructions, RTL behavior, variable-length instructions, bundling, SIMD, and more
  • EXAMPLES.md: Detailed documentation of example ISA specifications with learning paths and common patterns
  • TESTING.md: Complete testing documentation including test suite overview, how to run tests, and how to add new tests

Examples

The examples/ directory contains reference ISA specifications demonstrating best practices:

  • arm_cortex_a9.isa: Main ARM Cortex-A9 ISA specification (multi-file reference)
    • arm_cortex_a9_registers.isa - Register definitions
    • arm_cortex_a9_formats.isa - Instruction format definitions
    • arm_cortex_a9_instructions.isa - Instruction definitions

This demonstrates the multi-file approach using #include directives and cross-file format reference resolution.

Note: Test-specific ISA examples are located in tests/*/test_data/ directories.

To generate tools from the reference example:

uv run isa-dsl generate examples/arm_cortex_a9.isa --output output/

Command-Line Interface

The isa-dsl command provides several subcommands:

Generate Tools

uv run isa-dsl generate <isa_file> --output <output_dir>

Options:

  • --simulator / --no-simulator: Generate simulator (default: enabled)
  • --assembler / --no-assembler: Generate assembler (default: enabled)
  • --disassembler / --no-disassembler: Generate disassembler (default: enabled)
  • --docs / --no-docs: Generate documentation (default: enabled)

Validate ISA

uv run isa-dsl validate <isa_file>

Display ISA Information

uv run isa-dsl info <isa_file>

Testing

The project includes a comprehensive test suite with 111 automated tests covering:

  • Core functionality: ISA parsing, validation, RTL interpretation
  • Code generation: Assembler, simulator, disassembler, documentation generators
  • Advanced features: Variable-length instructions, instruction bundling, distributed operands
  • Integration tests: End-to-end workflows, QEMU verification, ARM toolchain integration
  • Multi-file support: Include processing, inheritance, merge modes
  • Assembly syntax: Formatting, literal braces, backward compatibility

Running Tests

# Run all tests
uv run pytest

# Run with verbose output
uv run pytest -v

# Run with coverage
uv run pytest --cov

# Run specific test suite
uv run pytest tests/arm/

Test Status: ✅ All 111 tests passing, 0 skipped, 0 failed

Development

Setup Development Environment

# Install UV if not already installed
curl -LsSf https://astral.sh/uv/install.sh | sh

# Sync dependencies (including dev dependencies)
uv sync --dev

# Run tests
uv run pytest

# Run tests with coverage
uv run pytest --cov

Code Quality

  • All test functions are limited to 50 lines or less
  • All test files are limited to 500 lines or less
  • Helper functions are organized as class methods in separate files
  • Comprehensive test coverage across all major features

Requirements

  • Python 3.8+
  • textX >= 3.0.0
  • Jinja2 >= 3.1.0
  • Click >= 8.1.0

For development:

  • pytest >= 7.4.0
  • pytest-cov >= 4.1.0

Deployment

Production Readiness

Ready for deployment - The project is production-ready with:

  • Comprehensive test suite (111 tests, all passing)
  • Well-documented API and CLI interface
  • Modular, maintainable codebase
  • Complete documentation
  • Example ISA specifications
  • Validation and error handling

Installation for Production

# Using UV (recommended)
uv sync

# Or using pip
pip install -r requirements.txt
pip install -e .

Building Distribution Packages

# Build wheel and source distribution
python -m build

# Or using UV
uv build

License

MIT License

Contributing

Contributions are welcome! Please ensure that:

  • All tests pass (uv run pytest)
  • Code follows existing style conventions
  • Documentation is updated for new features
  • Test functions are kept under 50 lines
  • Test files are kept under 500 lines

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

isa_dsl-0.1.1.tar.gz (107.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

isa_dsl-0.1.1-py3-none-any.whl (59.4 kB view details)

Uploaded Python 3

File details

Details for the file isa_dsl-0.1.1.tar.gz.

File metadata

  • Download URL: isa_dsl-0.1.1.tar.gz
  • Upload date:
  • Size: 107.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for isa_dsl-0.1.1.tar.gz
Algorithm Hash digest
SHA256 64db8572f275d56b6678920293eb4eb9d0f05325e4a4801556b81f6e8120b667
MD5 325fb702039439cbd38a4174cabd089c
BLAKE2b-256 7a1566e2e6c539ee07afc258dffd5be80b3bf01b11ec89d3b75127d99c1e1dce

See more details on using hashes here.

Provenance

The following attestation bundles were made for isa_dsl-0.1.1.tar.gz:

Publisher: publish-to-pypi.yml on ajithpadman/isadsl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file isa_dsl-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: isa_dsl-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 59.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for isa_dsl-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4c595249c022a6ccaeed85a47fe6d758bd1e980972217b4b2c49f7d45d399951
MD5 dc63ca0c703294111f3914be5a9c452c
BLAKE2b-256 9bc13483eba33e0daee38e160cc661cdc388b4c1509ed2a086b39f79bd8cc024

See more details on using hashes here.

Provenance

The following attestation bundles were made for isa_dsl-0.1.1-py3-none-any.whl:

Publisher: publish-to-pypi.yml on ajithpadman/isadsl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page