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

Systemverilog extends the existing arrays in Verilog with dynamic array, queues and assoc arrays. There arrays support system tasks to work with them. The return type is integer, and the default for the optional dimension expression is 1. The array dimension can specify any fixed-size index (packed or unpacked) or any dynamically sized index (dynamic, associative, or queue).

   

space.gif

  • $dimensions : Returns' the total number of dimensions in the array (packed and unpacked, static or dynamic) 1 for the string data type or any other nonarray type that is equivalent to a simple bit vector, 0 for any other type total number of unpacked dimensions for an array (static or dynamic) 0 for any other type
  • $unpacked_dimensions : Return's the the total number of unpacked dimensions for an array (static or dynamic).
  • $left : Return's the left bound (MSB) of the dimension
  • $right : Return's the right bound (LSB) of the dimension
  • $low : Return's the minimum of $left and $right of the dimension
  • $high : Return's the maximum of $left and $right of the dimension
  • $increment : Return's 1 if $left is greater than or equal to $right and –1 if $left is less than $right
  • $size : Returns the number of elements in the dimension, which is equivalent to $high – $low + 1
   

space.gif

   

space.gif

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

space.gif


  1 module system_array();
  2 // 1 dimension
  3 reg [7:0] me = 10;
  4 // 2 dimension array of Verilog 2001
  5 reg [7:0] mem [0:3] = '{8'h0,8'h1,8'h2,8'h3};
  6 // one more example of multi dimention array
  7 reg [7:0] mem1 [0:1] [0:3] = 
  8    '{'{8'h0,8'h1,8'h2,8'h3},'{8'h4,8'h5,8'h6,8'h7}};
  9 // One more example of multi dimention array
 10 reg [7:0] [0:4] mem2 [0:1] = 
 11    '{{8'h0,8'h1,8'h2,8'h3},{8'h4,8'h5,8'h6,8'h7}};
 12 // One more example of multi dimention array
 13 reg [7:0] [0:4] mem3 [0:1] [0:1]  = 
 14    '{'{{8'h0,8'h1,8'h2,8'h3},{8'h4,8'h5,8'h6,8'h7}},
 15    '{{8'h0,8'h1,8'h2,8'h3},{8'h4,8'h5,8'h6,8'h7}}};
 16 // Multi arrays in same line declaration
 17 bit [7:0] [31:0] mem4 [1:5] [1:10], mem5 [0:255]; 
 18 
 19 initial begin
 20   // $dimensions usage
 21   $display ("$dimensions in me %0d mem %0d mem1 %0d",
 22      $dimensions(me),$dimensions(mem),$dimensions(mem1));
 23   // $unpacked_dimensions
 24   $display ("$unpacked_dimensions in me %0d mem %0d mem1 %0d",
 25      $unpacked_dimensions(me),$unpacked_dimensions(mem),
 26      $unpacked_dimensions(mem1));
 27   // $left
 28   $display ("$left in me %0d mem %0d mem1 %0d",
 29      $left(me),$left(mem),$left(mem1));
 30   // $right
 31   $display ("$right in me %0d mem %0d mem1 %0d",
 32      $right(me),$right(mem),$right(mem1));
 33   // $low
 34   $display ("$low in me %0d mem %0d mem1 %0d",
 35      $low(me),$low(mem),$low(mem1));
 36   // $high
 37   $display ("$high in me %0d mem %0d mem1 %0d",
 38      $high(me),$high(mem),$high(mem1));
 39   // $increment
 40   $display ("$increment in me %0d mem %0d mem1 %0d",
 41      $increment(me),$increment(mem),$increment(mem1));
 42   // $size
 43   $display ("$size in me %0d mem %0d mem1 %0d",
 44      $size(me),$size(mem),$size(mem1));
 45 
 46    #1  $finish;
 47 end
 48 
 49 endmodule
You could download file system_array.sv here
   

space.gif

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

space.gif

 $dimensions in me 1 mem 2 mem1 3
 $unpacked_dimensions in me 0 mem 0 mem1 0
 $left in me 7 mem 0 mem1 0
 $right in me 0 mem 3 mem1 1
 $low in me 0 mem 0 mem1 0
 $high in me 7 mem 3 mem1 1
 $increment in me 1 mem -1 mem1 -1
 $size in me 8 mem 4 mem1 2
   

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