Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
ERC: check ElectriPower has voltage
Browse files Browse the repository at this point in the history
  • Loading branch information
ruben-iteng committed Sep 11, 2024
1 parent 3687b83 commit af485fe
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/faebryk/libs/app/erc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand All @@ -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)
Expand Down

0 comments on commit af485fe

Please sign in to comment.