How to design a DRAM
Controller to interface a DRAM
with the SHARC DSP
Introduction:
This document provides a reference design for
customers on how to interface a DRAM with the
SHARC DSP using a DRAM Controller. The
controller is implemented as a state-machine on a
Xilinx PLD. This design has been simulated, built
in hardware, and tested to operate successfully.
The design, however, has not been optimized for
best performance. Recommendations for further
modifications as well as alternative designs will be
given in Section IV.
I.Design Overview:
Different applications require specific ways of
DRAM interfacing. This design implements a
DRAM controller to interface a 4 Meg DRAM by
Micron with the SHARC.
1.SHARC:
A SHARC EZ-KIT Lite evaluation board is used in
this design. All the signals shown in this block are
available from the external connectors on this
board.
2.DRAM:
A 4Meg x 32 bit DRAM (MT8D432M-6x, 60ns access
time) manufactured by Micron is used for this
project. Data sheets showing specific timings are
available from Micron.
3.Mux, Refresh Timer, DRAM Controller:
These are three separate modules that are
programmed onto one 69 I/O pin Xilinx PLD
(XC95108-10PC84).
1
C
Mux
Shar
Refres
h
Figure 1: DRAM Interfacing Block Diagram
DRAM
2
DRAM
Controlle
3
a
DRAM is an ideal solution for mass data storage
210061910
620
2
r
43657
8
with high speed. However, DRAM requires page
swapping if an access crosses a page boundary. In
addition, DRAM requires refreshing so that data is
retained properly. This means an external
controller is needed to handle the interface between
the Sharc processor and the DRAM.
The controller receives input signals from the Sharc
on each memory access and asserts the right control
signals to the DRAM to read or write. Eleven 2:1
mux’s are used to select between column address
and row address depending on whether the
controller is doing a page swap or a normal
read/write. The refresh timer is responsible for
telling the controller when to refresh the DRAM.
II.Descriptions of the Refresh Timer and the
Controller
1.Refresh Timer:
Data sheets for this 4 Meg DRAM specify that all
2048 rows or pages need to be refreshed every
32ms. Spreading this task into equal intervals
shows that a new row needs to be refreshed every
15.625µs (32ms/2048). In this design, a refresh
request is generated by the timer every 15.525µs or
621 cycles if using a 40 Mhz clock.
The refresh timer works as follows: during reset,
the counter is forced to zero from any state. When
reset is released, the counter will start counting up
to 620. At this point, the counter resets to zero and
starts counting again. At the same time, a refresh
request (RFQ) is asserted, signaling the controller
to refresh one row of the DRAM. There are
different ways of refreshing the DRAM. For this
design, CBR or CAS Before RAS method is used as
illustrated in the diagram below. First, the
controller returns CAS and RAS to high, if
necessary. Next, the controller brings CAS low, and
then RAS low in the next cycle. It is important that
RAS and CAS should remain high or low long
enough to meet the time specifications in the data
sheets. At the end of the refresh cycles, the
controller asserts RFC (refresh complete) to signal
the refresh timer to bring RFQ low.
Using the CBR refresh method, the user does not
have to worry about which row to refresh. The
DRAM itself has an internal counter that keeps
track of which row to refresh. Each time a CBR is
performed, this internal counter will increment by
one so that the next adjacent page is refreshed on
the next CBR.
By refreshing one row every 15.5µs, the entire 4
Meg DRAM will effectively be refreshed within
every 32ms.
Clkin
Counte
/Reset
RFQ
/RAS
/CAS
RFC
Figure 2: Dram Refreshing for One Row or Page
CBR or
CAS Before RAS
EE-44Page 2
Notes on using Analog Devices’ DSP, audio, & video components from the Computer Products Division
Figure 3 below illustrates the operations of an outof-page read followed immediately by a within-page
write. Note that the timing diagram given here
does not reflect precisely the number of cycles used
in the Abel file. Refer to discussion about
optimization toward the end of this document.
Upon the detection of /MS and Page, the controller
will assert MuxSel to select the row address. Then
/RAS is asserted low to latch in the new row
address. Note that MuxSel is clocked at the
negative clock edge so that row address is valid by
the falling edge of /RAS. Then, if this is a read,
/WR_DRAM is kept high while /CAS is asserted low.
During the same cycle, Ack is asserted high to
indicate the completion of one memory access. Note
that /RAS is held low so that the same page is
retained. It will remain low until a page swap is
required or a DRAM refresh is serviced.
In this example, a write follows immediately. Since
it is a same-page operation, only /CAS needs to go
low. /WR_DRAM is asserted this time for a write
cycle.
b.Refresh Request during a Read/Write:
If the DRAM controller is servicing a memory
access when a refresh request occurs, the controller
will keep going to complete that memory read or
write before entering the refresh cycles. RFQ will
stay high until one row refresh has been done and
RFC is asserted. This is illustrated in Figure 4.
c.Memory Access Request during a Refresh
Service:
If the Sharc asserts /MS while the controller is
refreshing the DRAM, the controller will continue
to finish the refresh before servicing the memory
access. Without having Ack high during this time,
the Sharc will keep driving /MS, /RD or /WR, Data
and Address lines. Note that in this design, the
Sharc is configured to use Ack-only as waitstates.
Figure 5 illustrates this scenario.
Clkin
/MS
0
Page
Out-of-page READ
/RD
Within-page WRITE
/WR
MuxSel
AddrOu
Col Addr
Row
ColCol
/RAS
/CAS
/WR_
Ack
Figure 3: Page Swap, Read, Write
EE-44Page 3
Notes on using Analog Devices’ DSP, audio, & video components from the Computer Products Division
This DRAM controller is implemented as a Mealy
state machine and is programmed onto a Xilinx
PLD with 69 I/O pins. The state diagram on the
following page shows the flow of the design with
transitions from one state to another. Please refer
to the Abel source code for the output signals.
Several states in the state machine are used merely
to hold /CAS or /RAS low or high in order to meet
the time specifications. Further optimization could
be done to speed up the design as discussed in a
later section.
During the Idle/Reset cycle, the controller keeps
/RAS and /CAS high which will put the DRAM into
a low power mode. From here, the controller can
go to refresh cycles if RFQ is asserted or go to start
a memory access. Note that coming out of the idle
state, the controller needs to update the page in the
DRAM regardless of whether this is a out-of-page
access or not. The reason is that /RAS is no longer
held low during idle period.
In the state of Read/Write within Page, the
controller can remain here to wait for the next
memory access or go to refresh the DRAM if
necessary.
Page Swap
(S8..S10)
Idle/Reset
(S0)
/MS0,
Read/Write
after a Page Swap
(S11)
Refresh
(S1..S7)
/MS
(without Page)
Read/Write
within Page
(S12)
0
Extending
Cas/Ras
(S13..S15)
else
remain
EE-44Page 5
Notes on using Analog Devices’ DSP, audio, & video components from the Computer Products Division
A prototype of this design has been built with the
layout shown in Figure 7 below.
On the left is the DRAM board with 2 major
components:
1. DRAM: This is placed along the long edge
close to the Sharc EZ-Kit Lite board so that
the lengths of the wires connected to the
Sharc EZ-Kit Lite board are minimized for
noise reduction purposes.
2. Xilinx PLD: This is the DRAM Controller.
The refresh timer and the mux’s are all
programmed onto this same PLD. The Abel
file attached with this document includes all
code and equations necessary to program
this PLD.
Other components include the following:
1. A JTAG connector that allows the users to
easily program the PLD using a parallel
EZJTAG download cable from Xilinx.
2. An optional socket to hold the Xtal if an
external clock is used.
3. Power connector. An external power source
that can provide at least 1.5A must be used
to satisfy the demand of the DRAM.
DRAM
External
(MT8D432M-6x)
power
On the right is the Sharc EZ-KIT Lite board with
four external connectors shown in the figures. All
the signals shown in Figure 1: DRAM Interfacing
Block Diagram are available from these connectors.
This board runs on its own power supply. However,
common ground is needed between the two boards.
At least one thick wire should be used to make this
connection between the ground plane of the DRAM
board and the ground pin of the power connector to
the Sharc EZ-KIT Lite board.
Twisted pairs of wires are used for all data lines,
address lines, and control signals with the looping
wire grounded to reduce signal interference. Same
method is used for the clock signal but with thicker
wire.
Figure 8: Twisted Pair of
Optional
Xtal Clock
EZ-ICE
Connector
Sharc EZ-Kit
Lite External
Xilinx
Connectors
JTAG
Xilinx PLD
(XC9510810PC84)
Common
Ground
Power to
Sharc EZ-
Figure 7: Components and Board Layout
EE-44Page 6
Notes on using Analog Devices’ DSP, audio, & video components from the Computer Products Division
Each VDD pin on the DRAM and the PLD has two
decoupling capacitors of .02uF and 1.0uF in
parallel. On the pin where the power supply is
brought into the board, two capacitors of .1uF and
22uF are used.
Note that on the Sharc EZ-KIT Lite board, there is
an EZ-ICE connector which allows the users to
attach an EZ-ICE and use this emulator to debug
the DRAM Controller.
IV.Possible Design Modifications and
Improvement
*** Important Notes about This Design ***
However, the DRAM Controller has only been
tested with a 40Mhz clock taken from the Sharc EZKIT Lite board. This means there are two possible
improvements for speed.
1.60 Mhz clock is used:
In this Design we use an external EPSON
Americana 60 Mhz Oscilator(SG-615PCV) in
addition to the other hardware to make the
controller function faster. In the Appendix of this
EE Note we provide
App. 1. Abel Source Code: consists of
equations to implement the refresh
timer, mux’ , and the state machine for
the controller. The Abel code has been
synthesized and fitted using the
Foundations Series Tool Suite
App. 2. Schematics: is drawn using OrCAD.
J1, J3, and J6 are the actual
connectors on the Sharc EZ-Kit Lite
board.
App. 3. Layout
App. 4. Overall Layout
It is also recommended to optimize the logic of the
state-machine for better performance, especially
those states that extend the /CAS and /RAS control
signals.
Of course, another solution to this design problem
would be changing the entire approach to a more
effective method. If the controller is run at a fast
clock speed, it is possible just to program waitstates
on the SHARC and not use the ACK signal at all. If
a refresh request occurs during a burst of write or
read cycles, the controller may assert the Suspend
Bus Tri-State (/SBTS) signal to halt the dsp, and
then service the refresh. This way the SHARC will
not occupy the address bus and data bus while the
controller is refreshing the DRAM. If there are
other external devices to the system, these devices
may make use of the bus while the dsp is halting.
/SBTS may also be used during a page swapping
cycle. The controller latches in the new row address
before asserting /SBTS. When the address lines of
the dsp become tri-stated, the controller puts back
the row address onto the bus and asserts /RAS to
update the page in the DRAM. Then, it releases
/SBTS to continue the memory access normally.
V.Conclusion
This design has been tested to work quite
successfully. However, this is not the optimal
design as far as speed is concerned. Once in a
while, it is still subjective to noise, especially when
all or most of the data lines switch to high at the
same time causing a few glitches on some control
signals. If someone tries to duplicate this process, it
is recommended that further measures be taken to
clean out such noises. For example, putting a
capacitor and a resistor (with calculated values) in
series near input pins to the Sharc might help
reduce reflection on these transmission lines.
2.66Mhz or higher clock is used:
If a faster external clock is used as originally
intended for this design, then other considerations
have to be taken into account. The immediate
benefit would be speed. However, there will be
timing issues such as making Ack meet the setup
and hold time so that the Sharc can sample
correctly. Another potential problem is that
running a 66Mhz will introduce more noise to the
system, especially for a wire-wrapping board.
EE-44Page 7
Notes on using Analog Devices’ DSP, audio, & video components from the Computer Products Division