Hi all,
Assume I have 2 header fields of 16 bits each. (f1 and f2)
I have a temporary variable, say temp of 32 bits.
Can I concatenate two fields and store results in a temp variable directly
in P4?
Something like:
temp = f1.f2;
If not, any tricks for this concatenation function in P4?
Thanks
Sahil Gupta
++ is the concatenation operator for bitstrings
From: Sahil Gupta sg5414@rit.edu
Sent: Friday, February 19, 2021 5:27:21 PM
To: p4-dev p4-dev@lists.p4.org
Subject: [P4-dev] Way to concatenate two header fields two gather in P4
Hi all,
Assume I have 2 header fields of 16 bits each. (f1 and f2)
I have a temporary variable, say temp of 32 bits.
Can I concatenate two fields and store results in a temp variable directly in P4?
Something like:
temp = f1.f2;
If not, any tricks for this concatenation function in P4?
Thanks
Sahil Gupta
Sorry for miss spelled heading.
I hope someone from admin can edit it.
Correct heading: "Way to concatenate two header fields together in P4"
On Fri, Feb 19, 2021 at 8:27 PM Sahil Gupta sg5414@g.rit.edu wrote:
Hi all,
Assume I have 2 header fields of 16 bits each. (f1 and f2)
I have a temporary variable, say temp of 32 bits.
Can I concatenate two fields and store results in a temp variable directly
in P4?
Something like:
temp = f1.f2;
If not, any tricks for this concatenation function in P4?
Thanks
Sahil Gupta
Thanks Mihai Budiu.
Any examples from the p4c or BMv2 repository where I can see this operator
in action?
Regards
Sahil Gupta
On Fri, Feb 19, 2021 at 8:29 PM Mihai Budiu mbudiu@vmware.com wrote:
++ is the concatenation operator for bitstrings
From: Sahil Gupta sg5414@rit.edu
Sent: Friday, February 19, 2021 5:27:21 PM
To: p4-dev p4-dev@lists.p4.org
Subject: [P4-dev] Way to concatenate two header fields two gather in P4
Hi all,
Assume I have 2 header fields of 16 bits each. (f1 and f2)
I have a temporary variable, say temp of 32 bits.
Can I concatenate two fields and store results in a temp variable directly
in P4?
Something like:
temp = f1.f2;
If not, any tricks for this concatenation function in P4?
Thanks
Sahil Gupta
One more question.
Any way to store half the bits of the header?
Say field f is a 16 bit field.
Can I have something like:
temp = f1[0-8];
Regards
Sahil Gupta
On Fri, Feb 19, 2021 at 8:31 PM Sahil Gupta sg5414@g.rit.edu wrote:
Thanks Mihai Budiu.
Any examples from the p4c or BMv2 repository where I can see this operator
in action?
Regards
Sahil Gupta
On Fri, Feb 19, 2021 at 8:29 PM Mihai Budiu mbudiu@vmware.com wrote:
++ is the concatenation operator for bitstrings
From: Sahil Gupta sg5414@rit.edu
Sent: Friday, February 19, 2021 5:27:21 PM
To: p4-dev p4-dev@lists.p4.org
Subject: [P4-dev] Way to concatenate two header fields two gather in P4
Hi all,
Assume I have 2 header fields of 16 bits each. (f1 and f2)
I have a temporary variable, say temp of 32 bits.
Can I concatenate two fields and store results in a temp variable
directly in P4?
Something like:
temp = f1.f2;
If not, any tricks for this concatenation function in P4?
Thanks
Sahil Gupta
The test cases for p4c are all in testdata/p4_16_samples. Grep for ++.
From: Sahil Gupta sg5414@rit.edu
Sent: Friday, February 19, 2021 5:31:57 PM
To: Mihai Budiu mbudiu@vmware.com
Cc: p4-dev p4-dev@lists.p4.org
Subject: Re: [P4-dev] Way to concatenate two header fields two gather in P4
Thanks Mihai Budiu.
Any examples from the p4c or BMv2 repository where I can see this operator in action?
Regards
Sahil Gupta
On Fri, Feb 19, 2021 at 8:29 PM Mihai Budiu <mbudiu@vmware.commailto:mbudiu@vmware.com> wrote:
++ is the concatenation operator for bitstrings
From: Sahil Gupta <sg5414@rit.edumailto:sg5414@rit.edu>
Sent: Friday, February 19, 2021 5:27:21 PM
To: p4-dev <p4-dev@lists.p4.orgmailto:p4-dev@lists.p4.org>
Subject: [P4-dev] Way to concatenate two header fields two gather in P4
Hi all,
Assume I have 2 header fields of 16 bits each. (f1 and f2)
I have a temporary variable, say temp of 32 bits.
Can I concatenate two fields and store results in a temp variable directly in P4?
Something like:
temp = f1.f2;
If not, any tricks for this concatenation function in P4?
Thanks
Sahil Gupta
You want to use the bitslice operator f1[8:0]
The official spec is here https://p4.org/p4-spec/docs/P4-16-v1.2.0.html
From: Sahil Gupta sg5414@rit.edu
Sent: Friday, February 19, 2021 5:35:21 PM
To: Mihai Budiu mbudiu@vmware.com
Cc: p4-dev p4-dev@lists.p4.org
Subject: Re: [P4-dev] Way to concatenate two header fields two gather in P4
One more question.
Any way to store half the bits of the header?
Say field f is a 16 bit field.
Can I have something like:
temp = f1[0-8];
Regards
Sahil Gupta
On Fri, Feb 19, 2021 at 8:31 PM Sahil Gupta <sg5414@g.rit.edumailto:sg5414@g.rit.edu> wrote:
Thanks Mihai Budiu.
Any examples from the p4c or BMv2 repository where I can see this operator in action?
Regards
Sahil Gupta
On Fri, Feb 19, 2021 at 8:29 PM Mihai Budiu <mbudiu@vmware.commailto:mbudiu@vmware.com> wrote:
++ is the concatenation operator for bitstrings
From: Sahil Gupta <sg5414@rit.edumailto:sg5414@rit.edu>
Sent: Friday, February 19, 2021 5:27:21 PM
To: p4-dev <p4-dev@lists.p4.orgmailto:p4-dev@lists.p4.org>
Subject: [P4-dev] Way to concatenate two header fields two gather in P4
Hi all,
Assume I have 2 header fields of 16 bits each. (f1 and f2)
I have a temporary variable, say temp of 32 bits.
Can I concatenate two fields and store results in a temp variable directly in P4?
Something like:
temp = f1.f2;
If not, any tricks for this concatenation function in P4?
Thanks
Sahil Gupta
Thanks Mihai Budiu.
☺
On Fri, Feb 19, 2021 at 8:38 PM Mihai Budiu mbudiu@vmware.com wrote:
You want to use the bitslice operator f1[8:0]
The official spec is here https://p4.org/p4-spec/docs/P4-16-v1.2.0.html
From: Sahil Gupta sg5414@rit.edu
Sent: Friday, February 19, 2021 5:35:21 PM
To: Mihai Budiu mbudiu@vmware.com
Cc: p4-dev p4-dev@lists.p4.org
Subject: Re: [P4-dev] Way to concatenate two header fields two gather
in P4
One more question.
Any way to store half the bits of the header?
Say field f is a 16 bit field.
Can I have something like:
temp = f1[0-8];
Regards
Sahil Gupta
On Fri, Feb 19, 2021 at 8:31 PM Sahil Gupta sg5414@g.rit.edu wrote:
Thanks Mihai Budiu.
Any examples from the p4c or BMv2 repository where I can see this operator
in action?
Regards
Sahil Gupta
On Fri, Feb 19, 2021 at 8:29 PM Mihai Budiu mbudiu@vmware.com wrote:
++ is the concatenation operator for bitstrings
From: Sahil Gupta sg5414@rit.edu
Sent: Friday, February 19, 2021 5:27:21 PM
To: p4-dev p4-dev@lists.p4.org
Subject: [P4-dev] Way to concatenate two header fields two gather in P4
Hi all,
Assume I have 2 header fields of 16 bits each. (f1 and f2)
I have a temporary variable, say temp of 32 bits.
Can I concatenate two fields and store results in a temp variable directly
in P4?
Something like:
temp = f1.f2;
If not, any tricks for this concatenation function in P4?
Thanks
Sahil Gupta