GithubHelp home page GithubHelp logo

wxbbuaa2011 / sdram-fpga Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nullobject/sdram-fpga

0.0 1.0 0.0 122 KB

A FPGA core for a simple SDRAM controller.

Home Page: https://www.joshbassett.info/sdram-controller/

License: MIT License

VHDL 100.00%

sdram-fpga's Introduction

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.

sdram-fpga's People

Contributors

nullobject avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.