From af485feb62a487ae98a72917da91a2097f450ccd Mon Sep 17 00:00:00 2001 From: ruben-iteng <94007802+ruben-iteng@users.noreply.github.com> Date: Wed, 11 Sep 2024 18:50:59 +0200 Subject: [PATCH 1/3] ERC: check ElectriPower has voltage --- src/faebryk/libs/app/erc.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/faebryk/libs/app/erc.py b/src/faebryk/libs/app/erc.py index dc52a3de..4bc32803 100644 --- a/src/faebryk/libs/app/erc.py +++ b/src/faebryk/libs/app/erc.py @@ -9,6 +9,7 @@ from faebryk.core.graphinterface import Graph from faebryk.core.module import Module from faebryk.core.moduleinterface import ModuleInterface +from faebryk.library.Operation import Operation from faebryk.libs.picker.picker import has_part_picked from faebryk.libs.util import groupby, print_stack @@ -35,6 +36,11 @@ def __init__(self, faulting_ifs: Sequence[ModuleInterface], *args: object) -> No print(stack) +class ERCFaultElectricPowerUndefinedVoltage(ERCFault): + def __init__(self, faulting_EP: F.ElectricPower, *args: object) -> None: + super().__init__([faulting_EP], *args) + + def simple_erc(G: Graph): """Simple ERC check. @@ -54,12 +60,17 @@ def simple_erc(G: Graph): """ logger.info("Checking graph for ERC violations") - # power short + # power short and power with undefined voltage electricpower = G.nodes_of_type(F.ElectricPower) logger.info(f"Checking {len(electricpower)} Power") for ep in electricpower: if ep.lv.is_connected_to(ep.hv): raise ERCFaultShort([ep], "shorted power") + if isinstance(ep.voltage.get_most_narrow(), (F.TBD, Operation)): + raise ERCFaultElectricPowerUndefinedVoltage( + ep, + f"ElectricPower with undefined or unsolved voltage: {ep.voltage}", + ) # shorted nets nets = G.nodes_of_type(F.Net) From 951e461d1b32cd960e8c85b7aacc1a20b23192ca Mon Sep 17 00:00:00 2001 From: ruben-iteng <94007802+ruben-iteng@users.noreply.github.com> Date: Wed, 11 Sep 2024 19:25:31 +0200 Subject: [PATCH 2/3] Move ERC before picking so it fails faster --- src/faebryk/libs/examples/buildutil.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/faebryk/libs/examples/buildutil.py b/src/faebryk/libs/examples/buildutil.py index ded6cd7f..f709704a 100644 --- a/src/faebryk/libs/examples/buildutil.py +++ b/src/faebryk/libs/examples/buildutil.py @@ -49,6 +49,9 @@ def apply_design_to_pcb(m: Module): m, recursive=True, loglvl=logging.DEBUG if DEV_MODE else logging.INFO ) + G = m.get_graph() + run_checks(m, G) + # TODO this can be prettier # picking ---------------------------------------------------------------- modules = m.get_children_modules() @@ -64,9 +67,6 @@ def apply_design_to_pcb(m: Module): pick_part_recursively(m) # ------------------------------------------------------------------------- - G = m.get_graph() - run_checks(m, G) - example_prj = Path(__file__).parent / Path("resources/example") if not DEV_MODE: From 0766a2b041a2d8f2e65eed4652c6d834bab3e410 Mon Sep 17 00:00:00 2001 From: ruben-iteng <94007802+ruben-iteng@users.noreply.github.com> Date: Wed, 11 Sep 2024 19:25:50 +0200 Subject: [PATCH 3/3] Fix examples --- examples/iterative_design_nand.py | 3 +++ examples/signal_processing.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/examples/iterative_design_nand.py b/examples/iterative_design_nand.py index 0a01cb1f..ca69b0cd 100644 --- a/examples/iterative_design_nand.py +++ b/examples/iterative_design_nand.py @@ -132,6 +132,9 @@ def App(): for ic_nand, xor_nand in zip(nand_ic.gates, nxor.nands): xor_nand.specialize(ic_nand) + # connect power to IC + nand_ic.power.connect(power_source.power) + app.add(nand_ic) return app diff --git a/examples/signal_processing.py b/examples/signal_processing.py index 5f8201a7..5ebab92a 100644 --- a/examples/signal_processing.py +++ b/examples/signal_processing.py @@ -31,6 +31,12 @@ def __preinit__(self) -> None: # Specialize special = self.lowpass.specialize(F.FilterElectricalLC()) + # set reference voltage + # TODO: this will be automatically set by the power supply + # once this example is more complete + special.in_.reference.voltage.merge(3 * P.V) + special.out.reference.voltage.merge(3 * P.V) + # Construct special.get_trait(F.has_construction_dependency).construct()