• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
        • Warnings
        • Primitives
          • *vl-1-bit-approx-mux*
          • *vl-1-bit-mux*
          • Nedgeflop
            • Vl-make-same-bitselect-from-each
            • Vl-primitive-mkports
            • Vl-nedgeflop-ifstmt
            • Vl-make-1-bit-n-edge-flop
              • Vl-make-nedgeflop-insts
              • Vl-nedgeflop-always
              • Vl-nedgeflop-clkedge-assigns
              • Vl-nedgeflop-update-sexpr
              • Vl-nedgeflop-e-wires
              • Vl-make-delay-assigns
              • Vl-nedgeflop-posedge-clks
              • Vl-nedgeflop-data-mux
              • Vl-nedgeflop-some-edge-sexpr
              • Vl-modinsts-add-atts
              • Vl-nedgeflop-or-edges
            • Vl-primitive-mkport
            • *vl-1-bit-assign*
            • *vl-1-bit-zmux*
            • Vl-primitive-mkwire
            • *vl-1-bit-bufif1*
            • *vl-1-bit-bufif0*
            • *vl-1-bit-delay-1*
            • *vl-1-bit-ceq*
            • *vl-1-bit-buf*
            • *vl-1-bit-rcmos*
            • *vl-1-bit-latch*
            • *vl-1-bit-cmos*
            • *vl-1-bit-power*
            • *vl-1-bit-rpmos*
            • *vl-1-bit-rnmos*
            • *vl-1-bit-pmos*
            • *vl-1-bit-nmos*
            • *vl-1-bit-ground*
            • *vl-1-bit-tranif1*
            • *vl-1-bit-tranif0*
            • *vl-1-bit-rtranif1*
            • *vl-1-bit-rtranif0*
            • *vl-1-bit-rtran*
            • *vl-1-bit-tran*
            • *vl-1-bit-notif1*
            • *vl-1-bit-notif0*
            • *vl-1-bit-and*
            • *vl-1-bit-xor*
            • *vl-1-bit-xnor*
            • *vl-1-bit-pullup*
            • *vl-1-bit-pulldown*
            • *vl-1-bit-or*
            • *vl-1-bit-not*
            • *vl-1-bit-nor*
            • *vl-1-bit-nand*
            • *vl-1-bit-z*
            • *vl-1-bit-x*
            • *vl-1-bit-t*
            • *vl-1-bit-f*
          • Use-set
          • Syntax
          • Getting-started
          • Utilities
          • Loader
          • Transforms
          • Lint
          • Mlib
          • Server
          • Kit
          • Printer
          • Esim-vl
          • Well-formedness
        • Sv
        • Fgl
        • Vwsim
        • Vl
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Math
      • Testing-utilities
    • Nedgeflop

    Vl-make-1-bit-n-edge-flop

    Build the primitive VL module for an n-edge flop.

    Signature
    (vl-make-1-bit-n-edge-flop n) → flop
    Arguments
    n — Guard (posp n).
    Returns
    flop — Type (vl-module-p flop), given the guard.

    Definitions and Theorems

    Function: vl-make-1-bit-n-edge-flop

    (defun vl-make-1-bit-n-edge-flop (n)
     (declare (xargs :guard (posp n)))
     (let ((__function__ 'vl-make-1-bit-n-edge-flop))
       (declare (ignorable __function__))
       (b*
        ((name (cat "VL_1_BIT_" (natstr n)
                    "_EDGE_FLOP"))
         ((mv q-expr q-port q-portdecl q-vardecl)
          (vl-primitive-mkport "q" :vl-output))
         (q-portdecl (change-vl-portdecl q-portdecl
                                         :type *vl-plain-old-reg-type*))
         (q-vardecl (change-vl-vardecl q-vardecl
                                       :type *vl-plain-old-reg-type*))
         ((mv d-exprs d-ports d-portdecls d-vardecls)
          (vl-primitive-mkports "d" 0 n
                                :dir :vl-input))
         ((mv clk-exprs
              clk-ports clk-portdecls clk-vardecls)
          (vl-primitive-mkports "clk" 0 n
                                :dir :vl-input))
         (always (vl-nedgeflop-always q-expr clk-exprs d-exprs))
         (temp-mod
              (make-vl-module
                   :name name
                   :origname name
                   :ports (cons q-port (append d-ports clk-ports))
                   :portdecls (cons q-portdecl
                                    (append d-portdecls clk-portdecls))
                   :vardecls (cons q-vardecl
                                   (append d-vardecls clk-vardecls))
                   :alwayses (list always)
                   :minloc *vl-fakeloc*
                   :maxloc *vl-fakeloc*
                   :atts (list (cons (hons-copy "VL_HANDS_OFF") nil))))
         ((mv okp warnings walist)
          (vl-module-wirealist temp-mod nil))
         ((unless (and okp (not warnings)))
          (raise "Error creating wire alist? ~s0"
                 (vl-warnings-to-string warnings))
          temp-mod)
         (q-wire (car (vl-nedgeflop-e-wires (list q-expr)
                                            walist)))
         (d-wires (vl-nedgeflop-e-wires d-exprs walist))
         (clk-wires (vl-nedgeflop-e-wires clk-exprs walist))
         (q-prev (car (vl-emodwires-from-msb-to-lsb "q_prev" 0 0)))
         (d-prevs (vl-emodwires-from-msb-to-lsb "d_prev" (- n 1)
                                                0))
         (clk-prevs (vl-emodwires-from-msb-to-lsb "clk_prev" (- n 1)
                                                  0))
         (next-q-sexpr
              (acl2::4vs-ite*-dumb
                   (vl-nedgeflop-some-edge-sexpr clk-wires clk-prevs)
                   (vl-nedgeflop-update-sexpr clk-wires d-prevs)
                   q-prev))
         (nst-alist (cons (cons q-prev next-q-sexpr)
                          (append (pairlis$ clk-prevs clk-wires)
                                  (pairlis$ d-prevs d-wires))))
         (out-alist (list (cons q-wire next-q-sexpr)))
         (esim (list :n (vl-starname name)
                     :o (list (list q-wire))
                     :i (append (pairlis$ d-wires nil)
                                (pairlis$ clk-wires nil))
                     :x (list :out out-alist :nst nst-alist)
                     :a (list (cons "VL_N_EDGE_FLOP" t)
                              (cons "VL_FLOP_NUM_EDGES" n)
                              (cons "VL_FLOP_CLK_WIRES" clk-wires)
                              (cons "VL_FLOP_CLK_PREVS" clk-prevs)
                              (cons "VL_FLOP_D_WIRES" d-wires)
                              (cons "VL_FLOP_D_PREVS" d-prevs)
                              (cons "VL_FLOP_Q_WIRE" q-wire)
                              (cons "VL_FLOP_Q_PREV" q-prev)))))
        (change-vl-module temp-mod
                          :esim esim))))

    Theorem: vl-module-p-of-vl-make-1-bit-n-edge-flop

    (defthm vl-module-p-of-vl-make-1-bit-n-edge-flop
      (implies (and (force (posp n)))
               (b* ((flop (vl-make-1-bit-n-edge-flop n)))
                 (vl-module-p flop)))
      :rule-classes :rewrite)