OpenCores
URL https://opencores.org/ocsvn/s6soc/s6soc/trunk

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [doc/] [src/] [spec.tex] - Blame information for rev 31

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 dgisselq
\documentclass{gqtekspec}
2
\usepackage{import}
3
\usepackage{bytefield}
4
\project{CMod S6 SoC}
5
\title{Specification}
6
\author{Dan Gisselquist, Ph.D.}
7
\email{dgisselq (at) opencores.org}
8
\revision{Rev.~0.2}
9
\begin{document}
10
\pagestyle{gqtekspecplain}
11
\titlepage
12
\begin{license}
13
Copyright (C) \theyear\today, Gisselquist Technology, LLC
14
 
15
This project is free software (firmware): you can redistribute it and/or
16
modify it under the terms of  the GNU General Public License as published
17
by the Free Software Foundation, either version 3 of the License, or (at
18
your option) any later version.
19
 
20
This program is distributed in the hope that it will be useful, but WITHOUT
21
ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
22
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23
for more details.
24
 
25
You should have received a copy of the GNU General Public License along
26
with this program.  If not, see \texttt{http://www.gnu.org/licenses/} for a copy.
27
\end{license}
28
\begin{revisionhistory}
29
0.1 & 4/22/2016 & Gisselquist & First Draft \\\hline
30
\end{revisionhistory}
31
% Revision History
32
% Table of Contents, named Contents
33
\tableofcontents
34
\listoffigures
35
\listoftables
36
\begin{preface}
37
The Zip CPU was built with the express purpose of being an area optimized,
38
32--bit FPGA soft processor.
39
 
40
The S6~SoC is designed to prove that the ZipCPU has met this goal.
41
\end{preface}
42
 
43
\chapter{Introduction}
44
\pagenumbering{arabic}
45
\setcounter{page}{1}
46
 
47
This project is ongoing.  Any and all files, to include this one, are subject
48
to change without notice.
49
 
50
This project comes from my desire to demonstrate the Zip CPU's utility in a
51
challenging environment.  The CMod~S6 board fits this role nicely.
52
\begin{enumerate}
53
\item The Spartan--6 LX4 FPGA is very limited in it's resources:
54
        It only has 2,400 look--up tables (LUTs), and can only support
55
        a 4,096~Word RAM memory (16 kB).
56
\item With only 4kW RAM, the majority of any program will need to be placed into
57
        and run from flash.  (The chip will actually support more, just not
58
        8k RAM.)
59
\item While the chip has enough area for the CPU, it doesn't have enough area
60
        to include the CPU and \ldots write access to the flash, debug access,
61
        wishbone command access from the UART, pipelined CPU operations, and
62
        more.  Other solutions will need to be found.
63
\end{enumerate}
64
 
65
Of course, if someone just wants the functionality of a small, cheap, CPU,
66
this project does not fit that role very well.  While the S6 is not very
67
expensive, it is still an order of magnitude greater than it's CPU competitors
68
in price.  This includes such CPU's as the Raspberry Pi Zero, or even the
69
TeensyLC.
70
 
71
If, on the other hand, what you want is a small, cheap, CPU that can be embedded
72
within an FPGA without using too much of the FPGA's resources, this project
73
will demonstrate that utility and possibility.  Alternatively, if you wish to
74
study how to get a CPU to work in a small, constrained environment, this project
75
may be what you are looking for.
76
 
77
\chapter{Architecture}
78
Fig.~\ref{fig:architecture}
79
\begin{figure}\begin{center}
80
\includegraphics[width=5in]{../gfx/s6bones.eps}
81
\caption{CMod S6 SoC Architecture: ZipCPU and
82
        Peripherals}\label{fig:architecture}
83
\end{center}\end{figure}
84
shows the basic internal architecture of the S6~SoC.  In summary, it consists of a CPU
85
coupled with a variety of peripherals for the purpose of controlling the
86
external peripherals of the S6: flash, LEDs, buttons, and GPIO.  External
87
devices may also be added on, such as an audio device, an external serial
88
port, an external keypad, and an external display.  All of these devices
89
are then available for the CPU to interact with.
90
 
91
If you are familiar with the Zip CPU, you'll notice this architecture provides
92
no access to the Zip CPU debug port.  There simply wasn't enough room on the
93
device.  Debugging the ZipCPU will instead need to take place via other means,
94
such as dumping all registers and/or memory to the serial port on any reboot.
95
 
96
Further, the ZipCPU has no ability to write to flash memory.  For this reason,
97
there exists an alternate CMod S6~SoC architecture, as shown in
98
Fig.~\ref{fig:altarchitecture}.
99
\begin{figure}\begin{center}
100
\includegraphics[width=5in]{../gfx/altbones.eps}
101
\caption{Alternate CMod S6 SoC Architecture: Peripherals, with no
102
        CPU}\label{fig:altarchitecture}
103
\end{center}\end{figure}
104
Using this alternate architecture, it should be possible to test the peripherals
105
and program the flash memory.  Both architectures may be loaded into the flash,
106
together with the programming code for the Zip CPU.
107
 
108
The basic approach is simple: up and until the software works, the S6 will
109
power up into the alternate architecture of Fig.~\ref{fig:altarchitecture}.
110
While in this state, the flash may be examined and programmed.  Once complete,
111
a UART command to the ICAPE port will tell the S6 to load the (primary)
112
FPGA configuration from an alternate flash location.  This alternate location
113
will contain a configuration image containing the CPU.  The CPU will then begin
114
following the instructions given to it from the flash.
115
 
116
 
117
 
118
\chapter{Operation}
119
 
120
\chapter{Registers}
121
There are several address regions on the S6~SoC, as shown in
122
Tbl.~\ref{tbl:memregions}.
123
\begin{table}[htbp]
124
\begin{center}\begin{tabular}{|p{0.75in}|p{0.75in}|p{0.5in}|p{3.0in}|}\hline
125
\rowcolor[gray]{0.85} Start & End & & Purpose \\\hline\hline
126
\scalebox{0.9}{\tt 0x000100} & \scalebox{0.9}{\tt 0x000107} & R/W & Peripheral I/O Control \\\hline
127
\scalebox{0.9}{\tt 0x000200} & \scalebox{0.9}{\tt 0x000201} & R/(W) & Debugging scope\\\hline
128
\scalebox{0.9}{\tt 0x000400} & \scalebox{0.9}{\tt 0x00043f} & R/W & Internal Configuration Access Port\\\hline
129
\scalebox{0.9}{\tt 0x000800} & \scalebox{0.9}{\tt 0x000803} & R/W & RTC Clock (if present)\\\hline
130
\scalebox{0.9}{\tt 0x002000} & \scalebox{0.9}{\tt 0x002fff} & R/W & 16kB On-Chip Block RAM \\\hline
131
\scalebox{0.9}{\tt 0x400000} & \scalebox{0.9}{\tt 0x7fffff} & R & 16~MB SPI Flash memory\\\hline
132
\end{tabular}
133
\caption{Address Regions}\label{tbl:memregions}
134
\end{center}\end{table}
135
In general, the address regions that are made up of RAM or flash act like
136
memory.  The RAM can be read and written, and the flash acts like read only
137
memory.
138
 
139
This isn't quite so true with the other address regions.  Accessing the I/O
140
region, while it may be read/write, may have side-effects.  For example, reading
141
from the debugging scope device's data port will read a word from the scope's
142
buffer and advance the buffer pointer.
143
 
144
\section{Debugging Scope}
145
The debugging scope consists of two registers, a control register and a data
146
register.  It needs to be internally wired to 32--wires, internal to the S6
147
SoC, that will be of interest later.  For further details on how to configure
148
and use this scope, please see the {\tt WBSCOPE} project on OpenCores.
149
 
150
\section{Internal Configuration Access Port}
151
The Internal Configuration Access Port (ICAP) provides access to the internal
152
configuration details of the FPGA.  This access was designed so as to provide
153
the CPU with the capability to command a different FPGA load.  In particular,
154
the code in Fig.~\ref{fig:reload} should reconfigure the FPGA from any given
155
Quad SPI {\tt address}.\footnote{According to Xilinx's technical support, this
156
will only work if the JTAG port is not busy.}
157
\begin{figure}\begin{center}\begin{tabbing}
158
{\tt warmboot(uint32 address) \{} \\
159
\hbox to 0.25in{}\={\tt uint32\_t *icape6 = (volatile uint32\_t *)0x{\em <ICAPE port address>};}\\
160
 \>{\tt icape6[13] = (address<<2)\&0x0ffff;}\\
161
 \>{\tt icape6[14] = ((address>>14)\&0x0ff)|((0x03)<<8);}\\
162
 \>{\tt icape6[4] = 14;}\\
163
 \>{\em // The CMod~S6 is now reconfiguring itself from the new address.}\\
164
 \>{\em // If all goes well, this routine will never return.}\\
165
{\tt \}}
166
\end{tabbing}
167
\caption{Spartan--6 ICAPE Usage}\label{fig:reload}
168
\end{center}\end{figure}
169
 
170
For further details, please see either the {\tt WBICAPETWO} project on OpenCores
171
as well as Xilinx's ``Spartan-6 FPGA Configuration User Guide''.
172
 
173
\section{Real--Time Clock}
174
The Real Time Clock will be included if there is enough area to support it.
175
The four registers correspond to a clock, a timer, a stopwatch, and an alarm.
176
If space is tight, the timer and stopwatch, or indeed the entire clock, may be
177
removed from the design.  For further details regarding how to set and use this
178
clock, please see the {\tt RTCCLOCK} project on OpenCores.
179
 
180
\section{I/O Peripherals}
181
Tbl.~\ref{tbl:ioregs}
182
\begin{table}[htbp]
183
\begin{center}\begin{reglist}
184
PIC    &\scalebox{0.8}{\tt 0x0100} & 32 & R/W & Interrupt Controller \\\hline
185
BUSERR &\scalebox{0.8}{\tt 0x0101} & 32 & R & Last Bus Error Address\\\hline
186
TIMA   &\scalebox{0.8}{\tt 0x0102} & 32 & R/W & ZipTimer A\\\hline
187
TIMB   &\scalebox{0.8}{\tt 0x0103} & 32 & R/W & ZipTimer B\\\hline
188
PWM    &\scalebox{0.8}{\tt 0x0104} & 32 & R/W & PWM Audio Controller\\\hline
189
KYPAD  &\scalebox{0.8}{\tt 0x0105} & 32 & R/W & Special Purpose I/O, Keypad, LED Controller \\\hline
190
GPIO   &\scalebox{0.8}{\tt 0x0106} & 32 & R/W & GPIO Controller \\\hline
191
UART   &\scalebox{0.8}{\tt 0x0107} & 32 & R/W & UART data\\\hline
192
\end{reglist}
193
\caption{I/O Peripheral Registers}\label{tbl:ioregs}
194
\end{center}\end{table}
195
shows the addresses of various I/O peripherals included as part of the SoC.
196
 
197
The interrupt controller is identical to the one found with the ZipSystem.
198
Please read the ZipSystem documentation for how to control this.
199
 
200
The Bus Error peripheral simply records the address of the last bus error.
201
This can be useful when debugging.  While the peripheral may only be read,
202
setting it is really as easy as creating a bus error and trapping the result.
203
 
204
The two ZipTimer's are ZipSystem timer's, placed onto this peripheral bus.
205
They are available for the CPU to use.  Common uses might include I2C or SPI
206
speed control, or multi--tasking task-swap control.  For further details, please
207
see the ZipSystem documentation.
208
 
209
Audio Controller
210
 
211
Register {\tt KYPAD}, as shown in Fig.~\ref{fig:spioreg},
212
\begin{figure}\begin{center}
213
\begin{bytefield}[endianness=big]{32}
214
\bitheader{0-31} \\
215
\begin{leftwordgroup}{Read}\bitbox[lrt]{16}{Zeros}
216
        \bitbox[lrt]{4}{Kpad}
217
        \bitbox[lrt]{4}{Kpad}
218
        \bitbox[lrt]{2}{00}
219
        \bitbox[lrt]{2}{Btn}
220
        \bitbox[lrt]{4}{LED} \\
221
\bitbox[lrb]{16}{}
222
        \bitbox[lrb]{4}{Col Out}
223
        \bitbox[lrb]{4}{Row In}
224
        \bitbox[lrb]{2}{}
225
        \bitbox[lrb]{2}{}
226
        \bitbox[lrb]{4}{}\end{leftwordgroup} \\
227
\begin{leftwordgroup}{Write}\bitbox[lrt]{16}{Ignored}
228
        \bitbox[lrt]{4}{Col}
229
        \bitbox[lrt]{4}{Col}
230
        \bitbox[lrt]{4}{LED}
231
        \bitbox[lrt]{4}{LED} \\
232
\bitbox[lrb]{16}{}
233
        \bitbox[lrb]{4}{Out}
234
        \bitbox[lrb]{4}{Enable}
235
        \bitbox[lrb]{4}{Enable}
236
        \bitbox[lrb]{4}{}\end{leftwordgroup} \\
237
\end{bytefield}
238
\caption{SPIO Control Register}\label{fig:spioreg}
239
\end{center}\end{figure}
240
is a Special Purpose Input/Output (SPIO) register. It is
241
designed to control the on-board LED's, buttons, and keypad.  Upon any read,
242
the register reads the current state of the keypad column output, the keypad
243
row input, the buttons and the LED's.  Writing is more difficult, in order to
244
make certain that parts of these registers can be modified atomically.
245
Specifically, to change an LED, write the new value as well as a `1' to the
246
corresponding LED change enable bit.  The same goes for the keypad column
247
output, a `1' needs to be written to the change enable bit in order for a
248
new value to be accepted.
249
 
250
The controller will generate a keypad interrupt whenever any row input is
251
zero, and a button interrupt whenever any button value is a one.
252
 
253
The General Purpose Input and Output (GPIO) control register, shown in
254
Fig.~\ref{fig:gpioreg},
255
\begin{figure}\begin{center}
256
\begin{bytefield}[endianness=big]{32}
257
\bitheader{0-31} \\
258
\bitbox[lrtb]{16}{Current Input Vals (x16)}\bitbox[lrt]{16}{Current Output} \\
259
\bitbox[lrtb]{16}{Output Change Enable}\bitbox[lrb]{16}{Values (16-outs)}
260
\end{bytefield}
261
\caption{GPIO Control Register}\label{fig:gpioreg}
262
\end{center}\end{figure}
263
is quite simple to use: when read, the top 16--bits indicate
264
the value of the 16--input GPIO pins, whereas the bottom 16--bits indicate
265
the value being placed on the 16--output GPIO pins.  To change a GPIO pin,
266
write the new pins value to this register, together with setting the
267
corresponding pin in the upper 16--bits.  For example, to set output pin 0,
268
write a {\tt 0x010001} to the GPIO device.  To clear output pin 0, write a
269
{\tt 0x010000}.  This makes it possible to adjust some output pins independent
270
of the others.
271
 
272
The GPIO controller, like the keypad or SPIO controller, will also generate
273
an interrupt.  The GPIO interrupt is generated whenever a GPIO input line
274
changes.
275
 
276
Of the 16 GPIO inputs and the 16 GPIO outputs, two lines have been taken for
277
I2C support.  GPIO line zero, for both input and output, is an I2C data line,
278
and GPIO line one is an I2C clock line.  If the output of either of these
279
lines is set to zero, the GPIO controller will drive the line.  Otherwise,
280
the line is pulled up with a weak resistor so that other devices may
281
pull it low.  If either line is low, when the output control bit is high,
282
it is an indicator that another device is sending data across these wires.
283
 
284
Moving on to the UART \ldots
285
although the UART module within the S6~SoC is highly configurable, as built
286
the UART can only handle 9600~Baud, 8--data bits, no parity, and one stop bit.
287
There is a single byte data buffer, so reading from the port has a real--time
288
requirement associated with it.
289
Attempts to read from this port will either return an 8--bit data value from
290
the port, or if no values are available it will return an {\tt 0x0100}
291
indicating that fact.  In a similar fashion, writes to this port will send
292
the lower 8--bits of the write out the serial port.  If the port is already
293
busy, a single byte will be buffered.
294
 
295
\chapter{Clocks}
296
 
297
The S6~SoC is designed to run off of one master clock.  This clock is derived
298
from the 8~MHz input clock on the board, by multiplying it up to 80~MHz.
299
 
300
\chapter{IO Ports}
301
 
302
See Table.~\ref{tbl:ioports}.
303
\begin{table}[htbp]
304
\begin{center}
305
\begin{portlist}
306
i\_clk\_8mhz & 1 & Input & Clock\\\hline
307
o\_qspi\_cs\_n & 1 & Output & Quad SPI Flash chip select\\\hline
308
o\_qspi\_sck & 1 & Output & Quad SPI Flash clock\\\hline
309
io\_qspi\_dat & 4 & Input/Output & Four-wire SPI flash data bus\\\hline
310
i\_btn & 2 & Input  & Inputs from the two on-board push-buttons\\\hline
311
o\_led & 4 & Output & Outputs controlling the four on-board LED's\\\hline
312
o\_pwm & 1 & Output & Audio output, via pulse width modulator\\\hline
313
\multicolumn{2}{|l|}{o\_pwm\_shutdown\_n, 1}& Output & Audio output shutdown control\\\hline
314
o\_pwm\_gain & 1 & Output & Audio output 20~dB gain enable\\\hline
315
i\_uart & 1 & Input &  UART receive input\\\hline
316
o\_uart & 1 & Output & UART transmit output\\\hline
317
i\_uart\_cts & 1 & Input &  \\\hline
318
o\_uart\_rts & 1 & Output & \\\hline
319
i\_kp\_row & 4 & Output & Four wires to activate the four rows of the keypad\\\hline
320
o\_kp\_col & 4 & Output & Return four wires, from the keypads columns \\\hline
321
i\_gpio & 14 & Output & General purpose logic input lines\\\hline
322
o\_gpio & 14 & Output & General purpose logic output lines\\\hline
323
io\_scl & 1 & Input/Output & I2C clock port\\\hline
324
io\_sda & 1 & Input/Output & I2C data port\\\hline
325
\end{portlist}
326
\caption{List of IO ports}\label{tbl:ioports}
327
\end{center}\end{table}
328 18 dgisselq
 
329
\begin{table}
330
\begin{center}
331
\includegraphics[height=7in]{../gfx/pinout.eps}
332
\caption{Physical Locations of Device I/O Ports}\label{tbl:physicalio}
333
\end{center}\end{table}
334 7 dgisselq
% Appendices
335
% Index
336
\end{document}
337
 
338
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.