Skip to content

Check Topology Definitions

bocchino edited this page Mar 25, 2021 · 26 revisions

This algorithm traverses the source model and checks topology definitions.

Input

  1. A list tul of translation units.

  2. An analysis data structure a representing the results of analysis so far.

Output

An updated analysis a' with the topology map filled in if the check passes; otherwise an error.

Procedure

Visit each translation unit in tul with input a, yielding either a' or an error.

AST Visitor Methods

Each method accepts an analysis data structure a as input and yields either an updated analysis data structure a' or an error as output.

Translation Units

For each translation unit tu, visit each definition appearing in tu.

Component Definitions

For each topology definition d that has not yet been resolved:

  1. Visit each member m of d with input a, building up a topology data structure t. Check each member for semantic validity. For example, ensure that the types of the port connections match. Check that (i) user-specified port numbers are in bounds for their ports and (ii) no two connections at the same output port have the same number. If not, throw an error. Don’t check pattern validity yet, except to resolve uses.

  2. Visit all topologies imported into t, ensuring that they are resolved.

  3. Resolve t to a partially numbered topology consisting of (a) a list of instances and (b) a mapping between connection graph names and lists of connections. The connection end points have port numbers if and only if those numbers are present in the model source.

    1. Determine the set of all instances in t, consisting of (a) all instances specified in t and (b) public instances specified in topologies imported into t.

    2. For each connection graph name g appearing in t or in an imported topology, determine the set of all connections in g, with multiplicity (two or more connections between the same pairs of unnumbered ports are allowed).

      1. Include all connections directly specified in t. Check that all connections are between instances present in t. If not, throw an error.

      2. Include all connections from imported topologies that go between instances present in t.

    3. Resolve pattern specifiers in t to and add the resulting connections to t.

  4. Check that the number of connections at each output port is in bounds for the port size.

  5. Apply automatic numbering to t. This step fills in missing port numbers, preserving any numbers specified in the model source.

    1. Apply matched numbering. For each instance I, for each matching M = (p1, p2) specified in I:

      1. For each connection C1 to p1, compute the corresponding connection C2 to p2. If there is no such connection, then throw an error.

      2. For each pair (C1, C2), if the connections specify port numbers for both p1 and p2, then check that the numbers match. If not, throw an error. Otherwise if the connections specify a port number for either of p1 or p2, then assign the other number to match.

      3. For each pair (C1, C2) that does not have a port number assigned, find the lowest available port number at p1 and assign it for C1 at p1 and C2 at p2.

    2. Apply general numbering.

      1. For each port instance P involved in an output connection C, if C has no assigned from port number, then find the lowest port number available at P and assign it as the from port number.

      2. For each port instance P involved in an input connection C, if C has no assigned to port number, then assign zero as the from port number.

  6. Compute the ports that are actually unused.

  7. Construct the unique topology symbol s for d.

  8. Map s to t in the topology map of a.

  9. Return a as the result.

Clone this wiki locally