File: t_class_local_bad.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 (89 lines) | stat: -rw-r--r-- 2,156 bytes parent folder | download | duplicates (3)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2020 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0

// Let context messages easily know if given line is expected ok or bad
task ok;
endtask
task bad;
endtask

class Cls;
   int m_pub = 1;
   local int m_loc = 2;
   protected int m_prot = 3;
   task f_pub; endtask
   local task f_loc; endtask
   protected task f_prot; endtask
   static task s_pub; endtask
   static local task s_loc; endtask
   static protected task s_prot; endtask
   task check;
      Cls o;
      ok();  if (m_pub != 1) $stop;
      ok();  if (m_loc != 10) $stop;
      ok();  if (m_prot != 20) $stop;
      ok();  f_pub();
      ok();  f_loc();
      ok();  f_prot();
      ok();  o.f_pub();
      ok();  o.f_loc();
      ok();  o.f_prot();
      ok();  s_pub();
      ok();  s_loc();
      ok();  s_prot();
      ok();  Cls::s_pub();
      ok();  Cls::s_loc();
      ok();  Cls::s_prot();
   endtask
endclass

class Ext extends Cls;
   task check;
      Ext o;
      ok();  if (m_pub != 1) $stop;
      bad(); if (m_loc != 10) $stop;
      ok();  if (m_prot != 20) $stop;
      ok();  f_pub();
      bad(); f_loc();
      ok();  f_prot();
      ok();  o.f_pub();
      bad(); o.f_loc();
      ok();  o.f_prot();
      ok();  s_pub();
      bad(); s_loc();
      ok();  s_prot();
      ok();  Cls::s_pub();
      bad(); Cls::s_loc();
      ok();  Cls::s_prot();
   endtask
endclass

module t (/*AUTOARG*/);
   initial begin
      Cls c;
      Ext e;
      c = new;
      e = new;
      ok();  if (c.m_pub != 1) $stop;
      bad(); if (c.m_loc != 2) $stop;
      bad(); if (c.m_prot != 20) $stop;
      ok();  if (e.m_pub != 1) $stop;
      bad(); if (e.m_loc != 2) $stop;
      bad(); if (e.m_prot != 20) $stop;
      ok();  c.f_pub();
      bad(); c.f_loc();
      bad(); c.f_prot();
      ok();  c.s_pub();
      bad(); c.s_loc();
      bad(); c.s_prot();
      ok();  Cls::s_pub();
      bad(); Cls::s_loc();
      bad(); Cls::s_prot();
      //
      $write("*-* All Finished *-*\n");
      $finish;
   end
endmodule