Lattice Diamond / LSE flow files for VSCode
Editor support for the project and constraint files used by the Lattice Diamond
synthesis flow with LSE (Lattice Synthesis Engine). This extension deliberately
does not provide Verilog/VHDL support — there are good extensions for that
already. It covers the surrounding, Lattice-specific files that you normally end
up editing by hand.
What it covers
| Files |
Language |
What you get |
.lpf, .prf |
lpf |
Full grammar for the preference language: statements, objects, KEY=VALUE attributes, numbers with units, quoted object names, # comments. Plus ~22 snippets. |
.ldc, .fdc |
ldc |
Tcl/SDC-flavored constraints, with the Lattice ldc_* commands and the SDC commands LSE accepts highlighted distinctly from the get_* collectors and plain Tcl. Plus 14 snippets. |
.ldf, .rvl, .rva, .ipx |
xml |
Associated with the built-in XML language, so the project file folds and highlights. |
.mrp, .par, .twr, .srr, .bgn, .pad |
lattice-report |
Report coloring: ERROR lines red, WARNING lines highlighted, section headings and key: value summary lines picked out. Makes scanning a map/par/trace report much faster. |
Highlighting details (LPF)
Keyword matching is case-insensitive, so locate comp highlights the same as
LOCATE COMP. Tokens are split into tiers so a theme can distinguish them:
keyword.control.statement — statement heads: LOCATE, IOBUF, FREQUENCY,
PERIOD, BLOCK, MULTICYCLE, MAXDELAY, SYSCONFIG, REGION, UGROUP, …
keyword.other.object — object nouns: COMP, PORT, NET, SITE, CELL, BLKNAME, …
keyword.other.qualifier — FROM, TO, CLKNET, RESETPATHS, ASYNCPATHS, PRIMARY, …
variable.parameter.attribute / constant.other.value — the two halves of IO_TYPE=LVCMOS33
constant.numeric + keyword.other.unit — 100.000000 MHz, 10.0 ns, 2 X, 3.3 V
string.quoted.double — "clk_c", with */? wildcards and [3:0] bus ranges called out inside
Snippets
Type the prefix and press Tab. LPF: locate, iobuf, pin (location + IO
standard in one go), frequency, period, useprimary, blockresetpaths,
blockasyncpaths, blockpath, multicycle, maxdelay, inputsetup,
clocktoout, ugroup, region, locateugroup, prohibit, bank,
sysconfig, opcond, sysjitter.
LDC: create_clock, create_generated_clock, set_false_path,
set_multicycle_path, set_max_delay, set_input_delay, set_output_delay,
set_clock_groups, ldc_set_location, ldc_set_port, ldc_set_sysconfig,
ldc_set_vcc, ldc_set_attribute, ldc_create_group.
Several snippets use choice placeholders — e.g. iobuf offers a dropdown of
IO_TYPE and PULLMODE values rather than making you remember them.
Extensions deliberately not claimed
Some Diamond file extensions collide with far more common formats, so the
extension leaves them alone rather than hijacking them globally. If you want
them, add this to your workspace settings:
{
"files.associations": {
"*.sty": "xml", // Diamond strategy file — collides with LaTeX packages
"*.lpc": "ini", // IPexpress component config
"*.sdc": "ldc", // generic SDC, claimed by other FPGA extensions
"*.xcf": "xml" // programmer chain file — collides with GIMP images
}
}
Install
npm install
npm run package
code --install-extension lattice-lse-flow-0.1.0.vsix
Or, for development, symlink the folder into your extensions directory and
reload the window:
ln -s "$PWD" ~/.vscode/extensions/lattice-lse-flow
Development
The grammars are plain TextMate JSON — no build step, no TypeScript. After
editing a grammar, run the tokenizer test, which drives the same engine VS Code
uses and asserts the scopes on the fixtures in test/fixtures/:
npm install
node test/tokenize.js # assertions only (also `npm test`)
node test/tokenize.js --verbose # dump every token with its scopes
Press F5 to launch an Extension Development Host opened on
test/fixtures/, which contains a synthetic LPF and LDC plus a real .prf and
.mrp taken from a Diamond 3.14 ECP5 run.
Known approximations
- The LPF grammar also accepts
// and /* */ comments. Only # was observed
in real Diamond output; the others are harmless extras, not a claim about the
language.
REGION, UGROUP and VCCIO color as statement heads even when they appear
mid-statement (LOCATE UGROUP "g" REGION "r" ;). Cosmetic.
- Report heading detection is heuristic: an unindented, capitalized line. It
works on the
.mrp/.par/.twr shapes that were checked, not by spec.
Ideas not yet implemented
- Diagnostics for LPF: flag statements missing the terminating
;, unknown
statement heads, and duplicate LOCATE of the same site — cheap to do with a
DiagnosticCollection and would catch the most common hand-editing mistakes.
- Cross-file "go to definition": from a
"port_name" in an LPF to the port
declaration in the RTL, and from the .ldf <Source> entries to the files.
- Pin-name completion from the device's
.pad/package file, so SITE "…"
can autocomplete real package balls for the device named in the .ldf.
- Report outline: a
DocumentSymbolProvider for .mrp/.twr so the
outline pane lets you jump between report sections.
- LDF/STY forms: a small webview to toggle LSE strategy properties instead
of hand-editing the
PROP_LST_* XML.
License
MIT
| |