This problem set closes the Memory Elements chapter. Each article's practice exercise and drills cover one memory alone; these 6 problems make memories work with the logic around them.

Most problems hand you code to extend, fix or review rather than a blank file. Each one runs in ChipVerify Lab, and when your design fails, the grader explains what went wrong and which article covers it.

6 problems | Intermediate Level

What You'll Learn

  • Line up a valid bit with the data of a synchronous read
  • Give a memory a clean start without resetting its array
  • Size pointers and counts for every fill level, at any depth
  • Keep full, empty and the count right when both sides act at once
  • Build a packet buffer from a RAM and a FIFO of lengths

What You'll Build

Across the set you build the parts of a packet buffer, the block that holds packets between two parts of a design that run at their own pace.

Each problem adds or fixes one part: the RAM, a FIFO of any depth, a FIFO of lengths and a stack of labels. The last problem writes a buffer that stores whole packets and says how long each one is.

OutputMeaningBuilt in
rdata, rvalidThe byte read and its valid bitProblems 1, 2 and 6
full, emptyThe fill level of a FIFO or a stackProblems 3 to 6
pkts, lenPackets stored, and the length of the oldestProblems 4 and 6

The Problems

Work through the problems in order: later problems reuse what you built in earlier ones. Each starts with a short spec and a testbench you can run before you submit.

1

The packet RAMFix

A RAM passes its bench test with a slow reader. Make it work with one that asks for a byte at every clock.

Practise: When synchronous read data is valid
Builds on: Verilog Single Port RAM, Synchronous FIFO

Open in ChipVerify Lab →
2

A clean startConstrain

Old packets must not be readable after a reset, and the memory array cannot be cleared. Find another way.

Practise: Resetting a memory without resetting its array
Builds on: Verilog Single Port RAM

Open in ChipVerify Lab →
3

A FIFO of any depthExtend

A FIFO works for one depth and stores less than it says. Extend it to hold exactly DEPTH bytes, for any DEPTH.

Practise: Fill levels and pointers
Builds on: Synchronous FIFO

Open in ChipVerify Lab →
4

Review a generated length FIFOReview

A generated FIFO passes the testbench that came with it. Review it for two sides that do not wait for each other.

Practise: Full, empty and the count when both sides act
Builds on: Synchronous FIFO

Open in ChipVerify Lab →
5

The label stackFix

A stack of packet labels gives wrong answers. Make it hold exactly DEPTH labels and report every overflow and underflow.

Practise: The stack pointer and its flags
Builds on: Verilog Stack or LIFO

Open in ChipVerify Lab →
6

The packet bufferWrite, final problem

Write a buffer that stores whole packets in a RAM, gives them out in order and says how long each one is.

Practise: A RAM, two FIFOs and their counts together
Builds on: Synchronous FIFO, Verilog Single Port RAM

Open in ChipVerify Lab →

How Your Solution Is Graded

Every problem has a visible testbench that you can run and edit. When you submit, a hidden grading testbench runs thousands of random clock cycles against a model of the spec, at more than one depth where there is a parameter, and the design is synthesized to check that it contains no latches.

When a check fails, the console ends with a short list of what to look into. Each item explains the mistake in terms of the hardware and names the article section that covers it.

Before You Start

The problems use the ideas from the articles in this chapter, especially synchronous reads, full and empty detection, and stack pointers. If a problem stops you, the article it builds on is the place to look.

After This Chapter

Testing a buffer like this one takes more than a few directed writes and reads. The Simulation Timing & Testbenches chapter shows how to write a testbench that finds these mistakes on its own.

Did you find what you were looking for?

Quiz

No quiz questions available for this article.