Adding P4 cheat cheet and its latex source files. (#201)
This commit is contained in:
21
utils/cheat_sheet_src/src/header_stack.txt
Normal file
21
utils/cheat_sheet_src/src/header_stack.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
// header stack declaration
|
||||
header label_t {
|
||||
bit<20> label;
|
||||
bit bos;
|
||||
}
|
||||
struct header_t {
|
||||
label_t[10] labels;
|
||||
}
|
||||
header_t hdr;
|
||||
|
||||
// remove from header stack
|
||||
action pop_label() {
|
||||
hdr.labels.pop_front(1);
|
||||
}
|
||||
|
||||
// add to header stack
|
||||
action push_label(in bit<20> label) {
|
||||
hdr.labels.push_front(1);
|
||||
hdr.labels[0].setValid();
|
||||
hdr.labels[0] = { label, 0};
|
||||
}
|
||||
Reference in New Issue
Block a user