Q113FreeDesign Verification
Verify a channel-capacity optimizer
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.

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
endclassReviewed 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=8The limiting height is 7 across a width of 7; the two-pointer visit order reaches this first maximizing pair.
What to cover
Requirements
- 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.
- Return the first pair visited by that walk whose area equals the mathematical maximum.
- Treat counts outside 2 through MAX_COUNT (default 32) as bad_count with zero area and indices.
- Use widened unsigned arithmetic for the product and make the equal-height branch explicit.
- Treat accepted-write Register Abstraction Layer (RAL) prediction, start priority, response hold, reset retention, and stale-response checks as follow-up environment design.
