Data Types Flashcards
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;