cocotb / cocotb

cocotb, a coroutine based cosimulation library for writing VHDL and Verilog testbenches in Python
https://www.cocotb.org
BSD 3-Clause "New" or "Revised" License
1.74k stars 502 forks source link

Accessing signal in VHDL module from verilog top #1272

Closed Fatsie closed 3 years ago

Fatsie commented 4 years ago

This may be related to #1004 and #1105 but there signal was accessed in verilog module from VHDL top. My problem may also be missing feature due to use of 32 bit Modelsim delivered with Quartus software.

dff.vhdl:

library ieee;
use ieee.std_logic_1164.all;

entity dff is
  port(clk: in std_logic; d: in std_logic; q: out std_logic);
end entity dff;

architecture rtl of dff is
begin
  process(clk)
  begin
    if rising_edge(clk) then
      q <= d;
    end if;
  end process;
end architecture rtl;

top.v:

module top(clk, d, q);

input clk, d;
output q;

dff dff(.clk(clk), .q(q), .d(d));

endmodule // top

test.py:

import cocotb
from cocotb.triggers import Timer

@cocotb.test()
def test01_access(dut):
    """
    Segfaulting modelsim simulation
    """
    dut.dff._discover_all()
    yield Timer(1)

Makefile:

CURDIR=$(realpath .)

TOPLEVEL := top

COCOTBMAKEDIR=$(shell cocotb-config --makefiles)

VHDL_SOURCES := $(CURDIR)/dff.vhdl
VERILOG_SOURCES := $(CURDIR)/top.v

export COCOTB_LOG_LEVEL=DEBUG
TOPLEVEL_LANG=verilog
MODULE=test
SIM=modelsim
ARCH=i686
VCOM_ARGS=-2008
WAVES := 1

include $(COCOTBMAKEDIR)/Makefile.inc
include $(COCOTBMAKEDIR)/Makefile.sim

Running it (second time so no compiling is done):

(cocotb32_37) [verhaegs@localhost cocotb_modunderscore]$ make
make results.xml
make[1]: Map '/tmp/cocotb_modunderscore' wordt binnengegaan
set -o pipefail; cd sim_build && LD_LIBRARY_PATH=/tmp/cocotb_modunderscore/build/libs/i686:/home/verhaegs/software/lib:/home/verhaegs/software/lib64:/home/verhaegs/software/lib:/home/verhaegs/software/lib64:/home/verhaegs/software/lib:/home/verhaegs/software/lib64::/home/verhaegs/anaconda2/envs/cocotb32_37/lib:/home/verhaegs/anaconda2/envs/cocotb32_37/lib:/home/verhaegs/anaconda2/envs/cocotb32_37/lib:/home/verhaegs/anaconda2/envs/cocotb32_37/lib MODULE=test TESTCASE= TOPLEVEL="work.top" COCOTB_SIM=1 \
GPI_EXTRA=fli TOPLEVEL_LANG=verilog PYTHONPATH=/tmp/cocotb_modunderscore/build/libs/i686:/tmp/cocotb_modunderscore:/home/verhaegs/anaconda2/envs/cocotb32_37/lib/python3.7/site-packages: \
/home/verhaegs/software/no-stow/intelFPGA_lite/19.1/modelsim_ase/bin/vsim -c  -do runsim.do 2>&1 | tee sim.log
Reading pref.tcl

# 10.5b

