• 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
          • 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
            • Vl-plainarglist-simp
            • Vl-modinstlist-simp
            • Vl-modulelist-simp
            • Vl-assignlist-simp
            • Vl-expr-simp-unary-bitnot
              • Vl-expr-simp-binary-bitor
              • Vl-expr-simp-binary-bitand
              • Vl-expr-simp-qmark
              • Vl-modinst-simp
              • Vl-plainarg-simp
              • Vl-module-simp
              • Vl-design-simp
              • Vl-assign-simp
              • Vl-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
    • Expr-simp

    Vl-expr-simp-unary-bitnot

    Signature
    (vl-expr-simp-unary-bitnot x args) → new-x
    Arguments
    x — Expression to rewrite, of the form ~FOO.
        Guard (vl-expr-p x).
    args — Its already-rewritten args.
        Guard (vl-exprlist-p args).
    Returns
    new-x — Type (vl-expr-p new-x).

    Definitions and Theorems

    Function: vl-expr-simp-unary-bitnot

    (defun vl-expr-simp-unary-bitnot (x args)
     (declare (xargs :guard (and (vl-expr-p x)
                                 (vl-exprlist-p args))))
     (declare (xargs :guard (and (not (vl-atom-p x))
                                 (equal (vl-nonatom->op x)
                                        :vl-unary-bitnot)
                                 (equal (len args) 1))))
     (let ((__function__ 'vl-expr-simp-unary-bitnot))
       (declare (ignorable __function__))
       (b*
         ((arg (first args))
          ((when (and (not (vl-atom-p arg))
                      (eq (vl-nonatom->op arg)
                          :vl-unary-bitnot)))
           (first (vl-nonatom->args arg)))
          ((when (and (vl-atom-p arg)
                      (vl-expr-resolved-p arg)
                      (or (eql (vl-resolved->val arg) 1)
                          (eql (vl-resolved->val arg) 0))
                      (equal (vl-expr->finalwidth x) 1)
                      (equal (vl-expr->finaltype x)
                             :vl-unsigned)))
           (b* ((curr (vl-resolved->val arg))
                (ans (if (eql curr 0)
                         |*sized-1'b1*|
                       |*sized-1'b0*|)))
             (vl-cw-ps-seq (vl-cw "NC Rewrite ~a0 to ~a1~%" x ans))
             ans))
          ((when (and (not (vl-atom-p arg))
                      (eq (vl-nonatom->op arg) :vl-qmark)))
           (b* (((list a b c) (vl-nonatom->args arg))
                (~b (make-vl-nonatom :op :vl-unary-bitnot
                                     :args (list b)
                                     :finalwidth (vl-expr->finalwidth b)
                                     :finaltype (vl-expr->finaltype b)))
                (~c (make-vl-nonatom :op :vl-unary-bitnot
                                     :args (list c)
                                     :finalwidth (vl-expr->finalwidth c)
                                     :finaltype (vl-expr->finaltype c)))
                (ans (change-vl-nonatom arg
                                        :args (list a ~b ~c))))
             (vl-cw-ps-seq (vl-cw "QM Rewrite ~a0 to ~a1!~%" x ans))
             ans))
          ((when (and (not (vl-atom-p arg))
                      (eq (vl-nonatom->op arg)
                          :vl-binary-bitand)))
           (b* (((list a b) (vl-nonatom->args arg))
                (~a (make-vl-nonatom :op :vl-unary-bitnot
                                     :args (list a)
                                     :finalwidth (vl-expr->finalwidth a)
                                     :finaltype (vl-expr->finaltype a)))
                (~b (make-vl-nonatom :op :vl-unary-bitnot
                                     :args (list b)
                                     :finalwidth (vl-expr->finalwidth b)
                                     :finaltype (vl-expr->finaltype b)))
                (ans (change-vl-nonatom arg
                                        :op :vl-binary-bitor
                                        :args (list ~a ~b))))
             (vl-cw-ps-seq (vl-cw "DMA Rewrite ~a0 to ~a1~%" x ans))
             ans))
          ((when (and (not (vl-atom-p arg))
                      (eq (vl-nonatom->op arg)
                          :vl-binary-bitor)))
           (b* (((list a b) (vl-nonatom->args arg))
                (~a (make-vl-nonatom :op :vl-unary-bitnot
                                     :args (list a)
                                     :finalwidth (vl-expr->finalwidth a)
                                     :finaltype (vl-expr->finaltype a)))
                (~b (make-vl-nonatom :op :vl-unary-bitnot
                                     :args (list b)
                                     :finalwidth (vl-expr->finalwidth b)
                                     :finaltype (vl-expr->finaltype b)))
                (ans (change-vl-nonatom arg
                                        :op :vl-binary-bitand
                                        :args (list ~a ~b))))
             (vl-cw-ps-seq (vl-cw "DMO Rewrite ~a0 to ~a1~%" x ans))
             ans)))
         (change-vl-nonatom x :args args))))

    Theorem: vl-expr-p-of-vl-expr-simp-unary-bitnot

    (defthm vl-expr-p-of-vl-expr-simp-unary-bitnot
      (b* ((new-x (vl-expr-simp-unary-bitnot x args)))
        (vl-expr-p new-x))
      :rule-classes :rewrite)

    Theorem: vl-expr-simp-unary-bitnot-of-vl-expr-fix-x

    (defthm vl-expr-simp-unary-bitnot-of-vl-expr-fix-x
      (equal (vl-expr-simp-unary-bitnot (vl-expr-fix x)
                                        args)
             (vl-expr-simp-unary-bitnot x args)))

    Theorem: vl-expr-simp-unary-bitnot-vl-expr-equiv-congruence-on-x

    (defthm vl-expr-simp-unary-bitnot-vl-expr-equiv-congruence-on-x
      (implies (vl-expr-equiv x x-equiv)
               (equal (vl-expr-simp-unary-bitnot x args)
                      (vl-expr-simp-unary-bitnot x-equiv args)))
      :rule-classes :congruence)

    Theorem: vl-expr-simp-unary-bitnot-of-vl-exprlist-fix-args

    (defthm vl-expr-simp-unary-bitnot-of-vl-exprlist-fix-args
      (equal (vl-expr-simp-unary-bitnot x (vl-exprlist-fix args))
             (vl-expr-simp-unary-bitnot x args)))

    Theorem: vl-expr-simp-unary-bitnot-vl-exprlist-equiv-congruence-on-args

    (defthm
         vl-expr-simp-unary-bitnot-vl-exprlist-equiv-congruence-on-args
      (implies (vl-exprlist-equiv args args-equiv)
               (equal (vl-expr-simp-unary-bitnot x args)
                      (vl-expr-simp-unary-bitnot x args-equiv)))
      :rule-classes :congruence)