call bu refrence not used in static function???

16 views
Skip to first unread message

ankushkumar111111

unread,
Dec 19, 2013, 5:26:44 AM12/19/13
to vlsiat...@googlegroups.com
In a static function we cannot pass the argument using call by refrence . Why?
for example
                 static function reg student_info(ref int data, ref int age );
                 .........
                 .........
                  endfunction
here it will show a compile error regarding using of  "ref" in a static function.

Ritesh Joshi

unread,
Dec 24, 2013, 1:04:03 AM12/24/13
to vlsiat...@googlegroups.com
Hi Ankush,

We can use a call by reference in a static function, the property of a static function is that it can be accessed outside the class without the class instantiation and it cannot update the non-static.

 I think the example we are using is causing some problem so kindly share your example at my email id i.e. ritesh...@gmail.com.

Regards
Ritesh 




--
You received this message because you are subscribed to the Google Groups "vlsiatincise" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vlsiatincise...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

ankushku...@gmail.com

unread,
Dec 24, 2013, 7:21:50 AM12/24/13
to vlsiat...@googlegroups.com, ritesh...@gmail.com
Forwarding the programme
module function_by_ref ();
 
reg [7:0] data      ;
reg       parity_out;
 

function  automatic//static reg parity ( ref reg [7:0] idata);
 int parit = 0;
 for (int i= 0; i < 8; i ++) begin
    parit = parit ^ idata[i];
 end
 // We can modify the data passed through reference
 // idata ++ ;
 // Something that is passed as const  ref, can  not be modified
 // tdata ++ ; This is wrong
 return parit;
endfunction
 
initial begin   
  parity_out=0;
  data = 0;
  for (int i=250; i<256; i ++) begin
   #5 data = i;
  // ltime = $time;
   parity_out = parity (data);
   $display ("Data = %00000000b, Parity = %b, Modified data : %b",i, parity_out, data);
 

  end
  #50  $finish;
end
 
endmodule
 
Sent from Windows Mail
 
Reply all
Reply to author
Forward
0 new messages