CPU microarchitecture and simulator design
I was asked this
No reports yet. Sign in to say where you were asked it.
A coding interview question asked in Google's first round (coding), last asked Mar 2026. It tests computer architecture, c++ and simulation.
For a CPU architect role: a technical discussion about a modern out-of-order CPU, then the design of a simulator. State your assumptions wherever behaviour depends on the implementation.
Part 1: trace instructions through the pipeline
You get a short assembly sequence with a conditional branch, a load and an arithmetic instruction that depends on the load. Explain how it moves through fetch, branch prediction, decode, register renaming, scheduling, execution, completion and retirement. Then explain what happens on a branch misprediction and on a cache miss for the load.
Cover: speculative fetch along the predicted path; renaming and the reorder buffer's entries; how the dependent instruction waits for its operand and issues out of order; how a misprediction squashes younger instructions and restores state so that retirement stays in order and exceptions are precise.
Part 2: the memory hierarchy
Explain the role of each of these and how they interact: caches, the MOESI coherence states, miss-status holding registers (MSHRs), virtually indexed physically tagged (VIPT) caches, the TLB, and a hardware page walk.
Cover: which core may write a line in each coherence state and who supplies dirty data; how MSHRs let several misses be outstanding and merge requests for the same line; why VIPT lets the cache index start before translation and what limits the cache size per way; what happens on a TLB hit, a TLB miss and the page walk's own memory accesses.
Part 3: a branch-predictor module in C++
Design a C++ module for a branch predictor inside a simulator: the interface (predict, update), the state it keeps, when updates happen, the statistics it reports and how you test it. If your model updates speculatively, explain how it recovers after a squash.
Part 4: choose a simulation model
Compare cycle-driven with event-driven simulation, and cycle-accurate with cycle-approximate models. Say which you would use for functional correctness, for detailed performance work and for fast design-space exploration, and how you would make it run faster.
What a strong answer covers
- Each structure tied to what happens to a specific instruction, not listed in isolation.
- A clear line between architectural correctness and timing fidelity.
- A predictor interface with stable branch identity (PC plus history), policy separated from simulator plumbing, deterministic state for reproducible traces, and tests for accuracy, aliasing, warm-up and rollback.
- Simulation trade-offs: speed against fidelity, skipping idle periods in event-driven models, modelling contention and back-pressure, profiling and validation against a reference model or real hardware.
Follow-ups
- How can a VIPT L1 cache avoid synonym problems?
- When is the Owned state useful compared with MESI?
- Which predictor updates must be undone after a squash?
- How would you validate a fast approximate simulator?
Where it's asked
- Google · First round: coding · Last asked Mar 202645 min · Coding in a Google Doc, no syntax highlighting or autocomplete · No AI
What it tests
computer architecture · c++ · simulation
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
