Skip to content

Commit

Permalink
add +: slices
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDodd committed Oct 12, 2024
1 parent f0e1a24 commit 554c061
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions p4-16/spec/P4-16-spec.mdk
Original file line number Diff line number Diff line change
Expand Up @@ -3489,6 +3489,10 @@ Bit-strings also support the following operations:
The effect of this statement is to set bits `H` through `L` (inclusive of
both) of `e` to the bit-pattern represented by `x`, and leaves all other bits
of `e` unchanged. A slice of an unsigned integer is an unsigned integer.
A slice may also be specified as `[L+:W]` where L is the lowest bit of the slice
and W is the width of the slice. In this case, only W must be a non-negative compile-time
known numeric value. L must also be a numeric value and some architectures may require
it to likewise be compile-time know. Some architectures may allow variable indexing.
- Concatenation of bit-strings and/or fixed-width signed integers, denoted by `++`.
The two operands must be either `bit<W>` or `int<W>`, and they can be of
different signedness and width. The result has the same signedness as the
Expand Down
3 changes: 3 additions & 0 deletions p4-16/spec/grammar.mdk
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ lvalue
| lvalue "." member
| lvalue "[" expression "]"
| lvalue "[" expression ":" expression "]"
| lvalue "[" expression "+" ":" expression "]"
| "(" lvalue ")"
;
// END:lvalue
Expand Down Expand Up @@ -1036,6 +1037,7 @@ expression
| prefixedNonTypeName
| expression "[" expression "]"
| expression "[" expression ":" expression "]"
| expression "[" expression "+" ":" expression "]"
| "{" expressionList optTrailingComma "}"
| "{#}"
| "{" kvList optTrailingComma "}"
Expand Down Expand Up @@ -1086,6 +1088,7 @@ nonBraceExpression
| prefixedNonTypeName
| nonBraceExpression "[" expression "]"
| nonBraceExpression "[" expression ":" expression "]"
| nonBraceExpression "[" expression "+" ":" expression "]"
| "(" expression ")"
| "!" expression %prec PREFIX
| "~" expression %prec PREFIX
Expand Down

0 comments on commit 554c061

Please sign in to comment.