Safely creates expr[msb:lsb].
We ensure that expr is an identifier and that
Historic note. This used to have the same problem as vl-make-bitselect, and checked whether the msb was less than the final-width of expression. See the discussion there.
We no longer try to prevent you from creating part-selects with invalid ranges, since it's just not possible to do that correctly here. Garbage in, garbage out.
Function:
(defun vl-make-partselect (expr msb lsb) (declare (xargs :guard (and (vl-expr-p expr) (natp msb) (natp lsb)))) (let ((__function__ 'vl-make-partselect)) (declare (ignorable __function__)) (b* ((msb (lnfix msb)) (lsb (lnfix lsb)) ((when (> lsb msb)) (raise "LSB, ~x0, is larger than MSB, ~x1." lsb msb) (vl-default-n-bit-expr 1)) (width (+ 1 (- msb lsb))) (msb-index (vl-make-index msb)) (lsb-index (vl-make-index lsb)) ((unless (and (vl-fast-atom-p expr) (vl-fast-id-p (vl-atom->guts expr)))) (raise "Trying to select from a non-identifier: ~x0" expr) (vl-default-n-bit-expr width)) ((when (= lsb msb)) (make-vl-nonatom :op :vl-bitselect :args (list expr msb-index) :finalwidth 1 :finaltype :vl-unsigned))) (make-vl-nonatom :op :vl-partselect-colon :args (list expr msb-index lsb-index) :finalwidth width :finaltype :vl-unsigned))))
Theorem:
(defthm vl-expr-p-of-vl-make-partselect (b* ((|expr[msb:lsb]| (vl-make-partselect expr msb lsb))) (vl-expr-p |expr[msb:lsb]|)) :rule-classes :rewrite)
Theorem:
(defthm vl-expr->finalwidth-of-vl-make-partselect (equal (vl-expr->finalwidth (vl-make-partselect expr msb lsb)) (+ 1 (nfix (- (nfix msb) (nfix lsb))))))
Theorem:
(defthm vl-expr-widthsfixed-p-of-vl-make-partselect (implies (force (vl-expr-widthsfixed-p expr)) (vl-expr-widthsfixed-p (vl-make-partselect expr msb lsb))))
Theorem:
(defthm vl-make-partselect-of-vl-expr-fix-expr (equal (vl-make-partselect (vl-expr-fix expr) msb lsb) (vl-make-partselect expr msb lsb)))
Theorem:
(defthm vl-make-partselect-vl-expr-equiv-congruence-on-expr (implies (vl-expr-equiv expr expr-equiv) (equal (vl-make-partselect expr msb lsb) (vl-make-partselect expr-equiv msb lsb))) :rule-classes :congruence)
Theorem:
(defthm vl-make-partselect-of-nfix-msb (equal (vl-make-partselect expr (nfix msb) lsb) (vl-make-partselect expr msb lsb)))
Theorem:
(defthm vl-make-partselect-nat-equiv-congruence-on-msb (implies (acl2::nat-equiv msb msb-equiv) (equal (vl-make-partselect expr msb lsb) (vl-make-partselect expr msb-equiv lsb))) :rule-classes :congruence)
Theorem:
(defthm vl-make-partselect-of-nfix-lsb (equal (vl-make-partselect expr msb (nfix lsb)) (vl-make-partselect expr msb lsb)))
Theorem:
(defthm vl-make-partselect-nat-equiv-congruence-on-lsb (implies (acl2::nat-equiv lsb lsb-equiv) (equal (vl-make-partselect expr msb lsb) (vl-make-partselect expr msb lsb-equiv))) :rule-classes :congruence)