# do runsim.do
# Model Technology ModelSim - Intel FPGA Edition vmap 10.5b Lib Mapping Utility 2016.10 Oct  5 2016
# vmap -c 
# ** Warning: vmap will not overwrite local modelsim.ini.
# Model Technology ModelSim - Intel FPGA Edition vmap 10.5b Lib Mapping Utility 2016.10 Oct  5 2016
# vmap work work 
# Modifying modelsim.ini
# Model Technology ModelSim - Intel FPGA Edition vcom 10.5b Compiler 2016.10 Oct  5 2016
# Start time: 16:15:13 on Dec 31,2019
# vcom -work work -2008 /tmp/cocotb_modunderscore/dff.vhdl 
# -- Loading package STANDARD
# -- Loading package TEXTIO
# -- Loading package std_logic_1164
# -- Compiling entity dff
# -- Compiling architecture rtl of dff
# End time: 16:15:13 on Dec 31,2019, Elapsed time: 0:00:00
# Errors: 0, Warnings: 0
# Model Technology ModelSim - Intel FPGA Edition vlog 10.5b Compiler 2016.10 Oct  5 2016
# Start time: 16:15:13 on Dec 31,2019
# vlog -work work "+define+COCOTB_SIM" -sv -timescale 1ns/1ps -mfcu "+acc=rmb" /tmp/cocotb_modunderscore/top.v 
# -- Compiling module top
# 
# Top level modules:
#   top
# End time: 16:15:14 on Dec 31,2019, Elapsed time: 0:00:01
# Errors: 0, Warnings: 0
# vsim -onfinish exit -pli "libvpi.so" work.top 
# Start time: 16:15:14 on Dec 31,2019
# Loading sv_std.std
# Loading work.top
# Loading std.standard
# Loading std.textio(body)
# Loading ieee.std_logic_1164(body)
# Loading work.dff(rtl)
# Loading /tmp/cocotb_modunderscore/build/libs/i686/libvpi.so
#      -.--ns INFO     cocotb.gpi                                  gpi_embed.c:78   in set_program_name_in_venv        Did not detect Python virtual environment. Using system-wide Python interpreter
#      -.--ns INFO     cocotb.gpi                                GpiCommon.cpp:104  in gpi_print_registered_impl       VPI registered
#      -.--ns INFO     cocotb.gpi                                GpiCommon.cpp:104  in gpi_print_registered_impl       FLI registered
# Attempting stack trace sig 11
# Signal caught: signo [11]
# vsim_stacktrace.vstf written
# Current time Tue Dec 31 16:15:14 2019
# ModelSim - Intel FPGA Edition Stack Trace
# Program = vsim
# Id = "10.5b"
# Version = "2016.10"
# Date = "Oct  5 2016"
# Platform = linuxpe
# Signature = 400ea32bebde3acba4e1f6d8e4522046
# 0    0x0846bab4: '<unknown (@0x846bab4)>'
# --> START OF USERCODE
# 1    0xf5332593: 'FliImpl::native_check_create(std::string&, GpiObjHdl*) + 0x61f' in '/tmp/cocotb_modunderscore/build/libs/i686/libfli.so'
# 2    0xf57d45e8: '__gpi_get_handle_by_name(GpiObjHdl*, std::string, GpiImplInterface*) + 0x19d' in '/tmp/cocotb_modunderscore/build/libs/i686/libgpi.so'
# 3    0xf57d4970: 'gpi_get_handle_by_name + 0x77' in '/tmp/cocotb_modunderscore/build/libs/i686/libgpi.so'
# <-- END OF USERCODE
# 4    0xf5a73a4d: '<unknown (@0xf5a73a4d)>'
# 5    0xf545d036: '<unknown (@0xf545d036)>'
...[snip]...
# 48   0xf545e79a: '<unknown (@0xf545e79a)>'
# 49   0xf545e8eb: '<unknown (@0xf545e8eb)>'
# --> START OF USERCODE
# 50   0xf534fe98: 'embed_sim_init + 0xa2a' in '/tmp/cocotb_modunderscore/build/libs/i686/libcocotb.so'
# 51   0xf57d3c69: 'gpi_embed_init(gpi_sim_info_s*) + 0x18' in '/tmp/cocotb_modunderscore/build/libs/i686/libgpi.so'
# 52   0xf57f7e3b: 'VpiStartupCbHdl::run_callback() + 0x3b' in '/tmp/cocotb_modunderscore/build/libs/i686/libvpi.so'
# 53   0xf57f3e84: 'handle_vpi_callback + 0xe0' in '/tmp/cocotb_modunderscore/build/libs/i686/libvpi.so'
# <-- END OF USERCODE
# 54   0x08317f43: '<unknown (@0x8317f43)>'
# 55   0x083182d3: '<unknown (@0x83182d3)>'
...[snip]...
# 80   0x085c8bfb: '<unknown (@0x85c8bfb)>'
# 81   0x084a6ab4: '<unknown (@0x84a6ab4)>'
# End of Stack Trace

