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

Subversion Repositories ion

[/] [ion/] [trunk/] [doc/] [src/] [tex/] [soc.tex] - Blame information for rev 221

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 221 ja_rd
 
2
\chapter{SoC Module}
3
\label{soc_module}
4
 
5
The main purpose of the SoC module is to encapsulate the somewhat complex
6
interconnection between the CPU and the Cache/Memory Controller module.
7
 
8
If some project demands that some piece of hardware be directly connected to the
9
CPU, bypassing the cache, this is where it should be -- an MMU comes to mind.
10
 
11
Any peripherals deemed common enough that they will be present in all projects
12
might be placed in the SoC module too.
13
 
14
In the current version of the SoC module, there is only one peripheral included
15
in it -- a hardwired UART module. There is no penalty for placing peripherals
16
ouside the SoC module, so there is no incentive to place them inside. This is
17
an implementation option of yours.\\
18
 
19
Bear in mind that, in its current state, the SoC module is little more than a
20
vehicle for building demos around the ION CPU. It is not meant as a real-world
21
SoC, though it might be deloped into one eventually.
22
 
23
\section{SoC Generics}
24
\label{soc_generics}
25
 
26
    The SoC needs to be configured upon instantiation by setting the following
27
    generics:
28
 
29
\begin{table}[h]
30
\caption{SoC module generics\label{tab_soc_generics}}
31
\begin{tabularx}{\textwidth}{ lll|X }
32
\toprule
33
Name & Type & Default value & Description \\
34
\midrule
35
\texttt{BOOT\_BRAM\_SIZE}      & integer    & 1024  & Bootstrap BRAM size in 32-bit words. \\
36
\texttt{OBJ\_CODE}     & t\_obj\_code & (void code) & Bootstrap BRAM contents. \\
37
\midrule
38
\texttt{CLOCK\_FREQ}   & integer    & 50e6  & Main clock rate. \\
39
\texttt{BAUD\_RATE}    & integer    & 19200  & UART baud rate. \\
40
\midrule
41
\texttt{SRAM\_ADDR\_SIZE} & integer & 17 & Size of SRAM address bus. \\
42
\bottomrule
43
\end{tabularx}
44
\end{table}
45
 
46
The current version of the SoC is not very strict in the enforcement of limits
47
for the generics. You are advised to use only 'reasonable' values. This will
48
be fixed, eventually.
49
 
50
Generic \texttt{CLOCK\_FREQ} is only needed in order to compute the default
51
baud period for the internal UART (from the value of generic \texttt{BAUD\_RATE}).
52
 
53
 
54
Generic \texttt{BOOT\_BRAM\_SIZE} will determine the size of the internal
55
bootstrap BRAM. This generic \emph{can't be zero}; in the current version of
56
the SoC, the BRAM can't be disabled or omitted.
57
 
58
Note that if the size of the bootstrap BRAM is not enough to hold the whole
59
bootstrap code provided in generic \texttt{OBJ\_CODE}, the code \emph{will
60
be sineltly truncated!}. Usually this will result in an early crash.
61
 
62
Generic \texttt{OBJ\_CODE} is used at synthesis time to initialize the bootstrap
63
BRAM. This generic is meant to contain boostrap code, as seen in section
64
~\ref{bootstrap_code}). It can be omitted, in which case the bootstrap BRAM
65
will be initialized to all zeros.
66
 
67
 
68
\section{SoC Ports}
69
\label{soc_ports}
70
 
71
\begin{figure}[h]
72
\makebox[\textwidth]{\framebox[9cm]{\rule{0pt}{9cm}
73
\includegraphics[width=8cm]{img/soc_symbol.png}}}
74
\caption{SoC module interface\label{soc_symbol}}
75
\end{figure}
76
 
77
\begin{table}[h]
78
\caption{SoC module interface ports}
79
\begin{tabularx}{\textwidth}{ lll|X }
80
\toprule
81
Name & Type & Width & Description \\
82
\midrule
83
clk                 & in    & 1  & Clock input, active rising edge. \\
84
reset               & in    & 1  & Synchronous global reset. \\
85
\midrule
86
sram\_address       & out   & 16 & Memory word address (bit 0 absent). \\
87
sram\_data\_wr      & out   & 16 & Memory write data. Only valid when one of the \\
88
                    &       &    & memory byte write enable outputs is active.\\
89
sram\_data\_rd      & in    & 16 & Memory read data. Latched when xxx. \\
90
sram\_byte\_we\_n   & out   & 2  & Memory byte write enable, active low.  \\
91
                    &       &    & (0) enables the low byte (7 downto 0) \\
