20. Sequence detector for 1011
One bit arrives on din at every rising clock edge. Detect the pattern 1, 0, 1, 1 (in the order received), allowing overlap: the last bit of one match may start the next one, so 1011011 contains two matches.
Use a Moore machine: found depends only on the state, so it is 1 for the whole clock cycle after the edge that received the final 1 of a match, and 0 otherwise.
rst (synchronous, active high) returns the machine to the state where nothing of the pattern has been seen.
Ports
| Port | Dir | Bits | What it is |
|---|---|---|---|
clk | in | 1 | Clock. |
rst | in | 1 | Synchronous reset, active high. |
din | in | 1 | Serial input, one bit per edge. |
found | out | 1 | 1 for one cycle after a complete 1011. |
Example
Input 1, 0, 1, 1, 0, 1, 1: found is 1 after the fourth bit and again after the seventh (the "1" that ended the first match starts the second).
Written hints
AI hint
Submissions
No submissions yet. Submit your answer and it shows here. Sign in to keep them.
Submit your answer to have it graded. The hidden test runs on the server; you see whether it passes and, if not, the first case it gets wrong.
Press Build to check your code with Yosys. Errors and warnings show here, and a clean build draws the logic diagram.
Build your design to drive it by hand and see its signals here.