• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • 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
          • Occform
            • Vl-mux-occform
            • Vl-basic-binary-op-occform
            • Vl-occform-mkports
            • Vl-unary-reduction-op-occform
            • Vl-make-n-bit-mux
            • Vl-bitselect-occform
            • Vl-assign-occform
            • Vl-plusminus-occform
            • Vl-shift-occform
            • Vl-gte-occform
            • Vl-plain-occform
            • Vl-unary-not-occform
            • Vl-rem-occform
            • Vl-div-occform
              • Vl-ceq-occform
              • Vl-mult-occform
              • Vl-make-n-bit-dynamic-bitselect-m
              • Vl-simple-instantiate
              • Vl-occform-mkwires
              • Vl-assignlist-occform
              • Vl-occform-argfix
              • Vl-make-n-bit-unsigned-gte
              • Vl-make-2^n-bit-dynamic-bitselect
              • Vl-make-n-bit-div-rem
              • Vl-make-n-bit-plusminus
              • Vl-make-n-bit-signed-gte
              • Vl-make-n-bit-shr-by-m-bits
              • Vl-make-n-bit-shl-by-m-bits
              • Vl-occform-mkport
              • Vl-make-n-bit-dynamic-bitselect
              • Vl-make-n-bit-reduction-op
              • Vl-make-n-bit-adder-core
              • Vl-make-n-bit-xdetect
              • Vl-make-n-bit-x-propagator
              • Vl-make-n-bit-shl-place-p
              • Vl-make-n-bit-shr-place-p
              • Vl-make-n-bit-mult
              • Vl-occform-mkwire
              • Vl-make-nedgeflop-vec
              • Vl-make-n-bit-binary-op
              • Vl-make-list-of-netdecls
              • Vl-make-n-bit-delay-1
              • Vl-make-n-bit-zmux
              • *vl-2-bit-dynamic-bitselect*
              • Vl-make-n-bit-unsigned-rem
              • Vl-make-n-bit-unsigned-div
              • Vl-make-n-bit-shr-place-ps
              • Vl-make-n-bit-shl-place-ps
              • Vl-make-n-bit-assign
              • Vl-make-n-bit-x
              • Vl-make-n-bit-ceq
              • Vl-make-n-bit-xor-each
              • Vl-make-n-bit-not
              • Vl-make-1-bit-delay-m
              • Vl-make-n-bit-delay-m
              • *vl-1-bit-signed-gte*
              • *vl-1-bit-div-rem*
              • *vl-1-bit-adder-core*
              • Vl-make-nedgeflop
              • *vl-1-bit-mult*
              • *vl-1-bit-dynamic-bitselect*
            • 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
    • Occform

    Vl-div-occform

    Transform assign lhs = a / b into occurrences.

    Signature
    (vl-div-occform x nf mod ialist warnings) 
      → 
    (mv new-warnings new-modules new-modinsts new-assigns new-nf)
    Arguments
    x — Guard (vl-assign-p x).
    nf — Guard (vl-namefactory-p nf).
    mod — Guard (vl-module-p mod).
    ialist — Guard (equal ialist (vl-make-moditem-alist mod)).
    warnings — Guard (vl-warninglist-p warnings).
    Returns
    new-warnings — Type (vl-warninglist-p new-warnings).
    new-modules — Type (vl-modulelist-p new-modules).
    new-modinsts — Type (vl-modinstlist-p new-modinsts).
    new-assigns — Type (vl-assignlist-p new-assigns).
    new-nf — Type (vl-namefactory-p new-nf).

    Definitions and Theorems

    Function: vl-div-occform

    (defun vl-div-occform (x nf mod ialist warnings)
     (declare
        (xargs :guard (and (vl-assign-p x)
                           (vl-namefactory-p nf)
                           (vl-module-p mod)
                           (vl-warninglist-p warnings)
                           (equal ialist (vl-make-moditem-alist mod)))))
     (declare
         (xargs :guard (and (not (vl-atom-p (vl-assign->expr x)))
                            (member (vl-nonatom->op (vl-assign->expr x))
                                    '(:vl-binary-div))
                            t)))
     (let ((__function__ 'vl-div-occform))
      (declare (ignorable __function__))
      (b* ((x (vl-assign-fix x))
           (warnings (vl-warninglist-fix warnings))
           (nf (vl-namefactory-fix nf)))
        (b*
         (((vl-assign x) x)
          (arg1 (first (vl-nonatom->args x.expr)))
          (arg2 (second (vl-nonatom->args x.expr)))
          (width (vl-expr->finalwidth x.expr))
          (type (vl-expr->finaltype x.expr))
          ((unless (eq type :vl-unsigned))
           (occform-return
                :assigns (list x)
                :warnings
                (fatal :type :vl-warn-signed-div
                       :msg "~a0: signed divide is not implemented yet"
                       :args (list x))))
          ((unless (and (posp width)
                        (equal width (vl-expr->finalwidth x.lvalue))
                        (equal width (vl-expr->finalwidth arg1))
                        (equal width (vl-expr->finalwidth arg2))
                        type (vl-expr->finaltype x.lvalue)
                        (eq type (vl-expr->finaltype arg1))
                        (eq type (vl-expr->finaltype arg2))))
           (occform-return
                :assigns (list x)
                :warnings (fatal :type :vl-programming-error
                                 :msg "~a0: bad widths/types in divide."
                                 :args (list x))))
          ((mv warnings arg1)
           (vl-occform-argfix arg1 mod ialist warnings))
          ((mv warnings arg2)
           (vl-occform-argfix arg2 mod ialist warnings))
          (basename "vl_div")
          ((mv instname nf)
           (vl-namefactory-indexed-name basename nf))
          (mods (vl-make-n-bit-unsigned-div width))
          (modinst
               (vl-simple-instantiate (car mods)
                                      instname (list x.lvalue arg1 arg2)
                                      :loc x.loc)))
         (occform-return :mods mods
                         :modinsts (list modinst))))))

    Theorem: vl-warninglist-p-of-vl-div-occform.new-warnings

    (defthm vl-warninglist-p-of-vl-div-occform.new-warnings
      (b* (((mv ?new-warnings ?new-modules
                ?new-modinsts ?new-assigns ?new-nf)
            (vl-div-occform x nf mod ialist warnings)))
        (vl-warninglist-p new-warnings))
      :rule-classes :rewrite)

    Theorem: vl-modulelist-p-of-vl-div-occform.new-modules

    (defthm vl-modulelist-p-of-vl-div-occform.new-modules
      (b* (((mv ?new-warnings ?new-modules
                ?new-modinsts ?new-assigns ?new-nf)
            (vl-div-occform x nf mod ialist warnings)))
        (vl-modulelist-p new-modules))
      :rule-classes :rewrite)

    Theorem: vl-modinstlist-p-of-vl-div-occform.new-modinsts

    (defthm vl-modinstlist-p-of-vl-div-occform.new-modinsts
      (b* (((mv ?new-warnings ?new-modules
                ?new-modinsts ?new-assigns ?new-nf)
            (vl-div-occform x nf mod ialist warnings)))
        (vl-modinstlist-p new-modinsts))
      :rule-classes :rewrite)

    Theorem: vl-assignlist-p-of-vl-div-occform.new-assigns

    (defthm vl-assignlist-p-of-vl-div-occform.new-assigns
      (b* (((mv ?new-warnings ?new-modules
                ?new-modinsts ?new-assigns ?new-nf)
            (vl-div-occform x nf mod ialist warnings)))
        (vl-assignlist-p new-assigns))
      :rule-classes :rewrite)

    Theorem: vl-namefactory-p-of-vl-div-occform.new-nf

    (defthm vl-namefactory-p-of-vl-div-occform.new-nf
      (b* (((mv ?new-warnings ?new-modules
                ?new-modinsts ?new-assigns ?new-nf)
            (vl-div-occform x nf mod ialist warnings)))
        (vl-namefactory-p new-nf))
      :rule-classes :rewrite)

    Theorem: vl-div-occform-mvtypes-1

    (defthm vl-div-occform-mvtypes-1
      (true-listp (mv-nth 1
                          (vl-div-occform x nf mod ialist warnings)))
      :rule-classes :type-prescription)

    Theorem: vl-div-occform-mvtypes-2

    (defthm vl-div-occform-mvtypes-2
      (true-listp (mv-nth 2
                          (vl-div-occform x nf mod ialist warnings)))
      :rule-classes :type-prescription)

    Theorem: vl-div-occform-mvtypes-3

    (defthm vl-div-occform-mvtypes-3
      (true-listp (mv-nth 3
                          (vl-div-occform x nf mod ialist warnings)))
      :rule-classes :type-prescription)

    Theorem: vl-div-occform-of-vl-assign-fix-x

    (defthm vl-div-occform-of-vl-assign-fix-x
      (equal (vl-div-occform (vl-assign-fix x)
                             nf mod ialist warnings)
             (vl-div-occform x nf mod ialist warnings)))

    Theorem: vl-div-occform-vl-assign-equiv-congruence-on-x

    (defthm vl-div-occform-vl-assign-equiv-congruence-on-x
      (implies (vl-assign-equiv x x-equiv)
               (equal (vl-div-occform x nf mod ialist warnings)
                      (vl-div-occform x-equiv nf mod ialist warnings)))
      :rule-classes :congruence)

    Theorem: vl-div-occform-of-vl-namefactory-fix-nf

    (defthm vl-div-occform-of-vl-namefactory-fix-nf
      (equal (vl-div-occform x (vl-namefactory-fix nf)
                             mod ialist warnings)
             (vl-div-occform x nf mod ialist warnings)))

    Theorem: vl-div-occform-vl-namefactory-equiv-congruence-on-nf

    (defthm vl-div-occform-vl-namefactory-equiv-congruence-on-nf
      (implies (vl-namefactory-equiv nf nf-equiv)
               (equal (vl-div-occform x nf mod ialist warnings)
                      (vl-div-occform x nf-equiv mod ialist warnings)))
      :rule-classes :congruence)

    Theorem: vl-div-occform-of-vl-module-fix-mod

    (defthm vl-div-occform-of-vl-module-fix-mod
      (equal (vl-div-occform x nf (vl-module-fix mod)
                             ialist warnings)
             (vl-div-occform x nf mod ialist warnings)))

    Theorem: vl-div-occform-vl-module-equiv-congruence-on-mod

    (defthm vl-div-occform-vl-module-equiv-congruence-on-mod
      (implies (vl-module-equiv mod mod-equiv)
               (equal (vl-div-occform x nf mod ialist warnings)
                      (vl-div-occform x nf mod-equiv ialist warnings)))
      :rule-classes :congruence)

    Theorem: vl-div-occform-of-vl-warninglist-fix-warnings

    (defthm vl-div-occform-of-vl-warninglist-fix-warnings
      (equal (vl-div-occform x nf mod
                             ialist (vl-warninglist-fix warnings))
             (vl-div-occform x nf mod ialist warnings)))

    Theorem: vl-div-occform-vl-warninglist-equiv-congruence-on-warnings

    (defthm vl-div-occform-vl-warninglist-equiv-congruence-on-warnings
      (implies (vl-warninglist-equiv warnings warnings-equiv)
               (equal (vl-div-occform x nf mod ialist warnings)
                      (vl-div-occform x nf mod ialist warnings-equiv)))
      :rule-classes :congruence)