Skip to content

Commit

Permalink
make mior fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanku committed Dec 6, 2024
1 parent cb8ad3d commit 521b891
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
7 changes: 2 additions & 5 deletions substrate/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use crate::schematic::{
};
use crate::simulation::{SimController, SimulationContext, Simulator, Testbench};
use crate::types::layout::{BundleBuilder, HasHardwareType as HasLayoutType};
use crate::types::schematic::{Node, NodeContext, NodePriority, Port};
use crate::types::schematic::{IoBundle, Node, NodeContext, NodePriority, Port};
use crate::types::{Flatten, Flipped, HasBundleKind, HasNameTree};

/// The global context.
Expand Down Expand Up @@ -660,10 +660,7 @@ pub fn prepare_cell_builder<T: Schematic>(
id: Option<CellId>,
context: Context,
block: &T,
) -> (
CellBuilder<T::Schema>,
crate::types::schematic::IoBundle<T, Node>,
) {
) -> (CellBuilder<T::Schema>, IoBundle<T, Node>) {
let id = id.unwrap_or_else(|| context.alloc_cell_id());
let mut node_ctx = NodeContext::new();
// outward-facing IO (to other enclosing blocks)
Expand Down
38 changes: 19 additions & 19 deletions substrate/src/schematic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::types::schematic::{
BundleOfKind, Connect, HasSchematicBundleKind, IoBundle, IoKind, Node, NodeContext,
NodePriority, NodeUf, Port, SchematicBundleKind, Terminal,
};
use crate::types::{Flatten, HasNameTree, Io, NameBuf};
use crate::types::{Flatten, HasBundleKind, HasNameTree, Io, NameBuf};

/// A block that has a schematic.
pub trait Schematic: Block<Io: Io + HasSchematicBundleKind> {
Expand Down Expand Up @@ -150,19 +150,19 @@ impl<S: Schema + ?Sized> CellBuilder<S> {

/// Create a new signal with the given name and hardware type.
#[track_caller]
pub fn signal<TY: HasSchematicBundleKind>(
pub fn signal<K: HasSchematicBundleKind>(
&mut self,
name: impl Into<ArcStr>,
ty: TY,
) -> BundleOfKind<TY, Node> {
kind: K,
) -> BundleOfKind<K, Node> {
let (nodes, data) = self.node_ctx.instantiate_undirected(
&ty,
&kind,
NodePriority::Named,
SourceInfo::from_caller(),
);

let ty = ty.kind();
let names = ty.flat_names(Some(name.into().into()));
let kind = kind.kind();
let names = kind.flat_names(Some(name.into().into()));
assert_eq!(nodes.len(), names.len());

self.node_names.extend(nodes.iter().copied().zip(names));
Expand All @@ -179,14 +179,14 @@ impl<S: Schema + ?Sized> CellBuilder<S> {
+ HasSchematicBundleKind<BundleKind = <D1 as HasSchematicBundleKind>::BundleKind>,
{
let sinfo = SourceInfo::from_caller();
let s1_ty = s1.kind();
let s2_ty = s2.kind();
if s1_ty != s2_ty {
let s1_kind = s1.kind();
let s2_kind = s2.kind();
if s1_kind != s2_kind {
tracing::error!(
?sinfo,
?s1_ty,
?s2_ty,
"tried to connect bundles of different types",
?s1_kind,
?s2_kind,
"tried to connect bundles of different kinds",
);
self.fatal_error = true;
} else {
Expand Down Expand Up @@ -369,7 +369,7 @@ impl<S: Schema + ?Sized> CellBuilder<S> {
self.node_ctx
.instantiate_directed(&io, NodePriority::Auto, source_info);

let names = <<B as Block>::Io as crate::types::HasBundleKind>::kind(&io)
let names = <<B as Block>::Io as HasBundleKind>::kind(&io)
.flat_names(Some(inst_name.clone().into()));
assert_eq!(nodes.len(), names.len());

Expand Down Expand Up @@ -425,12 +425,12 @@ pub struct SubCellBuilder<'a, S1: Schema + ?Sized, S2: Schema + ?Sized>(
impl<'a, S1: FromSchema<S2>, S2: Schema + ?Sized> SubCellBuilder<'a, S1, S2> {
/// Create a new signal with the given name and hardware type.
#[track_caller]
pub fn signal<TY: HasSchematicBundleKind>(
pub fn signal<K: HasSchematicBundleKind>(
&mut self,
name: impl Into<ArcStr>,
ty: TY,
) -> BundleOfKind<TY, Node> {
self.0.signal(name, ty)
kind: K,
) -> BundleOfKind<K, Node> {
self.0.signal(name, kind)
}

/// Connect all signals in the given data instances.
Expand Down Expand Up @@ -1666,7 +1666,7 @@ mod tests {

fn schematic(
&self,
io: &crate::types::schematic::IoBundle<Resistor, Node>,
io: &IoBundle<Resistor, Node>,
cell: &mut super::CellBuilder<<Self as Schematic>::Schema>,
) -> crate::error::Result<Self::NestedData> {
let mut prim = PrimitiveBinding::new(Primitive::Resistor);
Expand Down

0 comments on commit 521b891

Please sign in to comment.