• Stars
    star
    251
  • Rank 160,959 (Top 4 %)
  • Language Verilog
  • Created over 9 years ago
  • Updated over 7 years ago

Reviews

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

Repository Details

Verilog SDRAM memory controller

SDRAM Memory Controller

CURRENT STATUS : stable

This is a very a simple sdram controller which works on the De0 Nano. The project also contains a simple push button interface for testing on the dev board.

Basic features

  • Operates at 100Mhz, CAS 3, 32MB, 16-bit data
  • On reset will go into INIT sequnce
  • After INIT the controller sits in IDLE waiting for REFRESH, READ or WRITE
  • REFRESH operations are spaced evenly 8192 times every 32ms
  • READ is always single read with auto precharge
  • WRITE is always single write with auto precharge

 Host Interface          SDRAM Interface

   /-----------------------------\
   |      sdram_controller       |
==> wr_addr                  addr ==>
==> wr_data             bank_addr ==>
--> wr_enable                data <=>
   |                 clock_enable -->
==> rd_addr                  cs_n -->   
--> rd_enable               ras_n -->
<== rd_data                 cas_n -->
<-- rd_ready                 we_n -->
<-- busy            data_mask_low -->      
   |               data_mask_high -->
--> rst_n                        |
--> clk                          |
   \-----------------------------/

From the above diagram most signals should be pretty much self explainatory. Here are some important points for now. It will be expanded on later.

  • wr_addr and rd_addr are equivelant to the concatenation of {bank, row, column}
  • rd_enable should be set to high once an address is presented on the addr bus and we wish to read data.
  • wr_enable should be set to high once addr and data is presented on the bus
  • busy will go high when the read or write command is acknowledged. busy will go low when the write or read operation is complete.
  • rd_ready will go high when data rd_data is available on the data bus.
  • NOTE For single reads and writes wr_enable and rd_enable should be set low once busy is observed. This will protect from the controller thinking another request is needed if left higher any longer.

Build

The recommended way to build is to use fusesoc. The build steps are then:

# Build the project with quartus
fusesoc build dram_controller
# Program the project to de0 nano
fusesoc pgm dram_controller

# Build with icarus verilog and test
fusesoc sim dram_controller --vcd
gtkwave $fusebuild/dram_controller/sim-icarus/testlog.vcd

# Run other test cases 
fusesoc sim --testbench fifo_tb dram_controller --vcd
fusesoc sim --testbench double_click_tb dram_controller --vcd

Timings

Initialization

wave init

Initialization process showing:

  • Precharge all banks
  • 2 refresh cycles
  • Mode programming

Refresh

wave refresh

Refresh process showing:

  • Precharge all banks
  • Single Refresh

Writes

wave write

Write operation showing:

  • Bank Activation & Row Address Strobe
  • Column Address Strobe with Auto Precharge set and Data on bus

Reads

wave read

Read operation showing:

  • Bank Activation & Row Address Strobe
  • Column Address Strobe with Auto Precharge set
  • Data on bus

Test Application

Test Application Figure - test application block diagram

The test application provides a simple user interface for testing the functionality of the sdram controller.

Basics:

  • The clock input should be 50Mhz (a pll multiplies it up to 100Mhz)
  • One push button is used for reset
  • A Second push button is used for read and write
    • single click for write
    • double click for read
  • A 4-bit dip switch is used for inputting addresses and data
    • Upon reset the read/write addresses are read from the dip switch
    • When writing the dip switch is data is written to the sdram
    • Address and data busses are greather than 4 bits, data is duplicated to fill the bus
  • 8 LEDs are used to display the data read from the sdram. The data but is 16-bits, high and low bytes are alternated on the LEDs about every half second.

Project Status/TODO

  • Compiles
  • Simulated Init
  • Simulated Refresh
  • Simulated Read
  • Simulated Write
  • Confirmed in De0 Nano

Project Setup

This project has been developed with altera quartus II.

License

BSD

Further Reading

I didn't look at these when designing my controller. But it might be good to take a look at for ideas.

More Repositories

1

uart

Verilog uart receiver and transmitter modules for De0 Nano
Verilog
16
star
2

kicad-spice-demo

Demo of simulating kicad schematics in spice
Eagle
11
star
3

tls-examples

TLS access example code snippets
Makefile
10
star
4

adc_interface

Verilog ADC interface for adc128s022 found in De0 Nano
Verilog
9
star
5

intelhex

Intel HEX file generator
Ruby
8
star
6

ac97

opencores ac97 controller verilog core
Verilog
7
star
7

wb_dma

Wishbone dma/bridge controller in verily
Verilog
6
star
8

or1k-toolchain-build

OpenRISC toolchain build scripts
Shell
6
star
9

mor1kx-generic

mor1kx OpenRISC generic test harness support verilator and iverilog
Verilog
5
star
10

de0_nano-multicore

OpenRISC multicore SoC for De0 Nano
Verilog
4
star
11

adc_preamp

Kicad schematic for opamp based microphone preamp circuit used with my adc_interface project
Eagle
4
star
12

de0_nano

OpenRISC SOC for the De0 Nano FPGA dev board
Verilog
3
star
13

stffrdhrn.github.io

Github blog for stafford horne
C
3
star
14

fudosan

PHP, Twiiter Bootstrap, jQuery, CouchDB based webapp for managing real-estate property and client relationships
PHP
3
star
15

or1k-utils

linux initramfs, testing, openocd, and other random utils for openrisc
Shell
3
star
16

ompic

Open Multi-Processor Interrupt Controller - for OpenRISC
Verilog
2
star
17

junk

Dumping ground for test programs and ideas, mostly used for toolchain testing
Makefile
2
star
18

hostconfig

My backup of host and dot file config
Shell
2
star
19

cgen

architecture code generation used by binutils
Scheme
2
star
20

micron-cores

FuseSOC cores for micron verilog models
Verilog
2
star
21

digi-recorder

A digital recorder for fpga in verilog, tested on de0 nano.
Verilog
2
star
22

freemodelfoundry-cores

FuseSOC cores for free model foundry verilog models
2
star
23

verilator_tb_utils

Verilator test bench utils
C++
1
star
24

flipflop

Verilog flip flop project, basically hello world for De0 Nano
Verilog
1
star
25

beeper

Verilog wave generator and pulse width modulator (PWM) for De0 Nano
Verilog
1
star
26

wiredelay

A wire delay simulation verilog core
Verilog
1
star
27

berkeley-softfloat-2

Berkeley Softfloat 2c - with updates
C
1
star
28

egg_timer

Verilog egg timer for De0 Nano
Verilog
1
star
29

dram_tester

A testsuite for my dram controller
Verilog
1
star
30

intgen

An verilog core for testing CPU interrupts
Verilog
1
star