working on deduce_resets
All checks were successful
/ deps (push) Successful in 16s
/ test (push) Successful in 4m54s
/ deps (pull_request) Successful in 13s
/ test (pull_request) Successful in 4m53s

This commit is contained in:
Jacob Lifshay 2024-11-25 00:01:02 -08:00
parent fa50930ff8
commit 3e3da53bd2
Signed by: programmerjake
SSH key fingerprint: SHA256:HnFTLGpSm4Q4Fj502oCFisjZSoakwEuTsJJMSke63RQ

View file

@ -20,7 +20,7 @@ use crate::{
},
prelude::*,
};
use std::{convert::Infallible, fmt};
use std::{convert::Infallible, fmt, mem};
#[derive(Debug)]
pub enum DeduceResetsError {
@ -415,17 +415,62 @@ impl RunProcessStep<AddEdgesToGraphStep> for ConnectAndLhsInstantiatedModule {
source_location,
} = self;
match Expr::ty(lhs) {
CanonicalType::UInt(ty) => todo!(),
CanonicalType::SInt(ty) => todo!(),
CanonicalType::Bool(ty) => todo!(),
CanonicalType::UInt(_) => {}
CanonicalType::SInt(_) => {}
CanonicalType::Bool(_) => {}
CanonicalType::AsyncReset(ty) => todo!(),
CanonicalType::SyncReset(ty) => todo!(),
CanonicalType::Reset(ty) => todo!(),
CanonicalType::Clock(ty) => todo!(),
CanonicalType::Clock(_) => {}
CanonicalType::Array(ty) => todo!(),
CanonicalType::Enum(ty) => todo!(),
CanonicalType::Bundle(ty) => todo!(),
CanonicalType::Enum(ty) => {
for (variant_index, EnumVariant { ty, .. }) in ty.variants().into_iter().enumerate()
{
if ty.is_none() {
continue;
}
let lhs =
ops::VariantAccess::new_by_index(Expr::from_canonical(lhs), variant_index)
.to_expr();
let rhs =
ops::VariantAccess::new_by_index(Expr::from_canonical(rhs), variant_index)
.to_expr();
ConnectAndLhsInstantiatedModule {
lhs_instantiated_module,
lhs,
rhs,
source_location,
}
.run_process_step(rhs_instantiated_module, state, step)?;
}
}
CanonicalType::Bundle(ty) => {
for (field_index, BundleField { flipped, .. }) in
ty.fields().into_iter().enumerate()
{
let mut lhs =
ops::FieldAccess::new_by_index(Expr::from_canonical(lhs), field_index)
.to_expr();
let mut rhs =
ops::FieldAccess::new_by_index(Expr::from_canonical(rhs), field_index)
.to_expr();
let mut lhs_instantiated_module = lhs_instantiated_module;
let mut rhs_instantiated_module = rhs_instantiated_module;
if flipped {
mem::swap(&mut lhs, &mut rhs);
mem::swap(&mut lhs_instantiated_module, &mut rhs_instantiated_module);
}
ConnectAndLhsInstantiatedModule {
lhs_instantiated_module,
lhs,
rhs,
source_location,
}
.run_process_step(rhs_instantiated_module, state, step)?;
}
}
}
Ok(Processed(()))
}
}