• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Fgl
      • Vwsim
      • Vl
        • Syntax
        • Loader
        • Warnings
        • Getting-started
        • Utilities
        • Printer
        • Kit
        • Mlib
          • Scopestack
          • Hid-tools
            • Vl-follow-hidexpr
            • Vl-index-expr-typetrace
            • Vl-follow-scopeexpr
            • Vl-follow-hidexpr-dimscheck
            • Vl-datatype-resolve-selects
            • Vl-datatype-remove-dim
            • Vl-operandinfo
            • Vl-follow-hidexpr-dimcheck
            • Vl-follow-data-selects
            • Vl-follow-hidexpr-error
            • Vl-hidstep
            • Vl-scopestack-find-item/ss/path
            • Vl-follow-array-indices
            • Vl-scopecontext
            • Vl-datatype-set-unsigned
            • Vl-selstep
            • Vl-scopestack-find-elabpath
            • Vl-hid-prefix-for-subhid
            • Vl-find-structmember
            • Vl-select
            • Vl-scopeexpr-replace-hid
            • Vl-genblocklist-find-block
            • Vl-partselect-width
              • Vl-seltrace->indices
              • Vl-datatype->structmembers
              • Vl-hidexpr-resolved-p
              • Vl-operandinfo->indices
              • Vl-flatten-hidindex
              • Vl-subhid-p
              • Vl-seltrace-usertypes-ok
              • Vl-flatten-hidexpr
              • Vl-scopeexpr->hid
              • Vl-seltrace-index-count
              • Vl-operandinfo-usertypes-ok
              • Vl-operandinfo-index-count
              • Vl-datatype-dims-count
              • Vl-scopeexpr-index-count
              • Vl-hidexpr-index-count
              • Vl-usertype-lookup
              • Vl-hidindex-resolved-p
              • Vl-scopeexpr-resolved-p
              • Vl-selstep-usertypes-ok
              • Vl-hidtrace
              • Vl-seltrace
              • Vl-scopedef-interface-p
            • Filtering-by-name
            • Vl-interface-mocktype
            • Stripping-functions
            • Genblob
            • Expr-tools
            • Extract-vl-types
            • Hierarchy
            • 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
      • Math
      • Testing-utilities
    • Hid-tools

    Vl-partselect-width

    Signature
    (vl-partselect-width x) → (mv err width)
    Arguments
    x — Guard (vl-partselect-p x).
    Returns
    err — Type (iff (vl-msg-p err) err).
    width — Type (implies (not err) (posp width)).

    Definitions and Theorems

    Function: vl-partselect-width

    (defun vl-partselect-width (x)
     (declare (xargs :guard (vl-partselect-p x)))
     (declare (xargs :guard (not (vl-partselect-case x :none))))
     (let ((__function__ 'vl-partselect-width))
      (declare (ignorable __function__))
      (b* ((x (vl-partselect-fix x)))
       (vl-partselect-case
        x :range
        (b* (((unless (and (vl-expr-resolved-p x.msb)
                           (vl-expr-resolved-p x.lsb)))
              (mv (vmsg "Unresolved partselect: ~a0" x)
                  nil))
             (msb (vl-resolved->val x.msb))
             (lsb (vl-resolved->val x.lsb)))
          (mv nil (+ 1 (abs (- msb lsb)))))
        :plusminus
        (b* (((unless (vl-expr-resolved-p x.width))
              (mv (vmsg "Unresolved partselect width: ~a0" x)
                  nil))
             (width (vl-resolved->val x.width))
             ((when (<= width 0))
              (mv (vmsg "Non-positive-width partselect not allowed: ~a0"
                        x)
                  nil)))
          (mv nil width))
        :otherwise (mv (vmsg "Impossible")
                       (impossible))))))

    Theorem: return-type-of-vl-partselect-width.err

    (defthm return-type-of-vl-partselect-width.err
      (b* (((mv ?err ?width)
            (vl-partselect-width x)))
        (iff (vl-msg-p err) err))
      :rule-classes :rewrite)

    Theorem: return-type-of-vl-partselect-width.width

    (defthm return-type-of-vl-partselect-width.width
      (b* (((mv ?err ?width)
            (vl-partselect-width x)))
        (implies (not err) (posp width)))
      :rule-classes :type-prescription)

    Theorem: vl-partselect-width-of-vl-partselect-fix-x

    (defthm vl-partselect-width-of-vl-partselect-fix-x
      (equal (vl-partselect-width (vl-partselect-fix x))
             (vl-partselect-width x)))

    Theorem: vl-partselect-width-vl-partselect-equiv-congruence-on-x

    (defthm vl-partselect-width-vl-partselect-equiv-congruence-on-x
      (implies (vl-partselect-equiv x x-equiv)
               (equal (vl-partselect-width x)
                      (vl-partselect-width x-equiv)))
      :rule-classes :congruence)