blob: 916bd9635d4a4b963b832262eb9441ac165103c2 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: VHDL
Bram Moolenaarbaca7f72013-09-22 14:42:24 +02003" Maintainer: Daniel Kho <daniel.kho@tauhop.com>
4" Previous Maintainer: Czo <Olivier.Sirol@lip6.fr>
Bram Moolenaar071d4272004-06-13 20:20:40 +00005" Credits: Stephan Hegel <stephan.hegel@snc.siemens.com.cn>
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +01006" Last Changed: 2015 Dec 4 by Daniel Kho
Bram Moolenaar071d4272004-06-13 20:20:40 +00007
Bram Moolenaarbaca7f72013-09-22 14:42:24 +02008" VHSIC (Very High Speed Integrated Circuit) Hardware Description Language
Bram Moolenaar071d4272004-06-13 20:20:40 +00009
10" For version 5.x: Clear all syntax items
11" For version 6.x: Quit when a syntax file was already loaded
12if version < 600
13 syntax clear
14elseif exists("b:current_syntax")
15 finish
16endif
17
Bram Moolenaarb8ff1fb2012-02-04 21:59:01 +010018let s:cpo_save = &cpo
19set cpo&vim
20
Bram Moolenaar071d4272004-06-13 20:20:40 +000021" case is not significant
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010022syn case ignore
Bram Moolenaar071d4272004-06-13 20:20:40 +000023
24" VHDL keywords
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010025syn keyword vhdlStatement access after alias all assert
26syn keyword vhdlStatement architecture array attribute
27syn keyword vhdlStatement assume assume_guarantee
28syn keyword vhdlStatement begin block body buffer bus
29syn keyword vhdlStatement case component configuration constant
30syn keyword vhdlStatement context cover
31syn keyword vhdlStatement default disconnect downto
32syn keyword vhdlStatement elsif end entity exit
33syn keyword vhdlStatement file for function
34syn keyword vhdlStatement fairness force
35syn keyword vhdlStatement generate generic group guarded
36syn keyword vhdlStatement impure in inertial inout is
37syn keyword vhdlStatement label library linkage literal loop
38syn keyword vhdlStatement map
39syn keyword vhdlStatement new next null
40syn keyword vhdlStatement of on open others out
41syn keyword vhdlStatement package port postponed procedure process pure
42syn keyword vhdlStatement parameter property protected
43syn keyword vhdlStatement range record register reject report return
44syn keyword vhdlStatement release restrict restrict_guarantee
45syn keyword vhdlStatement select severity signal shared
46syn keyword vhdlStatement subtype
47syn keyword vhdlStatement sequence strong
48syn keyword vhdlStatement then to transport type
49syn keyword vhdlStatement unaffected units until use
50syn keyword vhdlStatement variable
51syn keyword vhdlStatement vmode vprop vunit
52syn keyword vhdlStatement wait when while with
53syn keyword vhdlStatement note warning error failure
Bram Moolenaar071d4272004-06-13 20:20:40 +000054
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010055" Linting of conditionals.
56syn match vhdlStatement "\<\(if\|else\)\>"
57syn match vhdlError "\<else\s\+if\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +000058
Bram Moolenaarc8734422012-06-01 22:38:45 +020059" Predefined VHDL types
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010060syn keyword vhdlType bit bit_vector
61syn keyword vhdlType character boolean integer real time
62syn keyword vhdlType boolean_vector integer_vector real_vector time_vector
63syn keyword vhdlType string severity_level
Bram Moolenaarc8734422012-06-01 22:38:45 +020064" Predefined standard ieee VHDL types
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010065syn keyword vhdlType positive natural signed unsigned
66syn keyword vhdlType unresolved_signed unresolved_unsigned u_signed u_unsigned
67syn keyword vhdlType line text
68syn keyword vhdlType std_logic std_logic_vector
69syn keyword vhdlType std_ulogic std_ulogic_vector
Bram Moolenaar071d4272004-06-13 20:20:40 +000070
71" array attributes
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010072syn match vhdlAttribute "\'high"
73syn match vhdlAttribute "\'left"
74syn match vhdlAttribute "\'length"
75syn match vhdlAttribute "\'low"
76syn match vhdlAttribute "\'range"
77syn match vhdlAttribute "\'reverse_range"
78syn match vhdlAttribute "\'right"
79syn match vhdlAttribute "\'ascending"
Bram Moolenaar071d4272004-06-13 20:20:40 +000080" block attributes
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010081syn match vhdlAttribute "\'simple_name"
82syn match vhdlAttribute "\'instance_name"
83syn match vhdlAttribute "\'path_name"
84syn match vhdlAttribute "\'foreign" " VHPI
Bram Moolenaar071d4272004-06-13 20:20:40 +000085" signal attribute
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010086syn match vhdlAttribute "\'active"
87syn match vhdlAttribute "\'delayed"
88syn match vhdlAttribute "\'event"
89syn match vhdlAttribute "\'last_active"
90syn match vhdlAttribute "\'last_event"
91syn match vhdlAttribute "\'last_value"
92syn match vhdlAttribute "\'quiet"
93syn match vhdlAttribute "\'stable"
94syn match vhdlAttribute "\'transaction"
95syn match vhdlAttribute "\'driving"
96syn match vhdlAttribute "\'driving_value"
Bram Moolenaar071d4272004-06-13 20:20:40 +000097" type attributes
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010098syn match vhdlAttribute "\'base"
99syn match vhdlAttribute "\'subtype"
100syn match vhdlAttribute "\'element"
101syn match vhdlAttribute "\'leftof"
102syn match vhdlAttribute "\'pos"
103syn match vhdlAttribute "\'pred"
104syn match vhdlAttribute "\'rightof"
105syn match vhdlAttribute "\'succ"
106syn match vhdlAttribute "\'val"
107syn match vhdlAttribute "\'image"
108syn match vhdlAttribute "\'value"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000109
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100110syn keyword vhdlBoolean true false
Bram Moolenaar071d4272004-06-13 20:20:40 +0000111
112" for this vector values case is significant
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100113syn case match
Bram Moolenaar071d4272004-06-13 20:20:40 +0000114" Values for standard VHDL types
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100115syn match vhdlVector "\'[0L1HXWZU\-\?]\'"
116syn case ignore
Bram Moolenaar071d4272004-06-13 20:20:40 +0000117
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100118syn match vhdlVector "B\"[01_]\+\""
119syn match vhdlVector "O\"[0-7_]\+\""
120syn match vhdlVector "X\"[0-9a-f_]\+\""
121syn match vhdlCharacter "'.'"
122syn region vhdlString start=+"+ end=+"+
Bram Moolenaar071d4272004-06-13 20:20:40 +0000123
124" floating numbers
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100125syn match vhdlNumber "-\=\<\d\+\.\d\+\(E[+\-]\=\d\+\)\>"
126syn match vhdlNumber "-\=\<\d\+\.\d\+\>"
127syn match vhdlNumber "0*2#[01_]\+\.[01_]\+#\(E[+\-]\=\d\+\)\="
128syn match vhdlNumber "0*16#[0-9a-f_]\+\.[0-9a-f_]\+#\(E[+\-]\=\d\+\)\="
Bram Moolenaar071d4272004-06-13 20:20:40 +0000129" integer numbers
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100130syn match vhdlNumber "-\=\<\d\+\(E[+\-]\=\d\+\)\>"
131syn match vhdlNumber "-\=\<\d\+\>"
132syn match vhdlNumber "0*2#[01_]\+#\(E[+\-]\=\d\+\)\="
133syn match vhdlNumber "0*16#[0-9a-f_]\+#\(E[+\-]\=\d\+\)\="
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200134
Bram Moolenaar071d4272004-06-13 20:20:40 +0000135" operators
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200136syn keyword vhdlOperator and nand or nor xor xnor
137syn keyword vhdlOperator rol ror sla sll sra srl
138syn keyword vhdlOperator mod rem abs not
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200139
140" Concatenation and math operators
141syn match vhdlOperator "&\|+\|-\|\*\|\/"
142
143" Equality and comparison operators
144syn match vhdlOperator "=\|\/=\|>\|<\|>="
145
146" Assignment operators
147syn match vhdlOperator "<=\|:="
148syn match vhdlOperator "=>"
149
150" VHDL-2008 conversion, matching equality/non-equality operators
151syn match vhdlOperator "??\|?=\|?\/=\|?<\|?<=\|?>\|?>="
152
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100153" VHDL-2008 external names
154syn match vhdlOperator "<<\|>>"
155
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200156" Linting for illegal operators
157" '='
158syn match vhdlError "\(=\)[<=&+\-\*\/\\]\+"
159syn match vhdlError "[=&+\-\*\\]\+\(=\)"
160" '>', '<'
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100161" Allow external names: '<< ... >>'
162syn match vhdlError "\(>\)[<&+\-\/\\]\+"
163syn match vhdlError "[&+\-\/\\]\+\(>\)"
164syn match vhdlError "\(<\)[&+\-\/\\]\+"
165syn match vhdlError "[>=&+\-\/\\]\+\(<\)"
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200166" Covers most operators
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100167" support negative sign after operators. E.g. q<=-b;
168syn match vhdlError "\(&\|+\|\-\|\*\*\|\/=\|??\|?=\|?\/=\|?<=\|?>=\|>=\|<=\|:=\|=>\)[<>=&+\*\\?:]\+"
169syn match vhdlError "[<>=&+\-\*\\:]\+\(&\|+\|\*\*\|\/=\|??\|?=\|?\/=\|?<\|?<=\|?>\|?>=\|>=\|<=\|:=\|=>\)"
170syn match vhdlError "\(?<\|?>\)[<>&+\*\/\\?:]\+"
171syn match vhdlError "\(<<\|>>\)[<>&+\*\/\\?:]\+"
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200172
173"syn match vhdlError "[?]\+\(&\|+\|\-\|\*\*\|??\|?=\|?\/=\|?<\|?<=\|?>\|?>=\|:=\|=>\)"
174" '/'
175syn match vhdlError "\(\/\)[<>&+\-\*\/\\?:]\+"
176syn match vhdlError "[<>=&+\-\*\/\\:]\+\(\/\)"
177
178syn match vhdlSpecial "<>"
179syn match vhdlSpecial "[().,;]"
180
181
Bram Moolenaar071d4272004-06-13 20:20:40 +0000182" time
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100183syn match vhdlTime "\<\d\+\s\+\(\([fpnum]s\)\|\(sec\)\|\(min\)\|\(hr\)\)\>"
184syn match vhdlTime "\<\d\+\.\d\+\s\+\(\([fpnum]s\)\|\(sec\)\|\(min\)\|\(hr\)\)\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000185
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100186syn case match
187syn keyword vhdlTodo contained TODO NOTE
188syn keyword vhdlFixme contained FIXME
189syn case ignore
Bram Moolenaarbaca7f72013-09-22 14:42:24 +0200190
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100191syn region vhdlComment start="/\*" end="\*/" contains=vhdlTodo,vhdlFixme,@Spell
192syn match vhdlComment "\(^\|\s\)--.*" contains=vhdlTodo,vhdlFixme,@Spell
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200193
194" Industry-standard directives. These are not standard VHDL, but are commonly
195" used in the industry.
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100196syn match vhdlPreProc "/\*\s*synthesis\s\+translate_\(on\|off\)\s*\*/"
197"syn match vhdlPreProc "/\*\s*simulation\s\+translate_\(on\|off\)\s*\*/"
198syn match vhdlPreProc "/\*\s*pragma\s\+synthesis_\(on\|off\)\s*\*/"
199syn match vhdlPreProc "/\*\s*synopsys\s\+translate_\(on\|off\)\s*\*/"
200
201syn match vhdlPreProc "\(^\|\s\)--\s*synthesis\s\+translate_\(on\|off\)\s*"
202"syn match vhdlPreProc "\(^\|\s\)--\s*simulation\s\+translate_\(on\|off\)\s*"
203syn match vhdlPreProc "\(^\|\s\)--\s*pragma\s\+synthesis_\(on\|off\)\s*"
204syn match vhdlPreProc "\(^\|\s\)--\s*synopsys\s\+translate_\(on\|off\)\s*"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000205
Bram Moolenaarbaca7f72013-09-22 14:42:24 +0200206"Modify the following as needed. The trade-off is performance versus functionality.
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100207syn sync minlines=600
Bram Moolenaarbaca7f72013-09-22 14:42:24 +0200208
Bram Moolenaar071d4272004-06-13 20:20:40 +0000209" Define the default highlighting.
210" For version 5.7 and earlier: only when not done already
211" For version 5.8 and later: only when an item doesn't have highlighting yet
212if version >= 508 || !exists("did_vhdl_syntax_inits")
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100213 if version < 508
214 let did_vhdl_syntax_inits = 1
215 command -nargs=+ HiLink hi link <args>
216 else
217 command -nargs=+ HiLink hi def link <args>
218 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000219
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100220 HiLink vhdlSpecial Special
221 HiLink vhdlStatement Statement
222 HiLink vhdlCharacter Character
223 HiLink vhdlString String
224 HiLink vhdlVector Number
225 HiLink vhdlBoolean Number
226 HiLink vhdlTodo Todo
227 HiLink vhdlFixme Fixme
228 HiLink vhdlComment Comment
229 HiLink vhdlNumber Number
230 HiLink vhdlTime Number
231 HiLink vhdlType Type
232 HiLink vhdlOperator Operator
233 HiLink vhdlError Error
234 HiLink vhdlAttribute Special
235 HiLink vhdlPreProc PreProc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000236
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100237 delcommand HiLink
Bram Moolenaar071d4272004-06-13 20:20:40 +0000238endif
239
240let b:current_syntax = "vhdl"
241
Bram Moolenaarb8ff1fb2012-02-04 21:59:01 +0100242let &cpo = s:cpo_save
243unlet s:cpo_save
Bram Moolenaar071d4272004-06-13 20:20:40 +0000244" vim: ts=8