quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bullet_green_ball.gif Introduction

SystemVerilog added lot of new data types and improved the existing data types to improve run time memory utilization of simulators. Highlights of the SystemVerilog datatypes are below

   

space.gif

  • shortint and longint data types.
  • shortreal (real was already defined in Verilog) data type.
  • string, chandle and class data types.
  • logic, bit and byte data type.
  • User defined types typedef.
  • struct, union, and class data types.
  • void data type.
  • null data type.
  • arrays, queue, associative array, dynamic array
   

space.gif

Next few pages we shall see the basics of this new data types, and then in later chapers we shall see the details of each of this data types.

   

space.gif

Note : User define data types defined by typedef should be first defined before they are used.

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Integer data types

Integer data types can be classified into 2-state types and 4-state types. 2-state types can take only 0, 1, where as 4-state types can take 0,1,X,Z. 2-state types consume less (50%) memory and simulate faster when compared to 4-state types.

   

space.gif

2 state value integer data types are

  • shortint : 16-bit signed integer.
  • int : 32-bit signed integer.
  • longint : 64-bit signed integer.
  • byte : 8-bit signed integer, can be used for storing ASCII charater.
  • bit : User defined vector types.

4-state value integers data types are

  • logic : User defined vector types.
  • reg : User defined vector types.
  • wire : User defined vector types.
  • integer : 32-bit signed integer.
  • time : 64-bit unsigned integer.
   

space.gif

Integer types can be signed or unsigned, thus can change the result of a arthimetic operation. So care should be taken when declaring the data types that may be have to do arthimetic operation on it. By default byte, shortint, int, integer and longint default to signed and bit, reg, logic, and wire defaults to unsigned.

   

space.gif

NoteData type reg and logic are one and same. logic data type was introduced to avoid confusion with reg data type.

   

space.gif

  ../images/main/bullet_star_pink.gif Example - Integer Types
   

space.gif


  1 module data_types();
  2 
  3 bit       data_1bit;
  4 byte      data_8bit;
  5 shortint  data_16bit;
  6 int       data_32bit;
  7 longint   data_64bit;
  8 integer   data_integer;
  9 
 10 bit       unsigned data_1bit_unsigned;
 11 byte      unsigned data_8bit_unsigned;
 12 shortint  unsigned data_16bit_unsigned;
 13 int       unsigned data_32bit_unsigned;
 14 longint   unsigned data_64bit_unsigned;
 15 integer   unsigned data_integer_unsigned;
 16 
 17 initial begin
 18    data_1bit   = {32{4'b1111}};
 19    data_8bit   = {32{4'b1111}};
 20    data_16bit  = {32{4'b1111}};
 21    data_32bit  = {32{4'b1111}};
 22    data_64bit  = {32{4'b1111}};
 23    data_integer= {32{4'b1111}};
 24    $display("data_1bit    = %0d",data_1bit);
 25    $display("data_8bit    = %0d",data_8bit);
 26    $display("data_16bit   = %0d",data_16bit);
 27    $display("data_32bit   = %0d",data_32bit);
 28    $display("data_64bit   = %0d",data_64bit);
 29    $display("data_integer = %0d",data_integer);
 30    data_1bit   = {32{4'bzx01}};
 31    data_8bit   = {32{4'bzx01}};
 32    data_16bit  = {32{4'bzx01}};
 33    data_32bit  = {32{4'bzx01}};
 34    data_64bit  = {32{4'bzx01}};
 35    data_integer= {32{4'bzx01}};
 36    $display("data_1bit    = %b",data_1bit);
 37    $display("data_8bit    = %b",data_8bit);
 38    $display("data_16bit   = %b",data_16bit);
 39    $display("data_32bit   = %b",data_32bit);
 40    $display("data_64bit   = %b",data_64bit);
 41    $display("data_integer = %b",data_integer);
 42    data_1bit_unsigned   = {32{4'b1111}};
 43    data_8bit_unsigned   = {32{4'b1111}};
 44    data_16bit_unsigned  = {32{4'b1111}};
 45    data_32bit_unsigned  = {32{4'b1111}};
 46    data_64bit_unsigned  = {32{4'b1111}};
 47    data_integer_unsigned  = {32{4'b1111}};
 48    $display("data_1bit_unsigned  = %d",data_1bit_unsigned);
 49    $display("data_8bit_unsigned  = %d",data_8bit_unsigned);
 50    $display("data_16bit_unsigned = %d",data_16bit_unsigned);
 51    $display("data_32bit_unsigned = %d",data_32bit_unsigned);
 52    $display("data_64bit_unsigned = %d",data_64bit_unsigned);
 53    $display("data_integer_unsigned = %d",data_integer_unsigned);
 54    data_1bit_unsigned   = {32{4'bzx01}};
 55    data_8bit_unsigned   = {32{4'bzx01}};
 56    data_16bit_unsigned  = {32{4'bzx01}};
 57    data_32bit_unsigned  = {32{4'bzx01}};
 58    data_64bit_unsigned  = {32{4'bzx01}};
 59    data_integer_unsigned  = {32{4'bzx01}};
 60    $display("data_1bit_unsigned  = %b",data_1bit_unsigned);
 61    $display("data_8bit_unsigned  = %b",data_8bit_unsigned);
 62    $display("data_16bit_unsigned = %b",data_16bit_unsigned);
 63    $display("data_32bit_unsigned = %b",data_32bit_unsigned);
 64    $display("data_64bit_unsigned = %b",data_64bit_unsigned);
 65    $display("data_integer_unsigned = %b",data_integer_unsigned);
 66     #1  $finish;
 67 end
 68 
 69 endmodule
You could download file data_types.sv here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulation Output - Integer Types
   

space.gif

 data_1bit    = 1
 data_8bit    = -1
 data_16bit   = -1
 data_32bit   = -1
 data_64bit   = -1
 data_integer = -1
 data_1bit    = 1
 data_8bit    = 00010001
 data_16bit   = 0001000100010001
 data_32bit   = 00010001000100010001000100010001
 data_64bit   = 0001000100010001000100010001000
    100010001000100010001000100010001
 data_integer = zx01zx01zx01zx01zx01zx01zx01zx01
 data_1bit_unsigned  = 1
 data_8bit_unsigned  = 255
 data_16bit_unsigned = 65535
 data_32bit_unsigned = 4294967295
 data_64bit_unsigned = 18446744073709551615
 data_integer_unsigned = 4294967295
 data_1bit_unsigned  = 1
 data_8bit_unsigned  = 00010001
 data_16bit_unsigned = 0001000100010001
 data_32bit_unsigned = 00010001000100010001000100010001
 data_64bit_unsigned = 0001000100010001000100010001000
   100010001000100010001000100010001
 data_integer_unsigned = zx01zx01zx01zx01zx01zx01zx01zx01
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com