diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml index 71f4a3b..6cc3727 100644 --- a/.forgejo/workflows/test.yml +++ b/.forgejo/workflows/test.yml @@ -15,5 +15,4 @@ jobs: with: save-if: ${{ github.ref == 'refs/heads/master' }} - run: cargo test - - run: cargo test --features=unstable-doc - run: cargo doc --features=unstable-doc diff --git a/crates/fayalite/src/_docs/modules/module_bodies.rs b/crates/fayalite/src/_docs/modules/module_bodies.rs index bd85c61..63fe671 100644 --- a/crates/fayalite/src/_docs/modules/module_bodies.rs +++ b/crates/fayalite/src/_docs/modules/module_bodies.rs @@ -1,7 +1,7 @@ //! # Module Function Bodies //! //! The `#[hdl_module]` attribute lets you have statements/expressions with `#[hdl]` annotations -//! and `_hdl`-suffixed literals in the module function's body. +//! and `_hdl`-suffixed literals in the module function's body pub mod hdl_array_expressions; pub mod hdl_if_statements; diff --git a/crates/fayalite/src/_docs/modules/module_bodies/hdl_array_expressions.rs b/crates/fayalite/src/_docs/modules/module_bodies/hdl_array_expressions.rs index ae510b2..516b35c 100644 --- a/crates/fayalite/src/_docs/modules/module_bodies/hdl_array_expressions.rs +++ b/crates/fayalite/src/_docs/modules/module_bodies/hdl_array_expressions.rs @@ -13,12 +13,12 @@ //! m.connect( //! w, //! #[hdl] -//! [4_hdl_u8, v, 3_hdl_u8, (v + 7_hdl_u8).cast()] // you can make an array like this +//! [4_hdl_u8, v, 3_hdl_u8, v + 7_hdl_u8] // you can make an array like this //! ); //! m.connect( //! w, //! #[hdl] -//! [(v + 1_hdl_u8).cast(); 4] // or you can make an array repeat like this +//! [v + 1_hdl_u8; 4] // or you can make an array repeat like this //! ); //! # } //! ``` diff --git a/crates/fayalite/src/_docs/modules/module_bodies/hdl_let_statements/inputs_outputs.rs b/crates/fayalite/src/_docs/modules/module_bodies/hdl_let_statements/inputs_outputs.rs index 23d7c8a..b070e71 100644 --- a/crates/fayalite/src/_docs/modules/module_bodies/hdl_let_statements/inputs_outputs.rs +++ b/crates/fayalite/src/_docs/modules/module_bodies/hdl_let_statements/inputs_outputs.rs @@ -4,12 +4,11 @@ //! so you should read it. //! //! ``` -//! # use fayalite::{hdl_module, int::UInt, expr::Expr, array::Array}; +//! # use fayalite::{hdl_module, int::UInt, array::Array}; //! # #[hdl_module] //! # fn module() { //! #[hdl] //! let my_input: UInt<10> = m.input(); -//! let _: Expr> = my_input; // my_input has type Expr> //! #[hdl] //! let my_output: Array<[UInt<10>; 3]> = m.output(); //! # } diff --git a/crates/fayalite/src/_docs/modules/module_bodies/hdl_struct_variant_expressions.rs b/crates/fayalite/src/_docs/modules/module_bodies/hdl_struct_variant_expressions.rs index 1013447..15cbca9 100644 --- a/crates/fayalite/src/_docs/modules/module_bodies/hdl_struct_variant_expressions.rs +++ b/crates/fayalite/src/_docs/modules/module_bodies/hdl_struct_variant_expressions.rs @@ -11,7 +11,6 @@ //! ``` //! # use fayalite::{hdl_module, int::UInt, array::Array, ty::Value}; //! #[derive(Value, Clone, PartialEq, Eq, Hash, Debug)] -//! #[hdl(fixed_type)] //! pub struct MyStruct { //! pub a: UInt<8>, //! pub b: UInt<16>, diff --git a/crates/fayalite/src/_docs/semantics/connection_semantics.rs b/crates/fayalite/src/_docs/semantics/connection_semantics.rs index 7c77ff3..ef30329 100644 --- a/crates/fayalite/src/_docs/semantics/connection_semantics.rs +++ b/crates/fayalite/src/_docs/semantics/connection_semantics.rs @@ -20,8 +20,8 @@ //! Connection Semantics Example: //! //! ``` -//! # use fayalite::{hdl_module, int::UInt}; -//! # #[hdl_module] +//! # use fayalite::module_hdl; +//! # #[module_hdl] //! # fn module() { //! #[hdl] //! let a: UInt<8> = m.wire(); @@ -43,8 +43,8 @@ //! # Conditional Connection Semantics //! //! ``` -//! # use fayalite::{hdl_module, int::UInt}; -//! # #[hdl_module] +//! # use fayalite::module_hdl; +//! # #[module_hdl] //! # fn module() { //! #[hdl] //! let cond: UInt<1> = m.input(); diff --git a/crates/fayalite/src/expr/ops.rs b/crates/fayalite/src/expr/ops.rs index 5900e30..9c20385 100644 --- a/crates/fayalite/src/expr/ops.rs +++ b/crates/fayalite/src/expr/ops.rs @@ -11,7 +11,7 @@ use crate::{ }, int::{ DynInt, DynIntType, DynSInt, DynSIntType, DynUInt, DynUIntType, FixedOrDynIntType, Int, - IntCmp, IntType, IntTypeTrait, IntValue, UInt, UIntType, + IntCmp, IntTypeTrait, IntValue, UInt, UIntType, }, intern::{Intern, Interned}, reset::{ @@ -888,7 +888,7 @@ fixed_ary_op! { }, fn simulate(&self, sim_state: &mut SimState) -> _ { - self.value.simulate(sim_state).cast_as_type(self.ty.canonical()) + self.value.simulate(sim_state).cast(self.ty.canonical()) } fn expr_enum(&self) -> _ { @@ -935,7 +935,7 @@ impl< >, > Expr> { - pub fn cast_as_type< + pub fn cast< ToType: IntTypeTrait< CanonicalType = DynIntType<::Signed>, CanonicalValue = DynInt<::Signed>, @@ -946,20 +946,17 @@ impl< ) -> Expr { CastInt::::new_unchecked(self.canonical(), ty).to_expr() } - pub fn cast(self) -> Expr> { - self.cast_as_type(IntType::new()) - } pub fn as_same_width_uint(self) -> Expr> { - self.cast_as_type(self.ty().as_same_width_uint()) + self.cast(self.ty().as_same_width_uint()) } pub fn as_same_width_sint(self) -> Expr> { - self.cast_as_type(self.ty().as_same_width_sint()) + self.cast(self.ty().as_same_width_sint()) } pub fn as_same_value_uint(self) -> Expr { - self.cast_as_type(self.ty().as_same_value_uint()) + self.cast(self.ty().as_same_value_uint()) } pub fn as_same_value_sint(self) -> Expr { - self.cast_as_type(self.ty().as_same_value_sint()) + self.cast(self.ty().as_same_value_sint()) } } @@ -1023,7 +1020,7 @@ impl< return false.to_expr(); } let index = index.min(width - 1); - self.slice(index..=index).cast() + self.slice(index..=index).cast(UIntType::new()) } pub fn is_negative(self) -> Expr> { if T::Signed::VALUE { diff --git a/crates/fayalite/src/int.rs b/crates/fayalite/src/int.rs index 4f31480..adfa0df 100644 --- a/crates/fayalite/src/int.rs +++ b/crates/fayalite/src/int.rs @@ -211,7 +211,7 @@ impl< IntValue::with_type(new_type, self.into_uint_value()) } } - pub fn cast_as_type< + pub fn cast< NewType: IntTypeTrait< CanonicalType = DynIntType<::Signed>, CanonicalValue = DynInt<::Signed>, @@ -226,9 +226,6 @@ impl< IntValue::with_type(new_type, self.uint_value()) } } - pub fn cast(self) -> Int { - self.cast_as_type(IntType::new()) - } pub fn as_same_width_uint(self) -> IntValue { IntValue { ty: self.ty.as_same_width_uint(),