Files
lucisv/editors/vscode/snippets/verilog.json
T
lucioandClaude Fable 5 de8a307e00 VS Code: snippet templates for common Verilog/SV constructs
30 snippets across both language ids: module, always/always_ff/always_comb
with reset, case-with-default, FSM skeleton, interface with modports,
package, class, assert property, testbench, include guard, and more.
All 30 rendered bodies parse with vfmt itself; $-escaping verified by
round-tripping through the VS Code snippet grammar.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-24 01:42:48 -07:00

132 lines
2.8 KiB
JSON

{
"Module": {
"prefix": "module",
"body": [
"module ${1:name} (",
" input wire ${2:clk},",
" input wire ${3:rst_n}$4",
");",
" $0",
"endmodule"
],
"description": "Module with a port list"
},
"Clocked always block": {
"prefix": "always",
"body": [
"always @(posedge ${1:clk} or negedge ${2:rst_n}) begin",
" if (!$2) begin",
" ${3:q} <= ${4:1'b0};",
" end else begin",
" $0",
" end",
"end"
],
"description": "Sequential always block with async active-low reset"
},
"Combinational always block": {
"prefix": "alwayscomb",
"body": [
"always @(*) begin",
" $0",
"end"
],
"description": "Combinational always @(*) block"
},
"Case with default": {
"prefix": "case",
"body": [
"case (${1:sel})",
" ${2:value}: ${3:statement};",
" default: ${4:statement};",
"endcase"
],
"description": "Case statement with a default branch"
},
"Function": {
"prefix": "function",
"body": [
"function ${1:[7:0]} ${2:name}(input ${3:[7:0]} ${4:arg});",
" begin",
" $2 = ${5:$4};",
" end",
"endfunction"
],
"description": "Function declaration"
},
"Task": {
"prefix": "task",
"body": [
"task ${1:name}(input ${2:[7:0]} ${3:arg});",
" begin",
" $0",
" end",
"endtask"
],
"description": "Task declaration"
},
"Generate for": {
"prefix": "genfor",
"body": [
"genvar ${1:i};",
"generate",
" for ($1 = 0; $1 < ${2:N}; $1 = $1 + 1) begin : ${3:gen_$1}",
" $0",
" end",
"endgenerate"
],
"description": "Generate for loop with a named block"
},
"For loop": {
"prefix": "for",
"body": [
"for (${1:i} = 0; $1 < ${2:N}; $1 = $1 + 1) begin",
" $0",
"end"
],
"description": "For loop"
},
"Initial block": {
"prefix": "initial",
"body": [
"initial begin",
" $0",
"end"
],
"description": "Initial block"
},
"Testbench skeleton": {
"prefix": "tb",
"body": [
"module ${1:${TM_FILENAME_BASE}};",
" reg clk = 1'b0;",
" reg rst_n;",
"",
" always #${2:5} clk = ~clk;",
"",
" initial begin",
" rst_n = 1'b0;",
" repeat (2) @(posedge clk);",
" rst_n = 1'b1;",
" $0",
" \\$display(\"${3:done}\");",
" \\$finish;",
" end",
"endmodule"
],
"description": "Testbench with clock and reset"
},
"Include guard": {
"prefix": "guard",
"body": [
"`ifndef ${1:${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_VH}",
"`define $1",
"",
"$0",
"",
"`endif // $1"
],
"description": "ifndef/define include guard from the file name"
}
}