Compare commits
3 commits
30b9a5e48d
...
ed1aea41f3
Author | SHA1 | Date | |
---|---|---|---|
ed1aea41f3 | |||
f12322aa2a | |||
44ca1a607a |
16 changed files with 203 additions and 612 deletions
|
@ -58,8 +58,7 @@ impl ParsedBundle {
|
|||
}
|
||||
*mutability = FieldMutability::None;
|
||||
colon_token.get_or_insert(Token));
|
||||
let options = errors.unwrap_or_default(HdlAttr::parse_and_take_attr(attrs));
|
||||
options
|
||||
errors.unwrap_or_default(HdlAttr::parse_and_take_attr(attrs))
|
||||
}
|
||||
fn parse(item: ItemStruct) -> syn::Result<Self> {
|
||||
let ItemStruct {
|
||||
|
@ -686,7 +685,7 @@ impl ToTokens for ParsedBundle {
|
|||
let __retval = #mask_type_match_variant_ident {
|
||||
#(#match_variant_body_fields)*
|
||||
};
|
||||
::fayalite::intern::Interned::<_>::into_inner(::fayalite::intern::Intern::intern_sized(__retval))
|
||||
::fayalite::intern::Interned::into_inner(::fayalite::intern::Intern::intern_sized(__retval))
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
|
@ -761,7 +760,7 @@ impl ToTokens for ParsedBundle {
|
|||
let __retval = #match_variant_ident {
|
||||
#(#match_variant_body_fields)*
|
||||
};
|
||||
::fayalite::intern::Interned::<_>::into_inner(::fayalite::intern::Intern::intern_sized(__retval))
|
||||
::fayalite::intern::Interned::into_inner(::fayalite::intern::Intern::intern_sized(__retval))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -600,7 +600,7 @@ impl ToTokens for ParsedEnum {
|
|||
static_generics.split_for_impl();
|
||||
let static_type_body_variants =
|
||||
Vec::from_iter(variants.iter().map(|ParsedVariant { ident, field, .. }| {
|
||||
if let Some(_) = field {
|
||||
if field.is_some() {
|
||||
quote_spanned! {span=>
|
||||
#ident: ::fayalite::ty::StaticType::TYPE,
|
||||
}
|
||||
|
|
|
@ -1410,7 +1410,7 @@ impl ParseTypes<Path> for ParsedType {
|
|||
let mut args = None;
|
||||
let segments = Punctuated::from_iter(segments.pairs_mut().map_pair_value_mut(|segment| {
|
||||
let PathSegment { ident, arguments } = segment;
|
||||
if let Some(_) = args {
|
||||
if args.is_some() {
|
||||
parser
|
||||
.errors()
|
||||
.error(&ident, "associated types/consts are not yet implemented");
|
||||
|
@ -1594,7 +1594,7 @@ impl ParseTypes<Path> for ParsedConstGenericType {
|
|||
let mut args = None;
|
||||
let segments = Punctuated::from_iter(segments.pairs_mut().map_pair_value_mut(|segment| {
|
||||
let PathSegment { ident, arguments } = segment;
|
||||
if let Some(_) = args {
|
||||
if args.is_some() {
|
||||
parser
|
||||
.errors()
|
||||
.error(&ident, "associated types/consts are not yet implemented");
|
||||
|
@ -2718,7 +2718,7 @@ impl ParsedGenerics {
|
|||
type Output = #next_target #next_type_generics;
|
||||
|
||||
fn index(&self, #param_token: #index_type) -> &Self::Output {
|
||||
::fayalite::intern::Interned::<_>::into_inner(
|
||||
::fayalite::intern::Interned::into_inner(
|
||||
::fayalite::intern::Intern::intern_sized(#output_expr),
|
||||
)
|
||||
}
|
||||
|
@ -2778,7 +2778,7 @@ impl ParsedGenerics {
|
|||
type Output = #next_target #next_target_args;
|
||||
|
||||
fn index(&self, #param_token: #param_ident) -> &Self::Output {
|
||||
::fayalite::intern::Interned::<_>::into_inner(
|
||||
::fayalite::intern::Interned::into_inner(
|
||||
::fayalite::intern::Intern::intern_sized(#output_expr),
|
||||
)
|
||||
}
|
||||
|
@ -2848,7 +2848,7 @@ impl ParsedGenerics {
|
|||
type Output = #next_target #next_target_args;
|
||||
|
||||
fn index(&self, #param_token: __Param) -> &Self::Output {
|
||||
::fayalite::intern::Interned::<_>::into_inner(
|
||||
::fayalite::intern::Interned::into_inner(
|
||||
::fayalite::intern::Intern::intern_sized(#output_expr),
|
||||
)
|
||||
}
|
||||
|
@ -3554,7 +3554,7 @@ impl SplitForImpl for Generics {
|
|||
Self::TypeGenerics<'_>,
|
||||
Self::WhereClause<'_>,
|
||||
) {
|
||||
Generics::split_for_impl(&self)
|
||||
Generics::split_for_impl(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@ impl<T: Type, Len: Size> TypeWithDeref for ArrayType<T, Len> {
|
|||
let base = Expr::as_dyn_array(*this);
|
||||
let base_ty = Expr::ty(base);
|
||||
let retval = Vec::from_iter((0..base_ty.len()).map(|i| ArrayIndex::new(base, i).to_expr()));
|
||||
Interned::<_>::into_inner(Intern::intern_sized(
|
||||
Interned::into_inner(Intern::intern_sized(
|
||||
Len::ArrayMatch::<T>::try_from(retval)
|
||||
.ok()
|
||||
.expect("unreachable"),
|
||||
|
@ -202,7 +202,7 @@ impl<T: Type> Index<T> for ArrayWithoutGenerics {
|
|||
type Output = ArrayWithoutLen<T>;
|
||||
|
||||
fn index(&self, element: T) -> &Self::Output {
|
||||
Interned::<_>::into_inner(Intern::intern_sized(ArrayWithoutLen { element }))
|
||||
Interned::into_inner(Intern::intern_sized(ArrayWithoutLen { element }))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,6 +215,6 @@ impl<T: Type, L: SizeType> Index<L> for ArrayWithoutLen<T> {
|
|||
type Output = ArrayType<T, L::Size>;
|
||||
|
||||
fn index(&self, len: L) -> &Self::Output {
|
||||
Interned::<_>::into_inner(Intern::intern_sized(ArrayType::new(self.element, len)))
|
||||
Interned::into_inner(Intern::intern_sized(ArrayType::new(self.element, len)))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,6 +144,12 @@ impl BundleTypePropertiesBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for BundleTypePropertiesBuilder {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Bundle {
|
||||
#[track_caller]
|
||||
pub fn new(fields: Interned<[BundleField]>) -> Self {
|
||||
|
@ -342,6 +348,7 @@ macro_rules! impl_tuples {
|
|||
std::iter::once(MatchVariantWithoutScope(($(Expr::field(this, stringify!($num)),)*)))
|
||||
}
|
||||
fn mask_type(&self) -> Self::MaskType {
|
||||
#![allow(clippy::unused_unit)]
|
||||
let ($($var,)*) = self;
|
||||
($($var.mask_type(),)*)
|
||||
}
|
||||
|
@ -350,6 +357,7 @@ macro_rules! impl_tuples {
|
|||
}
|
||||
#[track_caller]
|
||||
fn from_canonical(canonical_type: CanonicalType) -> Self {
|
||||
#![allow(clippy::unused_unit)]
|
||||
let CanonicalType::Bundle(bundle) = canonical_type else {
|
||||
panic!("expected bundle");
|
||||
};
|
||||
|
@ -358,7 +366,7 @@ macro_rules! impl_tuples {
|
|||
};
|
||||
$(let BundleField { name, flipped, ty } = $var;
|
||||
assert_eq!(&*name, stringify!($num));
|
||||
assert_eq!(flipped, false);
|
||||
assert!(!flipped);
|
||||
let $var = $T::from_canonical(ty);)*
|
||||
($($var,)*)
|
||||
}
|
||||
|
@ -377,7 +385,7 @@ macro_rules! impl_tuples {
|
|||
impl<$($T: Type,)*> TypeWithDeref for ($($T,)*) {
|
||||
fn expr_deref(this: &Expr<Self>) -> &Self::MatchVariant {
|
||||
let _ = this;
|
||||
Interned::<_>::into_inner(($(Expr::field(*this, stringify!($num)),)*).intern_sized())
|
||||
Interned::into_inner(($(Expr::field(*this, stringify!($num)),)*).intern_sized())
|
||||
}
|
||||
}
|
||||
impl<$($T: StaticType,)*> StaticType for ($($T,)*) {
|
||||
|
|
|
@ -169,6 +169,12 @@ impl EnumTypePropertiesBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for EnumTypePropertiesBuilder {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Enum {
|
||||
#[track_caller]
|
||||
pub fn new(variants: Interned<[EnumVariant]>) -> Self {
|
||||
|
@ -399,9 +405,8 @@ impl<T: Type> HdlOption<T> {
|
|||
else {
|
||||
unreachable!();
|
||||
};
|
||||
let value = f(value).map_err(|e| {
|
||||
let value = f(value).inspect_err(|_| {
|
||||
and_then_out.complete(()); // avoid error
|
||||
e
|
||||
})?;
|
||||
let and_then_out = and_then_out.complete(Expr::ty(value));
|
||||
connect(and_then_out, value);
|
||||
|
|
|
@ -2057,7 +2057,7 @@ impl<ElementType: Type, Len: Size> ExprIndex<usize> for ArrayType<ElementType, L
|
|||
|
||||
#[track_caller]
|
||||
fn expr_index(this: &Expr<Self>, index: usize) -> &Expr<Self::Output> {
|
||||
Interned::<_>::into_inner(
|
||||
Interned::into_inner(
|
||||
ArrayIndex::<ElementType>::new(Expr::as_dyn_array(*this), index)
|
||||
.to_expr()
|
||||
.intern_sized(),
|
||||
|
@ -2154,7 +2154,7 @@ impl<ElementType: Type, Len: Size, Width: Size> ExprIndex<Expr<UIntType<Width>>>
|
|||
type Output = ElementType;
|
||||
|
||||
fn expr_index(this: &Expr<Self>, index: Expr<UIntType<Width>>) -> &Expr<Self::Output> {
|
||||
Interned::<_>::into_inner(
|
||||
Interned::into_inner(
|
||||
DynArrayIndex::<ElementType>::new(Expr::as_dyn_array(*this), Expr::as_dyn_int(index))
|
||||
.to_expr()
|
||||
.intern_sized(),
|
||||
|
@ -2279,7 +2279,7 @@ macro_rules! impl_int_slice {
|
|||
let base = Expr::as_dyn_int(*this);
|
||||
let base_ty = Expr::ty(base);
|
||||
let range = base_ty.slice_index_to_range(index);
|
||||
Interned::<_>::into_inner($name::new(base, range).to_expr().intern_sized())
|
||||
Interned::into_inner($name::new(base, range).to_expr().intern_sized())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2291,7 +2291,7 @@ macro_rules! impl_int_slice {
|
|||
let base = Expr::as_dyn_int(*this);
|
||||
let base_ty = Expr::ty(base);
|
||||
assert!(index < base_ty.width());
|
||||
Interned::<_>::into_inner(
|
||||
Interned::into_inner(
|
||||
$name::new(base, index..(index + 1))
|
||||
.to_expr()
|
||||
.cast_to_static::<Bool>()
|
||||
|
|
|
@ -147,7 +147,7 @@ where
|
|||
|
||||
fn try_from_usize(v: usize) -> Option<Self::SizeType> {
|
||||
if v == VALUE {
|
||||
Some(Self::SizeType::default())
|
||||
Some(ConstUsize)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ macro_rules! impl_int {
|
|||
type Output = $name<Width::Size>;
|
||||
|
||||
fn index(&self, width: Width) -> &Self::Output {
|
||||
Interned::<_>::into_inner(Intern::intern_sized($name::new(width)))
|
||||
Interned::into_inner(Intern::intern_sized($name::new(width)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -560,7 +560,7 @@ pub trait BoolOrIntType: Type + sealed::BoolOrIntTypeSealed {
|
|||
}
|
||||
fn bits_to_expr(bits: Cow<'_, BitSlice>) -> Expr<Self>;
|
||||
fn le_bytes_to_expr_wrapping(bytes: &[u8], bit_width: usize) -> Expr<Self> {
|
||||
let bitslice = BitSlice::<u8, Lsb0>::from_slice(&bytes);
|
||||
let bitslice = BitSlice::<u8, Lsb0>::from_slice(bytes);
|
||||
let bitslice = &bitslice[..bit_width.min(bitslice.len())];
|
||||
let mut bits = BitVec::new();
|
||||
bits.extend_from_bitslice(bitslice);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -634,7 +634,7 @@ impl<Element: Type, Len: Size> Mem<Element, Len> {
|
|||
self.0.source_location
|
||||
}
|
||||
pub fn array_type(self) -> ArrayType<Element, Len> {
|
||||
self.0.array_type.clone()
|
||||
self.0.array_type
|
||||
}
|
||||
pub fn initial_value(self) -> Option<Interned<BitSlice>> {
|
||||
self.0.initial_value
|
||||
|
@ -987,7 +987,7 @@ impl<Element: Type, Len: Size> MemBuilder<Element, Len> {
|
|||
#[allow(clippy::result_unit_err)]
|
||||
pub fn get_array_type(&self) -> Result<ArrayType<Element, Len>, ()> {
|
||||
Ok(ArrayType::new(
|
||||
self.mem_element_type.clone(),
|
||||
self.mem_element_type,
|
||||
Len::from_usize(self.get_depth()?),
|
||||
))
|
||||
}
|
||||
|
|
|
@ -607,6 +607,10 @@ impl BlockStack {
|
|||
pub struct Id(NonZeroU64);
|
||||
|
||||
impl Id {
|
||||
#[allow(
|
||||
clippy::new_without_default,
|
||||
reason = "returns a different value each time, so there isn't really a default value"
|
||||
)]
|
||||
pub fn new() -> Self {
|
||||
static NEXT_ID: AtomicU64 = AtomicU64::new(1);
|
||||
Self(
|
||||
|
@ -945,7 +949,7 @@ impl From<NormalModuleBody<ModuleBuilding>> for NormalModuleBody {
|
|||
Stmt::Declaration(decl) => {
|
||||
let annotations = annotations_map
|
||||
.remove(&decl)
|
||||
.map(|v| Intern::intern_owned(v))
|
||||
.map(Intern::intern_owned)
|
||||
.unwrap_or_default();
|
||||
match decl {
|
||||
StmtDeclaration::Wire(StmtWire {
|
||||
|
@ -1615,10 +1619,7 @@ impl AssertValidityState {
|
|||
let module = self.module;
|
||||
if block == 0 {
|
||||
for module_io in &*module.module_io {
|
||||
self.insert_new_base(
|
||||
TargetBase::intern_sized(module_io.module_io.clone().into()),
|
||||
block,
|
||||
);
|
||||
self.insert_new_base(TargetBase::intern_sized(module_io.module_io.into()), block);
|
||||
}
|
||||
}
|
||||
let Block { memories, stmts } = self.blocks[block];
|
||||
|
@ -1934,7 +1935,7 @@ impl ModuleBuilder {
|
|||
let module_io = module_io.canonical();
|
||||
let mut impl_ = self.impl_.borrow_mut();
|
||||
let impl_ = &mut *impl_;
|
||||
impl_.io_indexes.insert(module_io.clone(), impl_.io.len());
|
||||
impl_.io_indexes.insert(module_io, impl_.io.len());
|
||||
impl_.io.push(AnnotatedModuleIO {
|
||||
annotations: vec![],
|
||||
module_io,
|
||||
|
@ -2478,7 +2479,7 @@ pub fn memory_array_with_loc<Element: Type, Len: Size>(
|
|||
mem_array_type: ArrayType<Element, Len>,
|
||||
source_location: SourceLocation,
|
||||
) -> MemBuilder<Element, Len> {
|
||||
let mut retval = memory_impl(name, mem_array_type.element().clone(), source_location);
|
||||
let mut retval = memory_impl(name, mem_array_type.element(), source_location);
|
||||
retval.depth(mem_array_type.len());
|
||||
retval
|
||||
}
|
||||
|
|
|
@ -271,12 +271,12 @@ impl State {
|
|||
.into()),
|
||||
EnumTypeState::TagUIntAndBody(_) => {
|
||||
let int_tag_expr = Expr::<TagAndBody<UInt, UInt>>::from_canonical(folded_expr).tag;
|
||||
Ok(match_int_tag(int_tag_expr, source_location, &folded_blocks).into())
|
||||
Ok(match_int_tag(int_tag_expr, source_location, folded_blocks).into())
|
||||
}
|
||||
EnumTypeState::UInt(_) => {
|
||||
let int_tag_expr = Expr::<UInt>::from_canonical(folded_expr)
|
||||
[..unfolded_enum_type.discriminant_bit_width()];
|
||||
Ok(match_int_tag(int_tag_expr, source_location, &folded_blocks).into())
|
||||
Ok(match_int_tag(int_tag_expr, source_location, folded_blocks).into())
|
||||
}
|
||||
EnumTypeState::Unchanged => Ok(StmtMatch {
|
||||
expr: Expr::from_canonical(folded_expr),
|
||||
|
@ -929,13 +929,10 @@ impl Folder for State {
|
|||
unreachable!()
|
||||
}
|
||||
|
||||
fn fold_enum_literal<T: EnumType>(
|
||||
fn fold_enum_literal<T: EnumType + Fold<Self>>(
|
||||
&mut self,
|
||||
_v: ops::EnumLiteral<T>,
|
||||
) -> Result<ops::EnumLiteral<T>, Self::Error>
|
||||
where
|
||||
T: Fold<Self>,
|
||||
{
|
||||
) -> Result<ops::EnumLiteral<T>, Self::Error> {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
|
|
|
@ -766,7 +766,7 @@ impl ModuleState {
|
|||
output_stmts.push(
|
||||
StmtWire {
|
||||
annotations: Default::default(),
|
||||
wire: canonical_wire.clone(),
|
||||
wire: canonical_wire,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
|
|
|
@ -330,6 +330,6 @@ impl<T: Type> Index<T> for AsMaskWithoutGenerics {
|
|||
type Output = T::MaskType;
|
||||
|
||||
fn index(&self, ty: T) -> &Self::Output {
|
||||
Interned::<_>::into_inner(Intern::intern_sized(ty.mask_type()))
|
||||
Interned::into_inner(Intern::intern_sized(ty.mask_type()))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,3 +106,9 @@ impl<T: ?Sized> ScopedRef<T> {
|
|||
self.0.with_opt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: ?Sized> Default for ScopedRef<T> {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2258,7 +2258,7 @@ pub fn check_memory_of_bundle() {
|
|||
let wmask: (Bool, Bool) = m.input();
|
||||
#[hdl]
|
||||
let clk: Clock = m.input();
|
||||
let mem_init = Vec::from_iter((0..0x10u8).map(|i| (i ^ 3, (i ^ i / 2).cast_to_static())));
|
||||
let mem_init = Vec::from_iter((0..0x10u8).map(|i| (i ^ 3, (i ^ (i / 2)).cast_to_static())));
|
||||
#[hdl]
|
||||
let mut mem = memory_with_init(mem_init);
|
||||
let read_port = mem.new_read_port();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue