• 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
          • Expression-sizing
            • Expression-sizing-minutia
            • Expression-sizing-intro
            • Vl-keyvalue-pattern-collect-array-replacements
            • Vl-assignpattern-positional-replacement
            • Vl-plainarg-exprsize
            • Vl-assignpattern-keyvalue-replacement
            • Vl-keyvalue-pattern-collect-struct-replacements
            • Vl-modulelist-exprsize
            • Vl-expr-assignpattern-extend/truncate
            • Vl-structmemberlist->types
            • Vl-expr-size
              • Vl-expr-selfsize
              • Vl-expr-typedecide
              • Vl-expr-expandsizes
              • Vl-exprlist-expandsizes
              • Vl-exprlist-size
            • Vl-expr-selfdetermine-type
            • Vl-assignpattern-multi-replacement
            • Vl-parse-keyval-pattern-struct
            • Vl-plainarglist-exprsize
            • Vl-parse-keyval-pattern-array
            • Vl-warn-about-implicit-extension
            • Vl-assigncontext-size
            • Vl-arguments-exprsize
            • Vl-assignpattern-replacement
            • Vl-packeddimensionlist-exprsize
            • Vl-namedparamvaluelist-exprsize
            • Vl-maybe-delayoreventcontrol-exprsize
            • Vl-repeateventcontrol-exprsize
            • Vl-paramvaluelist-exprsize
            • Vl-maybe-packeddimension-exprsize
            • Vl-delayoreventcontrol-exprsize
            • Vl-namedparamvalue-exprsize
            • Vl-namedarglist-exprsize
            • Vl-enumitemlist-exprsize
            • Vl-packeddimension-exprsize
            • Vl-maybe-paramvalue-exprsize
            • Vl-evatomlist-exprsize
            • Vl-atom-selfdetermine-type
            • Vl-rangelist-exprsize
            • Vl-maybe-gatedelay-exprsize
            • Vl-maybe-datatype-exprsize
            • Vl-gatedelay-exprsize
            • Vl-paramargs-exprsize
            • Vl-namedarg-exprsize
            • Vl-eventcontrol-exprsize
            • Vl-enumbasetype-exprsize
            • Vl-delaycontrol-exprsize
            • Vl-paramvalue-exprsize
            • Vl-maybe-range-exprsize
            • Vl-enumitem-exprsize
            • Vl-range-exprsize
            • Vl-paramdecl-exprsize
            • Vl-paramdecllist-exprsize
            • Vl-maybe-expr-size
            • Vl-evatom-exprsize
            • Vl-vardecllist-exprsize
            • Vl-portdecllist-exprsize
            • Vl-modinstlist-exprsize
            • Vl-initiallist-exprsize
            • Vl-gateinstlist-exprsize
            • Vl-fundecllist-exprsize
            • Vl-assign-exprsize
            • Vl-interfaceport-exprsize
            • Vl-assignlist-exprsize
            • Vl-alwayslist-exprsize
            • Vl-portlist-exprsize
            • Vl-modinst-exprsize
            • Vl-gateinst-exprsize
            • Vl-fundecl-exprsize
            • Vl-vardecl-exprsize
            • Vl-regularport-exprsize
            • Vl-portdecl-exprsize
            • Vl-initial-exprsize
            • Vl-always-exprsize
            • Vl-port-exprsize
            • Vl-lvalue-type
            • Vl-classify-extension-warning-hook
            • Welltyped
            • Vl-castexpr->datatype
            • Vl-expr-size-assigncontext
            • Vl-type-expr-pairs-sum-datatype-sizes
            • Vl-basictype->datatype
            • Vl-expr-replace-assignpatterns
            • Vl-design-exprsize
            • Vl-op-simple-vector-p
            • Vl-expr-val-alist-max-count
            • Vl-expr-has-patterns
            • Vl-exprlist-max-count
            • Vl-unsigned-when-size-zero-lst
            • Vl-type-expr-pairs
            • Append-n
            • Vl-expr-val-alist
            • Vl-datatypelist
          • Occform
          • Oprewrite
          • Expand-functions
          • Delayredux
          • Unparameterization
          • Caseelim
          • Split
          • Selresolve
          • Weirdint-elim
          • Vl-delta
          • Replicate-insts
          • Rangeresolve
          • Propagate
          • Clean-selects
          • Clean-params
          • Blankargs
          • Inline-mods
          • Expr-simp
          • Trunc
          • Always-top
          • Gatesplit
          • Gate-elim
          • Expression-optimization
          • Elim-supplies
          • Wildelim
          • Drop-blankports
          • Clean-warnings
          • Addinstnames
          • Custom-transform-hooks
          • Annotate
          • Latchcode
          • Elim-unused-vars
          • Problem-modules
        • Lint
        • Mlib
        • Server
        • Kit
        • Printer
        • Esim-vl
        • Well-formedness
      • Sv
      • Fgl
      • Vwsim
      • Vl
      • X86isa
      • Svl
      • Rtl
    • Software-verification
    • Math
    • Testing-utilities
  • Expression-sizing

Vl-expr-size

Determine sizes for a top-level or self-determined expression.

Signature
(vl-expr-size lhs-size x ss ctx warnings) 
  → 
(mv successp warnings new-x)
Arguments
lhs-size — To size an expression x which occurs in an assignment such as assign lhs = x, the lhs-size should be the width of lhs. To size other expressions that do not occur in assignments, such as a self-determined subexpression, the lhs-size should be nil.
    Guard (maybe-natp lhs-size).
