System Verilog Packed Arrays
Packed Arrays in System Verilog
Arrays :
1. size( )
2. delete( )
Queues
Bounded Queues
Queues methods
1.size( )
2. delete( ) & delete(index)
3. insert( )
4. push( ) methods
5. pop( ) methods
Associative arrays
Associative array methods
1.size( )
2.delete ( ) & delete(index)
3.num ( )
4.exists( )
5.first( ) ,next( ), prev ( ), last( )
Common Methods for Dynamic Arrays & Queues :
Packed Arrays
What are packed arrays in system verilog?
System verilog uses the word “packed_array” to refer the dimension(size) before the varibale name.
The variables in which the size is declared before the variable name are called “packed_arrays”.
System Verilog enhances packed _arrays by allowing multiple dimensions.
–> A packed array is a mechanism of subdividing the location(vector) into subfields and each field is
capable of holding element .we can access elements individually using indices (field number).
–> packed_array is represented as contiguous set of bits.
–> packed_arrays should be declared as single bit types only i.e the data types should be “bit” , “logic” , “reg” ,
“wire” and other net types .
–> packed arrays will not support data types like “int” ,” byte” ,”short_int” ,”long_int “.
Syntax : data_type [ size ]variable_name;
Example : bit [ 3:0 ]sum;
int [2:0][3:0]register;
Simulated _Example :
module tb () ;
bit [3:0]xtn;
bit [2:0][7:0]mem ;
initial
begin
xtn = 15 ;
mem[0] = 8’b00000011;
mem[2] = 255;
mem[1][5] = 8’b1;
$display(” *****************************************”);
$display(” value of mem[0]= %b “,mem[0]);
$display(” value of mem =%p “,mem);
$display(” value of mem[0]= %p “,mem[0]);
$display(” value of mem[2]= %b “,mem[2]);
$display(” value of mem[1][5] = %b “,mem[1][5]);
$display(” value of xtn = %b “,xtn);
$display(” *****************************************”);
end
endmodule
Simulator_output :
*****************************************
value of mem[0]= 00000011
value of mem =16719875
value of mem[0]= 3
value of mem[2]= 11111111
value of mem[1][5] = 1
value of xtn = 1111
*****************************************