Data types Flashcards

1
Q

New data type advntges

A

Added new datatypes :

  • 2-state data types
  • Strings
  • with built-in searching/sorting support ( Q,dyn_arr,asso_arr)
  • which are Abstract data structures ( classes,structs)
  • with Multiple view of same data ( union/packed array)
  • which are Easy to WR/RD : enum
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Logic

A

Can be used anywhere, in place of nets/registers.

Except : more than one structural drivers

assign l1 = a&b;
assign l1 = c|d;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

All data types

A
  • bit : 1 : 2-state : unsigned
  • logic : 1 : 4-state : unsigned

byte : 8 : 2-state : signed
shortint : 16 : 2-state : signed
int : 32 : 2-state : signed
longint : 64 : 2-state : signed
real : 64 : 2-state : signed
* integer : 32 : 4-state : signed
* time : 64

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Built-in function

A
  • $isunknown( var ) : returns 1 is XorZ in var
  • $timeformat()
  • $size() : Returns size of array
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Fixed Array

A

Fixed array

  • Declaration : type name[size];
    type name[0:size-1];
    eg : int arr[5] ::::= int arr[0:5]
                   int arr[5] = '{ 20,21,22,23,24};    // same as ==  int arr[0:4]
                      Here arr[0] = 20
                           arr[1] = 21
                      foreach(arr[i])  : starts with arr[0],arr[1]...arr[4]
    
                   int arr[4:0] = '{ 20,21,22,23,24};
                      Here arr[0] = 24
                           arr[1] = 23
                      foreach(arr[i])  : starts with arr[4],arr[3]...arr[0]
  • Initialization : arr = ‘{ 20,21,3{-1}};
    arr = ‘{ 20,21,default:-1};
  • size : $size(arr)
  • Accessing : foreach(arr[i]) begin arr[i]=-1; end```
    int arr_2d[3][2] = ‘{‘{00,01}, ‘{10,11}, ‘{20,21}};
    foreach(arr_2d[i,j]) begin … end
    foreach(arr_2d[i]) begin foreach(arr_2d[,j]) begin … end end
    ~~~
  • Compare/copy : If arrays of same type & size
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Array which is packed

A

Unpacked ::
~~~
logic[7:0] u_arr1[4] -
——–——–——–bbbbbbbbb : u_arr1[0] : word0
——–
——–——–bbbbbbbbb : u_arr1[1] : word1
——–
——–
——–bbbbbbbbb : u_arr1[2] : word2
——–
——–_——–_bbbbbbbbb : u_arr1[3] : word3
~~~

Packed :: logic[3:0][7:0] p_arr1 - bbbbbbbb_bbbbbbbb_bbbbbbbb_bbbbbbbbb : p_arr1 : word0

logic[7:0]      u_arr1[4]   = '{ 8'haa, 8'hbb, 8'hcc, 8'hdd};
logic[7:0]      u_arr2[3:0] = '{ 8'haa, 8'hbb, 8'hcc, 8'hdd};
logic[3:0][7:0] p_arr1 = 32'haabbccdd;
logic[4][7:0]   p_arr2 = 32'haabbccdd;

u_arr1[0] :=  8'haa 
u_arr2[0] :=  8'hdd 

p_arr1[0] :=  8'hdd 
p_arr2[0] :=  8'haa 

Use of packed array :
* Multiple view of same data
* @(packed_array) : wait condition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

when is subscript needed after array

A
  • Depends on number of dimension defined after name
  • Page 33-34
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

2d array indexing

A
  • [i,j], [,j] allowed only in foreach.
  • not allowed even in body of foreach
  • page : 30,31
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Dynamin array

A
  • declaration syntax
  • initialization
  • size
  • accessing elements
  • compare/copy
  • Built-in functions
  • usage
  • Page - 35, notebook(ruled)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

when is new not needed for dyn array

A

page 35

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Mutli-D dyn array

A
  • Regular/irregular dyn array
  • https://verificationguide.com/systemverilog/systemverilog-multidimensional-dynamic-array/
bit [7:0] d_array[][];
  
  initial begin
    //memory allocation
    d_array = new[3];
    
    d_array[0] = new[2];
    d_array[1] = new[1];
    d_array[2] = new[4];
    
    //assigning random value to elements
    foreach(d_array[i,j]) d_array[i][j] = $random;
    
    //displaying array elements
    foreach(d_array[i,j])   
      $display("\td_aaray[%0d,%0d] = %0d",i,j, d_array[i][j]);
  end
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

fixed and dynamic array copies

A
  • notebook
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Queues

A
  • declaration syntax
  • initialization
  • size
  • indexing
  • copy/compare
  • builtin function
  • usage
  • notes/page-37
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

$ to access last element

A
  • applicable only to q
  • examples
  • note/page37
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

associative array

A
  • declaration synx ( also class as index type)
  • initalization
  • size
  • copy/compare
  • built-in functions
  • usage
  • https://www.chipverify.com/systemverilog/systemverilog-associative-array
  • notes/page-39
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

mulidimensional AA

A
  • initializtion
  • indexing
  • https://www.chipverify.com/systemverilog/systemverilog-associative-array
17
Q

display whole AA/dyn arr

A
  • https://www.chipverify.com/systemverilog/systemverilog-associative-array
18
Q

assign design var to dyn variable

A

https://verificationacademy.com/forums/systemverilog/initializing-multidimensional-associative-array

19
Q

AA array of type dyn arr

A

https://www.chipverify.com/systemverilog/systemverilog-associative-array

20
Q

next/prev of AA

A
  • function int next (ref index); Finds the smallest index whose value is greater than the given index
  • function int prev (ref index); Finds the largest index whose value is smaller than the given index
module top;
  logic[7:0] aa_inst[string] = '{ "BEE" : 4, "AEE" : 5, "CEE" : 6};
  string idx; // unlike forach(arr[i]), where i need not be declared, idx need to be declared
  initial begin
    aa_inst.first(idx);
    $display("Associative array : %0p,  first_indx=%0s",aa_inst,idx);
      // output : associative array : '{"AEE":'h5, "BEE":'h4, "CEE":'h6} ,  first_indx=AEE

    $display("\n----------------------------");
	if(aa_inst.first(idx)) begin
	  do begin 
	    $display("\tUsing first,next ::  [%0s] = %0d",idx,aa_inst[idx]);
	  end while(aa_inst.next(idx));
	end
    $display("\n----------------------------");
	if(aa_inst.first(idx)) begin
	  do begin 
	    $display("\tUsing first,prev :: [%0s] = %0d",idx,aa_inst[idx]);
	  end while(aa_inst.prev(idx));
	end  
	
    $display("\n----------------------------");
	if(aa_inst.last(idx)) begin
	  do begin 
	    $display("\tUsing last,next ::  [%0s] = %0d",idx,aa_inst[idx]);
	  end while(aa_inst.next(idx));
	end
    $display("\n----------------------------");
	if(aa_inst.last(idx)) begin
	  do begin 
	    $display("\tUsing last,prev :: [%0s] = %0d",idx,aa_inst[idx]);
	  end while(aa_inst.prev(idx));
	end  
	
end
endmodule

Associative array : ‘{“AEE”:’h5, “BEE”:’h4, “CEE”:’h6} , first_indx=AEE

    Using first,next ::  [AEE] = 5
    Using first,next ::  [BEE] = 4
    Using first,next ::  [CEE] = 6
    Using first,prev :: [AEE] = 5
    Using last,next ::  [CEE] = 6
    Using last,prev :: [CEE] = 6
    Using last,prev :: [BEE] = 4
    Using last,prev :: [AEE] = 5
21
Q

reduction methods

A
  • sum
  • and
  • or
  • xor
  • product

notes/page 41

22
Q

select random element in array

A

page 42