jafingerhut / p4-guide

Guide to p4lang repositories and some other public info about P4
534 stars 156 forks source link

Add hex min and max to match-range-using-tcam #30

Closed hesingh closed 4 years ago

hesingh commented 4 years ago

The current Python code does not accept a hex number for min and max with match-range-using-tcam.

One way to fix the issue is to add this function at the top of the code.

def auto_int(x):
        return int(x, 0)

Then changing type=int to type=auto_int where min and max are parsed.

Then this use of the Python code works.

python range-to-tcam-entries.py --bit-width 16 --min 0x0800 --max 0x0806

jafingerhut commented 4 years ago

Good suggestion. Commit with that change made here: https://github.com/jafingerhut/p4-guide/commit/001b48da13b90506c879ccc129d70ba84e7dc28f