Data Types Flashcards
(22 cards)
What are the basic verilog data types?
reg, wire, integer, real, time, realtime
What are the four basic states of a verilog reg?
1,0,X,Z
What new basic types does System Verilog add?
logic, bit, byte, shortint, int, longint, shortreal
What is a structure?
A collection of data types that can be referenced via a common variable
How is a structure declared?
typedef struct { int coins; real dollars; } money; money wallet; wallet = '{5,19.75}; // '{default:0}; // '{coins:5, dollars:19.75};
What is a fixed array?
A variable to store a basic data type in continuous locations
How is an array declared?
int myFifo [0:7];
int myFifo [8];
int myArray [2][3];
bit [8*17:1] myMessage=”Hello World”;
How to cast from an real to an int?
int’(2.0*3.0)
or system tasks
integer $rtoi(real)
real $itor(integer)
What is the difference between reg and wire?
reg can only be driven in a procedural (always and initial) block and wire and only be used in an assign statement.
What is the logic datatype?
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.
What is a bit?
Like logic but it only has two states: 0, 1
What are the most common data types in test benches?
bit, logic, byte, int
What is the string data type?
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.
What is the enum data type?
A set of named values
How to declare an enum?
enum {RED, YELLOW, GREEN} light;
What is an enum example?
module tb; typedef enum {T,F} e_b; initial begin e_b P; P=T; $display("P=%s",P.name); end endmodule
What are the types of arrays in SystemVerilog
Packed and unpacked
What is a packed array?
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.
How to declare a 2D packed array?
bit [3:0][7:0] m_data;
What is an unpacked array?
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.
What is a dynamic array?
A dynamic array is an unpacked array whose size can be set or changed at run time
What is an associative array?
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.