Skip to content

No sorting allowed: check every pair, not just neighbors

write-from-scratch / multi-constraint / array

nonoverlapping_address_ranges could check each region only against its predecessor because the array was sorted. Physical pages here are scattered in no order, so page 3 can overlap page 9 as easily as page 4. Every pair needs checking: a nested foreach over the same array, inside the constraint.

Fix the class below.

Requirements

  1. page_table.size() is between 8 and 16, inclusive.
  2. v_start_addr[0] is 32’h1000_0000, and each later v_start_addr[i] is v_start_addr[i-1] + page_size[i-1]: virtual space is contiguous, with no gaps or overlaps.
  3. Every page_size is 4KB (32’h1000), 64KB (32’h10000) or 2MB (32’h200000).
  4. Nothing orders p_start_addr by index: physical pages may land anywhere, in any order.
  5. No two physical pages overlap, checked for every pair i != j.
  6. No two physical pages are adjacent: p_start_addr[i] never equals p_start_addr[j] + page_size[j], for every pair i != j.
  7. Every physical page fits inside [32’h0000_0000 : 32’hFFFF_FFFF]. A plain p_start_addr + page_size <= 32'hFFFF_FFFF wraps at 32 bits near the top and lets an out-of-range page through.

Source on GitHub

iommu_scattered_page_table.sv