92
                    &       &    & (1) enables the high byte (15 downto 8). \\
93
\midrule
94
io\_rd\_addr        & out   & 30 & I/O port read address (bits 1..0 absent). \\
95
                    &       &    & Only valid when io\_rd\_vma is high. \\
96
io\_wr\_addr        & out   & 30 & I/O port write address (bits 1..0 absent). \\
97
io\_wr\_data        & out   & 32 & I/O write data.  Only valid when one of the \\
98
                    &       &    & i/o byte write enable outputs is active.\\
99
io\_rd\_data        & in    & 32 & I/O read data. Latched when xxx. \\
100
io\_byte\_we        & out   & 4  & I/O byte write enable, active high. \\
101
                    &       &    & (0) enables the low byte (7 downto 0) \\
102
                    &       &    & (3) enables the high byte (31 downto 24). \\
103
io\_rd\_vma         & out   & 1  & Active high on i/o read cycles. \\
104
\midrule
105
uart\_rxd           & in    & 1  & RxD input to internal UART. \\
106
uart\_txd           & out   & 1  & TxD output from internal UART. \\
107
\midrule
108
interrupt           & in    & 8  & Interrupt request inputs, active high. \\
109
\bottomrule
110
\end{tabularx}
111
\end{table}
112
 
113
As you can see in figure~\ref{soc_symbol} (symbol generated by Xilinx ISE),
114
the SoC has the following interfaces:
115
 
116
\begin{enumerate}
117
    \item Interface to external static asynchronous memory (SRAM, FLASH...).
118
    \item Interface to on-chip peripherals.
119
    \item Interrupt inputs.
120
    \item Debug port.
121
\end{enumerate}
122
 
123
These interfaces will be explained in the following subsections. The top module
124
for the demo supplied with the project (c2sb\_demo.vhdl) will be used for
125
illustration.
126
 
127
\emph{NOTE}: This section needs a lot of elaboration -- ideally this should be
128
equivalent to a datasheet in thoroughness and detail. This work, like many
129
other parts of this project, will have to wait.
130
 
131
\subsection{SoC interface to static memory}
132
\label{soc_if_sram}
133
 
134
The interface to external memory in the SoC module is essentially that of the
135
internal cache/memory controller. Its timing is described in section
136
~\ref{cache_state_machine}.\\
137
 
138
The SoC inputs are meant to be connected straight to the FPGA i/o pins. The only
139
trick is the bidirectional memory data bus: as you can see, the SoC data buses
140
are unidirectional and thus you will need to provide an interconnection
141
external to this module. This interconnection shall include the requisite
142
3-state buffers:
143
 
144
\begin{verbatim}
145
sram_databus <= sram_data_wr when sram_byte_we_n/="11" else (others => 'Z');
146
\end{verbatim}
147
 
148
The top level \emph{c2sb\_demo} module can be used as a fully tested example of
149
how to use this interface to connect to a common 16-bit-wide SRAM chip
150
(ISSI IS61LV25616).
151
 
152
In reviewing the top module source, note that I had to adapt the dual
153
byte-write-enable outputs to the SRAM
154
configuration of a single write-enable plus dual byte-enable inputs.
155
 
156
Note too that the static memory bus of the SoC module is used to access both the 16-bit wide SRAM
157
and an 8-bit wide FLASH. These chips are connected to separate buses on the
158
target board, so the top c2sb\_demo module needs to conflate both buses before connecting
159
them to the SoC. This is why a multiplexor is used in the \texttt{mpu\_sram\_data\_rd}
160
bus. A real-world board would probably have the SRAM and the FLASH connected
161
to the same bus, simplifying the interface logic.
162
 
163
 
164
\subsection{SoC interface to peripherals}
165
\label{soc_if_io}
166
 
167
    Every CPU access to an area designated as I/O (see ~\ref{soc_memory_map}, memory map)
168
    will trigger a read/write cycle on this interface.
169
 
170
    I/O ports are synchronous, byte accesible registers meant to be implemented
171
    within the FPGA. I/O ports do not support wait states.
172
 
173
    The I/O interface has separate input and output buses.
174
 
175
    In an output cycle, one or more lines of signal \texttt{io\_byte\_we} will be
176
    asserted for one clock cycle. Signals \texttt{io\_wr\_addr} and \texttt{io\_wr\_addr} will
177
    be valid as long as \texttt{io\_byte\_we} is asserted.
178
 
