33 releases

0.0.35 Oct 29, 2024
0.0.34 Oct 28, 2024
0.0.27 Sep 23, 2024
0.0.21 Aug 22, 2024
0.0.1 May 30, 2024

#258 in Hardware support

Download history 93/week @ 2024-07-29 323/week @ 2024-08-12 606/week @ 2024-08-19 16/week @ 2024-08-26 276/week @ 2024-09-02 38/week @ 2024-09-09 734/week @ 2024-09-16 285/week @ 2024-09-23 499/week @ 2024-09-30 470/week @ 2024-10-07 751/week @ 2024-10-14 148/week @ 2024-10-21 376/week @ 2024-10-28

1,977 downloads per month
Used in 2 crates

Apache-2.0

135KB
3.5K SLoC

XLS (AKA XLSynth) Rust Crate

Rust bindings to the functionality in the "Accelerated Hardware Synthesis" library.

extern crate xlsynth;

use xlsynth::{IrValue, IrPackage, IrFunction, XlsynthError};

fn sample() -> Result<IrValue, XlsynthError> {
    let package: IrPackage = xlsynth::convert_dslx_to_ir(
        "fn id(x: u32) -> u32 { x }",
        std::path::Path::new("/memfile/sample.x"))?;
    let mangled = xlsynth::mangle_dslx_name("sample", "id")?;
    let f: IrFunction = package.get_function(&mangled)?;
    let ft: IrValue = IrValue::parse_typed("bits[32]:42")?;
    f.interpret(&[ft])
}

fn main() {
    assert_eq!(sample().unwrap(), IrValue::parse_typed("bits[32]:42").unwrap());
}

Development Notes

The xlsynth Rust crate leverages a dynamic library with XLS' core functionality (i.e. libxls.so / libxls.dylib).

The DSO is built and released for multiple platforms via GitHub actions at xlsynth/xlsynth/releases.

The version that this crate expects is described in xlsynth-sys/build.rs as RELEASE_LIB_VERSION_TAG. By default, this crate pulls the dynamic library from the targeted release.

To link against a local version of the public API, instead of a released version, supply the DEV_XLS_DSO_WORKSPACE environment variable pointing at the workspace root where the built shared library resides; e.g.

$ export DEV_XLS_DSO_WORKSPACE=$HOME/proj/xlsynth/
$ ls $DEV_XLS_DSO_WORKSPACE/bazel-bin/xls/public/libxls.so
/home/cdleary/proj/xlsynth//bazel-bin/xls/public/libxls.so
$ cargo test -vv |& grep -i workspace
[xlsynth-sys ...] cargo:info=Using DSO from workspace: ...

Pre-Commit

The pre-commit tool is used to help with local checks before PRs are created:

$ sudo apt-get install pre-commit
$ pre-commit install
$ pre-commit run --all-files

This pre-commit step is also run as part of continuous integration.

Dependencies

~0–2.1MB
~37K SLoC