Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Constrain eight aligned nonoverlapping memory regions

Hardware interview practice

Constrain eight aligned nonoverlapping memory regions

HardMemory SystemsSystemVerilog

Generate eight ordered byte-addressed regions inside a 1 MiB space with four-byte-aligned bases, sizes from 16 through 4096 bytes, and no overlap.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Starting point

Question code

rand bit [20:0] base[8];
rand bit [12:0] size[8];
Reviewed example

Work through one case

Input
region 0: base 0, size 16; region 1: base 16, size 32
Expected output
legal adjacent regions with exclusive endpoints 16 and 48

Both bases are aligned, the second begins at the first region's endpoint, and neither region extends beyond 1 MiB.

What to cover

Requirements

  1. Require base[i][1:0] == 0 and size[i] inside 16 through 4096.
  2. Order the regions by increasing base.
  3. Place each region at or beyond the widened endpoint of its predecessor.
  4. Require every widened base-plus-size endpoint to be at most 1 MiB.
asic.fyi · Learn silicon end to end.info@asic.fyi