Data Types Flashcards

1
Q

What are the basic verilog data types?

A

reg, wire, integer, real, time, realtime

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

What are the four basic states of a verilog reg?

A

1,0,X,Z

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

What new basic types does System Verilog add?

A

logic, bit, byte, shortint, int, longint, shortreal

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

What is a structure?

A

A collection of data types that can be referenced via a common variable

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

How is a structure declared?

A
typedef struct {
  int coins; real dollars;
} money;
money wallet;
wallet = '{5,19.75}; // '{default:0}; // '{coins:5, dollars:19.75};
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a fixed array?

A

A variable to store a basic data type in continuous locations

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

How is an array declared?

A

int myFifo [0:7];
int myFifo [8];
int myArray [2][3];
bit [8*17:1] myMessage=”Hello World”;

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

How to cast from an real to an int?

A

int’(2.0*3.0)
or system tasks
integer $rtoi(real)
real $itor(integer)

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

What is the difference between reg and wire?

A

reg can only be driven in a procedural (always and initial) block and wire and only be used in an assign statement.

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

What is the logic datatype?

A

It can be driven from procedural or assign but it can only have one driver, or a complier error. A net with more than one driver needs to be a wire.

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

What is a bit?

A

Like logic but it only has two states: 0, 1

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

What are the most common data types in test benches?

A

bit, logic, byte, int

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

What is the string data type?

A

An ordered collection of characters that can be dynamically sized. The class comes with many of the typical C-style string functions: atoi, putc, compare, substr, len, etc.

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

What is the enum data type?

A

A set of named values

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

How to declare an enum?

A

enum {RED, YELLOW, GREEN} light;

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

What is an enum example?

A
module tb;
  typedef enum {T,F} e_b;
  initial begin
    e_b P;
    P=T;
    $display("P=%s",P.name);
  end
endmodule
17
Q

What are the types of arrays in SystemVerilog

A

Packed and unpacked

18
Q

What is a packed array?

A

A packed array is used to refer to dimensions declared before the variable name.

A one dimensional packed array is also called a vector.

They can be made of only the single bit data types like bit, logic.

19
Q

How to declare a 2D packed array?

A

bit [3:0][7:0] m_data;

20
Q

What is an unpacked array?

A

An unpacked array is used to refer to dimensions declared after the variable name.

Unpacked arrays may be fixed-size arrays, dynamic arrays, associative arrays or queues.

21
Q

What is a dynamic array?

A

A dynamic array is an unpacked array whose size can be set or changed at run time

22
Q

What is an associative array?

A

Associative arrays do not have any storage allocated until it is used, and the index expression is not restricted to integral expressions, but can be of any type.