SDRAM Controller AXI4 for Small FGPAs

SDRAM Controller AXI4 for Small FGPAs


Category: Communication Controller

Created: August 07, 2019

Updated: January 27, 2020

Language: Verilog

Other project properties

Development Status: Stable

WishBone compliant: No

WishBone version: n/a

License: GPL


SDRAM Controller (AXI4)


This IP core is that of a small, simple SDRAM controller used to interface a 32-bit AXI-4 bus to a 16-bit SDRAM chip.

Suitable for small FPGAs which do not have a hard SDRAM macro, or where using FPGA vendor IP is not desirable.

When accessing open rows, reads and writes can be pipelined to achieve full SDRAM bus utilization, however switching between reads & writes takes a few cycles.

The row management strategy is to leave active rows open until a row needs to be closed for a periodic auto refresh or until that bank needs to open another row due to a read or write request.

This IP supports supports 4 open active rows (one per bank).


  • AXI4-Slave supporting FIXED, INCR and WRAP bursts.
  • Support for 16-bit SDRAM parts


Verified under simulation against a couple of SDRAM models and on various Xilinx FPGAs (Spartan 6, Artix 7), and against the following SDRAM parts;

  • MT48LC16M16A2
  • AS4C16M16S


  • Top: sdram_axi
  • Clock: clk_i
  • Reset: rst_i - Asynchronous, active high
  • parameter SDRAM_MHZ - Clock speed (verified with 50MHz & 100MHz)
  • parameter SDRAM_ADDR_W - Total SDRAM address width (cols+rows+banks)
  • parameter SDRAM_COL_W - Number of column bits
  • parameter SDRAM_READ_LATENCY - Read data latency (try 3 for 100MHz, 2 for 50MHz)

Example Instantiation

This example works well for Xilinx FPGAs;

module top


input clk_i,
input rst_i,
output sdram_clk_o,
output sdram_cke_o,
output [1:0] sdram_dqm_o,
output sdram_cas_o,
output sdram_ras_o,
output sdram_we_o,
output sdram_cs_o,
output [1:0] sdram_ba_o,
output [12:0] sdram_addr_o,
inout [15:0] sdram_data_io


wire [ 15:0] sdram_data_in_w;
wire [ 15:0] sdram_data_out_w;
wire sdram_data_out_en_w;



// AXI port

// SDRAM Interface







genvar i;
for (i=0; i < 16; i = i + 1)