CodiodeCodiode
Home
Problem Solving
Skill Tracks
My Assignments
Contests
Leaderboard
Community
Settings
Codiode/Problems/Sequential Logic

SPI Slave MOSI Sampler

MediumLogic CircuitBuild

Embedded systems rely on SPI for high-speed sensor and peripheral communication. A robust SPI slave cannot use the incoming serial clock directly as a register clock due to domain crossing hazards.

The circuit must oversample the incoming asynchronous SCK and MOSI signals using the system clock. It must synchronize SCK through a 2-stage flip-flop synchronizer. A third flip-flop must keep the previous state of the synchronized clock to detect a rising edge. Upon detecting a rising edge, the circuit must capture the current MOSI value into the data_out register and assert a registered valid signal high for exactly one clock cycle.

Constraints

  • Use only synchronous elements clocked by the implicit system clock.
  • Do not use SCK as a clock input to any flip-flop.
  • Implement exactly a 2-stage synchronizer for the SCK input before edge detection.

Topics

SynchronizationSPIEdge DetectionInterface

Solve this problem

Place the gates, wire them up and watch the signals settle. Every submission runs on the same simulation engine that grades it.

This problem is part of Codiode Pro. The statement above is free to read.

Sign in to solveSee what Pro unlocks

The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.

Related problems

  • 3-bit Ripple Counter from Toggle Flip-FlopsEasy
  • D Latch from a 2:1 MUXEasy
  • 2-bit Ring CounterEasy
  • T Flip-Flop from a D Flip-FlopEasy
  • Handshake Deadlock Due to Early ResetHard
  • Reconvergence of Individually Synchronized BitsHard
  • Debug: Asynchronous Clear GlitchHard
  • Clock Gate Enable Crossing DomainsHard

Browse all problems · Learning tracks