From 6929352be77883e3ce724bf3271f1d57d0b6331f Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Thu, 3 Apr 2025 15:59:03 -0700 Subject: [PATCH] re-export `bitvec` and add types useful for simulation to the prelude --- crates/fayalite-proc-macros-impl/src/hdl_bundle.rs | 12 ++++++------ crates/fayalite-proc-macros-impl/src/hdl_enum.rs | 6 +++--- crates/fayalite/src/lib.rs | 4 ++-- crates/fayalite/src/prelude.rs | 8 +++++++- crates/fayalite/tests/sim.rs | 3 +-- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/crates/fayalite-proc-macros-impl/src/hdl_bundle.rs b/crates/fayalite-proc-macros-impl/src/hdl_bundle.rs index 8e49ac4..5d13d39 100644 --- a/crates/fayalite-proc-macros-impl/src/hdl_bundle.rs +++ b/crates/fayalite-proc-macros-impl/src/hdl_bundle.rs @@ -746,7 +746,7 @@ impl ToTokens for ParsedBundle { } fn sim_value_from_bits( &self, - bits: &::fayalite::__bitvec::slice::BitSlice, + bits: &::fayalite::bitvec::slice::BitSlice, ) -> ::SimValue { #![allow(unused_mut, unused_variables)] let mut v = ::fayalite::bundle::BundleSimValueFromBits::new(*self, bits); @@ -757,7 +757,7 @@ impl ToTokens for ParsedBundle { fn sim_value_clone_from_bits( &self, value: &mut ::SimValue, - bits: &::fayalite::__bitvec::slice::BitSlice, + bits: &::fayalite::bitvec::slice::BitSlice, ) { #![allow(unused_mut, unused_variables)] let mut v = ::fayalite::bundle::BundleSimValueFromBits::new(*self, bits); @@ -766,7 +766,7 @@ impl ToTokens for ParsedBundle { fn sim_value_to_bits( &self, value: &::SimValue, - bits: &mut ::fayalite::__bitvec::slice::BitSlice, + bits: &mut ::fayalite::bitvec::slice::BitSlice, ) { #![allow(unused_mut, unused_variables)] let mut v = ::fayalite::bundle::BundleSimValueToBits::new(*self, bits); @@ -895,7 +895,7 @@ impl ToTokens for ParsedBundle { } fn sim_value_from_bits( &self, - bits: &::fayalite::__bitvec::slice::BitSlice, + bits: &::fayalite::bitvec::slice::BitSlice, ) -> ::SimValue { #![allow(unused_mut, unused_variables)] let mut v = ::fayalite::bundle::BundleSimValueFromBits::new(*self, bits); @@ -906,7 +906,7 @@ impl ToTokens for ParsedBundle { fn sim_value_clone_from_bits( &self, value: &mut ::SimValue, - bits: &::fayalite::__bitvec::slice::BitSlice, + bits: &::fayalite::bitvec::slice::BitSlice, ) { #![allow(unused_mut, unused_variables)] let mut v = ::fayalite::bundle::BundleSimValueFromBits::new(*self, bits); @@ -915,7 +915,7 @@ impl ToTokens for ParsedBundle { fn sim_value_to_bits( &self, value: &::SimValue, - bits: &mut ::fayalite::__bitvec::slice::BitSlice, + bits: &mut ::fayalite::bitvec::slice::BitSlice, ) { #![allow(unused_mut, unused_variables)] let mut v = ::fayalite::bundle::BundleSimValueToBits::new(*self, bits); diff --git a/crates/fayalite-proc-macros-impl/src/hdl_enum.rs b/crates/fayalite-proc-macros-impl/src/hdl_enum.rs index 6fb2a56..5437410 100644 --- a/crates/fayalite-proc-macros-impl/src/hdl_enum.rs +++ b/crates/fayalite-proc-macros-impl/src/hdl_enum.rs @@ -880,7 +880,7 @@ impl ToTokens for ParsedEnum { } fn sim_value_from_bits( &self, - bits: &::fayalite::__bitvec::slice::BitSlice, + bits: &::fayalite::bitvec::slice::BitSlice, ) -> ::SimValue { let v = ::fayalite::enum_::EnumSimValueFromBits::new(*self, bits); match v.discriminant() { @@ -890,7 +890,7 @@ impl ToTokens for ParsedEnum { fn sim_value_clone_from_bits( &self, value: &mut ::SimValue, - bits: &::fayalite::__bitvec::slice::BitSlice, + bits: &::fayalite::bitvec::slice::BitSlice, ) { let v = ::fayalite::enum_::EnumSimValueFromBits::new(*self, bits); match v.discriminant() { @@ -900,7 +900,7 @@ impl ToTokens for ParsedEnum { fn sim_value_to_bits( &self, value: &::SimValue, - bits: &mut ::fayalite::__bitvec::slice::BitSlice, + bits: &mut ::fayalite::bitvec::slice::BitSlice, ) { let v = ::fayalite::enum_::EnumSimValueToBits::new(*self, bits); match value { diff --git a/crates/fayalite/src/lib.rs b/crates/fayalite/src/lib.rs index 0843589..932464b 100644 --- a/crates/fayalite/src/lib.rs +++ b/crates/fayalite/src/lib.rs @@ -8,8 +8,6 @@ extern crate self as fayalite; -#[doc(hidden)] -pub use bitvec as __bitvec; #[doc(hidden)] pub use std as __std; @@ -78,6 +76,8 @@ pub use fayalite_proc_macros::hdl_module; #[doc(inline)] pub use fayalite_proc_macros::hdl; +pub use bitvec; + /// struct used as a placeholder when applying defaults #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] pub struct __; diff --git a/crates/fayalite/src/prelude.rs b/crates/fayalite/src/prelude.rs index 39fa143..519210f 100644 --- a/crates/fayalite/src/prelude.rs +++ b/crates/fayalite/src/prelude.rs @@ -20,7 +20,7 @@ pub use crate::{ hdl_cover_with_enable, MakeFormalExpr, }, hdl, hdl_module, - int::{Bool, DynSize, KnownSize, SInt, SIntType, Size, UInt, UIntType}, + int::{Bool, DynSize, KnownSize, SInt, SIntType, SIntValue, Size, UInt, UIntType, UIntValue}, memory::{Mem, MemBuilder, ReadUnderWrite}, module::{ annotate, connect, connect_any, incomplete_wire, instance, memory, memory_array, @@ -29,9 +29,15 @@ pub use crate::{ phantom_const::PhantomConst, reg::Reg, reset::{AsyncReset, Reset, SyncReset, ToAsyncReset, ToReset, ToSyncReset}, + sim::{ + time::{SimDuration, SimInstant}, + value::{SimValue, ToSimValue, ToSimValueWithType}, + ExternModuleSimulationState, Simulation, + }, source_location::SourceLocation, ty::{AsMask, CanonicalType, Type}, util::{ConstUsize, GenericConstUsize}, wire::Wire, __, }; +pub use bitvec::{slice::BitSlice, vec::BitVec}; diff --git a/crates/fayalite/tests/sim.rs b/crates/fayalite/tests/sim.rs index 6433844..655a497 100644 --- a/crates/fayalite/tests/sim.rs +++ b/crates/fayalite/tests/sim.rs @@ -2,12 +2,11 @@ // See Notices.txt for copyright information use fayalite::{ - int::UIntValue, memory::{ReadStruct, ReadWriteStruct, WriteStruct}, module::{instance_with_loc, reg_builder_with_loc}, prelude::*, reset::ResetType, - sim::{time::SimDuration, vcd::VcdWriterDecls, Simulation}, + sim::vcd::VcdWriterDecls, util::RcWriter, }; use std::num::NonZeroUsize; -- 2.43.6