Here's a collapsed set of questions asked during the live web seminar along with Chris's answers. If you don't see your question here, or need further clarification, you can always ask on the Verification Academy Forums.
Does SystemVerilog support multidimensional arrays?
Yes, SystemVerilog supports multi-dimensional arrays. This was not shown as it beyond the scope of the webinar.
Is there any method to append one dynamic array into another?
Yes, just use the concatenation operator: c = {a, b};
Is there a better way (using vector methods available in SystemVerilog) to extract the range of bits from a vector, other than writing our own function to extract the bits?
Yes - the SystemVerilog Language Reference Manual (LRM) clearly describes bit and part selects.
Any limitations on index data-type for associative arrays? What is not supported?
The LRM is a little vague here. All integral values are legal, as long as you can compare two values for equality. Real and shortreal data types are illegal. An index with an X or Z is illegal. Strings and class handles are allowed. At least one simulator allows an array or structure as an index – wild!
The original associative array had a wildcard index. While still allowed, my advice is avoid this, as it leads to several problems. That is why I’m not even showing the syntax.
Which array type is good to use in terms of memory? Queues or dynamic array?
If each element is more than a few bytes, than it doesn’t matter. But it starts to matter for large arrays of small elements. Pick one based on how often you need to resize the array.
Is there a way to accommodate multiple elements having equivalent keys in SystemVerilog using associative arrays similar to multimap in C++?
I don't know of a direct way. You could have to make a queue for each index.
When we declare the array as int array[10] then is it little endian or big endian format?
As shown in the slides, "int a[10]" is equivalent to "int a[0:9]"
Does assigning an existing dynamic array to a new handle perform a deep copy or are these arrays linked?
Assignment between arrays will assign the values in the array. Try an example on your favorite simulator.
How do you find the largest number in the array?
Use the array reduction method array.max().
How to make an array if one wants create memory like 1 terabyte?
As the webinar stated, to simulate with very large memories, you need a sparse memory so use an associative array.
You said that the .delete() would "empty" the array, the text says "delete" the array - which one?
array.delete() deletes the contents of the array.
Can we pass class handle in index of associative array?
Yes, it is very common to have an associative array indexed with class handles.
Are the array reduction methods useable with queues?
A queue is an array, so yes, the methods work.
How to sort the array in ascending and descending order?
Use the sort() and rsort() array methods.
How to overwrite a datatype, in a child class (child extends parent), changing the size of datatype. First rule is to declare the field in parent class with virtual keyword. But next?
Are you asking about methods? A virtual method must always have the same signature, in the base and derived classes. You can't change the argument (port) list.
If you declare a dynamic array with a given size (e.g. 8) and then assign it from a different array (like the one in the example with 4 element), then the first dynamic array will be completely overwritten with the size and elements from the second one, correct? In this example, it will have a size of 4 afterwards.
When you assign to an entire dynamic array, its contents are deleted, then a new array is allocated. So yes, the first array would have just 4 elements.
Is copying array is shallow copy?
Yes, just the values in the array are copied, not the objects.
You mention foreach a lot, which direction does foreach count in? Low to High- High to Low - or does it depend on the declaration?
I always declare arrays lo:hi, so my foreach always goes from low to high. Try it out the other direction and let me know.
Can you construct a dynamic array with new[], as in your example?
Yes, that is how you construct the array, as shown.
Why we cannot sort associative arrays?
A sort will change the index of elements. In an associative array, the index and element values are tightly associated. For example, imagine an associative array that translates from an opcode string, such as ADD, JUMP, and the opcode value. If you sort the array, you would break this relationship.
What is 3 dimensional array? How can we read it?
SystemVerilog supports multidimensional arrays, which you can declare a3[2][3][4], and read with a3[1][2][3]
What is a good way to code FIFO-A transfer to FIFO-B one element at a time since we can't do pop from FIFO-A while also iterating through it in foreach or for loop.
Either directly assign the two queues, or use a foreach loop to iterate through the queues.
foreach(qa[i]) qb[i] = qa[i];
A packed array is actually a vector, whereas an un-packed array is an array in true sense? Why cannot there be better terms, packed, un-packed sound very confusing?
I totally agree with you, which is why I avoid the term "packed array".
q.sum() with(item>5) adds xpression result. q.find with(item>5) finds actual value which is greater than 5. Why is that difference?
For the reduction method, the with() clause represents the operand that gets substituted in the unrolled expression. q.sum() with(item>5) gives you the count of items greater than 5. (item>5) returns 1’b0 or 1’b1. The find methods return a list of items selected by the with() clause. It does not modify the items.
Can you please explain how to choose between a SystemVerilog associative array or a queue when creating a scoreboard?
A scoreboard needs to hold expected values. If the actual results return in the same order as the inputs, use a queue as a FIFO. If the results come in a different order, use an associative array.
In a scoreboard we use a combination of associative arrays and queues. Are there any well known use cases like these where we use a combination of array types?
If multiple responses could have the same index into the associative array of expected values, you need to make a queue for every element.
When we prefer to use associative array in real test bench, practical example
A scoreboard needs to hold expected values. If the actual results return in the same order as the inputs, use a queue as a FIFO. If the results come in a different oder, use an associative array.
How can I group together multiple values that are not the same type, like opcodes and operands?
Use a SystemVerilog structure, as described in the SystemVerilog Language Reference Manual (LRM).