Skip to content

Instantly share code, notes, and snippets.

@peter-b
Last active August 29, 2015 14:26
Show Gist options
  • Save peter-b/f3d9978ba11093a9dc7c to your computer and use it in GitHub Desktop.
Save peter-b/f3d9978ba11093a9dc7c to your computer and use it in GitHub Desktop.
libnetlist ideas

libnetlist ideas

Copyright © Peter Brett 2015

This work is licensed under a Creative Commons Attribution 4.0 International License.

Basic hierarchy

The refdes problem

Each circuit has subcircuits, i.e. a circuit can instantiate another circuit as a circuit instance.

Each circuit has attributes that can can have instance-specific values. For example, the "refdes" of physical parts on a PCB need to be uniquely and flatly numbered across the design, no matter how deep the hierarchy.

This introduces complications, as follows.

  • Consider a circuit A. It is instantiated twice in circuit B. That means that two instances are needed: B→A1 and B→A2.

  • Consider another circuit C that instantiates B twice. Now there are 6 instances needed: C→B1→A1, C→B1→A2, C→B2→A1, and C→B2→A2.

Instance-only model

It might be conceptually clearer if we get rid of circuits altogether, and only have circuit instances.

Each instance can either be an overlay, in which case it's derived from another instance, or a root, which isn't derived from anything.

Each instance also contains children. Children must be overlays. If an overlay Y is derived from an instance X, then Y must have exactly one child derived from each child of X.

Overall, this means that each root contains an instance for each subcircuit instantiated at every level of the design, and this ensures that there's a place to attach attributes to every element in the design.

Evaluating attributes in the instance-only model

Suppose that there's a root A, and it's instantiated by B. The instance diagram is:

A         B
⇩
AB1 → B

To evaluate an attribute:

  1. find the path of the instance that you want to evaluate the attribute for (e.g. A⇨AB1)
  2. get the derivation list for the instance (e.g. AB1→B)
  3. walk the derivation list until you find a value for the attribute.

Returning to the refdes problem

The instance diagram is:

C                                   B          A
⇩                                   ⇩
CB1 → B           CB2 → B           BA1 → A
⇩                 ⇩                 BA2 → A
CB1A1 → BA1 → A   CB2A1 → BA1 → A
CB1A2 → BA2 → A   CB2A2 → BA2 → A

In the PCB design for C, the designer assigns a refdes to each instance of A. These can be attached to the instances CB1A1, CB1A2, CB2A1, and CB2A2.

The instance-only design allows full back-annotation and full hierarchy.

Ports

A circuit has ports. These are ways that instances of the circuit can be connected into the netlist. For example, a circuit that represents a resistor would have a port for each of the resistor's pins.

Instance-only model for ports

Like circuit instances, there are similarly root ports and overlay ports. A root instance has a list of root ports, and an overlay instance has a list of overlay ports. An overlay instance has exactly one overlay port for each port in the instance it was derived from.

This setup allows attributes to be attached to ports at any level in the hierarchy.

Unresolved: Does this scheme cause issues with netlist resolution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment