Project 01 · VHDL
VHDL templates that follow
your house style
A snippet engine fills blanks. It cannot decide whether a reset exists, or whether a FIFO crosses clock domains. Each template here is a small Lua program that renders VHDL, so a handful of answers change the structure of the code, not just its names.
Problem
A tabstop cannot decide
whether a reset exists
Every team writes the same handful of blocks its own way. A
snippet stores one answer and leaves the rest to editing
afterwards. The question is
structural: an asynchronous reset is
a different sensitivity list and a different
if, not a different word.
-- reset = { style = "async" }
p_main : process (clk, rst_n) is
begin
if rst_n = '0' then
-- reset state
elsif rising_edge(clk) then
-- clocked logic
end if;
end process p_main;
-- reset = { style = "sync" }
p_main : process (clk) is
begin
if rising_edge(clk) then
if rst_n = '0' then
-- reset state
else
-- clocked logic
end if;
end if;
end process p_main;
Approach
Templates are Lua
that renders VHDL
A template declares its parameters and returns the lines to insert. Because it is a function rather than a string, a parameter can add a synchroniser stage, drop a generic, or split a process in two. Twenty-one ship with the plugin: skeletons, RTL blocks, clock-domain crossings, FIFOs and a dual-port RAM, five bus slaves, three testbench styles.
Completion comes from an in-process LSP server, so they appear in the normal menu without an external binary. An inserted block stays live: change a parameter and it re-renders where it sits.
Correctness
Generated code that does not analyse
is worse than none
So none of it is taken on trust. Every template is rendered into fixtures, and every fixture is compiled and style-checked before it can be merged.
-
651
Golden fixtures
Every template across seven configuration variants, VHDL-93 among them. A change to generated VHDL shows up as a reviewable diff rather than hiding inside a Lua change.
-
GHDL
Every fixture analysed
An open-source VHDL compiler, run over all of them in CI. If the generator emits something that will not compile, the build fails rather than the user finding out.
-
VSG
861 rules enabled
A VHDL style checker. The 28 rules that are off are house style, each with the reason recorded beside it.
-
Simulated
CDC, FIFOs, bus slaves
Analysis cannot see a clock-domain bug. Simulation caught the asynchronous FIFO reading the unsynchronised end of its own pointer synchronisers.
Beyond templates
Reading what is already written
Most of an FPGA day is spent wiring up entities that already exist. The plugin can instantiate entities and create testbenches from what is in the project: it parses an entity and writes the instance, its component declaration and the signals to connect it, named throughout.
Clocks and resets are found
by the shape of the declaration
rather than by name, so two clocks and an active-low reset
come out driven correctly even when nothing is called
clk.
Scope
What it does not do
No SystemVerilog, and no synthesis or simulation from inside the editor — those belong to tools that already do them well. MIT-licensed, and the VHDL it generates is explicitly public domain: code out of a generator should not carry the generator's licence.