Hardware interview practice
Sequence retention, isolation, power switch, and restore
A controller turns one register domain off and later wakes it. External save, power-good, and restore acknowledgements may stall. Implement the synthesizable SystemVerilog power-state controller and its timeout behavior.
Starting point
Question code
input logic clk, rst_n, sleep_req, wake_req;
input logic save_ack, pwr_good, restore_ack;
output logic save_req, iso_en, switch_off, restore_req;
output logic ready, error;Reviewed example
Work through one case
Input
sleep_req at C0, save_ack at C2, pwr_good falls at C3, wake_req at C5, pwr_good rises at C7, and restore_ack at C8.Expected output
After C8 the controller is ON with ready=1, error=0, and all four control requests deasserted.Each acknowledgement advances the ordered save-isolate-power-wake-restore sequence before isolation is finally removed.
What to cover
Requirements
- Reset enters ON with ready=1, all four control outputs and error=0. In ON, an accepted sleep_req clears ready and asserts save_req until save_ack.
- After save_ack, deassert save_req, assert iso_en and switch_off, and wait for pwr_good=0 before entering OFF; wake_req is acted on only in OFF.
- On wake_req, deassert switch_off but keep iso_en=1; after pwr_good=1 assert restore_req until restore_ack, then deassert restore_req and iso_en and return to ON with ready=1.
- Each wait for save_ack, pwr_good transition, or restore_ack allows four sampled cycles including its entry cycle; timeout enters ERROR with error=1, ready=0, iso_en=1, switch_off=1, other controls=0 until reset.
