Commit e22fb40
authored
Compositional generators (#250)
Resolves #215. One of those rare PRs with more lines removed than added!
Changes generators to be compositional: instead of a monolithic single
`self.generator(fn, ...args...)`, this now invokes `self.generate()`
(structurally like `self.contents()`) which can `self.get(...)` on any
parameter. Parameters must be declared with `self.generator_param(...)`
ahead of time (in `__init__` and `contents`), but this can be called
multiple times.
Refactors libraries to use mixins and have better separation of
concerns. Major changes:
- Parts table based selectors now have individual select functionality
in each mixin class, e.g. the footprint class handles filtering by
footprint spec, and the smd-standard-package class handles filtering by
the minimum-smd-package
- Microcontrollers (application circuits) no longer duplicate code (in
each microcontroller class) for generating oscillators or stuffing
additional pins onto SWD ports, these have been refactored into common
mixins enabled by compositional generators.
- Deduplicate microcontroller pin mapping / pin allocation code with the
new `BaseIoControllerPinmapGenerator` base class.
- (Syntactic) refactoring of libraries to use the new generators tyle
This provides no functionality changes (aside from the generator API,
though a deprecation is kept), this is an implementation change only.
Future features will build on this base infrastructure.
Minor changes:
- Capacitors: unifies the single and multiple-parallel code
- The microcontroller refactor changes the connection and component
ordering, which changes the netlists. However, the netlists should still
be structurally the same (isomorphic).
- Add standard pinning to the (abstract) LED base class
- Refactor FT232 to have port arrays on ACBUS and ADBUS
- Add types to requirements.txt
---
Notes:
- Another generator API could be defining the generator params as
objects using `param = self.GeneratorParam(...wrapped...)` and
supporting `param.get()`, akin to `self.ArgParameter(...)`. This was
actually attempted first, but in practice this creates a duplicate
object with the underlying parameter so it's not clear what should be
used where. However, it is a bit more type-safe (since current we can
`self.get(...)` anything, whereas if you have a GeneratorParam object,
`.get()` is guaranted as long as it's within the generate phase).
- This causes a 10-15% performance penalty in the unit test suite.
Likely, the parts table selectors are a lot less efficient, because of
`super()` call overhead, and possibly other additional work done because
while the new structure enables code deduplication, it constrains
optimizations. In particular, the unified single and multiple-parallel
capacitors does more work in the single case now since parallel caps are
being computed for all cases, across the entire parts table.
- Some parts are have potentially bad performance
- Resistor arrays repeat redundant calculations per-row.
- This supports internal-facing mixins (how blocks can share
implementations) per #104, while external mixins (eg, how to specify "I
want an abstract voltage regulator with a EN pin") would be a future
feature.
- Closes #166, since this uses `self.connect(...)` to create a node in a
way where it can't have type information. In the bigger picture, it
probably makes sense to separate the capabilities of a port and the
capabilities of a connection.1 parent 6288568 commit e22fb40
File tree
93 files changed
+2036
-2351
lines changed- edg_core
- electronics_abstract_parts
- electronics_lib
- electronics_model
- examples
- BldcController
- CanAdapter
- Datalogger
- Fcml
- HighSwitch
- Multimeter
- SwdDebugger
- TofArray
- UsbFpgaProgrammer
- UsbSourceMeasure
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
93 files changed
+2036
-2351
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
128 | 132 | | |
129 | 133 | | |
130 | 134 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | | - | |
| 19 | + | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | | - | |
| 34 | + | |
| 35 | + | |
36 | 36 | | |
37 | | - | |
38 | | - | |
| 37 | + | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
54 | 56 | | |
55 | | - | |
56 | | - | |
57 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
| |||
118 | 120 | | |
119 | 121 | | |
120 | 122 | | |
121 | | - | |
| 123 | + | |
| 124 | + | |
122 | 125 | | |
123 | 126 | | |
124 | | - | |
125 | | - | |
| 127 | + | |
| 128 | + | |
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
| |||
146 | 149 | | |
147 | 150 | | |
148 | 151 | | |
149 | | - | |
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
| |||
194 | 196 | | |
195 | 197 | | |
196 | 198 | | |
197 | | - | |
198 | 199 | | |
199 | | - | |
| 200 | + | |
200 | 201 | | |
201 | 202 | | |
202 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
| 11 | + | |
14 | 12 | | |
15 | 13 | | |
16 | | - | |
| 14 | + | |
17 | 15 | | |
18 | 16 | | |
19 | 17 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | 18 | | |
35 | 19 | | |
36 | 20 | | |
37 | 21 | | |
38 | | - | |
| 22 | + | |
39 | 23 | | |
40 | | - | |
41 | | - | |
| 24 | + | |
| 25 | + | |
42 | 26 | | |
43 | 27 | | |
44 | | - | |
| 28 | + | |
45 | 29 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | | - | |
17 | | - | |
| 16 | + | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | 55 | | |
59 | 56 | | |
60 | 57 | | |
61 | | - | |
| 58 | + | |
62 | 59 | | |
63 | 60 | | |
64 | | - | |
| 61 | + | |
65 | 62 | | |
66 | 63 | | |
67 | 64 | | |
68 | 65 | | |
69 | 66 | | |
70 | | - | |
| 67 | + | |
71 | 68 | | |
72 | 69 | | |
73 | | - | |
| 70 | + | |
74 | 71 | | |
75 | 72 | | |
76 | 73 | | |
| |||
119 | 116 | | |
120 | 117 | | |
121 | 118 | | |
122 | | - | |
| 119 | + | |
| 120 | + | |
123 | 121 | | |
124 | | - | |
125 | | - | |
| 122 | + | |
| 123 | + | |
126 | 124 | | |
127 | 125 | | |
128 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
| 44 | + | |
44 | 45 | | |
45 | | - | |
| 46 | + | |
46 | 47 | | |
| 48 | + | |
47 | 49 | | |
| 50 | + | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
| |||
121 | 125 | | |
122 | 126 | | |
123 | 127 | | |
124 | | - | |
| 128 | + | |
125 | 129 | | |
126 | | - | |
| 130 | + | |
| 131 | + | |
127 | 132 | | |
128 | | - | |
| 133 | + | |
129 | 134 | | |
130 | 135 | | |
131 | 136 | | |
| |||
161 | 166 | | |
162 | 167 | | |
163 | 168 | | |
164 | | - | |
| 169 | + | |
165 | 170 | | |
166 | | - | |
| 171 | + | |
| 172 | + | |
167 | 173 | | |
168 | | - | |
| 174 | + | |
169 | 175 | | |
170 | 176 | | |
171 | 177 | | |
| |||
0 commit comments