Documentation

Sparkle.Display.Diagram

Node and edge kinds #

The visual class of a diagram node.

Each variant gets its own SVG art in renderNode below — a rectangle for a register, a trapezoid for a mux, a gate body for combinational primitives, etc. Use gen for anything you don't have a dedicated shape for; it falls back to a plain box with the node's label.

Instances For
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      The visual class of an edge.

      data is the default — a thin arrow. clock is dashed and terminates in a small triangle at the destination's clock pin. bus n carries an n-bit width label and is drawn thicker.

      Instances For
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Structures #

          One block in the diagram.

          inputs lets a multi-input node (e.g. a 4:1 mux) declare how many distinct input pins it has on the left; edges can target a specific pin via dst := "muxId.<index>".

          Instances For

            One wire in the diagram. dst is nodeId for a single-input node, or nodeId.k to target the k-th input pin of a multi-input node.

            Instances For

              A complete diagram. blockDiagram (below) renders it.

              Instances For

                SVG rendering #

                Render a Diagram as a single SVG document.

                Edges first (so node bodies overlay them), then nodes. Multi-input destinations distribute their incoming edges across the node's left side.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  Render a Diagram and emit it to the current cell as an image/svg+xml payload. text/html (an <img> wrapping the SVG) is also acceptable but plain SVG keeps the output smaller and lets JupyterLab's vector-zoom handle scaling.

                  Equations
                  Instances For

                    IR → Diagram #

                    Walk a Sparkle IR.AST.Module and synthesise a Diagram automatically. Each statement becomes one node; each Expr.ref inside a statement's RHS becomes one edge.

                    Layout: ports go in column 0 (inputs) and the rightmost column (outputs); registers and combinational gates fan out across the middle columns roughly in topological order. This isn't a real placer — the goal is "good enough to read at a glance", not to match a manually-authored figure.

                    Build a Diagram from a Sparkle IR module.

                    Strategy: each input port is a port node in column 0; each statement gets a node in some intermediate column based on its index in the body; each output port is a port node in the final column. Edges follow Expr.ref dependencies.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For