Documentation

Sparkle.IR.AST

A retained top-level Lean Nat binder exposed as a module parameter.

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

        Port declaration (input/output of a module)

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

              Hardware operators

              These represent primitive operations that map directly to hardware gates.

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

                  Expression in the netlist IR

                  • Const: Literal constant value
                  • Ref: Reference to a wire or port by name
                  • Op: Application of an operator to arguments
                  Instances For

                    Create a constant expression from a BitVec

                    Equations
                    Instances For

                      Create a wire reference

                      Equations
                      Instances For

                        Helper constructors for common operations

                        Equations
                        Instances For
                          def Sparkle.IR.AST.Expr.mux (cond then_ else_ : Expr) :
                          Equations
                          Instances For

                            Convert expression to string (for debugging)

                            Statement in the netlist IR

                            • Assign: Continuous assignment (combinational logic)
                            • Register: Sequential logic (D flip-flop)
                            • Memory: Synchronous RAM/BRAM primitive
                            • Inst: Instantiation of another module
                            Instances For
                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                Equations
                                Instances For

                                  Convert statement to string (for debugging)

                                  Equations
                                  Instances For

                                    Module: A hardware module with inputs, outputs, internal wires, and logic

                                    This represents a synthesizable hardware component.

                                    If isPrimitive is true, this is a blackbox module (e.g., vendor SRAM, clock gate) that should be instantiated but not defined. The body is ignored for primitives.

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

                                          Create an empty module

                                          Equations
                                          Instances For
                                            def Sparkle.IR.AST.Module.primitive (name : String) (inputs outputs : List Port) :

                                            Create a primitive (blackbox) module with specified interface

                                            Equations
                                            Instances For

                                              Append-vs-prepend perf note #

                                              `addParameter` / `addInput` / `addOutput` / `addWire` / `addStmt`
                                              are called in the inner loop of synthesis. The natural definition
                                              (`m.body ++ [s]`)
                                              is O(n) per call, which makes the whole module-building
                                              loop O(n²) and dominated runtime for FSM-shape circuits
                                              (memcached server top-level synth went from ~0.5 s for the
                                              first multi-output leaf to 32+ s for the sixth — same Δcalls,
                                              but `module.body` had grown 6× and every `++ [s]` paid
                                              for that).
                                              
                                              Fix: build the lists in REVERSE order via head-prepend
                                              (O(1)), then reverse them once at the end of synthesis
                                              in `Module.finalize`.  External callers that read
                                              module lists after `finalize` see the same forward
                                              order they always did. 
                                              

                                              Add a retained module parameter (O(1); reversed by finalize).

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

                                                Add an input port (O(1); reversed by finalize).

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

                                                  Add an output port (O(1); reversed by finalize).

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

                                                    Add an internal wire (O(1); reversed by finalize).

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

                                                      Add a statement to the body (O(1); reversed by finalize).

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

                                                        Reverse the append-in-reverse lists to forward order. Must be called exactly once after all incremental additions are done and before any consumer reads m.parameters / inputs / outputs / wires / body.

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

                                                          Convert module to string (for debugging)

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

                                                            Design: A collection of modules that make up a hardware project.

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

                                                                  Create an empty design

                                                                  Equations
                                                                  Instances For

                                                                    Add a module to the design

                                                                    Equations
                                                                    Instances For

                                                                      Find a module by name

                                                                      Equations
                                                                      Instances For