If
and
are
considered as bit vectors of widths
and
, respectively, then the concatenation of
and
is the
-bit vector
This notion is formalized as a function of four arguments:
PROOF: By Lemma 2.2.1,
and
. It follows that
and
, and hence,
We note three trivial cases:
PROOF: By Definition 2.4.1 and Lemma 2.2.8,
PROOF: By Definition 2.4.1 and Lemma 2.2.8,
PROOF: By Definition 2.4.1 and Lemma 2.2.10,
PROOF: By Lemma 2.2.20,
Notation: In standard RTL syntax, the concatenation of two bit vectors represented by expressionsand
is denoted by `
'. However, this notation depends on the following characteristic shared by conventional hardware description languages: any expression that represents a bit vector includes a reference (either explicit or implicit) to its width. In order to incorporate this notation for concatenation, as well as other elements of RTL formalism, into our informal mathematical notation, we shall identify a class of expressions that may be unambigously associated with bit vector widths. This class includes all expressions that represent applications of one of the functions bits, bitn, and cat. As we proceed, other functions will be added to this list.
For each such expression, we define another expression, called its size, as follows:
For example, the size of the expression `' is the expression `
'. But since the second expression has the same value as `
', we may safely treat the first expression as one of size `
'.
As a matter of convenience, ifis an expression that does not have a defined size, but the value of which is known to be a bit vector of width 1, then we may treat
as having size 1, i.e., we may interpret
as an abbreviation for `
' (i.e., for `
'). For example, in a context in which
and
are known to be 1-bit vectors,
Figure 3.1 summarizes this notion of size and its extension to the various types of “sized” expressions that will be introduced later in this chapter and the next.
Next, we adopt the following notation for the concatenation of bit vectors that are represented by sized expressions:
For example, for any expressionsand
and natural numbers
and
, `
' and `
' are expressions of sizes
and
, respectively. Thus,
is an abbreviation for
which is an expression of size `'. But note that according to Lemma 2.4.5, the expression
is represented by the same abbreviation.
Also, note that according to Lemmas 2.2.1, 2.3.3, and 2.4.1, ifis an expression of size
, then the value of
is guaranteed to be a bit vector whose width is the value of
. As we introduce other abbreviations and extend our notion of size to other types of expressions, we shall ensure that this property is preserved.
A complete list of abbreviations based on RTL syntax is contained in Figure 3.2.
Example: Since `', `
', and `
' are expressions of sizes `
', `
', and `
', respectively, according Lemma 2.4.1, we may write
Concatenation is an associative operation:
PROOF: By Definition 2.4.1,
PROOF: By Definition 2.4.1, we have
where
Now by Definition 2.2.1,
But Lemma 2.4.1 yields
Finally, by Lemma 1.1.6, this reduces to
The following is essentially a restatement of Lemma 2.2.19, but is an important rewrite rule for concatenating adjacent bit slices:
PROOF: By Definition 2.4.1,
but by Lemma 2.2.19, this reduces to
We list three special cases of Lemma 2.4.9:
The next lemma is a formula for extracting a bit slice from a concatenation:
PROOF: Let
. By Lemma 2.4.7,
and
and by Lemma 2.4.1,
Case 1:
By Lemma 2.2.20,
Case 2:
By Lemma 2.2.20,
By Lemma 2.4.9,
But
by Lemma 2.4.4. Now by Lemma 2.2.20,
By Lemma 2.4.9,
But by Lemma 2.2.20,
By Lemma 2.4.9,
As in Case 4,
PROOF: The cases listed correspond to the first three cases of
Lemma 2.4.13 with
. Note that for the third case, the lemma
gives
, but since
, i.e.,
, this reduces to 0 by
Lemma 2.2.8.
The function mulcat concatenates several copies of a bit vector:
PROOF: This is proved by induction, using Lemma 2.4.5. For
,
PROOF: The claim is trivial for
. Using induction, let
and
assume that
is a bit vector of width
.
Then by Lemma 2.4.1,
is a bit vector of width
Notation: For any expressions,
, and
, the size the expression `
' is defined to be the expression `
'. If
is the size of
, then `
' is an abbreviation for `
'.
For example, `' is an abbreviation for `
' and according to Lemma 2.4.15, may also be used as an abbreviation for `
'.
As a consequence of Lemma 2.4.16, the basic property of sized expressions is preserved: ifis an expression of size
, then the value of
is a bit vector whose width is the value of
.
Note that the foregoing definition may be written as
We make note of several trivial identities:
PROOF: By Lemma 2.4.3,
PROOF: By induction and Lemma 2.4.3,
PROOF: By induction,
PROOF: If
, then by Lemmas 2.4.17 and 2.3.7,
If
and we invoke Lemma 2.4.14, substituting
If
and the proof is completed by induction.