Simulate an AIG on N*32 parallel input vectors.
This takes an s32v that has at least one row (see s32v-nrows) for each fanin node of the AIG and is seeded with combinational
input values. This function sweeps over the AIG to compute all other fanin
values given those inputs. After this, the Kth bit of the Nth row of the s32v
will equal the
If you want to simulate only one 32-bit set of values at a time, it is
faster and logically equivalent to use aignet-vecsim1 or aignet-vecsim-top (which logically equals
The combinational inputs of the AIG must have values already set in the
Exhaustive-sim wraps
Function:
(defun aignet-vecsim-step$inline (n s32v aignet) (declare (type (integer 0 *) n) (ignorable n s32v aignet)) (declare (xargs :stobjs (s32v aignet) :guard (<= (num-fanins aignet) (s32v-nrows s32v)))) (declare (xargs :guard (and (<= 0 n) (< n (num-fanins aignet)) t))) (b* ((n (lnfix n)) (nid n) (slot0 (id->slot nid 0 aignet)) (type (snode->type slot0))) (aignet-case type :gate (b* ((f0 (snode->fanin slot0)) (slot1 (id->slot nid 1 aignet)) (f1 (snode->fanin slot1))) (if (eql 1 (snode->regp slot1)) (s32v-xor-lits f0 f1 nid s32v) (s32v-and-lits f0 f1 nid s32v))) :const (s32v-zero nid s32v) :in s32v)))
Function:
(defun aignet-vecsim-tailrec (n s32v aignet) (declare (type (integer 0 *) n)) (declare (xargs :stobjs (s32v aignet) :guard (<= (num-fanins aignet) (s32v-nrows s32v)))) (declare (xargs :guard (and (<= 0 n) (<= n (num-fanins aignet)) t))) (b* (((when (mbe :logic (zp (- (ifix (num-fanins aignet)) (ifix n))) :exec (int= (num-fanins aignet) n))) s32v) (n (lifix n)) (s32v (aignet-vecsim-step n s32v aignet))) (aignet-vecsim-tailrec (1+ n) s32v aignet)))
Function:
(defun aignet-vecsim-iter (n s32v aignet) (declare (type (integer 0 *) n)) (declare (xargs :stobjs (s32v aignet) :guard (<= (num-fanins aignet) (s32v-nrows s32v)))) (declare (xargs :guard (and (<= 0 n) (<= n (num-fanins aignet)) t))) (b* (((when (mbe :logic (zp n) :exec (int= 0 n))) s32v) (n (1- (lifix n))) (s32v (aignet-vecsim-iter n s32v aignet))) (aignet-vecsim-step n s32v aignet)))
Theorem:
(defthm aignet-vecsim-iter-of-ifix-n (equal (aignet-vecsim-iter (ifix n) s32v aignet) (aignet-vecsim-iter n s32v aignet)))
Theorem:
(defthm aignet-vecsim-iter-int-equiv-congruence-on-n (implies (int-equiv n n-equiv) (equal (aignet-vecsim-iter n s32v aignet) (aignet-vecsim-iter n-equiv s32v aignet))) :rule-classes :congruence)
Theorem:
(defthm aignet-vecsim-tailrec-is-aignet-vecsim-iter (equal (aignet-vecsim-tailrec 0 s32v aignet) (aignet-vecsim-iter (num-fanins aignet) s32v aignet)))
Function:
(defun aignet-vecsim$inline (s32v aignet) (declare (xargs :stobjs (s32v aignet) :guard (<= (num-fanins aignet) (s32v-nrows s32v)))) (declare (xargs :guard t)) (b* nil (mbe :logic (aignet-vecsim-iter (num-fanins aignet) s32v aignet) :exec (aignet-vecsim-tailrec 0 s32v aignet))))
Theorem:
(defthm car-nonnil-forward-to-consp (implies (car x) (consp x)) :rule-classes :forward-chaining)
Theorem:
(defthm memo-tablep-aignet-vecsim-iter (implies (< (fanin-count aignet) (len (stobjs::2darr->rows s32v))) (< (fanin-count aignet) (len (stobjs::2darr->rows (aignet-vecsim-iter n s32v aignet))))) :rule-classes :linear)
Theorem:
(defthm aignet-vecsim-iter-lookup-prev (implies (<= (nfix n) (nfix m)) (equal (nth slot (nth m (stobjs::2darr->rows (aignet-vecsim-iter n s32v aignet)))) (nth slot (nth m (stobjs::2darr->rows s32v))))))
Theorem:
(defthm ncols-of-aignet-vecsim-iter (equal (stobjs::2darr->ncols (aignet-vecsim-iter n s32v aignet)) (stobjs::2darr->ncols s32v)))
Theorem:
(defthm nrows-of-aignet-vecsim-iter (implies (<= n (len (stobjs::2darr->rows s32v))) (equal (len (stobjs::2darr->rows (aignet-vecsim-iter n s32v aignet))) (len (stobjs::2darr->rows s32v)))))
Theorem:
(defthm nth-in-aignet-vecsim-iter-preserved (implies (and (< (nfix m) (nfix n)) (equal nm (1+ (nfix m))) (syntaxp (not (equal n nm)))) (equal (nth slot (nth m (stobjs::2darr->rows (aignet-vecsim-iter n vals aignet)))) (nth slot (nth m (stobjs::2darr->rows (aignet-vecsim-iter nm vals aignet)))))))
Theorem:
(defthm aignet-vecsim-iter-correct (implies (and (aignet-idp m aignet) (< (nfix m) (nfix n)) (< (nfix slot) (s32v-ncols s32v))) (equal (logbit bit (s32-fix (nth slot (nth m (stobjs::2darr->rows (aignet-vecsim-iter n s32v aignet)))))) (let* ((vals (vecsim-to-eval slot bit s32v vals aignet)) (in-vals (aignet-vals->invals nil vals aignet)) (reg-vals (aignet-vals->regvals nil vals aignet))) (id-eval m in-vals reg-vals aignet)))))
Theorem:
(defthm aignet-vecsim-correct (implies (and (aignet-idp m aignet) (< (nfix slot) (s32v-ncols s32v))) (equal (logbit bit (s32-fix (nth slot (nth m (stobjs::2darr->rows (aignet-vecsim s32v aignet)))))) (let* ((vals (vecsim-to-eval slot bit s32v vals aignet)) (in-vals (aignet-vals->invals nil vals aignet)) (reg-vals (aignet-vals->regvals nil vals aignet))) (id-eval m in-vals reg-vals aignet)))))
Theorem:
(defthm aignet-eval-iter-out-of-bounds (implies (<= (nfix n) (nfix m)) (equal (nth m (aignet-eval-iter n vals aignet)) (nth m vals))))
Theorem:
(defthm aignet-eval-out-of-bounds (implies (< (fanin-count aignet) (nfix m)) (equal (nth m (aignet-eval vals aignet)) (nth m vals))))
Theorem:
(defthm aignet-vecsim-to-eval-lemma (implies (< (nfix slot) (s32v-ncols s32v)) (bit-equiv (nth id (vecsim-to-eval slot bit (aignet-vecsim s32v aignet) vals aignet)) (nth id (aignet-eval (vecsim-to-eval slot bit s32v vals aignet) aignet)))))
Theorem:
(defthm aignet-vecsim-to-eval (implies (< (nfix slot) (s32v-ncols s32v)) (bits-equiv (vecsim-to-eval slot bit (aignet-vecsim s32v aignet) vals aignet) (aignet-eval (vecsim-to-eval slot bit s32v vals aignet) aignet))))