quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Optional argument list

When a task or function specifies no arguments, the empty parenthesis, (), following the task/function name shall be optional. This is also true for tasks or functions that require arguments, when all arguments have defaults specified.

   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Example - Optional argument list
   

space.gif


  1 module function_optional_list ();
  2 
  3 reg [7:0] data      ;
  4 reg       parity_out;
  5 time      ltime;
  6 
  7 function reg parity (reg [7:0] a = 8'hAA, time b = 0, time c = 0);
  8  parity = 0;
  9  for (int i= 0; i < 8; i ++) begin
 10     parity = parity ^ a[i];
 11  end
 12 endfunction
 13 
 14 initial begin    
 15   parity_out = parity();
 16   $display ("Data = %00000000b, Parity = %b", 8'hAA, parity_out);
 17   parity_out = parity();
 18   $display ("Data = %00000000b, Parity = %b", 8'hAA, parity_out);
 19    #10  $finish;
 20 end
 21 
 22 endmodule
You could download file function_optional_list.sv here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulation Output
   

space.gif

 Data = 10101010, Parity = 0
 Data = 10101010, Parity = 0
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com