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

Core: Better holders #7

Merged
merged 63 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
eb32870
WIP: Demo of new holder idea
iopapamanoglou Aug 6, 2024
813a488
Setup new flat structure; Split core
iopapamanoglou Aug 22, 2024
0394261
Implement handle_add
iopapamanoglou Aug 22, 2024
d5e41ca
Fix imports
iopapamanoglou Aug 22, 2024
76be49b
No dataclass
iopapamanoglou Aug 22, 2024
57516b6
Implement field setup
iopapamanoglou Aug 23, 2024
d75d024
Remove trait generic
iopapamanoglou Aug 23, 2024
3bb76ce
Remove footprinttrait & GIFs usage
iopapamanoglou Aug 23, 2024
fcf2ce6
Add L.py & f_field
iopapamanoglou Aug 23, 2024
64d2b9f
Replace init with new
iopapamanoglou Aug 23, 2024
0509cce
Inbetween lib refactor commit
iopapamanoglou Aug 23, 2024
806ce77
more progress
iopapamanoglou Aug 23, 2024
f94f9d8
Refactored through to S
iopapamanoglou Aug 26, 2024
516f846
Done first pass library
iopapamanoglou Aug 26, 2024
b6efe01
2nd pass
iopapamanoglou Aug 26, 2024
ee99e9a
ruff
iopapamanoglou Aug 26, 2024
0e415f8
gen_F try
iopapamanoglou Aug 26, 2024
2e0f7ce
gen_F fix
iopapamanoglou Aug 26, 2024
6bcb0c4
Fix init & Fix F_
iopapamanoglou Aug 27, 2024
b25ddb1
syntax fix examples
iopapamanoglou Aug 27, 2024
39d8ded
graph import errors
iopapamanoglou Aug 27, 2024
1a133f3
Fix some examples & lib stuff; Add better trait handling
iopapamanoglou Aug 27, 2024
cf0c31d
fix duplicate handle call
iopapamanoglou Aug 27, 2024
b882590
implement trait deletion
iopapamanoglou Aug 27, 2024
2acc91a
cleaner handle_parent_add
iopapamanoglou Aug 27, 2024
c66b86c
Move util imports
iopapamanoglou Aug 27, 2024
c89546e
move around util import
iopapamanoglou Aug 27, 2024
a4ec66d
move some util stuff to node
iopapamanoglou Aug 27, 2024
0661a45
fix trait override
iopapamanoglou Aug 28, 2024
3e089bb
Fix rt_field init order
iopapamanoglou Aug 28, 2024
63e8790
started fixing more core tests
iopapamanoglou Aug 28, 2024
ffd37b7
Fix connect_up; Add connect comment
iopapamanoglou Aug 28, 2024
94e3bbe
fix rt fields
iopapamanoglou Aug 29, 2024
1151050
Fix link shallow; Add util:once
iopapamanoglou Aug 29, 2024
829ec7f
dont autoupdate db in nopromptmode
iopapamanoglou Aug 29, 2024
a003fca
sort children by default
iopapamanoglou Aug 29, 2024
0fd2954
capacitor instances; all TESTS PASS
iopapamanoglou Aug 29, 2024
4456278
rename if_list -> node_list
iopapamanoglou Aug 29, 2024
e632092
removed type from d_field; fix rt_field init order
iopapamanoglou Aug 29, 2024
60c63fc
Fix route example
iopapamanoglou Aug 29, 2024
42b68b2
update libadd.py to new fab ll
iopapamanoglou Aug 29, 2024
9f3fa5d
small timing print fix
iopapamanoglou Aug 29, 2024
4016aa4
removed inconsistent defined traits
iopapamanoglou Aug 29, 2024
757a04a
replace TypeVar & Generic where single use
iopapamanoglou Aug 29, 2024
0372862
Run ruff
iopapamanoglou Aug 29, 2024
a6c268e
prettier libadd
iopapamanoglou Aug 29, 2024
f98968d
Add refactor libTof & run it
iopapamanoglou Aug 29, 2024
ba5b5da
fix lookahead refactor
iopapamanoglou Aug 29, 2024
b8daa43
Add library instance test
iopapamanoglou Aug 29, 2024
b72f3ab
Make more refactor stuff
iopapamanoglou Aug 29, 2024
a4d2044
Fixed esphome units
iopapamanoglou Aug 29, 2024
4a15444
remove debug
iopapamanoglou Aug 29, 2024
334d4f0
handpick ruben lib fixes
iopapamanoglou Aug 29, 2024
4cee3a2
Add todo to RP2040
iopapamanoglou Aug 29, 2024
717c5a7
Add: Only generate _F.py when staged library files are detected
ruben-iteng Aug 30, 2024
c32e089
Skip gen_F when _F.py is already staged
ruben-iteng Aug 30, 2024
4f2fa39
Fix some more components
ruben-iteng Aug 30, 2024
221dab2
Add: IsPowerSource
ruben-iteng Aug 30, 2024
4f7f373
gen_F deterministc, fix ldo subclass
iopapamanoglou Aug 30, 2024
46e9c83
ruff
iopapamanoglou Aug 30, 2024
1915403
Update: dependencies
ruben-iteng Aug 30, 2024
7464e3c
Fix: ME6211C33M5G_N
ruben-iteng Aug 30, 2024
1b4fa76
Pass through linkcls in connect functions
ruben-iteng Aug 30, 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
19 changes: 7 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,20 @@ In short faebryk is a python library that allows you to design ready-to-order el