** Fatal: (SIGSEGV) Bad pointer access. Closing vsimk.
** Fatal: vsimk is exiting with code 211.
Exit codes are defined in the "Error and Warning Messages"
appendix of the ModelSim User's Manual.
FATAL: We are calling up again
# ** Warning: (vsim-3116) Problem reading symbols from /home/verhaegs/anaconda2/envs/cocotb32_37/lib/libpython3.7m.so.1.0 : module was loaded at an absolute address.
#      0.00ns DEBUG    cocotb                                      __init__.py:81   in <module>                        Reopened stdout with line buffering
#      0.00ns DEBUG    cocotb                                      __init__.py:84   in <module>                        Reopened stderr with line buffering
#      0.00ns INFO     cocotb.gpi                                  gpi_embed.c:340  in embed_sim_init                  Running on ModelSim - INTEL FPGA STARTER EDITION version 10.5b 2016.10
#      0.00ns INFO     cocotb.gpi                                  gpi_embed.c:341  in embed_sim_init                  Python interpreter initialized and cocotb loaded!
#      0.00ns INFO     cocotb                                      __init__.py:138  in _initialise_testbench           Running tests with cocotb v1.2.0 from /home/verhaegs/anaconda2/envs/cocotb32_37/lib/python3.7/site-packages
#      0.00ns INFO     cocotb                                      __init__.py:155  in _initialise_testbench           Seeding Python random module with 1577805314
#      0.00ns DEBUG    cocotb.gpi                                GpiCommon.cpp:246  in gpi_get_root_handle             Looking for root handle 'top' over 2 implementations
#      0.00ns DEBUG    cocotb.gpi                                GpiCommon.cpp:254  in gpi_get_root_handle             Got a Root handle (top) back from VPI
#      0.00ns DEBUG    cocotb.gpi                                GpiCommon.cpp:50   in check_and_store                 Checking top exists
#      0.00ns DEBUG    cocotb.top                                    handle.py:91   in __init__                        Created
#      0.00ns DEBUG    cocotb.regression                         regression.py:133  in initialise                      Python Path: /tmp/cocotb_modunderscore/build/libs/i686,/tmp/cocotb_modunderscore,/home/verhaegs/anaconda2/envs/cocotb32_37/lib/python3.7/site-packages,/tmp/cocotb_modunderscore/sim_build,/home/verhaegs/anaconda2/envs/cocotb32_37/lib/python37.zip,/home/verhaegs/anaconda2/envs/cocotb32_37/lib/python3.7,/home/verhaegs/anaconda2/envs/cocotb32_37/lib/python3.7/lib-dynload
#      0.00ns DEBUG    cocotb.regression                         regression.py:134  in initialise                      PWD: /tmp/cocotb_modunderscore/sim_build
#      0.00ns INFO     cocotb.regression                         regression.py:190  in initialise                      Found test test.test01_access
#      0.00ns INFO     cocotb.regression                         regression.py:348  in execute                         Running test 1/1: test01_access
#      0.00ns INFO     ..otb.test.test01_access.0xf5995f0c       decorators.py:253  in _advance                        Starting tesimport cocotb
from cocotb.triggers import Timer

@cocotb.test()
def test01_access(dut):
    """
    Segfaulting modelsim simulation
    """
    dut.dff._discover_all()
    yield Timer(1)

t: "test01_access"
#                                                                                                                      Description: 
#                                                                                                                          Segfaulting modelsim simulation
#                                                                                                                          
#      0.00ns DEBUG    cocotb.gpi                                GpiCommon.cpp:275  in __gpi_get_handle_by_name        Searching for dff
#      0.00ns DEBUG    cocotb.gpi                                GpiCommon.cpp:288  in __gpi_get_handle_by_name        Checking if dff is native through implementation VPI
#      0.00ns DEBUG    cocotb.gpi                                  VpiImpl.cpp:209  in create_gpi_obj_from_handle      VPI: Not able to map type vpiVHDLArchitecture(1020) to object.
#      0.00ns DEBUG    cocotb.gpi                                  VpiImpl.cpp:281  in native_check_create             Unable to fetch object top.dff
#      0.00ns DEBUG    cocotb.gpi                                GpiCommon.cpp:288  in __gpi_get_handle_by_name        Checking if dff is native through implementation FLI
#      0.00ns DEBUG    cocotb.gpi                                  FliImpl.cpp:278  in native_check_create             Looking for child dff from top
# ** Error (suppressible): (vsim-FLI-3155) The FLI is not enabled in this version of ModelSim.
# ** Error (suppressible): (vsim-FLI-3155) The FLI is not enabled in this version of ModelSim.
# ** Error (suppressible): (vsim-FLI-3155) The FLI is not enabled in this version of ModelSim.
# End time: 16:15:14 on Dec 31,2019, Elapsed time: 0:00:00
# Errors: 3, Warnings: 1
make[1]: *** [results.xml] Fout 211
make[1]: Map '/tmp/cocotb_modunderscore' wordt verlaten
make: *** [sim] Fout 2

