Real Interview Questions for the Firmware Engineer at SK Hynix
NewInterview Q&A
Q&A-1Walk me through how you would choose between Mealy and Moore FSMs for a firmware command sequencer, and what characteristics would make you reject each one?
Reported in SK hynix Engineer (4/5, Feb 2, 2026): Stable platform
The 90-second answer
I would start by asking what the FSM drives. For a NAND command sequencer the outputs are enables that start a read, latch an address, or gate ECC. Those must not move mid-cycle when a host signal wiggles. That pushes me to a Moore machine, where output is decoded from the state register alone. I would use Mealy, where output depends on state and current input, only for a detector or a ready decode where the same-cycle response buys a cycle and the result is registered before it touches the datapath.
| Characteristic | Moore | Mealy |
|---|---|---|
| Output function | out = f(state) | out = f(state, input) |
| Timing | Changes after the clock edge that enters the state | Can change in the same cycle as the input |
| State count | Often one extra state to hold a response | Often fewer states |
| Glitch exposure | Low, state register is stable between edges | Higher, input transitions feed the output directly |
| Fit in this design | Command, address and data enables | Sequence detect, live rdy decode |
Worked trace: detecting 101
Clock on each row. z is the detect output.
| Cycle | Input | Moore state | Moore z | Mealy state | Mealy z |
|---|---|---|---|---|---|
| 0 | - | IDLE | 0 | IDLE | 0 |
| 1 | 1 | GOT_1 | 0 | GOT_1 | 0 |
| 2 | 0 | GOT_10 | 0 | GOT_10 | 0 |
| 3 | 1 | GOT_101 | 1 | IDLE | 1 |
| 4 | 1 | GOT_1 | 0 | GOT_1 | 0 |
Moore needs GOT_101 and asserts z a cycle after the final 1 is sampled. Mealy asserts z with that 1 and can fall back immediately. If that cycle costs throughput on every read, Mealy wins. If z starts a DMA or an ECC block, the extra cycle is cheaper than a glitch.
// Moore sequencer fragment, SystemVerilog, synthesizable
typedef enum logic [1:0] {IDLE, CMD, ADDR, DATA} state_t;
state_t state, next;
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) state <= IDLE;
else state <= next;
always_comb begin
next = IDLE;
unique case (state)
IDLE: if (cmd_valid) next = CMD;
CMD: next = ADDR;
ADDR: next = DATA;
DATA: next = IDLE;
endcase
end
assign cmd_en = (state == CMD);
assign addr_en = (state == ADDR);
assign data_en = (state == DATA);No input appears in those assigns. A noisy cmd_valid can affect the next state calculation, but it cannot pulse cmd_en between edges. The Mealy equivalent would write assign cmd_en = (state == IDLE) && cmd_valid;. That saves the CMD state, and it also means a 2 ns glitch on cmd_valid becomes a 2 ns enable pulse.
When I reject each one
I reject a pure Mealy sequencer when its output crosses into a latch, a clock domain, or a NAND timing generator. The failure is not theoretical. A late input near the clock edge can produce a runt pulse that the next block samples as a real command, and the error shows up as a rare abort with no reset reason logged. I reject a pure Moore detector when the protocol requires the response in the same cycle, for example a handshake where the peer drops the request if z is late. Then I keep Mealy but register z on the next edge before it drives anything stateful.
Two other choices I state up front. I use a synchronous FSM, state changes only on clk, because an asynchronous FSM that changes on input edges is hard to constrain and metastability from an unsynchronized host input can leave the state register in an illegal encoding. I also make the transition table complete, with a default to IDLE and a timeout to ERR. An incomplete table can map an unused input combination to a dead state after a soft error flips a bit, and the channel then hangs until a full reset. In simulation I check that every state reaches IDLE within a bounded number of cycles from any illegal encoding, and in the lab I inject that encoding to confirm recovery.
That framing, Moore for enables, Mealy only where the cycle matters and the output is contained, is the judgement I would defend in the loop.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Q&A-2How do you synchronize data?
Reported in SK hynix Engineer (4/5, Feb 2, 2026): Stable platform
The 90-second answer
Synchronization depends on what is unsynchronized. If a signal comes from another clock domain, I do not sample it directly with one flop. I pass it through a two-flop synchronizer, because the first flop can go metastable and the second flop gives it a full clock period to settle before logic uses it. If the data is multi-bit, I never synchronize the bits independently. I use a handshake for a single control transfer, or an asynchronous FIFO with Gray-coded pointers for a stream.
In NAND firmware that distinction shows up constantly. A host command arrives on the host interface clock, the firmware core runs on its own clock, and the NAND array runs on a third clock. A single status bit crossing between those domains gets a synchronizer. A command queue or DMA payload crossing between them gets an async FIFO or a handshake with a toggle and an acknowledge. Treating a bus like a single bit is how you get a torn command that passes simulation and fails on silicon.
// Single-bit CDC: 2-flop synchronizer, destination clock domain
module sync2 (
input logic clk_dst,
input logic rst_n_dst,
input logic async_in,
output logic sync_out
);
logic [1:0] shift;
always_ff @(posedge clk_dst or negedge rst_n_dst) begin
if (!rst_n_dst)
shift <= 2'b00;
else
shift <= {shift[0], async_in};
end
assign sync_out = shift[1];
endmoduleThe first flop (shift[0]) is allowed to go metastable. The second flop (shift[1]) is the one the rest of the design trusts. Reset is asserted asynchronously and released synchronously to the destination clock, otherwise the reset release itself becomes an unsynchronized input.
Choosing the mechanism
| Data | Mechanism | Why | Cost |
|---|---|---|---|
| --- | --- | --- | --- |
| --- | --- | --- | --- |
| --- | --- | --- | --- |
| 1-bit level or pulse | 2-flop synchronizer | Metastability contained to one bit | 2 destination cycles latency |
| 1-bit event, must not be lost | Toggle handshake | Source holds until acknowledge returns | 3 to 4 cycles per transfer |
| Multi-bit bus, low rate | MCP handshake, bus held stable | All bits sampled together after sync of request | Low throughput |
| Multi-bit stream, high rate | Async FIFO, Gray pointers | Decouples domains, absorbs bursts | Memory, pointer sync latency |
For a pulse that is shorter than the destination clock period, a plain synchronizer can miss it entirely. That is a different failure from metastability. I stretch the pulse in the source domain or convert it to a toggle that the destination samples and then toggles back.
Worked trace: toggle handshake
Suppose the host domain raises req_toggle to send one command word, and the core domain holds the bus stable until it acknowledges.
| Cycle (dst clock) | req_toggle sampled | Core action | ack_toggle returned |
|---|---|---|---|
| 0 | 0 | idle | 0 |
| 1 | 1 | detect change, latch bus | 0 |
| 2 | 1 | process command | 1 |
| 3 | 1 | hold ack until source sees it | 1 |
| 4 | 0 (source clears) | return to idle | 0 |
The bus is only sampled in cycle 1, after the request has passed through the synchronizer and the source has held it stable for at least one destination period. If the source changes the bus in cycle 2, the core has already latched the old value.
Failure modes I would name in the loop
Metastability is the first. Mean time between failures rises roughly exponentially with the settling time you give the first flop, so adding a third flop buys a large MTBF improvement at the cost of one more cycle. In practice, at a 100 MHz destination clock, a 2-flop synchronizer is the baseline and a 3-flop version is what I would propose for a signal that gates a NAND command issue, where a wrong sample corrupts data rather than just delaying it. Those figures are design targets, not guarantees, and the vendor cell library MTBF data decides the final count.
The second failure is reconvergence. If a synchronized signal fans out to two flops in different parts of the design, the two copies can resolve metastability differently and the design sees two different values. The fix is to synchronize once, register the output once, and fan out the registered signal.
The third is the async FIFO pointer. Binary pointers crossing domains can be sampled mid-transition with several bits changing at once, which produces a garbage pointer value. Gray code changes one bit per increment, so a sampled pointer is either the old value or the new one. Full and empty are then computed in each domain from the synchronized pointer of the other side, which adds two synchronizer delays to the flag latency. That latency has to be accounted for in FIFO depth, or the FIFO reports full later than the memory actually fills.
Reset is the fourth. Releasing reset asynchronously to a clock domain can violate recovery and removal timing on the flops. I assert reset asynchronously so the design reaches a known state even if a clock stops, and release it through a reset synchronizer so each domain leaves reset on its own clock edge.
If the interviewer pushes on firmware rather than RTL, I would add the software side: interrupts and DMA completion flags are the same problem at a higher level. The ISR sets a flag in the interrupt domain, the task reads it in the core domain, and the shared queue between them needs a lock or a lock-free ring with proper memory barriers. A flag without a barrier can be observed before the data it protects, which is the software version of sampling a bus too early.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Q&A-3How do you use bit manipulation in firmware code?
Reported in SK hynix Engineer (4/5, Feb 2, 2026): Stable platform
The 90-second answer
In firmware, bit manipulation is how I talk to hardware that packs several controls into one register. A 32-bit control register might hold an enable flag, a mode field, a clock divider and an interrupt enable, each at a fixed offset. I set, clear and test those fields with masks and shifts instead of separate variables, because the hardware reads the register as one word and the datasheet defines it that way.
The pattern I use everywhere is: define the mask from the field width and position, apply it on write, and mask again on read. That keeps a read of a 4-bit field from leaking neighbouring bits into the value.
/* C11, checked against a hypothetical 32-bit CTRL register */
#include <stdint.h>
#define CTRL_ENABLE (1u << 0)
#define CTRL_MODE_SHIFT 4
#define CTRL_MODE_MASK (0xFu << CTRL_MODE_SHIFT) /* bits 4-7 */
#define CTRL_IRQ_EN (1u << 31)
static volatile uint32_t *const CTRL = (volatile uint32_t *)0x40001000u;
static inline void ctrl_set_mode(uint32_t mode)
{
uint32_t v = *CTRL;
v &= ~CTRL_MODE_MASK; /* clear field first */
v |= (mode & 0xFu) << CTRL_MODE_SHIFT; /* mask input, then place it */
*CTRL = v;
}
static inline uint32_t ctrl_get_mode(void)
{
return (*CTRL & CTRL_MODE_MASK) >> CTRL_MODE_SHIFT;
}
static inline int ctrl_is_ready(void)
{
return (*CTRL & CTRL_ENABLE) != 0;
}Clearing before setting matters. If I OR a new mode over the old one, bits from the previous value survive and the register ends up in a mode neither the caller nor the datasheet intended. Masking the input matters for the same reason: a caller passing 0x1F for a 4-bit field would otherwise corrupt the bit above it.
Worked trace
Suppose CTRL reads 0x80000031 and I call ctrl_set_mode(0xA).
| Step | Value | What happened |
|---|---|---|
initial *CTRL | 0x80000031 | IRQ_EN set, MODE = 3, ENABLE set |
v &= ~CTRL_MODE_MASK | 0x80000001 | bits 4-7 cleared, other bits kept |
v |= (0xA & 0xF) << 4 | 0x800000A1 | MODE = 0xA placed at bits 4-7 |
ctrl_get_mode() | 0xA | mask then shift back down |
The same idiom shows up in NAND firmware I would write at SK Hynix. Status polling is a test, not a read of a whole byte: wait until the READY bit is set, then check the FAIL bit, and treat a set FAIL as an error even if READY later asserts. Packing a command or address phase is the inverse operation: each field is masked to its width and shifted to its offset, then ORed into one word for the controller FIFO.
Failure modes I watch for
Read-modify-write on real hardware is the big one. Some registers are write-1-to-clear or write-1-to-set, and some bits change on their own. Reading the register, modifying it in a local variable and writing it back can clear an interrupt flag I never meant to touch, or lose a bit the hardware set between my read and my write. Where the datasheet offers separate SET and CLEAR registers, I use those instead of RMW. Where it does not, I keep the RMW inside a critical section and only touch bits I own.
Shifts have their own traps. Shifting a 32-bit value by 32 is undefined behaviour in C, and 1 << 31 on a signed int overflows, so I use 1u or 1ULL for the top bit. Right-shifting a signed negative value is implementation-defined, so status and flag words stay uint32_t all the way through. Integer promotion also bites: uint8_t values promote to int before shifting, which is harmless for small shifts but surprises people when they mask with a 32-bit constant.
Endianness and width are the last check. A mask that is correct for a 32-bit register is wrong for a 16-bit one, and packing bytes into a word for a DMA buffer depends on whether the controller expects little-endian order. I write the expected byte order next to the packing code and verify it with a known pattern, for example packing 0x12, 0x34 and confirming the word reads 0x3412 on a little-endian target before I trust it in a command path.
When an interviewer pushes on alternatives, the honest answer is that bit manipulation is not optional for register work, but it is the wrong tool for data that is not packed. If a value has a range and a unit, I keep it as a plain integer with a named constant and convert at the register boundary, rather than scattering shifts through the logic.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Q&A-4How do you implement and manipulate linked lists?
Reported in SK hynix Engineer (4/5, Feb 2, 2026): Stable platform
The 90-second answer
In firmware I rarely call malloc. I allocate from a fixed pool and link nodes through a next pointer, keeping a head pointer and, when appends are frequent, a tail pointer. A singly linked list gives O(1) insert and delete at the head, O(n) search, and O(1) extra memory per node beyond the payload. That trade is usually right for queues of pending commands, error logs, or free blocks, where traversal is forward only and memory is tight.
// C11, checked against a static pool. No heap.
#define POOL_SIZE 64
typedef struct Node {
uint16_t id;
struct Node *next;
} Node;
static Node pool[POOL_SIZE];
static Node *free_list; /* reuses next to chain free nodes */
static Node *head;
static Node *tail;
static void pool_init(void)
{
free_list = NULL;
for (int i = POOL_SIZE - 1; i >= 0; i--) {
pool[i].next = free_list;
free_list = &pool[i];
}
head = tail = NULL;
}
static Node *pool_alloc(uint16_t id)
{
if (!free_list) return NULL; /* pool exhausted: caller must handle */
Node *n = free_list;
free_list = free_list->next;
n->id = id;
n->next = NULL;
return n;
}
static void pool_free(Node *n)
{
if (!n) return;
n->next = free_list;
free_list = n;
if (tail == n) tail = NULL; /* caller fixes tail on list removal */
}
static void push_back(uint16_t id)
{
Node *n = pool_alloc(id);
if (!n) return; /* drop or backpressure, never block in ISR */
if (!head) { head = tail = n; return; }
tail->next = n;
tail = n;
}
static int remove_by_id(uint16_t id)
{
Node *prev = NULL, *cur = head;
while (cur && cur->id != id) { prev = cur; cur = cur->next; }
if (!cur) return 0;
if (prev) prev->next = cur->next; else head = cur->next;
if (tail == cur) tail = prev;
pool_free(cur);
return 1;
}Manipulation, with the invariants that make it safe
Three operations cover most firmware uses. Insert at head: set n->next = head, then head = n, and set tail = n if the list was empty. Insert at tail: link from tail and advance tail, which is why the tail pointer matters. Delete: you need the predecessor, so singly linked deletion is O(n) even when you already hold the node, unless the caller passes prev. Reversal is iterative: keep prev, cur, next, flip each next, then swap head and tail.
Worked trace for remove_by_id(20) on 10 -> 20 -> 30, with tail = 30:
| Step | prev | cur | Action | List after |
|---|---|---|---|---|
| 1 | NULL | 10 | cur->id != 20, advance | 10 -> 20 -> 30 |
| 2 | 10 | 20 | match found | 10 -> 20 -> 30 |
| 3 | 10 | 20 | prev->next = cur->next (30) | 10 -> 30 |
| 4 | 10 | 20 | tail != cur, so tail stays 30; free 20 to pool | 10 -> 30 |
If the removed node were 30, step 4 would set tail = prev (10). Forgetting that leaves tail pointing at a node now on the free list, and the next push_back writes through a freed node. That is the classic firmware bug here, and it shows up as a corrupted free list rather than a crash at the delete site.
Choosing the shape
| Shape | Insert/delete at known node | Search | Memory per node | Use when |
|---|---|---|---|---|
| Singly linked | O(1) only with predecessor | O(n) | 1 pointer | Forward scan, queues, free lists |
| Doubly linked | O(1) with node alone | O(n) | 2 pointers | Delete from middle without a scan, LRU ordering |
| Circular singly | O(1) at head with tail | O(n) | 1 pointer | Round-robin scheduler, ring of tasks |
| Intrusive (node embedded in payload struct) | Same as underlying shape | O(n) | 1 pointer, no separate allocation | Payload lifetime tied to list membership, avoids double allocation |
Intrusive lists deserve a mention in a SK hynix loop because NAND controller firmware often queues command descriptors that already exist. Embedding Node in the descriptor avoids a second allocation and keeps the descriptor and its link in one cache line, at the cost of a node belonging to only one list at a time.
Failure modes I would name unprompted
Pool exhaustion: pool_alloc returns NULL. The caller decides, drop the log entry, return ENOMEM to the host, or apply backpressure. Silently blocking in interrupt context is the failure to avoid.
Cycles: a bad next write creates a loop and traversal never terminates. In production I bound traversals in debug builds with a count against POOL_SIZE, and in release I keep writes to next in exactly the three functions above.
Concurrent access: if an ISR pushes while the main loop removes, head and tail can tear. On a single core I disable interrupts around the pointer updates, a few instructions, or use a lock-free single-producer queue instead of a general list. On a multicore controller I would not share a list across cores without that protection.
Corruption from a wild pointer elsewhere in firmware looks identical to a list bug. The pool design helps: every node address must lie inside pool[], which I can assert on free in debug builds, and that check catches most stray frees early.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Curated: · Written: · Reviewed: