Skip to content

Commit 34adeba

Browse files
committed
migrate v1 version of p4fpga to p4fpga-python
0 parents  commit 34adeba

File tree

167 files changed

+27648
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+27648
-0
lines changed

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
P4PAXOS:=~/dev/p4paxos/p4src
3+
4+
objects:=$(wildcard tests/*.p4)
5+
6+
%:
7+
python bsvgen.py tests/$@.p4;
8+
9+
clean:
10+
rm *.pyc
11+
12+
doc:
13+
doxygen Doxyfile

ast_util.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import astbsv as ast
2+
from utils import GetHeaderWidthInState
3+
4+
# Generate ParseState Object from parseGraph
5+
class ParseState(object):
6+
REGULAR = "REGULAR"
7+
EMPTY = "EMPTY"
8+
def __init__(self, id, name):
9+
self.id = id
10+
self.name = name
11+
self.len = GetHeaderWidthInState(name)
12+
self.state_type = ParseState.REGULAR
13+
self.transitions = None
14+
self.transition_keys = None
15+
self.parse_ops = None
16+
17+
def __repr__(self):
18+
return "ParseState: %s %s %s" % (self.id, self.name, self.len)
19+
20+
def apply_pdict (tmpls, pdict):
21+
stmt = []
22+
for t in tmpls:
23+
stmt.append(ast.Template(t, pdict))
24+
return stmt
25+
26+
def apply_action_block(stmt):
27+
"""
28+
wrap list of stmt in an action block
29+
@param: list of stmt
30+
@rtype: ActionBlock in a []
31+
"""
32+
return [ast.ActionBlock(stmt)]
33+
34+
def apply_if_verbosity(verbosity, stmt):
35+
assert type(stmt) is list
36+
assert type(verbosity) is int
37+
return [ast.If("cr_verbosity[0] > %d"%(verbosity), stmt)]
38+
39+
def apply_case_stmt(caseExpr, stmt):
40+
stmt = ast.Case('v')
41+
return [ast.Case(case_expr)]

0 commit comments

Comments
 (0)