1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | function verilog(hljs) {
|
10 | const regex = hljs.regex;
|
11 | const KEYWORDS = {
|
12 | $pattern: /\$?[\w]+(\$[\w]+)*/,
|
13 | keyword: [
|
14 | "accept_on",
|
15 | "alias",
|
16 | "always",
|
17 | "always_comb",
|
18 | "always_ff",
|
19 | "always_latch",
|
20 | "and",
|
21 | "assert",
|
22 | "assign",
|
23 | "assume",
|
24 | "automatic",
|
25 | "before",
|
26 | "begin",
|
27 | "bind",
|
28 | "bins",
|
29 | "binsof",
|
30 | "bit",
|
31 | "break",
|
32 | "buf|0",
|
33 | "bufif0",
|
34 | "bufif1",
|
35 | "byte",
|
36 | "case",
|
37 | "casex",
|
38 | "casez",
|
39 | "cell",
|
40 | "chandle",
|
41 | "checker",
|
42 | "class",
|
43 | "clocking",
|
44 | "cmos",
|
45 | "config",
|
46 | "const",
|
47 | "constraint",
|
48 | "context",
|
49 | "continue",
|
50 | "cover",
|
51 | "covergroup",
|
52 | "coverpoint",
|
53 | "cross",
|
54 | "deassign",
|
55 | "default",
|
56 | "defparam",
|
57 | "design",
|
58 | "disable",
|
59 | "dist",
|
60 | "do",
|
61 | "edge",
|
62 | "else",
|
63 | "end",
|
64 | "endcase",
|
65 | "endchecker",
|
66 | "endclass",
|
67 | "endclocking",
|
68 | "endconfig",
|
69 | "endfunction",
|
70 | "endgenerate",
|
71 | "endgroup",
|
72 | "endinterface",
|
73 | "endmodule",
|
74 | "endpackage",
|
75 | "endprimitive",
|
76 | "endprogram",
|
77 | "endproperty",
|
78 | "endspecify",
|
79 | "endsequence",
|
80 | "endtable",
|
81 | "endtask",
|
82 | "enum",
|
83 | "event",
|
84 | "eventually",
|
85 | "expect",
|
86 | "export",
|
87 | "extends",
|
88 | "extern",
|
89 | "final",
|
90 | "first_match",
|
91 | "for",
|
92 | "force",
|
93 | "foreach",
|
94 | "forever",
|
95 | "fork",
|
96 | "forkjoin",
|
97 | "function",
|
98 | "generate|5",
|
99 | "genvar",
|
100 | "global",
|
101 | "highz0",
|
102 | "highz1",
|
103 | "if",
|
104 | "iff",
|
105 | "ifnone",
|
106 | "ignore_bins",
|
107 | "illegal_bins",
|
108 | "implements",
|
109 | "implies",
|
110 | "import",
|
111 | "incdir",
|
112 | "include",
|
113 | "initial",
|
114 | "inout",
|
115 | "input",
|
116 | "inside",
|
117 | "instance",
|
118 | "int",
|
119 | "integer",
|
120 | "interconnect",
|
121 | "interface",
|
122 | "intersect",
|
123 | "join",
|
124 | "join_any",
|
125 | "join_none",
|
126 | "large",
|
127 | "let",
|
128 | "liblist",
|
129 | "library",
|
130 | "local",
|
131 | "localparam",
|
132 | "logic",
|
133 | "longint",
|
134 | "macromodule",
|
135 | "matches",
|
136 | "medium",
|
137 | "modport",
|
138 | "module",
|
139 | "nand",
|
140 | "negedge",
|
141 | "nettype",
|
142 | "new",
|
143 | "nexttime",
|
144 | "nmos",
|
145 | "nor",
|
146 | "noshowcancelled",
|
147 | "not",
|
148 | "notif0",
|
149 | "notif1",
|
150 | "or",
|
151 | "output",
|
152 | "package",
|
153 | "packed",
|
154 | "parameter",
|
155 | "pmos",
|
156 | "posedge",
|
157 | "primitive",
|
158 | "priority",
|
159 | "program",
|
160 | "property",
|
161 | "protected",
|
162 | "pull0",
|
163 | "pull1",
|
164 | "pulldown",
|
165 | "pullup",
|
166 | "pulsestyle_ondetect",
|
167 | "pulsestyle_onevent",
|
168 | "pure",
|
169 | "rand",
|
170 | "randc",
|
171 | "randcase",
|
172 | "randsequence",
|
173 | "rcmos",
|
174 | "real",
|
175 | "realtime",
|
176 | "ref",
|
177 | "reg",
|
178 | "reject_on",
|
179 | "release",
|
180 | "repeat",
|
181 | "restrict",
|
182 | "return",
|
183 | "rnmos",
|
184 | "rpmos",
|
185 | "rtran",
|
186 | "rtranif0",
|
187 | "rtranif1",
|
188 | "s_always",
|
189 | "s_eventually",
|
190 | "s_nexttime",
|
191 | "s_until",
|
192 | "s_until_with",
|
193 | "scalared",
|
194 | "sequence",
|
195 | "shortint",
|
196 | "shortreal",
|
197 | "showcancelled",
|
198 | "signed",
|
199 | "small",
|
200 | "soft",
|
201 | "solve",
|
202 | "specify",
|
203 | "specparam",
|
204 | "static",
|
205 | "string",
|
206 | "strong",
|
207 | "strong0",
|
208 | "strong1",
|
209 | "struct",
|
210 | "super",
|
211 | "supply0",
|
212 | "supply1",
|
213 | "sync_accept_on",
|
214 | "sync_reject_on",
|
215 | "table",
|
216 | "tagged",
|
217 | "task",
|
218 | "this",
|
219 | "throughout",
|
220 | "time",
|
221 | "timeprecision",
|
222 | "timeunit",
|
223 | "tran",
|
224 | "tranif0",
|
225 | "tranif1",
|
226 | "tri",
|
227 | "tri0",
|
228 | "tri1",
|
229 | "triand",
|
230 | "trior",
|
231 | "trireg",
|
232 | "type",
|
233 | "typedef",
|
234 | "union",
|
235 | "unique",
|
236 | "unique0",
|
237 | "unsigned",
|
238 | "until",
|
239 | "until_with",
|
240 | "untyped",
|
241 | "use",
|
242 | "uwire",
|
243 | "var",
|
244 | "vectored",
|
245 | "virtual",
|
246 | "void",
|
247 | "wait",
|
248 | "wait_order",
|
249 | "wand",
|
250 | "weak",
|
251 | "weak0",
|
252 | "weak1",
|
253 | "while",
|
254 | "wildcard",
|
255 | "wire",
|
256 | "with",
|
257 | "within",
|
258 | "wor",
|
259 | "xnor",
|
260 | "xor"
|
261 | ],
|
262 | literal: [ 'null' ],
|
263 | built_in: [
|
264 | "$finish",
|
265 | "$stop",
|
266 | "$exit",
|
267 | "$fatal",
|
268 | "$error",
|
269 | "$warning",
|
270 | "$info",
|
271 | "$realtime",
|
272 | "$time",
|
273 | "$printtimescale",
|
274 | "$bitstoreal",
|
275 | "$bitstoshortreal",
|
276 | "$itor",
|
277 | "$signed",
|
278 | "$cast",
|
279 | "$bits",
|
280 | "$stime",
|
281 | "$timeformat",
|
282 | "$realtobits",
|
283 | "$shortrealtobits",
|
284 | "$rtoi",
|
285 | "$unsigned",
|
286 | "$asserton",
|
287 | "$assertkill",
|
288 | "$assertpasson",
|
289 | "$assertfailon",
|
290 | "$assertnonvacuouson",
|
291 | "$assertoff",
|
292 | "$assertcontrol",
|
293 | "$assertpassoff",
|
294 | "$assertfailoff",
|
295 | "$assertvacuousoff",
|
296 | "$isunbounded",
|
297 | "$sampled",
|
298 | "$fell",
|
299 | "$changed",
|
300 | "$past_gclk",
|
301 | "$fell_gclk",
|
302 | "$changed_gclk",
|
303 | "$rising_gclk",
|
304 | "$steady_gclk",
|
305 | "$coverage_control",
|
306 | "$coverage_get",
|
307 | "$coverage_save",
|
308 | "$set_coverage_db_name",
|
309 | "$rose",
|
310 | "$stable",
|
311 | "$past",
|
312 | "$rose_gclk",
|
313 | "$stable_gclk",
|
314 | "$future_gclk",
|
315 | "$falling_gclk",
|
316 | "$changing_gclk",
|
317 | "$display",
|
318 | "$coverage_get_max",
|
319 | "$coverage_merge",
|
320 | "$get_coverage",
|
321 | "$load_coverage_db",
|
322 | "$typename",
|
323 | "$unpacked_dimensions",
|
324 | "$left",
|
325 | "$low",
|
326 | "$increment",
|
327 | "$clog2",
|
328 | "$ln",
|
329 | "$log10",
|
330 | "$exp",
|
331 | "$sqrt",
|
332 | "$pow",
|
333 | "$floor",
|
334 | "$ceil",
|
335 | "$sin",
|
336 | "$cos",
|
337 | "$tan",
|
338 | "$countbits",
|
339 | "$onehot",
|
340 | "$isunknown",
|
341 | "$fatal",
|
342 | "$warning",
|
343 | "$dimensions",
|
344 | "$right",
|
345 | "$high",
|
346 | "$size",
|
347 | "$asin",
|
348 | "$acos",
|
349 | "$atan",
|
350 | "$atan2",
|
351 | "$hypot",
|
352 | "$sinh",
|
353 | "$cosh",
|
354 | "$tanh",
|
355 | "$asinh",
|
356 | "$acosh",
|
357 | "$atanh",
|
358 | "$countones",
|
359 | "$onehot0",
|
360 | "$error",
|
361 | "$info",
|
362 | "$random",
|
363 | "$dist_chi_square",
|
364 | "$dist_erlang",
|
365 | "$dist_exponential",
|
366 | "$dist_normal",
|
367 | "$dist_poisson",
|
368 | "$dist_t",
|
369 | "$dist_uniform",
|
370 | "$q_initialize",
|
371 | "$q_remove",
|
372 | "$q_exam",
|
373 | "$async$and$array",
|
374 | "$async$nand$array",
|
375 | "$async$or$array",
|
376 | "$async$nor$array",
|
377 | "$sync$and$array",
|
378 | "$sync$nand$array",
|
379 | "$sync$or$array",
|
380 | "$sync$nor$array",
|
381 | "$q_add",
|
382 | "$q_full",
|
383 | "$psprintf",
|
384 | "$async$and$plane",
|
385 | "$async$nand$plane",
|
386 | "$async$or$plane",
|
387 | "$async$nor$plane",
|
388 | "$sync$and$plane",
|
389 | "$sync$nand$plane",
|
390 | "$sync$or$plane",
|
391 | "$sync$nor$plane",
|
392 | "$system",
|
393 | "$display",
|
394 | "$displayb",
|
395 | "$displayh",
|
396 | "$displayo",
|
397 | "$strobe",
|
398 | "$strobeb",
|
399 | "$strobeh",
|
400 | "$strobeo",
|
401 | "$write",
|
402 | "$readmemb",
|
403 | "$readmemh",
|
404 | "$writememh",
|
405 | "$value$plusargs",
|
406 | "$dumpvars",
|
407 | "$dumpon",
|
408 | "$dumplimit",
|
409 | "$dumpports",
|
410 | "$dumpportson",
|
411 | "$dumpportslimit",
|
412 | "$writeb",
|
413 | "$writeh",
|
414 | "$writeo",
|
415 | "$monitor",
|
416 | "$monitorb",
|
417 | "$monitorh",
|
418 | "$monitoro",
|
419 | "$writememb",
|
420 | "$dumpfile",
|
421 | "$dumpoff",
|
422 | "$dumpall",
|
423 | "$dumpflush",
|
424 | "$dumpportsoff",
|
425 | "$dumpportsall",
|
426 | "$dumpportsflush",
|
427 | "$fclose",
|
428 | "$fdisplay",
|
429 | "$fdisplayb",
|
430 | "$fdisplayh",
|
431 | "$fdisplayo",
|
432 | "$fstrobe",
|
433 | "$fstrobeb",
|
434 | "$fstrobeh",
|
435 | "$fstrobeo",
|
436 | "$swrite",
|
437 | "$swriteb",
|
438 | "$swriteh",
|
439 | "$swriteo",
|
440 | "$fscanf",
|
441 | "$fread",
|
442 | "$fseek",
|
443 | "$fflush",
|
444 | "$feof",
|
445 | "$fopen",
|
446 | "$fwrite",
|
447 | "$fwriteb",
|
448 | "$fwriteh",
|
449 | "$fwriteo",
|
450 | "$fmonitor",
|
451 | "$fmonitorb",
|
452 | "$fmonitorh",
|
453 | "$fmonitoro",
|
454 | "$sformat",
|
455 | "$sformatf",
|
456 | "$fgetc",
|
457 | "$ungetc",
|
458 | "$fgets",
|
459 | "$sscanf",
|
460 | "$rewind",
|
461 | "$ftell",
|
462 | "$ferror"
|
463 | ]
|
464 | };
|
465 | const BUILT_IN_CONSTANTS = [
|
466 | "__FILE__",
|
467 | "__LINE__"
|
468 | ];
|
469 | const DIRECTIVES = [
|
470 | "begin_keywords",
|
471 | "celldefine",
|
472 | "default_nettype",
|
473 | "default_decay_time",
|
474 | "default_trireg_strength",
|
475 | "define",
|
476 | "delay_mode_distributed",
|
477 | "delay_mode_path",
|
478 | "delay_mode_unit",
|
479 | "delay_mode_zero",
|
480 | "else",
|
481 | "elsif",
|
482 | "end_keywords",
|
483 | "endcelldefine",
|
484 | "endif",
|
485 | "ifdef",
|
486 | "ifndef",
|
487 | "include",
|
488 | "line",
|
489 | "nounconnected_drive",
|
490 | "pragma",
|
491 | "resetall",
|
492 | "timescale",
|
493 | "unconnected_drive",
|
494 | "undef",
|
495 | "undefineall"
|
496 | ];
|
497 |
|
498 | return {
|
499 | name: 'Verilog',
|
500 | aliases: [
|
501 | 'v',
|
502 | 'sv',
|
503 | 'svh'
|
504 | ],
|
505 | case_insensitive: false,
|
506 | keywords: KEYWORDS,
|
507 | contains: [
|
508 | hljs.C_BLOCK_COMMENT_MODE,
|
509 | hljs.C_LINE_COMMENT_MODE,
|
510 | hljs.QUOTE_STRING_MODE,
|
511 | {
|
512 | scope: 'number',
|
513 | contains: [ hljs.BACKSLASH_ESCAPE ],
|
514 | variants: [
|
515 | {
|
516 | begin: /\b((\d+'([bhodBHOD]))[0-9xzXZa-fA-F_]+)/
|
517 | },
|
518 | {
|
519 | begin: /\B(('([bhodBHOD]))[0-9xzXZa-fA-F_]+)/
|
520 | },
|
521 | {
|
522 | begin: /\b[0-9][0-9_]*/,
|
523 | relevance: 0
|
524 | }
|
525 | ]
|
526 | },
|
527 |
|
528 | {
|
529 | scope: 'variable',
|
530 | variants: [
|
531 | {
|
532 | begin: '#\\((?!parameter).+\\)'
|
533 | },
|
534 | {
|
535 | begin: '\\.\\w+',
|
536 | relevance: 0
|
537 | }
|
538 | ]
|
539 | },
|
540 | {
|
541 | scope: 'variable.constant',
|
542 | match: regex.concat(/`/, regex.either(...BUILT_IN_CONSTANTS)),
|
543 | },
|
544 | {
|
545 | scope: 'meta',
|
546 | begin: regex.concat(/`/, regex.either(...DIRECTIVES)),
|
547 | end: /$|\/\/|\/\*/,
|
548 | returnEnd: true,
|
549 | keywords: DIRECTIVES
|
550 | }
|
551 | ]
|
552 | };
|
553 | }
|
554 |
|
555 | export { verilog as default };
|