Adding P4 cheat cheet and its latex source files. (#201)
This commit is contained in:
19
utils/cheat_sheet_src/src/counters.txt
Normal file
19
utils/cheat_sheet_src/src/counters.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
// counters
|
||||
counter(8192, CounterType.packets) c;
|
||||
|
||||
action count(bit<32> index) {
|
||||
//increment counter at index
|
||||
c.count(index);
|
||||
}
|
||||
|
||||
// registers
|
||||
register<bit<48>>(16384) r;
|
||||
|
||||
action ipg(out bit<48> ival, bit<32> x) {
|
||||
bit<48> last;
|
||||
bit<48> now;
|
||||
r.read(last, x);
|
||||
now = std_meta.ingress_global_timestamp;
|
||||
ival = now - last;
|
||||
r.write(x, now);
|
||||
}
|
||||
Reference in New Issue
Block a user