• 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
          • 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
            • Vl-modulelist-trunc
            • Vl-make-chopped-id
            • Vl-assign-trunc
            • Vl-truncate-weirdint
              • Vl-truncate-constint
              • Vl-assignlist-trunc
              • Vl-module-trunc
              • Vl-design-trunc
              • Vl-assignlist-can-skip-trunc-p
              • Vl-assign-can-skip-trunc-p
            • 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
    • Trunc

    Vl-truncate-weirdint

    Special routine for truncating unsigned weirdint literals without introducing temporary wires.

    Signature
    (vl-truncate-weirdint n x) → chopped-expr
    Arguments
    n — width to truncate down to.
        Guard (posp n).
    x — unsigned vl-weirdint-p to truncate.
        Guard (vl-expr-p x).
    Returns
    chopped-expr — Type (vl-expr-p chopped-expr).

    We can truncate a weirdint by just creating a new weirdint that has its width reduced and that drops the chopped off bits.

    Definitions and Theorems

    Function: vl-truncate-weirdint

    (defun vl-truncate-weirdint (n x)
      (declare (xargs :guard (and (posp n) (vl-expr-p x))))
      (declare (xargs :guard (and (vl-atom-p x)
                                  (vl-expr-welltyped-p x)
                                  (vl-weirdint-p (vl-atom->guts x))
                                  (equal (vl-expr->finaltype x)
                                         :vl-unsigned)
                                  (< n (vl-expr->finalwidth x)))))
      (let ((__function__ 'vl-truncate-weirdint))
        (declare (ignorable __function__))
        (b* ((n (lposfix n))
             (guts (vl-atom->guts x))
             ((vl-weirdint guts) guts)
             (bits-chop (nthcdr (- guts.origwidth n)
                                (list-fix guts.bits)))
             (new-guts (make-vl-weirdint :bits bits-chop
                                         :origwidth n
                                         :origtype :vl-unsigned))
             (new-atom (make-vl-atom :guts new-guts
                                     :finalwidth n
                                     :finaltype :vl-unsigned)))
          new-atom)))

    Theorem: vl-expr-p-of-vl-truncate-weirdint

    (defthm vl-expr-p-of-vl-truncate-weirdint
      (b* ((chopped-expr (vl-truncate-weirdint n x)))
        (vl-expr-p chopped-expr))
      :rule-classes :rewrite)

    Theorem: vl-truncate-weirdint-basics

    (defthm vl-truncate-weirdint-basics
      (implies
           (and (force (posp n))
                (force (vl-atom-p x))
                (force (vl-expr-welltyped-p x))
                (force (vl-weirdint-p (vl-atom->guts x)))
                (force (< n (vl-expr->finalwidth x)))
                (force (equal (vl-expr->finaltype x)
                              :vl-unsigned)))
           (and (equal (vl-expr->finalwidth (vl-truncate-weirdint n x))
                       n)
                (equal (vl-expr->finaltype (vl-truncate-weirdint n x))
                       :vl-unsigned)
                (vl-expr-welltyped-p (vl-truncate-weirdint n x)))))

    Theorem: vl-truncate-weirdint-of-pos-fix-n

    (defthm vl-truncate-weirdint-of-pos-fix-n
      (equal (vl-truncate-weirdint (pos-fix n) x)
             (vl-truncate-weirdint n x)))

    Theorem: vl-truncate-weirdint-pos-equiv-congruence-on-n

    (defthm vl-truncate-weirdint-pos-equiv-congruence-on-n
      (implies (acl2::pos-equiv n n-equiv)
               (equal (vl-truncate-weirdint n x)
                      (vl-truncate-weirdint n-equiv x)))
      :rule-classes :congruence)

    Theorem: vl-truncate-weirdint-of-vl-expr-fix-x

    (defthm vl-truncate-weirdint-of-vl-expr-fix-x
      (equal (vl-truncate-weirdint n (vl-expr-fix x))
             (vl-truncate-weirdint n x)))

    Theorem: vl-truncate-weirdint-vl-expr-equiv-congruence-on-x

    (defthm vl-truncate-weirdint-vl-expr-equiv-congruence-on-x
      (implies (vl-expr-equiv x x-equiv)
               (equal (vl-truncate-weirdint n x)
                      (vl-truncate-weirdint n x-equiv)))
      :rule-classes :congruence)