• Stars
    star
    111
  • Rank 314,510 (Top 7 %)
  • Language VHDL
  • License
    MIT License
  • Created about 5 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A FPGA core for a simple SDRAM controller.

SDRAM Controller

Because synchronous dynamic RAM (SDRAM) has complex timing and signalling requirements, a memory controller is necessary to avoid having to deal with the nitty-gritty details when reading or writing to memory. Its job is to hide the complexity of things like row and column addressing, precharging, and refreshing. Instead it lets us treat SDRAM just like plain old static memory.

This SDRAM controller provides a symmetric 32-bit synchronous read/write interface for a 16Mx16-bit SDRAM chip (e.g. AS4C16M16SA-6TCN, IS42S16400F, etc.).

Even though the SDRAM chip only has a 16-bit data bus, the controller uses a 32-bit data bus because it is more efficient to burst multiple words from the SDRAM than it is to do individual reads and writes.

Documentation

Signals 🚥

name direction description
reset input resets the SDRAM controller when asserted
clk input clock
addr input address bus
data input input data bus
we input write enable
req input requests a read or write operation when asserted
ack output asserted when a request is accepted by the SDRAM controller
valid output asserted when there is valid data on the output data bus
q output output data bus

Reset

The reset signal can be used to reset the internal state machine for the SDRAM controller.

Clock

The clk signal is the system clock used by the SDRAM controller.

Ideally, it should be different to the SDRAM clock (i.e. the clock for the actual SDRAM chip). By adjusting the phase relationship so that the SDRAM clock leads the system clock, we can ensure that the SDRAM output signals arrive in time to meet our timing constraints.

Address Bus

The addr signal should be set to the address of the memory location being accessed.

Input Data Bus

The data signal should be set to the 32-bit value to be written to the memory location at the given address.

Write Enable

The we signal should be asserted when you want to write to the SDRAM. It should be asserted together with the req signal.

Request

The req signal should be asserted when you want to read or write to the SDRAM. When making a request, the req, we, addr, and data signals should not be changed until the request has been acknowledged.

Acknowledge

The ack signal is asserted by the SDRAM controller when a request has been acknowledged.

Valid

The valid signal is asserted by the SDRAM controller when there is valid data on the output data bus.

Output Data Bus

The q signal is set to the last 32-bit word read from the SDRAM. The data on the output bus is only valid while the valid signal is asserted.

Reading

The SDRAM controller allows read operations to be performed using a simple interface.

Read requests can be chained so that a new read operation can be requested before the current operation has completed. Using this strategy, we can read any number of words from the SDRAM without wasting clock cycles, thus using the maximum available bandwidth of the SDRAM.

The following example describes how to read two 32-bit words using the SDRAM controller. This method can be used to read any number of words:

  1. Write the address to the addr bus.
  2. Request a read operation by deasserting the we signal and asserting the req signal.
  3. Wait for the ack signal to be asserted. This means that the read request has been acknowledged, and a read operation has begun.
  4. Write another address to the addr bus.
  5. Wait for the valid signal to be asserted. This means that the first read request has been completed and the data is available on the data bus.
  6. Read the value on the q data bus.
  7. Wait for ack signal to be asserted. This means that the second read request has been acknowledged, and a read operation has begun.
  8. Deassert the req signal when we're done making requests.
  9. Wait for the valid signal to be asserted. This means that the second read request has been completed and the data is available on the data bus.
  10. Read the value on the q data bus.

SDRAM Controller Read

Writing

The SDRAM controller handles write operations similarly to read operations.

Write requests can also be chained, so that a new write operation can be requested before the current operation has completed.

The following example describes how to write two 32-bit words using the SDRAM controller. This method can be used to write any number of words:

  1. Write an address to the addr bus and a value to the data bus.
  2. Request a write operation by asserting the we and req signals.
  3. Wait for the ack signal to be asserted. This means that the write request has been acknowledged, and a write operation has begun.
  4. Write another address to the addr bus and a value to the data bus.
  5. Wait for ack signal to be asserted. This means that the second write request has been acknowledged, and a write operation has begun.
  6. Deassert the we and req signals when we're done making requests.

