Draft preview. Lessons are being written and reviewed.

Digital Design / Module 6: Finite state machines

36. Non-overlapping detection

Change one transition and see the behaviour change.

Lecture coming soon

Lab: your code, animated

The idea

The same pattern, with a different specification: once a match is found, its bits can't be reused. Only one transition changes, yet the behaviour differs on many streams.

The change

From S1101 on inputOverlappingNon-overlapping
1S11S1
0S0S0

After a match in the non-overlapping version, the previous bits don't count. A new 1 is just the first bit of a brand-new attempt, so the machine goes to S1.

Comparing them on a stream

Take 1101101.

  • Overlapping: two matches, ending at positions 4 and 7, sharing position 4.
  • Non-overlapping: one match, ending at position 4. The remaining 101 can't complete a pattern, which requires a leading 11.

Which one do you need?

It depends on what the data means. A frame marker in a continuous stream may need non-overlapping detection, so that one marker isn't counted twice. Signal monitoring may need to catch all occurrences. Read the specification closely, since the phrase "non-overlapping" is easy to miss. In an interview, ask which one is meant before you start. That question alone shows good habits.

Try it

The lab above is set to non-overlapping. Adapt your earlier detector by changing that one line, then run it on the same stream.

Common mistake

Going to S0 regardless of the input after a match. Then the new 1 is thrown away, and a match beginning immediately after another is missed. Test 11011101: the second match starts right after the first, and it should still be found.

Key ideas

  • After a match, return to the start.
  • 1101101 now gives a different number of matches.
  • Read the specification's wording carefully.

Your exercise

Modify your detector and compare both on the same stream.

Find the bug

This code has one deliberate bug. Read the symptom, then click the line you think is wrong.

What goes wrong: The specification says matches must not share bits, but 1101101 reports two matches rather than one.

Interview questions

core1101101 without overlap?

basicStarting from an overlapping 1101 detector, what is the minimum change to make it non-overlapping?

basicHow many matches does a 1101 detector report on 1101101101, with overlap and without?

coreA designer made the detector non-overlapping by sending S1101 straight back to S0, whatever the input. What goes wrong, and which stream shows it?

S1101: state <= S0;  // intended as non-overlapping

coreWhy does the non-overlapping machine go to S1, and not S0, on a 1 straight after a match?

coreIn a Mealy version of the 1101 detector (states S0, S1, S11, S110), where does the overlap choice show up?

coreAn interviewer says 'design a 1101 detector'. What should you ask before drawing anything, and why does it matter?

advancedThe stream 1101101101101 (13 bits) is fed to both 1101 detectors. Give both counts, and explain why the ratio between them is not fixed.

advancedDo overlapping and non-overlapping detectors for the pattern 1000 behave differently?

Practise these 9 questions with animations