verilog.js 5.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. module.exports = function(hljs) {
  2. var SV_KEYWORDS = {
  3. keyword:
  4. 'accept_on alias always always_comb always_ff always_latch and assert assign ' +
  5. 'assume automatic before begin bind bins binsof bit break buf|0 bufif0 bufif1 ' +
  6. 'byte case casex casez cell chandle checker class clocking cmos config const ' +
  7. 'constraint context continue cover covergroup coverpoint cross deassign default ' +
  8. 'defparam design disable dist do edge else end endcase endchecker endclass ' +
  9. 'endclocking endconfig endfunction endgenerate endgroup endinterface endmodule ' +
  10. 'endpackage endprimitive endprogram endproperty endspecify endsequence endtable ' +
  11. 'endtask enum event eventually expect export extends extern final first_match for ' +
  12. 'force foreach forever fork forkjoin function generate|5 genvar global highz0 highz1 ' +
  13. 'if iff ifnone ignore_bins illegal_bins implements implies import incdir include ' +
  14. 'initial inout input inside instance int integer interconnect interface intersect ' +
  15. 'join join_any join_none large let liblist library local localparam logic longint ' +
  16. 'macromodule matches medium modport module nand negedge nettype new nexttime nmos ' +
  17. 'nor noshowcancelled not notif0 notif1 or output package packed parameter pmos ' +
  18. 'posedge primitive priority program property protected pull0 pull1 pulldown pullup ' +
  19. 'pulsestyle_ondetect pulsestyle_onevent pure rand randc randcase randsequence rcmos ' +
  20. 'real realtime ref reg reject_on release repeat restrict return rnmos rpmos rtran ' +
  21. 'rtranif0 rtranif1 s_always s_eventually s_nexttime s_until s_until_with scalared ' +
  22. 'sequence shortint shortreal showcancelled signed small soft solve specify specparam ' +
  23. 'static string strong strong0 strong1 struct super supply0 supply1 sync_accept_on ' +
  24. 'sync_reject_on table tagged task this throughout time timeprecision timeunit tran ' +
  25. 'tranif0 tranif1 tri tri0 tri1 triand trior trireg type typedef union unique unique0 ' +
  26. 'unsigned until until_with untyped use uwire var vectored virtual void wait wait_order ' +
  27. 'wand weak weak0 weak1 while wildcard wire with within wor xnor xor',
  28. literal:
  29. 'null',
  30. built_in:
  31. '$finish $stop $exit $fatal $error $warning $info $realtime $time $printtimescale ' +
  32. '$bitstoreal $bitstoshortreal $itor $signed $cast $bits $stime $timeformat ' +
  33. '$realtobits $shortrealtobits $rtoi $unsigned $asserton $assertkill $assertpasson ' +
  34. '$assertfailon $assertnonvacuouson $assertoff $assertcontrol $assertpassoff ' +
  35. '$assertfailoff $assertvacuousoff $isunbounded $sampled $fell $changed $past_gclk ' +
  36. '$fell_gclk $changed_gclk $rising_gclk $steady_gclk $coverage_control ' +
  37. '$coverage_get $coverage_save $set_coverage_db_name $rose $stable $past ' +
  38. '$rose_gclk $stable_gclk $future_gclk $falling_gclk $changing_gclk $display ' +
  39. '$coverage_get_max $coverage_merge $get_coverage $load_coverage_db $typename ' +
  40. '$unpacked_dimensions $left $low $increment $clog2 $ln $log10 $exp $sqrt $pow ' +
  41. '$floor $ceil $sin $cos $tan $countbits $onehot $isunknown $fatal $warning ' +
  42. '$dimensions $right $high $size $asin $acos $atan $atan2 $hypot $sinh $cosh ' +
  43. '$tanh $asinh $acosh $atanh $countones $onehot0 $error $info $random ' +
  44. '$dist_chi_square $dist_erlang $dist_exponential $dist_normal $dist_poisson ' +
  45. '$dist_t $dist_uniform $q_initialize $q_remove $q_exam $async$and$array ' +
  46. '$async$nand$array $async$or$array $async$nor$array $sync$and$array ' +
  47. '$sync$nand$array $sync$or$array $sync$nor$array $q_add $q_full $psprintf ' +
  48. '$async$and$plane $async$nand$plane $async$or$plane $async$nor$plane ' +
  49. '$sync$and$plane $sync$nand$plane $sync$or$plane $sync$nor$plane $system ' +
  50. '$display $displayb $displayh $displayo $strobe $strobeb $strobeh $strobeo ' +
  51. '$write $readmemb $readmemh $writememh $value$plusargs ' +
  52. '$dumpvars $dumpon $dumplimit $dumpports $dumpportson $dumpportslimit ' +
  53. '$writeb $writeh $writeo $monitor $monitorb $monitorh $monitoro $writememb ' +
  54. '$dumpfile $dumpoff $dumpall $dumpflush $dumpportsoff $dumpportsall ' +
  55. '$dumpportsflush $fclose $fdisplay $fdisplayb $fdisplayh $fdisplayo ' +
  56. '$fstrobe $fstrobeb $fstrobeh $fstrobeo $swrite $swriteb $swriteh ' +
  57. '$swriteo $fscanf $fread $fseek $fflush $feof $fopen $fwrite $fwriteb ' +
  58. '$fwriteh $fwriteo $fmonitor $fmonitorb $fmonitorh $fmonitoro $sformat ' +
  59. '$sformatf $fgetc $ungetc $fgets $sscanf $rewind $ftell $ferror'
  60. };
  61. return {
  62. aliases: ['v', 'sv', 'svh'],
  63. case_insensitive: false,
  64. keywords: SV_KEYWORDS, lexemes: /[\w\$]+/,
  65. contains: [
  66. hljs.C_BLOCK_COMMENT_MODE,
  67. hljs.C_LINE_COMMENT_MODE,
  68. hljs.QUOTE_STRING_MODE,
  69. {
  70. className: 'number',
  71. contains: [hljs.BACKSLASH_ESCAPE],
  72. variants: [
  73. {begin: '\\b((\\d+\'(b|h|o|d|B|H|O|D))[0-9xzXZa-fA-F_]+)'},
  74. {begin: '\\B((\'(b|h|o|d|B|H|O|D))[0-9xzXZa-fA-F_]+)'},
  75. {begin: '\\b([0-9_])+', relevance: 0}
  76. ]
  77. },
  78. /* parameters to instances */
  79. {
  80. className: 'variable',
  81. variants: [
  82. {begin: '#\\((?!parameter).+\\)'},
  83. {begin: '\\.\\w+', relevance: 0},
  84. ]
  85. },
  86. {
  87. className: 'meta',
  88. begin: '`', end: '$',
  89. keywords: {'meta-keyword': 'define __FILE__ ' +
  90. '__LINE__ begin_keywords celldefine default_nettype define ' +
  91. 'else elsif end_keywords endcelldefine endif ifdef ifndef ' +
  92. 'include line nounconnected_drive pragma resetall timescale ' +
  93. 'unconnected_drive undef undefineall'},
  94. relevance: 0
  95. }
  96. ]
  97. }; // return
  98. };