Randomization failure

When I am randomizing it then it is throwing a fatal error.
Please guide me.

Thanks in advance.


class ahb_seq_item extends uvm_sequence_item;

    // global signal
    rand bit                 HRESETn;
    // address and control signals
    bit [31:0]          HADDR[];
    rand brust_type     HBURST;
    rand size_type      HSIZE;
    rand transfer_type  HTRANS;
    rand rw_en          HWRITE;

    // data signals
    rand bit [31:0]     HWDATA[];
    bit [31:0]          HRDATA;
    // transfer response
    resp_type           HRESP;
    bit                 HREADY;
    rand bit [11:0]     start_add;

    constraint start_con { start_add inside {[10:30]};}
      
    `uvm_object_utils_begin(ahb_seq_item)
        `uvm_field_int(HRESETn, UVM_ALL_ON)
        `uvm_field_array_int(HADDR, UVM_ALL_ON)
        `uvm_field_enum(brust_type, HBURST, UVM_ALL_ON)
        `uvm_field_enum(size_type, HSIZE, UVM_ALL_ON)
        `uvm_field_enum(transfer_type, HTRANS, UVM_ALL_ON)
        `uvm_field_enum(resp_type, HRESP, UVM_ALL_ON)
        `uvm_field_enum(rw_en, HWRITE, UVM_ALL_ON)
        `uvm_field_array_int(HWDATA, UVM_ALL_ON)
        `uvm_field_int(start_add, UVM_ALL_ON)
    `uvm_object_utils_end

    function new(string name="ahb_seq_item");
        super.new(name);
        HRESETn = 1;
    endfunction: new
   
    //-------------------------------------------------------------------
    //----constraints for storing incr and wrap brust type in a varaible
    brust_type  str_incr ;
    brust_type  str_wrap;
    constraint incr_name {     if (HBURST == INCR4)  str_incr  == INCR4; 
                               if (HBURST == INCR8)  str_incr  == INCR8; 
                               if (HBURST == INCR16) str_incr  == INCR16; 
                               if (HBURST == WRAP4)  str_wrap  == WRAP4; 
                               if (HBURST == WRAP8)  str_wrap  == WRAP8; 
                               if (HBURST == WRAP16) str_wrap  == WRAP16;
                         }


    //--------------------------------------------------------------------
    //----Constraints for finding hsize length for incrementing the address
   
    int      hsize_in_byte;
    constraint addr_size    { 
                                if(HSIZE == BYTE)     hsize_in_byte == 1;
                                if(HSIZE == HALFWORD) hsize_in_byte == 2;
                                if(HSIZE == WORD)     hsize_in_byte == 4;
                                if(HSIZE == WORDx2)   hsize_in_byte == 8;
                                if(HSIZE == WORDx4)   hsize_in_byte == 16;
                                if(HSIZE == WORDx8)   hsize_in_byte == 32;
                                if(HSIZE == WORDx16)  hsize_in_byte == 64;
                                if(HSIZE == WORDx32)  hsize_in_byte == 128;
                            }
   
    //---------------------------------------------------------------------
   //---- constraints for finding length burst length---------------------
    rand bit [11:0]    undefined_length;
    constraint brust_length_con {
                                if(HBURST==SINGLE) { HADDR.size == 1;  HWDATA.size == 4; }
                                if(HBURST==INCR)   {
                                                        HWDATA.size ==  undefined_length; 
                                                        HADDR.size ==  undefined_length; 
                                                        undefined_length > 0 ;
                                                        undefined_length < 1024; }
                                if(HBURST==WRAP4 || HBURST==INCR4)   {  HADDR.size == 4;   HWDATA.size == 4; }
                                if(HBURST==WRAP8 || HBURST==INCR8)   {  HADDR.size == 8;   HWDATA.size == 8; }
                                if(HBURST==WRAP16 || HBURST==INCR16) {  HADDR.size == 16;  HWDATA.size == 16; }

                            } 
    
    //---------------------------------------------------------------------
    //------Wrap address calculation --------------------------------------
   
    bit      [31:0]    end_addr;
    int                total_bytes;
    bit      [31:0]    wrap_bound;
    bit      [4:0]     haddr_size;
    constraint  wrap_cal  {
                               if (HADDR.size ==  4 || HADDR.size == 8 || HADDR.size == 16){
                                haddr_size      ==  (HADDR.size) ;
                                total_bytes     ==  hsize_in_byte*haddr_size;
                                wrap_bound      ==  int'(start_add / total_bytes)* total_bytes ;
                                end_addr        ==  wrap_bound + total_bytes ;
                                 //WRAP4 or WRAP8 or WRAP16   
                                 if (HBURST == str_wrap){  
                                    foreach(HADDR[i]){
                                         if(i ==0) {  HADDR[i] == start_add ; }
                                         else { 
                                             if( HADDR[i] == end_addr){  HADDR[i]== wrap_bound ;  }
                                             else{ HADDR[i]  == HADDR[i-1] + hsize_in_byte ; }
                                             }
                                    }
                                 }
                               }
                          }
    
    //------------------------------------------------------------------------------------
    //-------address boundary calc for SINGLE, INCR, INCR4, INCR8 n INCR16
    constraint address_boundary {
                                  if (HBURST == SINGLE)  {foreach(HADDR[i]) HADDR[i] == start_add; }
                                 
                                  if (HBURST == INCR){  
                                     foreach(HADDR[i]){
                                         if(i ==0) { HADDR[i] == start_add ;  }
                                         else { HADDR[i]  == HADDR[i-1] + hsize_in_byte ; }
                                      }
                                   }

                                   //INCR4 or INCR8 or INCR16   
                                   if (HBURST == str_incr){  
                                      foreach(HADDR[i]){
                                         if(i ==0) {HADDR[i] == start_add ;}
                                         else { HADDR[i]  == HADDR[i-1] + hsize_in_byte ;  }
                                       }
                                   }                      
                               } 
    //------------------------------------------------------------------------------------
    
endclass : ahb_seq_item


class ahb_single_seq extends ahb_base_seq;

    `uvm_object_utils(ahb_single_seq)

    function new(string name="ahb_single_seq");
        super.new(name);
    endfunction:new

    task body();
        ahb_seq_item seq = ahb_seq_item::type_id::create("seq");
        start_item(seq);
        if(!seq.randomize())
            `uvm_fatal("SINGLE SEQ","randomziation failed inside sequence")
        seq.print();
        seq.HRESETn = 1 ;
       finish_item(seq);
    endtask : body

endclass: ahb_single_seq

In reply to yask_kush:

Please use code tags making your code easier to read. I have added them for you.

Your issue is that you are trying to assign values to variables that aren’t annotated to be randomized. You want to use ‘rand’ for all variables that will be assigned values by the constraints. If these variables aren’t annotated with ‘rand’, they will be 0 and not changed.

In reply to cgales:

Thanks, Cgales for your help.
My issue is resolved now.