When I remove dut.dff._discover_all() from test.py; the simulation passes without segfault.

marlonjames commented 4 years ago

This looks to be the culprit:

# ** Error (suppressible): (vsim-FLI-3155) The FLI is not enabled in this version of ModelSim.

ModelSim uses FLI to access VHDL.

themperek commented 4 years ago

@Fatsie Please close if the issue is solved.

github-actions[bot] commented 3 years ago

Has your question been resolved? If so please close this issue. If it has not been resolved, you may need to provide more information. If no more activity on this issue occurs in 7 days, it will be closed.

stdefeber commented 1 year ago

This issue is not as dead as it appears. I have a similar issue. However this involves xcelium.

OS : CentOs 7.6 CoCoTb : 1.6.2 Xcelium : 21.03.008

We switched from having mostly VHDL as top and intermediate layers to verilog/SV. When a VHDL module is compiled into a library, CoCoTb can not find it anymore.

Loading snapshot worklib.tb_top:v .................... Done
xmsim: *W,DSEM2009: This SystemVerilog design is simulated as per IEEE 1800-2009 SystemVerilog simulation semantics. Use -disable_sem2009 option for turning off SV 2009 simulation semantics.
     -.--ns INFO     cocotb.gpi                         ..mbed/gpi_embed.cpp:110  in set_program_name_in_venv        Using Python virtual environment interpreter at /data/home/<user>/projects/sandbox/cocotb_sandbox/.venv/bin/python
     -.--ns INFO     cocotb.gpi                         ../gpi/GpiCommon.cpp:99   in gpi_print_registered_impl       VPI registered
     -.--ns INFO     cocotb.gpi                         ../gpi/GpiCommon.cpp:99   in gpi_print_registered_impl       VHPI registered
xcelium> source /cadappl/ictools/cadence_xcelium/21.03.008/tools/xcelium/files/xmsimrc
xcelium> run
     0.00ns DEBUG    Reopened stderr with line buffering
     0.00ns DEBUG    Reopened stdout with line buffering
     0.00ns INFO     Running on xmsim(64) version 21.03-s008
     0.00ns INFO     Running tests with cocotb v1.6.2 from /data/home/<user>/projects/sandbox/cocotb_sandbox/.venv/lib64/python3.8/site-packages/cocotb
     0.00ns INFO     Seeding Python random module with 1680872851
     0.00ns DEBUG    Looking for root handle 'tb_top' over 2 implementations
     0.00ns DEBUG    Got a Root handle (tb_top) back from VPI
     0.00ns DEBUG    Checking tb_top exists
     0.00ns DEBUG    Created
     0.00ns DEBUG    Python Path: ,/opt/rh/rh-python38/root/usr/lib64/python38.zip,/opt/rh/rh-python38/root/usr/lib64/python3.8,/opt/rh/rh-python38/root/usr/lib64/python3.8/lib-dynload,/data/home/<user>l/projects/sandbox/cocotb_sandbox/.venv/lib64/python3.8/site-packages,/data/home/<user>/projects/sandbox/cocotb_sandbox/.venv/lib/python3.8/site-packages,/data/home/<user>/projects/sandbox/cocotb_sandbox/python/src
     0.00ns DEBUG    PWD: /data/home/<user>/projects/sandbox/cocotb_sandbox/cocotb
     0.00ns INFO     Found test test.test01_access
     0.00ns INFO     running test01_access (1/1)
     0.00ns INFO     Info message
     0.00ns INFO     @ get_top
     0.00ns INFO     @ get_top
     0.00ns DEBUG    Searching for u_ic
     0.00ns DEBUG    Checking if u_ic is native through implementation VPI
     0.00ns DEBUG    VPI: Created GPI object from type vpiModule(32)
     0.00ns DEBUG    Found u_ic via VPI
     0.00ns DEBUG    Checking tb_top.u_ic exists
     0.00ns DEBUG    Created
     0.00ns DEBUG    Searching for u_top
     0.00ns DEBUG    Checking if u_top is native through implementation VPI
     0.00ns DEBUG    VPI: Created GPI object from type vpiModule(32)
     0.00ns DEBUG    Found u_top via VPI
     0.00ns DEBUG    Checking tb_top.u_ic.u_top exists
     0.00ns DEBUG    Created
