Skip to content

Commit 669279e

Browse files
author
Mihai Budiu
authored
Merge pull request #853 from p4lang/concat
Allow concatenation with any type of bitstrings
2 parents 1fe300c + 5217709 commit 669279e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

p4-16/spec/P4-16-spec.mdk

+9-2
Original file line numberDiff line numberDiff line change
@@ -3374,8 +3374,6 @@ to bit-strings of the same width:
33743374

33753375
Bit-strings also support the following operations:
33763376

3377-
- Concatenation of two bit-strings, denoted by the infix operator `++`. The result is a bit-string whose
3378-
length is the sum of the lengths of the inputs where the most significant bits are taken from the left operand.
33793377
- Extraction of a set of contiguous bits, also known as a slice, denoted by `[m:l]`,
33803378
where `m` and `l` must be positive integers
33813379
that are compile-time known values, and `m >= l`. The result is
@@ -3470,6 +3468,14 @@ type. The result always has the same width as the left operand.
34703468
bit-pattern represented by `x`, and leaves all other bits of `e`
34713469
unchanged. A slice of a signed integer is treated like an unsigned integer.
34723470

3471+
### Concatenation { #sec-concatenation }
3472+
3473+
Concatenation is applied to two bit-strings (signed or unsigned). It
3474+
is denoted by the infix operator `++`. The result is a bit-string
3475+
whose length is the sum of the lengths of the inputs where the most
3476+
significant bits are taken from the left operand; the sign of the
3477+
result is taken from the left operand.
3478+
34733479
### A note about shifts
34743480

34753481
Shifts (on signed and unsigned values) deserve a special discussion
@@ -7776,6 +7782,7 @@ The P4 compiler should provide:
77767782
* Added structured annotations (Section [#sec-annotations]).
77777783
* Allow empty statements in parsers (Section [#sec-parser-state-stmt]).
77787784
* Fixed grammar for right shifts (Section [#sec-grammar]).
7785+
* Allow concatenation of signed strings (Section [#sec-concatenation]).
77797786

77807787
## Summary of changes made in version 1.2.0
77817788

0 commit comments

Comments
 (0)