Ghdl: Two-dimensional (2D) unconstrained array in record.

Created on 13 Mar 2019  路  4Comments  路  Source: ghdl/ghdl

Does GHDL support two-dimensional (2D) unconstrained array in record types?

Take a look at the following code snippet:

  type t_slv_array      is array (natural range <>) of std_logic_vector;
  type t_ipbus_tranaction_header is
  record
    protocol_version : natural range 0 to 2**4  - 1;
    transaction_id   : natural range 0 to 2**12 - 1;
    words            : natural range 0 to 2**8  - 1;
    type_id          : t_ipbus_transaction_type_id;
    info_code        : t_ipbus_transaction_info_code;
  end record;

  type t_ipbus_transaction is
  record
    header : t_ipbus_tranaction_header;
    bodyy  : t_slv_array;
  end record;

When I try to define a signal in a design in the following way:
signal transaction : t_ipbus_transaction(bodyy(7 downto 0)(31 downto 0));

GHDL Bug occurs:

******************** GHDL Bug occurred ***************************
Please report this bug on https://github.com/ghdl/ghdl/issues
GHDL release: 0.36-rc1 (v0.36-rc1-8-ga62344e4) [Dunoon edition]
Compiled with GNAT Version: 8.2.1 20181127
Target: x86_64-pc-linux-gnu
In directory: /home/mkru/workspace/UVVM_Community_VIPs/vip_ipbus/
Command line:
/usr/local/bin/ghdl1-llvm --std=08 --workdir=work -frelaxed-rules -P/usr/local/lib/ghdl/vendors/ -P/usr/local/lib/ghdl/ieee/v08/ -P/usr/local/lib/ghdl/ -c -fpic -o work/ipbus_tvm_tb.o tb/ipbus_tvm_tb.vhd
Exception SYSTEM.ASSERTIONS.ASSERT_FAILURE raised
Exception information:
raised SYSTEM.ASSERTIONS.ASSERT_FAILURE : no field Element_Subtype_Indication
Call stack traceback locations:
0x55b943dcb7f1 0x55b943bbd134 0x55b943cb30f7 0x55b943cb3d99 0x55b943cb4c7c 0x55b943cb5208 0x55b943cc63f5 0x55b943cc9715 0x55b943ca0354 0x55b943cd2bb7 0x55b943cd9bf2 0x55b943c94c90 0x55b943db3a63 0x55b943db46bf 0x55b943db6007 0x55b943b7c2c0 0x7feaf24de221 0x55b943b7b51c 0xfffffffffffffffe
******************************************************************

When I define type t_slv_arrayas:
type t_slv_array is array (natural range <>) of std_logic_vector(31 downto 0);
Then define signal as:
signal transaction : t_ipbus_transaction(bodyy(7 downto 0));

Everything works fine.

Bug VHDL-2008 VHDL-2008 (unconst. arrrayrecords)

Most helpful comment

@eine I do not have any code to test right now, as I have implemented things in different way. If the above works for you, I guess the issue can be closed.

All 4 comments

Hi there,

As far as I have experienced myself, GHDL handles actual two-dimensional arrays of a constrained array type just fine, e.g.:

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

However, the case that @m-kru describes is that of an unconstrained array of an unconstrained array type, e.g.:

type arr_uu_t is array (natural range <>) of std_logic_vector;

I recently had a similar issue when I tried to use the partially constrained subtype memory_v32_t from

type memory_t is array (natural range <>) of std_logic_vector;
subtype memory_v32_t is memory_t(open)(31 downto 0);

with the constants declared using above types either being

constant input_memory_v32 : memory_v32_t := (
  x"CAFEAFFE",
  x"DEADBEEF",
  x"DEADC0DE",
  x"CAFED00D"
);

or

constant input_memory_v32 : memory_t(open)(31 downto 0) := (
  x"CAFEAFFE",
  x"DEADBEEF",
  x"DEADC0DE",
  x"CAFED00D"
);

.
Elaboration crashed with the following error message:

