Edit code - EDA Playground
Warning! This exercise has been opened in another tab; autosave has been disabled. Close this tab or refresh to reactivate.

 Languages & Libraries

 Tools & Simulators

 Examples

205


36
 
1
//----------------------------------------------------------------------------------
2
//                      www.verificationguide.com
3
//----------------------------------------------------------------------------------
4
class sv_class;
5
  //class proporties
6
  int x;
7
  
8
  //method-1
9
  task set(int i);
10
    x = i;
11
  endtask
12
  
13
  //method-2
14
  function int get();
15
    return x;
16
  endfunction
17
  
18
endclass
19
  
20
module sv_class_ex;
21
 sv_class class_1;
22
  
23
  initial begin
24
    sv_class class_2 = new();
25
    class_1 = new();
26
    
27
    class_1.set(10);
28
    class_2.set(20);
29
    
30
    $display("\tclass_1 :: Value of x = %0d",class_1.get());
31
    $display("\tclass_2 :: Value of x = %0d",class_2.get());
32
  end
33
endmodule
34
35
36
  
xxxxxxxxxx
1
 
1
6968 views and 3 likes     
A short description will be helpful for you to remember your playground's details
 
100:0