• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • 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
            • Vl-slow-find-net/reg-range
            • Vl-ss-find-range
            • Vl-maybe-range-size
            • Vl-range-resolved-p
            • Vl-range-size
              • Vl-maybe-range-resolved-p
              • Vl-simplevar->range
              • Vl-simplereg->range
              • Vl-simplenet->range
              • Vl-make-n-bit-range
              • Vl-simplevar->signedp
              • Vl-simpletype->signedp
              • Vl-simpletype->range
              • Vl-simplereg->signedp
              • Vl-simplenet->signedp
              • Vl-simplenet->nettype
              • Vl-simplereglist-p
              • Vl-simplereg-p
              • Vl-simpletype-p
              • Vl-simplenet-p
              • Vl-simplevar-p
            • Lvalexprs
            • Hierarchy
            • Finding-by-name
            • Expr-tools
            • 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
    • Range-tools

    Vl-range-size

    The size of a range is one more than the difference between its msb and lsb. For example [3:0] has size 4.

    Signature
    (vl-range-size x) → size
    Arguments
    x — Guard (vl-range-p x).
    Returns
    size — Type (posp size).

    Notice that this definition still works in the case of [1:1] and so on.

    Definitions and Theorems

    Function: vl-range-size

    (defun vl-range-size (x)
      (declare (xargs :guard (vl-range-p x)))
      (declare (xargs :guard (vl-range-resolved-p x)))
      (let ((__function__ 'vl-range-size))
        (declare (ignorable __function__))
        (b* (((vl-range x) x)
             (left (vl-resolved->val x.msb))
             (right (vl-resolved->val x.lsb)))
          (+ 1 (abs (- left right))))))

    Theorem: posp-of-vl-range-size

    (defthm posp-of-vl-range-size
      (b* ((size (vl-range-size x)))
        (posp size))
      :rule-classes :type-prescription)

    Theorem: vl-range-size-of-vl-range-fix-x

    (defthm vl-range-size-of-vl-range-fix-x
      (equal (vl-range-size (vl-range-fix x))
             (vl-range-size x)))

    Theorem: vl-range-size-vl-range-equiv-congruence-on-x

    (defthm vl-range-size-vl-range-equiv-congruence-on-x
      (implies (vl-range-equiv x x-equiv)
               (equal (vl-range-size x)
                      (vl-range-size x-equiv)))
      :rule-classes :congruence)