-
Notifications
You must be signed in to change notification settings - Fork 1
/
assembly.p4
130 lines (112 loc) · 3.19 KB
/
assembly.p4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
const bit<8> PROTO_RAW_PROGRAM = 0x8F;
const bit<8> PROTO_PROGRAM = 0x90;
const bit<8> PROTO_STORE_REQUEST = 0x91;
const bit<8> PROTO_LOAD_REQUEST = 0x92;
const bit<8> PROTO_LOAD_RESPONSE = 0x93;
const bit<32> NUM_REGISTERS = 32;
const bit<32> MAX_INSNS = 300;
// Load balancer is always connected to all execution units via port 1
const bit<9> LOAD_BALANCER_PORT = 1;
// Data store is always connected to all execution units via port 2
const bit<9> DATASTORE_PORT = 2;
// Data store host is always connected to the data store switch via port 1
const bit<9> DATASTORE_HOST_PORT = 1;
const bit<48> LOAD_BALANCER_MAC = 0x0000FF000000;
const bit<32> LOAD_BALANCER_IP = 0x0AFFFF00;
const bit<48> DATASTORE_MAC = 0x0000FF000001;
const bit<32> DATASTORE_IP = 0x0AFFFF01;
/*******************************************************************************
*********************** M E T A D A T A ****************************************
*******************************************************************************/
header register_t {
bit<32> value;
}
header program_metadata_t {
bit<32> max_steps;
}
header program_execution_metadata_t {
// Ingress port to the load balancer from the source host
bit<9> src_port;
// Padding to make header byte-aligned
bit<7> reserved;
// MAC address of the source host
bit<48> src_mac;
// IPv4 address of the source host
bit<32> src_ipv4;
bit<32> pc;
bit<32> steps;
bit<32> mem_namespace;
}
header store_request_metadata_t {
bit<32> address;
bit<32> value;
// ID of the requesting execution node
bit<32> execution_node;
}
header load_request_metadata_t {
bit<32> address;
bit<5> register;
// Padding to make header byte-aligned
bit<3> reserved;
// ID of the requesting execution node
bit<32> execution_node;
}
header load_response_metadata_t {
bit<32> value;
bit<5> register;
// Padding to make header byte-aligned
bit<3> reserved;
// ID of the requesting execution node
bit<32> execution_node;
}
/*******************************************************************************
*********************** A S S E M B L Y ****************************************
*******************************************************************************/
header insn_unparsed_t {
bit<32> encoded;
}
header insn_unknown_t {
bit<7> funct7;
bit<5> part1;
bit<5> part2;
bit<3> funct3;
bit<5> part3;
bit<7> opcode;
}
header insn_rtype_t {
bit<7> funct7;
bit<5> rs2;
bit<5> rs1;
bit<3> funct3;
bit<5> rd;
bit<7> opcode;
}
header insn_itype_t {
bit<12> imm;
bit<5> rs1;
bit<3> funct3;
bit<5> rd;
bit<7> opcode;
}
header insn_stype_t {
bit<7> imm_upper;
bit<5> rs2;
bit<5> rs1;
bit<3> funct3;
bit<5> imm_lower;
bit<7> opcode;
}
header insn_utype_t {
bit<20> imm;
bit<5> rd;
bit<7> opcode;
}
// header_union is not fully supported in P4lang
// Specifically, we cannot create a header_union stack in a struct
header_union insn_t {
insn_rtype_t rtype;
insn_itype_t itype;
insn_stype_t stype;
insn_utype_t utype;
insn_unknown_t unknown;
}