Skip to question
SystemVerilogDesignVerificationFirmwareArchitectureASIC Interview Questions→
/Interview questions/Verify a channel-capacity optimizer

Q113·Free·Design Verification

Verify a channel-capacity optimizer

Difficulty
Medium
Topic
Memory Systems
Language
SV
Interview prompt

Question

Write an independent oracle for a software-programmed static random-access memory (SRAM) optimizer. For endpoints left < right, area is min(height[left], height[right]) times (right - left); return the maximum and the first maximizing pair visited by the specified two-pointer walk. Heights are known unsigned 32-bit values. MAX_COUNT is at least two and defaults to 32. pair_area is a helper called only for valid indices left < right in the current queue. Return the complete prediction for the accepted height snapshot; no bus monitor or RAL class is required in this exercise.

Heights at indices 1 and 8 bound a width-seven, height-seven rectangle with area 49.
For [1,8,6,2,5,4,8,3,7], endpoints 1 and 8 give min(8,7) × (8−1) = 49. Find the maximum independently, then apply the specified walk to select among ties.
Candidate starting point

Implementation scaffold

class area_oracle #(int MAX_COUNT = 32);
  function new(); if(MAX_COUNT<2)$fatal(1,"MAX_COUNT must be at least two"); endfunction
  typedef struct {
    bit          bad_count;
    longint unsigned area;
    int unsigned left_idx;
    int unsigned right_idx;
  } prediction_t;

  function automatic longint unsigned pair_area(
      const ref int unsigned height[$], input int left, input int right);
    // TODO: implement.
  endfunction

  function automatic prediction_t predict(int unsigned height[$]);
    // TODO: implement.
  endfunction
endclass
Reviewed example

Trace one case

Input
programmed heights = [1, 8, 6, 2, 5, 4, 8, 3, 7]
Expected output
maximum_area=49; left_index=1; right_index=8

The limiting height is 7 across a width of 7; the two-pointer visit order reaches this first maximizing pair.

What to cover

Requirements

  1. Compute the true maximum across every endpoint pair, then emulate a walk beginning at both ends: advance left when the left height is less than or equal to the right height, otherwise decrement right.
  2. Return the first pair visited by that walk whose area equals the mathematical maximum.
  3. Treat counts outside 2 through MAX_COUNT (default 32) as bad_count with zero area and indices.
  4. Use widened unsigned arithmetic for the product and make the equal-height branch explicit.
  5. Treat accepted-write Register Abstraction Layer (RAL) prediction, start priority, response hold, reset retention, and stale-response checks as follow-up environment design.
Exact question handoffPractice Q113

Solve it in the question bank, keep your progress, and reveal the reviewed solution when your access allows.

Open in question bank →
Solution accessEach time you open this Solution, one Practice Credit is used; it is not permanently unlocked. Premium Solution content also uses one credit per opening.
Continue learning

Verification Planning and Models

Review plan structure, stimulus, checkers, reference models, and system-level answers.

  • Memory Systems
  • UVM RAL
  • Two pointers
  • Tie-breaking
Verification Planning and Models →
Continue practicing

Related questions

Q028 · Memory SystemsVerify a RAM-based duplicate-ID detectorMedium→Q092 · Reference ModelsVerify a minimum energy-window engineMedium→
ASIC.FYI · Learn silicon end to end.info@asic.fyi