ASIC Verification Interview Guide

06.11.25 11:11 AM - By Advane Harshal

Blog 2: How to Transpose a 2D Array in SystemVerilog

The journey of becoming a successful ASIC verification engineer demands much more than just knowing SystemVerilog syntax or being able to write working code. Interviews at top semiconductor companies rigorously test your problem-solving approach, conceptual clarity, and awareness of industry best practices. Technical coding questions often look simple at first glance but reveal deep insights into how you tackle edge cases, debug issues, and communicate your thought process.

That’s precisely why I created this blog series.


As an engineer and mentor with years of hands-on experience, I found that most candidates struggle not because they can’t write a piece of code, but because they aren’t clear about the “why” and “how” behind the code. My goal is to bridge this gap:

    • To demonstrate the underlying concept,
    • Guide students through an effective problem-solving approach,
    • Point out common mistakes,
    • Deliver clean, interview-ready SystemVerilog implementations.

This series is crafted for students, job seekers, and working engineers who want to build solid fundamentals and stand out in ASIC verification interviews—whether you’re just getting started or aiming for your next big career jump.

Interview Question #1: How to Swap Two Elements in a 2D Array in SystemVerilog – ASIC Verification Interview Series

1. The Simple, Naive Swap Function

Let's start with a basic swap function. This version skips safety checks and doesn't use ref, making it easy to understand but unsafe.

// Naive swap (not robust)

function void simple_swap(byte arr[][], int i1, int j1, int i2, int j2);

byte temp;

temp = arr[i1][j1];

arr[i1][j1] = arr[i2][j2];

arr[i2][j2] = temp;

endfunction

Problems in the Naive Version

    • No boundary checks: Can crash simulation if indices are wrong.
    • Pass by value: The array isn't changed outside the function call.
    • No debug info: Hard to verify in larger testbenches.

2. The Robust, Interview-Ready Swap Function

Now we upgrade the code for real projects and interviews, using ref and validation.


function void swap_2d_elements(ref byte arr[][], int i1, int j1, int i2, int j2);

  if (i1 >= arr.size() || i2 >= arr.size() || j1 >= arr[0].size() 
      || j2 >= arr[0].size()) begin
    $error("swap_2d_elements: Index out of bounds (%0d,%0d), (%0d,%0d)", i1, j1, i2, j2);
    return;
  end

  byte temp = arr[i1][j1];
  arr[i1][j1] = arr[i2][j2];
  arr[i2][j2] = temp;

  $display("Swapped arr[%0d][%0d] with arr[%0d][%0d]", i1, j1, i2, j2);

endfunction

 

Takeaways

Start with simple code for clarity.
Make your solution robust: use ref and validate indices.
Add debug output so others can quickly verify your logic.
Explain these improvements in interviews—they prove your maturity as a verification engineer.







Advane Harshal