Documentation

Sparkle.Backend.Verilog

Sanitize a name to be a valid Verilog identifier

Equations
Instances For

    Emit a symbolic hardware dimension as a SystemVerilog constant expression.

    Convert Operator to Verilog operator symbol

    Equations
    Instances For
      partial def Sparkle.Backend.Verilog.emitExpr (widthOf : StringOption Nat := fun (x : String) => none) (e : IR.AST.Expr) :

      Convert IR expression to Verilog expression. widthOf maps a wire name to its declared bit width (when known), so a full-width / scalar .slice can be elided — Verilog forbids a part-select on a scalar (s[0:0] → "can not select part of scalar").

      def Sparkle.Backend.Verilog.emitStmt (stmt : IR.AST.Stmt) (indent : String := " ") (wires : List IR.AST.Port := []) :

      Emit a single statement. The optional wires parameter provides wire declarations for register reset value width lookup.

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

        Emit port declarations for module header

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

          Emit wire declarations

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

            Emit a SystemVerilog module parameter list.

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

              Emit the full module

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

                Main entry point: Convert a Module to SystemVerilog

                Equations
                Instances For

                  Convert a full Design to SystemVerilog.

                  Each module is run through the IR optimizer first — exactly as #synthesizeVerilog does before toVerilog (see Sparkle.Compiler.Elab). This is essential, not cosmetic: the optimizer's 0-bit elimination pass strips the degenerate 0-width concat tails that circuit do / Signal.loop bundles leave behind ({reg, <0-bit>}). Without it those tails reach emitConst, which promotes a 0-width literal to 1'd0, widening the concat by one bit so the intermediate wire (sized for the real field) TRUNCATES the real value away — silently freezing the least-significant register of every bundle at its reset value. Hierarchical emission (#writeVerilogDesign) is the only source of the @[hardware_module] submodules, so skipping this here broke every sub-module's last register (e.g. uartRxHW's rxValid).

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

                    Write module to a file

                    Equations
                    Instances For

                      Write a full design to a file

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