|
1 | | -# PolymorphicBlocks |
2 | | -Placeholder for UIST'20 paper |
| 1 | +## Getting Started |
| 2 | +See [the getting started document](getting-started.md). |
| 3 | +Also, see [the reference document](reference.md) for a list and short description of ports, links, and parts. |
| 4 | + |
| 5 | +## Developing and running |
| 6 | + |
| 7 | +### Python packages |
| 8 | +```python |
| 9 | +pip install protobuf py4j |
| 10 | +``` |
| 11 | +(or, on Ubuntu, to select a different version of Python, use eg `python3.8 -m pip` instead of `pip` directly) |
| 12 | + |
| 13 | +### Static checking |
| 14 | +``` |
| 15 | +mypy --check-untyped-defs -p edg_core -p electronics_model -p electronics_abstract_parts -p electronics_lib -p edg -p examples -p compiler_gui |
| 16 | +``` |
| 17 | + |
| 18 | +Or faster, with mypy in daemon mode: |
| 19 | +``` |
| 20 | +dmypy run -- --follow-imports=error --check-untyped-defs -p edg_core -p electronics_model -p electronics_abstract_parts -p electronics_lib -p edg -p examples -p compiler_gui |
| 21 | +``` |
| 22 | + |
| 23 | +Note: since mypy currently doesn't infer return types (see mypy issue 4409), some defs might be incomplete, so the type check is leaky and we can't currently use `--disallow-incomplete-defs` or `--disallow-untyped-defs`. |
| 24 | +If that doesn't get resolved, we might go through and manually annotate all return types. |
| 25 | + |
| 26 | +### Unit testing |
| 27 | +``` |
| 28 | +python -m unittest discover |
| 29 | +``` |
| 30 | + |
| 31 | +PROTIP: run both by combining the commands with `&&` |
| 32 | + |
| 33 | +### Building Java dependencies |
| 34 | +#### IntelliJ Project Setup |
| 35 | +- Open `frontend\compiler_gui\resources\java\py4j_elk` in IntelliJ |
| 36 | +- From main menu > File > Project Structure: |
| 37 | + - In Project Settings > Libraries, add these as Maven libraries: |
| 38 | + - net.sf.py4j:py4j:0.10.8.1 |
| 39 | + - org.eclipse.elk:org.eclipse.elk.alg.graphviz.dot:0.5.0 |
| 40 | + - org.eclipse.elk:org.eclipse.elk.alg.layered:0.5.0 |
| 41 | + - org.eclipse.elk:org.eclipse.elk.graph.json:0.5.0 |
| 42 | + - In Project Settings > Modules, ensure py4j_elk is added as a Module, and the `src/` folder is marked as source |
| 43 | + - In Project Settings > Modules, add a JAR build, "from module with dependencies". |
| 44 | + - For "Main class", choose "org.edg.Main" |
| 45 | + - For "JAR files from libraries", select "copy to the output directory and link via manifest", to avoid signature mismatches |
| 46 | + |
| 47 | + |
| 48 | +## Frontend Model and Architecture |
| 49 | + |
| 50 | +### Core |
| 51 | +#### Block Diagram |
| 52 | +- BaseBlock: abstract base class for all block-like constructs, which contain ports (IOs), parameters, and constraints between them. |
| 53 | + In general, subclasses may override superclass ports with a subtype port. (TODO: is this a good idea?) |
| 54 | + Provides infrastructure to record the names of ports and parameters (by overriding __setattr__) with the syntax self.[name] = self.Port([port]) |
| 55 | +- Link: abstract base class for all links, which are inferred to fit a connection between ports. |
| 56 | +- Block: abstract base class for blocks. |
| 57 | +- ConcreteBlock: abstract base class for blocks that can be part of a final design. |
| 58 | +- PortBridge: block-like construct that defines how an external port of a hierarchy block connects to an internal link, such as by adapting the type and propagating constraints. |
| 59 | +- HierarchyBlock: abstract base class for blocks that contain an internal block diagram (with internal blocks and connections), which may also link to external ports. |
| 60 | +- GeneratorPart (TODO: needs renaming and implementation): a hierarchy block that contains a function to generate the internal block diagram once the external block diagram is solved. |
| 61 | + Allows arbitrary Python to control the internal generation, since it is not part of the SMT loop. |
| 62 | +- BasePort: abstract mixin for all port-like constructs, which knows its parent (either a block or a container port). |
| 63 | +- BaseContainerPort: abstract base class for all ports that contains other ports. |
| 64 | +- Port: abstract base class for leaf-level ports, which contains parameters. |
| 65 | + Defines the link_type it may connect to (TODO: should it support multiple link types, of a common superclass?), and provides access to the connected link which can be used to avoid propagating duplicate parameters. |
| 66 | + Also defines the bridge_type, if one exists where this port is the external port on a hierarchy block. |
| 67 | +- Bundle: a Port and a BaseContainerPort, that defines internal fields (other ports). |
| 68 | +- Vector: an unknown-sized vector (array) of ports, which supports a map-extract operation to return an Array of some inner parameter as well as reduction operators that wrap the map-extract and an Array reduction. |
| 69 | + |
| 70 | +#### Parameters & Expressions |
| 71 | +- ConstraintExpr: abstract base class for constraint expressions. |
| 72 | +- BoolExpr: ConstraintExpr that is a Bool. |
| 73 | +- NumLikeExpr: ConstraintExpr abstract base class for numeric expressions, provides arithmetic operations compatible with SMT solvers (add, subtract, comparison). |
| 74 | +- FloatExpr: ConstraintExpr that is a real number. |
| 75 | +- RangeExpr: ConstraintExpr that is a real-valued interval type, with a min and max. (TODO: may support null-intervals) |
| 76 | +- Array: an unknown-sized array (container) of ConstraintExpr, which supports reduction operators (eg, sum, min, max, intersection). |
| 77 | + |
| 78 | +#### Other |
| 79 | +- Driver: provides auto-discovery of block diagram components in a Python library. |
| 80 | + (TODO: provides conversion to design, including recursive instantiation of library elements) |
| 81 | + |
| 82 | +### Electronics Model |
| 83 | +- ElectricaSink/Source/Link/Bridge: represents a single copper net, and models runtime voltage and currents as well as their limits |
| 84 | + Can be used as a base class for other single-copper-net ports. |
| 85 | +- DigitalSink/Source/Link/Bridge: subclass of Electrical*, additionally models logic IO thresholds |
| 86 | +- BaseCircuitBlock: a Block with associated footprints (where pins can be mapped to Electrical* ports) and nets (connections between Electrical* ports) |
| 87 | + This can be used for component-level blocks, links (with nets defining copper connectivity between ports), and hierarchy blocks. |
| 88 | + Not all blocks need a footprint: abstract blocks can rely on a refinement for a footprint, and hierarchy blocks can rely on internal blocks for footprints. |
| 89 | + |
| 90 | +### Standard Parts |
| 91 | +A standard library of actual parts (eg, could buy off DigiKey), their models, and supporting reference implementation components / circuits. |
0 commit comments