• 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
            • 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-make-n-bit-xdetect

    Generate a module that detects X/Z bits.

    Signature
    (vl-make-n-bit-xdetect n) → mods
    Arguments
    n — Guard (posp n).
    Returns
    mods — A non-empty module list. The first module in the list is the desired module; the other modules are any necessary supporting modules.
        Type (vl-modulelist-p mods).

    We generate a gate-based module with the following signature:

    module VL_N_BIT_XDETECT (out, in) ;
      output out;
      input [n-1:0] in;
    
      ...
    endmodule

    We set out to X whenever any bit of in is X or Z. Otherwise, we set out to 0.

    This module is useful because many of Verilog's arithmetic expressions (compares, additions, subtractions, etc.) require that if any input bit is X or Z, then the entire output should be X. The basic idea is to use VL_N_BIT_XDETECT to see if any input bit is X or Z, then XOR the output bit with every bit of the answer from a compare, addition, subtraction, etc. If the X-DET bit is zero, then XOR'ing it with the answer just yields the original answer. But if it is X, then the resulting bits are all X.

    Definitions and Theorems

    Function: vl-make-n-bit-xdetect

    (defun vl-make-n-bit-xdetect (n)
     (declare (xargs :guard (posp n)))
     (declare (xargs :guard t))
     (let ((__function__ 'vl-make-n-bit-xdetect))
      (declare (ignorable __function__))
      (b*
       ((n (lposfix n))
        (name (hons-copy (cat "VL_" (natstr n) "_BIT_X_DETECT")))
        ((mv out-expr
             out-port out-portdecl out-vardecl)
         (vl-occform-mkport "out" :vl-output 1))
        ((mv in-expr in-port in-portdecl in-vardecl)
         (vl-occform-mkport "in" :vl-input n))
        ((when (eql n 1))
         (let
           ((out-inst (vl-simple-inst *vl-1-bit-xor*
                                      "ans" out-expr in-expr in-expr)))
          (list
              (make-vl-module :name name
                              :origname name
                              :ports (list out-port in-port)
                              :portdecls (list out-portdecl in-portdecl)
                              :vardecls (list out-vardecl in-vardecl)
                              :modinsts (list out-inst)
                              :minloc *vl-fakeloc*
                              :maxloc *vl-fakeloc*)
              *vl-1-bit-xor*)))
        ((mv temp-expr temp-vardecl)
         (vl-occform-mkwire "temp" 1))
        ((cons temp-mod temp-support)
         (vl-make-n-bit-reduction-op :vl-unary-xor n))
        (temp-inst
             (vl-simple-inst temp-mod "mk_temp" temp-expr in-expr))
        (out-inst
             (vl-simple-inst *vl-1-bit-xor*
                             "mk_out" out-expr temp-expr temp-expr)))
       (list* (make-vl-module
                   :name name
                   :origname name
                   :ports (list out-port in-port)
                   :portdecls (list out-portdecl in-portdecl)
                   :vardecls (list out-vardecl in-vardecl temp-vardecl)
                   :modinsts (list temp-inst out-inst)
                   :minloc *vl-fakeloc*
                   :maxloc *vl-fakeloc*)
              temp-mod temp-support))))

    Theorem: vl-modulelist-p-of-vl-make-n-bit-xdetect

    (defthm vl-modulelist-p-of-vl-make-n-bit-xdetect
      (b* ((mods (vl-make-n-bit-xdetect n)))
        (vl-modulelist-p mods))
      :rule-classes :rewrite)

    Theorem: type-of-vl-make-n-bit-xdetect

    (defthm type-of-vl-make-n-bit-xdetect
      (and (true-listp (vl-make-n-bit-xdetect n))
           (consp (vl-make-n-bit-xdetect n)))
      :rule-classes :type-prescription)

    Theorem: vl-make-n-bit-xdetect-of-pos-fix-n

    (defthm vl-make-n-bit-xdetect-of-pos-fix-n
      (equal (vl-make-n-bit-xdetect (pos-fix n))
             (vl-make-n-bit-xdetect n)))

    Theorem: vl-make-n-bit-xdetect-pos-equiv-congruence-on-n

    (defthm vl-make-n-bit-xdetect-pos-equiv-congruence-on-n
      (implies (acl2::pos-equiv n n-equiv)
               (equal (vl-make-n-bit-xdetect n)
                      (vl-make-n-bit-xdetect n-equiv)))
      :rule-classes :congruence)