Problems

20. Sequence detector for 1011

MediumWrite the moduleAbout 25 min
fsmsequence detectionmoore

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

Module seq1011

PortDirBitsWhat it is
clkin1Clock.
rstin1Synchronous reset, active high.
dinin1Serial input, one bit per edge.
foundout11 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).

Stuck? . Sign in to save your progress. You can solve the free problems without an account.

Verilogseq1011.v
14px
Loading the editor…

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.

Sequence detector for 1011: Verilog interview question | breadboardhub