Hover Tooltips
About 582 wordsAbout 2 min
2025-01-08
What are hover tooltips
A hover tooltip explains the symbol under the pointer. Rest the mouse on a module name, instance, port, variable or number and the tooltip appears after a moment; from the keyboard, run Show Hover. Without leaving the current file, you can check:
- the declared type and direction of a variable or port;
- a module's declaration, parameters and file header comment;
- the width of a numeric literal and its value in each base;
- images, tables, formulas and diagrams written in declaration comments.
Verilog, SystemVerilog and VHDL are all supported.
Demo
Numeric literals
Hovering a numeric literal lists its width, signed and unsigned decimal values, and binary, octal, hexadecimal and floating-point interpretations. For example, 'h3536d238e7 is 40 bits wide with the decimal value 228553013479.
Values follow the literal as written: the leading zeros in 32'h0000_000A are only notation and the value is decimal 10; signed values also depend on the declared width. Literals containing X/Z are not ordinary integers.
Rich comments
Put the documentation immediately before a module or entity declaration and it is shown when you hover it. Comments support the following content:
| Content | Comment syntax |
|---|---|
| Image | ; paths resolve against the declaration file, including cross-file hovers |
| Table | Standard Markdown pipe table with a header separator |
| List | - item, 1. item; indent child items |
| Formula | $x^2$, a block between $$ lines, or a math / latex / tex fence |
| WaveDrom | A wavedrom fence containing JSON or JSON5 |
| Flowchart | A flowchart / flow fence containing Mermaid flow syntax or basic flowchart.js definitions and connections |
| Sequence diagram | A sequence fence with A->B: message, B-->A: reply, participants and notes; Mermaid sequenceDiagram is also accepted |
| Mermaid | A mermaid fence: flowcharts, sequence, state, class and ER diagrams |
Use // in Verilog/SystemVerilog and -- in VHDL; block comments with a * prefix are also supported. An excerpt from an adder's comment:
// **Formula**: $s = (a+b) \bmod 2^{W}$.
// ```mermaid
// flowchart LR
// A[input_a] --> ADD[Add]
// B[input_b] --> ADD
// ADD --> S[sum]
// ```Rendering rules:
- Line breaks and blank lines in comments are preserved; plain
------separators do not turn earlier text into oversized headings. Module and entity tooltips exclude comments inside the implementation body. - Raw HTML and command links are not enabled.
- Formulas and diagrams are rendered locally as SVG, with no browser or online service required, and follow the current light, dark or high-contrast theme; hover again after switching themes to see the new colors. Referenced images keep their original colors.
- Small local images are embedded, so they also display over Remote SSH; larger images keep their normal URI, and missing images keep their link.
- Mermaid supports only the diagram types in the table, not extensions such as Gantt or pie charts. Unsupported, malformed or oversized diagrams keep their source and show a message. WaveDrom never evaluates JavaScript expressions.
- Long tooltips are split between paragraphs so VS Code does not truncate image data.
In the tests/project/temp project of the Digital IDE repository, the comments in user/src/lang/svlog/lang_sv_leaf.sv and vhdl/lang_vhdl_stage.vhd cover every item in the table. Open lang_sv_core.sv and hover the instance type lang_sv_leaf, or open lang_vhdl_top.vhd and hover lang_vhdl_stage in u_vhdl_stage, to see the result.
When no tooltip appears
Make sure the pointer is on a valid identifier or number, then check the file's diagnostics, dependencies and language standard. Plain comments, whitespace and unresolved identifiers produce no tooltip.