2

I am having this issues in the Cadence tool chain simulation when I try to connect the multidimensional user defined type in VHDL to SystemVerilog in a UVM environment. This is the VHDL output type definition:

TYPE loop_reg_ty IS RECORD
      loop_index_value    : std_logic_vector(REG_BITWIDTH-1 DOWNTO 0);
      loop_counter : std_logic_vector(REG_BITWIDTH-1 DOWNTO 0);
      loop_end_flag : std_logic;
END RECORD;

TYPE loop_array_ty is array (MAX_NO_OF_LOOPS-1 downto 0) of loop_reg_ty;

One of the VHDL output ports in my DUT is of type loop_array_ty;

I am trying to define the SystemVerilog equivalent as:

typedef struct packed {
                            bit [REG_BITWIDTH-1:0] loop_index_value;
                            bit [REG_BITWIDTH-1:0] loop_counter;
                            bit loop_end_flag;
                          } raccu_loop_reg_ty;

typedef raccu_loop_reg_ty [MAX_NO_OF_RACCU_LOOPS-1:0] loop_array_ty;

When I use irun, I get the error:

VHDL port type is not compatible with Verilog.

Please suggest the possible work around solution.

toolic
  • 57,801
  • 17
  • 75
  • 117
  • Alternatively, OSVVM allows more advanced verification in straight VHDL, avoiding the need to translate types, possibly losing type information. www.osvvm.org –  Dec 05 '14 at 16:25
  • Your `loop_array_ty` definitions look odd as they do not match. Shouldn't the VHDL be `TYPE loop_array_ty is array (MAX_NO_OF_LOOPS-1 downto 0) of loop_reg_ty;` and the SystemVerilog be `typedef loop_reg_ty loop_array_ty [MAX_NO_OF_RACCU_LOOPS-1:0];`? – Greg Dec 05 '14 at 17:38
  • @Greg : Yes you are correct in VHDL part..That was a typo error..In System verilog "loop_array_ty" is an array of loop_reg_ty elements. Is that a wrong representation ? –  Dec 05 '14 at 17:54
  • @Greg : I am not sure how such instances are resolved. Please suggest any other possible best practices or solutions. I am not allowed to modify the DUT. –  Dec 05 '14 at 18:07
  • @SunilKR, I'm experienced with SystemVerilog, not VHDL. I highly suggest reading § 7.2 _Structures_ and § 7.4 _Packed and unpacked arrays_ of [IEEE Std 1800-2012](http://standards.ieee.org/getieee/1800/download/1800-2012.pdf). Then map that to VHDL arrays & records. I think a `RECORD` is a equivalent to a regular `struct`(not `struct packed`) and a `is array` is an unpacked SV array; but I don't understand VHDL enough to say for certain. – Greg Dec 05 '14 at 18:56

1 Answers1

1

First, your problem is that you're not defining the loop_array_ty correctly. It should be typedef raccu_loop_reg_ty loop_array_ty[MAX_NO_OF_RACCU_LOOPS-1:0].

I would suggest 2 things here:

First, try removing the packed qualifier from the struct definition. Connecting SV structs to VHDL records is something that is only available in newer Incisive versions. Make sure that the version you're using supports this.

If you're using an older version of Incisive (like I was a year back), your only choice is to map the individual record members using $nc_mirror (not tested code, but enough to get you started):

// struct definition...
// ...

