Skip to content

[FEATURE] Show hex, binary, and octal conversions when hovering over numeric literals #447

@nselvara

Description

@nselvara

Halli hallo,

Feature Description

When hovering over a numeric literal (binary bit_vector / std_(u)logic_vector, hex literal, or decimal), the tooltip currently shows signed/unsigned decimal conversions. It would be useful to also display the value in hex, binary, and octal, so you can cross-check representations without leaving the editor.

Current behaviour

The tooltip shows only signed/unsigned decimal:

Current tooltip – binary literal Current tooltip – hex literal

Proposed output

For a literal like "10100101" or x"A5", the tooltip could show:

Format Value
Bin 1010_0101
Hex 0xA5
Oct 0o245
Dec (u) 165
Dec (s) -91

Relevant literal types

  • Binary string literals: "10100101"
  • Hex literals: x"A5", x"5A"
  • Based literals: 16#F0#, 8#360#
  • Decimal values passed to to_unsigned / to_signed

Example code

type pattern_array_t is array (natural range <>) of std_ulogic_vector(7 downto 0);
constant TEST_PATTERNS : pattern_array_t := (
    "10100101",                              -- 0xA5
    x"5A",                                   -- 0x5A
    std_ulogic_vector(to_unsigned(16#F0#, 8)), -- 240
    std_ulogic_vector(to_unsigned(8#360#, 8)), -- 0xF0
    std_ulogic_vector(to_unsigned(204, 8))     -- 0xCC
);

Note

  • Octal is lower priority and could be hidden behind a config option if it clutters things
  • Grouping digits (e.g. 1010_0101) would help readability for wider vectors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions