• 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
          • Hierarchy
          • Extract-vl-types
          • Range-tools
            • Vl-range-resolved-p
            • Vl-maybe-range-size
            • Vl-maybe-range-resolved-p
            • Vl-selwidth
            • Vl-range-size
              • Vl-maybe-range-msbidx
              • Vl-maybe-range-lsbidx
              • Vl-maybe-range-lowidx
              • Vl-range-msbidx
              • Vl-range-lsbidx
              • Vl-range-low-idx
              • Vl-maybe-range-revp
              • Vl-range-revp
            • 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
    • 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)