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

SPI Command Decoder

HardLogic CircuitBuild

Serial peripheral interface (SPI) slaves must determine the master's intent before transferring payload data. The first byte of an SPI transaction often serves as a command header where the most significant bit (MSB) indicates a read or write operation.

Construct a sequential circuit that decodes the first byte of an SPI transaction. The circuit resets and remains idle while the active-low chip select cs_n is 1. When cs_n is 0, the circuit samples the mosi input on each rising edge of clk. The first sampled bit is the transaction MSB. Exactly on the 8th rising edge of clk, the circuit must assert valid to 1. Simultaneously, it must assert read to 1 if the MSB was 1, or assert write to 1 if the MSB was 0.

Constraints

  • Clear all outputs to 0 immediately when cs_n is 1.
  • Sample mosi strictly on the rising edge of clk.
  • Assert valid, read, and write only on the 8th rising edge of clk after cs_n goes low.
  • Hold the asserted output states as long as cs_n remains 0.

Topics

counterstate-machineinterface

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