| 1 |
2 |
dgisselq |
\documentclass{gqtekspec}
|
| 2 |
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
| 3 |
|
|
%%
|
| 4 |
|
|
%% Filename: spec.tex
|
| 5 |
|
|
%%
|
| 6 |
|
|
%% Project: A wishbone controlled DDR3 SDRAM memory controller.
|
| 7 |
|
|
%%
|
| 8 |
|
|
%% Purpose: This LaTeX file contains all of the documentation, or should I
|
| 9 |
|
|
%% say all of the description necessary to produce the
|
| 10 |
|
|
%% documentation, currently provided with the Wishbone controlled DDR3
|
| 11 |
|
|
%% SDRAM core. For those interested in this core, this file is not nearly
|
| 12 |
|
|
%% as interesting as the PDF file this file is used to create. Therefore,
|
| 13 |
|
|
%% I recommend building and then reading that pdf file, spec.pdf, before
|
| 14 |
|
|
%% diving into what's going on within this file. You should be able to
|
| 15 |
|
|
%% find the pdf file in this SVN distribution, together with this LaTeX
|
| 16 |
|
|
%% file and a copy of the GPL-3.0 license this file is distributed under.
|
| 17 |
|
|
%% If not, just type 'make' in the doc directory and it (should) build the
|
| 18 |
|
|
%% pdf file without a problem. (This, of course, assumes you have a valid
|
| 19 |
|
|
%% and working LaTeX distribution, together with dvips and Ghostscript.)
|
| 20 |
|
|
%%
|
| 21 |
|
|
%%
|
| 22 |
|
|
%% Creator: Dan Gisselquist, Ph.D.
|
| 23 |
|
|
%% Gisselquist Technology, LLC
|
| 24 |
|
|
%%
|
| 25 |
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
| 26 |
|
|
%%
|
| 27 |
|
|
%% Copyright (C) 2015-2016, Gisselquist Technology, LLC
|
| 28 |
|
|
%%
|
| 29 |
|
|
%% This program is free software (firmware): you can redistribute it and/or
|
| 30 |
|
|
%% modify it under the terms of the GNU General Public License as published
|
| 31 |
|
|
%% by the Free Software Foundation, either version 3 of the License, or (at
|
| 32 |
|
|
%% your option) any later version.
|
| 33 |
|
|
%%
|
| 34 |
|
|
%% This program is distributed in the hope that it will be useful, but WITHOUT
|
| 35 |
|
|
%% ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
| 36 |
|
|
%% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
| 37 |
|
|
%% for more details.
|
| 38 |
|
|
%%
|
| 39 |
|
|
%% You should have received a copy of the GNU General Public License along
|
| 40 |
|
|
%% with this program. (It's in the $(ROOT)/doc directory, run make with no
|
| 41 |
|
|
%% target there if the PDF file isn't present.) If not, see
|
| 42 |
|
|
%% <http://www.gnu.org/licenses/> for a copy.
|
| 43 |
|
|
%%
|
| 44 |
|
|
%% License: GPL, v3, as defined and found on www.gnu.org,
|
| 45 |
|
|
%% http://www.gnu.org/licenses/gpl.html
|
| 46 |
|
|
%%
|
| 47 |
|
|
%%
|
| 48 |
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
| 49 |
|
|
%%
|
| 50 |
|
|
%%
|
| 51 |
|
|
\usepackage{import}
|
| 52 |
|
|
\project{WB DDR3 SDRAM Controller}
|
| 53 |
|
|
\title{Specification}
|
| 54 |
|
|
\author{Dan Gisselquist, Ph.D.}
|
| 55 |
|
|
\email{dgisselq (at) opencores.org}
|
| 56 |
|
|
\revision{Rev.~0.0}
|
| 57 |
|
|
\begin{document}
|
| 58 |
|
|
\pagestyle{gqtekspecplain}
|
| 59 |
|
|
\titlepage
|
| 60 |
|
|
\begin{license}
|
| 61 |
|
|
Copyright (C) \theyear\today, Owner
|
| 62 |
|
|
|
| 63 |
|
|
This project is free software (firmware): you can redistribute it and/or
|
| 64 |
|
|
modify it under the terms of the GNU General Public License as published
|
| 65 |
|
|
by the Free Software Foundation, either version 3 of the License, or (at
|
| 66 |
|
|
your option) any later version.
|
| 67 |
|
|
|
| 68 |
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
| 69 |
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
| 70 |
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
| 71 |
|
|
for more details.
|
| 72 |
|
|
|
| 73 |
|
|
You should have received a copy of the GNU General Public License along
|
| 74 |
|
|
with this program. If not, see \texttt{http://www.gnu.org/licenses/} for a copy.
|
| 75 |
|
|
\end{license}
|
| 76 |
|
|
\begin{revisionhistory}
|
| 77 |
13 |
dgisselq |
0.0 & 8/02/2016 & D. Gisselquist & (Pre-release) Initial Version\\\hline
|
| 78 |
2 |
dgisselq |
\end{revisionhistory}
|
| 79 |
|
|
% Revision History
|
| 80 |
|
|
% Table of Contents, named Contents
|
| 81 |
|
|
\tableofcontents
|
| 82 |
|
|
\listoffigures
|
| 83 |
|
|
\listoftables
|
| 84 |
|
|
\begin{preface}
|
| 85 |
|
|
Now, just why am I building this? Because wishbone's been so good to me?
|
| 86 |
|
|
Because I've never used AXI? Because I dislike not being able to see
|
| 87 |
|
|
what goes on within a memory controller, and have no insight into why it's
|
| 88 |
|
|
performance is as fast (or slow) as it is? Because Xilinx allows you to only
|
| 89 |
|
|
open 4 banks at a tim? Or is it because, when I went to purchase my first
|
| 90 |
|
|
high speed FPGA circuit board, the vendor offered me the opportunity to
|
| 91 |
|
|
purchase a DMA controller with it? As a micro businessman, I really can't
|
| 92 |
|
|
afford using someone else's stuff. Time is cheap, money isn't nearly so cheap.
|
| 93 |
|
|
|
| 94 |
|
|
Hence, I offer my work to you as well. I hope you find it useful. Of course,
|
| 95 |
|
|
the normal caveats are available: I am available for hire, and I would be happy
|
| 96 |
|
|
to modify this core or even the license it is distributed under, for an
|
| 97 |
|
|
appropriate incentive.
|
| 98 |
|
|
\end{preface}
|
| 99 |
|
|
|
| 100 |
|
|
\chapter{Introduction}
|
| 101 |
|
|
\pagenumbering{arabic}
|
| 102 |
|
|
\setcounter{page}{1}
|
| 103 |
|
|
|
| 104 |
|
|
%
|
| 105 |
|
|
% Introduction
|
| 106 |
|
|
%
|
| 107 |
|
|
% This section contains the introduction to the core, describing both its
|
| 108 |
|
|
% use and its features.
|
| 109 |
|
|
%
|
| 110 |
|
|
The purpose of this core is to provide a GPL Wishbone Core capable of commanding
|
| 111 |
|
|
a DDR3 memory at full speed. A particular design goal is that consecutive
|
| 112 |
|
|
reads or writes should only take one additional clock per read/write.
|
| 113 |
|
|
|
| 114 |
|
|
% What is old
|
| 115 |
|
|
Since the DDR3 memory specification is dated as of August, 2009, memory chips
|
| 116 |
|
|
have been built to this specification. However, since DDR3 SDRAM's are rather
|
| 117 |
|
|
complex, and there is a lot of work required to manage them, controllers for
|
| 118 |
|
|
DDR3 SDRAM's remain primarily in the realm of proprietary.
|
| 119 |
|
|
|
| 120 |
|
|
% What does the old lack?
|
| 121 |
|
|
Currently, there are no DDR3 controllers present on OpenCores. Sure,
|
| 122 |
|
|
there's a project named ``DDR3 SDRAM controller'', yet it has no data files
|
| 123 |
|
|
present with it. This leaves the FPGA engineers with the choice of building
|
| 124 |
|
|
a controller for a very complex interface, or using a proprietary core from
|
| 125 |
|
|
Xilinx's Memory Interface Generator, for which there is no insight into how it
|
| 126 |
|
|
works, and then retooling their bus from wishbone to AXI.
|
| 127 |
|
|
|
| 128 |
|
|
% What is new
|
| 129 |
|
|
This core is designed to meet that need: it is both open (GPL), as well as
|
| 130 |
|
|
wishbone compliant.
|
| 131 |
|
|
% What does the new have that the old lacks
|
| 132 |
|
|
Further, this core offers 32--bit granularity to an interface that would
|
| 133 |
|
|
otherwise offer only 128--bit granularity. This core also offers complete
|
| 134 |
|
|
pipelind performance.
|
| 135 |
|
|
% What performance gain can be expected?
|
| 136 |
|
|
Because of the pipeline performance, this core is very appropriate for filling
|
| 137 |
|
|
cache lines. Because the core also offers non--pipelined performance, it is
|
| 138 |
|
|
also appropriate for random access from a CPU--whether by a write--through cache
|
| 139 |
|
|
or a CPU working without a cache.
|
| 140 |
|
|
|
| 141 |
|
|
\chapter{Architecture}
|
| 142 |
|
|
|
| 143 |
|
|
% This section describes the architecture of the block. A block level diagram
|
| 144 |
|
|
% should be included describing the top level of the design.
|
| 145 |
13 |
dgisselq |
\section{Data Structures}
|
| 146 |
|
|
There are two basic data structures within the core: the bank data structures,
|
| 147 |
|
|
and the bus data structure(s). The first keeps track of the persistent state
|
| 148 |
|
|
of each bank, while the second keeps track of I/O transactions that have been
|
| 149 |
|
|
initiated but not completed.
|
| 150 |
2 |
dgisselq |
|
| 151 |
8 |
dgisselq |
\section{Strategies}
|
| 152 |
|
|
\subsection{Bank}
|
| 153 |
|
|
Currently, banks are activated (opened) when needed and only precharged
|
| 154 |
|
|
(closed) upon refresh request. Further, upon any read or write from one bank,
|
| 155 |
|
|
the next bank is activated as well, under the assumption that the next bank
|
| 156 |
|
|
will be needed soon. This is necessary to allow pipeline access with no stalls
|
| 157 |
|
|
through the memory controller.
|
| 158 |
|
|
|
| 159 |
|
|
This means that, upon any bank miss, a bank precharge followed by bank activate
|
| 160 |
|
|
command will be necessary.
|
| 161 |
|
|
|
| 162 |
|
|
\subsection{Refresh}
|
| 163 |
|
|
The current build will pause all operations for four subsequent refreshes,
|
| 164 |
|
|
at roughly every 4 refresh intervals, and then allow operations to resume.
|
| 165 |
|
|
This pause is independent of anything going on, and includes a mandatory
|
| 166 |
|
|
wait for any writes to finish, followed by a precharge command---regardless of
|
| 167 |
|
|
whether or not such is required.
|
| 168 |
|
|
|
| 169 |
|
|
This is non-optimal, and ripe for optimizing later. A better strategy might
|
| 170 |
|
|
be to do singular refreshes after any single refresh period assuming the bus
|
| 171 |
|
|
is free, to only issue a precharge if the bus is busy, and to only wait
|
| 172 |
|
|
prior to that precharge if a write is busy. This will be a later optimization.
|
| 173 |
|
|
|
| 174 |
2 |
dgisselq |
\chapter{Operation}
|
| 175 |
|
|
|
| 176 |
|
|
% This section describes the operation of the core. Specific sequences, such
|
| 177 |
|
|
% as startup sequences, as well as the modes and states of the block should be
|
| 178 |
|
|
% described.
|
| 179 |
|
|
%
|
| 180 |
|
|
|
| 181 |
|
|
When accessed from within an FPGA, this core should be simple to access:
|
| 182 |
|
|
Raise the {\tt i\_wb\_cyc} line at the beginning of every transaction.
|
| 183 |
|
|
Set {\tt i\_wb\_stb} (transaction strobe), {\tt i\_wb\_we} (Write enable,
|
| 184 |
|
|
true if writing or false otherwise), {\tt i\_wb\_addr} (address of value),
|
| 185 |
|
|
and {\tt i\_wb\_data} for every transaction. You may move to the next
|
| 186 |
|
|
transaction any time {\tt i\_wb\_stb} is true on the same clock that
|
| 187 |
|
|
{\tt o\_wb\_stall} is false. Transactions will be pipelined internally. When
|
| 188 |
|
|
{\tt o\_wb\_ack} is true, a transaction has completed. If that transaction
|
| 189 |
|
|
was a read transaction, {\tt o\_wb\_data}, will also be filled with the data
|
| 190 |
|
|
read from the memory device.
|
| 191 |
|
|
|
| 192 |
|
|
\chapter{Clocks}
|
| 193 |
|
|
|
| 194 |
|
|
% This section specifies all of the clocks. All clocks, clock domain passes
|
| 195 |
|
|
% and the clock relations should be described.
|
| 196 |
|
|
|
| 197 |
|
|
% Name | Source | Rates (MHz) | Remarks | Description
|
| 198 |
|
|
% | Max|Min|Resolution|
|
| 199 |
|
|
|
| 200 |
|
|
This design is centered around a DDR-1600 chip. In order to run this chip
|
| 201 |
|
|
at speed, it requires a 200MHz clock. Xilinx recommends a 160~MHz clock for
|
| 202 |
|
|
their design, so it should work at slower rates--I just don't know how much
|
| 203 |
|
|
slower the design will continue to work for.
|
| 204 |
|
|
|
| 205 |
|
|
If you wish to slow down the design, adjust the parameter {\tt CKREFI4} to be
|
| 206 |
|
|
the number of clocks expected in four timse 7.8~$\mu$s.
|
| 207 |
|
|
|
| 208 |
|
|
\chapter{Wishbone Datasheet}\label{chap:wishbone}
|
| 209 |
|
|
Tbl.~\ref{tbl:wishbone}
|
| 210 |
|
|
\begin{table}[htbp]
|
| 211 |
|
|
\begin{center}
|
| 212 |
|
|
\begin{wishboneds}
|
| 213 |
|
|
Revision level of wishbone & WB B4 spec \\\hline
|
| 214 |
|
|
Type of interface & Slave, Read/Write, pipeline mode supported \\\hline
|
| 215 |
|
|
Port size & 32--bit \\\hline
|
| 216 |
|
|
Port granularity & 32--bit \\\hline
|
| 217 |
|
|
Maximum Operand Size & 32--bit \\\hline
|
| 218 |
|
|
Data transfer ordering & (Irrelevant) \\\hline
|
| 219 |
|
|
Clock constraints & Designed for 200MHz, DDR1600\\\hline
|
| 220 |
|
|
Signal Names & \begin{tabular}{ll}
|
| 221 |
|
|
Signal Name & Wishbone Equivalent \\\hline
|
| 222 |
|
|
{\tt i\_wb\_clk} & {\tt CLK\_I} \\
|
| 223 |
|
|
{\tt i\_wb\_cyc} & {\tt CYC\_I} \\
|
| 224 |
|
|
{\tt i\_wb\_stb} & {\tt STB\_I} \\
|
| 225 |
|
|
{\tt i\_wb\_we} & {\tt WE\_I} \\
|
| 226 |
|
|
{\tt i\_wb\_addr} & {\tt ADR\_I} \\
|
| 227 |
|
|
{\tt i\_wb\_data} & {\tt DAT\_I} \\
|
| 228 |
|
|
{\tt o\_wb\_ack} & {\tt ACK\_O} \\
|
| 229 |
|
|
{\tt o\_wb\_stall} & {\tt STALL\_O} \\
|
| 230 |
|
|
{\tt o\_wb\_data} & {\tt DAT\_O}
|
| 231 |
|
|
\end{tabular}\\\hline
|
| 232 |
|
|
\end{wishboneds}
|
| 233 |
|
|
\caption{Wishbone Datasheet}\label{tbl:wishbone}
|
| 234 |
|
|
\end{center}\end{table}
|
| 235 |
13 |
dgisselq |
is required by the wishbone specification, and so it is included here. The big
|
| 236 |
|
|
thing to notice is that all accesses to the DDR3 SDRAM memory are via 32--bit
|
| 237 |
|
|
reads and writes to this interface. You may also wish to note that the memory
|
| 238 |
|
|
interface supports pipeline reading and writing, to speed up any transfers. As
|
| 239 |
|
|
a result, the memory interface speed should approach one transfer per clock
|
| 240 |
|
|
once the pipeline is loaded, although there will be delays loading the pipeline.
|
| 241 |
|
|
Other than refresh cycles, once the pipeline is loaded it will continue its
|
| 242 |
|
|
transfer rate at one cycle per clock for as long as it is fed at that speed.
|
| 243 |
2 |
dgisselq |
|
| 244 |
|
|
Further, the Wishbone specification this core communicates with has been
|
| 245 |
|
|
simplified in this manner: The {\tt STB\_I} signal has been constrained so that
|
| 246 |
|
|
it will only be true if {\tt CYC\_I} is also true. To interface this core
|
| 247 |
|
|
in an environment without this requirement, simply create the {\tt i\_wb\_stb}
|
| 248 |
|
|
by anding {\tt STB\_I} together with {\tt CYC\_I} before sending the strobe
|
| 249 |
|
|
logic into the core.
|
| 250 |
|
|
|
| 251 |
|
|
\chapter{I/O Ports}
|
| 252 |
|
|
% This section specifies all of the core IO ports
|
| 253 |
|
|
|
| 254 |
|
|
The wishbone ports to this core were discussed in the last chapter, and shown
|
| 255 |
|
|
in Tbl.~\ref{tbl:wishbone}. The rest of the I/O ports to this core are listed
|
| 256 |
|
|
in Tbl.~\ref{tbl:ioports}.
|
| 257 |
|
|
\begin{table}[htbp]
|
| 258 |
|
|
\begin{center}
|
| 259 |
|
|
\begin{portlist}
|
| 260 |
|
|
{\tt i\_clk\_200mhz} & 1 & Output & A 200 MHz clock input \\
|
| 261 |
|
|
{\tt o\_ddr\_reset\_n} & 1 & Output & Active low reset command to the chip\\
|
| 262 |
|
|
{\tt o\_ddr\_cke} & 1 & Output & Clock Enable \\
|
| 263 |
|
|
{\tt o\_ddr\_cs\_n} & 1 & Output & Chip select\\
|
| 264 |
|
|
{\tt o\_ddr\_ras\_n} & 1 & Output & RAS\# Command input \\
|
| 265 |
|
|
{\tt o\_ddr\_cas\_n} & 1 & Output & RAS\# Command input \\
|
| 266 |
|
|
{\tt o\_ddr\_we\_n} & 1 & Output & WE\# Command input \\
|
| 267 |
|
|
{\tt o\_ddr\_dqs} & 1 & Output & True if the FPGA should drive the DQS on this clock, false otherwise. While not a DDR output, this needs to be converted to a DDR 2'b10 (if true) before it leaves the FPGA, or high impedence if false. \\
|
| 268 |
|
|
{\tt o\_ddr\_dm} & 3 & Output & Data Mask, used to enable only those valid writes. Although a DDR output, we treat it as SDR since all transactions are 32--bits (or more).\\
|
| 269 |
|
|
{\tt o\_ddr\_odt} & 1 & Output & On--Die--Termination bit. This will be true any time the data lines are being driven\\
|
| 270 |
|
|
{\tt o\_ddr\_bus\_dir} & 1 & Output & True if the FPGA will be driving the data bus lines during this clock, false otherwise\\
|
| 271 |
|
|
{\tt o\_ddr\_ba} & 3 & Output & Bank Address, 0-7\\
|
| 272 |
|
|
{\tt o\_ddr\_addr} & 16 & Output & Command address, either row or column\\
|
| 273 |
|
|
{\tt o\_ddr\_data} & 32 & Output & The output to be sent to the chip. This will need to be bumped to DDR rates before it actually hits the chip. \\
|
| 274 |
|
|
{\tt i\_ddr\_data} & 32 & Input & The data input from the chip. This comes in at DDR rates, and needs a Xilinx primitive to bring it from 16'bits to 32'bits.\\
|
| 275 |
|
|
\end{portlist}
|
| 276 |
|
|
\caption{List of IO ports that are not Wishbone Related}\label{tbl:ioports}
|
| 277 |
|
|
\end{center}\end{table}
|
| 278 |
|
|
|
| 279 |
|
|
% Appendices
|
| 280 |
|
|
% A. May be added to outline different specifications. (??)
|
| 281 |
|
|
|
| 282 |
|
|
|
| 283 |
|
|
% Index
|
| 284 |
|
|
\end{document}
|
| 285 |
|
|
|
| 286 |
|
|
|