-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmint.g4
More file actions
executable file
·224 lines (152 loc) · 4.65 KB
/
mint.g4
File metadata and controls
executable file
·224 lines (152 loc) · 4.65 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*
* krishna
*/
grammar mint;
netlist: importBlock? header ufmoduleBlock? layerBlocks EOF;
importBlock: importStat+;
importStat: WS* 'IMPORT' WS+ ufmodulename;
header: WS* 'DEVICE' WS+ device_name = ID;
ufmoduleBlock: globalStats+;
globalStats: ufmoduleStat | viaStat;
ufmoduleStat: ufmodulename ufnames ';';
layerBlocks: layerBlock+;
layerBlock: flowBlock controlBlock? integrationBlock?;
flowBlock: WS* 'LAYER FLOW' (WS* flowStat)* WS* 'END LAYER';
controlBlock:
WS* 'LAYER CONTROL' (WS* controlStat)* WS* 'END LAYER';
integrationBlock:
'LAYER INTEGRATION' (integrationStat)* 'END LAYER';
flowStat:
primitiveStat
| nodeStat
| channelStat
| netStat
| bankDeclStat
| gridStat
| spanStat
| positionConstraintStat
| gridStat
| gridGenStat
| gridDeclStat
| bankStat
| bankGenStat
| bankDeclStat
| terminalStat;
controlStat:
valveStat
| channelStat
| netStat
| bankDeclStat
| bankStat
| bankGenStat
| gridStat
| gridGenStat
| primitiveStat
| nodeStat
| viaStat
| positionConstraintStat
| terminalStat;
integrationStat: primitiveStat | positionConstraintStat;
//Flow and Control Statements
primitiveStat: (orientation WS+)? entity WS+ ufnames (
WS+ paramsStat
)? statTerminaion;
bankDeclStat: (orientation WS+)? 'BANK' WS+ ufnames WS+ 'of' WS+ entity (
WS+ paramsStat
)? statTerminaion;
bankGenStat: (orientation WS+)? 'BANK' WS+ ufname WS+ 'of' WS+ dim = INT WS+ entity (
WS+ paramsStat
)? statTerminaion;
bankStat: (orientation WS+)? 'BANK' WS+ ufnames (WS+ paramsStat)? statTerminaion;
gridGenStat: (orientation WS+)? 'GRID' WS+ ufname WS+ 'of' WS+ xdim = INT WS* ',' WS* ydim = INT WS+
entity (WS+ paramsStat)? statTerminaion;
gridDeclStat: (orientation WS+)? 'GRID' WS+ ufnames WS+ 'of' WS+ xdim = INT WS* ',' WS* ydim = INT
WS+ entity (WS+ paramsStat)? statTerminaion;
gridStat: (orientation WS+)? 'GRID' WS+ ufnames WS+ 'of' WS+ xdim = INT WS* ',' WS* ydim = INT (
WS+ paramsStat
)? statTerminaion;
spanStat: (orientation WS+)? entity WS+ ufnames WS+ indim = INT WS+ 'to' WS+ outdim = INT (
WS+ paramsStat
)? statTerminaion;
valveStat:
entity WS+ ufname WS+ 'on' WS+ ufname (WS+ paramsStat)? statTerminaion;
nodeStat: 'NODE' WS+ ufnames statTerminaion;
viaStat: 'VIA' WS+ ufnames statTerminaion;
terminalStat:
'TERMINAL' WS+ ufname WS+ pin = INT statTerminaion;
channelStat: (entity | 'CHANNEL') WS+ ufname WS+ 'from' WS+ source = uftarget WS+ 'to' WS+ sink =
uftarget WS* (WS+ paramsStat)? statTerminaion;
netStat: (entity | 'NET' | 'CHANNEL') WS+ ufname WS+ 'from' WS+ source = uftarget WS+ 'to' WS+ sinks
= uftargets (WS+ paramsStat)? statTerminaion;
//Common Parser Rules
entity: entity_element (WS entity_element)*;
entity_element: ID_BIG;
paramsStat: (paramStat WS*)*;
statTerminaion: WS* ';' WS*;
//connectionParamStat
// : lengthParam | paramsStat ;
connectionParamStat: paramsStat;
paramStat:
intParam
| boolParam
| widthParam
| constraintParams
| lengthParam
| spacingParam
| idParam;
idParam: param_element WS* '=' WS* id_value;
id_value: ID | ID_BIG;
constraintParams:
rotationParam
| directionParam
| spacingParam
| lengthParam
| verticalSpacingParam
| horizontalSpacingParam;
spacingParam: 'spacing' WS* '=' WS* value;
directionParam:
'direction' '=' direction = (
'UP'
| 'DOWN'
| 'LEFT'
| 'RIGHT'
);
param_element: ID;
intParam: param_element WS* '=' WS* value;
boolParam: param_element WS* '=' WS* boolvalue;
widthParam:
key = 'width' WS* '=' WS* value
| key = 'w' WS* '=' WS* value;
verticalSpacingParam: 'verticalSpacing' WS* '=' WS* value;
horizontalSpacingParam: 'horizontalSpacing' WS* '=' WS* value;
rotationParam: 'rotation' WS* '=' WS* rotation = value;
lengthParam: 'length' WS* '=' WS* length = value;
ufmodulename: ID_BIG;
ufterminal: INT;
uftargets: uftarget WS* (',' WS* uftarget)+;
uftarget: target_name = (ID | ID_BIG) (WS+ target_terminal = INT)?;
ufname: (ID | ID_BIG);
ufnames: ufname WS* (',' WS* ufname)* WS*;
value: INT | Real_number;
boolvalue: 'YES' | 'NO';
//Constraints
positionConstraintStat: ufname WS+ 'SET' setCoordinate+ ';';
setCoordinate: WS+ coordinate = ('X' | 'Y' | 'Z') WS+ INT;
orientation: ('V' | 'H');
//Common Lexical Rules
ID: ('a' ..'z' | '_') (
'a' ..'z'
| 'A' ..'Z'
| '0' ..'9'
| '_'
)*;
ID_BIG: ('A' ..'Z' | '_') ('A' ..'Z' | 'a' ..'z' | '_' | '0' ..'9')*;
INT: [0-9]+; // Define token INT as one or more digits
WS: [ \t]+;
NL: [\r\n]+ -> skip; // Define whitespace rule, toss it out
COMMENT: '#' ~[\r\n]* -> skip;
Real_number:
Unsigned_number '.' Unsigned_number
| Unsigned_number ('.' Unsigned_number)? [eE] ([+-])? Unsigned_number;
fragment Unsigned_number: Decimal_digit ('_' | Decimal_digit)*;
fragment Decimal_digit: [0-9];