• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
        • Svex-stvs
        • Svex-decomposition-methodology
        • Sv-versus-esim
        • Svex-decomp
        • Svex-compose-dfs
        • Svex-compilation
        • Moddb
        • Svmods
        • Svstmt
        • Sv-tutorial
        • Expressions
        • Symbolic-test-vector
        • Vl-to-svex
          • Vl-to-sv
          • Vl-design->sv-design
            • Vl-simpconfig
            • Vl-hierarchy-sv-translation
            • Vl-expr-svex-translation
              • Sv::vl-expr.lisp
                • Vl-scopecontext-to-addr
                • Vl-binaryop-to-svex
                • Vl-expr-to-svex-maybe-typed
                • Vl-datatype-syscall-to-svex
                • Vl-operandinfo-to-svex-preproc
                • Vl-structmemberlist->types
                • Vl-seltrace-to-svex-select
                • Vl-portdecllist->types
                • Vl-operandinfo-to-svex-select
                • Vl-plusminus-partselect->svex
                • Vl-arrayrange->rel-lsb-and-width
                • Vl-unaryop-to-svex
                • Vl-funcall-args-to-ordered
                • Vl-expr-to-svex-lhs
                • Vl-operandinfo-to-svex
                • Vl-array-assignpat-keyval-resolve
                • Vl-err->vfatal
                • Vl-datatypelist-usertype-resolve
                • Vl-upscope-to-svex-upscope
                • Vl-err->fatal
                • Vl-streaming-concat-trunc/extend
                • Vl-operandinfo-base-svar
                • Vl-index-shift-amount
                • Vttree->constraints
                • Vl-slicesize-resolve
                • Vl-function-map-find-matching-aux
                • Vl-funname-lookup
                • Vl-datatype-size-warn
                • Svex-repeat-aux
                • Vl-$test$plusargs-to-svex
                • Svex-extend
                • Vl-structmemberlist-shift-bits
                • Vl-datatype-slot-width/range
                • Vl-datatype-index-shift-amount
                • Vl-datatype-field-shift-amount
                • 4vec-extend
                  • Vl-function-pair-inputs-with-actuals
                  • Vl-expr-to-svex-untyped
                  • Vl-function-map-check-matching
                  • Vl-datatype-syscall-remove-dims
                  • Svex-concat-list-aux
                  • Vttree-add-constraints
                  • Vttree-add-warnings
                  • Vl-check-struct-assignpat-keys
                  • Vl-check-array-assignpat-keys
                  • Sv::constraintlist-subst-memo
                  • Vl-svex-keyval-index-lookup
                  • Vl-function-map-find-matching
                  • Vl-convert-dollarsign-to-expr
                  • Vttree->constraints-acc
                  • Vl-seltrace-type
                  • Vl-seltrace-to-path
                  • Vl-keyval-member-lookup
                  • Svex-repeat
                  • Vttree->warnings-acc
                  • Vl-trunc/extend-type-err
                  • Constraintlist-add-ctx
                  • Vl-hidtrace-add-to-path
                  • Svex-multiconcat
                  • Vttree-join
                  • Vl-value-to-string-aux
                  • Vl-seltrace-add-to-path
                  • Vl-value-to-4vec
                  • Vl-expr-to-svex-selfdet
                  • Vl-svex-keyval-default-lookup
                  • Vl-$test$plusargs-p
                  • Vl-value-to-svex
                  • Vl-value-in-range
                  • Vl-keyval-default-lookup
                  • Sv::svexlist-args-extract-constants
                  • Vl-string->bits
                  • Vl-size-to-unsigned-logic
                  • Vl-hidtrace-to-path
                  • Svex-concat-list
                  • Vttree->warnings
                  • Vl-seltrace-unres-count
                  • Vl-datatype-index-is-bitselect
                  • Vl-bitlist->4vec
                  • Vl-svex-keyvallist-vars
                  • Vl-hidstep->svex-index
                  • Vl-selstep->svex-name
                  • Vl-datatypelist-resolved-p
                  • Vl-datatype-$unpacked_dimensions
                  • Vl-datatype-$dimensions
                  • Vl-bitlist->offset
                  • Vl-bitlist->onset
                  • Vl-streamexprlist-has-with
                  • Vl-hidstep-resolved-p
                  • Vl-expr-needs-type-context
                  • Vl-streamexprlist->exprs
                  • Vl-integer-to-string
                  • Vl-hidtrace-resolved-p
                  • Vl-selstep-resolved-p
                  • Vl-select-resolved-p
                  • Vl-svex-keyvallist
                  • Vl-datatypelist
                  • Svex-x
                • Vttree
              • Vl-design->svex-modalist
              • Vl-svstmt
            • Vl-to-sv-main
            • Vl-simplify-sv
            • Vl-user-paramsettings->unparam-names
            • Vl-user-paramsettings->modnames
        • Fgl
        • Vwsim
        • Vl
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Math
      • Testing-utilities
    • Sv::vl-expr.lisp

    4vec-extend

    Returns an 4vec representing the sign- or zero-extension of x at the given width.

    Signature
    (4vec-extend type width x) → sv
    Arguments
    type — Guard (vl-exprsign-p type).
    width — Guard (natp width).
    x — Guard (sv::4vec-p x).
    Returns
    sv — Type (sv::4vec-p sv).

    We don't have to extend/truncate operands when translating VL expressions like a & b, but we do need to do it to the inputs of expressions like a < b, to chop off any garbage in the upper bits.

    Definitions and Theorems

    Function: 4vec-extend

    (defun 4vec-extend (type width x)
      (declare (xargs :guard (and (vl-exprsign-p type)
                                  (natp width)
                                  (sv::4vec-p x))))
      (let ((__function__ '4vec-extend))
        (declare (ignorable __function__))
        (if (vl-exprsign-equiv type :vl-signed)
            (sv::4vec-sign-ext (sv::2vec (lnfix width))
                               x)
          (sv::4vec-zero-ext (sv::2vec (lnfix width))
                             x))))

    Theorem: 4vec-p-of-4vec-extend

    (defthm 4vec-p-of-4vec-extend
      (b* ((sv (4vec-extend type width x)))
        (sv::4vec-p sv))
      :rule-classes :rewrite)

    Theorem: 4vec-extend-of-vl-exprsign-fix-type

    (defthm 4vec-extend-of-vl-exprsign-fix-type
      (equal (4vec-extend (vl-exprsign-fix type)
                          width x)
             (4vec-extend type width x)))

    Theorem: 4vec-extend-vl-exprsign-equiv-congruence-on-type

    (defthm 4vec-extend-vl-exprsign-equiv-congruence-on-type
      (implies (vl-exprsign-equiv type type-equiv)
               (equal (4vec-extend type width x)
                      (4vec-extend type-equiv width x)))
      :rule-classes :congruence)

    Theorem: 4vec-extend-of-nfix-width

    (defthm 4vec-extend-of-nfix-width
      (equal (4vec-extend type (nfix width) x)
             (4vec-extend type width x)))

    Theorem: 4vec-extend-nat-equiv-congruence-on-width

    (defthm 4vec-extend-nat-equiv-congruence-on-width
      (implies (acl2::nat-equiv width width-equiv)
               (equal (4vec-extend type width x)
                      (4vec-extend type width-equiv x)))
      :rule-classes :congruence)

    Theorem: 4vec-extend-of-4vec-fix-x

    (defthm 4vec-extend-of-4vec-fix-x
      (equal (4vec-extend type width (sv::4vec-fix x))
             (4vec-extend type width x)))

    Theorem: 4vec-extend-4vec-equiv-congruence-on-x

    (defthm 4vec-extend-4vec-equiv-congruence-on-x
      (implies (sv::4vec-equiv x x-equiv)
               (equal (4vec-extend type width x)
                      (4vec-extend type width x-equiv)))
      :rule-classes :congruence)