```python
import faebryk.library._F as F
from faebryk.core.core import Module
from faebryk.core.module import Module
from faebryk.libs.brightness import TypicalLuminousIntensity
from faebryk.libs.examples.buildutil import apply_design_to_pcb

class App(Module):
def __init__(self) -> None:
super().__init__()
led : F.PoweredLED
battery : F.Battery

class _NODES(Module.NODES()):
led = F.PoweredLED()
battery = F.Battery()

self.NODEs = _NODES(self)

self.NODEs.led.IFs.power.connect(self.NODEs.battery.IFs.power)
def __preinit__(self) -> None:
self.led.power.connect(self.battery.power)

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

Expand Down
69 changes: 28 additions & 41 deletions examples/iterative_design_nand.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,37 @@
import typer

import faebryk.library._F as F
from faebryk.core.core import Module
from faebryk.core.module import Module
from faebryk.core.util import (
get_all_nodes_with_trait,
specialize_interface,
specialize_module,
)
from faebryk.library._F import Constant
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
from faebryk.libs.util import times

logger = logging.getLogger(__name__)


class PowerSource(Module):
def __init__(self) -> None:
super().__init__()

class IFS(Module.IFS()):
power = F.ElectricPower()

self.IFs = IFS(self)
power: F.ElectricPower


class XOR_with_NANDS(F.LogicGates.XOR):
def __init__(
self,
):
super().__init__(Constant(2))

class NODES(Module.NODES()):
nands = times(4, lambda: F.LogicGates.NAND(Constant(2)))
nands = L.list_field(4, lambda: F.LogicGates.NAND(F.Constant(2)))

self.NODEs = NODES(self)
def __init__(self):
super().__init__(F.Constant(2))

A = self.IFs.inputs[0]
B = self.IFs.inputs[1]
def __preinit__(self):
A = self.inputs[0]
B = self.inputs[1]

G = self.NODEs.nands
Q = self.IFs.outputs[0]
G = self.nands
Q = self.outputs[0]

# ~(a&b)
q0 = G[0].get_trait(F.LogicOps.can_logic_nand).nand(A, B)
Expand All @@ -81,18 +70,18 @@ def App():
power_source = PowerSource()

# alias
power = power_source.IFs.power
power = power_source.power

# logic
logic_in = F.Logic()
logic_out = F.Logic()

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

# led
led = F.LEDIndicator()
led.IFs.power_in.connect(power)
led.power_in.connect(power)

# application
switch = F.Switch(F.Logic)()
Expand All @@ -104,15 +93,15 @@ def App():
e_out = specialize_interface(logic_out, F.ElectricLogic())
e_on = specialize_interface(on, F.ElectricLogic())
e_off = specialize_interface(off, F.ElectricLogic())
e_in.IFs.reference.connect(power)
e_out.IFs.reference.connect(power)
e_on.IFs.reference.connect(power)
e_off.IFs.reference.connect(power)
e_in.reference.connect(power)
e_out.reference.connect(power)
e_on.reference.connect(power)
e_off.reference.connect(power)
e_in.set_weak(on=False)
e_on.set(on=True)
e_off.set(on=False)

e_out.connect(led.IFs.logic_in)
e_out.connect(led.logic_in)

nxor = specialize_module(xor, XOR_with_NANDS())
battery = specialize_module(power_source, F.Battery())
Expand All @@ -122,36 +111,34 @@ def App():
e_switch = specialize_module(
el_switch,
e_switch,
matrix=[
(e, el.IFs.signal)
for e, el in zip(e_switch.IFs.unnamed, el_switch.IFs.unnamed)
],
matrix=[(e, el.signal) for e, el in zip(e_switch.unnamed, el_switch.unnamed)],
)

# build graph
app = Module()
app.NODEs.components = [
for c in [
led,
switch,
battery,
e_switch,
]
]:
app.add(c)

# parametrizing
for _, t in get_all_nodes_with_trait(app.get_graph(), F.ElectricLogic.has_pulls):
for pull_resistor in (r for r in t.get_pulls() if r):
pull_resistor.PARAMs.resistance.merge(100 * P.kohm)
power_source.IFs.power.PARAMs.voltage.merge(3 * P.V)
led.NODEs.led.NODEs.led.PARAMs.brightness.merge(
pull_resistor.resistance.merge(100 * P.kohm)
power_source.power.voltage.merge(3 * P.V)
led.led.led.brightness.merge(
TypicalLuminousIntensity.APPLICATION_LED_INDICATOR_INSIDE.value.value
)

# packages single nands as explicit IC
nand_ic = F.TI_CD4011BE()
for ic_nand, xor_nand in zip(nand_ic.NODEs.gates, nxor.NODEs.nands):
for ic_nand, xor_nand in zip(nand_ic.gates, nxor.nands):
specialize_module(xor_nand, ic_nand)

app.NODEs.nand_ic = nand_ic
app.add(nand_ic)

return app

Expand Down
23 changes: 8 additions & 15 deletions examples/minimal_led.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,24 @@
import typer

import faebryk.library._F as F
from faebryk.core.core import Module
from faebryk.core.module import Module
from faebryk.libs.brightness import TypicalLuminousIntensity
from faebryk.libs.examples.buildutil import (
apply_design_to_pcb,
)
from faebryk.libs.examples.buildutil import apply_design_to_pcb
from faebryk.libs.logging import setup_basic_logging

logger = logging.getLogger(__name__)


class App(Module):
def __init__(self) -> None:
super().__init__()
led: F.PoweredLED
battery: F.Battery

class _NODES(Module.NODES()):
led = F.PoweredLED()
battery = F.Battery()

self.NODEs = _NODES(self)

self.NODEs.led.IFs.power.connect(self.NODEs.battery.IFs.power)
def __preinit__(self) -> None:
self.led.power.connect(self.battery.power)

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

Expand Down
34 changes: 12 additions & 22 deletions examples/pcb_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,33 @@
import typer

import faebryk.library._F as F
from faebryk.core.core import Module
from faebryk.core.module import Module
from faebryk.exporters.pcb.layout.absolute import LayoutAbsolute
from faebryk.exporters.pcb.layout.extrude import LayoutExtrude
from faebryk.exporters.pcb.layout.typehierarchy import LayoutTypeHierarchy
from faebryk.library.has_pcb_layout_defined import has_pcb_layout_defined
from faebryk.library.has_pcb_position import has_pcb_position
from faebryk.library.has_pcb_position_defined import has_pcb_position_defined
from faebryk.libs.brightness import TypicalLuminousIntensity
from faebryk.libs.examples.buildutil import (
apply_design_to_pcb,
)
from faebryk.libs.examples.buildutil import apply_design_to_pcb
from faebryk.libs.logging import setup_basic_logging

logger = logging.getLogger(__name__)


class App(Module):
def __init__(self) -> None:
super().__init__()
leds: F.PoweredLED
battery: F.Battery

class _NODES(Module.NODES()):
leds = F.PoweredLED()
battery = F.Battery()

self.NODEs = _NODES(self)

self.NODEs.leds.IFs.power.connect(self.NODEs.battery.IFs.power)
def __preinit__(self) -> None:
self.leds.power.connect(self.battery.power)

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

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

layout = LayoutTypeHierarchy(
layouts=[
Expand All @@ -68,8 +58,8 @@ class _NODES(Module.NODES()):
),
]
)
self.add_trait(has_pcb_layout_defined(layout))
self.add_trait(has_pcb_position_defined(Point((50, 50, 0, L.NONE))))
self.add_trait(F.has_pcb_layout_defined(layout))
self.add_trait(F.has_pcb_position_defined(Point((50, 50, 0, L.NONE))))


# Boilerplate -----------------------------------------------------------------
Expand Down
Loading