Convert a vl-bit-p into the corresponding character, e.g.,
(vl-bit->char x) → char
(vl-bit->char x) produces the ASCII character for a vl-bit-p. That is, it returns one of the characters: 0, 1, X, or Z.
Function:
(defun vl-bit->char (x) (declare (xargs :guard (vl-bit-p x))) (let ((__function__ 'vl-bit->char)) (declare (ignorable __function__)) (let ((x (mbe :logic (vl-bit-fix x) :exec x))) (case x (:vl-0val #\0) (:vl-1val #\1) (:vl-xval #\X) (:vl-zval #\Z) (otherwise (progn$ (impossible) #\X))))))
Theorem:
(defthm characterp-of-vl-bit->char (b* ((char (vl-bit->char x))) (characterp char)) :rule-classes :type-prescription)
Theorem:
(defthm vl-bit->char-of-vl-bit-fix-x (equal (vl-bit->char (vl-bit-fix x)) (vl-bit->char x)))
Theorem:
(defthm vl-bit->char-vl-bit-equiv-congruence-on-x (implies (vl-bit-equiv x x-equiv) (equal (vl-bit->char x) (vl-bit->char x-equiv))) :rule-classes :congruence)