Can I constrain a sum/function of array element sizes?

I have found another question/answer on the forum in the meantime that pointed me to the solution below.


   rand t_byte_q  msg_queue[$];
   
   constraint c_msg_queue {
      this.msg_queue.size() inside { [1:16] };
      foreach (this.msg_queue[i]) {
         this.msg_queue[i].size() < (2**10 / this.msg_queue.size());
         this.msg_queue[i].size() > 32;
      }
      sum_pos(this.msg_queue) < 33;
   }

   function int sum_pos(t_byte_q  msg_queue[$]);
      sum_pos = 0;
      foreach(msg_queue[i])
         sum_pos += $ceil(msg_queue.size[i] / 32.0);
   endfunction


I tested your code and it throws an error for me. My code now does what I want, but I would like to understand what yours does :) What does the construct below ( sum(msg) with … ) mean?

msg_queue.sum(msg) with ((2**10 / msg.size() / 32) + (msg.size() % 32 !=0)) < 32;