A hardware dimension that is either concrete or depends on retained module parameters. This is deliberately a small, closed language: the compiler must reject Lean computations it cannot preserve instead of evaluating them only at a parameter's default value.
- literal (value : Nat) : DimExpr
- parameter (name : String) : DimExpr
- add (lhs rhs : DimExpr) : DimExpr
- sub (lhs rhs : DimExpr) : DimExpr
- mul (lhs rhs : DimExpr) : DimExpr
- div (lhs rhs : DimExpr) : DimExpr
- mod (lhs rhs : DimExpr) : DimExpr
- pow (base exponent : DimExpr) : DimExpr
- clog2 (value : DimExpr) : DimExpr
- min (lhs rhs : DimExpr) : DimExpr
- max (lhs rhs : DimExpr) : DimExpr
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- (Sparkle.IR.Type.DimExpr.literal value).isConcrete = true
- x✝.isConcrete = false
Instances For
Equations
- (Sparkle.IR.Type.DimExpr.literal 0).mkAdd x✝ = x✝
- x✝.mkAdd (Sparkle.IR.Type.DimExpr.literal 0) = x✝
- (Sparkle.IR.Type.DimExpr.literal lhs).mkAdd (Sparkle.IR.Type.DimExpr.literal rhs) = Sparkle.IR.Type.DimExpr.literal (lhs + rhs)
- x✝¹.mkAdd x✝ = x✝¹.add x✝
Instances For
Equations
- x✝.mkSub (Sparkle.IR.Type.DimExpr.literal 0) = x✝
- (Sparkle.IR.Type.DimExpr.literal lhs).mkSub (Sparkle.IR.Type.DimExpr.literal rhs) = Sparkle.IR.Type.DimExpr.literal (lhs - rhs)
- x✝¹.mkSub x✝ = x✝¹.sub x✝
Instances For
Equations
- (Sparkle.IR.Type.DimExpr.literal 0).mkMul x✝ = Sparkle.IR.Type.DimExpr.literal 0
- x✝.mkMul (Sparkle.IR.Type.DimExpr.literal 0) = Sparkle.IR.Type.DimExpr.literal 0
- (Sparkle.IR.Type.DimExpr.literal 1).mkMul x✝ = x✝
- x✝.mkMul (Sparkle.IR.Type.DimExpr.literal 1) = x✝
- (Sparkle.IR.Type.DimExpr.literal lhs).mkMul (Sparkle.IR.Type.DimExpr.literal rhs) = Sparkle.IR.Type.DimExpr.literal (lhs * rhs)
- x✝¹.mkMul x✝ = x✝¹.mul x✝
Instances For
Equations
Hardware Type: The subset of types that can be synthesized to hardware.
- Bit: Single bit (wire)
- BitVector: n-bit vector
- Array: Fixed-size array (for memories/ROMs)
- bit : HWType
- bitVector (width : Nat) : HWType
- bitVectorDim (width : DimExpr) : HWType
- array (size : Nat) (elemType : HWType) : HWType
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Sparkle.IR.Type.instBEqHWType.beq Sparkle.IR.Type.HWType.bit Sparkle.IR.Type.HWType.bit = true
- Sparkle.IR.Type.instBEqHWType.beq (Sparkle.IR.Type.HWType.bitVector a) (Sparkle.IR.Type.HWType.bitVector b) = (a == b)
- Sparkle.IR.Type.instBEqHWType.beq (Sparkle.IR.Type.HWType.bitVectorDim a) (Sparkle.IR.Type.HWType.bitVectorDim b) = (a == b)
- Sparkle.IR.Type.instBEqHWType.beq (Sparkle.IR.Type.HWType.array a a_1) (Sparkle.IR.Type.HWType.array b b_1) = (a == b && Sparkle.IR.Type.instBEqHWType.beq a_1 b_1)
- Sparkle.IR.Type.instBEqHWType.beq x✝¹ x✝ = false
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
- Sparkle.IR.Type.instDecidableEqHWType.decEq Sparkle.IR.Type.HWType.bit Sparkle.IR.Type.HWType.bit = isTrue ⋯
- Sparkle.IR.Type.instDecidableEqHWType.decEq Sparkle.IR.Type.HWType.bit (Sparkle.IR.Type.HWType.bitVector width) = isFalse ⋯
- Sparkle.IR.Type.instDecidableEqHWType.decEq Sparkle.IR.Type.HWType.bit (Sparkle.IR.Type.HWType.bitVectorDim width) = isFalse ⋯
- Sparkle.IR.Type.instDecidableEqHWType.decEq Sparkle.IR.Type.HWType.bit (Sparkle.IR.Type.HWType.array size elemType) = isFalse ⋯
- Sparkle.IR.Type.instDecidableEqHWType.decEq (Sparkle.IR.Type.HWType.bitVector width) Sparkle.IR.Type.HWType.bit = isFalse ⋯
- Sparkle.IR.Type.instDecidableEqHWType.decEq (Sparkle.IR.Type.HWType.bitVector a) (Sparkle.IR.Type.HWType.bitVector b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Sparkle.IR.Type.instDecidableEqHWType.decEq (Sparkle.IR.Type.HWType.bitVector width) (Sparkle.IR.Type.HWType.bitVectorDim width_1) = isFalse ⋯
- Sparkle.IR.Type.instDecidableEqHWType.decEq (Sparkle.IR.Type.HWType.bitVector width) (Sparkle.IR.Type.HWType.array size elemType) = isFalse ⋯
- Sparkle.IR.Type.instDecidableEqHWType.decEq (Sparkle.IR.Type.HWType.bitVectorDim width) Sparkle.IR.Type.HWType.bit = isFalse ⋯
- Sparkle.IR.Type.instDecidableEqHWType.decEq (Sparkle.IR.Type.HWType.bitVectorDim width) (Sparkle.IR.Type.HWType.bitVector width_1) = isFalse ⋯
- Sparkle.IR.Type.instDecidableEqHWType.decEq (Sparkle.IR.Type.HWType.bitVectorDim a) (Sparkle.IR.Type.HWType.bitVectorDim b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Sparkle.IR.Type.instDecidableEqHWType.decEq (Sparkle.IR.Type.HWType.bitVectorDim width) (Sparkle.IR.Type.HWType.array size elemType) = isFalse ⋯
- Sparkle.IR.Type.instDecidableEqHWType.decEq (Sparkle.IR.Type.HWType.array size elemType) Sparkle.IR.Type.HWType.bit = isFalse ⋯
- Sparkle.IR.Type.instDecidableEqHWType.decEq (Sparkle.IR.Type.HWType.array size elemType) (Sparkle.IR.Type.HWType.bitVector width) = isFalse ⋯
- Sparkle.IR.Type.instDecidableEqHWType.decEq (Sparkle.IR.Type.HWType.array size elemType) (Sparkle.IR.Type.HWType.bitVectorDim width) = isFalse ⋯
Instances For
Equations
Get the bit width of a hardware type
Equations
- One or more equations did not get rendered due to their size.
- Sparkle.IR.Type.HWType.bit.bitWidth = 1
- (Sparkle.IR.Type.HWType.bitVector w).bitWidth = w
- (Sparkle.IR.Type.HWType.bitVectorDim (Sparkle.IR.Type.DimExpr.literal w)).bitWidth = w
- (Sparkle.IR.Type.HWType.array size elemType).bitWidth = size * elemType.bitWidth
Instances For
Checked concrete width for consumers that do not support retained dimensions.
Equations
- Sparkle.IR.Type.HWType.bit.bitWidth? = some 1
- (Sparkle.IR.Type.HWType.bitVector w).bitWidth? = some w
- (Sparkle.IR.Type.HWType.bitVectorDim (Sparkle.IR.Type.DimExpr.literal w)).bitWidth? = some w
- (Sparkle.IR.Type.HWType.bitVectorDim width).bitWidth? = none
- (Sparkle.IR.Type.HWType.array size elemType).bitWidth? = Option.map (fun (x : Nat) => size * x) elemType.bitWidth?
Instances For
Return the packed width without discarding symbolic dimensions.
Equations
- Sparkle.IR.Type.HWType.bit.bitWidthDim = Sparkle.IR.Type.DimExpr.literal 1
- (Sparkle.IR.Type.HWType.bitVector a).bitWidthDim = Sparkle.IR.Type.DimExpr.literal a
- (Sparkle.IR.Type.HWType.bitVectorDim a).bitWidthDim = a
- (Sparkle.IR.Type.HWType.array a a_1).bitWidthDim = (Sparkle.IR.Type.DimExpr.literal a).mkMul a_1.bitWidthDim
Instances For
Check if a hardware type is a bit vector
Equations
Instances For
Convert hardware type to a human-readable string
Equations
- Sparkle.IR.Type.HWType.bit.toString = "Bit"
- (Sparkle.IR.Type.HWType.bitVector 1).toString = "Bit"
- (Sparkle.IR.Type.HWType.bitVector w).toString = toString "BitVec" ++ toString w
- (Sparkle.IR.Type.HWType.bitVectorDim width).toString = toString "BitVec(" ++ toString width ++ toString ")"
- (Sparkle.IR.Type.HWType.array size elemType).toString = toString "Array[" ++ toString size ++ toString "](" ++ toString elemType.toString ++ toString ")"
Instances For
Equations
Convert a Lean type with BitPack instance to HWType
Equations
Instances For
Helper to infer HWType from a Nat width
Equations
Instances For
Construct a packed hardware type while preserving a symbolic dimension.
Equations
Instances For
8-bit hardware type
Instances For
16-bit hardware type
Equations
Instances For
32-bit hardware type
Equations
Instances For
64-bit hardware type
Equations
Instances For
Boolean hardware type
Instances For
Reset kind: synchronous or asynchronous.
Lives here (not in Sparkle.Core.Domain) so the IR layer can
reference it without importing Core/Domain.lean (which would
create a layering inversion). Sparkle.Core.Domain re-exports
this so user code keeps seeing Sparkle.Core.Domain.ResetKind.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
Equations
- Sparkle.IR.Type.instBEqResetKind.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)