• 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
          • Trunc
          • Always-top
          • Gatesplit
            • Vl-gatesplit-nand/nor/xnor
            • Vl-modulelist-gatesplit
            • Vl-gatesplit-and/or/xor
              • Vl-make-gates-for-and/or/xor
            • Vl-degenerate-gate-to-buf
            • Vl-gatesplit-buf/not
            • Vl-make-temporary-wires
            • Vl-gateinst-gatesplit
            • Vl-gateinstlist-gatesplit
            • Vl-module-gatesplit
            • Vl-design-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
  • Gatesplit

Vl-gatesplit-and/or/xor

Split up a multi-input and, or, xor, or xnor gate, if necessary.

Signature
(vl-gatesplit-and/or/xor x nf warnings) 
  → 
(mv warnings new-decls new-gateinsts nf)
Arguments
x — Gate to split (if necessary).
    Guard (vl-gateinst-p x).
nf — For generating fresh names.
    Guard (vl-namefactory-p nf).
warnings — Ordinary warnings accumulator.
    Guard (vl-warninglist-p warnings).
Returns
warnings — Type (vl-warninglist-p warnings).
new-decls — New declarations for temporary wires.
    Type (vl-vardecllist-p new-decls), given the guard.
new-gateinsts — Replacement gate instances.
    Type (vl-gateinstlist-p new-gateinsts), given the guard.
nf — Type (vl-namefactory-p nf), given the guard.

From Section 7.2, and, or, xor, and xnor gates have one output and many inputs. The behavior for more than 2 inputs is described as the "natural extension". We have checked with Verilog-XL that, at least for n = 4, they behave as follows:

gate(out, i1, i2, ..., iN);
  -->
gate(temp1, i1,      i2);
gate(temp2, temp1,   i3);
 ...
gate(out,   tempN-2, iN);

Definitions and Theorems

Function: vl-gatesplit-and/or/xor

