nickg / nvc

VHDL compiler and simulator
https://www.nickg.me.uk/nvc/
GNU General Public License v3.0
631 stars 77 forks source link

Array data not written to the FST file #852

Closed m-kru closed 7 months ago

m-kru commented 7 months ago

I have some testbench with following declarative part:

architecture test of tb_writeb is

  signal clk : std_logic := '1';

  signal ck : checker_t := init;
  signal iface : interface_t := init;

  constant ADDR : unsigned(31 downto 0) := x"00000000";
  constant DATA : data_array_t := (
    x"01234567", x"89ABCDEF", x"DAEDBEEF", x"F0F0F0F0"
  );

  signal written_data : data_array_t(0 to 3);

  signal write_done : boolean := false;

begin

The data_arary_t is defined in a separate package as type data_array_t is array (natural range <>) of std_logic_vector(31 downto 0);. In the output .fst file I cannot find ADDR, DATA, and written_data. ADDR and DATA are constants so their absence is not a big deal. However, the written_data is a signal and it would be really nice to have a possibility to display it on a waveform.

nickg commented 7 months ago

The --dump-arrays option should do that:

     --dump-arrays
             Include memories and nested arrays in the waveform data.  This is
             disabled by default as it can have significant performance, mem‐
             ory, and disk space overhead.
m-kru commented 7 months ago

It indeed works. However, I observe some weird behavior.


  type data_array_t is array (natural range <>) of std_logic_vector(31 downto 0);

  type mock_completer_t is record
    -- Configuration elements
    prefix : string; -- Optional prefix used in report messages.
    -- Internal elements
    memory : data_array_t;
    -- Statistics elements
    read_count  : natural; -- Number of read transfers.
    write_count : natural; -- Number of write transfers.
  end record;

  function init (memory_size: natural; prefix: string := "apb: mock completer: ") return mock_completer_t is
    variable mc : mock_completer_t(prefix(0 to prefix'length-1), memory(0 to memory_size - 1));
  begin
    mc.prefix := prefix;
    return mc;
  end function;

  signal mc : mock_completer_t := init(memory_size => 8);

I would expect the mc.memory array to have 8 elements. However, the gtkwave shows 256 elements.

image

nickg commented 7 months ago

I would expect the mc.memory array to have 8 elements. However, the gtkwave shows 256 elements.

Yes this is a bug.