Let
be an
-bit vector
, and let
. The bit slice
operator
computes the
-bit vector
. It is defined formally as
follows.
Notation: Following standard RTL syntax, we abbreviate `' as `
'.
For the purpose of resolving ambiguous expressions, this construction takes precedence over the basic arithmetic operators, e.g.,
PROOF: By Lemmas 1.1.1 and 1.2.3,
.
By Lemma 1.2.4,
Example: Let. Then
is a 3-bit vector and
is a 4-bit vector.
PROOF:
.
PROOF: By Lemma 1.2.23,
.
If the lower limit of a bit slice is 0, it reduces to a call to
:
PROOF:
PROOF: By Lemmas 2.2.4 and 1.2.19,
By expanding
, we may also express a bit slice in terms of the floor
alone:
PROOF: Applying Definitions 2.2.1 and 1.2.1 and Lemma 1.1.6, we have
![]() |
|||
In most cases of interest, the index arguments of
satisfy
.
However, the following two lemmas are worth noting.
PROOF: Since
,
. Applying
Definition 1.2.1 and Lemma 1.1.1, we have
PROOF: By Lemma 1.2.4,
and hence
which, together with Lemma 2.2.1, implies
Here is another case in which a bit slice may be reduced to 0:
PROOF: By Lemmas 1.2.3 and 1.2.6,
Therefore, by Lemma 1.1.5 and Definition 1.1.1,
which, together with Lemma 2.2.1, implies
Calls to bits may often be eliminated by means of the following.
PROOF: Since
,
by Lemmas 2.2.4 and 1.2.7.
Notation: For any expressionsand
, `
' is an abbreviation for the expression `
'.
This is standard RTL syntax in the case whereand
are constants and
is expressed as a binary expansion consisting of at most
bits, e.g.,
But note that we are extending this notation to include arbitrary variable expressionsand
, and to allow the width of
to exceed
. For example, Lemma 2.2.11 may now be stated as follows.
IfIn practice, however, we shall generally restrict our use of this construction to cases whereis an
-bit vector, then
.
is a constant of width
. 2.1
According to our next lemma, a slice of a right-shifted bit vector,
, may always be represented as a slice of
.
PROOF: Let
and
, so that
and
. Then
where
and by Definition 2.2.1 and Lemma 1.1.7,
PROOF: Applying Lemma 2.2.13, Definition 2.2.1, and Lemma 2.2.4 in succession, we have
PROOF: If
, then by Definition 2.2.1 and Lemma 1.2.24,
| 0 |
The next lemma provides an alternate expression for a left-shifted bit slice with lower limit 0:
PROOF: By Lemmas 1.2.24 and 2.2.4,
We note two cases in which a bit slice of
can be simplified.
PROOF: By Lemma 2.2.8, we may assume that
.
Since
,
We apply Lemma 2.2.13, substituting
PROOF: Since
, where
,
Lemma 1.2.16 implies
The lemma
now follows from Lemma 2.2.2.
Here is an important lemma that decomposes a slice into two subslices.
PROOF: The proof consists of three applications of Lemma 2.2.6:
and hence,
Compositions of bit slices may be reduced by means of the following.
PROOF: By Lemma 2.2.13,
On the other hand, if
and by Lemma 1.2.7, the expression reduces instead to