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