blob: 06fc2e795e90b1b3ca960088e3a019fdfc0d562a [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
Bram Moolenaar5f148ec2016-03-07 22:59:26 +01002" Language: VHDL [VHSIC (Very High Speed Integrated Circuit) Hardware Description Language]
Bram Moolenaarff781552020-03-19 20:37:11 +01003" Maintainer: Daniel Kho <daniel.kho@logik.haus>
Bram Moolenaarbaca7f72013-09-22 14:42:24 +02004" Previous Maintainer: Czo <Olivier.Sirol@lip6.fr>
Bram Moolenaar5f148ec2016-03-07 22:59:26 +01005" Credits: Stephan Hegel <stephan.hegel@snc.siemens.com.cn>
Bram Moolenaard1caa942020-04-10 22:10:56 +02006" Last Changed: 2020 Apr 04 by Daniel Kho
Bram Moolenaar071d4272004-06-13 20:20:40 +00007
Bram Moolenaar89bcfda2016-08-30 23:26:57 +02008" quit when a syntax file was already loaded
9if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000010 finish
11endif
12
Bram Moolenaarb8ff1fb2012-02-04 21:59:01 +010013let s:cpo_save = &cpo
14set cpo&vim
15
Bram Moolenaar071d4272004-06-13 20:20:40 +000016" case is not significant
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010017syn case ignore
Bram Moolenaar071d4272004-06-13 20:20:40 +000018
Bram Moolenaard1caa942020-04-10 22:10:56 +020019" VHDL 1076-2019 keywords
20syn keyword vhdlStatement access after alias all
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010021syn keyword vhdlStatement architecture array attribute
Bram Moolenaard1caa942020-04-10 22:10:56 +020022syn keyword vhdlStatement assert assume
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010023syn keyword vhdlStatement begin block body buffer bus
24syn keyword vhdlStatement case component configuration constant
25syn keyword vhdlStatement context cover
26syn keyword vhdlStatement default disconnect downto
27syn keyword vhdlStatement elsif end entity exit
28syn keyword vhdlStatement file for function
29syn keyword vhdlStatement fairness force
30syn keyword vhdlStatement generate generic group guarded
31syn keyword vhdlStatement impure in inertial inout is
32syn keyword vhdlStatement label library linkage literal loop
33syn keyword vhdlStatement map
34syn keyword vhdlStatement new next null
35syn keyword vhdlStatement of on open others out
36syn keyword vhdlStatement package port postponed procedure process pure
Bram Moolenaard1caa942020-04-10 22:10:56 +020037syn keyword vhdlStatement parameter property protected private
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010038syn keyword vhdlStatement range record register reject report return
Bram Moolenaard1caa942020-04-10 22:10:56 +020039syn keyword vhdlStatement release restrict
40syn keyword vhdlStatement select severity signal shared subtype
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010041syn keyword vhdlStatement sequence strong
42syn keyword vhdlStatement then to transport type
43syn keyword vhdlStatement unaffected units until use
Bram Moolenaard1caa942020-04-10 22:10:56 +020044syn keyword vhdlStatement variable view
45syn keyword vhdlStatement vpkg vmode vprop vunit
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010046syn keyword vhdlStatement wait when while with
Bram Moolenaard1caa942020-04-10 22:10:56 +020047
48" VHDL predefined severity levels
49syn keyword vhdlAttribute note warning error failure
Bram Moolenaar071d4272004-06-13 20:20:40 +000050
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010051" Linting of conditionals.
52syn match vhdlStatement "\<\(if\|else\)\>"
53syn match vhdlError "\<else\s\+if\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +000054
Bram Moolenaar5f148ec2016-03-07 22:59:26 +010055" Types and type qualifiers
56" Predefined standard VHDL types
Bram Moolenaar77cdfd12016-03-12 12:57:59 +010057syn match vhdlType "\<bit\>\'\="
58syn match vhdlType "\<boolean\>\'\="
59syn match vhdlType "\<natural\>\'\="
60syn match vhdlType "\<positive\>\'\="
61syn match vhdlType "\<integer\>\'\="
62syn match vhdlType "\<real\>\'\="
63syn match vhdlType "\<time\>\'\="
Bram Moolenaar5f148ec2016-03-07 22:59:26 +010064
Bram Moolenaar77cdfd12016-03-12 12:57:59 +010065syn match vhdlType "\<bit_vector\>\'\="
66syn match vhdlType "\<boolean_vector\>\'\="
67syn match vhdlType "\<integer_vector\>\'\="
68syn match vhdlType "\<real_vector\>\'\="
69syn match vhdlType "\<time_vector\>\'\="
Bram Moolenaar5f148ec2016-03-07 22:59:26 +010070
Bram Moolenaar77cdfd12016-03-12 12:57:59 +010071syn match vhdlType "\<character\>\'\="
72syn match vhdlType "\<string\>\'\="
Bram Moolenaar85eee132018-05-06 17:57:30 +020073syn keyword vhdlType line text side width
Bram Moolenaar5f148ec2016-03-07 22:59:26 +010074
75" Predefined standard IEEE VHDL types
Bram Moolenaar77cdfd12016-03-12 12:57:59 +010076syn match vhdlType "\<std_ulogic\>\'\="
77syn match vhdlType "\<std_logic\>\'\="
78syn match vhdlType "\<std_ulogic_vector\>\'\="
79syn match vhdlType "\<std_logic_vector\>\'\="
80syn match vhdlType "\<unresolved_signed\>\'\="
81syn match vhdlType "\<unresolved_unsigned\>\'\="
82syn match vhdlType "\<u_signed\>\'\="
83syn match vhdlType "\<u_unsigned\>\'\="
84syn match vhdlType "\<signed\>\'\="
85syn match vhdlType "\<unsigned\>\'\="
Bram Moolenaar5f148ec2016-03-07 22:59:26 +010086
Bram Moolenaar071d4272004-06-13 20:20:40 +000087
88" array attributes
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010089syn match vhdlAttribute "\'high"
90syn match vhdlAttribute "\'left"
91syn match vhdlAttribute "\'length"
92syn match vhdlAttribute "\'low"
93syn match vhdlAttribute "\'range"
94syn match vhdlAttribute "\'reverse_range"
95syn match vhdlAttribute "\'right"
96syn match vhdlAttribute "\'ascending"
Bram Moolenaar071d4272004-06-13 20:20:40 +000097" block attributes
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010098syn match vhdlAttribute "\'simple_name"
99syn match vhdlAttribute "\'instance_name"
100syn match vhdlAttribute "\'path_name"
101syn match vhdlAttribute "\'foreign" " VHPI
Bram Moolenaar071d4272004-06-13 20:20:40 +0000102" signal attribute
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100103syn match vhdlAttribute "\'active"
104syn match vhdlAttribute "\'delayed"
105syn match vhdlAttribute "\'event"
106syn match vhdlAttribute "\'last_active"
107syn match vhdlAttribute "\'last_event"
108syn match vhdlAttribute "\'last_value"
109syn match vhdlAttribute "\'quiet"
110syn match vhdlAttribute "\'stable"
111syn match vhdlAttribute "\'transaction"
112syn match vhdlAttribute "\'driving"
113syn match vhdlAttribute "\'driving_value"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000114" type attributes
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100115syn match vhdlAttribute "\'base"
116syn match vhdlAttribute "\'subtype"
117syn match vhdlAttribute "\'element"
118syn match vhdlAttribute "\'leftof"
119syn match vhdlAttribute "\'pos"
120syn match vhdlAttribute "\'pred"
121syn match vhdlAttribute "\'rightof"
122syn match vhdlAttribute "\'succ"
123syn match vhdlAttribute "\'val"
124syn match vhdlAttribute "\'image"
125syn match vhdlAttribute "\'value"
Bram Moolenaarff781552020-03-19 20:37:11 +0100126" VHDL-2019 interface attribute
Bram Moolenaar85eee132018-05-06 17:57:30 +0200127syn match vhdlAttribute "\'converse"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000128
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100129syn keyword vhdlBoolean true false
Bram Moolenaar071d4272004-06-13 20:20:40 +0000130
131" for this vector values case is significant
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100132syn case match
Bram Moolenaar071d4272004-06-13 20:20:40 +0000133" Values for standard VHDL types
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100134syn match vhdlVector "\'[0L1HXWZU\-\?]\'"
135syn case ignore
Bram Moolenaar071d4272004-06-13 20:20:40 +0000136
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100137syn match vhdlVector "B\"[01_]\+\""
138syn match vhdlVector "O\"[0-7_]\+\""
139syn match vhdlVector "X\"[0-9a-f_]\+\""
140syn match vhdlCharacter "'.'"
141syn region vhdlString start=+"+ end=+"+
Bram Moolenaar071d4272004-06-13 20:20:40 +0000142
143" floating numbers
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100144syn match vhdlNumber "-\=\<\d\+\.\d\+\(E[+\-]\=\d\+\)\>"
145syn match vhdlNumber "-\=\<\d\+\.\d\+\>"
146syn match vhdlNumber "0*2#[01_]\+\.[01_]\+#\(E[+\-]\=\d\+\)\="
147syn match vhdlNumber "0*16#[0-9a-f_]\+\.[0-9a-f_]\+#\(E[+\-]\=\d\+\)\="
Bram Moolenaar071d4272004-06-13 20:20:40 +0000148" integer numbers
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100149syn match vhdlNumber "-\=\<\d\+\(E[+\-]\=\d\+\)\>"
150syn match vhdlNumber "-\=\<\d\+\>"
151syn match vhdlNumber "0*2#[01_]\+#\(E[+\-]\=\d\+\)\="
152syn match vhdlNumber "0*16#[0-9a-f_]\+#\(E[+\-]\=\d\+\)\="
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200153
Bram Moolenaar071d4272004-06-13 20:20:40 +0000154" operators
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200155syn keyword vhdlOperator and nand or nor xor xnor
156syn keyword vhdlOperator rol ror sla sll sra srl
157syn keyword vhdlOperator mod rem abs not
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200158
159" Concatenation and math operators
160syn match vhdlOperator "&\|+\|-\|\*\|\/"
161
162" Equality and comparison operators
163syn match vhdlOperator "=\|\/=\|>\|<\|>="
164
165" Assignment operators
166syn match vhdlOperator "<=\|:="
167syn match vhdlOperator "=>"
168
Bram Moolenaarff781552020-03-19 20:37:11 +0100169" VHDL-202x concurrent signal association (spaceship) operator
Bram Moolenaar85eee132018-05-06 17:57:30 +0200170syn match vhdlOperator "<=>"
171
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200172" VHDL-2008 conversion, matching equality/non-equality operators
173syn match vhdlOperator "??\|?=\|?\/=\|?<\|?<=\|?>\|?>="
174
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100175" VHDL-2008 external names
176syn match vhdlOperator "<<\|>>"
177
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200178" Linting for illegal operators
179" '='
180syn match vhdlError "\(=\)[<=&+\-\*\/\\]\+"
181syn match vhdlError "[=&+\-\*\\]\+\(=\)"
182" '>', '<'
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100183" Allow external names: '<< ... >>'
184syn match vhdlError "\(>\)[<&+\-\/\\]\+"
185syn match vhdlError "[&+\-\/\\]\+\(>\)"
186syn match vhdlError "\(<\)[&+\-\/\\]\+"
187syn match vhdlError "[>=&+\-\/\\]\+\(<\)"
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200188" Covers most operators
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100189" support negative sign after operators. E.g. q<=-b;
Bram Moolenaarff781552020-03-19 20:37:11 +0100190" Supports VHDL-202x spaceship (concurrent simple signal association).
Bram Moolenaar85eee132018-05-06 17:57:30 +0200191syn match vhdlError "\(<=\)[<=&+\*\\?:]\+"
192syn match vhdlError "[>=&+\-\*\\:]\+\(=>\)"
193syn match vhdlError "\(&\|+\|\-\|\*\*\|\/=\|??\|?=\|?\/=\|?<=\|?>=\|>=\|:=\|=>\)[<>=&+\*\\?:]\+"
194syn match vhdlError "[<>=&+\-\*\\:]\+\(&\|+\|\*\*\|\/=\|??\|?=\|?\/=\|?<\|?<=\|?>\|?>=\|>=\|<=\|:=\)"
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100195syn match vhdlError "\(?<\|?>\)[<>&+\*\/\\?:]\+"
196syn match vhdlError "\(<<\|>>\)[<>&+\*\/\\?:]\+"
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200197
198"syn match vhdlError "[?]\+\(&\|+\|\-\|\*\*\|??\|?=\|?\/=\|?<\|?<=\|?>\|?>=\|:=\|=>\)"
199" '/'
200syn match vhdlError "\(\/\)[<>&+\-\*\/\\?:]\+"
201syn match vhdlError "[<>=&+\-\*\/\\:]\+\(\/\)"
202
203syn match vhdlSpecial "<>"
204syn match vhdlSpecial "[().,;]"
205
206
Bram Moolenaar071d4272004-06-13 20:20:40 +0000207" time
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100208syn match vhdlTime "\<\d\+\s\+\(\([fpnum]s\)\|\(sec\)\|\(min\)\|\(hr\)\)\>"
209syn match vhdlTime "\<\d\+\.\d\+\s\+\(\([fpnum]s\)\|\(sec\)\|\(min\)\|\(hr\)\)\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000210
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100211syn case match
212syn keyword vhdlTodo contained TODO NOTE
213syn keyword vhdlFixme contained FIXME
214syn case ignore
Bram Moolenaarbaca7f72013-09-22 14:42:24 +0200215
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100216syn region vhdlComment start="/\*" end="\*/" contains=vhdlTodo,vhdlFixme,@Spell
217syn match vhdlComment "\(^\|\s\)--.*" contains=vhdlTodo,vhdlFixme,@Spell
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200218
Bram Moolenaar5f148ec2016-03-07 22:59:26 +0100219" Standard IEEE P1076.6 preprocessor directives (metacomments).
220syn match vhdlPreProc "/\*\s*rtl_synthesis\s\+\(on\|off\)\s*\*/"
221syn match vhdlPreProc "\(^\|\s\)--\s*rtl_synthesis\s\+\(on\|off\)\s*"
222syn match vhdlPreProc "/\*\s*rtl_syn\s\+\(on\|off\)\s*\*/"
223syn match vhdlPreProc "\(^\|\s\)--\s*rtl_syn\s\+\(on\|off\)\s*"
224
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200225" Industry-standard directives. These are not standard VHDL, but are commonly
226" used in the industry.
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100227syn match vhdlPreProc "/\*\s*synthesis\s\+translate_\(on\|off\)\s*\*/"
228"syn match vhdlPreProc "/\*\s*simulation\s\+translate_\(on\|off\)\s*\*/"
Bram Moolenaar5f148ec2016-03-07 22:59:26 +0100229syn match vhdlPreProc "/\*\s*pragma\s\+translate_\(on\|off\)\s*\*/"
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100230syn match vhdlPreProc "/\*\s*pragma\s\+synthesis_\(on\|off\)\s*\*/"
231syn match vhdlPreProc "/\*\s*synopsys\s\+translate_\(on\|off\)\s*\*/"
232
233syn match vhdlPreProc "\(^\|\s\)--\s*synthesis\s\+translate_\(on\|off\)\s*"
234"syn match vhdlPreProc "\(^\|\s\)--\s*simulation\s\+translate_\(on\|off\)\s*"
Bram Moolenaar5f148ec2016-03-07 22:59:26 +0100235syn match vhdlPreProc "\(^\|\s\)--\s*pragma\s\+translate_\(on\|off\)\s*"
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100236syn match vhdlPreProc "\(^\|\s\)--\s*pragma\s\+synthesis_\(on\|off\)\s*"
237syn match vhdlPreProc "\(^\|\s\)--\s*synopsys\s\+translate_\(on\|off\)\s*"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000238
Bram Moolenaarbaca7f72013-09-22 14:42:24 +0200239"Modify the following as needed. The trade-off is performance versus functionality.
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100240syn sync minlines=600
Bram Moolenaarbaca7f72013-09-22 14:42:24 +0200241
Bram Moolenaar071d4272004-06-13 20:20:40 +0000242" Define the default highlighting.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200243" Only when an item doesn't have highlighting yet
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200244
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200245hi def link vhdlSpecial Special
246hi def link vhdlStatement Statement
247hi def link vhdlCharacter Character
248hi def link vhdlString String
249hi def link vhdlVector Number
250hi def link vhdlBoolean Number
251hi def link vhdlTodo Todo
252hi def link vhdlFixme Fixme
253hi def link vhdlComment Comment
254hi def link vhdlNumber Number
255hi def link vhdlTime Number
256hi def link vhdlType Type
257hi def link vhdlOperator Operator
258hi def link vhdlError Error
259hi def link vhdlAttribute Special
260hi def link vhdlPreProc PreProc
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200261
Bram Moolenaar071d4272004-06-13 20:20:40 +0000262
263let b:current_syntax = "vhdl"
264
Bram Moolenaarb8ff1fb2012-02-04 21:59:01 +0100265let &cpo = s:cpo_save
266unlet s:cpo_save
Bram Moolenaard1caa942020-04-10 22:10:56 +0200267
Bram Moolenaar071d4272004-06-13 20:20:40 +0000268" vim: ts=8