Generating multiple non overlapping chunks of memories from a given big memory

In reply to Rsignori92:

Based on your question, I think you almost got it. I see that you are missing the constraint that related the current start_address to the previous end_address. If you have the current start_adddress greater than (or equal to) the previous end_address, you can guarantee non-overlapping regions.

I have the below example code for a memory, you can refer to the constraints and re-use it for your n-lines problem.


parameter min = 0;
parameter max = 10000;

class memory_chunks;
   
  rand int unsigned x_start[];
  rand int unsigned x_end[];
  rand int x_size[];
  rand int chunks;
  
  constraint size_c {
    foreach(x_size[i]) x_size[i] == x_end[i]-x_start[i];
    foreach(x_size[i]) x_size[i] inside {[1:100]};
  }
  
  constraint chucks_n{
    chunks ==5 ;
  }
  
  constraint num_regions_c {
    x_start.size() == chunks;
    x_end.size() == chunks;
  }
  
  constraint c1 {
    foreach(x_start[i]) x_start[i] inside {min,max};
    foreach(x_end[i])   x_end[i] inside {min,max};
    foreach(x_start[i]) x_start[i] < x_end[i];
  }
  
  constraint non_overlapping_c {
    foreach(x_start[i]) { 
      (i > 0) -> (x_start[i] > x_end[i-1]) ; 
    }
  }
 
endclass