Documentation

Sparkle.Core.Wireable

Asserts that α has a known hardware bit-width.

Instances are intentionally minimal — no toBits/fromBits. The IR elaborator recognises the structural shape of α (BitVec / Bool / Prod / HWVector) directly when wiring, so the typeclass only needs to expose the width for code that reasons about state size statically.

Instances
    @[reducible]

    Right-nested heterogeneous product over a static type list.

    HList [α, β, γ] = α × β × γ × Unit. Definitionally a Prod chain so Prod.fst / Prod.snd projections (which the IR elaborator already lowers to bit slices) reach individual slots without needing new wire rules.

    Equations
    Instances For
      @[reducible]
      def Sparkle.Core.HList.cons {α : Type} {αs : List Type} (x : α) (xs : HList αs) :
      HList (α :: αs)

      Element-wise construction (the same shape α × HList αs of the inductive HList (α :: αs), just sugared).

      Equations
      Instances For
        @[reducible]
        Equations
        Instances For
          @[reducible]
          def Sparkle.Core.HList.head {α : Type} {αs : List Type} (h : HList (α :: αs)) :
          α

          Head of a non-empty HList — definitionally Prod.fst.

          Equations
          Instances For
            @[reducible]
            def Sparkle.Core.HList.tail {α : Type} {αs : List Type} (h : HList (α :: αs)) :
            HList αs

            Tail of a non-empty HList — definitionally Prod.snd.

            Equations
            Instances For

              Empty HList wires to a zero-width slot. Matches the Prod chain's Unit terminator.

              Equations
              instance Sparkle.Core.instWireableProd {α β : Type} [ : Wireable α] [ : Wireable β] :
              Wireable (α × β)

              Prod of two Wireables is Wireable. Width is the sum, exactly what the elaborator's existing Prod wire rule does.

              Equations

              HListWireable αs asserts that every element type in αs has a Wireable instance. Used as a constraint on runCircuit so users can't accidentally place non- synthesisable types (e.g. Option Nat) into the register state list — the type check fires at the runCircuit call site, well before #synthesizeVerilog would.

              The class is intentionally empty: its presence is the assertion. Instances are derived structurally on the list so any αs whose elements are individually Wireable automatically gets an instance.

              Wireable (HList αs) follows by induction over the Prod chain α × HList αs, using the existing Wireable (α × β) instance above.

                Instances

                  HList αs is Wireable whenever every element is. Induction over the list.

                  Equations