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

Class specialization is ignored for associative array as a class type parameter #5022

Open
esynr3z opened this issue Mar 27, 2024 · 0 comments
Labels
area: elaboration Issue involves elaboration phase status: ready Issue is ready for someone to fix; then goes to 'status: assigned'

Comments

@esynr3z
Copy link

esynr3z commented Mar 27, 2024

Hello,
It seems that Verilator ignores some_map_t specialization of class wrapper and try to cast this.map to a default type. This can be connected to #4997, as I become able to reach this point after that fix. The code below works in major simulators.

The code:

module test;
  typedef int some_map_t[string];

  class wrapper#(type VAL_T=bit);
    VAL_T value;

    static function wrapper#(VAL_T) from (VAL_T value);
      wrapper#(VAL_T) obj = new();
      obj.value = value;
      return obj;
    endfunction
  endclass

  class foo;
    some_map_t map;
    function wrapper#(some_map_t) to_map();
      return wrapper#(some_map_t)::from(this.map); // <--- error
    endfunction
  endclass

  initial begin
    #1 $finish();
  end
endmodule

The error:

$ verilator --binary test.sv && ./obj_dir/Vtest
Vtest_test__03a__03afoo__Vclpkg__DepSet_hf3806fa6__0.cpp: In member function ‘void Vtest_test__03a__03afoo::__VnoInFunc_to_map(Vtest__Syms*, VlClassRef<Vtest_test__03a__03awrapper>&)’:
Vtest_test__03a__03afoo__Vclpkg__DepSet_hf3806fa6__0.cpp:14:81: error: cannot convert ‘VlAssocArray<std::__cxx11::basic_string<char>, unsigned int>’ to ‘CData’ {aka ‘unsigned char’}
   14 |     vlSymsp->TOP__test__03a__03awrapper__Vclpkg.__VnoInFunc_from(vlSymsp, this->__PVT__map, __Vfunc_from__0__Vfuncout);
      |                                                                           ~~~~~~^~~~~~~~~~
      |                                                                                 |
      |                                                                                 VlAssocArray<std::__cxx11::basic_string<char>, unsigned int>
In file included from Vtest__ALL.cpp:7:
Vtest_test__03a__03awrapper__Vclpkg__DepSet_h3427c6c0__0.cpp:9:106: note:   initializing argument 2 of ‘void Vtest_test__03a__03awrapper__Vclpkg::__VnoInFunc_from(Vtest__Syms*, CData, VlClassRef<Vtest_test__03a__03awrapper>&)’
    9 | void Vtest_test__03a__03awrapper__Vclpkg::__VnoInFunc_from(Vtest__Syms* __restrict vlSymsp, CData/*0:0*/ value, VlClassRef<Vtest_test__03a__03awrapper> &from__Vfuncrtn) {
      |                                                                                             ~~~~~~~~~~~~~^~~~~

Verilator version: Verilator 5.023 devel rev v5.020-202-g1c79df863
OS: Ubuntu 22.04.4 LTS

@esynr3z esynr3z added the new New issue not seen by maintainers label Mar 27, 2024
@wsnyder wsnyder added area: elaboration Issue involves elaboration phase status: ready Issue is ready for someone to fix; then goes to 'status: assigned' and removed new New issue not seen by maintainers labels Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: elaboration Issue involves elaboration phase status: ready Issue is ready for someone to fix; then goes to 'status: assigned'
Projects
None yet
Development

No branches or pull requests

2 participants