verilog.js 6.0 KB

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