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 Variables system tasks

Systemverilog provides list of system tasks to get information on variables as listed below

   

space.gif

  • type name functions : $typename The $typename system function returns a string that represents the resolved type of its argument.
  • expression size system functions : $size The $bits system function returns the number of bits required to hold an expression as a bit stream.
  • range system functions : $isunbounded The $isunbounded system function returns true if the argument is $.
   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Example : Variables system tasks
   

space.gif


  1 module system_variable();
  2 
  3   bit signed [2:0] abc;
  4   int signed       xyz;
  5   enum {A,B,C=99}  enm;
  6 
  7   typedef struct {bit [7:0] A,B;} AB_t;
  8   AB_t AB[10]; 
  9 
 10   parameter int foo = $;
 11 
 12 initial begin
 13   // $typename usage
 14   $display ("$typename of abc  %s",$typename(abc));
 15   $display ("$typename of xyz  %s",$typename(xyz));
 16   $display ("$typename of enm  %s",$typename(enm));
 17   $display ("$typename of AB_t %s",$typename(AB_t));
 18   $display ("$typename of AB   %s",$typename(AB));
 19   $display ("$typename of foo  %s",$typename(foo));
 20   // $bits usage
 21   $display ("$bits     of abc  %0d",$bits(abc));
 22   $display ("$bits     of xyz  %0d",$bits(xyz));
 23   $display ("$bits     of enm  %0d",$bits(enm));
 24   $display ("$bits     of AB_t %0d",$bits(AB_t));
 25   $display ("$bits     of AB   %0d",$bits(AB));
 26   $display ("$bits     of foo  %0d",$bits(foo));
 27   // $isunbounded
 28   $display ("$isunbounded of abc  %0d",$isunbounded(abc));
 29   $display ("$isunbounded of xyz  %0d",$isunbounded(xyz));
 30   $display ("$isunbounded of enm  %0d",$isunbounded(enm));
 31   $display ("$isunbounded of AB   %0d",$isunbounded(AB));
 32   $display ("$isunbounded of foo  %0d",$isunbounded(foo));
 33 end
 34 
 35 endmodule
You could download file system_variable.sv here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulator Output : Variables system tasks
   

space.gif

 $typename of abc  bit signed[2:0]
 $typename of xyz  int
 $typename of enm  enum system_variable.unnamed$$
 $typename of AB_t struct system_variable.AB_t
 $typename of AB   struct system_variable.AB_t$[0:9]
 $typename of foo  int
 $bits     of abc  3
 $bits     of xyz  32
 $bits     of enm  32
 $bits     of AB_t 16
 $bits     of AB   160
 $bits     of foo  32
 $isunbounded of abc  0
 $isunbounded of xyz  0
 $isunbounded of enm  0
 $isunbounded of AB   0
 $isunbounded of foo  1
   

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