• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
        • Warnings
        • Primitives
        • Use-set
        • Syntax
        • Getting-started
        • Utilities
        • Loader
        • Transforms
        • Lint
        • Mlib
          • Scopestack
          • Filtering-by-name
          • Vl-namefactory
          • Substitution
          • Allexprs
          • Hid-tools
          • Vl-consteval
          • Range-tools
          • Lvalexprs
          • Hierarchy
          • Finding-by-name
          • Expr-tools
            • Vl-expr-widthsfixed-p
            • Vl-make-idexpr-list
            • Vl-exprlist-resolved->vals
            • Vl-idexprlist->names
            • Vl-expr-names
            • Vl-expr-count
            • Vl-idexpr
            • Vl-exprlist-to-plainarglist
            • Vl-expr-atoms
            • Vl-expr-ops
            • Vl-expr-count-noatts
            • Vl-make-index
              • Vl-expr-selects
              • Vl-bitlist-from-nat
              • Vl-pps-expr
              • Vl-expr-add-atts
              • Vl-idexprlist-p
              • Vl-expr-resolved-p
              • Vl-pps-origexpr
              • Vl-expr-funnames
              • Vl-idexpr->name
              • Vl-idexpr-p
              • Vl-exprlist-funnames
              • Vl-resolved->val
              • Vl-exprlist-resolved-p
              • Vl-expr->atts
              • Vl-obviously-true-expr-p
              • Vl-obviously-false-expr-p
              • Vl-exprlist-has-funcalls
              • Vl-expr-has-funcalls
              • Vl-zbitlist-p
              • Vl-zatom-p
              • Vl-exprlist-has-ops
              • Vl-expr-has-ops
              • Vl-expr-varnames
              • Vl-one-bit-constants
            • Expr-slicing
            • Stripping-functions
            • Stmt-tools
            • Modnamespace
            • Vl-parse-expr-from-str
            • Welltyped
            • Reordering-by-name
            • Flat-warnings
            • Genblob
            • Expr-building
            • Datatype-tools
            • Syscalls
            • Relocate
            • Expr-cleaning
            • Namemangle
            • Caremask
            • Port-tools
            • Lvalues
          • Server
          • Kit
          • Printer
          • Esim-vl
          • Well-formedness
        • Sv
        • Fgl
        • Vwsim
        • Vl
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Math
      • Testing-utilities
    • Expr-tools

    Vl-make-index

    Safely create a constant integer atom whose value is n.

    Signature
    (vl-make-index n) → index
    Returns
    index — Type (vl-expr-p index).

    n is expected to be a natural number, but our guard is only t. We cause a hard error if we are given a non-natural number index, or one which is too large. BOZO consider a stronger guard.

    Definitions and Theorems

    Function: vl-make-index

    (defun vl-make-index (n)
     (declare (xargs :guard t))
     (let ((__function__ 'vl-make-index))
       (declare (ignorable __function__))
       (let*
        ((value (if (natp n)
                    n
                  (prog2$ (raise "Proposed index is not a natural: ~x0."
                                 n)
                          0)))
         (width (+ 1 (integer-length value))))
        (if
         (<= width 31)
         (hons-copy
              (make-vl-atom :guts (make-vl-constint :origwidth 32
                                                    :origtype :vl-signed
                                                    :wasunsized t
                                                    :value value)
                            :finalwidth 32
                            :finaltype :vl-signed))
         (hons-copy
              (make-vl-atom :guts (make-vl-constint :origwidth width
                                                    :origtype :vl-signed
                                                    :value value)
                            :finalwidth width
                            :finaltype :vl-signed))))))

    Theorem: vl-expr-p-of-vl-make-index

    (defthm vl-expr-p-of-vl-make-index
      (b* ((index (vl-make-index n)))
        (vl-expr-p index))
      :rule-classes :rewrite)

    Theorem: vl-expr-kind-of-vl-make-index

    (defthm vl-expr-kind-of-vl-make-index
      (eq (vl-expr-kind (vl-make-index n))
          :atom))

    Theorem: vl-expr-resolved-p-of-vl-make-index

    (defthm vl-expr-resolved-p-of-vl-make-index
      (vl-expr-resolved-p (vl-make-index n)))

    Theorem: vl-resolved->val-of-vl-make-index

    (defthm vl-resolved->val-of-vl-make-index
      (equal (vl-resolved->val (vl-make-index n))
             (nfix n)))

    Theorem: posp-of-vl-expr->finalwidth-of-vl-make-index

    (defthm posp-of-vl-expr->finalwidth-of-vl-make-index
      (posp (vl-expr->finalwidth (vl-make-index n)))
      :rule-classes :type-prescription)

    Theorem: vl-make-index-of-nfix-n

    (defthm vl-make-index-of-nfix-n
      (equal (vl-make-index (nfix n))
             (vl-make-index n)))

    Theorem: vl-make-index-nat-equiv-congruence-on-n

    (defthm vl-make-index-nat-equiv-congruence-on-n
      (implies (acl2::nat-equiv n n-equiv)
               (equal (vl-make-index n)
                      (vl-make-index n-equiv)))
      :rule-classes :congruence)