blob: eeba10a41c3baaff35a60f70386caf13f84c353d [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 Moolenaar60cce2f2015-10-13 23:21:27 +02006" Last Changed: 2015 Oct 13 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" This is not VHDL. I use the C-Preprocessor cpp to generate different binaries
22" from one VHDL source file. Unfortunately there is no preprocessor for VHDL
23" available. If you don't like this, please remove the following lines.
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020024"syn match cDefine "^#ifdef[ ]\+[A-Za-z_]\+"
25"syn match cDefine "^#endif"
Bram Moolenaar071d4272004-06-13 20:20:40 +000026
27" case is not significant
28syn case ignore
29
30" VHDL keywords
31syn keyword vhdlStatement access after alias all assert
32syn keyword vhdlStatement architecture array attribute
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020033syn keyword vhdlStatement assume assume_guarantee
Bram Moolenaar071d4272004-06-13 20:20:40 +000034syn keyword vhdlStatement begin block body buffer bus
35syn keyword vhdlStatement case component configuration constant
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020036syn keyword vhdlStatement context cover
37syn keyword vhdlStatement default disconnect downto
Bram Moolenaar071d4272004-06-13 20:20:40 +000038syn keyword vhdlStatement elsif end entity exit
39syn keyword vhdlStatement file for function
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020040syn keyword vhdlStatement fairness force
Bram Moolenaar071d4272004-06-13 20:20:40 +000041syn keyword vhdlStatement generate generic group guarded
42syn keyword vhdlStatement impure in inertial inout is
43syn keyword vhdlStatement label library linkage literal loop
44syn keyword vhdlStatement map
45syn keyword vhdlStatement new next null
46syn keyword vhdlStatement of on open others out
47syn keyword vhdlStatement package port postponed procedure process pure
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020048syn keyword vhdlStatement parameter property protected
Bram Moolenaar071d4272004-06-13 20:20:40 +000049syn keyword vhdlStatement range record register reject report return
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020050syn keyword vhdlStatement release restrict restrict_guarantee
Bram Moolenaar071d4272004-06-13 20:20:40 +000051syn keyword vhdlStatement select severity signal shared
52syn keyword vhdlStatement subtype
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020053syn keyword vhdlStatement sequence strong
Bram Moolenaar071d4272004-06-13 20:20:40 +000054syn keyword vhdlStatement then to transport type
55syn keyword vhdlStatement unaffected units until use
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020056syn keyword vhdlStatement variable
57syn keyword vhdlStatement vmode vprop vunit
58syn keyword vhdlStatement wait when while with
Bram Moolenaar071d4272004-06-13 20:20:40 +000059syn keyword vhdlStatement note warning error failure
60
61" Special match for "if" and "else" since "else if" shouldn't be highlighted.
62" The right keyword is "elsif"
63syn match vhdlStatement "\<\(if\|else\)\>"
64syn match vhdlNone "\<else\s\+if\>$"
65syn match vhdlNone "\<else\s\+if\>\s"
66
Bram Moolenaarc8734422012-06-01 22:38:45 +020067" Predefined VHDL types
Bram Moolenaar071d4272004-06-13 20:20:40 +000068syn keyword vhdlType bit bit_vector
69syn keyword vhdlType character boolean integer real time
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020070syn keyword vhdlType boolean_vector integer_vector real_vector time_vector
Bram Moolenaar071d4272004-06-13 20:20:40 +000071syn keyword vhdlType string severity_level
Bram Moolenaarc8734422012-06-01 22:38:45 +020072" Predefined standard ieee VHDL types
Bram Moolenaar071d4272004-06-13 20:20:40 +000073syn keyword vhdlType positive natural signed unsigned
Bram Moolenaar60cce2f2015-10-13 23:21:27 +020074syn keyword vhdlType unresolved_signed unresolved_unsigned u_signed u_unsigned
Bram Moolenaar071d4272004-06-13 20:20:40 +000075syn keyword vhdlType line text
76syn keyword vhdlType std_logic std_logic_vector
77syn keyword vhdlType std_ulogic std_ulogic_vector
78" Predefined non standard VHDL types for Mentor Graphics Sys1076/QuickHDL
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020079"syn keyword vhdlType qsim_state qsim_state_vector
80"syn keyword vhdlType qsim_12state qsim_12state_vector
81"syn keyword vhdlType qsim_strength
Bram Moolenaar071d4272004-06-13 20:20:40 +000082" Predefined non standard VHDL types for Alliance VLSI CAD
Bram Moolenaarbaca7f72013-09-22 14:42:24 +020083"syn keyword vhdlType mux_bit mux_vector reg_bit reg_vector wor_bit wor_vector
Bram Moolenaar071d4272004-06-13 20:20:40 +000084
85" array attributes
86syn match vhdlAttribute "\'high"
87syn match vhdlAttribute "\'left"
88syn match vhdlAttribute "\'length"
89syn match vhdlAttribute "\'low"
90syn match vhdlAttribute "\'range"
91syn match vhdlAttribute "\'reverse_range"
92syn match vhdlAttribute "\'right"
93syn match vhdlAttribute "\'ascending"
94" block attributes
Bram Moolenaar60cce2f2015-10-13 23:21:27 +020095"syn match vhdlAttribute "\'behaviour" " Non-standard VHDL
96"syn match vhdlAttribute "\'structure" " Non-standard VHDL
Bram Moolenaar071d4272004-06-13 20:20:40 +000097syn match vhdlAttribute "\'simple_name"
98syn match vhdlAttribute "\'instance_name"
99syn match vhdlAttribute "\'path_name"
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200100syn match vhdlAttribute "\'foreign" " VHPI
Bram Moolenaar071d4272004-06-13 20:20:40 +0000101" signal attribute
102syn match vhdlAttribute "\'active"
103syn match vhdlAttribute "\'delayed"
104syn match vhdlAttribute "\'event"
105syn match vhdlAttribute "\'last_active"
106syn match vhdlAttribute "\'last_event"
107syn match vhdlAttribute "\'last_value"
108syn match vhdlAttribute "\'quiet"
109syn match vhdlAttribute "\'stable"
110syn match vhdlAttribute "\'transaction"
111syn match vhdlAttribute "\'driving"
112syn match vhdlAttribute "\'driving_value"
113" type attributes
114syn match vhdlAttribute "\'base"
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200115syn match vhdlAttribute "\'subtype"
116syn match vhdlAttribute "\'element"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000117syn match vhdlAttribute "\'leftof"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000118syn match vhdlAttribute "\'pos"
119syn match vhdlAttribute "\'pred"
120syn match vhdlAttribute "\'rightof"
121syn match vhdlAttribute "\'succ"
122syn match vhdlAttribute "\'val"
123syn match vhdlAttribute "\'image"
124syn match vhdlAttribute "\'value"
125
126syn keyword vhdlBoolean true false
127
128" for this vector values case is significant
129syn case match
130" Values for standard VHDL types
131syn match vhdlVector "\'[0L1HXWZU\-\?]\'"
132" Values for non standard VHDL types qsim_12state for Mentor Graphics Sys1076/QuickHDL
Bram Moolenaarbaca7f72013-09-22 14:42:24 +0200133"syn keyword vhdlVector S0S S1S SXS S0R S1R SXR S0Z S1Z SXZ S0I S1I SXI
Bram Moolenaar071d4272004-06-13 20:20:40 +0000134syn case ignore
135
136syn match vhdlVector "B\"[01_]\+\""
137syn match vhdlVector "O\"[0-7_]\+\""
138syn match vhdlVector "X\"[0-9a-f_]\+\""
139syn match vhdlCharacter "'.'"
Bram Moolenaarbaca7f72013-09-22 14:42:24 +0200140syn region vhdlString start=+"+ end=+"+
Bram Moolenaar071d4272004-06-13 20:20:40 +0000141
142" floating numbers
143syn match vhdlNumber "-\=\<\d\+\.\d\+\(E[+\-]\=\d\+\)\>"
144syn match vhdlNumber "-\=\<\d\+\.\d\+\>"
145syn match vhdlNumber "0*2#[01_]\+\.[01_]\+#\(E[+\-]\=\d\+\)\="
146syn match vhdlNumber "0*16#[0-9a-f_]\+\.[0-9a-f_]\+#\(E[+\-]\=\d\+\)\="
147" integer numbers
148syn match vhdlNumber "-\=\<\d\+\(E[+\-]\=\d\+\)\>"
149syn match vhdlNumber "-\=\<\d\+\>"
150syn match vhdlNumber "0*2#[01_]\+#\(E[+\-]\=\d\+\)\="
151syn match vhdlNumber "0*16#[0-9a-f_]\+#\(E[+\-]\=\d\+\)\="
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200152
Bram Moolenaar071d4272004-06-13 20:20:40 +0000153" operators
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200154syn keyword vhdlOperator and nand or nor xor xnor
155syn keyword vhdlOperator rol ror sla sll sra srl
156syn keyword vhdlOperator mod rem abs not
157" TODO remove the following line. You can't have a sequence of */=+ as an operator for example.
158"syn match vhdlOperator "[&><=:+\-*\/|]"
159" The following lines match valid and invalid operators.
160
161" Concatenation and math operators
162syn match vhdlOperator "&\|+\|-\|\*\|\/"
163
164" Equality and comparison operators
165syn match vhdlOperator "=\|\/=\|>\|<\|>="
166
167" Assignment operators
168syn match vhdlOperator "<=\|:="
169syn match vhdlOperator "=>"
170
171" VHDL-2008 conversion, matching equality/non-equality operators
172syn match vhdlOperator "??\|?=\|?\/=\|?<\|?<=\|?>\|?>="
173
174" Linting for illegal operators
175" '='
176syn match vhdlError "\(=\)[<=&+\-\*\/\\]\+"
177syn match vhdlError "[=&+\-\*\\]\+\(=\)"
178" '>', '<'
179syn match vhdlError "\(>\)[<>&+\-\/\\]\+"
180syn match vhdlError "[>&+\-\/\\]\+\(>\)"
181syn match vhdlError "\(<\)[<&+\-\/\\]\+"
182syn match vhdlError "[<>=&+\-\/\\]\+\(<\)"
183" Covers most operators
184syn match vhdlError "\(&\|+\|\-\|\*\*\|\/=\|??\|?=\|?\/=\|?<=\|?>=\|>=\|<=\|:=\|=>\)[<>=&+\-\*\\?:]\+"
185syn match vhdlError "[<>=&+\-\*\\:]\+\(&\|+\|\-\|\*\*\|\/=\|??\|?=\|?\/=\|?<\|?<=\|?>\|?>=\|>=\|<=\|:=\|=>\)"
186syn match vhdlError "\(?<\|?>\)[<>&+\-\*\/\\?:]\+"
187
188"syn match vhdlError "[?]\+\(&\|+\|\-\|\*\*\|??\|?=\|?\/=\|?<\|?<=\|?>\|?>=\|:=\|=>\)"
189" '/'
190syn match vhdlError "\(\/\)[<>&+\-\*\/\\?:]\+"
191syn match vhdlError "[<>=&+\-\*\/\\:]\+\(\/\)"
192
193syn match vhdlSpecial "<>"
194syn match vhdlSpecial "[().,;]"
195
196
Bram Moolenaar071d4272004-06-13 20:20:40 +0000197" time
198syn match vhdlTime "\<\d\+\s\+\(\([fpnum]s\)\|\(sec\)\|\(min\)\|\(hr\)\)\>"
199syn match vhdlTime "\<\d\+\.\d\+\s\+\(\([fpnum]s\)\|\(sec\)\|\(min\)\|\(hr\)\)\>"
200
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200201syn case match
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200202syn keyword vhdlTodo contained TODO NOTE
203syn keyword vhdlFixme contained FIXME
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200204syn case ignore
Bram Moolenaarbaca7f72013-09-22 14:42:24 +0200205
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200206syn region vhdlComment start="/\*" end="\*/" contains=vhdlTodo,vhdlFixme,@Spell
207syn match vhdlComment "\(^\|\s\)--.*" contains=vhdlTodo,vhdlFixme,@Spell
208
209" Industry-standard directives. These are not standard VHDL, but are commonly
210" used in the industry.
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200211syn match vhdlPreProc "/\* synthesis .* \*/"
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200212"syn match vhdlPreProc "/\* simulation .* \*/"
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200213syn match vhdlPreProc "/\* pragma .* \*/"
214syn match vhdlPreProc "/\* synopsys .* \*/"
215syn match vhdlPreProc "--\s*synthesis .*"
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200216"syn match vhdlPreProc "--\s*simulation .*"
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200217syn match vhdlPreProc "--\s*pragma .*"
218syn match vhdlPreProc "--\s*synopsys .*"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000219
Bram Moolenaarbaca7f72013-09-22 14:42:24 +0200220"Modify the following as needed. The trade-off is performance versus functionality.
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200221syn sync minlines=600
Bram Moolenaarbaca7f72013-09-22 14:42:24 +0200222
Bram Moolenaar071d4272004-06-13 20:20:40 +0000223" Define the default highlighting.
224" For version 5.7 and earlier: only when not done already
225" For version 5.8 and later: only when an item doesn't have highlighting yet
226if version >= 508 || !exists("did_vhdl_syntax_inits")
227 if version < 508
228 let did_vhdl_syntax_inits = 1
229 command -nargs=+ HiLink hi link <args>
230 else
231 command -nargs=+ HiLink hi def link <args>
232 endif
233
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200234 HiLink vhdlSpecial Special
235 HiLink vhdlStatement Statement
236 HiLink vhdlCharacter Character
237 HiLink vhdlString String
238 HiLink vhdlVector Number
239 HiLink vhdlBoolean Number
240 HiLink vhdlTodo Todo
241 HiLink vhdlFixme Fixme
242 HiLink vhdlComment Comment
243 HiLink vhdlNumber Number
244 HiLink vhdlTime Number
245 HiLink vhdlType Type
246 HiLink vhdlOperator Operator
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200247 HiLink vhdlError Error
Bram Moolenaarf2571c62015-06-09 19:44:55 +0200248 HiLink vhdlAttribute Special
249 HiLink vhdlPreProc PreProc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000250
251 delcommand HiLink
252endif
253
254let b:current_syntax = "vhdl"
255
Bram Moolenaarb8ff1fb2012-02-04 21:59:01 +0100256let &cpo = s:cpo_save
257unlet s:cpo_save
Bram Moolenaar071d4272004-06-13 20:20:40 +0000258" vim: ts=8