SDRAM Controller Write

State Diagram

State Diagram

Licence

This project is licensed under the MIT licence. See the LICENCE file for more details.

More Repositories

1

rein

Database constraints made easy for ActiveRecord.
Ruby
670
star
2

fkit

A functional programming toolkit for JavaScript.
JavaScript
585
star
3

tetris

A clone of the popular game Tetris.
JavaScript
101
star
4

risk

A game of Risk played on a hexgrid.
JavaScript
97
star
5

bulb

A reactive programming library for JavaScript.
JavaScript
83
star
6

bokeh

Bokeh is a simple, scalable and blazing-fast task queue built on Node.js and ZeroMQ.
JavaScript
77
star
7

openfpga-tecmo

Scala
45
star
8

mache

A library for writing cleaner and more expressive acceptance tests using page objects.
Ruby
40
star
9

jsdoc-react

A JSDoc template built with React.
JavaScript
27
star
10

rygar-emu

An emulator for the Rygar arcade game
C
21
star
11

rygar-fpga

A FPGA core for the arcade game, Rygar (1986).
VHDL
17
star
12

de10-nano-examples

DE10 Nano Sample Cores
VHDL
14
star
13

purescript-digraph

A directed graph library for PureScript.
PureScript
11
star
14

z80-chisel

A Z80 CPU implemented in Chisel.
Scala
10
star
15

de0-nano-examples

Some example circuits written in VHDL for Terasic DE0-Nano FPGA board.
VHDL
8
star
16

de10-nano-z80

A simple Z80 CPU example written in VHDL for the D10 Nano
VHDL
7
star
17

crc-chisel

Hardware CRC implementation in Chisel
Scala
5
star
18

de10-nano-sprite

A simple sprite example written in VHDL for DE10 Nano
VHDL
4
star
19

de10-nano-tilemap

A simple tilemap example written in VHDL for DE10 Nano
VHDL
4
star
20

rgb_matrix

Firmware for the SparkFun RGB LED Matrix.
3
star
21

alpha

Objective-C
3
star
22

sdram-chisel

Scala
3
star
23

de10-nano-video

A simple video example written in VHDL for the DE10 Nano
VHDL
3
star
24

de0-nano-matrix

A LED matrix controller written in VHDL for the DE0-Nano FPGA development board.
VHDL
3
star
25

Flatland

Objective-C
2
star
26

de10-nano-counter

A simple counter example written in VHDL for the DE10 Nano
VHDL
2
star
27

de0-nano-sdram

VHDL
2
star
28

arcadia

MiSTer FPGA core framework for Chisel
Scala
2
star
29

led-matrix

A LED matrix controller implemented in VHDL
VHDL
2
star
30

de0-nano-char

A tilemap example written in VHDL for the DE0 Nano
VHDL
2
star
31

papilio-neopixel

VHDL
2
star
32

noise

Experiments with the webkit audio API.
CoffeeScript
2
star
33

de0-nano-counter

A simple counter example written in VHDL for the DE0 Nano
VHDL
1
star
34

cave-tilemap-chisel

Scala
1
star
35

de0-nano-video

A simple video example written in VHDL for the DE0 Nano
VHDL
1
star
36

papilio-flasher

A simple circuit design to flash the LED on the Papilio Pro board.
VHDL
1
star
37

nyan-jack

JavaScript
1
star
38

spartan-3e-counter

VHDL
1
star
39

buccaneer

A BusPirate library for Ruby.
Ruby
1
star
40

purescript-examples

PureScript
1
star
41

papilio-picoblaze

VHDL
1
star
42

memory

A game of memory.
JavaScript
1
star
43

z80-test

Makefile
1
star
44

arduino

My arduino sketches
C++
1
star
45

fallout

Ruby
1
star