HDLbits
Browse Problems

Circuits/Sequential Logic

Sequential Logic

Latches, flip-flops, counters, shift registers, FSMs.

  1. 1

    SR Latch (Gate-Level)

    Build a cross-coupled NOR SR latch and reason about its set/reset/hold/invalid behavior.

    medium
  2. 2

    D Flip-Flop with Asynchronous Reset

    A D flip-flop that samples d on the rising clock edge, with an asynchronous active-high reset.

    medium
  3. 3

    D Flip-Flop with Synchronous Reset and Enable

    A D flip-flop with a synchronous, active-high reset that takes priority over a clock-enable input.

    medium
  4. 4

    4-bit Up/Down Counter

    A 4-bit counter that increments or decrements each clock, with a synchronous reset and free-running wraparound.

    medium
  5. 5

    Decade (Mod-10) Counter

    A synchronous-reset counter that cycles through 0-9 and wraps back to 0, rather than the full 4-bit range.

    medium
  6. 6

    Universal Shift Register

    A 4-bit register that can hold, parallel-load, shift left, or shift right, selected by a mode input.

    medium
  7. 7

    Moore FSM: Non-Overlapping Sequence Detector (1011)

    A Moore-style FSM that flags each non-overlapping occurrence of the bit pattern 1011 in a serial input stream.

    medium
  8. 8

    Mealy FSM: Overlapping Sequence Detector (1011)

    A Mealy-style FSM that flags every occurrence of the bit pattern 1011 in a serial input stream, including overlapping matches.

    medium
  9. 9

    D Flip-Flop

    Store one bit on each rising clock edge.

    easy
  10. 10

    D Flip-Flops

    Register an eight-bit vector on the rising clock edge.

    easy
  11. 11

    DFF with Synchronous Reset

    Add a synchronous active-high reset to a D flip-flop.

    easy
  12. 12

    DFF with Configurable Reset Value

    Reset a four-bit register to a specified nonzero value.

    medium
  13. 13

    DFF with Byte Enable

    Update a 32-bit register only when its write enable is asserted.

    medium
  14. 14

    D Latch

    Implement a level-sensitive D latch.

    medium
  15. 15

    D Flip-Flop with Input Gate

    Feed a gated data value into a rising-edge-triggered register.

    medium
  16. 16

    Mux and DFF

    Register the selected one of two input bytes.

    medium
  17. 17

    Detect a Rising Edge

    Convert a sampled low-to-high transition into a one-cycle pulse.

    medium
  18. 18

    Detect Both Edges

    Generate a one-cycle pulse for either sampled signal transition.

    medium
  19. 19

    Edge Capture Register

    Capture data once on a rising capture event and hold the result.

    medium
  20. 20

    Dual-Edge Register

    Capture data on both the rising and falling clock transitions.

    hard
  21. 21

    Counter 1 to 12

    Build a clocked counter cycling through values 1 to 12.

    medium
  22. 22

    Counter 1000

    Count modulo 1000 with a synchronous reset.

    medium
  23. 23

    Slow Decade Counter

    Use a slower enable pulse to advance a decade counter.

    medium
  24. 24

    4-Digit Decimal Counter

    Count from 0000 through 9999 and present the value as packed BCD.

    hard
  25. 25

    12-Hour Clock

    Advance hours, minutes, and seconds in a 12-hour clock.

    hard
  26. 26

    4-Bit Shift Register

    Shift one serial input bit into a four-bit register each cycle.

    easy
  27. 27

    Left/Right Rotator

    Rotate an eight-bit value left or right by one bit per cycle.

    medium
  28. 28

    Arithmetic Shift by 1 or 8

    Register a signed value after an arithmetic right shift of one or eight bits.

    medium
  29. 29

    5-Bit LFSR

    Advance a five-bit linear-feedback shift register from a fixed nonzero seed.

    medium
  30. 30

    3-Bit LFSR

    Build a three-bit linear-feedback shift register.

    easy
  31. 31

    32-Bit LFSR

    Advance a 32-bit LFSR using four feedback taps.

    hard
  32. 32

    Enabled Shift Register

    Shift a serial input into a register only on enabled cycles.

    easy
  33. 33

    Bidirectional Shift Register

    Shift an eight-bit register in either direction with a serial input.

    medium
  34. 34

    3-Input Lookup Table

    Use three logic inputs as the address of an eight-bit lookup table.

    medium
  35. 35

    Simple FSM 1 (Asynchronous Reset)

    Implement a two-state Moore machine with an active-high asynchronous reset.

    medium
  36. 36

    Simple FSM 1 (Synchronous Reset)

    Implement a two-state Moore machine with synchronous reset.

    medium
  37. 37

    Simple FSM 2 (Asynchronous Reset)

    Toggle between two states on input events with an asynchronous reset.

    medium
  38. 38

    Simple FSM 2 (Synchronous Reset)

    Toggle between two states on input events with a synchronous reset.

    medium
  39. 39

    Simple One-Hot State Transitions

    Cycle a three-state machine through one-hot encoded states.

    medium
  40. 40

    Design a Moore FSM

    Build a Moore machine that recognizes two consecutive sampled ones.

    medium
  41. 41

    Simple FSM 3 (Asynchronous Reset)

    Build a three-state counter-style FSM with asynchronous reset.

    medium
  42. 42

    Simple FSM 3 (Synchronous Reset)

    Build a three-state counter-style FSM with synchronous reset.

    medium
  43. 43

    Lemmings 1: Walk

    Create the walking outputs for a simple two-direction character controller.

    easy
  44. 44

    Lemmings 2: Bump

    Turn the character around when it bumps into either wall.

    medium
  45. 45

    Lemmings 3: Fall

    Track whether the character is walking or falling based on ground support.

    medium
  46. 46

    Lemmings 4: Bump and Fall

    Combine wall collisions and missing ground in a small character controller.

    hard
  47. 47

    Simple State Transitions 3

    Implement a three-state transition graph driven by a serial control input.

    medium
  48. 48

    One-Hot FSM

    Implement a four-state ring machine using one-hot state encoding.

    medium
  49. 49

    Sequence Recognition

    Detect a five-bit pattern in a serial stream.

    medium
  50. 50

    Serial Two's Complementer (Mealy)

    Convert a least-significant-bit-first serial word to its two's complement.

    medium
  51. 51

    Serial Two's Complementer (Moore)

    Build a registered serial two's-complement conversion machine.

    hard
  52. 52

    Serial Receiver

    Receive a start bit, eight data bits, and a stop bit using a sample enable.

    hard
  53. 53

    Serial Receiver and Datapath

    Coordinate serial frame timing and byte capture in a receiver.

    hard
  54. 54

    Serial Receiver with Parity Checking

    Check odd parity while receiving serial data frames.

    hard
  55. 55

    Q8: Design a Mealy FSM

    Recognize an overlapping 1101 pattern with an output pulse on its final input bit.

    medium
  56. 56

    Q3a: FSM State Register

    Build a three-state request, busy, and done controller.

    medium
  57. 57

    Q3b: FSM Output Logic

    Decode status outputs from a two-bit state encoding.

    medium
  58. 58

    Q3c: FSM Next-State Logic

    Implement the combinational next-state table for a request controller.

    medium
  59. 59

    Q6: Complete an FSM

    Complete a Moore FSM that reports after two consecutive input samples.

    medium
  60. 60

    Q6b: FSM Next-State Logic

    Compute next-state bits from encoded state and current input.

    medium
  61. 61

    Q6c: One-Hot Next-State Logic

    Derive next-state equations for a one-hot input recognizer.

    medium
  62. 62

    Q2a: FSM Controller

    Build a two-state start and finish controller.

    medium
  63. 63

    Q2b: One-Hot FSM Equations

    Write next-state equations for a one-hot start/finish controller.

    medium
  64. 64

    Four-Bit Binary Counter

    Build a four-bit modulo-16 binary counter.

    easy
  65. 65

    Decade Counter with Enable

    Add a count enable to a modulo-10 counter.

    medium
  66. 66

    Rule 90 Cellular Automaton

    Update a one-dimensional cellular automaton using Rule 90.

    medium
  67. 67

    Rule 110 Cellular Automaton

    Implement a one-dimensional cellular automaton with Rule 110.

    medium
  68. 68

    Conway's Game of Life 16x16

    Compute a 16 by 16 Game of Life generation with dead cells beyond the boundary.

    hard
  69. 69

    Q2a: Another FSM

    Detect a run of three consecutive high input samples.

    medium
  70. 70

    Q2b: Another One-Hot FSM

    Represent the progress of a run-length detector using one-hot state bits.

    medium
  71. 71

    Mux and DFF with Enable

    Combine a data mux and an enabled register.

    medium
  72. 72

    DFFs and Gates

    Compute a bitwise gate function and register its result.

    medium
  73. 73

    Create Circuit from Truth Table

    Implement a sequential transition table as a clocked circuit.

    medium
  74. 74

    Decade Counter Again

    Add a synchronous load path to a decade counter.

    medium
  75. 75

    PS/2 Packet Parser

    Recognize three-byte PS/2 packets in a continuous byte stream.

    medium
  76. 76

    PS/2 Packet Parser and 3-Byte Datapath

    Find three-byte PS/2 message boundaries and capture each completed packet.

    hard