tb_top.u_ic.u_top
     0.00ns INFO     @ get_dff
     0.00ns INFO     @ get_core
     0.00ns INFO     @ get_top
     0.00ns INFO     @ get_top
     0.00ns DEBUG    Searching for u_core
     0.00ns DEBUG    Checking if u_core is native through implementation VPI
     0.00ns DEBUG    VPI: Created GPI object from type vpiModule(32)
     0.00ns DEBUG    Found u_core via VPI
     0.00ns DEBUG    Checking tb_top.u_ic.u_top.u_core exists
     0.00ns DEBUG    Created
     0.00ns DEBUG    Searching for u_sub_wrapper
     0.00ns DEBUG    Checking if u_sub_wrapper is native through implementation VPI
     0.00ns WARNING  VPI: Not able to map type vhpiCompInstStmtK(1024) to object.
     0.00ns DEBUG    Unable to fetch object tb_top.u_ic.u_top.u_core.u_sub_wrapper
     0.00ns DEBUG    Checking if u_sub_wrapper is native through implementation VHPI
     0.00ns DEBUG    VHPI: Creating tb_top:u_ic:u_top:u_core:u_sub_wrapper of type 2 (vhpiCompInstStmtK)
     0.00ns DEBUG    Found u_sub_wrapper via VHPI
     0.00ns DEBUG    Checking tb_top.u_ic.u_top.u_core.u_sub_wrapper exists
     0.00ns DEBUG    Created
     0.00ns DEBUG    Searching for u_sub
     0.00ns DEBUG    Checking if u_sub is native through implementation VPI
     0.00ns DEBUG    Unable to query vpi_get_handle_by_name tb_top.u_ic.u_top.u_core.u_sub_wrapper.u_sub
     0.00ns DEBUG    Checking if u_sub is native through implementation VHPI
     0.00ns DEBUG    VHPI: Unable to query vhpi_handle_by_name tb_top.u_ic.u_top.u_core.u_sub_wrapper.u_sub
     0.00ns DEBUG    Failed to find a handle named u_sub via any registered implementation
     0.00ns INFO     test01_access failed
                     Traceback (most recent call last):
                       File "/data/home/<user>/projects/sandbox/cocotb_sandbox/cocotb/test.py", line 49, in test01_access
                         sub_wrapper.u_sub._discover_all()
                       File "/data/home/<user>/projects/sandbox/cocotb_sandbox/.venv/lib64/python3.8/site-packages/cocotb/handle.py", line 346, in __getattr__
                         raise AttributeError(f"{self._name} contains no object named {name}")
                     AttributeError: u_sub_wrapper contains no object named u_sub
     0.00ns INFO     **************************************************************************************
                     ** TEST                          STATUS  SIM TIME (ns)  REAL TIME (s)  RATIO (ns/s) **
                     **************************************************************************************
                     ** test.test01_access             FAIL           0.00           0.00          0.04  **
                     **************************************************************************************
                     ** TESTS=1 PASS=0 FAIL=1 SKIP=0                  0.00           0.01          0.01  **
                     **************************************************************************************

     0.00ns DEBUG    VHPI: Releasing VhpiObjHdl handle for tb_top.u_ic.u_top.u_core.u_sub_wrapper at 0x500040

I have anonymized the above output. Therefor \<user>.

The Makefile:

CURDIR=$(realpath .)

TOPLEVEL := tb_top

COCOTBMAKEDIR=$(shell cocotb-config --makefiles)

VHDL_SOURCES_module_lib := \
    $(CURDIR)/../RTL/dff.m.vhdl \
    $(CURDIR)/../INTERFACE/sub.e.vhdl \
    $(CURDIR)/../RTL/sub.a.vhdl

