• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Vwsim
      • Fgl
      • Vl
        • Syntax
        • Loader
        • Warnings
        • Getting-started
        • Utilities
        • Printer
        • Kit
        • Mlib
          • Scopestack
          • Hid-tools
          • Filtering-by-name
          • Vl-interface-mocktype
          • Stripping-functions
          • Genblob
          • Expr-tools
            • Vl-expr-typedecide
            • Vl-exprlist-resolved->vals
            • Vl-make-idexpr-list
            • Vl-idexprlist->names
            • Vl-expr-selfsize
            • Vl-expr-update-subexprs
            • Vl-exprlist-to-plainarglist
            • Vl-op-p
            • Vl-call-namedargs-update-subexprs
            • Vl-valuerangelist-update-subexprs
            • Vl-streamexprlist-update-subexprs
            • Vl-maybe-exprlist-update-subexprs
            • Vl-expr-values
            • Vl-evatomlist-update-subexprs
            • Vl-keyvallist-update-subexprs
            • Vl-assignpat-update-subexprs
            • Vl-valuerange-update-subexprs
            • Vl-streamexpr-update-subexprs
            • Vl-scopeexpr-update-subexprs
            • Vl-patternkey-update-subexprs
            • Vl-partselect-update-subexprs
            • Vl-hidexpr-update-subexprs
            • Vl-expr-ops
            • Vl-arrayrange-update-subexprs
            • Vl-slicesize-update-subexprs
            • Vl-plusminus-update-subexprs
            • Vl-expr-add-atts
            • Vl-make-integer
            • Vl-range-update-subexprs
            • Vl-idexpr
            • Vl-make-index
            • Vl-bitlist-from-nat
              • Vl-expr->subexprs
              • Vl-pps-expr
              • Vl-evatomlist->subexprs
              • Vl-call-namedargs->subexprs
              • Vl-valuerangelist->subexprs
              • Vl-streamexprlist->subexprs
              • Vl-maybe-exprlist->subexprs
              • Vl-hidexpr->subexprs
              • Vl-expr-resolved-p
              • Vl-valuerange->subexprs
              • Vl-streamexpr->subexprs
              • Vl-patternkey->subexprs
              • Vl-partselect->subexprs
              • Vl-keyvallist->subexprs
              • Vl-exprlist-has-ops
              • Vl-assignpat->subexprs
              • Vl-arrayrange->subexprs
              • Vl-slicesize->subexprs
              • Vl-scopeexpr->subexprs
              • Vl-plusminus->subexprs
              • Vl-expr-has-ops
              • Vl-resolved->val
              • Vl-range->subexprs
              • Vl-pps-origexpr
              • Vl-idscope
              • Vl-idexpr->name
              • Vl-idexpr-p
              • Vl-idexprlist-p
              • Vl-exprlist-resolved-p
              • Vl-idscope->name
              • Vl-idscope-p
              • Vl-zbitlist-p
              • Vl-zatom-p
              • Vl-op-fix
              • Vl-oplist
              • Vl-expr-varnames
              • Vl-one-bit-constants
            • Hierarchy
            • Extract-vl-types
            • Range-tools
            • Finding-by-name
            • Stmt-tools
            • Modnamespace
            • Flat-warnings
            • Reordering-by-name
            • Datatype-tools
            • Syscalls
            • Allexprs
            • Lvalues
            • Port-tools
          • Transforms
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Testing-utilities
      • Math
    • Expr-tools

    Vl-bitlist-from-nat

    Turn a natural number into a vl-bitlist-p of the given width.

    Signature
    (vl-bitlist-from-nat x width) → bits
    Arguments
    x — Guard (natp x).
    width — Guard (natp width).
    Returns
    bits — Type (vl-bitlist-p bits).

    Definitions and Theorems

    Function: vl-bitlist-from-nat

    (defun vl-bitlist-from-nat (x width)
           (declare (xargs :guard (and (natp x) (natp width))))
           (let ((__function__ 'vl-bitlist-from-nat))
                (declare (ignorable __function__))
                (b* (((when (zp width)) nil)
                     (width (1- width))
                     (bit (if (logbitp width (lnfix x))
                              :vl-1val :vl-0val)))
                    (cons bit (vl-bitlist-from-nat x width)))))

    Theorem: vl-bitlist-p-of-vl-bitlist-from-nat

    (defthm vl-bitlist-p-of-vl-bitlist-from-nat
            (b* ((bits (vl-bitlist-from-nat x width)))
                (vl-bitlist-p bits))
            :rule-classes :rewrite)

    Theorem: len-of-vl-bitlist-from-nat

    (defthm len-of-vl-bitlist-from-nat
            (equal (len (vl-bitlist-from-nat x width))
                   (nfix width)))

    Theorem: vl-bitlist-from-nat-of-nfix-x

    (defthm vl-bitlist-from-nat-of-nfix-x
            (equal (vl-bitlist-from-nat (nfix x) width)
                   (vl-bitlist-from-nat x width)))

    Theorem: vl-bitlist-from-nat-nat-equiv-congruence-on-x

    (defthm vl-bitlist-from-nat-nat-equiv-congruence-on-x
            (implies (acl2::nat-equiv x x-equiv)
                     (equal (vl-bitlist-from-nat x width)
                            (vl-bitlist-from-nat x-equiv width)))
            :rule-classes :congruence)

    Theorem: vl-bitlist-from-nat-of-nfix-width

    (defthm vl-bitlist-from-nat-of-nfix-width
            (equal (vl-bitlist-from-nat x (nfix width))
                   (vl-bitlist-from-nat x width)))

    Theorem: vl-bitlist-from-nat-nat-equiv-congruence-on-width

    (defthm vl-bitlist-from-nat-nat-equiv-congruence-on-width
            (implies (acl2::nat-equiv width width-equiv)
                     (equal (vl-bitlist-from-nat x width)
                            (vl-bitlist-from-nat x width-equiv)))
            :rule-classes :congruence)