(defun vl-gatesplit-and/or/xor (x nf warnings)
 (declare (xargs :guard (and (vl-gateinst-p x)
                             (vl-namefactory-p nf)
                             (vl-warninglist-p warnings))))
 (declare (xargs :guard (member (vl-gateinst->type x)
                                '(:vl-and :vl-or :vl-xor))))
 (let ((__function__ 'vl-gatesplit-and/or/xor))
  (declare (ignorable __function__))
  (b*
   ((type (vl-gateinst->type x))
    (args (list-fix (vl-gateinst->args x)))
    (nargs (length args))
    (range (vl-gateinst->range x))
    (loc (vl-gateinst->loc x))
    (origname (or (vl-gateinst->name x) "unnamed"))
    ((when range)
     (mv
      (fatal
       :type :vl-bad-gate
       :msg
       "~a0: expected no instance arrays; did you forget to ~
                         run the replicate-insts transform?"
       :args (list x))
      nil (list x)
      nf))
    ((when (< nargs 2))
     (mv
      (fatal
           :type :vl-bad-gate
           :msg "~a0: expected at least 2 arguments, but found ~x1."
           :args (list x nargs))
      nil (list x)
      nf))
    ((when (eql nargs 2))
     (b* (((mv warnings new-x)
           (vl-degenerate-gate-to-buf x warnings)))
       (mv warnings nil (list new-x) nf)))
    ((when (eql nargs 3))
     (mv (ok) nil (list x) nf))
    ((mv temp-exprs temp-decls nf)
     (vl-make-temporary-wires origname (- nargs 3)
                              nf loc))
    (atts (cons (cons "VL_GATESPLIT"
                      (make-vl-atom :guts (vl-string origname)))
                (vl-gateinst->atts x)))
    (temp-args-out (vl-exprlist-to-plainarglist temp-exprs
                                                :dir :vl-output))
    (temp-args-in (vl-exprlist-to-plainarglist temp-exprs
                                               :dir :vl-input))
    (o (car args))
    (i1 (cadr args))
    (i2-n (cddr args))
    (outs (append temp-args-out (list o)))
    (lhses (cons i1 temp-args-in))
    (rhses i2-n)
    ((mv warnings gateinsts nf)
     (vl-make-gates-for-and/or/xor
          outs lhses rhses
          type origname loc atts nf warnings)))
   (mv warnings temp-decls gateinsts nf))))

Theorem: vl-warninglist-p-of-vl-gatesplit-and/or/xor.warnings

(defthm vl-warninglist-p-of-vl-gatesplit-and/or/xor.warnings
  (b* (((mv ?warnings ?new-decls ?new-gateinsts ?nf)
        (vl-gatesplit-and/or/xor x nf warnings)))
    (vl-warninglist-p warnings))
  :rule-classes :rewrite)

Theorem: vl-vardecllist-p-of-vl-gatesplit-and/or/xor.new-decls

(defthm vl-vardecllist-p-of-vl-gatesplit-and/or/xor.new-decls
 (implies
  (and
   (force (vl-gateinst-p x))
   (force (vl-namefactory-p nf))
   (force (vl-warninglist-p warnings))
   (force
    ((lambda (acl2::x acl2::l)
       (return-last
            'acl2::mbe1-raw
            (acl2::member-eql-exec acl2::x acl2::l)
            (return-last
                 'progn
                 (acl2::member-eql-exec$guard-check acl2::x acl2::l)
                 (member-equal acl2::x acl2::l))))
     (vl-gateinst->type$inline x)
     '(:vl-and :vl-or :vl-xor))))
  (b* (((mv ?warnings ?new-decls ?new-gateinsts ?nf)
        (vl-gatesplit-and/or/xor x nf warnings)))
    (vl-vardecllist-p new-decls)))
 :rule-classes :rewrite)

Theorem: vl-gateinstlist-p-of-vl-gatesplit-and/or/xor.new-gateinsts

(defthm vl-gateinstlist-p-of-vl-gatesplit-and/or/xor.new-gateinsts
 (implies
  (and
   (force (vl-gateinst-p x))
   (force (vl-namefactory-p nf))
   (force (vl-warninglist-p warnings))
   (force
    ((lambda (acl2::x acl2::l)
       (return-last
            'acl2::mbe1-raw
            (acl2::member-eql-exec acl2::x acl2::l)
            (return-last
                 'progn
                 (acl2::member-eql-exec$guard-check acl2::x acl2::l)
                 (member-equal acl2::x acl2::l))))
     (vl-gateinst->type$inline x)
     '(:vl-and :vl-or :vl-xor))))
  (b* (((mv ?warnings ?new-decls ?new-gateinsts ?nf)
        (vl-gatesplit-and/or/xor x nf warnings)))
    (vl-gateinstlist-p new-gateinsts)))
 :rule-classes :rewrite)

Theorem: vl-namefactory-p-of-vl-gatesplit-and/or/xor.nf

(defthm vl-namefactory-p-of-vl-gatesplit-and/or/xor.nf
 (implies
  (and
   (force (vl-gateinst-p x))
   (force (vl-namefactory-p nf))
   (force (vl-warninglist-p warnings))
   (force
    ((lambda (acl2::x acl2::l)
       (return-last
            'acl2::mbe1-raw
            (acl2::member-eql-exec acl2::x acl2::l)
            (return-last
                 'progn
                 (acl2::member-eql-exec$guard-check acl2::x acl2::l)
                 (member-equal acl2::x acl2::l))))
     (vl-gateinst->type$inline x)
     '(:vl-and :vl-or :vl-xor))))
  (b* (((mv ?warnings ?new-decls ?new-gateinsts ?nf)
        (vl-gatesplit-and/or/xor x nf warnings)))
    (vl-namefactory-p nf)))
 :rule-classes :rewrite)

Theorem: vl-gatesplit-and/or/xor-mvtypes-1

(defthm vl-gatesplit-and/or/xor-mvtypes-1
  (true-listp (mv-nth 1
                      (vl-gatesplit-and/or/xor x nf warnings)))
  :rule-classes :type-prescription)

Theorem: vl-gatesplit-and/or/xor-mvtypes-2

(defthm vl-gatesplit-and/or/xor-mvtypes-2
  (true-listp (mv-nth 2
                      (vl-gatesplit-and/or/xor x nf warnings)))
  :rule-classes :type-prescription)

Subtopics

Vl-make-gates-for-and/or/xor
Produce a list of two-input and, or, or xor gates to replace a multi-input gate.