File: t_class_param_extends3.v

package info (click to toggle)
verilator 5.038-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 162,552 kB
  • sloc: cpp: 139,204; python: 20,931; ansic: 10,222; yacc: 6,000; lex: 1,925; makefile: 1,260; sh: 494; perl: 282; fortran: 22
file content (63 lines) | stat: -rw-r--r-- 1,647 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2023 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0

package u_pkg;
   typedef class u_report_object;
   typedef class u_callback;

   virtual class u_object;
   endclass

   class u_queue #(type T=int) extends u_object;
      int m_value = 6;
   endclass

   class u_callbacks_base extends u_object;
      typedef u_callbacks_base this_type;
   endclass

   class u_typed_callbacks#(type T=u_object) extends u_callbacks_base;
      typedef u_typed_callbacks#(T) this_type;
      static this_type m_t_inst;
      static u_queue#(u_callback) m_tw_cb_q;
   endclass

   class u_callbacks #(type T=u_object, type CB=u_callback)
      extends u_typed_callbacks#(T);
      static function bit m_register_pair();
      endfunction
      static function void add(u_callback cb);
         u_queue#(u_callback) qr;
         qr = u_callbacks#(u_report_object,u_callback)::m_t_inst.m_tw_cb_q;  //<<<<
         if (qr.m_value != 6) $stop;
      endfunction
   endclass

   class u_callback extends u_object;
   endclass

   virtual class u_report_catcher extends u_callback;
      static local bit m_register_cb_u_report_catcher = u_callbacks#(u_report_object,u_report_catcher)::m_register_pair();
   endclass

   // Having this class (versus using #(u_object) is needed to hit the bug
   class u_report_object extends u_object;
   endclass

endpackage

module t;

   u_pkg::u_callback cb;

   initial begin
      cb = new;

      $write("*-* All Finished *-*\n");
      $finish;
   end

endmodule