123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550 |
- /*
- Language: Verilog
- Author: Jon Evans <jon@craftyjon.com>
- Contributors: Boone Severson <boone.severson@gmail.com>
- 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.
- Website: http://www.verilog.com
- Category: hardware
- */
- function verilog(hljs) {
- const regex = hljs.regex;
- const KEYWORDS = {
- $pattern: /\$?[\w]+(\$[\w]+)*/,
- keyword: [
- "accept_on",
- "alias",
- "always",
- "always_comb",
- "always_ff",
- "always_latch",
- "and",
- "assert",
- "assign",
- "assume",
- "automatic",
- "before",
- "begin",
- "bind",
- "bins",
- "binsof",
- "bit",
- "break",
- "buf|0",
- "bufif0",
- "bufif1",
- "byte",
- "case",
- "casex",
- "casez",
- "cell",
- "chandle",
- "checker",
- "class",
- "clocking",
- "cmos",
- "config",
- "const",
- "constraint",
- "context",
- "continue",
- "cover",
- "covergroup",
- "coverpoint",
- "cross",
- "deassign",
- "default",
- "defparam",
- "design",
- "disable",
- "dist",
- "do",
- "edge",
- "else",
- "end",
- "endcase",
- "endchecker",
- "endclass",
- "endclocking",
- "endconfig",
- "endfunction",
- "endgenerate",
- "endgroup",
- "endinterface",
- "endmodule",
- "endpackage",
- "endprimitive",
- "endprogram",
- "endproperty",
- "endspecify",
- "endsequence",
- "endtable",
- "endtask",
- "enum",
- "event",
- "eventually",
- "expect",
- "export",
- "extends",
- "extern",
- "final",
- "first_match",
- "for",
- "force",
- "foreach",
- "forever",
- "fork",
- "forkjoin",
- "function",
- "generate|5",
- "genvar",
- "global",
- "highz0",
- "highz1",
- "if",
- "iff",
- "ifnone",
- "ignore_bins",
- "illegal_bins",
- "implements",
- "implies",
- "import",
- "incdir",
- "include",
- "initial",
- "inout",
- "input",
- "inside",
- "instance",
- "int",
- "integer",
- "interconnect",
- "interface",
- "intersect",
- "join",
- "join_any",
- "join_none",
- "large",
- "let",
- "liblist",
- "library",
- "local",
- "localparam",
- "logic",
- "longint",
- "macromodule",
- "matches",
- "medium",
- "modport",
- "module",
- "nand",
- "negedge",
- "nettype",
- "new",
- "nexttime",
- "nmos",
- "nor",
- "noshowcancelled",
- "not",
- "notif0",
- "notif1",
- "or",
- "output",
- "package",
- "packed",
- "parameter",
- "pmos",
- "posedge",
- "primitive",
- "priority",
- "program",
- "property",
- "protected",
- "pull0",
- "pull1",
- "pulldown",
- "pullup",
- "pulsestyle_ondetect",
- "pulsestyle_onevent",
- "pure",
- "rand",
- "randc",
- "randcase",
- "randsequence",
- "rcmos",
- "real",
- "realtime",
- "ref",
- "reg",
- "reject_on",
- "release",
- "repeat",
- "restrict",
- "return",
- "rnmos",
- "rpmos",
- "rtran",
- "rtranif0",
- "rtranif1",
- "s_always",
- "s_eventually",
- "s_nexttime",
- "s_until",
- "s_until_with",
- "scalared",
- "sequence",
- "shortint",
- "shortreal",
- "showcancelled",
- "signed",
- "small",
- "soft",
- "solve",
- "specify",
- "specparam",
- "static",
- "string",
- "strong",
- "strong0",
- "strong1",
- "struct",
- "super",
- "supply0",
- "supply1",
- "sync_accept_on",
- "sync_reject_on",
- "table",
- "tagged",
- "task",
- "this",
- "throughout",
- "time",
- "timeprecision",
- "timeunit",
- "tran",
- "tranif0",
- "tranif1",
- "tri",
- "tri0",
- "tri1",
- "triand",
- "trior",
- "trireg",
- "type",
- "typedef",
- "union",
- "unique",
- "unique0",
- "unsigned",
- "until",
- "until_with",
- "untyped",
- "use",
- "uwire",
- "var",
- "vectored",
- "virtual",
- "void",
- "wait",
- "wait_order",
- "wand",
- "weak",
- "weak0",
- "weak1",
- "while",
- "wildcard",
- "wire",
- "with",
- "within",
- "wor",
- "xnor",
- "xor"
- ],
- literal: [ 'null' ],
- built_in: [
- "$finish",
- "$stop",
- "$exit",
- "$fatal",
- "$error",
- "$warning",
- "$info",
- "$realtime",
- "$time",
- "$printtimescale",
- "$bitstoreal",
- "$bitstoshortreal",
- "$itor",
- "$signed",
- "$cast",
- "$bits",
- "$stime",
- "$timeformat",
- "$realtobits",
- "$shortrealtobits",
- "$rtoi",
- "$unsigned",
- "$asserton",
- "$assertkill",
- "$assertpasson",
- "$assertfailon",
- "$assertnonvacuouson",
- "$assertoff",
- "$assertcontrol",
- "$assertpassoff",
- "$assertfailoff",
- "$assertvacuousoff",
- "$isunbounded",
- "$sampled",
- "$fell",
- "$changed",
- "$past_gclk",
- "$fell_gclk",
- "$changed_gclk",
- "$rising_gclk",
- "$steady_gclk",
- "$coverage_control",
- "$coverage_get",
- "$coverage_save",
- "$set_coverage_db_name",
- "$rose",
- "$stable",
- "$past",
- "$rose_gclk",
- "$stable_gclk",
- "$future_gclk",
- "$falling_gclk",
- "$changing_gclk",
- "$display",
- "$coverage_get_max",
- "$coverage_merge",
- "$get_coverage",
- "$load_coverage_db",
- "$typename",
- "$unpacked_dimensions",
- "$left",
- "$low",
- "$increment",
- "$clog2",
- "$ln",
- "$log10",
- "$exp",
- "$sqrt",
- "$pow",
- "$floor",
- "$ceil",
- "$sin",
- "$cos",
- "$tan",
- "$countbits",
- "$onehot",
- "$isunknown",
- "$fatal",
- "$warning",
- "$dimensions",
- "$right",
- "$high",
- "$size",
- "$asin",
- "$acos",
- "$atan",
- "$atan2",
- "$hypot",
- "$sinh",
- "$cosh",
- "$tanh",
- "$asinh",
- "$acosh",
- "$atanh",
- "$countones",
- "$onehot0",
- "$error",
- "$info",
- "$random",
- "$dist_chi_square",
- "$dist_erlang",
- "$dist_exponential",
- "$dist_normal",
- "$dist_poisson",
- "$dist_t",
- "$dist_uniform",
- "$q_initialize",
- "$q_remove",
- "$q_exam",
- "$async$and$array",
- "$async$nand$array",
- "$async$or$array",
- "$async$nor$array",
- "$sync$and$array",
- "$sync$nand$array",
- "$sync$or$array",
- "$sync$nor$array",
- "$q_add",
- "$q_full",
- "$psprintf",
- "$async$and$plane",
- "$async$nand$plane",
- "$async$or$plane",
- "$async$nor$plane",
- "$sync$and$plane",
- "$sync$nand$plane",
- "$sync$or$plane",
- "$sync$nor$plane",
- "$system",
- "$display",
- "$displayb",
- "$displayh",
- "$displayo",
- "$strobe",
- "$strobeb",
- "$strobeh",
- "$strobeo",
- "$write",
- "$readmemb",
- "$readmemh",
- "$writememh",
- "$value$plusargs",
- "$dumpvars",
- "$dumpon",
- "$dumplimit",
- "$dumpports",
- "$dumpportson",
- "$dumpportslimit",
- "$writeb",
- "$writeh",
- "$writeo",
- "$monitor",
- "$monitorb",
- "$monitorh",
- "$monitoro",
- "$writememb",
- "$dumpfile",
- "$dumpoff",
- "$dumpall",
- "$dumpflush",
- "$dumpportsoff",
- "$dumpportsall",
- "$dumpportsflush",
- "$fclose",
- "$fdisplay",
- "$fdisplayb",
- "$fdisplayh",
- "$fdisplayo",
- "$fstrobe",
- "$fstrobeb",
- "$fstrobeh",
- "$fstrobeo",
- "$swrite",
- "$swriteb",
- "$swriteh",
- "$swriteo",
- "$fscanf",
- "$fread",
- "$fseek",
- "$fflush",
- "$feof",
- "$fopen",
- "$fwrite",
- "$fwriteb",
- "$fwriteh",
- "$fwriteo",
- "$fmonitor",
- "$fmonitorb",
- "$fmonitorh",
- "$fmonitoro",
- "$sformat",
- "$sformatf",
- "$fgetc",
- "$ungetc",
- "$fgets",
- "$sscanf",
- "$rewind",
- "$ftell",
- "$ferror"
- ]
- };
- const BUILT_IN_CONSTANTS = [
- "__FILE__",
- "__LINE__"
- ];
- const DIRECTIVES = [
- "begin_keywords",
- "celldefine",
- "default_nettype",
- "default_decay_time",
- "default_trireg_strength",
- "define",
- "delay_mode_distributed",
- "delay_mode_path",
- "delay_mode_unit",
- "delay_mode_zero",
- "else",
- "elsif",
- "end_keywords",
- "endcelldefine",
- "endif",
- "ifdef",
- "ifndef",
- "include",
- "line",
- "nounconnected_drive",
- "pragma",
- "resetall",
- "timescale",
- "unconnected_drive",
- "undef",
- "undefineall"
- ];
- return {
- name: 'Verilog',
- aliases: [
- 'v',
- 'sv',
- 'svh'
- ],
- case_insensitive: false,
- keywords: KEYWORDS,
- contains: [
- hljs.C_BLOCK_COMMENT_MODE,
- hljs.C_LINE_COMMENT_MODE,
- hljs.QUOTE_STRING_MODE,
- {
- scope: 'number',
- contains: [ hljs.BACKSLASH_ESCAPE ],
- variants: [
- { begin: /\b((\d+'([bhodBHOD]))[0-9xzXZa-fA-F_]+)/ },
- { begin: /\B(('([bhodBHOD]))[0-9xzXZa-fA-F_]+)/ },
- { // decimal
- begin: /\b[0-9][0-9_]*/,
- relevance: 0
- }
- ]
- },
- /* parameters to instances */
- {
- scope: 'variable',
- variants: [
- { begin: '#\\((?!parameter).+\\)' },
- {
- begin: '\\.\\w+',
- relevance: 0
- }
- ]
- },
- {
- scope: 'variable.constant',
- match: regex.concat(/`/, regex.either(...BUILT_IN_CONSTANTS)),
- },
- {
- scope: 'meta',
- begin: regex.concat(/`/, regex.either(...DIRECTIVES)),
- end: /$|\/\/|\/\*/,
- returnEnd: true,
- keywords: DIRECTIVES
- }
- ]
- };
- }
- export { verilog as default };
|