VHDL_SOURCES := \
    $(CURDIR)/../RTL/sub_wrapper.vhdl \

VERILOG_SOURCES :=  \
    $(CURDIR)/../RTL/core.sv \
    $(CURDIR)/../RTL/ic.sv \
    $(CURDIR)/../RTL/top.sv \
    $(CURDIR)/../TESTBENCH/tb_top.v

VHDL_LIB_ORDER = \
    module_lib \

export COCOTB_LOG_LEVEL=DEBUG
TOPLEVEL_LANG=verilog
MODULE=test
SIM=xcelium
COCOTB_HDL_TIMEUNIT=100fs
COCOTB_HDL_TIMEPRECISION=100fs
COCOTB_RESOLVE_X=ZEROS
COMPILE_ARGS += -v93 -V200X -accessreg +rwc $(INCDIRS)

include $(COCOTBMAKEDIR)/Makefile.inc
include $(COCOTBMAKEDIR)/Makefile.sim

Testcase:

test.py

import cocotb
from cocotb.triggers import Timer
import logging

logger = logging.getLogger('simple_test')
logger.setLevel (logging.INFO)

def get_ic(dut):
  logger.info("@ get_top")
  return dut.u_ic

def get_top(dut):
  logger.info("@ get_top")
  return get_ic(dut).u_top

def get_core(dut):
  logger.info("@ get_core")
  return get_top(dut).u_core

def get_sub_wrapper(dut):
  logger.info("@ get_dff")
  return get_core(dut).u_sub_wrapper

def get_sub(dut):
  logger.info("@ get_dff")
  return get_sub_wrapper(dut).u_sub

def get_dff0(dut):
  logger.info("@ get_dff")
  return get_sub(dut).u_dff0

def get_dff1(dut):
  logger.info("@ get_dff")
  return get_top(dut).u_dff1

@cocotb.test()
def test01_access(dut):
    """
    """
    logger.debug ('Debug message')
    logger.info  ('Info message')

    #dut.u_top.core.dff._discover_all()
    top = get_top(dut)
    print(top)

    sub_wrapper = get_sub_wrapper(dut)
    sub_wrapper.u_sub._discover_all()

    print(sub_wrapper)

    dff0 = get_dff0(dut)
    #dff1 = get_dff1(dut)
    print(dff0)

My apologies for the eleaborate hierarchy. It mimics the real design and was to find out whether it had anything to do with the number of levels.

Test bench, not used as such, just to mimic the real example. In the real design it contains pull-ups e.q. I2C :

tb_top.v

module tb_top(
  input  clk, 
  input  d0, 
  output q0, 
  input  d1, 
  output q1 
);

  ic u_ic (
    .clk(clk),
    .q0(q0),
    .d0(d0),
    .q1(q1),
    .d1(d1)
  );

endmodule

IC-level:

ic.sv

module ic(
  clk,
  d0, 
  q0,
  d1, 
  q1
);

input clk, d0, d1;
output q0, q1;

  top u_top(
    .clk(clk),
    .q0(q0),
    .d0(d0)
  );

endmodule

Top:

top.sv

module top(
  clk,
  d0, 
  q0
);

input clk, d0;
output q0;

  core u_core(
    .clk(clk),
    .q(q0),
    .d(d0)
  );

endmodule

The core:

core.sv

module core(clk, d, q);

input clk, d;
output q;

sub u_sub_wrapper(.clk(clk), .q(q), .d(d));

endmodule 

I had created a sub_wrapper just to find out whether a VHDL module in library "work" would solve the issue.

sub_wrapper.vhdl

library ieee;
use ieee.std_logic_1164.all;

library module_lib;
use     module_lib.all;

entity sub_wrapper is
port (
  clk : in  std_logic;
  d   : in  std_logic;
  q   : out std_logic
);
end entity;

architecture rtl of sub_wrapper is

begin

  u_sub : entity module_lib.sub
  port map (
    clk => clk,
    d   => d,
    q   => q
  );

end rtl;

The sub architecture itself:

sub.a.vhdl

library ieee;
use ieee.std_logic_1164.all;

library module_lib;
use     module_lib.all;

architecture rtl of sub is

begin

  u_dff0 : entity module_lib.dff
  port map (
    clk => clk,
    d   => d,
    q   => q
  );

end rtl;

