all about vlsi DV
1. Introduction
When beginners reach arrays in System Verilog, the most common reaction is:
“Why is this so complicated? Why packed, unpacked, dynamic?”
The confusion happens because arrays are usually explained from syntax first, not from how data is actually used.
In real verification and RTL:
-
Data is produced
-
Data is collected
-
Data is stored
-
Data is processed later
Arrays exist to support these real workflows.
In this article, we will use Alice and Bob repeatedly so arrays become intuitive and memorable, not theoretic
2. What Are the Different Types of Arrays in System Verilog?
(Featured Snippet Target)
System Verilog provides packed arrays for representing bits of a single signal, unpacked arrays for storing collections of elements, and dynamic arrays for storing variable-sized data decided at runtime.
Think of it this way:
-
Packed → one thing made of bits
-
Unpacked → many things
-
Dynamic → many things, size decided later
Now let’s make that concrete.
3. Alice & Bob Setup (Very Important)
-
Alice generates data
-
Bob consumes or checks data
The only question arrays answer is:
How does Alice give data to Bob?
4. Packed Arrays — Alice Sends ONE Thing
Mental Picture (Memorize This)
Alice has one number to send Bob.
That number has many bits.
She sends it as a single unit.
This is a packed array.
Bob:
-
Treats it as one value
Can look inside individual bits if needed
Runnable Example — Packed Array
module packed_array_example;
logic [7:0] packet; // ONE thing, 8 bits
initial begin
packet = 8'b1101_0110;
// Alice sends packet
$display("Packet = %b", packet);
// Bob inspects one bit
$display("Bit 2 = %b", packet[2]);
end
endmodule
Why This Is Packed
-
packet is one signal
-
Bits are tightly packed together
-
Hardware sees it as a bus
👉 Packed arrays are about bits inside one value.
5. Unpacked Arrays — Alice Sends MANY Things
Mental Picture (Very Important)
Now Alice doesn’t have one thing.
She has many separate items.
She puts them in a row of boxes:
-
Box 0
-
Box 1
-
Box 2
-
Box 3
Bob opens one box at a time.
This is an unpacked array.
Runnable Example — Unpacked Array
module unpacked_array_example;
logic box [0:3]; // FOUR separate boxes
initial begin
box[0] = 1;
box[1] = 0;
box[2] = 1;
box[3] = 1;
// Bob checks box 2
$display("Box[2] = %b", box[2]);
end
endmodule
Why This Is Unpacked
-
Each element is independent
-
Not one combined value
-
Order matters more than bit layout
👉 Unpacked arrays are about collections of values.
6. Packed + Unpacked Together — Alice’s Shelf of Packets
Mental Picture (This One Sticks)
Alice now has:
-
A shelf
-
On the shelf are multiple packets
-
Each packet has multiple bits
Bob can:
-
Pick packet number 1
-
Then inspect bit number 3 inside it
This is packed + unpacked together.
Runnable Example — Memory-Like Structure
module combined_array_example;
logic [7:0] shelf [0:3]; // 4 packets, each 8 bits
initial begin
shelf[0] = 8'hA5;
shelf[1] = 8'h3C;
// Bob reads a whole packet
$display("Packet 1 = %h", shelf[1]);
// Bob reads one bit inside packet
$display("Packet 1, Bit 2 = %b", shelf[1][2]);
end
endmodule
👉 This models memory:
-
Rows = unpacked
Columns = packed
7. Dynamic Arrays — Alice Decides Size Later
Mental Picture (Very Real-World)
Alice does not yet know:
-
How many items she will produce
So she tells Bob:
“Wait. I’ll tell you the size later.”
At runtime:
-
She decides how many boxes she needs
-
Then fills them
This is a dynamic array.
Runnable Example — Dynamic Array
module dynamic_array_example;
int items[];
initial begin
// Alice decides size at runtime
items = new[3];
items[0] = 10;
items[1] = 20;
items[2] = 30;
// Bob checks
$display("Size = %0d", items.size());
$display("Item[1] = %0d", items[1]);
end
endmodule
Key Characteristics
-
Size decided at runtime
-
Must be explicitly allocated
-
Used heavily in testbenches
-
Not synthesizable
👉 Dynamic arrays are about flexibility.
8. One Simple Rule to Remember (Interview Gold)
If you remember nothing else, remember this:
Packed = bits of one thing
Unpacked = many things
Dynamic = many things, size later
Interviewers love this clarity.
9. Common Beginner Mistakes
-
Treating unpacked arrays like vectors
-
Forgetting that packed arrays are one signal
-
Using dynamic arrays in RTL
-
Not allocating dynamic arrays before use
These mistakes don’t look obvious — but they cause confusion fast.
10. Interview Perspective
Interviewers usually probe:
-
“Explain packed vs unpacked in simple terms”
-
“How would you model memory?”
-
“Which arrays are synthesizable?”
They want to see:
-
Mental clarity
Not syntax memorization
11. Knowledge Check
-
If Alice sends one value with many bits, which array is it?
-
If Alice stores many independent values, which array is it?
-
Why are dynamic arrays unsuitable for RTL?
Answer these without looking back.
12. What’s Next
Now that you understand how data is stored, the next step is:
How do we manage data that grows and shrinks like a FIFO?
👉 Next Article:
Queues & Dynamic Arrays — FIFO Concepts