Group up a list of bits into N-bit concatenations.
(vl-partition-msb-bitslices n x) → new-exprs
The basic way that we partition an expression into
We return a new list of expressions, each of is a concatenation of
Then the resulting list of expressions will be:
We prove that the resulting expressions all have width
An arguably unfortunate consequence of our partitioning approach is that the
resulting concatenations of bits can be large and ugly in certain cases. For
instance, part selects like
My original implementation of partitioning also had a "cleaning" phase that tried to correct for this, essentially by identifying these descending sequences of bit-selects and re-assembling them into part-selects. But I no longer to implement such a cleaning phase. My rationale is that:
NOTE: we now have expr-cleaning code that can do this cleaning. We don't currently use it here, in case it has any bugs, but perhaps we should re-integrate it.
Function:
(defun vl-partition-msb-bitslices (n x) (declare (xargs :guard (and (posp n) (vl-exprlist-p x)))) (declare (xargs :guard (and (eql (mod (len x) n) 0) (all-equalp 1 (vl-exprlist->finalwidths x))))) (let ((__function__ 'vl-partition-msb-bitslices)) (declare (ignorable __function__)) (b* ((n (lposfix n)) ((when (eql n 0)) nil) ((when (< (len x) n)) nil)) (cons (make-vl-nonatom :op :vl-concat :args (first-n n x) :finalwidth n :finaltype :vl-unsigned :atts nil) (vl-partition-msb-bitslices n (rest-n n x))))))
Theorem:
(defthm vl-exprlist-p-of-vl-partition-msb-bitslices (b* ((new-exprs (vl-partition-msb-bitslices n x))) (vl-exprlist-p new-exprs)) :rule-classes :rewrite)
Theorem:
(defthm len-of-vl-partition-msb-bitslices (equal (len (vl-partition-msb-bitslices n x)) (floor (len x) (pos-fix n))))
Theorem:
(defthm vl-exprlist->finalwidths-of-vl-partition-msb-bitslices (equal (vl-exprlist->finalwidths (vl-partition-msb-bitslices n x)) (replicate (floor (len x) (pos-fix n)) (pos-fix n))))
Theorem:
(defthm vl-exprlist->finaltypes-of-vl-partition-msb-bitslices (equal (vl-exprlist->finaltypes (vl-partition-msb-bitslices n x)) (replicate (floor (len x) (pos-fix n)) :vl-unsigned)))
Theorem:
(defthm vl-exprlist-welltyped-p-of-vl-partition-msb-bitslices (implies (and (force (vl-exprlist-welltyped-p x)) (force (all-equalp 1 (vl-exprlist->finalwidths x)))) (vl-exprlist-welltyped-p (vl-partition-msb-bitslices n x))))
Theorem:
(defthm vl-partition-msb-bitslices-of-pos-fix-n (equal (vl-partition-msb-bitslices (pos-fix n) x) (vl-partition-msb-bitslices n x)))
Theorem:
(defthm vl-partition-msb-bitslices-pos-equiv-congruence-on-n (implies (acl2::pos-equiv n n-equiv) (equal (vl-partition-msb-bitslices n x) (vl-partition-msb-bitslices n-equiv x))) :rule-classes :congruence)
Theorem:
(defthm vl-partition-msb-bitslices-of-vl-exprlist-fix-x (equal (vl-partition-msb-bitslices n (vl-exprlist-fix x)) (vl-partition-msb-bitslices n x)))
Theorem:
(defthm vl-partition-msb-bitslices-vl-exprlist-equiv-congruence-on-x (implies (vl-exprlist-equiv x x-equiv) (equal (vl-partition-msb-bitslices n x) (vl-partition-msb-bitslices n x-equiv))) :rule-classes :congruence)