vhdl.vim 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. " Vim syntax file
  2. " Language: VHDL [VHSIC (Very High Speed Integrated Circuit) Hardware Description Language]
  3. " Maintainer: Daniel Kho <daniel.kho@logik.haus>
  4. " Previous Maintainer: Czo <Olivier.Sirol@lip6.fr>
  5. " Credits: Stephan Hegel <stephan.hegel@snc.siemens.com.cn>
  6. " Last Changed: 2020 Apr 04 by Daniel Kho
  7. " quit when a syntax file was already loaded
  8. if exists("b:current_syntax")
  9. finish
  10. endif
  11. let s:cpo_save = &cpo
  12. set cpo&vim
  13. " case is not significant
  14. syn case ignore
  15. " VHDL 1076-2019 keywords
  16. syn keyword vhdlStatement access after alias all
  17. syn keyword vhdlStatement architecture array attribute
  18. syn keyword vhdlStatement assert assume
  19. syn keyword vhdlStatement begin block body buffer bus
  20. syn keyword vhdlStatement case component configuration constant
  21. syn keyword vhdlStatement context cover
  22. syn keyword vhdlStatement default disconnect downto
  23. syn keyword vhdlStatement elsif end entity exit
  24. syn keyword vhdlStatement file for function
  25. syn keyword vhdlStatement fairness force
  26. syn keyword vhdlStatement generate generic group guarded
  27. syn keyword vhdlStatement impure in inertial inout is
  28. syn keyword vhdlStatement label library linkage literal loop
  29. syn keyword vhdlStatement map
  30. syn keyword vhdlStatement new next null
  31. syn keyword vhdlStatement of on open others out
  32. syn keyword vhdlStatement package port postponed procedure process pure
  33. syn keyword vhdlStatement parameter property protected private
  34. syn keyword vhdlStatement range record register reject report return
  35. syn keyword vhdlStatement release restrict
  36. syn keyword vhdlStatement select severity signal shared subtype
  37. syn keyword vhdlStatement sequence strong
  38. syn keyword vhdlStatement then to transport type
  39. syn keyword vhdlStatement unaffected units until use
  40. syn keyword vhdlStatement variable view
  41. syn keyword vhdlStatement vpkg vmode vprop vunit
  42. syn keyword vhdlStatement wait when while with
  43. " VHDL predefined severity levels
  44. syn keyword vhdlAttribute note warning error failure
  45. " Linting of conditionals.
  46. syn match vhdlStatement "\<\(if\|else\)\>"
  47. syn match vhdlError "\<else\s\+if\>"
  48. " Types and type qualifiers
  49. " Predefined standard VHDL types
  50. syn match vhdlType "\<bit\>\'\="
  51. syn match vhdlType "\<boolean\>\'\="
  52. syn match vhdlType "\<natural\>\'\="
  53. syn match vhdlType "\<positive\>\'\="
  54. syn match vhdlType "\<integer\>\'\="
  55. syn match vhdlType "\<real\>\'\="
  56. syn match vhdlType "\<time\>\'\="
  57. syn match vhdlType "\<bit_vector\>\'\="
  58. syn match vhdlType "\<boolean_vector\>\'\="
  59. syn match vhdlType "\<integer_vector\>\'\="
  60. syn match vhdlType "\<real_vector\>\'\="
  61. syn match vhdlType "\<time_vector\>\'\="
  62. syn match vhdlType "\<character\>\'\="
  63. syn match vhdlType "\<string\>\'\="
  64. syn keyword vhdlType line text side width
  65. " Predefined standard IEEE VHDL types
  66. syn match vhdlType "\<std_ulogic\>\'\="
  67. syn match vhdlType "\<std_logic\>\'\="
  68. syn match vhdlType "\<std_ulogic_vector\>\'\="
  69. syn match vhdlType "\<std_logic_vector\>\'\="
  70. syn match vhdlType "\<unresolved_signed\>\'\="
  71. syn match vhdlType "\<unresolved_unsigned\>\'\="
  72. syn match vhdlType "\<u_signed\>\'\="
  73. syn match vhdlType "\<u_unsigned\>\'\="
  74. syn match vhdlType "\<signed\>\'\="
  75. syn match vhdlType "\<unsigned\>\'\="
  76. " array attributes
  77. syn match vhdlAttribute "\'high"
  78. syn match vhdlAttribute "\'left"
  79. syn match vhdlAttribute "\'length"
  80. syn match vhdlAttribute "\'low"
  81. syn match vhdlAttribute "\'range"
  82. syn match vhdlAttribute "\'reverse_range"
  83. syn match vhdlAttribute "\'right"
  84. syn match vhdlAttribute "\'ascending"
  85. " block attributes
  86. syn match vhdlAttribute "\'simple_name"
  87. syn match vhdlAttribute "\'instance_name"
  88. syn match vhdlAttribute "\'path_name"
  89. syn match vhdlAttribute "\'foreign" " VHPI
  90. " signal attribute
  91. syn match vhdlAttribute "\'active"
  92. syn match vhdlAttribute "\'delayed"
  93. syn match vhdlAttribute "\'event"
  94. syn match vhdlAttribute "\'last_active"
  95. syn match vhdlAttribute "\'last_event"
  96. syn match vhdlAttribute "\'last_value"
  97. syn match vhdlAttribute "\'quiet"
  98. syn match vhdlAttribute "\'stable"
  99. syn match vhdlAttribute "\'transaction"
  100. syn match vhdlAttribute "\'driving"
  101. syn match vhdlAttribute "\'driving_value"
  102. " type attributes
  103. syn match vhdlAttribute "\'base"
  104. syn match vhdlAttribute "\'subtype"
  105. syn match vhdlAttribute "\'element"
  106. syn match vhdlAttribute "\'leftof"
  107. syn match vhdlAttribute "\'pos"
  108. syn match vhdlAttribute "\'pred"
  109. syn match vhdlAttribute "\'rightof"
  110. syn match vhdlAttribute "\'succ"
  111. syn match vhdlAttribute "\'val"
  112. syn match vhdlAttribute "\'image"
  113. syn match vhdlAttribute "\'value"
  114. " VHDL-2019 interface attribute
  115. syn match vhdlAttribute "\'converse"
  116. syn keyword vhdlBoolean true false
  117. " for this vector values case is significant
  118. syn case match
  119. " Values for standard VHDL types
  120. syn match vhdlVector "\'[0L1HXWZU\-\?]\'"
  121. syn case ignore
  122. syn match vhdlVector "B\"[01_]\+\""
  123. syn match vhdlVector "O\"[0-7_]\+\""
  124. syn match vhdlVector "X\"[0-9a-f_]\+\""
  125. syn match vhdlCharacter "'.'"
  126. syn region vhdlString start=+"+ end=+"+
  127. " floating numbers
  128. syn match vhdlNumber "-\=\<\d\+\.\d\+\(E[+\-]\=\d\+\)\>"
  129. syn match vhdlNumber "-\=\<\d\+\.\d\+\>"
  130. syn match vhdlNumber "0*2#[01_]\+\.[01_]\+#\(E[+\-]\=\d\+\)\="
  131. syn match vhdlNumber "0*16#[0-9a-f_]\+\.[0-9a-f_]\+#\(E[+\-]\=\d\+\)\="
  132. " integer numbers
  133. syn match vhdlNumber "-\=\<\d\+\(E[+\-]\=\d\+\)\>"
  134. syn match vhdlNumber "-\=\<\d\+\>"
  135. syn match vhdlNumber "0*2#[01_]\+#\(E[+\-]\=\d\+\)\="
  136. syn match vhdlNumber "0*16#[0-9a-f_]\+#\(E[+\-]\=\d\+\)\="
  137. " operators
  138. syn keyword vhdlOperator and nand or nor xor xnor
  139. syn keyword vhdlOperator rol ror sla sll sra srl
  140. syn keyword vhdlOperator mod rem abs not
  141. " Concatenation and math operators
  142. syn match vhdlOperator "&\|+\|-\|\*\|\/"
  143. " Equality and comparison operators
  144. syn match vhdlOperator "=\|\/=\|>\|<\|>="
  145. " Assignment operators
  146. syn match vhdlOperator "<=\|:="
  147. syn match vhdlOperator "=>"
  148. " VHDL-202x concurrent signal association (spaceship) operator
  149. syn match vhdlOperator "<=>"
  150. " VHDL-2008 conversion, matching equality/non-equality operators
  151. syn match vhdlOperator "??\|?=\|?\/=\|?<\|?<=\|?>\|?>="
  152. " VHDL-2008 external names
  153. syn match vhdlOperator "<<\|>>"
  154. " Linting for illegal operators
  155. " '='
  156. syn match vhdlError "\(=\)[<=&+\-\*\/\\]\+"
  157. syn match vhdlError "[=&+\-\*\\]\+\(=\)"
  158. " '>', '<'
  159. " Allow external names: '<< ... >>'
  160. syn match vhdlError "\(>\)[<&+\-\/\\]\+"
  161. syn match vhdlError "[&+\-\/\\]\+\(>\)"
  162. syn match vhdlError "\(<\)[&+\-\/\\]\+"
  163. syn match vhdlError "[>=&+\-\/\\]\+\(<\)"
  164. " Covers most operators
  165. " support negative sign after operators. E.g. q<=-b;
  166. " Supports VHDL-202x spaceship (concurrent simple signal association).
  167. syn match vhdlError "\(<=\)[<=&+\*\\?:]\+"
  168. syn match vhdlError "[>=&+\-\*\\:]\+\(=>\)"
  169. syn match vhdlError "\(&\|+\|\-\|\*\*\|\/=\|??\|?=\|?\/=\|?<=\|?>=\|>=\|:=\|=>\)[<>=&+\*\\?:]\+"
  170. syn match vhdlError "[<>=&+\-\*\\:]\+\(&\|+\|\*\*\|\/=\|??\|?=\|?\/=\|?<\|?<=\|?>\|?>=\|>=\|<=\|:=\)"
  171. syn match vhdlError "\(?<\|?>\)[<>&+\*\/\\?:]\+"
  172. syn match vhdlError "\(<<\|>>\)[<>&+\*\/\\?:]\+"
  173. "syn match vhdlError "[?]\+\(&\|+\|\-\|\*\*\|??\|?=\|?\/=\|?<\|?<=\|?>\|?>=\|:=\|=>\)"
  174. " '/'
  175. syn match vhdlError "\(\/\)[<>&+\-\*\/\\?:]\+"
  176. syn match vhdlError "[<>=&+\-\*\/\\:]\+\(\/\)"
  177. syn match vhdlSpecial "<>"
  178. syn match vhdlSpecial "[().,;]"
  179. " time
  180. syn match vhdlTime "\<\d\+\s\+\(\([fpnum]s\)\|\(sec\)\|\(min\)\|\(hr\)\)\>"
  181. syn match vhdlTime "\<\d\+\.\d\+\s\+\(\([fpnum]s\)\|\(sec\)\|\(min\)\|\(hr\)\)\>"
  182. syn case match
  183. syn keyword vhdlTodo contained TODO NOTE
  184. syn keyword vhdlFixme contained FIXME
  185. syn case ignore
  186. syn region vhdlComment start="/\*" end="\*/" contains=vhdlTodo,vhdlFixme,@Spell
  187. syn match vhdlComment "\(^\|\s\)--.*" contains=vhdlTodo,vhdlFixme,@Spell
  188. " Standard IEEE P1076.6 preprocessor directives (metacomments).
  189. syn match vhdlPreProc "/\*\s*rtl_synthesis\s\+\(on\|off\)\s*\*/"
  190. syn match vhdlPreProc "\(^\|\s\)--\s*rtl_synthesis\s\+\(on\|off\)\s*"
  191. syn match vhdlPreProc "/\*\s*rtl_syn\s\+\(on\|off\)\s*\*/"
  192. syn match vhdlPreProc "\(^\|\s\)--\s*rtl_syn\s\+\(on\|off\)\s*"
  193. " Industry-standard directives. These are not standard VHDL, but are commonly
  194. " used in the industry.
  195. syn match vhdlPreProc "/\*\s*synthesis\s\+translate_\(on\|off\)\s*\*/"
  196. "syn match vhdlPreProc "/\*\s*simulation\s\+translate_\(on\|off\)\s*\*/"
  197. syn match vhdlPreProc "/\*\s*pragma\s\+translate_\(on\|off\)\s*\*/"
  198. syn match vhdlPreProc "/\*\s*pragma\s\+synthesis_\(on\|off\)\s*\*/"
  199. syn match vhdlPreProc "/\*\s*synopsys\s\+translate_\(on\|off\)\s*\*/"
  200. syn match vhdlPreProc "\(^\|\s\)--\s*synthesis\s\+translate_\(on\|off\)\s*"
  201. "syn match vhdlPreProc "\(^\|\s\)--\s*simulation\s\+translate_\(on\|off\)\s*"
  202. syn match vhdlPreProc "\(^\|\s\)--\s*pragma\s\+translate_\(on\|off\)\s*"
  203. syn match vhdlPreProc "\(^\|\s\)--\s*pragma\s\+synthesis_\(on\|off\)\s*"
  204. syn match vhdlPreProc "\(^\|\s\)--\s*synopsys\s\+translate_\(on\|off\)\s*"
  205. "Modify the following as needed. The trade-off is performance versus functionality.
  206. syn sync minlines=600
  207. " Define the default highlighting.
  208. " Only when an item doesn't have highlighting yet
  209. hi def link vhdlSpecial Special
  210. hi def link vhdlStatement Statement
  211. hi def link vhdlCharacter Character
  212. hi def link vhdlString String
  213. hi def link vhdlVector Number
  214. hi def link vhdlBoolean Number
  215. hi def link vhdlTodo Todo
  216. hi def link vhdlFixme Fixme
  217. hi def link vhdlComment Comment
  218. hi def link vhdlNumber Number
  219. hi def link vhdlTime Number
  220. hi def link vhdlType Type
  221. hi def link vhdlOperator Operator
  222. hi def link vhdlError Error
  223. hi def link vhdlAttribute Special
  224. hi def link vhdlPreProc PreProc
  225. let b:current_syntax = "vhdl"
  226. let &cpo = s:cpo_save
  227. unlet s:cpo_save
  228. " vim: ts=8