0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00
vim/runtime/syntax/vhdl.vim

269 lines
9.5 KiB
VimL
Raw Normal View History

2004-06-13 20:20:40 +00:00
" Vim syntax file
2016-03-07 22:59:26 +01:00
" Language: VHDL [VHSIC (Very High Speed Integrated Circuit) Hardware Description Language]
2020-03-19 20:37:11 +01:00
" Maintainer: Daniel Kho <daniel.kho@logik.haus>
" Previous Maintainer: Czo <Olivier.Sirol@lip6.fr>
2016-03-07 22:59:26 +01:00
" Credits: Stephan Hegel <stephan.hegel@snc.siemens.com.cn>
2020-03-19 20:37:11 +01:00
" Last Changed: 2020 Mar 09 by Daniel Kho
2004-06-13 20:20:40 +00:00
" quit when a syntax file was already loaded
if exists("b:current_syntax")
2004-06-13 20:20:40 +00:00
finish
endif
let s:cpo_save = &cpo
set cpo&vim
2004-06-13 20:20:40 +00:00
" case is not significant
2015-12-05 20:59:21 +01:00
syn case ignore
2004-06-13 20:20:40 +00:00
" VHDL keywords
2015-12-05 20:59:21 +01:00
syn keyword vhdlStatement access after alias all assert
syn keyword vhdlStatement architecture array attribute
syn keyword vhdlStatement assume assume_guarantee
syn keyword vhdlStatement begin block body buffer bus
syn keyword vhdlStatement case component configuration constant
syn keyword vhdlStatement context cover
syn keyword vhdlStatement default disconnect downto
syn keyword vhdlStatement elsif end entity exit
syn keyword vhdlStatement file for function
syn keyword vhdlStatement fairness force
syn keyword vhdlStatement generate generic group guarded
syn keyword vhdlStatement impure in inertial inout is
syn keyword vhdlStatement label library linkage literal loop
syn keyword vhdlStatement map
syn keyword vhdlStatement new next null
syn keyword vhdlStatement of on open others out
syn keyword vhdlStatement package port postponed procedure process pure
syn keyword vhdlStatement parameter property protected
syn keyword vhdlStatement range record register reject report return
syn keyword vhdlStatement release restrict restrict_guarantee
syn keyword vhdlStatement select severity signal shared
syn keyword vhdlStatement subtype
syn keyword vhdlStatement sequence strong
syn keyword vhdlStatement then to transport type
syn keyword vhdlStatement unaffected units until use
syn keyword vhdlStatement variable
2020-03-19 20:37:11 +01:00
" VHDL-2019 interface
2018-05-06 17:57:30 +02:00
syn keyword vhdlStatement view
2015-12-05 20:59:21 +01:00
syn keyword vhdlStatement vmode vprop vunit
syn keyword vhdlStatement wait when while with
syn keyword vhdlStatement note warning error failure
" Linting of conditionals.
syn match vhdlStatement "\<\(if\|else\)\>"
syn match vhdlError "\<else\s\+if\>"
2004-06-13 20:20:40 +00:00
2016-03-07 22:59:26 +01:00
" Types and type qualifiers
" Predefined standard VHDL types
2016-03-12 12:57:59 +01:00
syn match vhdlType "\<bit\>\'\="
syn match vhdlType "\<boolean\>\'\="
syn match vhdlType "\<natural\>\'\="
syn match vhdlType "\<positive\>\'\="
syn match vhdlType "\<integer\>\'\="
syn match vhdlType "\<real\>\'\="
syn match vhdlType "\<time\>\'\="
2016-03-07 22:59:26 +01:00
2016-03-12 12:57:59 +01:00
syn match vhdlType "\<bit_vector\>\'\="
syn match vhdlType "\<boolean_vector\>\'\="
syn match vhdlType "\<integer_vector\>\'\="
syn match vhdlType "\<real_vector\>\'\="
syn match vhdlType "\<time_vector\>\'\="
2016-03-07 22:59:26 +01:00
2016-03-12 12:57:59 +01:00
syn match vhdlType "\<character\>\'\="
syn match vhdlType "\<string\>\'\="
2018-05-06 17:57:30 +02:00
syn keyword vhdlType line text side width
2016-03-07 22:59:26 +01:00
" Predefined standard IEEE VHDL types
2016-03-12 12:57:59 +01:00
syn match vhdlType "\<std_ulogic\>\'\="
syn match vhdlType "\<std_logic\>\'\="
syn match vhdlType "\<std_ulogic_vector\>\'\="
syn match vhdlType "\<std_logic_vector\>\'\="
syn match vhdlType "\<unresolved_signed\>\'\="
syn match vhdlType "\<unresolved_unsigned\>\'\="
syn match vhdlType "\<u_signed\>\'\="
syn match vhdlType "\<u_unsigned\>\'\="
syn match vhdlType "\<signed\>\'\="
syn match vhdlType "\<unsigned\>\'\="
2016-03-07 22:59:26 +01:00
2004-06-13 20:20:40 +00:00
" array attributes
2015-12-05 20:59:21 +01:00
syn match vhdlAttribute "\'high"
syn match vhdlAttribute "\'left"
syn match vhdlAttribute "\'length"
syn match vhdlAttribute "\'low"
syn match vhdlAttribute "\'range"
syn match vhdlAttribute "\'reverse_range"
syn match vhdlAttribute "\'right"
syn match vhdlAttribute "\'ascending"
2004-06-13 20:20:40 +00:00
" block attributes
2015-12-05 20:59:21 +01:00
syn match vhdlAttribute "\'simple_name"
syn match vhdlAttribute "\'instance_name"
syn match vhdlAttribute "\'path_name"
syn match vhdlAttribute "\'foreign" " VHPI
2004-06-13 20:20:40 +00:00
" signal attribute
2015-12-05 20:59:21 +01:00
syn match vhdlAttribute "\'active"
syn match vhdlAttribute "\'delayed"
syn match vhdlAttribute "\'event"
syn match vhdlAttribute "\'last_active"
syn match vhdlAttribute "\'last_event"
syn match vhdlAttribute "\'last_value"
syn match vhdlAttribute "\'quiet"
syn match vhdlAttribute "\'stable"
syn match vhdlAttribute "\'transaction"
syn match vhdlAttribute "\'driving"
syn match vhdlAttribute "\'driving_value"
2004-06-13 20:20:40 +00:00
" type attributes
2015-12-05 20:59:21 +01:00
syn match vhdlAttribute "\'base"
syn match vhdlAttribute "\'subtype"
syn match vhdlAttribute "\'element"
syn match vhdlAttribute "\'leftof"
syn match vhdlAttribute "\'pos"
syn match vhdlAttribute "\'pred"
syn match vhdlAttribute "\'rightof"
syn match vhdlAttribute "\'succ"
syn match vhdlAttribute "\'val"
syn match vhdlAttribute "\'image"
syn match vhdlAttribute "\'value"
2020-03-19 20:37:11 +01:00
" VHDL-2019 interface attribute
2018-05-06 17:57:30 +02:00
syn match vhdlAttribute "\'converse"
2015-12-05 20:59:21 +01:00
syn keyword vhdlBoolean true false
2004-06-13 20:20:40 +00:00
" for this vector values case is significant
2015-12-05 20:59:21 +01:00
syn case match
2004-06-13 20:20:40 +00:00
" Values for standard VHDL types
2015-12-05 20:59:21 +01:00
syn match vhdlVector "\'[0L1HXWZU\-\?]\'"
syn case ignore
2004-06-13 20:20:40 +00:00
2015-12-05 20:59:21 +01:00
syn match vhdlVector "B\"[01_]\+\""
syn match vhdlVector "O\"[0-7_]\+\""
syn match vhdlVector "X\"[0-9a-f_]\+\""
syn match vhdlCharacter "'.'"
syn region vhdlString start=+"+ end=+"+
2004-06-13 20:20:40 +00:00
" floating numbers
2015-12-05 20:59:21 +01:00
syn match vhdlNumber "-\=\<\d\+\.\d\+\(E[+\-]\=\d\+\)\>"
syn match vhdlNumber "-\=\<\d\+\.\d\+\>"
syn match vhdlNumber "0*2#[01_]\+\.[01_]\+#\(E[+\-]\=\d\+\)\="
syn match vhdlNumber "0*16#[0-9a-f_]\+\.[0-9a-f_]\+#\(E[+\-]\=\d\+\)\="
2004-06-13 20:20:40 +00:00
" integer numbers
2015-12-05 20:59:21 +01:00
syn match vhdlNumber "-\=\<\d\+\(E[+\-]\=\d\+\)\>"
syn match vhdlNumber "-\=\<\d\+\>"
syn match vhdlNumber "0*2#[01_]\+#\(E[+\-]\=\d\+\)\="
syn match vhdlNumber "0*16#[0-9a-f_]\+#\(E[+\-]\=\d\+\)\="
2015-10-13 23:21:27 +02:00
2004-06-13 20:20:40 +00:00
" operators
2015-10-13 23:21:27 +02:00
syn keyword vhdlOperator and nand or nor xor xnor
syn keyword vhdlOperator rol ror sla sll sra srl
syn keyword vhdlOperator mod rem abs not
" Concatenation and math operators
syn match vhdlOperator "&\|+\|-\|\*\|\/"
" Equality and comparison operators
syn match vhdlOperator "=\|\/=\|>\|<\|>="
" Assignment operators
syn match vhdlOperator "<=\|:="
syn match vhdlOperator "=>"
2020-03-19 20:37:11 +01:00
" VHDL-202x concurrent signal association (spaceship) operator
2018-05-06 17:57:30 +02:00
syn match vhdlOperator "<=>"
2015-10-13 23:21:27 +02:00
" VHDL-2008 conversion, matching equality/non-equality operators
syn match vhdlOperator "??\|?=\|?\/=\|?<\|?<=\|?>\|?>="
2015-12-05 20:59:21 +01:00
" VHDL-2008 external names
syn match vhdlOperator "<<\|>>"
2015-10-13 23:21:27 +02:00
" Linting for illegal operators
" '='
syn match vhdlError "\(=\)[<=&+\-\*\/\\]\+"
syn match vhdlError "[=&+\-\*\\]\+\(=\)"
" '>', '<'
2015-12-05 20:59:21 +01:00
" Allow external names: '<< ... >>'
syn match vhdlError "\(>\)[<&+\-\/\\]\+"
syn match vhdlError "[&+\-\/\\]\+\(>\)"
syn match vhdlError "\(<\)[&+\-\/\\]\+"
syn match vhdlError "[>=&+\-\/\\]\+\(<\)"
2015-10-13 23:21:27 +02:00
" Covers most operators
2015-12-05 20:59:21 +01:00
" support negative sign after operators. E.g. q<=-b;
2020-03-19 20:37:11 +01:00
" Supports VHDL-202x spaceship (concurrent simple signal association).
2018-05-06 17:57:30 +02:00
syn match vhdlError "\(<=\)[<=&+\*\\?:]\+"
syn match vhdlError "[>=&+\-\*\\:]\+\(=>\)"
syn match vhdlError "\(&\|+\|\-\|\*\*\|\/=\|??\|?=\|?\/=\|?<=\|?>=\|>=\|:=\|=>\)[<>=&+\*\\?:]\+"
syn match vhdlError "[<>=&+\-\*\\:]\+\(&\|+\|\*\*\|\/=\|??\|?=\|?\/=\|?<\|?<=\|?>\|?>=\|>=\|<=\|:=\)"
2015-12-05 20:59:21 +01:00
syn match vhdlError "\(?<\|?>\)[<>&+\*\/\\?:]\+"
syn match vhdlError "\(<<\|>>\)[<>&+\*\/\\?:]\+"
2015-10-13 23:21:27 +02:00
"syn match vhdlError "[?]\+\(&\|+\|\-\|\*\*\|??\|?=\|?\/=\|?<\|?<=\|?>\|?>=\|:=\|=>\)"
" '/'
syn match vhdlError "\(\/\)[<>&+\-\*\/\\?:]\+"
syn match vhdlError "[<>=&+\-\*\/\\:]\+\(\/\)"
syn match vhdlSpecial "<>"
syn match vhdlSpecial "[().,;]"
2004-06-13 20:20:40 +00:00
" time
2015-12-05 20:59:21 +01:00
syn match vhdlTime "\<\d\+\s\+\(\([fpnum]s\)\|\(sec\)\|\(min\)\|\(hr\)\)\>"
syn match vhdlTime "\<\d\+\.\d\+\s\+\(\([fpnum]s\)\|\(sec\)\|\(min\)\|\(hr\)\)\>"
2004-06-13 20:20:40 +00:00
2015-12-05 20:59:21 +01:00
syn case match
syn keyword vhdlTodo contained TODO NOTE
syn keyword vhdlFixme contained FIXME
syn case ignore
2015-10-13 23:21:27 +02:00
2015-12-05 20:59:21 +01:00
syn region vhdlComment start="/\*" end="\*/" contains=vhdlTodo,vhdlFixme,@Spell
syn match vhdlComment "\(^\|\s\)--.*" contains=vhdlTodo,vhdlFixme,@Spell
2015-06-09 19:44:55 +02:00
2016-03-07 22:59:26 +01:00
" Standard IEEE P1076.6 preprocessor directives (metacomments).
syn match vhdlPreProc "/\*\s*rtl_synthesis\s\+\(on\|off\)\s*\*/"
syn match vhdlPreProc "\(^\|\s\)--\s*rtl_synthesis\s\+\(on\|off\)\s*"
syn match vhdlPreProc "/\*\s*rtl_syn\s\+\(on\|off\)\s*\*/"
syn match vhdlPreProc "\(^\|\s\)--\s*rtl_syn\s\+\(on\|off\)\s*"
2015-10-13 23:21:27 +02:00
" Industry-standard directives. These are not standard VHDL, but are commonly
" used in the industry.
2015-12-05 20:59:21 +01:00
syn match vhdlPreProc "/\*\s*synthesis\s\+translate_\(on\|off\)\s*\*/"
"syn match vhdlPreProc "/\*\s*simulation\s\+translate_\(on\|off\)\s*\*/"
2016-03-07 22:59:26 +01:00
syn match vhdlPreProc "/\*\s*pragma\s\+translate_\(on\|off\)\s*\*/"
2015-12-05 20:59:21 +01:00
syn match vhdlPreProc "/\*\s*pragma\s\+synthesis_\(on\|off\)\s*\*/"
syn match vhdlPreProc "/\*\s*synopsys\s\+translate_\(on\|off\)\s*\*/"
syn match vhdlPreProc "\(^\|\s\)--\s*synthesis\s\+translate_\(on\|off\)\s*"
"syn match vhdlPreProc "\(^\|\s\)--\s*simulation\s\+translate_\(on\|off\)\s*"
2016-03-07 22:59:26 +01:00
syn match vhdlPreProc "\(^\|\s\)--\s*pragma\s\+translate_\(on\|off\)\s*"
2015-12-05 20:59:21 +01:00
syn match vhdlPreProc "\(^\|\s\)--\s*pragma\s\+synthesis_\(on\|off\)\s*"
syn match vhdlPreProc "\(^\|\s\)--\s*synopsys\s\+translate_\(on\|off\)\s*"
2004-06-13 20:20:40 +00:00
"Modify the following as needed. The trade-off is performance versus functionality.
2015-12-05 20:59:21 +01:00
syn sync minlines=600
2004-06-13 20:20:40 +00:00
" Define the default highlighting.
" Only when an item doesn't have highlighting yet
hi def link vhdlSpecial Special
hi def link vhdlStatement Statement
hi def link vhdlCharacter Character
hi def link vhdlString String
hi def link vhdlVector Number
hi def link vhdlBoolean Number
hi def link vhdlTodo Todo
hi def link vhdlFixme Fixme
hi def link vhdlComment Comment
hi def link vhdlNumber Number
hi def link vhdlTime Number
hi def link vhdlType Type
hi def link vhdlOperator Operator
hi def link vhdlError Error
hi def link vhdlAttribute Special
hi def link vhdlPreProc PreProc
2004-06-13 20:20:40 +00:00
let b:current_syntax = "vhdl"
let &cpo = s:cpo_save
unlet s:cpo_save
2004-06-13 20:20:40 +00:00
" vim: ts=8