Skip to content

Commit 00ba9dd

Browse files
authored
vhdl: add snippets for conditional assignments, signals, variables, functions, procedures, etc. (rafamadriz#492)
* vhdl.json: more descriptive prefixes for generate snippets * vhdl.json: add signal declaration snippets * vhdl.json: add variable and constant snippets * vhdl.json: add function snippet * vhdl.json: fix missing comma in function snippet * vhdl.json: add procedure snippet * vhdl.json: remove variable section from function and procedure * vhdl.json: add with select assignment snippet * vhdl.json: add when-else assignment snippet * vhdl.json: add missing semicolon to when-else snippet * vhdl.json: remove semicolon from type snippets without initialiser Semicolon is not needed in these snippets because they are already contained in the signal, variable and constant snippets. Type snippets with initialiser are also not needed any more because initialiser is also contained in the other snippets. They can be deprecated in the future. * vhdl.json: remove duplicated zeroes snippets * vhdl.json: add snippet for when alternatives in case statements
1 parent 8929e8f commit 00ba9dd

File tree

1 file changed

+82
-17
lines changed

1 file changed

+82
-17
lines changed

snippets/vhdl.json

Lines changed: 82 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
]
8181
},
8282
"case_generate": {
83-
"prefix": "case",
83+
"prefix": "casegen",
8484
"description": "Case Generate Statement",
8585
"body": [
8686
"${1:generate_label}: case ${2:expression} generate",
@@ -93,13 +93,32 @@
9393
"end generate $1;"
9494
]
9595
},
96+
"when_in_case": {
97+
"prefix": "cwhen, whenc",
98+
"description": "when alternative of a case statement",
99+
"body": [ "when ${1:choice} => $0" ]
100+
},
101+
"with_select": {
102+
"prefix": "with",
103+
"description": "With-Select assignment",
104+
"body": [
105+
"with ${1:src} select ${2:dst} <= ${3:value} when $4{condition};"
106+
]
107+
},
108+
"when_else": {
109+
"prefix": "whenelse",
110+
"description": "When-Else assignment",
111+
"body": [
112+
"${1:dst} <= ${2: true_value} when ${3: condition} else ${4:false_value};"
113+
]
114+
},
96115
"if": {
97116
"prefix": "if",
98117
"description": "If Statement",
99118
"body": ["if ${1:condition} then", "\t$0", "end if;"]
100119
},
101120
"if_generate": {
102-
"prefix": "if",
121+
"prefix": "ifgen",
103122
"description": "If Generate Statement",
104123
"body": [
105124
"${1:generate_label}: if ${2:condition} generate",
@@ -124,7 +143,7 @@
124143
"body": ["for ${1:loop_var} in ${2:range} loop", "\t$0", "end loop;"]
125144
},
126145
"for_generate": {
127-
"prefix": "for",
146+
"prefix": "forgen",
128147
"description": "For Generate",
129148
"body": [
130149
"${1:generate_label}: for ${2:iteration} generate",
@@ -167,6 +186,62 @@
167186
"subtype ${1:subtype_name} is ${2:base_type} range ${3:0} ${4|to,downto|} ${5:7};"
168187
]
169188
},
189+
"signal": {
190+
"prefix": "signal",
191+
"description": "Signal declaration",
192+
"body": [
193+
"signal ${1:signal_name} : ${2:std_logic};"
194+
]
195+
},
196+
"signal initialised": {
197+
"prefix": "sigi, signali",
198+
"description": "Signal declaration with initialisation",
199+
"body": [
200+
"signal ${1:signal_name} : ${2:std_logic} := ${3:'0'};"
201+
]
202+
},
203+
"variable": {
204+
"prefix": "variable",
205+
"description": "variable declaration",
206+
"body": [
207+
"variable ${1:var_name} : ${2:integer};"
208+
]
209+
},
210+
"variable initialised": {
211+
"prefix": "vari, variablei",
212+
"description": "Variable declaration with initialisation",
213+
"body": [
214+
"variable ${1:var_name} : ${2:integer} := ${3:0};"
215+
]
216+
},
217+
"constant": {
218+
"prefix": "constant",
219+
"description": "Constant declaration with initialisation",
220+
"body": [
221+
"constant ${1:const_name} : ${2:integer} := ${3:0};"
222+
]
223+
},
224+
"function": {
225+
"prefix": "function, pfunc",
226+
"description": "Pure function declaration",
227+
"body": [
228+
"function ${1:func_name}(${2:})",
229+
"\treturn ${3:return_type} is",
230+
"begin",
231+
"\t$0",
232+
"end function $1;"
233+
]
234+
},
235+
"procedure": {
236+
"prefix": "procedure",
237+
"description": "Procedure declaration",
238+
"body": [
239+
"procedure ${1:proc_name}(${2:}) is",
240+
"begin",
241+
"\t$0",
242+
"end procedure $1;"
243+
]
244+
},
170245
"testbench_process": {
171246
"prefix": "tproc, processt",
172247
"description": "Testbench Process (No Sensitivity List)",
@@ -215,7 +290,7 @@
215290
"std_logic": {
216291
"prefix": "std",
217292
"description": "std_logic Type",
218-
"body": "std_logic;"
293+
"body": "std_logic"
219294
},
220295
"std_logic initialised": {
221296
"prefix": "stdi",
@@ -225,7 +300,7 @@
225300
"std_logic_vector": {
226301
"prefix": "stdv",
227302
"description": "std_logic_vector Type",
228-
"body": "std_logic_vector(${1:7} ${2|downto,to|} ${3:0});"
303+
"body": "std_logic_vector(${1:7} ${2|downto,to|} ${3:0})"
229304
},
230305
"std_logic_vector initialised": {
231306
"prefix": "stdvi",
@@ -235,7 +310,7 @@
235310
"std_ulogic_vector": {
236311
"prefix": "stduv",
237312
"description": "std_ulogic_vector Type",
238-
"body": "std_ulogic_vector(${1:7} ${2|downto,to|} ${3:0});"
313+
"body": "std_ulogic_vector(${1:7} ${2|downto,to|} ${3:0})"
239314
},
240315
"std_ulogic_vector initialised": {
241316
"prefix": "stduvi",
@@ -282,16 +357,6 @@
282357
"description": "Zero Others Array",
283358
"body": "(others => (others => '1'))"
284359
},
285-
"zeroes": {
286-
"prefix": "oth",
287-
"description": "Zero Others",
288-
"body": "(others => '0')"
289-
},
290-
"zeroes_arr": {
291-
"prefix": "otharr",
292-
"description": "Zero Others Array",
293-
"body": "(others => (others => '0'))"
294-
},
295360
"integer_range_limitation": {
296361
"prefix": "intr",
297362
"description": "Integer (Range Limitation)",
@@ -302,4 +367,4 @@
302367
"description": "While Loop",
303368
"body": ["while ${1:condition} loop", "\t$0", "end loop;"]
304369
}
305-
}
370+
}

0 commit comments

Comments
 (0)