## Design a circuit that detects if one input is a delayed version of the other

Assuming 1b input A is generated by a random sequence, 1b input B is a delayed version of A. The delay value varies, and can be [1, 10] (inclusive).

Design a circuit, that takes A and B as inputs, and Y as output. If B is guaranteed to have 1s, then Y should be 1.

## Design A Programmable Sequence Detector

If the sequence is not predefined, then we can no longer use traditional FSM based sequence detector. Assuming we know the sequence to detect is 5-bit, then we can use the following circuit to detect the sequence.

The circuit consists of a 5-stage shift register, and a 5-bit configuration register. The sequence to detect is programmed in the configuration register, and the input sequence is compared with the configuration register every cycle.

## Determine Whether An Infinite Sequence Is A Multiple of 5

Assuming incoming bit stream is one bit per cycle, design a circuit that detects whether the integer number formed by the bit stream is a multiple of 5.

The idea is to have an FSM consisting of 5 states, S0, S1, S2, S3, S4. Each state represents divided by 5 remainder in previous cycle. If FSM stays at S0, then it means the number could be divided by 5 in previous cycle; otherwise, the number was not a multiple of 5.

## Sequence Detector 3b Palindrome

Assuming the incoming bit stream is one bit per cycle, design a 3-b palindrome sequence detector.

Palindrome code is a sequence of characters which reads the same backward as forward. For example, 101, 010, 111, 000, etc.

The following diagram shows an example solution. We use Mealy Machine instead of Moore Machine since Moore Machine requires more states to detect 3b palindrome sequence.

## Design a circuit that detects sequence 1(01)*1

Draw the diagram of the FSM that can detect the sequence 1(01)*1, where * represents zero or more times. For example, the sequence can be 11, 1011, or 101011, etc.

The following diagram shows a Moore-machine based solution.

## Design a circuit to detect signal toggling

Theoretically, the simplest way to detect whether a signal has changed is to directly compare the current value Value(T) with the last clock cycle value Value(T-1). Thus, we just need to delay/save the value from last clock cycle using one register.