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

Chip Select Lead and Lag Timing

HardLogic CircuitBuild

SPI peripherals require precise framing to sample data correctly. The Chip Select line must be stable before the clock begins toggling and remain held after the final clock edge to ensure the transaction completes cleanly.

Design a synchronous state machine that controls an active-low chip select (cs_n) and a clock enable (sck_en) based on a transaction request (req). The system is clocked by an implicit global clock.

| Cycle | req | State Phase | cs_n | sck_en | |-------|-------|-------------|--------|----------| | 0 | 0 | Idle | 1 | 0 | | 1 | 1 | Lead | 0 | 0 | | 2 | 1 | Active | 0 | 1 | | 3 | 1 | Active | 0 | 1 | | 4 | 0 | Lag | 0 | 0 | | 5 | 0 | Idle | 1 | 0 |

Assume req will always remain asserted for at least two consecutive cycles during a transaction. Assume req will remain deasserted for at least one cycle between transactions.

Constraints

  • Implement a synchronous Moore state machine.
  • Use the active-high synchronous reset rst to return the system to the Idle state.
  • Derive cs_n and sck_en strictly from the current state register.

Topics

State MachineSPIInterface

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