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

WIP: Core: Param rework #87

Closed
wants to merge 80 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
4e151ba
Core: Move current parameter implementation
NoR8quoh1r Oct 8, 2024
048df64
Core: Add minimal Range implementation for new params
NoR8quoh1r Oct 8, 2024
b5f0a8b
Core: Add mostly empty new Parameter class
NoR8quoh1r Oct 8, 2024
cb3a25f
Sets.py; Delte old params; Tests
iopapamanoglou Oct 8, 2024
c0f0418
Add parameter constructor
iopapamanoglou Oct 8, 2024
5675489
Core: Add some arithmetic expressions
NoR8quoh1r Oct 8, 2024
066bad8
Namespace
iopapamanoglou Oct 8, 2024
8da05dd
lambda warnings
iopapamanoglou Oct 8, 2024
0bd8b29
Core: Add more arithmetic expressions
NoR8quoh1r Oct 8, 2024
0e5209d
functions for ops
iopapamanoglou Oct 8, 2024
a869db8
L sets
iopapamanoglou Oct 8, 2024
4566a02
Core: Make expression node and add check
NoR8quoh1r Oct 8, 2024
10c3e67
WIP: Library refactor
iopapamanoglou Oct 8, 2024
b091b22
Core:
NoR8quoh1r Oct 8, 2024
df73c8a
fix range from_cente
iopapamanoglou Oct 8, 2024
2792ca3
unit => units
iopapamanoglou Oct 9, 2024
52126b2
Replace merge with {subset, superset, alias_is} half Lib
iopapamanoglou Oct 9, 2024
988bf1c
Replace merge with {subset, superset, alias_is} half Lib
iopapamanoglou Oct 9, 2024
ac1b98b
Fix F.Range -> L.Range
iopapamanoglou Oct 9, 2024
3d0fafc
Fix ParameterOperatable param types; Run ruff
iopapamanoglou Oct 9, 2024
a74bd73
Librar: Remove F.Constant in function signatures
NoR8quoh1r Oct 9, 2024
6a6975d
Library: Take ParameterOperatable in function signatures
NoR8quoh1r Oct 9, 2024
76efaab
remove singles
iopapamanoglou Oct 9, 2024
66b5a71
remove last param operands
iopapamanoglou Oct 9, 2024
d247aa4
ruff
iopapamanoglou Oct 9, 2024
4a3629a
Core: Parameter: Add some checks to predicates
NoR8quoh1r Oct 9, 2024
0707414
Params: Rework rated_* slightly
NoR8quoh1r Oct 9, 2024
414d305
Remove merge from non lib
iopapamanoglou Oct 9, 2024
59965dd
Remove esphome Param stuff
iopapamanoglou Oct 9, 2024
41afca7
add abstract decorator
iopapamanoglou Oct 9, 2024
3a98300
Now that we have units, get rid of all the useless stuff to do with
NoR8quoh1r Oct 9, 2024
6e8d033
assert_true
iopapamanoglou Oct 9, 2024
1930f72
Get rid of some F.Constant
NoR8quoh1r Oct 9, 2024
f3f3818
minor mini stuff
iopapamanoglou Oct 9, 2024
4076a68
Reworks sets.py, adding union, add and subtract
NoR8quoh1r Oct 10, 2024
ff8d312
Params: delete old data structures (Range, Constant, Any, TBD)
NoR8quoh1r Oct 11, 2024
c806780
Params: Solver API proposal
NoR8quoh1r Oct 11, 2024
9acc1dd
improve ranges/sets/unions
NoR8quoh1r Oct 18, 2024
2313191
rename (unit) RangeUnion to Ranges
NoR8quoh1r Oct 18, 2024
4d77e85
solver api, picker stuff
NoR8quoh1r Oct 18, 2024
e5f1e16
Add tests with units; Fix mul & div; Move things around
iopapamanoglou Oct 21, 2024
f12da68
Minor solve API fixes
iopapamanoglou Oct 21, 2024
8a05bba
fix L Set
iopapamanoglou Oct 21, 2024
64e6080
Model param deps in graph
iopapamanoglou Oct 21, 2024
9b52eea
Minor fixes; visualize example
iopapamanoglou Oct 21, 2024
a09ff7d
Fix: Node __preinit__ multicall
iopapamanoglou Oct 22, 2024
7c0a016
backport: lazy_mifs interactive graph
iopapamanoglou Oct 22, 2024
0471c9f
predicates have to be constrain()
iopapamanoglou Oct 22, 2024
5fa829e
genF
iopapamanoglou Oct 22, 2024
3e8e89f
Fix import errors
iopapamanoglou Oct 22, 2024
050fb01
fix dB units
iopapamanoglou Oct 22, 2024
698ac2a
fix some unit arithmetic
iopapamanoglou Oct 22, 2024
7ed6fa7
flat param graph
iopapamanoglou Oct 22, 2024
5967776
s/F.Range/L.Range/
NoR8quoh1r Oct 22, 2024
a0b6d0e
fix e_series with new sets
NoR8quoh1r Oct 23, 2024
5afd0ea
interactive layouts
iopapamanoglou Oct 23, 2024
6ff340d
interactive params
iopapamanoglou Oct 23, 2024
3262529
direct changes in ui
iopapamanoglou Oct 23, 2024
4cb7f84
iterate on jlbpcb set types/approach
NoR8quoh1r Oct 23, 2024
a8ce5fe
viz: ui default options
iopapamanoglou Oct 23, 2024
caa9c6c
run ruff
iopapamanoglou Oct 23, 2024
a3ea34d
refine jlc & solver
iopapamanoglou Oct 23, 2024
2e8b2e2
e_series cache; minor range fix
iopapamanoglou Oct 23, 2024
2c93157
Esphome solver
iopapamanoglou Oct 23, 2024
3ffec74
remove graph from solver; add hint_param to ComponentQuery
iopapamanoglou Oct 23, 2024
48b78dd
comment on hint
iopapamanoglou Oct 23, 2024
a6a74ea
parameter report
iopapamanoglou Oct 24, 2024
f6a23a2
rename final
iopapamanoglou Oct 31, 2024
08b8b89
explicit lock
iopapamanoglou Oct 31, 2024
17d896b
SolverResult
iopapamanoglou Oct 31, 2024
e58ef00
Begin phase 1 impl: Alias classes
iopapamanoglou Oct 31, 2024
28f1f53
check graph copy
iopapamanoglou Oct 31, 2024
a8645dd
only solve used params
iopapamanoglou Oct 31, 2024
21d041f
wip: compress assoc
iopapamanoglou Oct 31, 2024
4d13797
expression simplification
NoR8quoh1r Nov 1, 2024
f0e34d5
expression simplification
NoR8quoh1r Nov 7, 2024
865996e
normalize params, remove some tautologies
NoR8quoh1r Nov 7, 2024
93eeb78
intersect literal subsets
NoR8quoh1r Nov 7, 2024
4533df5
fix hash/eq bug in graph core
NoR8quoh1r Nov 8, 2024
e7db104
improve alias simplification
NoR8quoh1r Nov 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions examples/iterative_design_nand.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,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 @@ -71,7 +71,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 @@ -121,9 +121,11 @@ def App():
# parametrizing
for _, t in app.get_graph().nodes_with_trait(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
6 changes: 2 additions & 4 deletions examples/minimal_led_orderable.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
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
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 @@ -56,8 +55,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 @@ -130,7 +129,6 @@ def main():
G = app.get_graph()

# picking ----------------------------------------------------------------
replace_tbd_with_any(app, recursive=True)
modules = app.get_children_modules(types=Module)
try:
JLCPCB_DB()
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
Loading