******************** GHDL Bug occurred ***************************
Please report this bug on https://github.com/ghdl/ghdl/issues
GHDL release: 0.36 (v0.36) [Dunoon edition]
Compiled with GNAT Version: 7.3.0
Target: x86_64-linux-gnu
In directory: /home/alexander/Development/Hardware/memory/test/
Command line:
/usr/local/bin/ghdl --elab-run --std=08 --work=lib --workdir=/home/alexander/Development/Hardware/memory/test/vunit_out/ghdl/libraries/lib -P/home/alexander/Development/Hardware/memory/test/vunit_out/ghdl/libraries/vunit_lib -P/home/alexander/Development/Hardware/memory/test/vunit_out/ghdl/libraries/lib -P/home/alexander/Development/Hardware/memory/test/vunit_out/ghdl/libraries/osvvm memory_endianness_tb tb -grunner_cfg=active python runner : true,enabled_test_cases : ,output path : /home/alexander/Development/Hardware/memory/test/vunit_out/test_output/lib.memory_endianness_tb.all_207b1b17f42499d91735508c2d2ea238347e6a58/,tb path : /home/alexander/Development/Hardware/memory/test/,use_color : true --assert-level=error --wave=/home/alexander/Development/Hardware/memory/test/vunit_out/test_output/lib.memory_endianness_tb.all_207b1b17f42499d91735508c2d2ea238347e6a58/ghdl/wave.ghw
Exception CONSTRAINT_ERROR raised
Exception information:
raised CONSTRAINT_ERROR : ortho_code-decls.adb:527 index check failed
Call stack traceback locations:
0x55e600a86ce2 0x55e600a83cbf 0x55e600a8f33c 0x55e600a8f446 0x55e600a8f5a2 0x55e600a8ff3d 0x55e600a86571 0x55e600a98a11 0x55e600c3ac95 0x55e600c3be3a 0x55e600c3d46f 0x55e600c3e8ea 0x55e600c69819 0x55e600bd57dd 0x55e600bd29a9 0x55e600be06bb 0x55e600c6cc6d 0x55e600bb59c2 0x55e600b3f80c 0x55e600c6f9d8 0x55e6009756c3 0x7f6fc1122b95 0x55e6009744a8 0xfffffffffffffffe
******************************************************************

Interestingly,

constant input_memory_v32 : memory_v32_t(0 to 3) := (
  x"CAFEAFFE",
  x"DEADBEEF",
  x"DEADC0DE",
  x"CAFED00D"
);

and

constant input_memory_v32 : memory_t(0 to 3)(31 downto 0) := (
  x"CAFEAFFE",
  x"DEADBEEF",
  x"DEADC0DE",
  x"CAFED00D"
);

work fine.


Therefore, it seems as if unconstrained arrays of unconstrained array types are not fully supported, yet.
Is there a way to contribute to improved support for such declarations?

Arrays of unconstrained types are supported in general, but there might be remaining issues.

Do not hesitate to report any issue; if you want to investigate you should start with gdb.
In case of crash of ghdl, run it within gdb (be careful as 'ghdl' spawns ghdl-llvm or ghdl-gcc),
and execute 'catch exception'.
There is a .gdbinit in the sources of ghdl.

The following MWE works for me with latest master:

library ieee;
context ieee.ieee_std_context;

entity dut is
end entity dut;

architecture rtl of dut is

  type t_slv_array is array (natural range <>) of std_logic_vector;
  type t_ipbus_tranaction_header is
  record
    protocol_version : natural range 0 to 2**4  - 1;
    transaction_id   : natural range 0 to 2**12 - 1;
    words            : natural range 0 to 2**8  - 1;
  end record;

  type t_ipbus_transaction is
  record
    header : t_ipbus_tranaction_header;
    bodyy  : t_slv_array;
  end record;

  signal transaction : t_ipbus_transaction(bodyy(7 downto 0)(31 downto 0));

begin

end architecture rtl;
# ghdl -a --std=08 ent.vhd 
# ghdl -e --std=08 dut

@m-kru, can you please confirm?

@eine I do not have any code to test right now, as I have implemented things in different way. If the above works for you, I guess the issue can be closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DBLouis picture DBLouis  路  5Comments

philtomson picture philtomson  路  6Comments

ZirconfleX picture ZirconfleX  路  4Comments

RocketRoss picture RocketRoss  路  4Comments

MJoergen picture MJoergen  路  4Comments