Saturday, 5 December 2015

1.Dynamic array of queue
2.Queue of queue
3.Associative array of queue



module array_of_queue;

typedef int qint_t[$];

// dynamic array of queues
qint_t DAq[]; // same as int DAq[][$];

// queue of queues
qint_t Qq[$]; // same as int Qq[$][$];

// associative array of queues
qint_t AAq[string]; // same as int AAq[string][$];

initial begin

// 1).Dynamic array of 5 queues
DAq = new[5];
// Push something onto one of the queues
DAq[3].push_back(7);
// initialize another queue with three entries
DAq[0] = {1,2,3,4,5};
  $display("%p",DAq);

// 2).Queue of queues -two
  Qq= '{'{1,2},'{3,4,5}};
Qq.push_back(qint_t'{6,7});
Qq[2].push_back(1);
  $display("%p",Qq);

// 3).Associative array of queues

AAq["one"] = {};
AAq["two"] = {1,2,3,4};
AAq["one"].push_back(5);
  $display("%p",AAq);
end

endmodule
-------------------------------------------------------------------------
OUTPUT:

'{'{1, 2, 3, 4, 5} , '{}, '{}, '{7} , '{}}
'{'{1, 2} , '{3, 4, 5} , '{6, 7, 1} }
'{"one":'{5} , "two":'{1, 2, 3, 4} } 


No comments:

Post a Comment