Tuesday, January 26, 2016

Data type in SV Part 4

1.Data types :
shortint, int, longint, bit , byte  //signed and 2 state (0 and 1)
logic, reg, time //unsigned and 4 state (0,1,X and Z)
integer  //signed and 4 state

2. user-defined datatype :
class, enumerations, struct, unions, typedef

3.Enumerations :  it is strongly typed and if we want to insert error. also if we don't initialize, then each one will have unique value .

methods : first, last, next, prev, name

4. Structured and Unions :
In structures we can have different data types which we can't have in array.

Diff between structures  and unions :
Same memory space is allocated for every members in UNIONS while in case of structures different mem space is allocated for each data members .

struct {int a; byte b; bit [7:0] c;} my_data ;

memory allocation for the above defined struct "my_data_struct". 
 


union { int a; byte b; bit [7:0] c; } my_data; 
Memory allocation for the above defined union "my_data_union". 



5. Typedef :
It lets us define our own identifiers
typedef bit[3:0] nibble ;
advantage :  reusable, shorter name, less error prone



No comments:

Post a Comment

Ethernet and more

Ethernet is a protocol under IEEE 802.33 standard User Datagram Protocol (UDP) UDP is a connectionless transport protocol. I...