Module ring_buffer

This document contains technical documentation for the ring_buffer module. To browse the source code, please visit the repository on GitHub.

simple_ring_buffer_manager.vhd

View source code on GitHub.

component simple_ring_buffer_manager is
  generic (
    address_width : positive;
    segment_length_bytes : positive
  );
  port (
    clk : in std_ulogic;
    --# {{}}
    enable : in std_ulogic;
    --# {{}}
    buffer_start_address : in u_unsigned;
    buffer_end_address : in u_unsigned;
    buffer_written_address : out u_unsigned;
    buffer_read_address : in u_unsigned;
    --# {{}}
    segment_ready : in std_ulogic;
    segment_valid : out std_ulogic;
    segment_address : out u_unsigned;
    --# {{}}
    segment_written : in std_ulogic;
    --# {{}}
    status : out simple_ring_buffer_manager_status_t
  );
end component;

Simple implementation of ring buffer, or circular buffer, logic. It is simple in the sense that all address segments provided are of the same length, which is defined at compile-time.

The buffer_start_address, buffer_end_address and buffer_read_address must be set by the user before enabling the entity with the enable signal. Initially, the buffer_read_address should be set to the buffer_start_address. All these addresses need to be byte-aligned with the segment length.

Warning

Once the entity has been enabled, it does not support disabling, doing so would result in undefined behavior.

Once enabled, the entity will start providing segment addresses to the user on the segment interface. This is an AXI-Stream-like handshaking interface. Once a segment has been written, the segment_written signal must be pulsed by the user. The entity will then update the buffer_written_address accordingly.

Note

In order to distinguish between the full and the empty states, this entity will never have more than segment_length_bytes - 1 segments outstanding.

Warning

This entity will fail if buffer_last_address is the very last address in the address space. (e.g. 0xFFFFFFFF).

Resource utilization

This entity has netlist builds set up with automatic size checkers in module_ring_buffer.py. The following table lists the resource utilization for the entity, depending on generic configuration.

Resource utilization for simple_ring_buffer_manager netlist builds.

Generics

Total LUTs

FFs

Maximum logic level

address_width = 29

segment_length_bytes = 64

94

52

12

simple_ring_buffer_manager_pkg.vhd

View source code on GitHub.

Package with types and constants for simple_ring_buffer_manager.vhd.