Verilog HDL: Data Types
Value Set: 
---> Four values to model the functionality
 
     Value level--------- Condition in hardware circuits
 
             0 ------------- > Logic zero, false condition
1 ------------- > Logic one, true condition
X ------------ > Unknown logic value
Z ------------- > High impedance ,floating state
 
 
Nets:
  
Eg:
            wire a;
wire b,c;
wire d=1'b0 //Net d is fixed to logic value zero at declaration
 
 Register:
 
 Eg: 
              reg reset;          //declare a variable reset that can hold its value
 
 Registers can also be declared as signed variables
 Eg:
 
              reg signed[63:0] ; //64 bit signed value
 
 
 
  Nets or reg (multiple bit widths) data types can be declared as vectors
  Eg : 
        wire a;                                         //scalar net variable;default
 
  // 0:always MSB ; 40:always LSB
 Vector Part Select:
It is possible to address bits or parts of vectors.
 Eg: 
 
         busA[7]                   //bit 7 of vector bus A
 
  
 Eg: 
         reg[255:0] data 1;         //Little endian notation
 
 Integer:
 Default width is the host machine word size
 
 Eg:    
           integer counter;                    //general purpose variable used as a counter
 
 Real:
 
  Eg: 
           real delta;           //define a real variable
 
 
 Time:
  
Eg :
        time save_sim_time;                 //define a time variable save_sim_time
 
  
 Arrays:
 
 Eg: 
        integer count[0:7] ;         //an array of 8 count variables
 
 
 Memories:
  
  Eg : 
       reg memory_1_bit[0:1023];           //memory memory_1_bit with 1K 1-bit words
 
  
 
 
  Eg: 
          parameter part_id =5;                        //defines a constant port_id
 
---> Four values to model the functionality
                           ---> Eight strengths of real hardware
1 ------------- > Logic one, true condition
X ------------ > Unknown logic value
Z ------------- > High impedance ,floating state
Nets:
- Represent connection between hardware elements ; is a datatype; not a keyword
 - Nets are declared primarily with the keyword 'wire'
 - Default value is 'z'
 - Exception : 'trireg' net,which defaults to x
 
Eg:
wire b,c;
wire d=1'b0 //Net d is fixed to logic value zero at declaration
- Represent data storage element
 - Retain value until another value is placed onto them
 - Keyword is 'reg'
 
Vectors:
Default is scalar (1-bit)
       wire [7:0] bus;                            //8 bit bus
        wire [31:0] bus A,bus B,bus C;  //3 buses of 32 bit width
       reg clock;                                    //scalar register; default
        reg [0:40] virtual_addr;              //vector register. Virtual address 41 bits wide
It is possible to address bits or parts of vectors.
         bus[2:0]                  //three LSBs of vector bus
        virtual_addr[0:1]    //two MSBs of vector virtual_addr
  Variable Vector Part Select:
       byte = data1[31-:8];      //starting bit=31,width=8=>data[31:24]
       byte = data[24+:8];       //starting bit =24, width=8=>data[31:24]
 - Can be in decimal notation(eg: 3.14)
 - Can be in scientific notation(eg: 3e6)
 - No range declaration possible
 - Default value is zero
 
- A special time register data type is used in verilog to store simulation time
 - Width is application specific ;but atleast 64 bits
 - The system function '$time' is invoked to get the current simulation time
 - The simulation time is measured in terms of simulation seconds
 
Eg :
       initial save_sim_time= $time;  //save the current simulation time
- Allowed for reg, integer, time, real, realtime and vector
 - Multidimensional arrays are also allowed
 - Arrays are accessed by []
 
      reg bool[31:0] ;              //array of 32 one-bit Boolean register variables
       time chk_point[1:100];   //array of 100 time checkpoint variables
      reg [4:0] port_id[0:7];    //array of 8 port_ids; each port_id is 5 bits wide
 - Memories are modeled as a one-dimensional array of registers
 - Each word can be one or more bits
 
      reg[7:0] memory_byte[0:1023];    //memory memory_byte with 1K 8-bit words(bytes)
       memory_byte[511]                        //fetches 1 byte word whose address is 511
Parameters:
- Constant definitions
 
         parameter cache_line_width=256;    //constant defines width of cache line
          parameter signed [15:0] width;         //fixed sign and range for parameter width
No comments:
Post a Comment