website statistics

Using the SRL16E to make a synchronous FIFOΒΆ

Xilinx Spartan and Virtex FPGAs offer a 16-bit shift register primitive, the SRL16E. Using the SRL16E makes designs much smaller and faster, as described in the Xilinx white paper.

To make a synchronous FIFO in Verilog:

module fifo ( clk, datain, wr, dataout, rd, fullness);
  parameter WIDTH = 1;

  input clk;
  input [WIDTH-1:0] datain;
  input wr;
  output [WIDTH-1:0] dataout;
  input rd;
  output reg [4:0] fullness;

  always @(posedge clk)
    fullness <= (fullness + wr - rd);
  wire [3:0] readaddr = (fullness - 1);

  genvar i;

    for (i = 0; i < WIDTH; i=i+1) begin : srl16
      SRL16E fifo16(


This fifo is variable width, and 16 entries deep. To make a 32-bit wide fifo:

wire fwr;       // fifo write
wire fdr;       // fifo read
wire [31:0] fifo_in;
wire [31:0] fifo_out;
wire [4:0] fifo_fullness;

fifo #(32) myfifo(.clk(sys_clk),
  .wr(fwr), .datain(fifo_in),
  .rd(frd), .dataout(fifo_out),

More VHDL, Verilog and FPGA notes.