A structure can contain elements of different data types which can be referenced as a whole or individually by their names. This is quite different from arrays where the elements are of the same data-type.

  int array [10];         // all elements are of int type
  bit [7:0] mem [256];    // all elements are of bit type
  struct { 
    [list of variables]
  } struct_name;
Unpacked Structures

By default, structures are unpacked, meaning that there is an implementation dependent packing of the data-types. A structure is defined using the struct keyword and a list of member declarations can be provided within the curly brackets followed by the name of the structure. The example below will create a structure of name packet with the members opcode, length, addr and data.

Login to your free account to read more ...

Was this article helpful ?