1 |
3 |
dgisselq |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2 |
|
|
%%
|
3 |
|
|
%% Filename: spec.tex
|
4 |
|
|
%%
|
5 |
|
|
%% Project: Wishbone Controlled Quad SPI Flash Controller
|
6 |
|
|
%%
|
7 |
|
|
%% Purpose: This LaTeX file contains all of the documentation/description
|
8 |
|
|
%% currently provided with this Quad SPI Flash Controller.
|
9 |
|
|
%% It's not nearly as interesting as the PDF file it creates,
|
10 |
|
|
%% so I'd recommend reading that before diving into this file.
|
11 |
|
|
%% You should be able to find the PDF file in the SVN distribution
|
12 |
|
|
%% together with this PDF file and a copy of the GPL-3.0 license
|
13 |
|
|
%% this file is distributed under.
|
14 |
|
|
%%
|
15 |
|
|
%%
|
16 |
|
|
%% Creator: Dan Gisselquist
|
17 |
5 |
dgisselq |
%% Gisselquist Technology, LLC
|
18 |
3 |
dgisselq |
%%
|
19 |
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
20 |
|
|
%%
|
21 |
|
|
%% Copyright (C) 2015, Gisselquist Technology, LLC
|
22 |
|
|
%%
|
23 |
|
|
%% This program is free software (firmware): you can redistribute it and/or
|
24 |
|
|
%% modify it under the terms of the GNU General Public License as published
|
25 |
|
|
%% by the Free Software Foundation, either version 3 of the License, or (at
|
26 |
|
|
%% your option) any later version.
|
27 |
|
|
%%
|
28 |
|
|
%% This program is distributed in the hope that it will be useful, but WITHOUT
|
29 |
|
|
%% ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
30 |
|
|
%% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
31 |
|
|
%% for more details.
|
32 |
|
|
%%
|
33 |
|
|
%% You should have received a copy of the GNU General Public License along
|
34 |
|
|
%% with this program. (It's in the $(ROOT)/doc directory, run make with no
|
35 |
|
|
%% target there if the PDF file isn't present.) If not, see
|
36 |
|
|
%% <http://www.gnu.org/licenses/> for a copy.
|
37 |
|
|
%%
|
38 |
|
|
%% License: GPL, v3, as defined and found on www.gnu.org,
|
39 |
|
|
%% http://www.gnu.org/licenses/gpl.html
|
40 |
|
|
%%
|
41 |
|
|
%%
|
42 |
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
43 |
2 |
dgisselq |
\documentclass{gqtekspec}
|
44 |
|
|
\project{Quad SPI Flash Controller}
|
45 |
|
|
\title{Specification}
|
46 |
|
|
\author{Dan Gisselquist, Ph.D.}
|
47 |
6 |
dgisselq |
\email{dgisselq (at) opencores.org}
|
48 |
14 |
dgisselq |
\revision{Rev.~0.3}
|
49 |
2 |
dgisselq |
\begin{document}
|
50 |
|
|
\pagestyle{gqtekspecplain}
|
51 |
|
|
\titlepage
|
52 |
|
|
\begin{license}
|
53 |
|
|
Copyright (C) \theyear\today, Gisselquist Technology, LLC
|
54 |
|
|
|
55 |
|
|
This project is free software (firmware): you can redistribute it and/or
|
56 |
|
|
modify it under the terms of the GNU General Public License as published
|
57 |
|
|
by the Free Software Foundation, either version 3 of the License, or (at
|
58 |
|
|
your option) any later version.
|
59 |
|
|
|
60 |
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
61 |
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
62 |
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
63 |
|
|
for more details.
|
64 |
|
|
|
65 |
|
|
You should have received a copy of the GNU General Public License along
|
66 |
9 |
dgisselq |
with this program. If not, see \texttt{http://www.gnu.org/licenses/} for a
|
67 |
3 |
dgisselq |
copy.
|
68 |
2 |
dgisselq |
\end{license}
|
69 |
|
|
\begin{revisionhistory}
|
70 |
14 |
dgisselq |
0.3 & 8/11/2016 & Gisselquist & Added information on the Extended Quad SPI controller\\\hline
|
71 |
5 |
dgisselq |
0.2 & 5/26/2015 & Gisselquist & Minor spelling changes\\\hline
|
72 |
2 |
dgisselq |
0.1 & 5/13/2015 & Gisselquist & First Draft \\\hline
|
73 |
|
|
\end{revisionhistory}
|
74 |
|
|
% Revision History
|
75 |
|
|
% Table of Contents, named Contents
|
76 |
|
|
\tableofcontents
|
77 |
|
|
\listoffigures
|
78 |
|
|
\listoftables
|
79 |
|
|
\begin{preface}
|
80 |
|
|
The genesis of this project was a desire to communicate with and program an
|
81 |
|
|
FPGA board without the need for any proprietary tools. This includes Xilinx
|
82 |
|
|
JTAG cables, or other proprietary loading capabilities such as Digilent's
|
83 |
|
|
Adept program. As a result, all interactions with the board need to take
|
84 |
|
|
place using open source tools, and the board must be able to reprogram itself.
|
85 |
14 |
dgisselq |
|
86 |
|
|
That was the beginning of the QSPI flash controller.
|
87 |
|
|
|
88 |
|
|
The EQSPI flash controller started from a similar need for a board that had
|
89 |
|
|
an EQSPI flash. That particular board was an Arty, and so the EQSPI flash
|
90 |
|
|
controller has been designed around the Arty platform.
|
91 |
2 |
dgisselq |
\end{preface}
|
92 |
|
|
|
93 |
|
|
\chapter{Introduction}
|
94 |
|
|
\pagenumbering{arabic}
|
95 |
|
|
\setcounter{page}{1}
|
96 |
|
|
|
97 |
14 |
dgisselq |
This document discusses the design and usage of two cores: a Quad SPI flash
|
98 |
|
|
controller, and a newer Extended Quad SPI flash controller. In general, the
|
99 |
|
|
two are {\em very} similar. However, their construction and register usage
|
100 |
|
|
are subtly different, so the user will need to pay attention to these
|
101 |
|
|
differences.
|
102 |
|
|
|
103 |
|
|
Both Flash controllers handle all of the necessary queries and accesses to
|
104 |
2 |
dgisselq |
and from a SPI Flash device that has been augmented with an additional
|
105 |
|
|
two data lines and enabled with a mode allowing all four data lines to
|
106 |
|
|
work together in the same direction at the same time. Since the interface
|
107 |
|
|
was derived from a SPI interface, most of the interaction takes place using
|
108 |
|
|
normal SPI protocols and only some commands work at the higher four bits
|
109 |
14 |
dgisselq |
at a time speed. This remains true, even though the newer Extended SPI flash
|
110 |
|
|
controller allows control accesses and Dual I/O and Quad I/O speeds: control
|
111 |
|
|
interactions remain at SPI speeds, and only data reads and writes take place
|
112 |
|
|
at the Quad I/O speed.
|
113 |
2 |
dgisselq |
|
114 |
14 |
dgisselq |
Both controllers attempt to mask the underlying operation of the
|
115 |
|
|
Flash device behind a wishbone interface, to make it so that reads and writes
|
116 |
2 |
dgisselq |
are as simple as using the wishbone interface. However, the difference
|
117 |
|
|
between erasing (turning bits from '0' to '1') and programming (turning bits
|
118 |
|
|
from '1' to '0') breaks this model somewhat. Therefore, reads from the
|
119 |
14 |
dgisselq |
device act like normal wishbone reads, writes program the device (if the write
|
120 |
|
|
protect is properly removed) and sort of work with the wishbone, while erase
|
121 |
|
|
commands require another register to control. Please read the Operations
|
122 |
|
|
chapter for a detailed description of how to perform these relevant operations.
|
123 |
2 |
dgisselq |
|
124 |
14 |
dgisselq |
This QSPI controller implements the interface for the Quad SPI flash found on
|
125 |
|
|
the Basys-3 board built by Digilent, Inc, as well as their CMod-S6 board. A
|
126 |
|
|
similar controller has been modified for the flash on the XuLA2-LX25 SoC.
|
127 |
|
|
It is possible that some portions of the interface may be specific to the
|
128 |
|
|
Spansion S25FL032P chip used on the Basys-3 board, and the
|
129 |
2 |
dgisselq |
100~MHz system clock found on the board, although there is no reason the
|
130 |
|
|
controller needs to be limited to this architecture. It just happens to be
|
131 |
14 |
dgisselq |
the one the QSPI controller was designed to and for.
|
132 |
2 |
dgisselq |
|
133 |
14 |
dgisselq |
The Extended QSPI controller, or EQSPI controller, was designed to control the
|
134 |
|
|
Micron Serial NOR Flash Memory, N25Q128A, found on Digilent's Arty board. As
|
135 |
|
|
with the Spansion chip, it is possible that parts of the interface are specific
|
136 |
|
|
to this board and this chip.
|
137 |
|
|
|
138 |
|
|
For a description of how the internal of each core work, feel free to browse
|
139 |
2 |
dgisselq |
through the Architecture chapter.
|
140 |
|
|
|
141 |
14 |
dgisselq |
The registers that control the cores are discussed in the Registers chapter.
|
142 |
2 |
dgisselq |
|
143 |
|
|
As required, you can find a wishbone datasheet in Chapt.~\ref{chap:wishbone}.
|
144 |
|
|
|
145 |
14 |
dgisselq |
The final pertinent information for implementing the cores is found in the
|
146 |
2 |
dgisselq |
I/O Ports chapter, Chapt.~\ref{chap:ioports}.
|
147 |
|
|
|
148 |
|
|
As always, write me if you have any questions or problems.
|
149 |
|
|
|
150 |
|
|
\chapter{Architecture}\label{chap:arch}
|
151 |
|
|
|
152 |
14 |
dgisselq |
The internal architecture of each of these two cores is different, reflecting
|
153 |
|
|
their different chips and goals. The QSPI controller is designed to run using
|
154 |
|
|
a 50~MHz SPI clock, generated from a 100~MHz controller clock. The EQSPI
|
155 |
|
|
controller, however, was designed to prove that a 100~MHz SPI clock could be
|
156 |
|
|
used to drive a flash controller from a 200~MHz controller clock. As a result
|
157 |
|
|
of these clocking differences, the architectures of each are quite different.
|
158 |
|
|
|
159 |
|
|
\section{QSPI Flash Architecture}
|
160 |
2 |
dgisselq |
As built, the core consists of only two components: the wishbone quad SPI
|
161 |
|
|
flash controller, {\tt wbqspiflash}, and the lower level quad SPI driver,
|
162 |
|
|
{\tt llqspi}. The controller issues high level read/write commands to the
|
163 |
|
|
lower level driver, which actually implements the Quad SPI protocol.
|
164 |
|
|
|
165 |
14 |
dgisselq |
Pictorally, this looks something like Fig.~\ref{fig:qspi-arch}.
|
166 |
2 |
dgisselq |
\begin{figure}\begin{center}\begin{pspicture}(-2in,0)(2in,3.5in)
|
167 |
|
|
\rput(0,2.5in){
|
168 |
|
|
\rput(-0.9in,0){\psline{->}(0,1in)(0,0in)}
|
169 |
|
|
\rput[b]{90}(-0.92in,0.5in){\tt i\_wb\_cyc}
|
170 |
|
|
\rput(-0.7in,0){\psline{->}(0,1in)(0,0in)}
|
171 |
|
|
\rput[b]{90}(-0.72in,0.5in){\tt i\_wb\_data\_stb}
|
172 |
|
|
\rput(-0.5in,0){\psline{->}(0,1in)(0,0in)}
|
173 |
|
|
\rput[b]{90}(-0.52in,0.5in){\tt i\_wb\_ctrl\_stb}
|
174 |
|
|
\rput(-0.3in,0){\psline{->}(0,1in)(0,0in)}
|
175 |
|
|
\rput[b]{90}(-0.32in,0.5in){\tt i\_wb\_we}
|
176 |
|
|
\rput(-0.1in,0){\psline{->}(0,1in)(0,0in)}
|
177 |
|
|
\rput[b]{90}(-0.12in,0.5in){\tt i\_wb\_addr}
|
178 |
|
|
\rput( 0.1in,0){\psline{->}(0,1in)(0,0in)}
|
179 |
|
|
\rput[b]{90}( 0.08in,0.5in){\tt i\_wb\_data}
|
180 |
|
|
%
|
181 |
|
|
\rput( 0.5in,0){\psline{<-}(0,1in)(0,0in)}
|
182 |
|
|
\rput[b]{90}( 0.48in,0.5in){\tt o\_wb\_ack}
|
183 |
|
|
\rput( 0.7in,0){\psline{<-}(0,1in)(0,0in)}
|
184 |
|
|
\rput[b]{90}( 0.68in,0.5in){\tt o\_wb\_stall}
|
185 |
|
|
\rput( 0.9in,0){\psline{<-}(0,1in)(0,0in)}
|
186 |
|
|
\rput[b]{90}( 0.88in,0.5in){\tt o\_wb\_data}}
|
187 |
|
|
\rput(0,2.0in){%
|
188 |
|
|
\rput(0,0){\psframe(-1.2in,0)(1.2in,0.5in)}
|
189 |
|
|
\rput(0,0.25in){\tt wbqspiflash}}
|
190 |
|
|
\rput(0,1.0in){
|
191 |
|
|
\rput(-0.9in,0){\psline{->}(0,1in)(0,0in)}
|
192 |
|
|
\rput[b]{90}(-0.92in,0.5in){\tt spi\_wr}
|
193 |
|
|
\rput(-0.7in,0){\psline{->}(0,1in)(0,0in)}
|
194 |
|
|
\rput[b]{90}(-0.72in,0.5in){\tt spi\_hold}
|
195 |
|
|
\rput(-0.5in,0){\psline{->}(0,1in)(0,0in)}
|
196 |
|
|
\rput[b]{90}(-0.52in,0.5in){\tt spi\_in}
|
197 |
|
|
\rput(-0.3in,0){\psline{->}(0,1in)(0,0in)}
|
198 |
|
|
\rput[b]{90}(-0.32in,0.5in){\tt spi\_len}
|
199 |
|
|
\rput(-0.1in,0){\psline{->}(0,1in)(0,0in)}
|
200 |
|
|
\rput[b]{90}(-0.12in,0.5in){\tt spi\_spd}
|
201 |
|
|
\rput( 0.1in,0){\psline{->}(0,1in)(0,0in)}
|
202 |
|
|
\rput[b]{90}( 0.08in,0.5in){\tt spi\_dir}
|
203 |
|
|
% \rput(-0.9in,0){\psline{->}(0,1in)(0,0in)}
|
204 |
|
|
% \rput[b]{90}(-0.92in,0.5in){\tt i\_wb\_cyc}
|
205 |
|
|
\rput( 0.5in,0){\psline{->}(0,1in)(0,0in)}
|
206 |
|
|
\rput[b]{90}( 0.48in,0.5in){\tt spi\_out}
|
207 |
|
|
\rput( 0.7in,0){\psline{->}(0,1in)(0,0in)}
|
208 |
|
|
\rput[b]{90}( 0.68in,0.5in){\tt spi\_valid}
|
209 |
|
|
\rput( 0.9in,0){\psline{->}(0,1in)(0,0in)}
|
210 |
|
|
\rput[b]{90}( 0.88in,0.5in){\tt spi\_busy}}
|
211 |
|
|
\rput(0,0.5in){
|
212 |
|
|
\rput(0,0){\psframe(-1.25in,0)(1.25in,0.5in)}
|
213 |
|
|
\rput(0,0.25in){\tt llqspi}}
|
214 |
|
|
\rput(0,0){\psline{<->}(-0.3in,0.5in)(-0.3in,0)
|
215 |
|
|
\psline{<->}(-0.1in,0.5in)(-0.1in,0)
|
216 |
|
|
\psline{<->}(0.1in,0.5in)(0.1in,0)
|
217 |
|
|
\psline{<->}(0.3in,0.5in)(0.3in,0)}
|
218 |
|
|
\rput[l](0.4in,0.25in){Quad SPI I/O lines}
|
219 |
|
|
\end{pspicture}\end{center}
|
220 |
14 |
dgisselq |
\caption{QSPI Architecture Diagram}\label{fig:qspi-arch}
|
221 |
2 |
dgisselq |
\end{figure}
|
222 |
|
|
This is also what you will find if you browse through the code.
|
223 |
|
|
|
224 |
|
|
While it isn't relevant for operating the device, a quick description of these
|
225 |
|
|
internal wires may be educational. The lower level device is commanded by
|
226 |
|
|
asserting a {\tt spi\_wr} signal when the device is not busy (i.e. {\tt
|
227 |
|
|
spi\_busy} is low). The actual command given depends upon the other
|
228 |
|
|
signals. {\tt spi\_len} is a two bit value indicating whether this is an
|
229 |
|
|
8 bit (2'b00), 16 bit (2'b01), 24 bit (2'b10), or 32 bit (2'b11) transaction.
|
230 |
|
|
The data to be sent out the port is placed into {\tt spi\_in}.
|
231 |
|
|
|
232 |
|
|
Further, to support Quad I/O, {\tt spi\_spd} can be set to one to use all four
|
233 |
|
|
bits. In this case, {\tt spi\_dir} must also be set to either 1'b0 for
|
234 |
|
|
writing, or 1'b1 to read from the four bits.
|
235 |
|
|
|
236 |
|
|
When data is valid from the lower level driver, the {\tt spi\_valid} line
|
237 |
|
|
will go high and {\tt spi\_out} will contain the data with the most recently
|
238 |
|
|
read bits in the lower bits. Further, when the device is idle, {\tt spi\_busy}
|
239 |
|
|
will go low, where it may then read another command.
|
240 |
|
|
|
241 |
|
|
Sadly, this simple interface as originally designed doesn't work on a
|
242 |
|
|
device where transactions can be longer than 32~bits. To support these
|
243 |
|
|
longer transactions, the lower level driver checks the {\tt spi\_wr} line
|
244 |
|
|
before it finishes any transaction. If the line is high, the lower level
|
245 |
|
|
driver will deassert {\tt spi\_busy} for one cycle while reading the command
|
246 |
|
|
from the controller on the previous cycle. Further, the controller can also
|
247 |
|
|
assert the {\tt spi\_hold} line which will stop the clock to the device
|
248 |
|
|
and force everything to wait for further instructions.
|
249 |
|
|
|
250 |
|
|
This hold line interface was necessary to deal with a slow wishbone bus that
|
251 |
|
|
was writing to the device, but that didn't have it's next data line ready.
|
252 |
|
|
Thus, by holding the {\tt i\_wb\_cyc} line high, a write could take many
|
253 |
|
|
clocks and the flash would simply wait for it. (I was commanding the device
|
254 |
|
|
via a serial port, so writes could take {\em many} clock cycles for each
|
255 |
|
|
word to come through, i.e. 1,500 clocks or so per word and that's at high
|
256 |
|
|
speed.)
|
257 |
|
|
|
258 |
|
|
The upper level component, the controller {\tt wbqspiflash}, is little more
|
259 |
|
|
than a glorified state machine that interacts with the wishbone bus.
|
260 |
|
|
From it's idle state, it can handle any command, whether data or control,
|
261 |
|
|
and issue appropriate commands to the lower level driver. From any other
|
262 |
|
|
state, it will stall the bus until it comes back to idle--with a few exceptions.
|
263 |
|
|
Subsequent data reads, while reading data, will keep the device reading.
|
264 |
|
|
Subsequent data writes, while in program mode, will keep filling the devices
|
265 |
|
|
buffer before starting the write. In other respects, the device will just
|
266 |
|
|
stall the bus until it comes back to idle.
|
267 |
|
|
|
268 |
|
|
While they aren't used in this design, the wishbone error and retry signals
|
269 |
|
|
would've made a lot of sense here. Specifically, it should be an error to
|
270 |
|
|
read from the device while it is in the middle of an erase or program command.
|
271 |
|
|
Instead, this core stalls the bus--trying to do good for everyone. Perhaps
|
272 |
|
|
a later, updated, implementation will make better use of these signals instead
|
273 |
|
|
of stalling. For now, this core just stalls the bus.
|
274 |
|
|
|
275 |
|
|
Perhaps the best takeaway from this architecture section is that the varying
|
276 |
|
|
pieces of complexity have each been separated from each other. There's a
|
277 |
|
|
lower level driver that handles actually toggling the lines to the port,
|
278 |
|
|
while the higher level driver maintains the state machine controlling which
|
279 |
|
|
commands need to be issued and when.
|
280 |
|
|
|
281 |
14 |
dgisselq |
\section{EQSPI Flash Architecture}
|
282 |
|
|
The EQSPI flash architecture was an entire redesign. The reason for the
|
283 |
|
|
redesign is quite simple: the QSPI flash controller was just way to complex
|
284 |
|
|
to run at a 200~MHz clock. This new and modified architecture is shown in
|
285 |
|
|
Fig.~\ref{fig:eqspi-arch}.
|
286 |
|
|
\begin{figure}\begin{center}\begin{pspicture}(-2in,-1.2in)(2.75in,5.5in)
|
287 |
|
|
% \rput(0,0){\psframe(-2in,-1.2in)(2.75in,5.5in)}
|
288 |
|
|
\rput(0,4.5in){%
|
289 |
|
|
\rput(-0.9in,0){\psline{->}(0,1in)(0,0in)}
|
290 |
|
|
\rput[b]{90}(-0.92in,0.5in){\tt i\_wb\_cyc}
|
291 |
|
|
\rput(-0.7in,0){\psline{->}(0,1in)(0,0in)}
|
292 |
|
|
\rput[b]{90}(-0.72in,0.5in){\tt i\_wb\_data\_stb}
|
293 |
|
|
\rput(-0.5in,0){\psline{->}(0,1in)(0,0in)}
|
294 |
|
|
\rput[b]{90}(-0.52in,0.5in){\tt i\_wb\_ctrl\_stb}
|
295 |
|
|
\rput(-0.3in,0){\psline{->}(0,1in)(0,0in)}
|
296 |
|
|
\rput[b]{90}(-0.32in,0.5in){\tt i\_wb\_we}
|
297 |
|
|
\rput(-0.1in,0){\psline{->}(0,1in)(0,0in)}
|
298 |
|
|
\rput[b]{90}(-0.12in,0.5in){\tt i\_wb\_addr}
|
299 |
|
|
\rput( 0.1in,0){\psline{->}(0,1in)(0,0in)}
|
300 |
|
|
\rput[b]{90}( 0.08in,0.5in){\tt i\_wb\_data}
|
301 |
|
|
%
|
302 |
|
|
\rput( 0.5in,0){\psline{<-}(0,1in)(0,0in)}
|
303 |
|
|
\rput[b]{90}( 0.48in,0.5in){\tt o\_wb\_ack}
|
304 |
|
|
\rput( 0.7in,0){\psline{<-}(0,1in)(0,0in)}
|
305 |
|
|
\rput[b]{90}( 0.68in,0.5in){\tt o\_wb\_stall}
|
306 |
|
|
\rput( 0.9in,0){\psline{<-}(0,1in)(0,0in)}
|
307 |
|
|
\rput[b]{90}( 0.88in,0.5in){\tt o\_wb\_data}
|
308 |
|
|
\rput( 1.1in,0){\psline{<-}(0,1in)(0,0in)}
|
309 |
|
|
\rput[b]{90}( 1.08in,0.5in){\tt o\_int}}
|
310 |
|
|
\rput(0,4.0in){%
|
311 |
|
|
\rput(0,0){\psframe(-1.2in,0)(1.2in,0.5in)}
|
312 |
|
|
\rput(0,0.25in){\tt qspibus}}
|
313 |
|
|
% Wires
|
314 |
|
|
\rput(0,3.0in){%
|
315 |
|
|
\rput(0,0){\psframe(-2in,0)(-1.05in,0.5in)}
|
316 |
|
|
\rput(-1.5in,0.25in){\tt readqspi}}
|
317 |
|
|
\rput(0,3.0in){%
|
318 |
|
|
\rput(0,0){\psframe(-0.95in,0)(-0.05in,0.5in)}
|
319 |
|
|
\rput(-0.5in,0.25in){\tt writeqspi}}
|
320 |
|
|
\rput(0,3.0in){%
|
321 |
|
|
\rput(0,0){\psframe(0.05in,0)(0.95in,0.5in)}
|
322 |
|
|
\rput(0.5in,0.25in){\tt ctrlspi}}
|
323 |
|
|
\rput(0,3.0in){%
|
324 |
|
|
\rput(0,0){\psframe(1.05in,0)(2in,0.5in)}
|
325 |
|
|
\rput(1.5in,0.25in){\tt idotpqspi}}
|
326 |
|
|
\rput(0,2.0in){%
|
327 |
|
|
\rput(0,0){\pspolygon(-1in,0)(1in,0)(1.5in,0.5in)(-1.5in,0.5in)}
|
328 |
|
|
\rput(0,0.25in){Command Mux}}
|
329 |
|
|
\rput(0,1.0in){
|
330 |
|
|
\rput(-1.0in,0){\psline{->}(0,1in)(0,0in)}
|
331 |
|
|
\rput[b]{90}(-1.02in,0.5in){\tt spi\_wr}
|
332 |
|
|
\rput(-0.8in,0){\psline{->}(0,1in)(0,0in)}
|
333 |
|
|
\rput[b]{90}(-0.82in,0.5in){\tt spi\_hold}
|
334 |
|
|
\rput(-0.6in,0){\psline{->}(0,1in)(0,0in)}
|
335 |
|
|
\rput[b]{90}(-0.62in,0.5in){\tt spi\_in}
|
336 |
|
|
\rput(-0.4in,0){\psline{->}(0,1in)(0,0in)}
|
337 |
|
|
\rput[b]{90}(-0.42in,0.5in){\tt spi\_len}
|
338 |
|
|
\rput(-0.2in,0){\psline{->}(0,1in)(0,0in)}
|
339 |
|
|
\rput[b]{90}(-0.22in,0.5in){\tt spi\_spd}
|
340 |
|
|
\rput( 0.0in,0){\psline{->}(0,1in)(0,0in)}
|
341 |
|
|
\rput[b]{90}(-0.02in,0.5in){\tt spi\_dir}
|
342 |
|
|
\rput( 0.2in,0){\psline{->}(0,1in)(0,0in)}
|
343 |
|
|
\rput[b]{90}( 0.18in,0.5in){\tt spi\_word}
|
344 |
|
|
\rput( 0.6in,0){\psline{<-}(0,1in)(0,0in)}
|
345 |
|
|
\rput[b]{90}( 0.58in,0.5in){\tt spi\_out}
|
346 |
|
|
\rput( 0.8in,0){\psline{<-}(0,1in)(0,0in)}
|
347 |
|
|
\rput[b]{90}( 0.78in,0.5in){\tt spi\_valid}
|
348 |
|
|
\rput( 1.0in,0){\psline{<-}(0,1in)(0,0in)}
|
349 |
|
|
\rput[b]{90}( 0.98in,0.5in){\tt spi\_busy}}
|
350 |
|
|
\rput(0,0.5in){
|
351 |
|
|
\rput(0,0){\psframe(-1.25in,0)(1.25in,0.5in)}
|
352 |
|
|
\rput(0,0.25in){\tt lleqspi}}
|
353 |
|
|
\rput(0,0){
|
354 |
|
|
\rput[b]{90}(-1.02in,0.25in){\tt bmod}
|
355 |
|
|
\psline{->}(-1.0in,0.5in)(-1.0in,-0.35in)(-0.7in,-0.35in)
|
356 |
|
|
\psline{->}(-0.5in,-0.35in)(-0.3in,-0.35in)
|
357 |
|
|
\psline{->}(-0.1in,-0.35in)( 0.1in,-0.35in)
|
358 |
|
|
\psline{->}( 0.3in,-0.35in)( 0.5in,-0.35in)
|
359 |
|
|
\psline{<->}(-0.6in,0.5in)(-0.6in,0)
|
360 |
|
|
\rput[b]{90}(-0.62in,0.25in){\tt dat[0]}
|
361 |
|
|
\psline{<->}(-0.2in,0.5in)(-0.2in,0)
|
362 |
|
|
\rput[b]{90}(-0.22in,0.25in){\tt dat[1]}
|
363 |
|
|
\psline{<->}(0.2in,0.5in)(0.2in,0)
|
364 |
|
|
\rput[b]{90}(0.18in,0.25in){\tt dat[2]}
|
365 |
|
|
\psline{<->}(0.6in,0.5in)(0.6in,0)
|
366 |
|
|
\rput[b]{90}(0.58in,0.25in){\tt dat[3]}
|
367 |
|
|
\psline{->}(1.0in,0.5in)(1.0in,0)
|
368 |
|
|
\rput[b]{90}(0.98in,0.25in){\tt clk/cs}}
|
369 |
|
|
\rput[l](1.1in,0.25in){Top level Interface Wires}
|
370 |
|
|
\rput(0,-0.7in){
|
371 |
|
|
\rput(-0.6in,0){\rput(0,0){\psframe(-0.1in,0)(0.1in,0.7in)}\rput{90}(0,0.35in){\tt xioddr}}
|
372 |
|
|
\rput(-0.2in,0){\rput(0,0){\psframe(-0.1in,0)(0.1in,0.7in)}\rput{90}(0,0.35in){\tt xioddr}}
|
373 |
|
|
\rput( 0.2in,0){\rput(0,0){\psframe(-0.1in,0)(0.1in,0.7in)}\rput{90}(0,0.35in){\tt xioddr}}
|
374 |
|
|
\rput( 0.6in,0){\rput(0,0){\psframe(-0.1in,0)(0.1in,0.7in)}\rput{90}(0,0.35in){\tt xioddr}}
|
375 |
|
|
\rput( 1.0in,0){\rput(0,0){\psframe(-0.1in,0)(0.1in,0.7in)}\rput{90}(0,0.35in){\tt xioddr}}
|
376 |
|
|
\rput(0,0){\psline{<->}(-0.6in,-0.5in)(-0.6in,0)
|
377 |
|
|
\psline{<->}(-0.2in,-0.5in)(-0.2in,0)
|
378 |
|
|
\psline{<->}(0.2in,-0.5in)(0.2in,0)
|
379 |
|
|
\psline{<->}(0.6in,-0.5in)(0.6in,0)
|
380 |
|
|
\psline{<-}(1.0in,-0.5in)(1.0in,0)}
|
381 |
|
|
\rput[l](1.1in,-0.25in){Quad SPI I/O lines}}
|
382 |
|
|
\end{pspicture}\end{center}
|
383 |
|
|
\caption{EQSPI Architecture Diagram}\label{fig:eqspi-arch}
|
384 |
|
|
\end{figure}
|
385 |
|
|
All of the various modules of this architecture, save the {\tt lleqspi} and
|
386 |
|
|
{\tt xioddr} modules, are found in the {\tt eqspiflash.v} file.
|
387 |
|
|
|
388 |
|
|
The goal of this architecture was to reduce the amount of logic necessary to
|
389 |
|
|
process the many various requests this controller allows.
|
390 |
|
|
|
391 |
|
|
At the top, all requests to the controller come from the bus straight into the
|
392 |
|
|
{\tt qspibus} module. The purpose of this module is to parse the various
|
393 |
|
|
commands to their respective modules. One command, however, never gets
|
394 |
|
|
parsed: the request to read from the erase register. This register returns
|
395 |
|
|
the status of the controller, and particularly whether or not it is still
|
396 |
|
|
busy with the last erase or write command.
|
397 |
|
|
|
398 |
|
|
The top level controller has the ability to latch a bus request. Such requests
|
399 |
|
|
are then issued to the lower level controllers. However, they remain latched
|
400 |
|
|
in the top level controller until the lower controller acknowledges them, at
|
401 |
|
|
which point the bus may advance to its next request. Depending on the lower
|
402 |
|
|
level controller, this may not occurr until the lower level transaction is
|
403 |
|
|
complete, or nearly so.
|
404 |
|
|
|
405 |
|
|
The lower level controllers also communicate with the command multiplexer
|
406 |
|
|
beneath them. Each controller has a request line, whereby it requests access
|
407 |
|
|
to the lowerest level controller. Once granted, the controller maintains
|
408 |
|
|
control of that lowest level until it is released. In this fashion, for
|
409 |
|
|
example, the {\tt readqspi} controller implements the execute in place
|
410 |
|
|
functionality: it reads from the interface, then maintains the interface.
|
411 |
|
|
If another driver requests the interface, the read controller reactivates
|
412 |
|
|
itself and returns the interface to a non--XIP mode.
|
413 |
|
|
|
414 |
|
|
Now, of these four controllers, the {\tt readqspi} controller handles reads
|
415 |
|
|
from the device. Reads are always done in Quad SPI mode, if so enabled,
|
416 |
|
|
and the device is left in XIP mode until another controller requests the
|
417 |
|
|
interface. XIP mode is left by reading a 32'bit value from the device at
|
418 |
|
|
address zero.
|
419 |
|
|
|
420 |
|
|
The {\tt writeqspi} controller handles both program and erase requests.
|
421 |
|
|
Upon completion of either request, the {\tt writeqspi} controller holds on
|
422 |
|
|
to the interface perpetually reading from the status register until the device
|
423 |
|
|
is no longer busy.
|
424 |
|
|
|
425 |
|
|
The {\tt ctrlspi} controller handles requests to read and write the various
|
426 |
|
|
control registers internal to the device. These include the status register,
|
427 |
|
|
the non--volatile configuration register, the volatile configuration register,
|
428 |
|
|
the extended volatile configuration register, the flags register, and the
|
429 |
|
|
lock registers associated with the most recently selected sector (set in the
|
430 |
|
|
erase register). Writes to these registers, though, aren't quite so simple:
|
431 |
|
|
One must first disable the write protect in the erase control register,
|
432 |
|
|
thus setting the Write Enable Latch of the device, before the device
|
433 |
|
|
will accept write requests.
|
434 |
|
|
|
435 |
|
|
Finally, the {\tt idotpqspi} controller handles the logic associated with the
|
436 |
|
|
ID memory internal to the controller, as well as both reading and writing the
|
437 |
|
|
One Time Programmable (OTP) registers, and eventually locking the OTP registers
|
438 |
|
|
so that they can no longer be read or written. As with the {\tt writeqspi}
|
439 |
|
|
module, write requests do not release the port until the write has completed.
|
440 |
|
|
Reading the erase register will provide the status on this operation.
|
441 |
|
|
|
442 |
|
|
Moving down in the architecture to the command multiplexer, this portion is
|
443 |
|
|
really not that remarkable. It takes one clock for requests to go through the
|
444 |
|
|
command multiplexer and get to the lower level controller, and it grants
|
445 |
|
|
and releases control to the various controllers.
|
446 |
|
|
|
447 |
|
|
The {\tt lleqspi} controller is the lower level controller for this device.
|
448 |
|
|
It's operation mirrors that of the {\tt llqspi} lower--level controller from
|
449 |
|
|
the QSPI flash. The biggest difference is that the Micron chip requires a
|
450 |
|
|
particular recovery time following any command other than a read command
|
451 |
|
|
leaving the chip in the XIP mode.
|
452 |
|
|
|
453 |
|
|
What is new in this controller is the requirement for the output ports to
|
454 |
|
|
be connected to the I/O banks via {\tt ODDR} and {\tt IDDR} modules. These
|
455 |
|
|
are contained within the {\tt xioddr} modules. Since the wires can change
|
456 |
|
|
direction, the {\tt bmod} pair of wires provides an indication of which
|
457 |
|
|
direction the various bits of the port are moving--either as inputs or outputs.
|
458 |
|
|
|
459 |
2 |
dgisselq |
\chapter{Operation}\label{chap:ops}
|
460 |
|
|
This implementation attempts to encapsulate (hide) the details of the chip
|
461 |
|
|
from the user, so that the user does not need to know about the various
|
462 |
|
|
subcommands going to and from the chip. The original goal was to make the
|
463 |
|
|
chip act like any other read/write memory, however the difference between
|
464 |
14 |
dgisselq |
erasing and programming a flash chip made this impossible. Therefore a
|
465 |
|
|
separate register is provided to control the erase any given sector, while
|
466 |
|
|
reads and writes may proceed (almost) as normal.
|
467 |
2 |
dgisselq |
|
468 |
|
|
The wishbone bus that this controller works with, however, is a 32--bit
|
469 |
|
|
bus. Address one on the bus addresses a completely different 32--bit word
|
470 |
|
|
from address zero or address two. Bus select lines are not implemented,
|
471 |
|
|
all operations are 32--bit. Further, the device is little--endian, meaning
|
472 |
|
|
that the low order byte is the first byte that will be or is stored on the
|
473 |
|
|
flash.
|
474 |
|
|
|
475 |
|
|
\section{High Level}
|
476 |
|
|
From a high level perspective, this core provides read/write access to the
|
477 |
|
|
device either via the wishbone (read and program), or through a control
|
478 |
|
|
register found on the wishbone (the EREG). Programming the device consists of
|
479 |
14 |
dgisselq |
first clearing the write protect, and then erasing the region of interest.
|
480 |
|
|
This will set all the bits to `1' in that region. After erasing the region,
|
481 |
|
|
the write protect may again be cleared, and then the region can then be
|
482 |
|
|
programmed, setting some of the `1' bits to '0's. When neither erase nor
|
483 |
|
|
program operation is going on, the device may be read. The section will
|
484 |
|
|
describe each of those operations in detail.
|
485 |
2 |
dgisselq |
|
486 |
|
|
To erase a sector of the device, two writes are required to the EREG register.
|
487 |
|
|
The first write turns off the write protect bit, whereas the second write
|
488 |
14 |
dgisselq |
commands the erase itself. The first write should equal \hbox{0x1000\_0000}
|
489 |
|
|
for the QSPI controller and \hbox{0x4000\_0000} for the EQSPI controller.
|
490 |
|
|
After this write, the EQSPI controller will issue a Write Enable command to the
|
491 |
|
|
device. For the QSPI controller, the second write should be any address within
|
492 |
|
|
the sector to be erased together with setting the high bit of the register.
|
493 |
|
|
This is equivalent to setting it to \hbox{0x8000\_0000} plus the address. The
|
494 |
|
|
EQSPI flash driver is subtly different in that it requires a {\em key} to erase.
|
495 |
|
|
Hence, for the EQSPI flash driver, one must write \hbox{0xc000\_01be} plus the
|
496 |
|
|
first address in the sector to accomplish the same result. Further, the
|
497 |
|
|
EQSPI flash controller allows the erasing of 4~kB subsegments. To do this,
|
498 |
|
|
the second write must also set the subsector bit, so it looks like writing
|
499 |
|
|
\hbox{0xd000\_01be} plus the first address in the subsector. After
|
500 |
|
|
this second write, the QSPI controller will issue a write--enable
|
501 |
|
|
command to the device (the EQSPI controller will have already issued the
|
502 |
|
|
write--enable), followed by a sector erase command. In summary, for the
|
503 |
|
|
QSPI flash:
|
504 |
2 |
dgisselq |
\begin{enumerate}
|
505 |
|
|
\item Disable write protect by writing \hbox{\tt 0x1000\_0000} to the EREG
|
506 |
|
|
register
|
507 |
|
|
\item Command the erase by writing \hbox{\tt 0x8000\_0000} plus the device
|
508 |
|
|
address to the EREG register. (Remember, this is the {\em word
|
509 |
|
|
address} of interest, not the {\em byte address}.)
|
510 |
|
|
\end{enumerate}
|
511 |
14 |
dgisselq |
and for the EQSPI flash:
|
512 |
|
|
\begin{enumerate}
|
513 |
|
|
\item Disable write protect by writing \hbox{\tt 0x4000\_0000} to the EREG
|
514 |
|
|
register
|
515 |
|
|
\item Command the sector (64~kB) erase by writing \hbox{\tt 0xc000\_01be} plus
|
516 |
|
|
the first address in the segment to the EREG register.
|
517 |
2 |
dgisselq |
|
518 |
14 |
dgisselq |
In the case of a subsegment (4~kB) erase command, write
|
519 |
|
|
\hbox{\tt 0xd000\_01be} plus the first address in the subsegment to
|
520 |
|
|
the EREG register.
|
521 |
|
|
\end{enumerate}
|
522 |
|
|
|
523 |
2 |
dgisselq |
While the device is erasing, the controller will idle while checking the
|
524 |
|
|
status register over and over again. Should you wish to read from the EREG
|
525 |
14 |
dgisselq |
during this time, the high order bit of the EREG register will be set indicating
|
526 |
|
|
that a write is in progress (WIP). Once the erase is complete, this bit will
|
527 |
|
|
clear, the interrupt line will be strobed high, and other operations may take
|
528 |
|
|
then place on the part. Any attempt to perform another operation on the part
|
529 |
|
|
prior to that time will stall the bus until the erase is complete.
|
530 |
2 |
dgisselq |
|
531 |
|
|
Once an area has been erased, it may then be programmed. To program the device,
|
532 |
|
|
first disable the write protect by writing a {\tt 0x1000\_0000} to the EREG
|
533 |
14 |
dgisselq |
register for the QSPI controller, or {\tt 0x4000\_0000} for the EQSPI
|
534 |
|
|
controller. After that, you may then write to the area in question whatever
|
535 |
2 |
dgisselq |
values you wish to program. One 256~byte (64~bus word) page may be programmed
|
536 |
|
|
at a time. Pages start on even boundaries, such as addresses {\tt 0x040},
|
537 |
|
|
{\tt 0x080}, {\tt 0x0100}, etc. To program a whole page at a time, write the
|
538 |
|
|
64~words of the page to the controller without dropping the {\tt i\_wb\_cyc}
|
539 |
|
|
line. Attempts to write more than 64~words will stall the bus, as will
|
540 |
|
|
attempts to write more than one page. Writes of less than a page work as well.
|
541 |
|
|
In summary,
|
542 |
|
|
\begin{enumerate}
|
543 |
|
|
\item Disable the write protect by writing a {\tt 0x1000\_0000} to the EREG
|
544 |
14 |
dgisselq |
register when using the QSPI flash controller, or {\tt 0x4000\_0000}
|
545 |
|
|
for the EQSPI flash controller.
|
546 |
2 |
dgisselq |
\item Write the page of interest to the data memory of the device.
|
547 |
|
|
|
548 |
|
|
The first address should start at the beginning of a page (bottom six
|
549 |
|
|
bits zero), and end at the end of the page (bottom six bits one, top
|
550 |
|
|
bits identical). Writes of less than a page are okay. Writes crossing
|
551 |
14 |
dgisselq |
page boundaries will stall the bus, while waiting for the first write
|
552 |
|
|
to complete before attempting to start the second write.
|
553 |
2 |
dgisselq |
\end{enumerate}
|
554 |
|
|
|
555 |
|
|
While the device is programming a page, the controller will idle while
|
556 |
|
|
checking the status register as it did during an erase. During this idle,
|
557 |
|
|
both the EREG register and the device status register may be queried. Once
|
558 |
|
|
the status register drops the write in progress line, the top level bit of
|
559 |
|
|
the EREG register will be cleared and the interrupt line strobed. Prior to this
|
560 |
|
|
time, any other bus operation will stall the bus until the write completes.
|
561 |
|
|
|
562 |
14 |
dgisselq |
Reads are simple for the QSPI flash controller, you just read from the device
|
563 |
|
|
and the device does everything you expect. Reads may be pipelined. To use
|
564 |
|
|
the QSPI mode of transferring 4--bits at a time, when using the QSPI controller,
|
565 |
|
|
you must first either read (or set) the quad mode bit in the configuration
|
566 |
|
|
register. This will enable Quad--I/O mode reads. Once enabled, reads will
|
567 |
|
|
take place four bits at a time from the bus.
|
568 |
2 |
dgisselq |
|
569 |
14 |
dgisselq |
Using the EQSPI flash controller, reads are almost as simple, but with a couple
|
570 |
|
|
of caveats. The first caveat is that the controller defaults to Quad I/O mode,
|
571 |
|
|
and will not leave it. The problem is that this mode depends upon a variable
|
572 |
|
|
number of dummy cycles set to 8. Hence, before issuing reads from the data
|
573 |
|
|
section of the device, the number of dummy cycles will need to be set in either
|
574 |
|
|
the volatile or non--volatile configuration register.
|
575 |
|
|
|
576 |
|
|
|
577 |
|
|
% When using the QSPI controller,
|
578 |
|
|
% it will take 72 device clocks (at 50~MHz) to read the first word
|
579 |
|
|
% from memory using the QSPI controller, and 32 for every pipelined word read
|
580 |
|
|
% thereafter provided that the reads are in memory order. Likewise, in quad
|
581 |
|
|
% SPI mode, it will instead take 28 device clocks to read the first word,
|
582 |
|
|
% and 8 device clocks to read every word thereafter again provided that the
|
583 |
|
|
% subsequent pipelined reads are in memory order.
|
584 |
|
|
|
585 |
|
|
Both controllers provide for a special mode following a read, where the
|
586 |
2 |
dgisselq |
next read may start immediately in Quad I/O mode following a 12~clock
|
587 |
14 |
dgisselq |
setup for the QSPI controller, or 16~clocks for the EQSPI controller. Both
|
588 |
|
|
controllers leaves the device in this mode following any initial
|
589 |
2 |
dgisselq |
read. Therefore, back to back reads as part of separate bus cycles will only
|
590 |
14 |
dgisselq |
take 20~clocks (24 for EQSPI) to read the first word, and 8~clocks per word
|
591 |
|
|
thereafter. Other commands, however, such as erasing, writing, reading from
|
592 |
|
|
the status, configuration, or ID registers, will require a 32~device
|
593 |
|
|
clock operation before entering.
|
594 |
2 |
dgisselq |
|
595 |
|
|
\section{Low Level}
|
596 |
|
|
|
597 |
14 |
dgisselq |
At a lower level, the QSPI core implements the following Quad SPI commands:
|
598 |
2 |
dgisselq |
\begin{enumerate}
|
599 |
|
|
\item FAST\_READ, when a read is requested and Quad mode has not been enabled.
|
600 |
|
|
\item QIOR, or quad I/O high performance read mode. This is the default read
|
601 |
|
|
command when Quad mode has been enabled, and it leaves the device
|
602 |
|
|
in the Quad I/O High Performance Read mode, ready for a faster second
|
603 |
|
|
read command.
|
604 |
|
|
\item RDID, or Read identification
|
605 |
|
|
\item WREN, or Write Enable, is issued prior to any erase, program, or
|
606 |
|
|
write register (i.e. configuration or status) command.
|
607 |
|
|
This detail is hidden from the user.
|
608 |
|
|
\item RDSR, or read status register, is issued any time the user attempts
|
609 |
|
|
to read from the status register. Further, following an erase or a
|
610 |
|
|
write command, the device is left reading this register over and over
|
611 |
|
|
again until the write completes.
|
612 |
|
|
\item RCR, or read configuration, is issued any time a request is made to
|
613 |
|
|
read from the configuration register. Following such a read, the
|
614 |
|
|
quad I/O may be enabled for the device, if it is enabled in this
|
615 |
|
|
register.
|
616 |
|
|
\item WRR, or write registers, is issued upon any write to the status or
|
617 |
|
|
configuration registers. To separate the two, the last value read
|
618 |
|
|
from the status register is written to the status register when
|
619 |
|
|
writing the configuration register.
|
620 |
|
|
\item PP, or page program, is issued to program the device in serial mode
|
621 |
|
|
whenever programming is desired and the quad I/O has not been enabled.
|
622 |
|
|
\item QPP, or quad page program, is used to program the device whenever
|
623 |
|
|
a write is requested and quad I/O mode has been enabled.
|
624 |
|
|
\item SE, or sector erase, is the only type of erase this core supports.
|
625 |
|
|
\item CLSR, or Clear Status Register, is issued any time the last status
|
626 |
|
|
register had the bits {\tt P\_ERR} or {\tt E\_ERR} set and the
|
627 |
|
|
write to the status register attempts to clear one of these. This
|
628 |
|
|
command is then issued following the WRR command.
|
629 |
|
|
\end{enumerate}
|
630 |
|
|
|
631 |
|
|
\chapter{Registers}\label{chap:regs}
|
632 |
|
|
|
633 |
14 |
dgisselq |
\section{QSPI Controller}
|
634 |
|
|
|
635 |
|
|
The QSPI controller supports four control registers. These are the EREG
|
636 |
2 |
dgisselq |
register, the configuration register, the status register, and the device ID,
|
637 |
|
|
as shown and listed in Table.~\ref{tbl:reglist}.
|
638 |
|
|
\begin{table}[htbp]
|
639 |
|
|
\begin{center}
|
640 |
|
|
\begin{reglist}
|
641 |
|
|
EREG & 0 & 32 & R/W & An overall control register, providing instant status
|
642 |
|
|
from the device and controlling erase commands.\\\hline
|
643 |
|
|
Config & 1 & 8 & R/W & The devices configuration register.\\\hline
|
644 |
|
|
Status & 2 & 8 & R/W & The devices status register.\\\hline
|
645 |
|
|
ID & 3 & 16 & R & Reads the 16-bit ID from the device.\\\hline
|
646 |
|
|
\end{reglist}
|
647 |
14 |
dgisselq |
\caption{List of QSPI Registers}\label{tbl:reglist}
|
648 |
2 |
dgisselq |
\end{center}\end{table}
|
649 |
|
|
|
650 |
14 |
dgisselq |
\subsection{EREG Register}
|
651 |
2 |
dgisselq |
The EREG register was designed to be a replacement for all of the device
|
652 |
|
|
registers, leaving all the other registers a part of a lower level access
|
653 |
|
|
used only in debugging the device. This would've been the case, save that
|
654 |
|
|
one may need to set bit one of the configuration register to enter high
|
655 |
|
|
speed mode.
|
656 |
|
|
|
657 |
|
|
The bits associated with this register are listed in Tbl.~\ref{tbl:eregbits}.
|
658 |
|
|
|
659 |
|
|
\begin{table}[htbp]
|
660 |
|
|
\begin{center}
|
661 |
|
|
\begin{bitlist}
|
662 |
|
|
31 & R/W & Write in Progress/Erase. On a read, this bit will be high if any
|
663 |
|
|
write or erase operation is in progress, zero otherwise. To erase
|
664 |
|
|
a sector, set this bit to a one. Otherwise, writes should keep this
|
665 |
|
|
register at zero.\\\hline
|
666 |
|
|
30 & R & Dirty bit. The sector referenced has been written to since it
|
667 |
|
|
was erased. This bit is meaningless between startup and the first
|
668 |
|
|
erase, but valid afterwards.\\\hline
|
669 |
|
|
29 & R & Busy bit. This bit returns a one any time the lower level Quad
|
670 |
|
|
SPI core is active. However, to read this register, the lower level
|
671 |
|
|
core must be inactive, so this register should always read zero.
|
672 |
|
|
\\\hline
|
673 |
|
|
28 & R/W & Disable write protect. Set this to a one to disable the write
|
674 |
|
|
protect mode, or to a zero to re--enable write protect on this chip.
|
675 |
|
|
Note that this register is not self--clearing. Therefore, write
|
676 |
|
|
protection may still be disabled following an erase or a write.
|
677 |
|
|
Clear this manually when you wish to re--enable write protection.
|
678 |
|
|
\\\hline
|
679 |
|
|
27 & R & Returns a one if the device is in high speed (4-bit I/O) mode.
|
680 |
|
|
To set the device into high speed mode, set bit~1 of the configuration
|
681 |
|
|
register.\\\hline
|
682 |
|
|
20--26 & R & Always return zero.\\\hline
|
683 |
|
|
14--19 & R/W & The sector address bits of the last sector erased. If the
|
684 |
|
|
erase line bit is set while writing this register, these bits
|
685 |
|
|
will be set as well with the sector being erased.\\\hline
|
686 |
|
|
0--13 & R & Always return zero.\\\hline
|
687 |
|
|
\end{bitlist}
|
688 |
|
|
\caption{EREG bit definitions}\label{tbl:eregbits}
|
689 |
|
|
\end{center}\end{table}
|
690 |
|
|
|
691 |
|
|
In general, only three bits and an address are of interest here.
|
692 |
|
|
|
693 |
|
|
The first bit of interest is bit 27, which will tell you if you are in Quad--I/O
|
694 |
|
|
mode. The device will automatically start up in SPI serial mode. Upon
|
695 |
|
|
reading the configuration register, it will transition to Quad--I/O mode if
|
696 |
|
|
the QUAD bit is set. Likewise, if the bit is written to the configuration
|
697 |
|
|
register it will transition to Quad--I/O mode.
|
698 |
|
|
|
699 |
|
|
While this may seem kind of strange, I have found this setup useful. It allows
|
700 |
|
|
me to debug commands that might work in serial mode but not quad I/O mode,
|
701 |
|
|
and it allows me to explicitly switch to Quad I/O mode. Further, writes to the
|
702 |
|
|
configuration register are non--volatile and in some cases permanent.
|
703 |
|
|
Therefore, it doesn't make sense that a controller should perform such a write
|
704 |
|
|
without first being told to do so. Therefore, this bit is set upon
|
705 |
|
|
noticing that the QUAD bit is set in the configuration register.
|
706 |
|
|
|
707 |
|
|
The second bit of interest is the write protect disable bit. Write a '1'
|
708 |
|
|
to this bit before any erase or program operation, and a '0' to this bit
|
709 |
|
|
otherwise. This allows you to make sure that accidental bus writes to the
|
710 |
|
|
wrong address won't reprogram your flash (which they would do otherwise).
|
711 |
|
|
|
712 |
|
|
The final bit of interest is the write in progress slash erase bit. On read,
|
713 |
|
|
this bit mirrors the WIP bit in the status register. It will be a one during
|
714 |
|
|
any ongoing erase or programming operation, and clear otherwise. Further,
|
715 |
|
|
to erase a sector, disable the write protect and then set this bit to a one
|
716 |
|
|
while simultaneously writing the sector of interest to the device.
|
717 |
|
|
|
718 |
|
|
The last item of interest in this register is the sector address of interest.
|
719 |
|
|
This was placed in bits 14--19 so that any address within the sector
|
720 |
|
|
would work. Thus, to erase a sector, write the sector address, together with
|
721 |
|
|
an erase bit, to this register.
|
722 |
|
|
|
723 |
14 |
dgisselq |
\subsection{Config Register}
|
724 |
2 |
dgisselq |
|
725 |
|
|
The Quad Flash device also has a non--volatile configuration register, as
|
726 |
|
|
shown in Tbl.~\ref{tbl:confbits}. Writes to this register are program events,
|
727 |
|
|
which will stall subsequent bus operations until the write in progress bit
|
728 |
|
|
of either the status or EREG registers clears. Note that some bits, once
|
729 |
|
|
written, cannot be cleared such as the BPNV bit.
|
730 |
|
|
|
731 |
|
|
Writes to this register are not truly independent of the status register,
|
732 |
|
|
as the Write Registers (WRR) command writes the status register before the
|
733 |
|
|
configuration register. Therefore, the core implements this by writing the
|
734 |
|
|
status register with the last value that was read by the core, or zero
|
735 |
|
|
if the status register has yet to be read by the core. Following the
|
736 |
|
|
status register write, the new value for the configuration register is
|
737 |
|
|
written.
|
738 |
|
|
\begin{table}[htbp]\begin{center}
|
739 |
|
|
\begin{bitlist}
|
740 |
|
|
8--31 & R & Always return zero.\\\hline
|
741 |
|
|
6--7 & R & Not used.\\\hline
|
742 |
|
|
5 & R/W & TBPROT. Configures the start of block protection. See device
|
743 |
|
|
documentation for more information. (Default 0)\\\hline
|
744 |
|
|
4 & R/W & Do not use. (Default 0)\\\hline
|
745 |
|
|
3 & R/W & BPNV, configures BP2--0 bits in the status register. If this bit
|
746 |
|
|
is set to 1, these bits are volatile, if set to '0' (default) the
|
747 |
|
|
bits are non--volatile. {\em Note that once this bit has been set,
|
748 |
|
|
it cannot be cleared!}\\\hline
|
749 |
|
|
2 & R/W & TBPARM. Configures the parameter sector location. See device
|
750 |
|
|
documentation for more detailed information. (Default 0)\\\hline
|
751 |
|
|
1 & R/W & QUAD. Set to '1' to place the device into Quad I/O (4--bit) mode,
|
752 |
|
|
'0' to leave in dual or serial I/O mode. (This core does not support
|
753 |
|
|
dual I/O mode.) (Most programmers will set this to '1'.)\\\hline
|
754 |
|
|
|
755 |
|
|
otherwise. (Default 0).\\\hline
|
756 |
|
|
\\\hline
|
757 |
|
|
\end{bitlist}
|
758 |
|
|
\caption{Configuration bit definitions}\label{tbl:confbits}
|
759 |
|
|
\end{center}\end{table}
|
760 |
|
|
|
761 |
|
|
Further information on this register is available in the device data sheet.
|
762 |
|
|
|
763 |
14 |
dgisselq |
\subsection{Status Register}
|
764 |
2 |
dgisselq |
The definitions of the bits in the status register are shown in
|
765 |
|
|
Tbl.~\ref{tbl:statbits}. For operating this core, only the write in progress
|
766 |
|
|
bit is relevant. All other bits should be set to zero.
|
767 |
|
|
|
768 |
|
|
\begin{table}[htbp]
|
769 |
|
|
\begin{center}
|
770 |
|
|
\begin{bitlist}
|
771 |
|
|
8--31 & R & Always return zero.\\\hline
|
772 |
|
|
7 & R/W & Status register write disable. This setting is irrelevant in the
|
773 |
|
|
current core configuration, since the W\#/ACC line is always kept
|
774 |
|
|
high.\\\hline
|
775 |
|
|
6 & R/W & P\_ERR. The device will set this to a one if a programming error
|
776 |
|
|
has occurred. Writes with either P\_ERR or E\_ERR cleared will
|
777 |
|
|
clear this bit.\\\hline
|
778 |
|
|
5 & R/W & E\_ERR. The device will set this to a one if an erase error has
|
779 |
|
|
occurred, zero otherwise. Writes clearing either P\_ERR or E\_ERR
|
780 |
|
|
will clear this bit.
|
781 |
|
|
\\\hline
|
782 |
|
|
2--4 & R/W & Block protect bits. This core assumes these bits are zero.
|
783 |
|
|
See device documentation for other possible settings.\\\hline
|
784 |
|
|
1 & R & Write Enable Latch. This bit is handled internally by the core,
|
785 |
|
|
being set before any program or erase operation and cleared by
|
786 |
|
|
the operation itself. Therefore, reads should always read this
|
787 |
|
|
line as low.\\\hline
|
788 |
|
|
|
789 |
|
|
program operation is in progress. It will be cleared upon completion.
|
790 |
|
|
\\\hline
|
791 |
|
|
\end{bitlist}
|
792 |
|
|
\caption{Status bit definitions}\label{tbl:statbits}
|
793 |
|
|
\end{center}\end{table}
|
794 |
|
|
|
795 |
14 |
dgisselq |
\subsection{Device ID}
|
796 |
2 |
dgisselq |
|
797 |
|
|
Reading from the Device ID register causes the core controller to issue
|
798 |
|
|
a RDID {\tt 0x9f} command. The bytes returned are first the manufacture
|
799 |
|
|
ID of the part ({\tt 0x01} for this part), followed by the device ID
|
800 |
|
|
({\tt 0x0215} for this part), followed by the number of extended bytes that
|
801 |
|
|
may be read ({\tt 0x4D} for this part). This controller provides no means
|
802 |
|
|
of reading these extended bytes. (See Tab.~\ref{tbl:idbits})
|
803 |
|
|
|
804 |
|
|
\begin{table}[htbp]\begin{center}
|
805 |
|
|
\begin{bitlist}
|
806 |
|
|
0--31 & R & Always reads {\tt 0x0102154d}.\\\hline
|
807 |
|
|
\end{bitlist}
|
808 |
|
|
\caption{Read ID bit definitions}\label{tbl:idbits}
|
809 |
|
|
\end{center}\end{table}
|
810 |
|
|
|
811 |
|
|
\chapter{Wishbone Datasheet}\label{chap:wishbone}
|
812 |
|
|
Tbl.~\ref{tbl:wishbone} is required by the wishbone specification, and so
|
813 |
|
|
it is included here.
|
814 |
|
|
\begin{table}[htbp]
|
815 |
|
|
\begin{center}
|
816 |
|
|
\begin{wishboneds}
|
817 |
|
|
Revision level of wishbone & WB B4 spec \\\hline
|
818 |
14 |
dgisselq |
Type of interface & Slave, (Pipelind) Read/Write \\\hline
|
819 |
2 |
dgisselq |
Port size & 32--bit \\\hline
|
820 |
5 |
dgisselq |
Port granularity & 32--bit \\\hline
|
821 |
2 |
dgisselq |
Maximum Operand Size & 32--bit \\\hline
|
822 |
|
|
Data transfer ordering & Little Endian \\\hline
|
823 |
14 |
dgisselq |
Clock constraints & Must be 100~MHz or slower (QSPI)\\\cline{2-2}
|
824 |
|
|
& Must be 200~MHz or slower (EQSPI)\\\hline
|
825 |
2 |
dgisselq |
Signal Names & \begin{tabular}{ll}
|
826 |
|
|
Signal Name & Wishbone Equivalent \\\hline
|
827 |
14 |
dgisselq |
{\tt i\_clk\_100mhz} & {\tt CLK\_I} { (QSPI)} \\
|
828 |
|
|
{\tt i\_clk\_200mhz} & {\tt CLK\_I} { (EQSPI)}\\
|
829 |
2 |
dgisselq |
{\tt i\_wb\_cyc} & {\tt CYC\_I} \\
|
830 |
|
|
{\tt i\_wb\_ctrl\_stb} & {\tt STB\_I} \\
|
831 |
|
|
{\tt i\_wb\_data\_stb} & {\tt STB\_I} \\
|
832 |
|
|
{\tt i\_wb\_we} & {\tt WE\_I} \\
|
833 |
5 |
dgisselq |
{\tt i\_wb\_addr} & {\tt ADR\_I} \\
|
834 |
2 |
dgisselq |
{\tt i\_wb\_data} & {\tt DAT\_I} \\
|
835 |
|
|
{\tt o\_wb\_ack} & {\tt ACK\_O} \\
|
836 |
|
|
{\tt o\_wb\_stall} & {\tt STALL\_O} \\
|
837 |
|
|
{\tt o\_wb\_data} & {\tt DAT\_O}
|
838 |
|
|
\end{tabular}\\\hline
|
839 |
|
|
\end{wishboneds}
|
840 |
14 |
dgisselq |
\caption{Wishbone Datasheet for the (E)QSPI Flash controller}\label{tbl:wishbone}
|
841 |
2 |
dgisselq |
\end{center}\end{table}
|
842 |
|
|
|
843 |
14 |
dgisselq |
The EQSPI flash controller has a further simplified wishbone usage: the strobe
|
844 |
|
|
lines, whether {\tt i\_wb\_ctrl\_stb} or {\tt i\_wb\_data\_stb}, must be
|
845 |
|
|
guaranteed low any time {\tt i\_wb\_cyc} is low. This simplifies transaction
|
846 |
|
|
processing internal to the controller, and is part of the method of getting the
|
847 |
|
|
controller running at 200~MHz.
|
848 |
|
|
|
849 |
|
|
\section{EQSPI Controller}
|
850 |
|
|
\subsection{EREG Register}
|
851 |
|
|
\subsection{Status Register}
|
852 |
|
|
\subsection{Non--Volatile Configuration Register}
|
853 |
|
|
\subsection{Volatile Configuration Register}
|
854 |
|
|
\subsection{Extended Volatile Configuration Register}
|
855 |
|
|
\subsection{Sector Lock Register}
|
856 |
|
|
\subsection{Flag Status Register}
|
857 |
|
|
\subsection{Identification memory}
|
858 |
|
|
\subsection{One--Time Programmable Memory}
|
859 |
|
|
|
860 |
2 |
dgisselq |
\chapter{Clocks}\label{chap:clocks}
|
861 |
|
|
|
862 |
14 |
dgisselq |
The QSPI core is based upon the Basys--3 design. The Basys--3 development board
|
863 |
2 |
dgisselq |
contains one external 100~MHz clock. This clock is divided by two to create
|
864 |
|
|
the 50~MHz clock used to drive the device. According to the data sheet,
|
865 |
|
|
it should be possible to run this core at up to 160~MHz, however I have not
|
866 |
14 |
dgisselq |
tested it at such speeds. See Table.~\ref{tbl:qspi-clocks}.
|
867 |
|
|
\begin{table}[htbp]\begin{center}\begin{clocklist}
|
868 |
2 |
dgisselq |
i\_clk\_100mhz & External & 160 & & System clock.\\\hline
|
869 |
|
|
\end{clocklist}
|
870 |
14 |
dgisselq |
\caption{List of QSPI Controller Clocks}\label{tbl:qspi-clocks}
|
871 |
2 |
dgisselq |
\end{center}\end{table}
|
872 |
|
|
|
873 |
14 |
dgisselq |
The EQSPI core is based upon a very similar Arty design, but one that instead
|
874 |
|
|
uses a 200~MHz core clock frequency. In a fashion similar to the QSPI
|
875 |
|
|
controller, this clock is divided down to create a 100~MHz clock to command
|
876 |
|
|
the device. Hence, the EQSPI clock is much faster, as shown in
|
877 |
|
|
Table.~\ref{tbl:eqspi-clocks}.
|
878 |
|
|
\begin{table}[htbp]\begin{center}\begin{clocklist}
|
879 |
|
|
i\_clk\_200mhz & External & 200 & & System clock.\\\hline
|
880 |
|
|
\end{clocklist}
|
881 |
|
|
\caption{List of EQSPI Controller Clocks}\label{tbl:eqspi-clocks}
|
882 |
|
|
\end{center}\end{table}
|
883 |
|
|
|
884 |
|
|
|
885 |
2 |
dgisselq |
\chapter{I/O Ports}\label{chap:ioports}
|
886 |
|
|
There are two interfaces that this device supports: a wishbone interface, and
|
887 |
|
|
the interface to the Quad--SPI flash itself. Both of these have their own
|
888 |
|
|
section in the I/O port list. For the purpose of this table, the wishbone
|
889 |
|
|
interface is listed in Tbl.~\ref{tbl:iowishbone}, and the Quad SPI flash
|
890 |
|
|
interface is listed in Tbl.~\ref{tbl:ioqspi}. The two lines that don't really
|
891 |
|
|
fit this classification are found in Tbl.~\ref{tbl:ioother}.
|
892 |
|
|
\begin{table}[htbp]
|
893 |
|
|
\begin{center}
|
894 |
|
|
\begin{portlist}
|
895 |
|
|
i\_wb\_cyc & 1 & Input & Wishbone bus cycle wire.\\\hline
|
896 |
|
|
i\_wb\_data\_stb & 1 & Input & Wishbone strobe, when the access is to the data
|
897 |
|
|
memory.\\\hline
|
898 |
|
|
i\_wb\_ctrl\_stb & 1 & Input & Wishbone strobe, for when the access is to
|
899 |
|
|
one of control registers.\\\hline
|
900 |
|
|
i\_wb\_we & 1 & Input & Wishbone write enable, indicating a write interaction
|
901 |
|
|
to the bus.\\\hline
|
902 |
|
|
i\_wb\_addr & 19 & Input & Wishbone address. When accessing control registers,
|
903 |
|
|
only the bottom two bits are relevant all other bits are
|
904 |
|
|
ignored.\\\hline
|
905 |
|
|
i\_wb\_data & 32 & Input & Wishbone bus data register.\\\hline
|
906 |
|
|
o\_wb\_ack & 1 & Output & Return value acknowledging a wishbone write, or
|
907 |
|
|
signifying valid data in the case of a wishbone read request.
|
908 |
|
|
\\\hline
|
909 |
|
|
o\_wb\_stall & 1 & Output & Indicates the device is not yet ready for another
|
910 |
|
|
wishbone access, effectively stalling the bus.\\\hline
|
911 |
|
|
o\_wb\_data & 32 & Output & Wishbone data bus, returning data values read
|
912 |
|
|
from the interface.\\\hline
|
913 |
|
|
\end{portlist}
|
914 |
|
|
\caption{Wishbone I/O Ports}\label{tbl:iowishbone}
|
915 |
|
|
\end{center}\end{table}
|
916 |
|
|
|
917 |
|
|
While this core is wishbone compatible, there was one necessary change to
|
918 |
|
|
the wishbone interface to make this possible. That was the split of the
|
919 |
|
|
strobe line into two separate lines. The first strobe line, the data strobe,
|
920 |
|
|
is used when the access is to data memory--such as a read or write (program)
|
921 |
|
|
access. The second strobe line, the control strobe, is for reads and writes
|
922 |
|
|
to one of the four control registers. By splitting these strobe lines,
|
923 |
|
|
the wishbone interconnect designer may place the control registers in a
|
924 |
|
|
separate location of wishbone address space from the flash memory. It is
|
925 |
|
|
an error for both strobe lines to be on at the same time.
|
926 |
|
|
|
927 |
|
|
With respect to the Quad SPI interface itself, one piece of glue logic
|
928 |
14 |
dgisselq |
is necessary to tie the QSPI flash I/O to the in/out port at the top
|
929 |
2 |
dgisselq |
level of the device. Specifically, these two lines must be added somewhere:
|
930 |
|
|
\begin{tabbing}
|
931 |
|
|
assign {\tt io\_qspi\_dat} = \= (\~{\tt qspi\_mod[1]})?(\{2'b11,1'bz,{\tt qspi\_dat[0]}\}) \hbox{\em // Serial mode} \\
|
932 |
|
|
\> :(({\tt qspi\_bmod[0]})?(4'bzzzz):({\tt qspi\_dat[3:0]}));
|
933 |
|
|
\hbox{\em // Quad mode}
|
934 |
|
|
\end{tabbing}
|
935 |
|
|
These provide the transition between the input and output ports used by this
|
936 |
|
|
core, and the bi--directional inout ports used by the actual part. Further,
|
937 |
|
|
because the two additional lines are defined to be ones during serial I/O
|
938 |
|
|
mode, the hold and write protect lines are effectively eliminated in this
|
939 |
|
|
design in favor of faster speed I/O (i.e., Quad I/O).
|
940 |
|
|
|
941 |
14 |
dgisselq |
The EQSPI controller is similar, but the glue logic is more involved.
|
942 |
|
|
|
943 |
2 |
dgisselq |
\begin{table}[htbp]
|
944 |
|
|
\begin{center}
|
945 |
|
|
\begin{portlist}
|
946 |
|
|
o\_qspi\_sck & 1 & Output & Serial clock output to the device. This pin
|
947 |
|
|
will be either inactive, or it will toggle at 50~MHz.\\\hline
|
948 |
|
|
o\_qpsi\_cs\_n & 1 & Output & Chip enable, active low. This will be
|
949 |
|
|
set low at the beginning of any interaction with the chip,
|
950 |
|
|
and will be held low throughout the interaction.\\\hline
|
951 |
|
|
o\_qspi\_mod & 2 & Output & Two mode lines for the top level to control
|
952 |
|
|
how the output data lines interact with the device. See the text
|
953 |
|
|
for how to use these lines.\\\hline
|
954 |
|
|
o\_qspi\_dat & 4 & Output & Four output lines, the least of which is the
|
955 |
|
|
old SPI MOSI line. When selected by the o\_qspi\_mod, this output
|
956 |
|
|
becomes the command for all 4 QSPI I/O lines.\\\hline
|
957 |
|
|
i\_qspi\_dat & 4 & Input & The four input lines from the device, of which
|
958 |
|
|
line one, {\tt i\_qspi\_dat[1]}, is the old MISO line.\\\hline
|
959 |
|
|
\end{portlist}
|
960 |
|
|
\caption{List of Quad--SPI Flash I/O ports}\label{tbl:ioqspi}
|
961 |
|
|
\end{center}\end{table}
|
962 |
|
|
|
963 |
|
|
Finally, the clock line is not specific to the wishbone bus, and the interrupt
|
964 |
|
|
line is not specific to any of the above. These have been separated out here.
|
965 |
|
|
\begin{table}[htbp]
|
966 |
|
|
\begin{center}
|
967 |
|
|
\begin{portlist}
|
968 |
14 |
dgisselq |
i\_clk\_100mhz & 1 & Input & The 100~MHz clock driving all QSPI
|
969 |
|
|
interactions.\\\hline
|
970 |
2 |
dgisselq |
o\_interrupt & 1 & Output & An strobed interrupt line indicating the end of
|
971 |
|
|
any erase or write transaction. This line will be high for exactly
|
972 |
|
|
one clock cycle, indicating that the core is again available for
|
973 |
|
|
commanding.\\\hline
|
974 |
|
|
\end{portlist}
|
975 |
|
|
\caption{Other I/O Ports}\label{tbl:ioother}
|
976 |
|
|
\end{center}\end{table}
|
977 |
|
|
% Appendices
|
978 |
|
|
% Index
|
979 |
|
|
\end{document}
|
980 |
|
|
|
981 |
|
|
|