module top;
  // intermediate signal we'll mirror onto
  loop_array_ty loop_s;

  // no output connected
  my_dut dut_inst();

  // make the connection between SV and VHDL using nc_mirror
  initial begin
    for (int i = 0; i < MAX_NO_OF_RACCU_LOOPS; i++) begin
      $nc_mirror($sformatf("loop_s[%0d].loop_index_value", i),
        $sformatf("dut_inst.loop_o[%0d].loop_index_value", i);

      // $nc_mirror for loop_counter
      // $nc_mirror for loop_end_flag
    end
  end
endmodule

Also make sure that you're setting the REG_BITWIDTH constant appropriately in both languages, otherwise you'll also get a type mismatch.

Tudor Timi
  • 7,453
  • 1
  • 24
  • 53
  • Thanks for your response. I am using 14.10.004 version i hope that is the new version. –  Dec 05 '14 at 20:50
  • I removed the packed identifier but still no change. The error message is ncelab: *E,CFMPTC : .... and it is in the elaboration stage.. –  Dec 05 '14 at 20:53
  • Do i have to use any extra strings when i use irun command ? As i saw in Questa -mixedsvvh supports importing the vhdl package into SV environment.. Is there something in irun which does the same job in newer version of Incisive. –  Dec 05 '14 at 20:58
  • @SunilKR 14.10.004 is a lot newer than what I was using. As far as I know it shouldn't need any extra option. There is an equivalent to `-mixedsvvh` as far as I know, where you don't need to redefine the types in SV, but I've never used that (you shouldn't need it here anyway). You'll have to wait until Monday or if you're in a hurry use the `$nc_mirror` method. – Tudor Timi Dec 06 '14 at 05:21
  • I'm not sure why i am not able to import the packages defined in vhdl to SV environment then. If i can use it then i don need to take care of this new definitions. I will wait till Monday to know further from you. –  Dec 06 '14 at 14:44
  • @SunilKR I don't get what your problem is. Removing the `packed` qualifier from the `struct` definition works for me in Incisive 14.10.003, so it should work in your version too. – Tudor Timi Dec 08 '14 at 09:57
  • Thanks for trying it out. I am not sure where i m going wrong then ! Are you successful in importing the VHDL package definition in SV environment ? –  Dec 08 '14 at 10:13
  • I have defined my SV file exactly as above but it tells that VHDL type is not compatible with Verilog. –  Dec 08 '14 at 10:14
  • @SunilKR I don't like the idea of letting the simulator import VHDL types directly into SV and vice-versa, because it can cause some subtle issues (I've seen this with Questa and -mixedsvvh). I've redefined the type in SV like you did in your question, barring the `packed`. As I mentioned in my answer, make sure that `REG_BITWIDTH` matches in both languages, otherwise you'll get an error (I've used hard coded constants in my test case for simplicity). – Tudor Timi Dec 08 '14 at 11:02
  • Thanks again. The Register bit width are the same in both environment. I am not sure whether the way i have done is correct. Please correct me if i am wrong or let me know the way you did : When i removed the **Packed** i was not able to use that "type" in typedef : **typedef raccu_loop_reg_ty [MAX_NO_OF_RACCU_LOOPS-1:0] loop_array_ty;** So i changed the definition to **typedef bit [2*REG_BITWIDTH:0][MAX_NO_OF_RACCU_LOOPS-1:0] loop_array_ty;** which leads to the same error. –  Dec 08 '14 at 12:17
  • I got this error if i use the type without "Packed" : **Illegal element type for a vector (vector element type must be an integral type).** Can you please send me those files which i can analyse myself. –  Dec 08 '14 at 12:24
  • The difference is that you have taken the struct type as the DUT output type.In the problem i have stated the DUT output type is of an array of those struct. I doubt whether it works now ! can you suggest the work around if the DUT type is of an array of struct type.Hope you understand the difference. –  Dec 08 '14 at 12:36
  • @SunilKR I noticed, sorry, I misread the question. I've tried it now with the array and it crashes the simulator. See the updated answer. The code I tested with is here: http://www.edaplayground.com/x/KC4 You could follow up with Cadence to fix the crash, but that will take a long time. You'll have to use the `$nc_mirror` option. – Tudor Timi Dec 08 '14 at 12:41
  • I have started to use **$nc_mirror** option now. I encounter this warning **Too few entity port connections** and it further goes on and at end **Error during elaboration**. Please suggest few methods to debug errors in elaboration as it doesn't show any other messages.Also what i noticed (which is weird for me!) is that when i comment out all **$nc_mirror** statements the results doesn't change. I am not sure whether it is having any effect. –  Dec 08 '14 at 15:28
  • @SunilKR I think you get the warning because you leave the output port unconnected (the one of the problematic type). You have to leave it unconnected, though, otherwise the simulator crashes. This has nothing to do with the `$nc_mirror` calls. This warning is anyway not the reason your elaboration is stopping with error (if you take my example and remove the output connection of `dut_inst` it will compile and run). Post your entire log file on the Cadence forum under functional verification (I'm a member there as well). – Tudor Timi Dec 08 '14 at 15:40