System Verilog Data Types – “4-state”

Data Types :

     –> 2-state data types

              a. bit data types

              b. byte data types 

              c. int data type

              d.  shortint  data type

              e. longint data type       

    –> 4- state data types

              a. logic data type

              b. integer data type

              c. time data type

    –> string data type

    –> enum 

    –> typedef

    –> struct 

              

4-state data types : 

             4 – state data types are the data types which have the values “0” ,”1″ , “X”  & “Z ” . These data types have “X(unknow) ” and “Z(high impedance)” values also . 4-state data types are classified as follows :

                           a. logic data type 

                           b. integer data type 

                           c. time data type

a.) logic data type :

                              logic data type is a 4-state data type which have values 0 , 1 , X &  Z . The keyword “logic ” is used to declare the logic data type . System Verilog provides the logic data type which is having both  “reg” datatype and “wire” data type  functionalities.

                    –> logic data type can store values like “reg” data type and can be continuosly driven like “wire”                           data type.

                    –> logic data type does not support inout ports . we can’t declare inout ports as logic type.

                   –>  The default size of logic data type is ” 1″ bit and default value will be ” X (unknown) “.

                   –> logic data type can be used on L.H.S side for assigning values and it also can be used along                           with “assign ” statement as it has both reg and wire functionalities.

                   Syntax : data_type variable_name ;

                    Example : logic  a; a is logic type with 1 bit size

                                        logic [3:0] sum; // sum is a vector of logic type

       b.) integer data type :

                         –>  “integer” data type is 4- state data type which is capable of holding signed integer                                               values  .“integer” data type have all the four values 0 ,1 , X &  Z .

                         –> The default size of “integer” data type is 32 bits and default value is “X(unknown)” .

                          –> we will use keyword “integer” for declaring variable.

                         Syntax : data_type variable_name ;

                         Example : integer  sum ; // sum is variable of integer type with 32 bit size

   

         NOTE : The difference between “int” data type and “integer” data type is “int” is                   will have only two values ( o or 1) but “integer” will have all four values(0,1,X,Z ).

       

         c.) Time data type :

                          –> Time data type is 4- state data type which is having all four values 0,1,X & Z .

                          –> we will use keyword “time” for declaring time data type varibale.

                          –> The system method “$time” will give the simulation time at a particular point of time                                          where it is called.

                          –> default size of time data type is 64 bits and default value will be X(unknow).

                          Syntax : data_type variable_name;

                          Example : time  xtn;

                                              time sim_time;

                                              sim_time = $time; // sim_time will get the time at this particular instance of time.

Leave a Reply