https://github.com/dalance/sv4state
https://github.com/dalance/sv4state
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dalance/sv4state
- Owner: dalance
- License: apache-2.0
- Created: 2021-09-07T01:41:24.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-09-13T06:59:33.000Z (almost 5 years ago)
- Last Synced: 2025-01-01T23:35:39.619Z (over 1 year ago)
- Language: Rust
- Size: 10.7 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# sv4state
sv4state is a Rust library for SystemVerilog 4-state value.
`logic` value which is passed throgh SystemVerilog DPI can be handled by this library.
[](https://github.com/dalance/sv4state/actions)
[](https://crates.io/crates/sv4state)
[](https://docs.rs/sv4state)
## Example
`svLogicVecVal` shows a 32bit `logic` value of SystemVerilog.
So `logic [127:0]` corresponds to `[svLogicVecVal; 4]`.
```rust
use sv4state::{svLogicVecVal, Sv4State};
#[no_mangle]
pub extern "C" fn get_data(data: &[svLogicVecVal; 4]) {
let sv_u32 = Sv4State::::from_dpi(data);
println!("{:x}", sv_u32[0]);
println!("{:x}", sv_u32[1]);
println!("{:x}", sv_u32[2]);
println!("{:x}", sv_u32[3]);
}
```
The `get_data()` can be call through SystemVerilog DPI like below:
```SystemVerilog
import "DPI-C" function void get_data(
input logic [127:0] data
);
```