1
###############################################################################
3
# Purpose: Configuration module for Verilog HDL language #
4
# Author: Cody Precord <cprecord@editra.org> #
5
# Copyright: (c) 2008 Cody Precord <staff@editra.org> #
6
# License: wxWindows License #
7
###############################################################################
12
@summary: Lexer configuration module for Verilog Hardware Description Language
13
and System Verilog programming languages. Much help in creating this
14
module from Tim Corcoran.
18
__author__ = "Cody Precord <cprecord@editra.org>"
19
__svnid__ = "$Id: _verilog.py 68798 2011-08-20 17:17:05Z CJP $"
20
__revision__ = "$Revision: 68798 $"
22
#-----------------------------------------------------------------------------#
30
#-----------------------------------------------------------------------------#
31
#TODO: What to do with preprocessors?
32
#TODO: What to do with standard methods?
34
#---- Keyword Definitions ----#
36
#==============================================================================
37
# IEEE 1364-1995 Verilog
38
#==============================================================================
39
# IEEE 1364-1995 Verilog Preprocessors
40
V_1364_1995_PREPROCESSORS = (
41
# 1364-1995 Section 14
42
"`celldefine `default_nettype `define `else `endcelldefine `endif `ifdef "
43
"`include `nounconnected_drive `resetall `timescale `unconnected_drive "
46
"`default_decay_time `default_trireg_strength `delay_mode_distributed "
47
"`delay_mode_path `delay_mode_unit `delay_mode_zero "
48
#1364-1995 Verilog Preprocessor Commercial Extensions
49
"`accelerate `autoexpand_vectornets `disable_portfaults `enable_portfaults "
50
"`endprotect `endprotected `expand_vectornets `noaccelerate "
51
"`noexpand_vectornets `noremove_gatenames `noremove_netnames "
52
"`nosuppress_faults `portcoerce `protect `protected "
53
"`remove_gatenames `remove_netnames `suppress_faults "
56
# IEEE 1364-1995 Verilog Keywords (NOT USED: attribute endattribute signed unsigned)
57
V_1364_1995_KEYWORDS = (
58
"always assign begin case casex casez deassign default defparam disable "
59
"edge else end endcase endfunction endmodule endprimitive endspecify "
60
"endtable endtask for force forever fork function if ifnone initial "
61
"inout input join macromodule module negedge output parameter posedge "
62
"primitive release repeat scalared specify specparam strength table task "
66
# IEEE 1364-1995 Verilog Types (NOT USED: xbuf)
68
"and buf bufif0 bufif1 cmos event highz0 highz1 integer large medium nand "
69
"nmos nor not notif0 notif1 or pmos pull0 pull1 pulldown pullup rcmos real "
70
"realtime reg rnmos rpmos rtran rtranif0 rtranif1 small strong0 strong1 "
71
"supply0 supply1 time tran tranif0 tranif1 tri tri0 tri1 triand trior "
72
"trireg wand weak0 weak1 wire wor xnor xor"
75
# IEEE 1364-1995 Verilog System Tasks and Functions
77
# 1364-1995 Section 14
78
"$async$and$array $async$and$plane $async$nand$array $async$nand$plane "
79
"$async$nor$array $async$nor$plane $async$or$array $async$or$plane "
80
"$bitstoreal $display $displayb $displayh $displayo $dist_chi_square "
81
"$dist_erlang $dist_exponential $dist_normal $dist_poisson $dist_t "
82
"$dist_uniform $dumpall $dumpfile $dumpflush $dumplimit $dumpoff $dumpon "
83
"$dumpvars $fclose $fdisplay $fdisplayb $fdisplayh $fdisplayo $finish "
84
"$fmonitor $fmonitorb $fmonitorh $fmonitoro $fopen $fstrobe $fstrobeb "
85
"$fstrobeh $fstrobeo $fwrite $fwriteb $fwriteh $fwriteo $hold $itor "
86
"$monitor $monitorb $monitorh $monitoro $monitoroff $monitoron $nochange "
87
"$period $printtimescale $q_add $q_exam $q_full $q_initialize $q_remove "
88
"$random $readmemb $readmemh $realtime $realtobits $recovery $rtoi $setup "
89
"$setuphold $skew $stime $stop $strobe $strobeb $strobeh $strobeo "
90
"$sync$and$array $sync$and$plane $sync$nand$array $sync$nand$plane "
91
"$sync$nor$array $sync$nor$plane $sync$or$array $sync$or$plane $time "
92
"$timeformat $width $write $writeb $writeh $writeo "
94
"$countdrivers $getpattern $incsave $input $key $list $log $nokey $nolog "
95
"$reset $reset_count $reset_value $restart $save $scale $scope $showscopes "
96
"$showvars $sreadmemb $sreadmemh"
99
#==============================================================================
100
# IEEE 1364-2001 Verilog
101
#==============================================================================
102
# IEEE 1364-2001 Verilog Preprocessors
103
V_1364_2001_PREPROCESSORS = (
104
"`elsif `ifndef `line"
107
# IEEE 1364-2001 Verilog Keywords
108
V_1364_2001_KEYWORDS = (
109
"automatic cell config design endconfig endgenerate generate genvar incdir "
110
"include instance liblist library localparam noshowcancelled "
111
"pulsestyle_ondetect pulsestyle_onevent showcancelled signed unsigned use"
114
# IEEE 1364-2001 Verilog Types
115
V_1364_2001_TYPES = (
119
# IEEE 1364-2001 Verilog System Tasks and Functions
120
V_1364_2001_TASKS = (
121
"$dumpports $dumpportsall $dumpportsflush $dumpportslimit $dumpportsoff "
122
"$dumpportson $ferror $fflush $fgetc $fgets $fread $fscanf $fseek $ftell "
123
"$rewind $sdf_annotate $sformat $signed $sscanf $swrite $swriteb $swriteh "
124
"$swriteo $test$plusargs $ungetc $unsigned $value$plusargs"
127
#==============================================================================
128
# IEEE 1364-2005 Verilog
129
#==============================================================================
130
# IEEE 1364-2005 Verilog Preprocessors
131
V_1364_2005_PREPROCESSORS = (
135
# IEEE 1364-2005 Verilog Keywords (NONE)
136
V_1364_2005_KEYWORDS = (
140
# IEEE 1364-2005 Verilog Types
141
V_1364_2005_TYPES = (
145
# IEEE 1364-2005 Verilog System Tasks and Functions (NONE)
146
V_1364_2005_TASKS = (
150
#VERILOG_PREPROCESSORS = " ".join([V_1364_1995_PREPROCESSORS, V_1364_2001_PREPROCESSORS, V_1364_2005_PREPROCESSORS])
151
#VERILOG_KEYWORDS = " ".join([V_1364_1995_KEYWORDS, V_1364_2001_KEYWORDS, V_1364_2005_KEYWORDS ])
152
#VERILOG_TYPES = " ".join([V_1364_1995_TYPES, V_1364_2001_TYPES, V_1364_2005_TYPES ])
153
#VERILOG_TASKS = " ".join([V_1364_1995_TASKS, V_1364_2001_TASKS, V_1364_2005_TASKS ])
155
# ---\/----- Overkill maybe? -----\/---
156
VERILOG_PREPROCESSORS = " ".join( [V_1364_1995_PREPROCESSORS,
157
V_1364_2001_PREPROCESSORS,
158
V_1364_2005_PREPROCESSORS] ).split()
159
VERILOG_PREPROCESSORS.sort()
160
VERILOG_PREPROCESSORS = " ".join( VERILOG_PREPROCESSORS )
162
VERILOG_KEYWORDS = " ".join( [V_1364_1995_KEYWORDS,
163
V_1364_2001_KEYWORDS,
164
V_1364_2005_KEYWORDS] ).split()
165
VERILOG_KEYWORDS.sort()
166
VERILOG_KEYWORDS = " ".join( VERILOG_KEYWORDS )
168
VERILOG_TYPES = " ".join( [V_1364_1995_TYPES,
170
V_1364_2005_TYPES] ).split()
172
VERILOG_TYPES = " ".join( VERILOG_TYPES )
174
VERILOG_TASKS = " ".join( [V_1364_1995_TASKS,
176
V_1364_2005_TASKS] ).split()
178
VERILOG_TASKS = " ".join( VERILOG_TASKS )
179
# ---/\----- Overkill maybe? -----/\---
181
#---- System Verilog Extensions ----#
183
#==============================================================================
184
# IEEE 1800-2005 SystemVerilog
185
#==============================================================================
186
# IEEE 1800-2005 SystemVerilog Preprocessors
187
SV_1800_2005_PREPROCESSORS = (
188
# One of "1800-2009" "1800-2005" "1364-2005" "1364-2001" "1364-2001-noconfig" "1364-1995"
189
"`begin_keywords `end_keywords"
192
# IEEE 1800-2005 SystemVerilog Keywords
193
SV_1800_2005_KEYWORDS = (
194
"alias always_comb always_ff always_latch assert assume before bind "
195
"bins binsof bit break constraint covergroup coverpoint class clocking const"
196
"context continue cover cross dist do endclass endclocking endgroup endinterface "
197
"endpackage endprogram endproperty endsequence expect export extends extern "
198
"final first_match foreach forkjoin iff ignore_bins illegal_bins import "
199
"inside interface intersect join_any join_none modport new null package "
200
"priority process program property pure randcase randsequence ref return "
201
"sequence solve super this throughout timeprecision timeunit type unique "
202
"wait_order wildcard with within "
203
"local packed protected static struct tagged typedef union virtual"
206
# IEEE 1800-2005 SystemVerilog Types
207
SV_1800_2005_TYPES = (
208
"byte chandle enum int logic longint rand randc shortint shortreal std "
211
# "local packed protected static struct tagged typedef union virtual"
214
# IEEE 1800-2005 SystemVerilog System Tasks and Functions
215
SV_1800_2005_TASKS = (
216
"$assertkill $assertoff $asserton $bits $countones $coverage_control "
217
"$coverage_get $coverage_get_max $coverage_merge $coverage_save "
218
"$dimensions $error $exit $fatal $fell $high $increment $info $isunbounded "
219
"$isunknown $left $low $onehot $onehot0 $psprintf $right $rose $sampled "
220
"$size $stable $typename $unpacked_dimensions $warning"
223
# IEEE 1800-2005 SystemVerilog Standard Methods
224
SV_1800_2005_METHODS = (
225
"and atobin atohex atoi atooct atoreal await back bintoa clear compare data "
226
"delete empty eq erase erase_range exists find find_first find_first_index "
227
"find_index find_last find_last_index finish first front get getc hextoa "
228
"icompare index insert insert_range itoa kill last len max min name neq new "
229
"next num octtoa or peek pop_back pop_front prev product purge push_back "
230
"push_front put putc rand_mode realtoa resume reverse rsort self set shuffle "
231
"size sort start status stop substr sum suspend swap tolower toupper try_get "
232
"try_peek try_put unique unique_index xor"
235
#==============================================================================
236
# IEEE 1800-2009 SystemVerilog
237
#==============================================================================
238
SV_1800_2009_PREPROCESSORS = (
239
"`__FILE__ `__LINE__ `undefineall"
242
# IEEE 1800-2009 SystemVerilog Keywords
243
SV_1800_2009_KEYWORDS = (
244
"accept_on checker endchecker eventually global implies let matches nexttime "
245
"reject_on restrict s_always s_eventually s_nexttime s_until s_until_with "
246
"sync_accept_on sync_reject_on unique0 until until_with untyped weak "
247
# 34.4 Protect pragma directives
249
"author author_info begin_protected comment data_block data_decrypt_key "
250
"data_keyname data_keyowner data_method data_public_key decrypt_license "
251
"digest_block digest_decrypt_key digest_key_method digest_keyname "
252
"digest_keyowner digest_method digest_public_key encoding encrypt_agent "
253
"encrypt_agent_info encrypt_license end_protected key_block key_keyname "
254
"key_keyowner key_method key_public_key reset runtime_license viewport"
257
# IEEE 1800-2009 SystemVerilog Types
258
SV_1800_2009_TYPES = (
259
# TODO: Are there new types?
263
# IEEE 1800-2009 SystemVerilog System Tasks and Functions
264
SV_1800_2009_TASKS = (
265
# Section 20.1 General
266
"$acos $acosh $asin $asinh $assertfailoff $assertfailon $assertnonvacuouson "
267
"$assertpassoff $assertpasson $assertvacuousoff $atan $atan2 $atanh "
268
"$bitstoshortreal $cast $ceil $changed $changed_gclk $changing_gclk $clog2 "
269
"$cos $cosh $exp $falling_gclk $fell_gclk $floor $future_gclk $get_coverage "
270
"$hypot $ln $load_coverage_db $log10 $past $past_gclk $pow $rising_gclk "
271
"$rose_gclk $set_coverage_db_name $sformatf $shortrealtobits $sin $sinh "
272
"$sqrt $stable_gclk $steady_gclk $system $tan $tanh"
275
# IEEE 1800-2009 SystemVerilog Standard Methods
276
SV_1800_2009_METHODS = (
277
# TODO: Add new methods
281
#SYSTEMVERILOG_PREPROCESSORS = " ".join( [VERILOG_PREPROCESSORS, SV_1800_2005_PREPROCESSORS, SV_1800_2009_PREPROCESSORS] )
282
#SYSTEMVERILOG_KEYWORDS = " ".join( [VERILOG_KEYWORDS, SV_1800_2005_KEYWORDS, SV_1800_2009_KEYWORDS ] )
283
#SYSTEMVERILOG_TYPES = " ".join( [VERILOG_TYPES, SV_1800_2005_TYPES, SV_1800_2009_TYPES ] )
284
#SYSTEMVERILOG_TASKS = " ".join( [VERILOG_TASKS, SV_1800_2005_TASKS, SV_1800_2009_TASKS ] )
286
# ---\/----- Overkill maybe? -----\/---
287
SYSTEMVERILOG_PREPROCESSORS = " ".join( [VERILOG_PREPROCESSORS,
288
SV_1800_2005_PREPROCESSORS,
289
SV_1800_2009_PREPROCESSORS] ).split()
290
SYSTEMVERILOG_PREPROCESSORS.sort()
291
SYSTEMVERILOG_PREPROCESSORS = " ".join( SYSTEMVERILOG_PREPROCESSORS )
293
SYSTEMVERILOG_KEYWORDS = " ".join( [VERILOG_KEYWORDS,
294
SV_1800_2005_KEYWORDS,
295
SV_1800_2009_KEYWORDS] ).split()
296
SYSTEMVERILOG_KEYWORDS.sort()
297
SYSTEMVERILOG_KEYWORDS = " ".join( SYSTEMVERILOG_KEYWORDS )
299
SYSTEMVERILOG_TYPES = " ".join( [VERILOG_TYPES,
301
SV_1800_2009_TYPES] ).split()
302
SYSTEMVERILOG_TYPES.sort()
303
SYSTEMVERILOG_TYPES = " ".join( SYSTEMVERILOG_TYPES )
305
SYSTEMVERILOG_TASKS = " ".join( [VERILOG_TASKS,
307
SV_1800_2009_TASKS] ).split()
308
SYSTEMVERILOG_TASKS.sort()
309
SYSTEMVERILOG_TASKS = " ".join( SYSTEMVERILOG_TASKS )
310
# ---/\----- Overkill maybe? -----/\---
312
#---- End System Verilog Extensions ----#
316
#---- End Keyword Definitions ----#
318
#---- Syntax Style Specs ----#
320
(stc.STC_V_COMMENT, 'comment_style' ),
321
(stc.STC_V_COMMENTLINE, 'comment_style' ),
322
(stc.STC_V_COMMENTLINEBANG, 'comment_style' ),
323
(stc.STC_V_DEFAULT, 'default_style' ),
324
(stc.STC_V_IDENTIFIER, 'default_style' ),
325
(stc.STC_V_NUMBER, 'number_style' ),
326
(stc.STC_V_OPERATOR, 'operator_style' ),
327
(stc.STC_V_PREPROCESSOR, 'pre_style' ),
328
(stc.STC_V_STRING, 'string_style' ),
329
(stc.STC_V_STRINGEOL, 'stringeol_style'),
330
(stc.STC_V_USER, 'default_style' ),
331
(stc.STC_V_WORD, 'keyword_style' ),
332
(stc.STC_V_WORD2, 'keyword2_style' ),
333
(stc.STC_V_WORD3, 'scalar_style' )
336
#---- Extra Properties ----#
338
FOLD_CMT = ("fold.comment", "1")
339
FOLD_PRE = ("fold.preprocessor", "1")
340
FOLD_COMP = ("fold.compact", "1")
341
FOLD_ELSE = ("fold.at.else", "0")
342
FOLD_MOD = ("fold.verilog.flags", "0")
344
#-----------------------------------------------------------------------------#
346
class SyntaxData(syndata.SyntaxDataBase):
347
"""SyntaxData object for Verilog and SysVerilog"""
348
def __init__(self, langid):
349
super(SyntaxData, self).__init__(langid)
352
self.SetLexer(stc.STC_LEX_VERILOG)
354
def GetKeywords(self):
355
"""Returns Specified Keywords List """
356
if self.LangId == synglob.ID_LANG_VERILOG:
357
return [(0, VERILOG_KEYWORDS),
361
return [(0, SYSTEMVERILOG_KEYWORDS),
362
(1, SYSTEMVERILOG_TYPES),
363
(2, SYSTEMVERILOG_TASKS)]
365
def GetSyntaxSpec(self):
366
"""Syntax Specifications """
369
def GetProperties(self):
370
"""Returns a list of Extra Properties to set """
373
def GetCommentPattern(self):
374
"""Returns a list of characters used to comment a block of code """