Safely create a constant integer atom whose value is n.
The expression we create doesn't have a type, because it would depend on the context. In many cases it might suffice to use an integer type; in this case see vl-make-integer.
Function:
(defun vl-make-index (n) (declare (xargs :guard (integerp n))) (let ((__function__ 'vl-make-index)) (declare (ignorable __function__)) (let* ((value (lifix n)) (width (+ 1 (integer-length value)))) (if (<= width 31) (hons-copy (make-vl-literal :val (make-vl-constint :origwidth 32 :origsign :vl-signed :wasunsized t :value (acl2::loghead 32 value)))) (hons-copy (make-vl-literal :val (make-vl-constint :origwidth width :origsign :vl-signed :value (acl2::loghead width value))))))))
Theorem:
(defthm vl-expr-p-of-vl-make-index (b* ((index (vl-make-index n))) (vl-expr-p index)) :rule-classes :rewrite)
Theorem:
(defthm vl-expr-kind-of-vl-make-index (eq (vl-expr-kind (vl-make-index n)) :vl-literal))
Theorem:
(defthm vl-expr-resolved-p-of-vl-make-index (vl-expr-resolved-p (vl-make-index n)))
Theorem:
(defthm vl-resolved->val-of-vl-make-index (equal (vl-resolved->val (vl-make-index n)) (ifix n)))
Theorem:
(defthm vl-make-index-of-ifix-n (equal (vl-make-index (ifix n)) (vl-make-index n)))
Theorem:
(defthm vl-make-index-int-equiv-congruence-on-n (implies (acl2::int-equiv n n-equiv) (equal (vl-make-index n) (vl-make-index n-equiv))) :rule-classes :congruence)