Compare commits
No commits in common. "2c1afd1cd63f8da01300bf866c510f5db313da2b" and "5835b995a96450c2dcc4d6448fcb7d75df6716b8" have entirely different histories.
2c1afd1cd6
...
5835b995a9
File diff suppressed because it is too large
Load diff
|
@ -66,8 +66,8 @@ pub(crate) struct ModuleFn {
|
||||||
vis: Visibility,
|
vis: Visibility,
|
||||||
sig: Signature,
|
sig: Signature,
|
||||||
block: Box<Block>,
|
block: Box<Block>,
|
||||||
|
io: Vec<ModuleIO>,
|
||||||
struct_generics: ParsedGenerics,
|
struct_generics: ParsedGenerics,
|
||||||
the_struct: TokenStream,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
|
||||||
|
@ -224,41 +224,6 @@ impl Parse for ModuleFn {
|
||||||
errors.finish()?;
|
errors.finish()?;
|
||||||
let struct_generics = struct_generics.unwrap();
|
let struct_generics = struct_generics.unwrap();
|
||||||
let (block, io) = body_results.unwrap();
|
let (block, io) = body_results.unwrap();
|
||||||
let (_struct_impl_generics, _struct_type_generics, struct_where_clause) =
|
|
||||||
struct_generics.split_for_impl();
|
|
||||||
let struct_where_clause: Option<WhereClause> = parse_quote! { #struct_where_clause };
|
|
||||||
if let Some(struct_where_clause) = &struct_where_clause {
|
|
||||||
sig.generics
|
|
||||||
.where_clause
|
|
||||||
.get_or_insert_with(|| WhereClause {
|
|
||||||
where_token: struct_where_clause.where_token,
|
|
||||||
predicates: Default::default(),
|
|
||||||
})
|
|
||||||
.predicates
|
|
||||||
.extend(struct_where_clause.predicates.clone());
|
|
||||||
}
|
|
||||||
let fn_name = &sig.ident;
|
|
||||||
let io_flips = io
|
|
||||||
.iter()
|
|
||||||
.map(|io| match io.kind.kind {
|
|
||||||
ModuleIOKind::Input((input,)) => quote_spanned! {input.span=>
|
|
||||||
#[hdl(flip)]
|
|
||||||
},
|
|
||||||
ModuleIOKind::Output(_) => quote! {},
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
let io_types = io.iter().map(|io| &io.kind.ty).collect::<Vec<_>>();
|
|
||||||
let io_names = io.iter().map(|io| &io.name).collect::<Vec<_>>();
|
|
||||||
let the_struct: ItemStruct = parse_quote! {
|
|
||||||
#[allow(non_camel_case_types)]
|
|
||||||
#[hdl(no_runtime_generics, no_static)]
|
|
||||||
#vis struct #fn_name #struct_generics #struct_where_clause {
|
|
||||||
#(
|
|
||||||
#io_flips
|
|
||||||
#vis #io_names: #io_types,)*
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let the_struct = crate::hdl_bundle::hdl_bundle(the_struct)?;
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
attrs,
|
attrs,
|
||||||
config_options,
|
config_options,
|
||||||
|
@ -266,8 +231,8 @@ impl Parse for ModuleFn {
|
||||||
vis,
|
vis,
|
||||||
sig,
|
sig,
|
||||||
block,
|
block,
|
||||||
|
io,
|
||||||
struct_generics,
|
struct_generics,
|
||||||
the_struct,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -281,8 +246,8 @@ impl ModuleFn {
|
||||||
vis,
|
vis,
|
||||||
sig,
|
sig,
|
||||||
block,
|
block,
|
||||||
|
io,
|
||||||
struct_generics,
|
struct_generics,
|
||||||
the_struct,
|
|
||||||
} = self;
|
} = self;
|
||||||
let ConfigOptions {
|
let ConfigOptions {
|
||||||
outline_generated: _,
|
outline_generated: _,
|
||||||
|
@ -314,7 +279,7 @@ impl ModuleFn {
|
||||||
ModuleKind::Normal => quote! { ::fayalite::module::ModuleKind::Normal },
|
ModuleKind::Normal => quote! { ::fayalite::module::ModuleKind::Normal },
|
||||||
};
|
};
|
||||||
let fn_name = &outer_sig.ident;
|
let fn_name = &outer_sig.ident;
|
||||||
let (_struct_impl_generics, struct_type_generics, _struct_where_clause) =
|
let (_struct_impl_generics, struct_type_generics, struct_where_clause) =
|
||||||
struct_generics.split_for_impl();
|
struct_generics.split_for_impl();
|
||||||
let struct_ty = quote! {#fn_name #struct_type_generics};
|
let struct_ty = quote! {#fn_name #struct_type_generics};
|
||||||
body_sig.ident = parse_quote! {__body};
|
body_sig.ident = parse_quote! {__body};
|
||||||
|
@ -329,6 +294,17 @@ impl ModuleFn {
|
||||||
};
|
};
|
||||||
outer_sig.output =
|
outer_sig.output =
|
||||||
parse_quote! {-> ::fayalite::intern::Interned<::fayalite::module::Module<#struct_ty>>};
|
parse_quote! {-> ::fayalite::intern::Interned<::fayalite::module::Module<#struct_ty>>};
|
||||||
|
let io_flips = io
|
||||||
|
.iter()
|
||||||
|
.map(|io| match io.kind.kind {
|
||||||
|
ModuleIOKind::Input((input,)) => quote_spanned! {input.span=>
|
||||||
|
#[hdl(flip)]
|
||||||
|
},
|
||||||
|
ModuleIOKind::Output(_) => quote! {},
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
let io_types = io.iter().map(|io| &io.kind.ty).collect::<Vec<_>>();
|
||||||
|
let io_names = io.iter().map(|io| &io.name).collect::<Vec<_>>();
|
||||||
let fn_name_str = fn_name.to_string();
|
let fn_name_str = fn_name.to_string();
|
||||||
let (_, body_type_generics, _) = body_fn.sig.generics.split_for_impl();
|
let (_, body_type_generics, _) = body_fn.sig.generics.split_for_impl();
|
||||||
let body_turbofish_type_generics = body_type_generics.as_turbofish();
|
let body_turbofish_type_generics = body_type_generics.as_turbofish();
|
||||||
|
@ -340,6 +316,15 @@ impl ModuleFn {
|
||||||
|m| __body #body_turbofish_type_generics(m, #(#param_names,)*),
|
|m| __body #body_turbofish_type_generics(m, #(#param_names,)*),
|
||||||
)
|
)
|
||||||
}};
|
}};
|
||||||
|
let the_struct: ItemStruct = parse_quote! {
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
#[hdl(no_runtime_generics, no_static)]
|
||||||
|
#vis struct #fn_name #struct_generics #struct_where_clause {
|
||||||
|
#(
|
||||||
|
#io_flips
|
||||||
|
#vis #io_names: #io_types,)*
|
||||||
|
}
|
||||||
|
};
|
||||||
let outer_fn = ItemFn {
|
let outer_fn = ItemFn {
|
||||||
attrs,
|
attrs,
|
||||||
vis,
|
vis,
|
||||||
|
@ -347,7 +332,7 @@ impl ModuleFn {
|
||||||
block,
|
block,
|
||||||
};
|
};
|
||||||
let mut retval = outer_fn.into_token_stream();
|
let mut retval = outer_fn.into_token_stream();
|
||||||
retval.extend(the_struct);
|
retval.extend(crate::hdl_bundle::hdl_bundle(the_struct).unwrap());
|
||||||
retval
|
retval
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ use fayalite::{
|
||||||
intern::Intern,
|
intern::Intern,
|
||||||
module::transform::simplify_enums::{simplify_enums, SimplifyEnumsKind},
|
module::transform::simplify_enums::{simplify_enums, SimplifyEnumsKind},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
ty::StaticType,
|
|
||||||
};
|
};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
|
@ -134,11 +133,9 @@ circuit my_module:
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(todo)]
|
||||||
#[hdl_module(outline_generated)]
|
#[hdl_module(outline_generated)]
|
||||||
pub fn check_array_repeat<const N: usize>()
|
pub fn check_array_repeat<const N: usize>() {
|
||||||
where
|
|
||||||
ConstUsize<N>: KnownSize,
|
|
||||||
{
|
|
||||||
#[hdl]
|
#[hdl]
|
||||||
let i: UInt<8> = m.input();
|
let i: UInt<8> = m.input();
|
||||||
#[hdl]
|
#[hdl]
|
||||||
|
@ -150,6 +147,7 @@ where
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(todo)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_array_repeat() {
|
fn test_array_repeat() {
|
||||||
let _n = SourceLocation::normalize_files_for_tests();
|
let _n = SourceLocation::normalize_files_for_tests();
|
||||||
|
@ -190,21 +188,21 @@ circuit check_array_repeat_1:
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(todo)]
|
||||||
#[hdl_module(outline_generated)]
|
#[hdl_module(outline_generated)]
|
||||||
pub fn check_skipped_generics<T, #[hdl(skip)] U, const N: usize, #[hdl(skip)] const M: usize>(v: U)
|
pub fn check_skipped_generics<T, #[hdl(skip)] U, const N: usize, #[hdl(skip)] const M: usize>(v: U)
|
||||||
where
|
where
|
||||||
T: StaticType,
|
T: StaticValue,
|
||||||
ConstUsize<N>: KnownSize,
|
|
||||||
U: std::fmt::Display,
|
U: std::fmt::Display,
|
||||||
{
|
{
|
||||||
dbg!(M);
|
dbg!(M);
|
||||||
#[hdl]
|
#[hdl]
|
||||||
let i: T = m.input();
|
let i: T = m.input();
|
||||||
#[hdl]
|
#[hdl]
|
||||||
let o: Array<T, N> = m.output();
|
let o: Array<[T; N]> = m.output();
|
||||||
let bytes = v.to_string().as_bytes().to_expr();
|
let bytes = v.to_string().as_bytes().to_expr();
|
||||||
#[hdl]
|
#[hdl]
|
||||||
let o2: Array<UInt<8>> = m.output(Expr::ty(bytes));
|
let o2: Array<[UInt<8>]> = m.output(bytes.ty());
|
||||||
connect(
|
connect(
|
||||||
o,
|
o,
|
||||||
#[hdl]
|
#[hdl]
|
||||||
|
@ -213,6 +211,7 @@ where
|
||||||
connect(o2, bytes);
|
connect(o2, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(todo)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_skipped_generics() {
|
fn test_skipped_generics() {
|
||||||
let _n = SourceLocation::normalize_files_for_tests();
|
let _n = SourceLocation::normalize_files_for_tests();
|
||||||
|
|
Loading…
Reference in a new issue