B2.2.2 Write the Monitor

MediumImplement20 minIcarus · browser samples / server checksReview the topic

Write the monitor of a FIFO whose read data arrives one clock after the pop. Record every byte that goes in and comes out, in order, and count the pushes and pops the FIFO refused.

Hardware context: A four-entry FIFO with registered read data, inside a bench with a generator, driver, monitor, checker and coverage. Feeding a scoreboard with what the pins really showed.

A monitor turns pin wiggles into transactions. This FIFO's write side is simple: a byte goes in at a rising edge with push high and full low. Its read side is not. The byte of a pop shows on dout only after the rising edge that took the pop.

Write fifo_monitor. The write half is in the starter. Add the read side, so read holds the bytes handed out, oldest first, and count the refused pushes and pops.

Signals in the Timeline

SignalWidthRole
scenario4input of each check
Full specification
At a rising edge with rst at 0The monitor records
push = 1, full = 0din into wrote; n_wrote + 1
pop = 1, empty = 0nothing yet: the byte appears on dout after this edge
the edge after an accepted popdout into read; n_read + 1 (another pop may be taken at the same edge)
push = 1, full = 1, or pop = 1, empty = 1refused + 1; nothing else
rst = 1nothing; a pop taken just before is forgotten, as the FIFO forgets it

All pins change shortly after each rising edge. So at an edge every pin shows the value it had through the cycle before.

Examples

Example 1

Three in, Three Out, One at a Time
Input
PPP.O.O.O... with bytes 11 22 33
Output
n_wrote = 3, n_read = 3, refused = 0, read0 = 0x11, read1 = 0x22, read2 = 0x33, read3 = 0x0, read4 = 0x0, read5 = 0x0, wrote0 = 0x11

Three pushes, then a pop every other clock. Each byte shows on dout one clock after its pop, and comes out in order: 11, 22, 33.

Example 2

Pops on Back-to-Back Clocks
Input
PPPPOOOO.... with bytes a1 b2 c3 d4
Output
n_wrote = 4, n_read = 4, refused = 0, read0 = 0xa1, read1 = 0xb2, read2 = 0xc3, read3 = 0xd4, read4 = 0x0, read5 = 0x0, wrote0 = 0xa1

Four pops on four clocks in a row. At each edge the monitor collects the last pop's byte and notes the new pop.

Example 3

A Pop While Empty, a Push While Full
Input
OPPPPPOOOOO. with bytes 01 02 03 04 05
Output
n_wrote = 4, n_read = 4, refused = 3, read0 = 0x1, read1 = 0x2, read2 = 0x3, read3 = 0x4, read4 = 0x0, read5 = 0x0, wrote0 = 0x1

The first pop finds the FIFO empty, the fifth push finds it full, and the fifth pop finds it empty again. Three refusals, and none of them adds a byte.

Constraints and Contract

  • Keep the module name, the ports, wrote, n_wrote, read, n_read and refused.
  • Between cases the bench sets the counts to 0. At most 16 bytes go each way in a case.

Hints

Hint 1

A pop and its byte are one clock apart: remember the pop until the next edge.

Hint 2

At the edge after a pop, read dout first, then decide about the pop at this edge.

Hint 3

A refused pop leaves dout unchanged, so its byte must not be recorded.

What the grader checks: Eight scripts of 12 clocks, each followed by two idle clocks. The pins move as a four-entry FIFO with registered read data would drive them. The bench reads the counts, the first six bytes read and the first byte written. It does not test more than 16 bytes, or x on a pin.

8 checks on Icarus · browser samples / server checks. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 2 problems on this path

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

Three in, Three Out, One at a Time

Input
PPP.O.O.O... with bytes 11 22 33
Expected output
n_wrote = 3, n_read = 3, refused = 0, read0 = 0x11, read1 = 0x22, read2 = 0x33, read3 = 0x0, read4 = 0x0, read5 = 0x0, wrote0 = 0x11

Three pushes, then a pop every other clock. Each byte shows on dout one clock after its pop, and comes out in order: 11, 22, 33.

Run samples executes all 3 public checks. Check all tests runs 8 checks on the server.

Icarus · browser samples / server checks