18 / 24 · Concept
Read a serial input over time
Organize a stream of one-bit inputs into a timeline.
Lessons are free to read. Enroll to save your learning progress.
Learning goals
- Organize serial input values by edge
- Distinguish the newest input from the stored vector
Data arriving one bit at a time
din is one bit, so 1011 does not arrive in one instant. Supply 1, 0, 1, 1 for four successive rising edges. q stores the three most recently sampled bits together.
Assume the input is stable before each edge and reset is inactive. Changing din between edges does not update storage until the next rising edge.
| Sample | din | Old q | Next q |
|---|---|---|---|
| 1 | 1 | 000 | 001 |
| 2 | 0 | 001 | 010 |
| 3 | 1 | 010 | 101 |
| 4 | 1 | 101 | 011 |
Why the input string is not the final register
After the fourth sample, q=011 represents the latest three inputs, 0, 1, 1, from older to newer. The first 1 has shifted out. This is not a memory of the complete input history.
The first din=0 in the supplied input file occurs during reset. Number the four data samples 1, 0, 1, 1 separately from that reset cycle to align the table with the waveform.
Try it yourself
After reset, what does q become after three consecutive input bits of 1?
Read the explanation
001 → 011 → 111. Each new 1 enters q[0], while older bits move toward higher indices.