The sub entity:

sub.e.vhdl

library ieee;
use ieee.std_logic_1164.all;

entity sub is
port (
  clk : in  std_logic;
  d   : in  std_logic;
  q   : out std_logic
);
end entity sub; 

And finally a dff:

dff.m.vhdl

library ieee;
use ieee.std_logic_1164.all;

entity dff is
port(
  clk : in  std_logic; 
  d   : in  std_logic; 
  q   : out std_logic
);
end entity dff;

architecture rtl of dff is
begin

  process(clk)
  begin
    if rising_edge(clk) then
      q <= d;
    end if;
  end process;

end architecture rtl;
stdefeber commented 1 year ago

A work around has been found. When all sources are marked as VHDL_SOURCES it works.

VHDL_SOURCES_module_lib := \
    $(CURDIR)/../RTL/dff.m.vhdl \
    $(CURDIR)/../INTERFACE/sub.e.vhdl \
    $(CURDIR)/../RTL/sub.a.vhdl

VHDL_SOURCES := \
    $(CURDIR)/../RTL/sub_wrapper.vhdl \
    $(CURDIR)/../RTL/core.sv \
    $(CURDIR)/../RTL/ic.sv \
    $(CURDIR)/../RTL/top.sv \
    $(CURDIR)/../TESTBENCH/tb_top.v
     0.00ns INFO     Found test test.test01_access
     0.00ns INFO     running test01_access (1/1)
     0.00ns INFO     Info message
     0.00ns INFO     @ get_top
     0.00ns INFO     @ get_top
     0.00ns DEBUG    Searching for u_ic
     0.00ns DEBUG    Checking if u_ic is native through implementation VPI
     0.00ns DEBUG    VPI: Created GPI object from type vpiModule(32)
     0.00ns DEBUG    Found u_ic via VPI
     0.00ns DEBUG    Checking tb_top.u_ic exists
     0.00ns DEBUG    Created
     0.00ns DEBUG    Searching for u_top
     0.00ns DEBUG    Checking if u_top is native through implementation VPI
     0.00ns DEBUG    VPI: Created GPI object from type vpiModule(32)
     0.00ns DEBUG    Found u_top via VPI
     0.00ns DEBUG    Checking tb_top.u_ic.u_top exists
     0.00ns DEBUG    Created
tb_top.u_ic.u_top
     0.00ns INFO     @ get_dff
     0.00ns INFO     @ get_dff
     0.00ns INFO     @ get_dff
     0.00ns INFO     @ get_core
     0.00ns INFO     @ get_top
     0.00ns INFO     @ get_top
     0.00ns DEBUG    Searching for u_core
     0.00ns DEBUG    Checking if u_core is native through implementation VPI
     0.00ns DEBUG    VPI: Created GPI object from type vpiModule(32)
     0.00ns DEBUG    Found u_core via VPI
     0.00ns DEBUG    Checking tb_top.u_ic.u_top.u_core exists
     0.00ns DEBUG    Created
     0.00ns DEBUG    Searching for u_sub_wrapper
     0.00ns DEBUG    Checking if u_sub_wrapper is native through implementation VPI
     0.00ns WARNING  VPI: Not able to map type vhpiCompInstStmtK(1024) to object.
     0.00ns DEBUG    Unable to fetch object tb_top.u_ic.u_top.u_core.u_sub_wrapper
     0.00ns DEBUG    Checking if u_sub_wrapper is native through implementation VHPI
     0.00ns DEBUG    VHPI: Creating tb_top:u_ic:u_top:u_core:u_sub_wrapper of type 2 (vhpiCompInstStmtK)
     0.00ns DEBUG    Found u_sub_wrapper via VHPI
     0.00ns DEBUG    Checking tb_top.u_ic.u_top.u_core.u_sub_wrapper exists
     0.00ns DEBUG    Created
     0.00ns DEBUG    Searching for u_sub
     0.00ns DEBUG    Checking if u_sub is native through implementation VPI
     0.00ns WARNING  VPI: Not able to map type vhpiCompInstStmtK(1024) to object.
     0.00ns DEBUG    Unable to fetch object tb_top.u_ic.u_top.u_core.u_sub_wrapper.u_sub
     0.00ns DEBUG    Checking if u_sub is native through implementation VHPI
     0.00ns DEBUG    VHPI: Creating tb_top:u_ic:u_top:u_core:u_sub_wrapper:u_sub of type 2 (vhpiCompInstStmtK)
     0.00ns DEBUG    Found u_sub via VHPI
     0.00ns DEBUG    Checking tb_top.u_ic.u_top.u_core.u_sub_wrapper.u_sub exists
     0.00ns DEBUG    Created
     0.00ns DEBUG    Searching for u_dff0
     0.00ns DEBUG    Checking if u_dff0 is native through implementation VPI
     0.00ns WARNING  VPI: Not able to map type vhpiCompInstStmtK(1024) to object.
     0.00ns DEBUG    Unable to fetch object tb_top.u_ic.u_top.u_core.u_sub_wrapper.u_sub.u_dff0
     0.00ns DEBUG    Checking if u_dff0 is native through implementation VHPI
     0.00ns DEBUG    VHPI: Creating tb_top:u_ic:u_top:u_core:u_sub_wrapper:u_sub:u_dff0 of type 2 (vhpiCompInstStmtK)
     0.00ns DEBUG    Found u_dff0 via VHPI
     0.00ns DEBUG    Checking tb_top.u_ic.u_top.u_core.u_sub_wrapper.u_sub.u_dff0 exists
     0.00ns DEBUG    Created
tb_top.u_ic.u_top.u_core.u_sub_wrapper.u_sub.u_dff0
     0.00ns DEBUG    Searching for clk
     0.00ns DEBUG    Checking if clk is native through implementation VPI
     0.00ns WARNING  VPI: Not able to map type vhpiPortDeclK(1079) to object.
     0.00ns DEBUG    Unable to fetch object tb_top.u_ic.u_top.u_core.u_sub_wrapper.u_sub.u_dff0.clk
     0.00ns DEBUG    Checking if clk is native through implementation VHPI
     0.00ns DEBUG    VHPI: Detected a LOGIC type tb_top.u_ic.u_top.u_core.u_sub_wrapper.u_sub.u_dff0.clk
     0.00ns DEBUG    VHPI: Creating tb_top:u_ic:u_top:u_core:u_sub_wrapper:u_sub:u_dff0:clk of type 5 (vhpiEnumTypeDeclK)
     0.00ns DEBUG    Found clk via VHPI
     0.00ns DEBUG    Checking tb_top.u_ic.u_top.u_core.u_sub_wrapper.u_sub.u_dff0.clk exists
     0.00ns DEBUG    Created
     0.00ns DEBUG    clk has 1 elements
    10.00ns DEBUG    Searching for d
    10.00ns DEBUG    Checking if d is native through implementation VPI
    10.00ns WARNING  VPI: Not able to map type vhpiPortDeclK(1079) to object.
    10.00ns DEBUG    Unable to fetch object tb_top.u_ic.u_top.u_core.u_sub_wrapper.u_sub.u_dff0.d
    10.00ns DEBUG    Checking if d is native through implementation VHPI
    10.00ns DEBUG    VHPI: Detected a LOGIC type tb_top.u_ic.u_top.u_core.u_sub_wrapper.u_sub.u_dff0.d
    10.00ns DEBUG    VHPI: Creating tb_top:u_ic:u_top:u_core:u_sub_wrapper:u_sub:u_dff0:d of type 5 (vhpiEnumTypeDeclK)
    10.00ns DEBUG    Found d via VHPI
    10.00ns DEBUG    Checking tb_top.u_ic.u_top.u_core.u_sub_wrapper.u_sub.u_dff0.d exists
    10.00ns DEBUG    Created
    10.00ns DEBUG    d has 1 elements
    70.00ns INFO     test01_access passed
    70.00ns INFO     **************************************************************************************
                     ** TEST                          STATUS  SIM TIME (ns)  REAL TIME (s)  RATIO (ns/s) **
                     **************************************************************************************
                     ** test.test01_access             PASS          70.00           0.01      10970.02  **
                     **************************************************************************************
                     ** TESTS=1 PASS=1 FAIL=0 SKIP=0                 70.00           0.01       6107.54  **
                     **************************************************************************************
Nabih-Saleh commented 6 months ago

unfortunately, this work around does not always work!, because it complain when compiling .v file because it found illegal syntax based on vhdl compiler