xlsynth

Crates.ioxlsynth
lib.rsxlsynth
version
sourcesrc
created_at2024-05-30 17:08:18.175398
updated_at2024-12-11 06:41:34.989823
descriptionAccelerated Hardware Synthesis (XLS/XLSynth) via Rust
homepagehttps://github.com/xlsynth/xlsynth-crate
repositoryhttps://github.com/xlsynth/xlsynth-crate
max_upload_size
id1257077
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Chris Leary (cdleary)

documentation

https://docs.rs/xlsynth

README

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 clean  # Make sure we pick up the new env var.
$ cargo test -vv |& grep -i "DSO from workspace"
[xlsynth-sys ...] cargo:info=Using DSO from workspace: ...

Where in ~/proj/xlsynth/ (the root of the xlsynth workspace) we build the DSO with

$ bazel build -c opt //xls/public:libxls.so

Note that on OS X you additionally will have to set:

$ export DYLD_LIBRARY_PATH=$HOME/proj/xlsynth/bazel-bin/xls/public/:$DYLD_LIBRARY_PATH

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.

Commit count: 113

cargo fmt