l0bsterssg

node.js static responsive blog post generator
Log | Files | Refs | README

verilog.js (6275B)


      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   var 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   return {
     71     name: 'Verilog',
     72     aliases: ['v', 'sv', 'svh'],
     73     case_insensitive: false,
     74     keywords: SV_KEYWORDS,
     75     contains: [
     76       hljs.C_BLOCK_COMMENT_MODE,
     77       hljs.C_LINE_COMMENT_MODE,
     78       hljs.QUOTE_STRING_MODE,
     79       {
     80         className: 'number',
     81         contains: [hljs.BACKSLASH_ESCAPE],
     82         variants: [
     83           {begin: '\\b((\\d+\'(b|h|o|d|B|H|O|D))[0-9xzXZa-fA-F_]+)'},
     84           {begin: '\\B((\'(b|h|o|d|B|H|O|D))[0-9xzXZa-fA-F_]+)'},
     85           {begin: '\\b([0-9_])+', relevance: 0}
     86         ]
     87       },
     88       /* parameters to instances */
     89       {
     90         className: 'variable',
     91         variants: [
     92           {begin: '#\\((?!parameter).+\\)'},
     93           {begin: '\\.\\w+', relevance: 0},
     94         ]
     95       },
     96       {
     97         className: 'meta',
     98         begin: '`', end: '$',
     99         keywords: {'meta-keyword': 'define __FILE__ ' +
    100           '__LINE__ begin_keywords celldefine default_nettype define ' +
    101           'else elsif end_keywords endcelldefine endif ifdef ifndef ' +
    102           'include line nounconnected_drive pragma resetall timescale ' +
    103           'unconnected_drive undef undefineall'},
    104         relevance: 0
    105       }
    106     ]
    107   }; // return
    108 }
    109 
    110 module.exports = verilog;