Skip to main content

Zuspec Software Backend

The Zuspec Software (SW) Backend transforms Zuspec hardware component models into executable C/C++ code for simulation, testing, and modeling.

Features

  • Component Translation: Zuspec Components → C structs and functions

  • Async/Sync: Transforms async methods with optional sync conversion

  • Protocol Interfaces: Generates C API structs for Protocol types

  • Type Mapping: Maps Zuspec types to C types

  • Validation: Pre-generation compatibility checks

  • Compilation: Built-in GCC compiler interface

  • Test Execution: Automated test runner

  • Type Specialization: Optional monomorphization (experimental)

  • PSS → C (scenario path): compile PSS actions/activities/constraints to a self-contained C program via the shared Scenario Runtime IR — runtime constraint solving (dv-solve), sequential/repeat activities, and parallel/timed concurrency on the zsp_timebase scheduler. See docs/pss-to-c.md and examples/pss/. Independent of the datamodel-driven CGenerator below:

    from zuspec.be.sw.scenario import generate_c_files, build_executable
    srcs = generate_c_files(["examples/pss/02_constrained_regs.pss"], "out/", root="pss_top")
    build_executable(srcs, "out/case", "out/")   # → ./out/case <seed> <iters>
    

Installation

pip install zuspec-be-sw

Quick Start

import zuspec.dataclasses as zdc
from zuspec.be.sw import CGenerator, CValidator, CCompiler, TestRunner
from pathlib import Path

@zdc.dataclass
class Counter(zdc.Component):
    count: int = zdc.field(default=0)
    
    def increment(self):
        self.count += 1
    
    def get_count(self) -> int:
        return self.count

# Build → Validate → Generate → Compile → Run
factory = zdc.DataModelFactory()
ctxt = factory.build(Counter)

validator = CValidator()
assert validator.validate(ctxt)

gen = CGenerator(Path("output"))
sources = gen.generate(ctxt)

compiler = CCompiler(Path("output"))
exe = compiler.compile(sources, Path("output/test"))

runner = TestRunner()
result = runner.run(exe)

Generated C Code

typedef struct Counter {
    int count;
} Counter;

void Counter_init(Counter *self);
void Counter_increment(Counter *self);
int Counter_get_count(Counter *self);

Documentation

Requirements

  • Python >= 3.7
  • zuspec-dataclasses
  • C compiler (GCC)

License

Apache-2.0

Metadata

Release files for zuspec-be-sw 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for zuspec-be-sw 0.2.0
File Interpreter ABI Platform
zuspec_be_sw-0.2.0-py3-none-any.whl Python 3 none any Details

Release files / zuspec_be_sw-0.2.0-py3-none-any.whl

Download URL zuspec_be_sw-0.2.0-py3-none-any.whl
Size 263.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4654189f1a26b813117d851768db95335dffb6d8ab0a5375a8df69f915840d9f
BLAKE2b-256 checksum
How to use checksums
d5e464fb1b9eea4df39b1cdc6e292b15ed4f38e8f8b2fad54f7bae7d97f76d88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file

0.1.0

1 release file

0.0.9

15 release files

0.0.8

15 release files

0.0.7

15 release files

0.0.5

5 release files

0.0.4

5 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page