blob: efcb840284aba7e0bbde813b82496b19ba6e301c [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]
3" Maintainer: Daniel Kho <daniel.kho@tauhop.com>
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 Moolenaar85eee132018-05-06 17:57:30 +02006" Last Changed: 2018 May 06 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
19" VHDL keywords
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010020syn keyword vhdlStatement access after alias all assert
21syn keyword vhdlStatement architecture array attribute
22syn keyword vhdlStatement assume assume_guarantee
23syn 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
37syn keyword vhdlStatement parameter property protected
38syn keyword vhdlStatement range record register reject report return
39syn keyword vhdlStatement release restrict restrict_guarantee
40syn keyword vhdlStatement select severity signal shared
41syn keyword vhdlStatement subtype
42syn keyword vhdlStatement sequence strong
43syn keyword vhdlStatement then to transport type
44syn keyword vhdlStatement unaffected units until use
45syn keyword vhdlStatement variable
Bram Moolenaar85eee132018-05-06 17:57:30 +020046" VHDL-2017 interface
47syn keyword vhdlStatement view
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010048syn keyword vhdlStatement vmode vprop vunit
49syn keyword vhdlStatement wait when while with
50syn keyword vhdlStatement note warning error failure
Bram Moolenaar071d4272004-06-13 20:20:40 +000051
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010052" Linting of conditionals.
53syn match vhdlStatement "\<\(if\|else\)\>"
54syn match vhdlError "\<else\s\+if\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +000055
Bram Moolenaar5f148ec2016-03-07 22:59:26 +010056" Types and type qualifiers
57" Predefined standard VHDL types
Bram Moolenaar77cdfd12016-03-12 12:57:59 +010058syn match vhdlType "\<bit\>\'\="
59syn match vhdlType "\<boolean\>\'\="
60syn match vhdlType "\<natural\>\'\="
61syn match vhdlType "\<positive\>\'\="
62syn match vhdlType "\<integer\>\'\="
63syn match vhdlType "\<real\>\'\="
64syn match vhdlType "\<time\>\'\="
Bram Moolenaar5f148ec2016-03-07 22:59:26 +010065
Bram Moolenaar77cdfd12016-03-12 12:57:59 +010066syn match vhdlType "\<bit_vector\>\'\="
67syn match vhdlType "\<boolean_vector\>\'\="
68syn match vhdlType "\<integer_vector\>\'\="
69syn match vhdlType "\<real_vector\>\'\="
70syn match vhdlType "\<time_vector\>\'\="
Bram Moolenaar5f148ec2016-03-07 22:59:26 +010071
Bram Moolenaar77cdfd12016-03-12 12:57:59 +010072syn match vhdlType "\<character\>\'\="
73syn match vhdlType "\<string\>\'\="
Bram Moolenaar85eee132018-05-06 17:57:30 +020074syn keyword vhdlType line text side width
Bram Moolenaar5f148ec2016-03-07 22:59:26 +010075
76" Predefined standard IEEE VHDL types
Bram Moolenaar77cdfd12016-03-12 12:57:59 +010077syn match vhdlType "\<std_ulogic\>\'\="
78syn match vhdlType "\<std_logic\>\'\="
79syn match vhdlType "\<std_ulogic_vector\>\'\="
80syn match vhdlType "\<std_logic_vector\>\'\="
81syn match vhdlType "\<unresolved_signed\>\'\="
82syn match vhdlType "\<unresolved_unsigned\>\'\="
83syn match vhdlType "\<u_signed\>\'\="
84syn match vhdlType "\<u_unsigned\>\'\="
85syn match vhdlType "\<signed\>\'\="
86syn match vhdlType "\<unsigned\>\'\="
Bram Moolenaar5f148ec2016-03-07 22:59:26 +010087
Bram Moolenaar071d4272004-06-13 20:20:40 +000088
89" array attributes
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010090syn match vhdlAttribute "\'high"
91syn match vhdlAttribute "\'left"
92syn match vhdlAttribute "\'length"
93syn match vhdlAttribute "\'low"
94syn match vhdlAttribute "\'range"
95syn match vhdlAttribute "\'reverse_range"
96syn match vhdlAttribute "\'right"
97syn match vhdlAttribute "\'ascending"
Bram Moolenaar071d4272004-06-13 20:20:40 +000098" block attributes
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +010099syn match vhdlAttribute "\'simple_name"
100syn match vhdlAttribute "\'instance_name"
101syn match vhdlAttribute "\'path_name"
102syn match vhdlAttribute "\'foreign" " VHPI
Bram Moolenaar071d4272004-06-13 20:20:40 +0000103" signal attribute
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100104syn match vhdlAttribute "\'active"
105syn match vhdlAttribute "\'delayed"
106syn match vhdlAttribute "\'event"
107syn match vhdlAttribute "\'last_active"
108syn match vhdlAttribute "\'last_event"
109syn match vhdlAttribute "\'last_value"
110syn match vhdlAttribute "\'quiet"
111syn match vhdlAttribute "\'stable"
112syn match vhdlAttribute "\'transaction"
113syn match vhdlAttribute "\'driving"
114syn match vhdlAttribute "\'driving_value"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000115" type attributes
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100116syn match vhdlAttribute "\'base"
117syn match vhdlAttribute "\'subtype"
118syn match vhdlAttribute "\'element"
119syn match vhdlAttribute "\'leftof"
120syn match vhdlAttribute "\'pos"
121syn match vhdlAttribute "\'pred"
122syn match vhdlAttribute "\'rightof"
123syn match vhdlAttribute "\'succ"
124syn match vhdlAttribute "\'val"
125syn match vhdlAttribute "\'image"
126syn match vhdlAttribute "\'value"
Bram Moolenaar85eee132018-05-06 17:57:30 +0200127" VHDL-2017 interface attribute
128syn match vhdlAttribute "\'converse"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000129
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100130syn keyword vhdlBoolean true false
Bram Moolenaar071d4272004-06-13 20:20:40 +0000131
132" for this vector values case is significant
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100133syn case match
Bram Moolenaar071d4272004-06-13 20:20:40 +0000134" Values for standard VHDL types
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100135syn match vhdlVector "\'[0L1HXWZU\-\?]\'"
136syn case ignore
Bram Moolenaar071d4272004-06-13 20:20:40 +0000137
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100138syn match vhdlVector "B\"[01_]\+\""
139syn match vhdlVector "O\"[0-7_]\+\""
140syn match vhdlVector "X\"[0-9a-f_]\+\""
141syn match vhdlCharacter "'.'"
142syn region vhdlString start=+"+ end=+"+
Bram Moolenaar071d4272004-06-13 20:20:40 +0000143
144" floating numbers
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100145syn match vhdlNumber "-\=\<\d\+\.\d\+\(E[+\-]\=\d\+\)\>"
146syn match vhdlNumber "-\=\<\d\+\.\d\+\>"
147syn match vhdlNumber "0*2#[01_]\+\.[01_]\+#\(E[+\-]\=\d\+\)\="
148syn match vhdlNumber "0*16#[0-9a-f_]\+\.[0-9a-f_]\+#\(E[+\-]\=\d\+\)\="
Bram Moolenaar071d4272004-06-13 20:20:40 +0000149" integer numbers
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100150syn match vhdlNumber "-\=\<\d\+\(E[+\-]\=\d\+\)\>"
151syn match vhdlNumber "-\=\<\d\+\>"
152syn match vhdlNumber "0*2#[01_]\+#\(E[+\-]\=\d\+\)\="
153syn match vhdlNumber "0*16#[0-9a-f_]\+#\(E[+\-]\=\d\+\)\="
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200154
Bram Moolenaar071d4272004-06-13 20:20:40 +0000155" operators
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200156syn keyword vhdlOperator and nand or nor xor xnor
157syn keyword vhdlOperator rol ror sla sll sra srl
158syn keyword vhdlOperator mod rem abs not
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200159
160" Concatenation and math operators
161syn match vhdlOperator "&\|+\|-\|\*\|\/"
162
163" Equality and comparison operators
164syn match vhdlOperator "=\|\/=\|>\|<\|>="
165
166" Assignment operators
167syn match vhdlOperator "<=\|:="
168syn match vhdlOperator "=>"
169
Bram Moolenaar85eee132018-05-06 17:57:30 +0200170" VHDL-2017 concurrent signal association (spaceship) operator
171syn match vhdlOperator "<=>"
172
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200173" VHDL-2008 conversion, matching equality/non-equality operators
174syn match vhdlOperator "??\|?=\|?\/=\|?<\|?<=\|?>\|?>="
175
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100176" VHDL-2008 external names
177syn match vhdlOperator "<<\|>>"
178
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200179" Linting for illegal operators
180" '='
181syn match vhdlError "\(=\)[<=&+\-\*\/\\]\+"
182syn match vhdlError "[=&+\-\*\\]\+\(=\)"
183" '>', '<'
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100184" Allow external names: '<< ... >>'
185syn match vhdlError "\(>\)[<&+\-\/\\]\+"
186syn match vhdlError "[&+\-\/\\]\+\(>\)"
187syn match vhdlError "\(<\)[&+\-\/\\]\+"
188syn match vhdlError "[>=&+\-\/\\]\+\(<\)"
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200189" Covers most operators
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100190" support negative sign after operators. E.g. q<=-b;
Bram Moolenaar85eee132018-05-06 17:57:30 +0200191" Supports VHDL-2017 spaceship (concurrent simple signal association).
192syn match vhdlError "\(<=\)[<=&+\*\\?:]\+"
193syn match vhdlError "[>=&+\-\*\\:]\+\(=>\)"
194syn match vhdlError "\(&\|+\|\-\|\*\*\|\/=\|??\|?=\|?\/=\|?<=\|?>=\|>=\|:=\|=>\)[<>=&+\*\\?:]\+"
195syn match vhdlError "[<>=&+\-\*\\:]\+\(&\|+\|\*\*\|\/=\|??\|?=\|?\/=\|?<\|?<=\|?>\|?>=\|>=\|<=\|:=\)"
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100196syn match vhdlError "\(?<\|?>\)[<>&+\*\/\\?:]\+"
197syn match vhdlError "\(<<\|>>\)[<>&+\*\/\\?:]\+"
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200198
199"syn match vhdlError "[?]\+\(&\|+\|\-\|\*\*\|??\|?=\|?\/=\|?<\|?<=\|?>\|?>=\|:=\|=>\)"
200" '/'
201syn match vhdlError "\(\/\)[<>&+\-\*\/\\?:]\+"
202syn match vhdlError "[<>=&+\-\*\/\\:]\+\(\/\)"
203
204syn match vhdlSpecial "<>"
205syn match vhdlSpecial "[().,;]"
206
207
Bram Moolenaar071d4272004-06-13 20:20:40 +0000208" time
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100209syn match vhdlTime "\<\d\+\s\+\(\([fpnum]s\)\|\(sec\)\|\(min\)\|\(hr\)\)\>"
210syn match vhdlTime "\<\d\+\.\d\+\s\+\(\([fpnum]s\)\|\(sec\)\|\(min\)\|\(hr\)\)\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000211
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100212syn case match
213syn keyword vhdlTodo contained TODO NOTE
214syn keyword vhdlFixme contained FIXME
215syn case ignore
Bram Moolenaarbaca7f72013-09-22 14:42:24 +0200216
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100217syn region vhdlComment start="/\*" end="\*/" contains=vhdlTodo,vhdlFixme,@Spell
218syn match vhdlComment "\(^\|\s\)--.*" contains=vhdlTodo,vhdlFixme,@Spell
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200219
Bram Moolenaar5f148ec2016-03-07 22:59:26 +0100220" Standard IEEE P1076.6 preprocessor directives (metacomments).
221syn match vhdlPreProc "/\*\s*rtl_synthesis\s\+\(on\|off\)\s*\*/"
222syn match vhdlPreProc "\(^\|\s\)--\s*rtl_synthesis\s\+\(on\|off\)\s*"
223syn match vhdlPreProc "/\*\s*rtl_syn\s\+\(on\|off\)\s*\*/"
224syn match vhdlPreProc "\(^\|\s\)--\s*rtl_syn\s\+\(on\|off\)\s*"
225
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200226" Industry-standard directives. These are not standard VHDL, but are commonly
227" used in the industry.
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100228syn match vhdlPreProc "/\*\s*synthesis\s\+translate_\(on\|off\)\s*\*/"
229"syn match vhdlPreProc "/\*\s*simulation\s\+translate_\(on\|off\)\s*\*/"
Bram Moolenaar5f148ec2016-03-07 22:59:26 +0100230syn match vhdlPreProc "/\*\s*pragma\s\+translate_\(on\|off\)\s*\*/"
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100231syn match vhdlPreProc "/\*\s*pragma\s\+synthesis_\(on\|off\)\s*\*/"
232syn match vhdlPreProc "/\*\s*synopsys\s\+translate_\(on\|off\)\s*\*/"
233
234syn match vhdlPreProc "\(^\|\s\)--\s*synthesis\s\+translate_\(on\|off\)\s*"
235"syn match vhdlPreProc "\(^\|\s\)--\s*simulation\s\+translate_\(on\|off\)\s*"
Bram Moolenaar5f148ec2016-03-07 22:59:26 +0100236syn match vhdlPreProc "\(^\|\s\)--\s*pragma\s\+translate_\(on\|off\)\s*"
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100237syn match vhdlPreProc "\(^\|\s\)--\s*pragma\s\+synthesis_\(on\|off\)\s*"
238syn match vhdlPreProc "\(^\|\s\)--\s*synopsys\s\+translate_\(on\|off\)\s*"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000239
Bram Moolenaarbaca7f72013-09-22 14:42:24 +0200240"Modify the following as needed. The trade-off is performance versus functionality.
Bram Moolenaar2c5e8e82015-12-05 20:59:21 +0100241syn sync minlines=600
Bram Moolenaarbaca7f72013-09-22 14:42:24 +0200242
Bram Moolenaar071d4272004-06-13 20:20:40 +0000243" Define the default highlighting.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200244" Only when an item doesn't have highlighting yet
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200245
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200246hi def link vhdlSpecial Special
247hi def link vhdlStatement Statement
248hi def link vhdlCharacter Character
249hi def link vhdlString String
250hi def link vhdlVector Number
251hi def link vhdlBoolean Number
252hi def link vhdlTodo Todo
253hi def link vhdlFixme Fixme
254hi def link vhdlComment Comment
255hi def link vhdlNumber Number
256hi def link vhdlTime Number
257hi def link vhdlType Type
258hi def link vhdlOperator Operator
259hi def link vhdlError Error
260hi def link vhdlAttribute Special
261hi def link vhdlPreProc PreProc
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200262
Bram Moolenaar071d4272004-06-13 20:20:40 +0000263
264let b:current_syntax = "vhdl"
265
Bram Moolenaarb8ff1fb2012-02-04 21:59:01 +0100266let &cpo = s:cpo_save
267unlet s:cpo_save
Bram Moolenaar071d4272004-06-13 20:20:40 +0000268" vim: ts=8