From d4764905744fa76c4789e592ea285513f0b1ceab Mon Sep 17 00:00:00 2001 From: jaehyun1ee <99jaehyunlee@kaist.ac.kr> Date: Wed, 27 May 2026 17:49:05 +0900 Subject: [PATCH 1/3] Allow division and modulo for fixed-width bit types Signed-off-by: jaehyun1ee <99jaehyunlee@kaist.ac.kr> --- p4-16/spec/P4-16-spec.adoc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/p4-16/spec/P4-16-spec.adoc b/p4-16/spec/P4-16-spec.adoc index 2683a36b7a..23136e88ad 100644 --- a/p4-16/spec/P4-16-spec.adoc +++ b/p4-16/spec/P4-16-spec.adoc @@ -3636,6 +3636,12 @@ to bit-strings of the same width: and is computed by truncating the result to the output's width. P4 architectures may impose additional restrictions --- e.g., they may only allow multiplication by a non-negative integer power of two. +* Truncating integer division between positive values, denoted by `/`. + The result has the same width as the operands. Similar to multiplication, + P4 architectures may impose additional restrictions. +* Modulo between positive values, denoted by `%`. + The result has the same width as the operands. Similar to multiplication, + P4 architectures may impose additional restrictions. * Bitwise "and" between two bit-strings of the same width, denoted by `&`. * Bitwise "or" between two bit-strings of the same width, denoted by `|`. * Bitwise "complement" of a single bit-string, denoted by `~`. From 66a986248b070de936de68aced300836cb62f2ad Mon Sep 17 00:00:00 2001 From: jaehyun1ee <99jaehyunlee@kaist.ac.kr> Date: Mon, 6 Jul 2026 11:52:16 +0900 Subject: [PATCH 2/3] drop 'positive' from div/mod for bit types Signed-off-by: jaehyun1ee <99jaehyunlee@kaist.ac.kr> --- p4-16/spec/P4-16-spec.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/p4-16/spec/P4-16-spec.adoc b/p4-16/spec/P4-16-spec.adoc index 23136e88ad..749374eeb2 100644 --- a/p4-16/spec/P4-16-spec.adoc +++ b/p4-16/spec/P4-16-spec.adoc @@ -3636,7 +3636,7 @@ to bit-strings of the same width: and is computed by truncating the result to the output's width. P4 architectures may impose additional restrictions --- e.g., they may only allow multiplication by a non-negative integer power of two. -* Truncating integer division between positive values, denoted by `/`. +* Truncating integer division, denoted by `/`. The result has the same width as the operands. Similar to multiplication, P4 architectures may impose additional restrictions. * Modulo between positive values, denoted by `%`. From bd811ecc057d89612606f808da7c9791d0c89203 Mon Sep 17 00:00:00 2001 From: jaehyun1ee <99jaehyunlee@kaist.ac.kr> Date: Mon, 6 Jul 2026 11:54:26 +0900 Subject: [PATCH 3/3] add constraint on div/mod denominator Signed-off-by: jaehyun1ee <99jaehyunlee@kaist.ac.kr> --- p4-16/spec/P4-16-spec.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/p4-16/spec/P4-16-spec.adoc b/p4-16/spec/P4-16-spec.adoc index 749374eeb2..1ed9406d09 100644 --- a/p4-16/spec/P4-16-spec.adoc +++ b/p4-16/spec/P4-16-spec.adoc @@ -3637,6 +3637,7 @@ to bit-strings of the same width: P4 architectures may impose additional restrictions --- e.g., they may only allow multiplication by a non-negative integer power of two. * Truncating integer division, denoted by `/`. + The denominator must be positive. The result has the same width as the operands. Similar to multiplication, P4 architectures may impose additional restrictions. * Modulo between positive values, denoted by `%`.