179
    In an input cycle, \texttt{io\_rd\_vma} will be asserted for one cycle and the input
180
    data should be present at \texttt{io\_rd\_data} at the end of the following clock
181
    cycle. The full read operation extends over two clock cycles.
182
 
183
\subsection{SoC interrupt inputs}
184
\label{soc_irqs}
185
 
186
    The present version of the CPU does not have support for hardware interrupts
187
    and therefore these signals are not used yet and are unconnected.
188
    Hardware interrupts will be implemented in some future version as
189
    time permits.
190
 
191
\subsection{SoC debug port}
192
\label{soc_debug_port}
193
 
194
    The debug port is a VHDL record (\texttt{t\_debug\_info}, defined in
195
    package \emph{mips\_pkg}), which holds some internal CPU status flags that
196
    can be useful while debugging the core. It is not meant to be useful for
197
    a real application.
198
 
199
    Currently the record holds only two flags:
200
 
201
    \begin{itemize}
202
    \item \texttt{cache\_enabled}, asserted when the cache is enabled.
203
    \item \texttt{unmapped\_access}, asserted when some access to an unmapped
204
    address is made.
205
    \end{itemize}
206
 
207
    The current version of the demo connects these signals to some on-board
208
    LEDs.
209
 
210
 
211
\section{SoC Memory Map}
212
\label{soc_memory_map}
213
 
214
    The \emph{memory map} determines the type of memory that is connected to
215
    each of a number of predefined address rangess (see section
216
    ~\ref{memory_map_definition}).
217
    It is defined in package \emph{mips\_pkg} and it is implemented in the
218
    \emph{mips\_cache} module.
219
 
220
\begin{table}[h]
221
\caption{SoC module memory map\label{tab_soc_memory_map}}
222
\begin{tabularx}{\textwidth}{ lll|X }
223
\toprule
224
Address range & Type & Wait States & Intended usage \\
225
\midrule
226
\texttt{0xb8000000-0xbfffffff}   & BRAM    & 0  & SoC internal boot BRAM. \\
227
\midrule
228
\texttt{0x00000000-0x07ffffff}   & SRAM-16 & 2  & Off-chip SRAM. \\
229
\texttt{0x80000000-0x87ffffff}   & SRAM-16 & 2  & Off-chip SRAM. \\
230
\texttt{0x20000000-0x27ffffff}   & I/O     & 0  & On-chip I/O registers. \\
231
\texttt{0xb0000000-0xb7ffffff}   & SRAM-8  & 7  & Off-chip SRAM or FLASH. \\
232
\bottomrule
233
\end{tabularx}
234
\end{table}
235
 
236
 
237
\section{SoC UART}
238
\label{soc_uart}
239
 
240
    The current revision of the SoC includes a single peripheral, a hardwired
241
    8-bit UART (file \emph{uart.vhdl}).
242
 
243
    This UART is an 8-bit module built for some other unrelated project of mine
244
    and commandeered to serve on this SoC. Therefore, it has some features
245
    (like its 8-bit interface) which are sub-optimal for this application and/or
246
    are not used.
247
 
248
    The UART is 'hardwired' because some of its operational parameters are
249
    hardcoded and can't be changed even at synthesis time. Namely:
250
 
251
    \begin{itemize}
252
    \item Stop bits: 1.
253
    \item Parity: None.
254
    \item Bits per character: 8.
255
    \end{itemize}
256
 
257
    All other parameters can at least be configured at synthesis time, and
258
    under some conditions can be configured at run time too. The interested
259
    user must read the module source for a better explaination of these
260
    features. This document will only deal with the UART module as it is
261
    instantiated in the SoC.
262
 
263
 
264
    These are the UART control registers:
265
 
266
    \begin{table}[h]
267
    \caption{UART control registers\label{uart_control_regs}}
268
    \begin{tabularx}{\textwidth}{ ll|X }
269
    \toprule
270
    Byte Address & Word Address & Register \\
271
    \midrule
272
    \texttt{0x20000003}   & \texttt{0x20000000} & Tx/Rx Buffer \\
273
    \texttt{0x20000007}   & \texttt{0x20000004} & Status. \\
274
    \texttt{0x2000000b}   & \texttt{0x20000008} & Baud rate period, low byte. \\
275
    \texttt{0x2000000f}   & \texttt{0x2000000c} & Baud rate period, high byte. \\
276
    \bottomrule
277
    \end{tabularx}
278
    \end{table}
279
 
280
 
281
    All of these registers are mapped to the byte address given in the table,
