Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ688
Page ↗
Q688FWQualcommASIC interview problem

Compute wrapped performance-counter deltas

TechniquesSiliconReliabilityDebugComputedeltas
DifficultyMedium
TopicPost-Silicon & Reliability
LanguageC++
Requirements4 checkpoints
01

Problem

Validation takes two snapshots of four free-running 32-bit hardware counters. Write a C++ function that returns modulo-2^32 deltas and the busiest counter.

Starting declarationC++
bool counter_delta(const uint32_t before[4],
const uint32_t after[4], uint32_t delta[4],
unsigned *max_i);

Example input and output

Use this case to check your interpretation
Input
before={100,0xFFFFFFFE,8,2} and after={125,1,17,11}.
Output
delta={25,3,9,9} and max_i=0.
Explanation

Unsigned subtraction handles the wrapped second counter, and the largest delta is 25 at the lowest matching index 0.

02

Requirements (4)

  • Require every pointer; return false without writing outputs if any is null.
  • For each index compute delta[i]=after[i]-before[i] using uint32_t modulo arithmetic.
  • Set max_i to the index of the largest delta; on a tie choose the lower index.
  • Compute all temporary results before writing outputs so aliased before/after and delta arrays still work.