1
  bit    [31:0] queue_1[$];

All I understood from the above expression is that the queue instantiated here is of type bit with a size of 32, but I read somewhere that the queue is a variable size parameter.

If a queue is a variable size parameter, then why are we using [31:0] in front of it? Isn't the queue going to be contained in those parameters of [31:0]?

toolic
  • 57,801
  • 17
  • 75
  • 117

1 Answers1

3

A SystemVerilog queue is an array whose size is not fixed. It can grow and shrink.

bit [31:0] queue_1[$];

is a queue of 32-bit, 2-state numbers. The type bit is a 2-state type (it can have values 1'b0 or 1'b1). This would be a queue of 1-bit, 2-state numbers:

bit queue_1[$];

In SystemVerilog, dimensions to the left of the variable name are called packed dimensions. They represent the number of bits in a number. Dimensions to the right of a variable name are called unpacked dimensions. They represent the number of elements in an array. So, for example, this is an array of 16 32-bit numbers:

bit [31:0] array [0:15];
Matthew Taylor
  • 13,365
  • 3
  • 17
  • 44