282
    that is, they are mapped on the \emph{low} byte of the 32-bit word they
283
    belong to -- you don't have to worry about this unless you use a word
284
    pointer to access these registers.
285
 
286
 
287
\subsection{UART Usage}
288
\label{soc_uart_usage}
289
 
290
    Until hardware interrupts are implemented, you have to rely on polling to
291
    use the UART.
292
 
293
    When you want to transmit, you wait until flag TxRdy is '1' and then write
294
    to the Tx Buffer. That will clear TxRdy until the transmission is done.
295
    Writing to the Tx Buffer will NOT clear flag TxIrq.
296
 
297
    Writing to the Tx Buffer while TxRdy is '0' will have no effect.
298
 
299
    When you want to read received data, you wait until RxRdy is '1' and then
300
    read the Rx Buffer. Reading the Rx Buffer will clear flag RxRdy until a new
301
    byte arrives.
302
    Reading the RxBuffer while RxRdy is '0' will return undefined data.
303
    Reading the Rx Buffer will NOT clear flag RxIrq.
304
 
305
    Of course, once hardware interrupts are implemented, you will use them
306
    instead of polling, but this is the basic mechanics. Same as any old UART,
307
    really.
308
 
309
 
310
 
311
\subsection{UART Status Register}
312
\label{soc_status_reg}
313
 
314
    These are the flags present in the status register:
315
 
316
 
317
\needspace{7\baselineskip}
318
\begin{verbatim}
319
  UART Status Register
320
 
321
      7       6       5       4       3       2       1       0
322
  +-------+-------+-------+-------+-------+-------+-------+-------+
323
  |   0   |   0   | RxIrq | TxIrq |   0   |   0   | RxRdy | TxRdy |
324
  +-------+-------+-------+-------+-------+-------+-------+-------+
325
      h       h      W1C     W1C      h       h       r       r
326
\end{verbatim}
327
 
328
 
329
    Bits marked 'h' are hardwired and can't be modified.
330
 
331
    Bits marked 'r' are read only; they are set and clear by the UART core.
332
 
333
    Bits marked W1C ('Write 1 Clear') are set by the UART core when an interrupt
334
    has been triggered and must be cleared by the software by writing a '1'.
335
 
336
    \begin{itemize}
337
    \item Status bit TxRdy is high when there isn't any transmission in progress.
338
            It is cleared when data is written to the transmission buffer and is
339
            raised at the same time the transmission interrupt is triggered.
340
    \item Status bit RxRdy is raised at the same time the receive interrupt is
341
            triggered and is cleared when the data register is read.
342
    \item Status bit TxIrq is raised when the transmission interrupt is triggered
343
            and is cleared when a 1 is written to it.
344
    \item Status bit RxIrq is raised when the reception interrupt is triggered
345
            and is cleared when a 1 is written to it.
346
    \end{itemize}
347
 
348
    When writing to the status/control registers, only flags TxIrq and RxIrq are
349
    affected, and only when writing a '1' as explained above. All other flags
350
    are read-only.
351
 
352
 
353
\subsection{UART Baud Rate Registers}
354
\label{soc_uart_baud_regs}
355
 
356
    When the UART module generic 'HARDWIRED' is set to 'false', these registers
357
    can be written to in order to configure the baud rate -- see the source for
358
    details.
359
 
360
    When the UART module generic 'HARDWIRED' is set to 'true', these registers
361
    are frozen and can't be modified. This is how the module is instantiated in
362
    the current version of the SoC.
363
 
364
    In either case, these are write-only registers: reading them will return
365
    the contents of the status register (simplified multiplexor).
366
 
367
    The baud rate is configured by loading these registers with the baud period
368
    in clock cycles.
369
 
370
 
371
\subsection{UART Interrupt}
372
\label{soc_uart_interrupts}
373
 
374
    The UART can trigger an interrupt (i.e. assert its interrupt output for one
375
    clock cycle) whenever a character is received or transmitted. The UART
376
    source explains in detail exactly when these interrupts are triggered.
377
 
378
    The interrupt status is kept in two flags on the status register that can
379
    be used for interrupt polling. Note there's no way to tell what kind of
380
    interrupt we got other than looking at those flags.
381
 
382
    Since the current CPU revision does not support hardware interrupts, this
383
    feature is still unused and the interrupt line is unconnected.
384
    Again, details can be found in the UART module source.
385
 
386
 
387
 
388
 
389
 
390
 
391
 
392
 
393
 
394
 
395
 
396
 
397
 

powered by: WebSVN 2.1.0

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