BitFlow

FIFO with Almost-Full / Almost-Empty Flags

intermediate · memory · 190 XP

Sign in to write your solution, run it in the simulator and submit it for grading.

Sign in or create a free account →

Problem

FIFO with Almost-Full / Almost-Empty Flags Extend the synchronous FIFO (MEM.06) with **two programmable early-warning threshold flags**. **New ports (all MEM.06 ports plus):** | Port | Direction | Description | |----------------|-----------|----------------------------------------------| | `almost_full` | output | Asserts when `count >= AF_THRESH` | | `almost_empty` | output | Asserts when `count <= AE_THRESH` | **Parameters:** `AF_THRESH = 6` (default), `AE_THRESH = 2` (default). These flags give producers and consumers advance warning before the FIFO reaches a critical state. A DMA controller can stop requesting data when `almost_full` asserts — giving 2 entries of margin before a hard `full` stop. `almost_full` does **not** imply `full`. `almost_empty` does **not** imply `empty`. All four flags can be independently active. Instantiate with non-default thresholds in your testbench (`AF_THRESH=7`, `AE_THRESH=1`) to verify parameterisation.

Constraints

  • Inherit all MEM.06 behaviour exactly.
  • `almost_full = (count >= AF_THRESH)`
  • `almost_empty = (count <= AE_THRESH)`
  • AF_THRESH and AE_THRESH are module parameters.
  • All four flags (full, empty, almost_full, almost_empty) are independent.

Examples

Input: count=6 with AF_THRESH=6

Output: almost_full=1, full=0

Almost-full before actual full

Input: count=2 with AE_THRESH=2

Output: almost_empty=1, empty=0

Almost-empty before actual empty

Input: count=0

Output: empty=1, almost_empty=1

Both assert at empty

Common questions

What does the FIFO with Almost-Full / Almost-Empty Flags problem ask you to build?
FIFO with Almost-Full / Almost-Empty Flags Extend the synchronous FIFO (MEM.06) with **two programmable early-warning threshold flags**.
What constraints does FIFO with Almost-Full / Almost-Empty Flags have?
Inherit all MEM.06 behaviour exactly.; `almost_full = (count >= AF_THRESH)`; `almost_empty = (count <= AE_THRESH)`; AF_THRESH and AE_THRESH are module parameters.; All four flags (full, empty, almost_full, almost_empty) are independent.
What is an example input and output for FIFO with Almost-Full / Almost-Empty Flags?
Input count=6 with AF_THRESH=6 gives output almost_full=1, full=0. Almost-full before actual full
Which Verilog concepts does FIFO with Almost-Full / Almost-Empty Flags practise?
memory, FIFO, flow-control, threshold, sequential.