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

Commit

Permalink
Merge branch main into 'feature/future_params'
Browse files Browse the repository at this point in the history
  • Loading branch information
iopapamanoglou committed Nov 13, 2024
2 parents c5338b8 + e7db104 commit 447114c
Show file tree
Hide file tree
Showing 144 changed files with 6,322 additions and 3,135 deletions.
14 changes: 8 additions & 6 deletions examples/iterative_design_nand.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ class PowerSource(Module):


class XOR_with_NANDS(F.LogicGates.XOR):
nands = L.list_field(4, lambda: F.LogicGates.NAND(F.Constant(2)))
nands = L.list_field(4, lambda: F.LogicGates.NAND(2))

def __init__(self):
super().__init__(F.Constant(2))
super().__init__(2)

def __preinit__(self):
A = self.inputs[0]
Expand Down Expand Up @@ -72,7 +72,7 @@ def App():
logic_in = F.Logic()
logic_out = F.Logic()

xor = F.LogicGates.XOR(F.Constant(2))
xor = F.LogicGates.XOR(2)
logic_out.connect(xor.get_trait(F.LogicOps.can_logic_xor).xor(logic_in, on))

# led
Expand Down Expand Up @@ -124,9 +124,11 @@ def App():
F.ElectricLogic.has_pulls
):
for pull_resistor in (r for r in t.get_pulls() if r):
pull_resistor.resistance.merge(F.Range.from_center_rel(100 * P.kohm, 0.05))
power_source.power.voltage.merge(3 * P.V)
led.led.led.brightness.merge(
pull_resistor.resistance.constrain_subset(
L.Range.from_center_rel(100 * P.kohm, 0.05)
)
power_source.power.voltage.constrain_subset(L.Range.from_center_rel(3 * P.V, 0.05))
led.led.led.brightness.constrain_subset(
TypicalLuminousIntensity.APPLICATION_LED_INDICATOR_INSIDE.value.value
)

Expand Down
4 changes: 2 additions & 2 deletions examples/mcu.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class App(Module):

def __preinit__(self) -> None:
# Parametrize
self.led.led.led.color.merge(F.LED.Color.YELLOW)
self.led.led.led.brightness.merge(
self.led.led.led.color.constrain_subset(F.LED.Color.YELLOW)
self.led.led.led.brightness.constrain_subset(
TypicalLuminousIntensity.APPLICATION_LED_INDICATOR_INSIDE.value.value
)

Expand Down
4 changes: 2 additions & 2 deletions examples/minimal_led.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def __preinit__(self) -> None:
self.led.power.connect(self.battery.power)

# Parametrize
self.led.led.color.merge(F.LED.Color.YELLOW)
self.led.led.brightness.merge(
self.led.led.color.constrain_subset(F.LED.Color.YELLOW)
self.led.led.brightness.constrain_subset(
TypicalLuminousIntensity.APPLICATION_LED_INDICATOR_INSIDE.value.value
)

Expand Down
7 changes: 3 additions & 4 deletions examples/minimal_led_orderable.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from faebryk.exporters.pcb.layout.typehierarchy import LayoutTypeHierarchy
from faebryk.libs.app.checks import run_checks
from faebryk.libs.app.manufacturing import export_pcba_artifacts
from faebryk.libs.app.parameters import replace_tbd_with_any, resolve_dynamic_parameters
from faebryk.libs.app.parameters import resolve_dynamic_parameters
from faebryk.libs.brightness import TypicalLuminousIntensity
from faebryk.libs.examples.buildutil import BUILD_DIR, PCB_FILE, apply_design_to_pcb
from faebryk.libs.examples.pickers import add_example_pickers
Expand Down Expand Up @@ -58,8 +58,8 @@ def __preinit__(self) -> None:
self.led.power.connect_via(self.power_button, self.battery.power)

# Parametrize
self.led.led.color.merge(F.LED.Color.YELLOW)
self.led.led.brightness.merge(
self.led.led.color.constrain_subset(F.LED.Color.YELLOW)
self.led.led.brightness.constrain_subset(
TypicalLuminousIntensity.APPLICATION_LED_INDICATOR_INSIDE.value.value
)

Expand Down Expand Up @@ -133,7 +133,6 @@ def main():
resolve_dynamic_parameters(G)

# picking ----------------------------------------------------------------
replace_tbd_with_any(app, recursive=True)
modules = app.get_children_modules(types=Module)
CachePicker.add_to_modules(modules, prio=-20)
try:
Expand Down
19 changes: 11 additions & 8 deletions examples/pcb_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from faebryk.exporters.pcb.layout.typehierarchy import LayoutTypeHierarchy
from faebryk.libs.brightness import TypicalLuminousIntensity
from faebryk.libs.examples.buildutil import apply_design_to_pcb
from faebryk.libs.library import L
from faebryk.libs.logging import setup_basic_logging
from faebryk.libs.units import P

Expand All @@ -37,23 +38,25 @@ def __preinit__(self) -> None:
self.leds.power.connect(self.battery.power)

# Parametrize
self.leds.led.color.merge(F.LED.Color.YELLOW)
self.leds.led.brightness.merge(
self.leds.led.color.constrain_subset(F.LED.Color.YELLOW)
self.leds.led.brightness.constrain_subset(
TypicalLuminousIntensity.APPLICATION_LED_INDICATOR_INSIDE.value.value
)

self.eeprom.power.voltage.merge(3.3 * P.V)
self.eeprom.power.voltage.constrain_subset(
L.Range.from_center_rel(3.3 * P.V, 0.05)
)
self.eeprom.set_address(0x0)

# Layout
Point = F.has_pcb_position.Point
L = F.has_pcb_position.layer_type
Ly = F.has_pcb_position.layer_type

layout = LayoutTypeHierarchy(
layouts=[
LayoutTypeHierarchy.Level(
mod_type=F.PoweredLED,
layout=LayoutAbsolute(Point((0, 0, 0, L.TOP_LAYER))),
layout=LayoutAbsolute(Point((0, 0, 0, Ly.TOP_LAYER))),
children_layout=LayoutTypeHierarchy(
layouts=[
LayoutTypeHierarchy.Level(
Expand All @@ -65,16 +68,16 @@ def __preinit__(self) -> None:
),
LayoutTypeHierarchy.Level(
mod_type=F.Battery,
layout=LayoutAbsolute(Point((0, 20, 0, L.BOTTOM_LAYER))),
layout=LayoutAbsolute(Point((0, 20, 0, Ly.BOTTOM_LAYER))),
),
LayoutTypeHierarchy.Level(
mod_type=F.M24C08_FMN6TP,
layout=LayoutAbsolute(Point((15, 10, 0, L.TOP_LAYER))),
layout=LayoutAbsolute(Point((15, 10, 0, Ly.TOP_LAYER))),
),
]
)
self.add(F.has_pcb_layout_defined(layout))
self.add(F.has_pcb_position_defined(Point((50, 50, 0, L.NONE))))
self.add(F.has_pcb_position_defined(Point((50, 50, 0, Ly.NONE))))

LayoutHeuristicElectricalClosenessDecouplingCaps.add_to_all_suitable_modules(
self
Expand Down
4 changes: 3 additions & 1 deletion examples/route.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def __init__(self, extrude_y: float):

def __preinit__(self):
for resistor in self.resistors:
resistor.resistance.merge(F.Range.from_center_rel(1000 * P.ohm, 0.05))
resistor.resistance.constrain_subset(
L.Range.from_center_rel(1000 * P.ohm, 0.05)
)
resistor.unnamed[0].connect(self.unnamed[0])
resistor.unnamed[1].connect(self.unnamed[1])

Expand Down
20 changes: 14 additions & 6 deletions examples/signal_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import faebryk.library._F as F
from faebryk.core.module import Module
from faebryk.libs.examples.buildutil import apply_design_to_pcb
from faebryk.libs.library import L
from faebryk.libs.logging import setup_basic_logging
from faebryk.libs.units import P

Expand All @@ -25,20 +26,27 @@ def __preinit__(self) -> None:
# TODO actually do something with the filter

# Parametrize
self.lowpass.cutoff_frequency.merge(200 * P.Hz)
self.lowpass.response.merge(F.Filter.Response.LOWPASS)
self.lowpass.cutoff_frequency.constrain_subset(
L.Range.from_center_rel(200 * P.Hz, 0.05)
)
self.lowpass.response.constrain_subset(F.Filter.Response.LOWPASS)

# 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)

special.in_.reference.voltage.constrain_subset(
L.Range.from_center_rel(3 * P.V, 0.05)
)
special.out.reference.voltage.constrain_subset(
L.Range.from_center_rel(3 * P.V, 0.05)
)

# TODO
# Construct
special.get_trait(F.has_construction_dependency).construct()
# special.get_trait(F.has_construction_dependency).construct()


def main():
Expand Down
Loading

0 comments on commit 447114c

Please sign in to comment.