Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ073
Page ↗
Q073DesignQualcommASIC interview problem

Convert a Turnstile Protocol into an FSM

TechniquesDesignFSM
DifficultyMedium
TopicProtocols and Interfaces
LanguageSystemVerilog
Requirements4 checkpoints
01

Problem

A turnstile starts LOCKED. A coin while LOCKED moves to UNLOCKED and pulses `unlock`. A push while UNLOCKED permits one passage, returns to LOCKED, and pulses `pass`. A push while LOCKED pulses `alarm`; a coin while UNLOCKED pulses `refund`. Coin and push high together are invalid and leave state unchanged while pulsing `alarm`. Design the state-transition diagram and implement the complete synchronous Moore-state/Mealy-pulse controller.

Module declarationSystemVerilog
module turnstile(input logic clk,rst_n,coin,push,
 output logic locked,unlock,pass,refund,alarm);
// coin/push are synchronous one-cycle events
// pulse outputs are one cycle; reset state is LOCKED

Example input and output

Use this case to check your interpretation
Input
Case 1: LOCKED + coin
Case 2: UNLOCKED + push
Case 3: Either state + coin=1,push=1
Output
Case 1: UNLOCKED, unlock=1, locked=0 on the updated state, all other pulses 0.
Case 2: LOCKED, pass=1, refund=alarm=unlock=0.
Case 3: state unchanged and alarm=1 only.
Explanation

The shown result follows by applying this rule: The diagram and RTL implement all state/event combinations including simultaneous invalid inputs. The cases also demonstrate this requirement: Default every pulse low each cycle, define no-event as state hold, and include illegal-state recovery to LOCKED with no transaction pulse.

02

Requirements (4)

  • Use exactly two stored states, LOCKED and UNLOCKED; active-low reset enters LOCKED and clears all pulse outputs.
  • Implement the four single-event transitions exactly as stated and drive `locked` directly from registered state.
  • When coin and push are both high, keep the old state, pulse alarm only, and do not pulse unlock, pass, or refund.
  • Default every pulse low each cycle, define no-event as state hold, and include illegal-state recovery to LOCKED with no transaction pulse.