Create a wrapper.h header and put all IEEE 1800 defs in the crate root

This makes life a bit easier as it avoids conflicting definitions
when including bindgen-generated code in the same module scope
and is more similar to what other bindings crates (ex. libc) do.
main
John Jekel 6 months ago
parent 8f00fffafe
commit 68438c40f3
  1. 2
      Cargo.lock
  2. 12
      Cargo.toml
  3. 2
      README.md
  4. 17
      build.rs
  5. 41
      include/wrapper.h
  6. 52
      lib/lib.rs

2
Cargo.lock generated

@ -255,7 +255,7 @@ checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380"
[[package]]
name = "sv-bindings"
version = "0.1.0"
version = "0.1.1"
dependencies = [
"bindgen",
]

@ -1,7 +1,7 @@
[package]
name = "sv-bindings"
version = "0.1.0"
description = "Raw FFI bindings for the SystemVerilog DPI, PLI, and VPI interfaces (IEEE 1800)."
version = "0.1.1"
description = "Raw FFI bindings for the (System)Verilog DPI, PLI, and VPI interfaces (IEEE 1800)."
authors = ["John Zacarias Jekel <john@jekel.ca>"]
readme = "README.md"
#homepage = ""
@ -14,13 +14,7 @@ keywords = ["verilog", "systemverilog", "dpi", "vpi", "bindings"]
#documentation = ""
[features]
default = ["svdpi", "vpi_user", "vpi_compatibility", "sv_vpi_user"]
#Raw bindings
svdpi = []
vpi_user = []
vpi_compatibility = []
sv_vpi_user = []
default = []
[build-dependencies]
bindgen = "0.69.1"

@ -3,3 +3,5 @@
Raw FFI bindings for the SystemVerilog DPI, PLI, and VPI interfaces (IEEE 1800).
TODO better readme with examples
If there is enough interest in this crate, and others wish to contribute, I can move the repo to GitHub or Gitlab.

@ -1,8 +1,8 @@
/*
* File: build.rs
* Brief: TODO
* Brief: Build script for the sv-bindings crate
*
* Copyright (C) TODO John Jekel
* Copyright (C) 2023 John Jekel
* See the LICENSE file at the root of the project for licensing info.
*
* TODO longer description
@ -38,14 +38,11 @@
* --------------------------------------------------------------------------------------------- */
const HEADERS_TO_BINDINGS: &[(&str, &str)] = &[
#[cfg(feature = "svdpi")]
("include/svdpi.h", "svdpi.rs"),
#[cfg(feature = "vpi_user")]
("include/vpi_user.h", "vpi_user.rs"),
#[cfg(feature = "vpi_compatibility")]
("include/vpi_compatibility.h", "vpi_compatibility.rs"),
#[cfg(feature = "sv_vpi_user")]
("include/sv_vpi_user.h", "sv_vpi_user.rs"),
//("include/svdpi.h", "svdpi.rs"),
//("include/vpi_user.h", "vpi_user.rs"),
//("include/vpi_compatibility.h", "vpi_compatibility.rs"),
//("include/sv_vpi_user.h", "sv_vpi_user.rs"),
("include/wrapper.h", "wrapper.rs")//Switching to a wrapper to make life easier
];
/* ------------------------------------------------------------------------------------------------

@ -0,0 +1,41 @@
/**
* @file wrapper.h
* @brief Wrapper around (System)Verilog headers to make life easier.
*
* @copyright Copyright (C) 2023 John Jekel
* See the LICENSE file at the root of the project for licensing info.
*
* TODO longer description
*
*/
#ifndef WRAPPER_H
#define WRAPPER_H
/* ------------------------------------------------------------------------------------------------
* Constants/Defines
* --------------------------------------------------------------------------------------------- */
//TODO
/* ------------------------------------------------------------------------------------------------
* Includes
* --------------------------------------------------------------------------------------------- */
#include "svdpi.h"
#include "vpi_user.h"
#include "sv_vpi_user.h"
/* ------------------------------------------------------------------------------------------------
* Type/Class Declarations
* --------------------------------------------------------------------------------------------- */
//TODO
/* ------------------------------------------------------------------------------------------------
* Function Declarations
* --------------------------------------------------------------------------------------------- */
//TODO
#endif//WRAPPER_H

@ -1,8 +1,8 @@
/*
* File: lib.rs
* Brief: TODO
* Brief: sv-bindings: Raw FFI bindings for the (System)Verilog DPI, PLI, and VPI interfaces (IEEE 1800).
*
* Copyright (C) TODO John Jekel
* Copyright (C) 2023 John Jekel
* See the LICENSE file at the root of the project for licensing info.
*
* TODO longer description
@ -10,7 +10,11 @@
*/
/*!
* TODO rustdoc for this file here
* sv-bindings: Raw FFI bindings for the (System)Verilog DPI, PLI, and VPI interfaces (IEEE 1800).
*
* If you wish to use sv-bindings, add it as a dependency!
*
* TODO better documentation
*/
#![allow(non_upper_case_globals)]
@ -18,44 +22,28 @@
#![allow(non_snake_case)]
/* ------------------------------------------------------------------------------------------------
* Submodules
* Includes
* --------------------------------------------------------------------------------------------- */
#[cfg(feature = "svdpi")]
mod svdpi {
include!(concat!(env!("OUT_DIR"), "/svdpi.rs"));
}
#[cfg(feature = "vpi_user")]
mod vpi_user {
include!(concat!(env!("OUT_DIR"), "/vpi_user.rs"));
}
/*
include!(concat!(env!("OUT_DIR"), "/svdpi.rs"));
include!(concat!(env!("OUT_DIR"), "/vpi_user.rs"));
include!(concat!(env!("OUT_DIR"), "/vpi_compatibility.rs"));
include!(concat!(env!("OUT_DIR"), "/sv_vpi_user.rs"));
*/
include!(concat!(env!("OUT_DIR"), "/wrapper.rs"));//Switching to a wrapper to make life easier
#[cfg(feature = "vpi_compatibility")]
mod vpi_compatibility {
include!(concat!(env!("OUT_DIR"), "/vpi_compatibility.rs"));
}
/* ------------------------------------------------------------------------------------------------
* Submodules
* --------------------------------------------------------------------------------------------- */
#[cfg(feature = "sv_vpi_user")]
mod sv_vpi_user {
include!(concat!(env!("OUT_DIR"), "/sv_vpi_user.rs"));
}
//TODO
/* ------------------------------------------------------------------------------------------------
* Uses
* --------------------------------------------------------------------------------------------- */
#[cfg(feature = "svdpi")]
pub use svdpi::*;
#[cfg(feature = "vpi_user")]
pub use vpi_user::*;
#[cfg(feature = "vpi_compatibility")]
pub use vpi_compatibility::*;
#[cfg(feature = "sv_vpi_user")]
pub use sv_vpi_user::*;
//TODO
/* ------------------------------------------------------------------------------------------------
* Macros

Loading…
Cancel
Save