Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VPI Unconstrained Array Bug #2635

Open
gbowers4 opened this issue Apr 4, 2024 · 0 comments
Open

VPI Unconstrained Array Bug #2635

gbowers4 opened this issue Apr 4, 2024 · 0 comments

Comments

@gbowers4
Copy link

gbowers4 commented Apr 4, 2024

Description

GHDL 4.0.0 Recently added support for unconstrained array typedefs in VHDL, however as it seems this features hasn't been tested in cocotb and a bug occurs. when a constrained array is read from/written to GHDL performs the same as any other simulator, however when the dimensions of the array type is unconstrained a cocotb GPI error occurs.

How to reproduce?

Test

@cocotbTest()
async def run(dut):
    """
        Template Test program
    """
    print(dut.test_constrained[0].value)
    print(dut.test_unconstrained[0].value)
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity rtl_bench is
port(
  clk : in std_logic
);
end rtl_bench;

architecture arch of rtl_bench is

  type constrained_array_t is array (0 to 3) of std_logic_vector(7 downto 0);
  type unconstrained_array_t is array (integer range <>) of std_logic_vector;
  signal test_constrained   : constrained_array_t := (others => x"ba");
  signal test_unconstrained : unconstrained_array_t (0 to 3)(7 downto 0) := (others => x"ba");


begin

end arch;

Output

INFO     cocotb:simulator.py:305      0.00ns DEBUG    gpi                                VPI: Created GPI object from type ???(114)
INFO     cocotb:simulator.py:305      0.00ns DEBUG    gpi                                Checking rtl_bench.test_constrained exists
INFO     cocotb:simulator.py:305      0.00ns DEBUG    cocotb.test_constrained            Created
INFO     cocotb:simulator.py:305      0.00ns DEBUG    gpi                                Checking if index 0 native through implementation VPI
INFO     cocotb:simulator.py:305      0.00ns DEBUG    gpi                                VPI: Indexable object initialized with range [7:0] and length >8<
INFO     cocotb:simulator.py:305      0.00ns DEBUG    gpi                                VPI: test_constrained[0] initialized with 8 elements
INFO     cocotb:simulator.py:305      0.00ns DEBUG    gpi                                VPI: Created GPI object from type ???(36)
INFO     cocotb:simulator.py:305      0.00ns DEBUG    gpi                                Checking rtl_bench.test_constrained[0] exists
INFO     cocotb:simulator.py:305      0.00ns DEBUG    cocotb.test_constrained[0]         Created
INFO     cocotb:simulator.py:305 10111010
INFO     cocotb:simulator.py:305      0.00ns DEBUG    gpi                                Searching for test_unconstrained
INFO     cocotb:simulator.py:305      0.00ns DEBUG    gpi                                VPI: Created GPI object from type ???(114)
INFO     cocotb:simulator.py:305      0.00ns DEBUG    gpi                                Checking rtl_bench.test_unconstrained exists
INFO     cocotb:simulator.py:305      0.00ns DEBUG    cocotb.test_unconstrained          Created
INFO     cocotb:simulator.py:305      0.00ns DEBUG    gpi                                Checking if index 0 native through implementation VPI
INFO     cocotb:simulator.py:305      0.00ns DEBUG    gpi                                Unable to find handle through vpi_handle_by_index(), attempting second method
INFO     cocotb:simulator.py:305      0.00ns DEBUG    gpi                                Unable to vpi_get_handle_by_index test_unconstrained[0]
INFO     cocotb:simulator.py:305      0.00ns WARNING  gpi                                Failed to find a handle at index 0 via any registered implementation
INFO     cocotb:simulator.py:305      0.00ns TRACE    gpi                                Returning to simulator
INFO     cocotb:simulator.py:305      0.00ns TRACE    gpi                                Returning control to simulator
INFO     cocotb:simulator.py:305      0.00ns TRACE    gpi                                Passing control to GPI user
INFO     cocotb:simulator.py:305      0.00ns TRACE    gpi                                Returning to Python
INFO     cocotb:simulator.py:305      0.00ns INFO     cocotb.regression                  run failed
INFO     cocotb:simulator.py:305                                                         Traceback (most recent call last):
INFO     cocotb:simulator.py:305                                                           File "/data/firmware/src/pylib/cocotb/templates/avl_st_template/avl_st_template_test.py", line 43, in run
INFO     cocotb:simulator.py:305                                                             print(dut.test_unconstrained[0].value)
INFO     cocotb:simulator.py:305                                                           File "/usr/local/lib/python3.10/dist-packages/cocotb/handle.py", line 652, in __getitem__
INFO     cocotb:simulator.py:305                                                             raise IndexError(
INFO     cocotb:simulator.py:305                                                         IndexError: test_unconstrained(GPI_ARRAY) contains no object at index 0

Context

  • GHDL 4.0.0 Built from GCC
  • cocotb 1.8.1
  • Ubuntu 22.04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant