0

The design to be tested is written in VHDL and uses unconstrained records like this for its ports:

type forward_stream is record
    data     : std_ulogic_vector;
    -- further members
    ...
end record;

These ports should now be driven from a systemverilog testbench. Is there any way to use the vhdl record type for the testbench signals? If so how do I constrain the record in systemverilog?

Or do I have to create a VHDL package that constrains the record and provides it as a type to be used in the testbench?

As HDL support varies largely between tools, I am asking about questasim (modelsim's big brother, same vendor so supposedly somewhat downward compatible) in particular.

Update

I gathered the following from the Questa SIM user manual for 10.4:

  • A record is mapped to a struct/packed struct (Table 9-5)
  • Subtypes are not mentioned in Table 9-5

I tried:

  1. using a subtype in system verilog to connect to a port of the unconstrained type
  2. using a subtype in system verilog to connect to a port of the unconstrained type with constraints
  3. using a subtype in system verilog to connect to a port of the subtype
  4. using the unconstrained type (without constraints) in system verilog to connect to a port of the unconstrained type with constraints.

Sample code:

VHDL:

library IEEE;
use IEEE.std_logic_1164.all;

package module_crosslanguage_pkg is
    type t is record
        s : std_ulogic_vector(2 downto 0);
        c : std_logic_vector;
    end record;

    subtype t_s is t(c(1 downto 0));
end package;

use work.module_crosslanguage_pkg.all;

entity dummy_test is
    port(a : in t);                -- 1.
    port(a : in t(c(1 downto 0))); -- 2.
    port(a : in t_s);              -- 3.
    port(a : in t(c(1 downto 0))); -- 4.
end entity;

architecture a of dummy_test is
begin
end;

System Verilog

module modulebay_testbench();

import module_crosslanguage_pkg::*;

    t_s testsignal;
    t testsignal2;

    dummy_test u(.a(testsignal)); -- 1., 2., 3.
    dummy_test u(.a(testsignal2)); -- 4.
endmodule;

The error is always Fatal: (vsim-3362) The type of VHDL port 'a' is invalid for Verilog connection (1st connection).

ted
  • 4,791
  • 5
  • 38
  • 84
  • This is entirely a Questasim question. See IEEE Std 1076-2008 14.2 Elaboration of a design hierarchy, paras 7 and 8 *quoted): *Similarly, the means by which top-level interface objects are associated with the external environment of the hierarchy are also defined by an implementation supporting top-level interface objects.* –  Oct 21 '16 at 17:45

1 Answers1

1

Yes, see Sharing User-Defined Types in the Questa User Manual. It shows how to import packages defined in one language and use/import them in the other.

dave_59
  • 39,096
  • 3
  • 24
  • 63
  • How do you get a yes, from three questions? Also there are two subsection to **Sharing User-Defined Types**, ***Using a Common VHDL Package*** and ***Using a Common System Verilog Package***. Which is "Yes"? –  Oct 21 '16 at 17:51
  • Yes was to the main point of your question. You can use the VHDL package in your SystemVerilog testbench. And yes to the How-to question by pointing you to the manual. And yes, you might have to create a separate VHDL package to meet the requirements for importing into SystemVerilog. – dave_59 Oct 21 '16 at 18:00
  • Not my question, and what was the main point of the three questions by the OP? –  Oct 21 '16 at 18:45
  • Hi Dave, I hoped to get an answer from you as you seem to have some insights. Regarding the manual: I looked at it before posting, and it does not help with unconstrained vectors. I updated what I tried, if you have any other ideas of how to make this work (other than writing a wrapper that in VHDL that contains a fully constrained record as interface), any insights would be greatly appreciated. Unfortunately examples/mixedlang did not help either. – ted Oct 24 '16 at 09:07
  • It seems Questa may not support the combination of a record with an unconstrained array at the language boundary. You might have to create a separate constrained type. Sorry, I don't know VHDL well enough to give you a workaround. – dave_59 Oct 24 '16 at 17:28
  • Thanks for letting me know. – ted Oct 24 '16 at 20:56