Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Rotate a tile in place with one memory port

Hardware interview practice

Rotate a tile in place with one memory port

MediumMemory SystemsSystemVerilog

Rotate a loaded square pixel tile 90 degrees clockwise in place when the local row-major memory permits only one synchronous read or one write per cycle.

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 →
Reviewed example

Work through one case

Input
N=2; row-major tile = [1, 2, 3, 4]
Expected output
row-major tile after rotation = [3, 1, 4, 2]

Saving the complete four-pixel cycle before any write prevents the single-port in-place update from destroying a later source pixel.

What to cover

Requirements

  1. Support N from 1 to 8 and exactly N times N pixels loaded in row-major order.
  2. Use the mapping (row, col) -> (col, N - 1 - row) without allocating a second tile.
  3. Save all four pixels in a cycle before writing any of them back.
  4. Use only a constant number of pixel registers and block external reads during rotation.
  5. After done, provide one-cycle external reads of the rotated row-major tile.
asic.fyi · Learn silicon end to end.info@asic.fyi