Compare commits
No commits in common. "8449854cac07c28ad421211da3217a52e6de2588" and "bdbc6d89bd8046483e8b3ad7ff3e9cde7afb0f7b" have entirely different histories.
8449854cac
...
bdbc6d89bd
4 changed files with 43 additions and 40 deletions
|
|
@ -78,6 +78,7 @@ mod kw {
|
||||||
custom_keyword!(output);
|
custom_keyword!(output);
|
||||||
custom_keyword!(reg_builder);
|
custom_keyword!(reg_builder);
|
||||||
custom_keyword!(reset);
|
custom_keyword!(reset);
|
||||||
|
custom_keyword!(reset_default);
|
||||||
custom_keyword!(skip);
|
custom_keyword!(skip);
|
||||||
custom_keyword!(target);
|
custom_keyword!(target);
|
||||||
custom_keyword!(wire);
|
custom_keyword!(wire);
|
||||||
|
|
|
||||||
|
|
@ -265,6 +265,11 @@ pub(crate) enum RegBuilderReset {
|
||||||
paren: Paren,
|
paren: Paren,
|
||||||
init_expr: Box<Expr>,
|
init_expr: Box<Expr>,
|
||||||
},
|
},
|
||||||
|
ResetDefault {
|
||||||
|
dot_token: Token![.],
|
||||||
|
reset_default: kw::reset_default,
|
||||||
|
paren: Paren,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_fold! {
|
impl_fold! {
|
||||||
|
|
@ -281,6 +286,11 @@ impl_fold! {
|
||||||
paren: Paren,
|
paren: Paren,
|
||||||
init_expr: Box<Expr>,
|
init_expr: Box<Expr>,
|
||||||
},
|
},
|
||||||
|
ResetDefault {
|
||||||
|
dot_token: Token![.],
|
||||||
|
reset_default: kw::reset_default,
|
||||||
|
paren: Paren,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -302,6 +312,11 @@ impl Parse for RegBuilderReset {
|
||||||
paren: parenthesized!(paren_contents in input),
|
paren: parenthesized!(paren_contents in input),
|
||||||
init_expr: paren_contents.call(parse_single_fn_arg)?,
|
init_expr: paren_contents.call(parse_single_fn_arg)?,
|
||||||
}),
|
}),
|
||||||
|
RegBuilderMethod::ResetDefault(reset_default) => Ok(Self::ResetDefault {
|
||||||
|
dot_token,
|
||||||
|
reset_default,
|
||||||
|
paren: parenthesized!(paren_contents in input),
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -329,6 +344,15 @@ impl ToTokens for RegBuilderReset {
|
||||||
reset.to_tokens(tokens);
|
reset.to_tokens(tokens);
|
||||||
paren.surround(tokens, |tokens| init_expr.to_tokens(tokens));
|
paren.surround(tokens, |tokens| init_expr.to_tokens(tokens));
|
||||||
}
|
}
|
||||||
|
RegBuilderReset::ResetDefault {
|
||||||
|
dot_token,
|
||||||
|
reset_default,
|
||||||
|
paren,
|
||||||
|
} => {
|
||||||
|
dot_token.to_tokens(tokens);
|
||||||
|
reset_default.to_tokens(tokens);
|
||||||
|
paren.surround(tokens, |_| {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -377,6 +401,8 @@ make_builder_method_enum! {
|
||||||
NoReset(no_reset),
|
NoReset(no_reset),
|
||||||
#[cond = need_reset]
|
#[cond = need_reset]
|
||||||
Reset(reset),
|
Reset(reset),
|
||||||
|
#[cond = need_reset]
|
||||||
|
ResetDefault(reset_default),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -419,13 +445,17 @@ impl HdlLetKindRegBuilder {
|
||||||
let mut clock_domain = None;
|
let mut clock_domain = None;
|
||||||
match RegBuilderMethod::parse_dot_prefixed(&input.fork(), true, true)?.1 {
|
match RegBuilderMethod::parse_dot_prefixed(&input.fork(), true, true)?.1 {
|
||||||
RegBuilderMethod::ClockDomain(_) => clock_domain = Some(input.parse()?),
|
RegBuilderMethod::ClockDomain(_) => clock_domain = Some(input.parse()?),
|
||||||
RegBuilderMethod::NoReset(_) | RegBuilderMethod::Reset(_) => {}
|
RegBuilderMethod::NoReset(_)
|
||||||
|
| RegBuilderMethod::Reset(_)
|
||||||
|
| RegBuilderMethod::ResetDefault(_) => {}
|
||||||
}
|
}
|
||||||
let reset = input.parse()?;
|
let reset = input.parse()?;
|
||||||
if clock_domain.is_none() {
|
if clock_domain.is_none() {
|
||||||
match RegBuilderMethod::parse_dot_prefixed(&input.fork(), true, false)?.1 {
|
match RegBuilderMethod::parse_dot_prefixed(&input.fork(), true, false)?.1 {
|
||||||
RegBuilderMethod::ClockDomain(_) => clock_domain = Some(input.parse()?),
|
RegBuilderMethod::ClockDomain(_) => clock_domain = Some(input.parse()?),
|
||||||
RegBuilderMethod::NoReset(_) | RegBuilderMethod::Reset(_) => unreachable!(),
|
RegBuilderMethod::NoReset(_)
|
||||||
|
| RegBuilderMethod::Reset(_)
|
||||||
|
| RegBuilderMethod::ResetDefault(_) => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
|
@ -1340,7 +1370,7 @@ impl Visitor<'_> {
|
||||||
no_reset.to_tokens(&mut expr);
|
no_reset.to_tokens(&mut expr);
|
||||||
paren.surround(&mut expr, |expr| ty_expr.to_tokens(expr));
|
paren.surround(&mut expr, |expr| ty_expr.to_tokens(expr));
|
||||||
}
|
}
|
||||||
RegBuilderReset::Reset { .. } => {
|
RegBuilderReset::Reset { .. } | RegBuilderReset::ResetDefault { .. } => {
|
||||||
hdl_let.kind.reset.to_tokens(&mut expr);
|
hdl_let.kind.reset.to_tokens(&mut expr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1236,11 +1236,10 @@ macro_rules! impl_dyn_shl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<LhsWidth: Size, RhsWidth: Size> Shl<Expr<UIntType<RhsWidth>>> for Expr<$ty<LhsWidth>> {
|
impl_binary_op_trait! {
|
||||||
type Output = Expr<$ty>;
|
#[generics(LhsWidth: Size, RhsWidth: Size)]
|
||||||
|
fn Shl::shl(lhs: $ty<LhsWidth>, rhs: UIntType<RhsWidth>) -> $ty {
|
||||||
fn shl(self, rhs: Expr<UIntType<RhsWidth>>) -> Self::Output {
|
$name::new(Expr::as_dyn_int(lhs), Expr::as_dyn_int(rhs)).to_expr()
|
||||||
$name::new(Expr::as_dyn_int(self), Expr::as_dyn_int(rhs)).to_expr()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -1309,11 +1308,10 @@ macro_rules! impl_dyn_shr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<LhsWidth: Size, RhsWidth: Size> Shr<Expr<UIntType<RhsWidth>>> for Expr<$ty<LhsWidth>> {
|
impl_binary_op_trait! {
|
||||||
type Output = Expr<$ty<LhsWidth>>;
|
#[generics(LhsWidth: Size, RhsWidth: Size)]
|
||||||
|
fn Shr::shr(lhs: $ty<LhsWidth>, rhs: UIntType<RhsWidth>) -> $ty<LhsWidth> {
|
||||||
fn shr(self, rhs: Expr<UIntType<RhsWidth>>) -> Self::Output {
|
$name::new(lhs, Expr::as_dyn_int(rhs)).to_expr()
|
||||||
$name::new(self, Expr::as_dyn_int(rhs)).to_expr()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ use std::{
|
||||||
borrow::{BorrowMut, Cow},
|
borrow::{BorrowMut, Cow},
|
||||||
fmt,
|
fmt,
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
num::NonZero,
|
|
||||||
ops::{Bound, Index, Not, Range, RangeBounds, RangeInclusive},
|
ops::{Bound, Index, Not, Range, RangeBounds, RangeInclusive},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
@ -469,11 +468,7 @@ impl SInt {
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! impl_prim_int {
|
macro_rules! impl_prim_int {
|
||||||
(
|
($prim_int:ident, $ty:ty) => {
|
||||||
$(#[$meta:meta])*
|
|
||||||
$prim_int:ident, $ty:ty
|
|
||||||
) => {
|
|
||||||
$(#[$meta])*
|
|
||||||
impl ToExpr for $prim_int {
|
impl ToExpr for $prim_int {
|
||||||
type Type = $ty;
|
type Type = $ty;
|
||||||
|
|
||||||
|
|
@ -484,17 +479,6 @@ macro_rules! impl_prim_int {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$(#[$meta])*
|
|
||||||
impl ToExpr for NonZero<$prim_int> {
|
|
||||||
type Type = $ty;
|
|
||||||
|
|
||||||
fn to_expr(&self) -> Expr<Self::Type> {
|
|
||||||
<$ty>::le_bytes_to_expr_wrapping(
|
|
||||||
&self.get().to_le_bytes(),
|
|
||||||
<$ty as BoolOrIntType>::Width::VALUE,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -509,16 +493,6 @@ impl_prim_int!(i32, SInt<32>);
|
||||||
impl_prim_int!(i64, SInt<64>);
|
impl_prim_int!(i64, SInt<64>);
|
||||||
impl_prim_int!(i128, SInt<128>);
|
impl_prim_int!(i128, SInt<128>);
|
||||||
|
|
||||||
impl_prim_int!(
|
|
||||||
/// for portability reasons, [`usize`] always translates to [`UInt<64>`]
|
|
||||||
usize, UInt<64>
|
|
||||||
);
|
|
||||||
|
|
||||||
impl_prim_int!(
|
|
||||||
/// for portability reasons, [`isize`] always translates to [`SInt<64>`]
|
|
||||||
isize, SInt<64>
|
|
||||||
);
|
|
||||||
|
|
||||||
pub trait BoolOrIntType: Type + sealed::BoolOrIntTypeSealed {
|
pub trait BoolOrIntType: Type + sealed::BoolOrIntTypeSealed {
|
||||||
type Width: Size;
|
type Width: Size;
|
||||||
type Signed: GenericConstBool;
|
type Signed: GenericConstBool;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue