• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • 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-weirdint-atom-expandsizes
                • Vl-constint-atom-expandsizes
                • Vl-hidexpr-expandsizes
                  • Vl-expandsizes-zeroextend
                  • Vl-atom-expandsizes
                  • Vl-string-atom-expandsizes
                  • Vl-sign-extend-constint
                • 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
    • Vl-expr-expandsizes

    Vl-hidexpr-expandsizes

    Propagate the final width and type of an expression into an identifier or HID.

    Signature
    (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings) 
      → 
    (mv successp warnings new-x)
    Arguments
    x — Guard (vl-expr-p x).
    finalwidth — Guard (natp finalwidth).
    finaltype — Guard (vl-exprtype-p finaltype).
    ss — Guard (vl-scopestack-p ss).
    ctx — Guard (vl-context-p ctx).
    warnings — Guard (vl-warninglist-p warnings).
    Returns
    successp — Type (booleanp successp).
    warnings — Type (vl-warninglist-p warnings).
    new-x — Type (vl-expr-p new-x).

    Definitions and Theorems

    Function: vl-hidexpr-expandsizes

    (defun vl-hidexpr-expandsizes
           (x finalwidth finaltype ss ctx warnings)
     (declare (xargs :guard (and (vl-expr-p x)
                                 (natp finalwidth)
                                 (vl-exprtype-p finaltype)
                                 (vl-scopestack-p ss)
                                 (vl-context-p ctx)
                                 (vl-warninglist-p warnings))))
     (let ((__function__ 'vl-hidexpr-expandsizes))
      (declare (ignorable __function__))
      (b*
       ((x (vl-expr-fix x))
        (ctx (vl-context-fix ctx))
        (finalwidth (lnfix finalwidth))
        (finaltype (vl-exprtype-fix finaltype))
        ((mv warnings origwidth)
         (vl-expr-selfsize x ss ctx warnings))
        ((mv warnings origtype)
         (vl-expr-typedecide x ss ctx warnings))
        ((unless (and origwidth origtype))
         (mv
          nil
          (fatal
           :type :vl-programming-error
           :msg
           "~a0: expected to only try to expand sizes for atoms ~
                             whose sizes types can be successfully determined, ~
                             but we failed to determine the size or type of ~a1."
           :args (list ctx x))
          x))
        ((when (> origwidth finalwidth))
         (mv
          nil
          (fatal
           :type :vl-programming-error
           :msg
           "~a0: origwidth > finalwidth when expanding ~a1. This ~
                             indicates a serious bug in our sizing code."
           :args (list ctx x))
          x))
        ((unless (or (eq origtype finaltype)
                     (and (eq origtype :vl-signed)
                          (eq finaltype :vl-unsigned))))
         (mv
          nil
          (fatal
           :type :vl-programming-error
           :msg
           "~a0: origtype is ~s1 but finaltype is ~s2 when ~
                             expanding ~a3.  This indicates a serious bug in our ~
                             typing code."
           :args (list ctx origtype finaltype x))
          x))
        (new-x (if (vl-fast-atom-p x)
                   (change-vl-atom x
                                   :finalwidth finalwidth
                                   :finaltype finaltype)
                 (change-vl-nonatom x
                                    :finalwidth finalwidth
                                    :finaltype finaltype))))
       (mv t (ok) new-x))))

    Theorem: booleanp-of-vl-hidexpr-expandsizes.successp

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

    Theorem: vl-warninglist-p-of-vl-hidexpr-expandsizes.warnings

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

    Theorem: vl-expr-p-of-vl-hidexpr-expandsizes.new-x

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

    Theorem: no-change-loserp-of-vl-hidexpr-expandsizes

    (defthm no-change-loserp-of-vl-hidexpr-expandsizes
     (let
      ((ret
         (vl-hidexpr-expandsizes x
                                 finalwidth finaltype ss ctx warnings)))
      (implies (not (mv-nth 0 ret))
               (equal (mv-nth 2 ret)
                      (vl-expr-fix x)))))

    Theorem: vl-expr-welltyped-p-of-vl-hidexpr-expandsizes

    (defthm vl-expr-welltyped-p-of-vl-hidexpr-expandsizes
     (let
      ((ret
         (vl-hidexpr-expandsizes x
                                 finalwidth finaltype ss ctx warnings)))
      (implies (and (mv-nth 0 ret) (vl-idexpr-p x))
               (vl-expr-welltyped-p (mv-nth 2 ret)))))

    Theorem: warning-irrelevance-of-vl-hidexpr-expandsizes

    (defthm warning-irrelevance-of-vl-hidexpr-expandsizes
     (let
      ((ret1
        (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings))
       (ret2
            (vl-hidexpr-expandsizes x finalwidth finaltype ss nil nil)))
      (implies (syntaxp (not (and (equal ctx ''nil)
                                  (equal warnings ''nil))))
               (and (equal (mv-nth 0 ret1) (mv-nth 0 ret2))
                    (equal (mv-nth 2 ret1)
                           (mv-nth 2 ret2))))))

    Theorem: vl-expr->finalwidth-of-vl-hidexpr-expandsizes

    (defthm vl-expr->finalwidth-of-vl-hidexpr-expandsizes
     (let
      ((ret
         (vl-hidexpr-expandsizes x
                                 finalwidth finaltype ss ctx warnings)))
      (implies (mv-nth 0 ret)
               (equal (vl-expr->finalwidth (mv-nth 2 ret))
                      (nfix finalwidth)))))

    Theorem: vl-expr->finaltype-of-vl-hidexpr-expandsizes

    (defthm vl-expr->finaltype-of-vl-hidexpr-expandsizes
     (let
      ((ret
         (vl-hidexpr-expandsizes x
                                 finalwidth finaltype ss ctx warnings)))
      (implies (mv-nth 0 ret)
               (equal (vl-expr->finaltype (mv-nth 2 ret))
                      (vl-exprtype-fix finaltype)))))

    Theorem: vl-hidexpr-expandsizes-of-vl-expr-fix-x

    (defthm vl-hidexpr-expandsizes-of-vl-expr-fix-x
     (equal
         (vl-hidexpr-expandsizes (vl-expr-fix x)
                                 finalwidth finaltype ss ctx warnings)
         (vl-hidexpr-expandsizes x
                                 finalwidth finaltype ss ctx warnings)))

    Theorem: vl-hidexpr-expandsizes-vl-expr-equiv-congruence-on-x

    (defthm vl-hidexpr-expandsizes-vl-expr-equiv-congruence-on-x
     (implies
      (vl-expr-equiv x x-equiv)
      (equal
         (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings)
         (vl-hidexpr-expandsizes x-equiv
                                 finalwidth finaltype ss ctx warnings)))
     :rule-classes :congruence)

    Theorem: vl-hidexpr-expandsizes-of-nfix-finalwidth

    (defthm vl-hidexpr-expandsizes-of-nfix-finalwidth
     (equal
         (vl-hidexpr-expandsizes x (nfix finalwidth)
                                 finaltype ss ctx warnings)
         (vl-hidexpr-expandsizes x
                                 finalwidth finaltype ss ctx warnings)))

    Theorem: vl-hidexpr-expandsizes-nat-equiv-congruence-on-finalwidth

    (defthm vl-hidexpr-expandsizes-nat-equiv-congruence-on-finalwidth
     (implies
      (acl2::nat-equiv finalwidth finalwidth-equiv)
      (equal
         (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings)
         (vl-hidexpr-expandsizes x finalwidth-equiv
                                 finaltype ss ctx warnings)))
     :rule-classes :congruence)

    Theorem: vl-hidexpr-expandsizes-of-vl-exprtype-fix-finaltype

    (defthm vl-hidexpr-expandsizes-of-vl-exprtype-fix-finaltype
     (equal
        (vl-hidexpr-expandsizes x finalwidth (vl-exprtype-fix finaltype)
                                ss ctx warnings)
        (vl-hidexpr-expandsizes x
                                finalwidth finaltype ss ctx warnings)))

    Theorem: vl-hidexpr-expandsizes-vl-exprtype-equiv-congruence-on-finaltype

    (defthm
       vl-hidexpr-expandsizes-vl-exprtype-equiv-congruence-on-finaltype
     (implies
      (vl-exprtype-equiv finaltype finaltype-equiv)
      (equal
         (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings)
         (vl-hidexpr-expandsizes x finalwidth
                                 finaltype-equiv ss ctx warnings)))
     :rule-classes :congruence)

    Theorem: vl-hidexpr-expandsizes-of-vl-scopestack-fix-ss

    (defthm vl-hidexpr-expandsizes-of-vl-scopestack-fix-ss
     (equal
         (vl-hidexpr-expandsizes x finalwidth
                                 finaltype (vl-scopestack-fix ss)
                                 ctx warnings)
         (vl-hidexpr-expandsizes x
                                 finalwidth finaltype ss ctx warnings)))

    Theorem: vl-hidexpr-expandsizes-vl-scopestack-equiv-congruence-on-ss

    (defthm vl-hidexpr-expandsizes-vl-scopestack-equiv-congruence-on-ss
     (implies
      (vl-scopestack-equiv ss ss-equiv)
      (equal
         (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings)
         (vl-hidexpr-expandsizes x finalwidth
                                 finaltype ss-equiv ctx warnings)))
     :rule-classes :congruence)

    Theorem: vl-hidexpr-expandsizes-of-vl-context-fix-ctx

    (defthm vl-hidexpr-expandsizes-of-vl-context-fix-ctx
     (equal
         (vl-hidexpr-expandsizes x finalwidth
                                 finaltype ss (vl-context-fix ctx)
                                 warnings)
         (vl-hidexpr-expandsizes x
                                 finalwidth finaltype ss ctx warnings)))

    Theorem: vl-hidexpr-expandsizes-vl-context-equiv-congruence-on-ctx

    (defthm vl-hidexpr-expandsizes-vl-context-equiv-congruence-on-ctx
     (implies
      (vl-context-equiv ctx ctx-equiv)
      (equal
         (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings)
         (vl-hidexpr-expandsizes x finalwidth
                                 finaltype ss ctx-equiv warnings)))
     :rule-classes :congruence)

    Theorem: vl-hidexpr-expandsizes-of-vl-warninglist-fix-warnings

    (defthm vl-hidexpr-expandsizes-of-vl-warninglist-fix-warnings
     (equal
         (vl-hidexpr-expandsizes x finalwidth finaltype
                                 ss ctx (vl-warninglist-fix warnings))
         (vl-hidexpr-expandsizes x
                                 finalwidth finaltype ss ctx warnings)))

    Theorem: vl-hidexpr-expandsizes-vl-warninglist-equiv-congruence-on-warnings

    (defthm
     vl-hidexpr-expandsizes-vl-warninglist-equiv-congruence-on-warnings
     (implies
      (vl-warninglist-equiv warnings warnings-equiv)
      (equal
         (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings)
         (vl-hidexpr-expandsizes x finalwidth
                                 finaltype ss ctx warnings-equiv)))
     :rule-classes :congruence)