[P4-dev] extern objects

Nate Foster jnfoster at cs.cornell.edu
Wed Apr 26 12:13:04 EDT 2017


P4 uses standard lexical scoping rules, so global_ext can be used by both
controls.

I'm not sure what you mean by "singleton" but if you mean that the
architecture only has one instance of that object, I would do it something
like this.

// Architecture
extern global_ext {
  // do not include a constructor, just methods
  T1 f1();
  T2 f2();
   ...
}

control c1(global_ext ge);
control c1(global_ext ge);
package switch(c1 x, c2 y);

// Program
control c1(global_ext ge) { ... }
control c2(global_ext ge) { ... }
switch(c1(), c2()) main;


On Wed, Apr 26, 2017 at 6:10 AM, Elena Gurevich (TRC) <
Elena.Gurevich at huawei.com> wrote:

> Hello all,
>
>
>
> I would like to clarify an “extern” type usage.
>
>
>
> Let’s say I have some extern object declared by architecture and a package
> containing two control flows.
>
>
>
> extern global_ext {…};
>
>
>
> control c1() {…};
>
> control c2() {…};
>
>
>
> So how can I define extern type singleton with global visibility, that can
> be used by  both control flows ?
>
>
>
> Best regards,
>
> Lena
>
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20170426/97b5c287/attachment-0002.html>


More information about the P4-dev mailing list