x — The expression that we want to size.
    Guard (vl-expr-p x).
ss — Guard (vl-scopestack-p ss).
ctx — Context for sizing error messages.
    Guard (vl-context-p ctx).
warnings — Ordinary warnings accumulator.
    Guard (vl-warninglist-p warnings).
Returns
successp — Indicates whether all sizing was successful.
    Type (booleanp successp).
warnings — Possibly extended with fatal or non-fatal warnings.
    Type (vl-warninglist-p warnings).
new-x — Updated version of x where all the sizes/types have been computed and installed.
    Type (vl-expr-p new-x).

This function implements the two-phase algorithm described in expression-sizing. That is, it first determines the maximum size of any operand in x and the desired type of x, using vl-expr-selfsize and vl-expr-typedecide (which are not part of the mutual recursion). It then propagates this size and type into the operands, using vl-expr-expandsizes.

Theorem: return-type-of-vl-expr-size.successp

(defthm return-type-of-vl-expr-size.successp
  (b* (((mv ?successp ?warnings ?new-x)
        (vl-expr-size lhs-size x ss ctx warnings)))
    (booleanp successp))
  :rule-classes :type-prescription)

Theorem: return-type-of-vl-expr-size.warnings

(defthm return-type-of-vl-expr-size.warnings
  (b* (((mv ?successp ?warnings ?new-x)
        (vl-expr-size lhs-size x ss ctx warnings)))
    (vl-warninglist-p warnings))
  :rule-classes :rewrite)

Theorem: return-type-of-vl-expr-size.new-x

(defthm return-type-of-vl-expr-size.new-x
  (b* (((mv ?successp ?warnings ?new-x)
        (vl-expr-size lhs-size x ss ctx warnings)))
    (vl-expr-p new-x))
  :rule-classes :rewrite)

Theorem: return-type-of-vl-exprlist-size.successp

(defthm return-type-of-vl-exprlist-size.successp
  (b* (((mv ?successp ?warnings ?new-x)
        (vl-exprlist-size x ss ctx warnings)))
    (booleanp successp))
  :rule-classes :type-prescription)

Theorem: return-type-of-vl-exprlist-size.warnings

(defthm return-type-of-vl-exprlist-size.warnings
  (b* (((mv ?successp ?warnings ?new-x)
        (vl-exprlist-size x ss ctx warnings)))
    (vl-warninglist-p warnings))
  :rule-classes :rewrite)

Theorem: return-type-of-vl-exprlist-size.new-x

(defthm return-type-of-vl-exprlist-size.new-x
  (b* (((mv ?successp ?warnings ?new-x)
        (vl-exprlist-size x ss ctx warnings)))
    (and (vl-exprlist-p new-x)
         (equal (len new-x) (len x))))
  :rule-classes :rewrite)

Theorem: return-type-of-vl-exprlist-expandsizes.successp

(defthm return-type-of-vl-exprlist-expandsizes.successp
 (b*
  (((mv ?successp ?warnings ?new-x)
    (vl-exprlist-expandsizes x
                             finalwidth finaltype ss ctx warnings)))
  (booleanp successp))
 :rule-classes :type-prescription)

Theorem: return-type-of-vl-exprlist-expandsizes.warnings

(defthm return-type-of-vl-exprlist-expandsizes.warnings
 (b*
  (((mv ?successp ?warnings ?new-x)
    (vl-exprlist-expandsizes x
                             finalwidth finaltype ss ctx warnings)))
  (vl-warninglist-p warnings))
 :rule-classes :rewrite)

Theorem: return-type-of-vl-exprlist-expandsizes.new-x

(defthm return-type-of-vl-exprlist-expandsizes.new-x
 (b*
  (((mv ?successp ?warnings ?new-x)
    (vl-exprlist-expandsizes x
                             finalwidth finaltype ss ctx warnings)))
  (and (vl-exprlist-p new-x)
       (equal (len new-x) (len x))))
 :rule-classes :rewrite)

Theorem: return-type-of-vl-expr-expandsizes.successp

(defthm return-type-of-vl-expr-expandsizes.successp
  (b* (((mv ?successp ?warnings ?new-x)
        (vl-expr-expandsizes x
                             finalwidth finaltype ss ctx warnings)))
    (booleanp successp))
  :rule-classes :type-prescription)

Theorem: return-type-of-vl-expr-expandsizes.warnings

(defthm return-type-of-vl-expr-expandsizes.warnings
  (b* (((mv ?successp ?warnings ?new-x)
        (vl-expr-expandsizes x
                             finalwidth finaltype ss ctx warnings)))
    (vl-warninglist-p warnings))
  :rule-classes :rewrite)

Theorem: return-type-of-vl-expr-expandsizes.new-x

(defthm return-type-of-vl-expr-expandsizes.new-x
  (b* (((mv ?successp ?warnings ?new-x)
        (vl-expr-expandsizes x
                             finalwidth finaltype ss ctx warnings)))
    (vl-expr-p new-x))
  :rule-classes :rewrite)

Subtopics

Vl-expr-selfsize
Computation of self-determined expression sizes.
Vl-expr-typedecide
Computation of expression signedness (main routine).
Vl-expr-expandsizes
Propagate the final width/type into a context-determined expression.
Vl-exprlist-expandsizes
Propagate final width/type into a list of context-determined expressions.
Vl-exprlist-size
Self-determine the sizes of a list of expressions.