Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

how to get the edge between two tables #39

Open
yuan-128 opened this issue Apr 7, 2021 · 1 comment
Open

how to get the edge between two tables #39

yuan-128 opened this issue Apr 7, 2021 · 1 comment

Comments

@yuan-128
Copy link

yuan-128 commented Apr 7, 2021

I want to know how to get the edge between two tables.I can get tables from the following code

from p4_hlir.main import HLIR
h = HLIR("simple_router.p4")
h.build()
h.p4_tables
@antoninbas
Copy link
Member

You can look at the self.next_ field

class p4_node(p4_object):
"""
TODO: docstring
"""
def __init__(self, hlir, name, **kwargs):
p4_object.__init__(self, hlir, name, **kwargs)
if not self.valid_obj:
return
self.control_flow_parent = None
self.next_ = OrderedDict()
# self.prev = OrderedSet()
self.conditional_barrier = None
self.dependencies_to = {} # tables to which this table have a dependency
self.dependencies_for = {} # tables for which this table is a dependency
# the "default default" next node, according to the original P4 control
# flow; if a table has not runtime-configured (or compile-time
# configured) default action and there is a table miss, this node will
# be executed, as per the P4 spec
# note that this is also defined for conditions in case an optimization
# removes a useless condition and base_default_next needs to be updated
# for upstream nodes
self.base_default_next = None
hlir.p4_nodes[name] = self

p4_table inherits from p4_node

Note that this repo is not maintained any more. I recommend transitioning to the p4lang/p4c compiler, which is in active development.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants