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

Subversion Repositories wbuart32

[/] [wbuart32/] [trunk/] [doc/] [src/] [spec.tex] - Blame information for rev 5

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

Line No. Rev Author Line
1 2 dgisselq
\documentclass{gqtekspec}
2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3
%%
4
%% Filename:    spec.tex
5
%%
6
%% Project:     wbuart32, a full featured UART with simulator
7
%%
8
%% Purpose:     To describe, for LaTeX, how to build the specification file
9
%%              for the wbuart32 core(s).  This file is not nearly as
10
%%      interesting as the file it creates, so I suggest you read spec.pdf
11
%%      first, before deciding you are really interested in this file.
12
%%
13
%% Creator:     Dan Gisselquist, Ph.D.
14
%%              Gisselquist Technology, LLC
15
%%
16
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17
%%
18
%% Copyright (C) 2015-2016, Gisselquist Technology, LLC
19
%%
20
%% This program is free software (firmware): you can redistribute it and/or
21
%% modify it under the terms of  the GNU General Public License as published
22
%% by the Free Software Foundation, either version 3 of the License, or (at
23
%% your option) any later version.
24
%%
25
%% This program is distributed in the hope that it will be useful, but WITHOUT
26
%% ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
27
%% FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28
%% for more details.
29
%%
30
%% You should have received a copy of the GNU General Public License along
31
%% with this program.  (It's in the $(ROOT)/doc directory, run make with no
32
%% target there if the PDF file isn't present.)  If not, see
33
%% <http://www.gnu.org/licenses/> for a copy.
34
%%
35
%% License:     GPL, v3, as defined and found on www.gnu.org,
36
%%              http://www.gnu.org/licenses/gpl.html
37
%%
38
%%
39
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40
%%
41
%%
42
\usepackage{import}
43
\usepackage{bytefield}
44
\usepackage{amsmath}
45
\project{WBUART32}
46
\title{Specification}
47
\author{Dan Gisselquist, Ph.D.}
48 5 dgisselq
\email{dgisselq (at) ieee.org}
49 2 dgisselq
\revision{Rev.~0.1}
50
\begin{document}
51
\pagestyle{gqtekspecplain}
52
\titlepage
53
\begin{license}
54 5 dgisselq
Copyright (C) 2016--2017, Gisselquist Technology, LLC.
55 2 dgisselq
 
56
This project is free software (firmware): you can redistribute it and/or
57
modify it under the terms of  the GNU General Public License as published
58
by the Free Software Foundation, either version 3 of the License, or (at
59
your option) any later version.
60
 
61
This program is distributed in the hope that it will be useful, but WITHOUT
62
ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
63
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
64
for more details.
65
 
66
You should have received a copy of the GNU General Public License along
67
with this program.  If not, see \texttt{http://www.gnu.org/licenses/} for a copy.
68
\end{license}
69
\begin{revisionhistory}
70 5 dgisselq
0.2 & 1/03/2017 & D. Gisselquist & Added test-bench information\\\hline
71 2 dgisselq
0.1 & 8/26/2016 & D. Gisselquist & Initial Draft Specification\\\hline
72
\end{revisionhistory}
73
% Revision History
74
% Table of Contents, named Contents
75
\tableofcontents
76
\listoffigures
77
\listoftables
78
\begin{preface}
79
It may be that building a UART is a mandatory coming of age task for any HDL
80
designer.  The task is simple, easy, and there's not all that much to it.
81
This project comes out of some of my first experiences with Verilog.
82
 
83 5 dgisselq
Since then, it has been augmented with quite a few useful capabilities for
84 2 dgisselq
simulating a UART connection when using Verilator.  It is this, perhaps
85
unusual, addition to the core set that makes this core worth taking note of.
86
 
87
I hope you find it useful.
88
\end{preface}
89
 
90
\chapter{Introduction}\label{ch:intro}
91
\pagenumbering{arabic}
92
\setcounter{page}{1}
93
%
94
% Introduction
95
%
96
% This section contains the introduction to the core, describing both its
97
% use and its features.
98
%
99
 
100
% What is old
101
The Universal Asynchronous Serial Transport, or UART, has become quite the
102
common protocol between devices.  It is simple to wire up, easy to use, and
103
easy to process.  This core provides one implementation of the logic necessary
104
to use such a communications scheme.
105
 
106
% What does the old lack?
107
% What is new
108
% What does the new have that the old lacks
109
% What performance gain can be expected?
110
 
111
While you are likely to find many UART examples out there, this particular
112
UART implementation offers something many of these other examples do not: a
113
Verilator simulation capability.  This will allow the user to connect, via
114
a TCP/IP port or a telnet application, to the UART of their desired chip.  As
115
a result, full two-way interaction can be had between a simulation and a
116
terminal or other port.  Indeed, this may even be sufficient to connect a
117
CPU, capable of running Linux, to a terminal to verify that yes it can truly
118
run Linux--all within Verilator.
119
 
120 5 dgisselq
As a final addition, there are three files in the test bench section which can
121
be used as top--level design files to prove whether or not the serial port on
122
a given circuit board works.
123
 
124 2 dgisselq
\chapter{Architecture}\label{ch:arch}
125
 
126 5 dgisselq
The HDL portion of the core itself consists of four basic files: {\tt rxuart.v},
127
{\tt txuart.v}, {\tt ufifo.v} and {\tt wbuart.v}.  These are, respectively, the
128
receive UART code, the transmit UART code, a fairly generic FIFO, and a fully
129
wishbone compliant UART peripheral.  This latter files demonstrates one example
130
of how the receiver, transmitter, and FIFOs may be connected to a Wishbone bus.
131
A fifth file, {\tt wbuart-insert.v}, demonstrates how the {\tt rxuart.v} and
132
{\tt txuart.v} files may be included into a module implementing a simpler
133
interface.
134 2 dgisselq
 
135
Each of the core files, {\tt rxuart.v} and {\tt txuart.v}, are fully capable.
136
They each accept a 29--bit setup value specifying baud rate, the number of bits
137
per byte (between 5 and 8), whether or not parity is used, whether that parity
138
is even, odd, or fixed mark or fixed space.  This setup register will be
139
discussed further in Chap.\ref{ch:registers}.
140
 
141
A further note on the {\tt rxuart.v} module is in order.  This module double
142
latches the input, in the proper two buffer fashion to avoid problems with
143
metastability.  Then, upon the detection of the start bit (i.e. a high to low
144
transition), the port waits a half of a baud, and then starts its baud clock
145
so as to sample in the middle of every baud following.  The result of this is
146
a timing requirement: after $N+2$ baud intervals ($N+3$ if parity is used),
147
where $N$ is the number of bits per byte, this calculated middle sample must
148
still lie within the associated bit period.  This leaves us with the criteria
149
that,
150
\begin{eqnarray}
151
\left|\left(N+2\right)
152
        \left(\frac{f_{\mbox{\tiny SYS}}}{f_{\mbox{\tiny BAUD}}}
153
                -{\mbox{\tt CKS}}\right)\right|
154
        &<& \frac{f_{\mbox{\tiny SYS}}}{2f_{\mbox{\tiny BAUD}}},
155
        \label{eqn:baudlimit}.
156
\end{eqnarray}
157
where $f_{\mbox{\tiny SYS}}$ is the system clock frequency,
158
$f_{\mbox{\tiny BAUD}}$ is the baud rate or frequency,
159
{\tt CKS} is the number of clocks per baud as set in the configuration
160
register, and $N$ is the number of bits per byte.  What this means is that,
161
for transmission rates where $f_{\mbox{\tiny BAUD}}$ approaches
162
$f_{\mbox{\tiny SYS}}$, the number of data rates that can actually be
163
synthesized becomes limited.
164
 
165
Connecting to either {\tt txuart.v} or {\tt rxuart.v} is quite simple.  Both
166
files have a data port and a strobe.  To transmit, set the data and strobe
167
lines.  Drop the strobe line as soon as the strobe is asserted and the busy line
168 5 dgisselq
is not.
169
Likewise, to connect to the {\tt rxuart.v} port, there is a data
170
and a strobe.  This time, though, these two wires are outputs of the receive
171
module as opposed to inputs.
172 2 dgisselq
When the strobe is high, the data is valid.  It will only be high for one
173
clock period.  If you wish to connect this output to a bus, a register will be
174
needed to hold the strobe high until the data is read.  Also, while the strobe
175 5 dgisselq
is high, the {\tt o\_frame\_err} will indicate whether or not there was a
176 2 dgisselq
framing error (i.e., no stop bit), and {\tt o\_parity\_err} will indicate
177 5 dgisselq
whether or not the parity matched.  Finally, the {\tt o\_break} line will
178
indicate whether the receiver is in a ``break'' state,
179 2 dgisselq
 
180
The {\tt tx\_busy} line may be inverted and connected to a transmit interrupt
181
line.  In a similar fashion, the {\tt rx\_stb} line, or the bus equivalent of
182 5 dgisselq
{\tt rx\_ready}, may be used for receive interrupt lines--although it will need
183
to be latched as both {\tt wbuart.v} and {\tt wbuart-insert.v} demonstrate.
184 2 dgisselq
 
185 5 dgisselq
An simple example of how to put this configuration together is found in
186 2 dgisselq
{\tt wbuart-insert.v}.  In this example given, the {\tt rx\_data} register
187
will have only the lower eight bits set if the data is valid, higher bits will
188
be set upon error conditions, and cleared automatically upon the next byte read.
189
In a similar fashion, the {\tt tx\_data} register can be written to with a byte
190
in order to transmit that byte.  Writing bit nine will place the transmitter
191
into a ``break'' condition, only cleared by writing a zero to that bit later.
192
Reading from the {\tt tx\_data} register can also be used to determine if the
193
transmitter is busy (via polling), whether it is currently in a break condition,
194
or even what bit is currently being placed to the output port.
195
 
196 5 dgisselq
A more comprehensive example of how these UART modules may be used together
197
can be found in {\tt wbuart.v}.  This file provides a full wishbone interface
198
allowing interaction with the core using four registers: a setup register,
199
receive register and transmit register as before, as well as a FIFO health
200
register through which the size and fill of the FIFO can be queried.
201
 
202 2 dgisselq
The C++ simulation portion of the code revolves around the file
203
{\tt bench/cpp/uartsim.cpp} and its associated header.  This file defines a
204
class, {\tt UARTSIM}, which can be used to connect the UART to a TCP/IP stream.
205
When initialized, this class takes, as input, the TCP/IP port number that the
206 5 dgisselq
class is to connect with.  Setting the port to zero connects the UART to
207
the standard input and output file facilities.  Once connected, using this
208
simulator is as simple as calculating the receive input bit from the transmit
209
output bit when the clock is low, and the core takes care of everything else.
210 2 dgisselq
 
211 5 dgisselq
Finally, there are a series of example files found in the bench/verilog
212
directory.  {\tt helloworld.v} presents an example of a simple UART transmitter
213
sending the ``Hello, World \\r\\n'' message over and over again.  This example
214
uses only the {\tt txuart.v} module, and can be simulated in Verilator.
215
A second test file, {\tt linetest.v}, works by waiting for a line of data to be
216
received, after which it parrots that line back to the terminal.  This tests
217
both {\tt txuart.v} and {\tt rxuart.v}.  A third test file, {\tt speechfifo.v}
218
tests both the wishbone interface as well as the FIFO, by filling the UART,
219
10~samples at a time, with text from Abraham Lincoln's Gettysburg address.
220
All three of these files have an internal option to define
221
{\tt OPT\_STANDALONE}.  If and when defined, they may be used as top--level
222
files as part of a UART test.
223
 
224 2 dgisselq
\chapter{Operation}\label{ch:ops}
225
 
226
% This section describes the operation of the core.  Specific sequences, such
227
% as startup sequences, as well as the modes and states of the block should be
228
% described.
229
%
230
 
231
To use the core, a couple of steps are required.  First, wire it up.  The
232 5 dgisselq
{\tt rxuart.v} and {\tt txuart.v} files may be wired up for use individually,
233
or using an example such as {\tt wbuart-insert.v}.  Alternatively, the
234
{\tt wbuart.v} file may be connected to a straight 32--bit wishbone bus.
235
Second, set the UART configuration register.  This is ideally set by setting
236
the {\tt INITIAL\_SETUP} parameter of {\tt rxuart}, {\tt txuart} or even
237
{\tt wbuart.v}  Alternatively, you can write to the setup register at a later
238
time, as is done with the {\tt speechfifo.v} bench test.
239 2 dgisselq
 
240 5 dgisselq
From a simulation standpoint, it will also need to be ``wired'' up in your
241
C++ main Verilator file.  Somewhere, internal to the top--level Verilator
242
C++ simulation file, you'll want to have some setup lines similar to,
243 2 dgisselq
\begin{tabbing}
244 5 dgisselq
\hbox to 3.0in{\tt \#include "uartsim.h"} \= {\em // Tell compiler about UARTSIM}\\
245
\vdots \\
246
{\tt UARTSIM *uartsim;} \> {\em // Declare a variable to hold the simulator}\\
247
{\tt uartsim = new UARTSIM(ip\_port);} \> {\em // Create/initialize it with your TCP/IP port \#} \\
248
{\tt uartsim->setup(setup\_register\_value);} \> {\em // Tell it the line coding to expect}\\
249
\end{tabbing}
250
and then another set of lines within your clocked section that look something
251
like,
252
\begin{tabbing}
253 2 dgisselq
{\tt if (!clk)} \= \\
254 5 dgisselq
\> {\tt tb->i\_uart\_rx} {\tt = } {\tt uartsim(tb->o\_uart\_tx);}
255 2 dgisselq
\end{tabbing}
256 5 dgisselq
You should be able to find several examples of this in the {\tt helloworld.cpp},
257
{\tt linetest.cpp}, and {\tt speechtest.cpp} files.  These C++ implementations,
258
though, are also complicated by the need for a self--contained testing program
259
to be able to capture and know what was placed onto the standard input and
260
output streams, hence many of them fork() into two processes so that one
261
process can verify the output of the other.  Both {\tt speechtest.cpp} and
262
{\tt linetest.cpp} allow a {\em -i} option to run in an interactive mode without
263
forking.  Either way, forking the simulation program shouldn't be needed for
264
normal usages of these techniques, but you may find it helpful to know should
265
you examine this code or should you wish to build your own test file that
266
proves its own output.
267 2 dgisselq
 
268
To use the transmitter, set the {\tt i\_stb} and {\tt i\_data} wires.  Drop
269
the strobe line any time after {\tt (i\_stb)\&\&(!o\_busy)}.
270
 
271
To use the receiver, grab the data any time {\tt o\_stb} is true.
272
 
273
From the standpoint of the bus, there are two ways to handle receiving and
274
transmitting: polling and interrupt based, although both work one character at
275 5 dgisselq
a time.  To poll, repeatedly read the receive data register until only bits from
276
the bottom eight are set.  This is an indication that the byte is
277 2 dgisselq
valid.  Alternatively, you could wait until the an interrupt line is set and
278 5 dgisselq
then read.  In the {\tt wbuart-insert.v} example as well as the {\tt wbuart.v}
279
implementation, the {\tt o\_uart\_rx\_int} line will be set ({\tt rx\_int} for
280
{\tt wbuart-insert.v}), and automatically cleared upon any read.  To write,
281
one can read from the transmit data register until the eighth bit, the
282
{\tt tx\_busy} bit, is cleared, and then transmit.  Alternatively, this
283
negation of this bit may be connected to an interrupt line,
284
{\tt o\_uart\_tx\_int}.  Writing to the port while the transmitter is idle will
285
start it transmitting.  Writing to the port while it is busy will fill a one
286
word buffer that will get sent as soon as the port is idle for one clock.
287 2 dgisselq
 
288
 
289
\chapter{Registers}\label{ch:registers}
290
% This section specifies all internal registers.  It should completely cover
291
% the interface between the CPU and the host as seen from the software point
292
% of view.
293
 
294
% List of Registers
295
 
296
% Register 1 Description
297
%
298
% You shall choose the style of register you prefer.  Do not use both options
299
% in one and the same document.  (Table of bits, vs. byetarray type of
300
% description).
301
 
302 5 dgisselq
The {\tt wbuart} core supports four registers, shown in Tbl.~\ref{tbl:reglist}.
303
\begin{table}\begin{center}\begin{reglist}
304
{\tt SETUP}   & 2'b00 & 30 & R/W & UART configuration/setup register.\\\hline
305
{\tt FIFO}    & 2'b01 & 32 & R & Returns size and status of the FIFOs\\\hline
306
{\tt RX\_DATA}& 2'b10 & 13 & R & Read data, reads from the UART.\\\hline
307
{\tt TX\_DATA}& 2'b11 & 15 & (R/)W & Transmit data: writes send out the UART.
308
                \\\hline
309 2 dgisselq
\end{reglist}\caption{UART Registers}\label{tbl:reglist}
310
\end{center}\end{table}
311 5 dgisselq
We'll cover the format of all of these registers here, as they are defined by
312
{\tt wbuart.v}.
313 2 dgisselq
 
314
\section{Setup Register}
315
The setup register is perhaps the most critical of all the registers.  This
316
is shown in Fig.\ref{fig:SETUP}.
317
\begin{figure}\begin{center}
318
\begin{bytefield}[endianness=big]{32}
319
\bitheader{0-31}\\
320
\bitbox{2}{00}
321
\bitbox{2}{N}
322
\bitbox{1}{S}
323
\bitbox{1}{P}
324
\bitbox{1}{F}
325
\bitbox{1}{T}
326
\bitbox{24}{Baud CLKS}
327
\end{bytefield}
328
\caption{SETUP Register fields}\label{fig:SETUP}
329
\end{center}\end{figure}
330
It is designed so that, for any 8N1 protocol (eight data bits, no parity, one
331 5 dgisselq
stop bit), all of the upper bits will be set to zero so that only the number of
332
clocks per baud interval needs to be set.  The top two bits are unused, making
333
this a 30--bit number.\footnote{The top two bits are ideally suited for adding
334
in a user configurable hardware flow control: one for flow control in use, zero
335
otherwise, but this is only a future upgrade possibility as of this writing.}
336
The other fields are: $N$ sets the number of bits per word.  A value of zero
337
corresponds to 8--bit words, a value of one to seven bit words, and so forth up
338
to a value of three for five bit words.  $S$ determines the number of stop
339
bits.  Set this to one for two stop bits, or leave it at zero for a single
340
stop bit.  $P$ determines whether or not a parity bit is used (1~for parity,
341
0~for no parity), while $F$ determines whether or not the parity is fixed.
342
Tbl.~\ref{tbl:parity} lists out the various values possible here.
343 2 dgisselq
\begin{table}\begin{center}
344
\begin{tabular}{ccc|l}
345
P&F&T&Setting \\\hline\hline
346
1 & 0 & 0 & Odd parity          \\\hline
347
1 & 0 & 1 & Even parity \\\hline
348
1 & 1 & 0 & Parity bit is a Space (1'b0)\\\hline
349
1 & 1 & 1 & Parity bit is a Mark (1'b1)\\\hline
350
 
351
\end{tabular}\caption{Parity setup}\label{tbl:parity}
352
\end{center}\end{table}
353
 
354 5 dgisselq
Changes to this setup register will take place in the transmitter as soon as
355
the transmitter is idle and ready to accept another byte.
356
 
357
Changes to this setup register in {\tt rxuart.v} also take place between bytes.
358
However, within the {\tt wbuart.v} context, any changes to the setup register
359
will also reset the receiver and receive FIFO together.  Once reset, the
360
receiver will insist on a minimum of sixteen idle baud intervals before
361
receiving the next byte.
362
 
363
\section{FIFO Register}
364
The FIFO register is a read--only register containing information about the
365
status of both receive and transmit FIFOs within it.  The transmit FIFO
366
information is kept in the upper 16--bits, and the receiver FIFO information
367
in the lower 1-bits, as shown in Fig.~\ref{fig:FIFO}.
368
\begin{figure}\begin{center}
369
\begin{bytefield}[endianness=big]{32}
370
\bitheader{0-31}\\
371
\bitbox[rlt]{4}{LGLN}
372
\bitbox[rlt]{10}{TX Fill}
373
\bitbox[rlt]{1}{H}
374
\bitbox[rlt]{1}{Z}
375
\bitbox[rlt]{4}{}
376
\bitbox[rlt]{10}{}
377
\bitbox[rlt]{1}{}
378
\bitbox[rlt]{1}{} \\
379
\bitbox[rlb]{4}{}
380
\bitbox[rlb]{10}{}
381
\bitbox[rlb]{1}{}
382
\bitbox[rlb]{1}{}
383
\bitbox[rlb]{4}{LGLN}
384
\bitbox[rlb]{10}{RX Fill}
385
\bitbox[rlb]{1}{H}
386
\bitbox[rlb]{1}{Z} \\
387
\end{bytefield}
388
\caption{RXDATA Register fields}\label{fig:FIFO}
389
\end{center}\end{figure}
390
We'll discuss each of these bits individually.
391
 
392
The {\tt LGLN} field indicates the log base two of the FIFO length.  Hence an
393
{\tt LGLN} field of four would indicate a FIFO length of sixteen values.
394
The FIFO fill indicates the current level of fill.  The $H$ bit will be true
395
if the FIFO is half full, and the $Z$ bit will be true if the FIFO is non-empty.
396
 
397
The $H$ and $Z$ bits also mirror the interrupt bits generated by {\tt wbuart.v}.
398
Interrupts will be generated any time the FIFO is half full (on receive), or
399
less than half full (on transmit). The same logic applies for the $Z$ bit.
400
 
401
Writes to this register are quietly ignored.
402
 
403 2 dgisselq
\section{RX\_DATA Register}
404
Fig.~\ref{fig:RXDATA}
405
\begin{figure}\begin{center}
406
\begin{bytefield}[endianness=big]{32}
407
\bitheader{0-31}\\
408 5 dgisselq
\bitbox[rlt]{19}{19'h00}
409
\bitbox{1}{E}
410
\bitbox[rlt]{1}{B}
411
\bitbox[rlt]{1}{F}
412
\bitbox[rlt]{1}{P}
413
\bitbox[rlt]{1}{S}
414
\bitbox[rlt]{8}{RWORD} \\
415
\bitbox[lrb]{19}{}
416
\bitbox{1}{-}
417
\bitbox[lrb]{1}{}
418
\bitbox[lrb]{1}{}
419
\bitbox[lrb]{1}{}
420
\bitbox[lrb]{1}{}
421
\bitbox[lrb]{8}{}
422 2 dgisselq
\end{bytefield}
423
\caption{RXDATA Register fields}\label{fig:RXDATA}
424
\end{center}\end{figure}
425
breaks out the various bit fields of the receive
426 5 dgisselq
data register used in {\tt wbuart.v}.  In particular, the $B$ field indicates
427
that the receive line is in a break condition.  The $F$ and $P$ fields indicate
428
that a frame error or parity error has been detected.  These bits are not self
429
clearing, but rather are cleared by writing to 1's to them.  The $S$ field will
430
be false when the {\tt RWORD} is valid.  Hence, if {\tt (RWORD \& ~0x0ff)} is
431
zero there is a word ready to be received without error.
432 2 dgisselq
 
433 5 dgisselq
The $E$ bit is an error bit.  When set, it indicates that the FIFO has
434
overflowed sometime since the last reset.  This bit is also a reset bit.
435
In other words, writing a {\tt 1'b0} to this bit will command a receive
436
reset: clearing the FIFO, and waiting for the line to be idle before receiving
437
another byte.  This bit is not implemented in {\tt wbuart-insert.v}, but
438
exists in the {\tt wbuart.v} implementation.
439
 
440 2 dgisselq
\section{TX\_DATA Register}
441
Fig.~\ref{fig:TXDATA}
442
\begin{figure}\begin{center}
443
\begin{bytefield}[endianness=big]{32}
444
\bitheader{0-31}\\
445 5 dgisselq
\bitbox[lrt]{17}{17'h00}
446
\bitbox{1}{H}
447
\bitbox{1}{Z}
448
\bitbox{1}{E}
449
\bitbox[lrt]{1}{C}
450
\bitbox[lrt]{1}{O}
451
\bitbox[lrt]{1}{B}
452
\bitbox[lrt]{1}{S}
453
\bitbox[lrt]{8}{TWORD} \\
454
\bitbox[lrb]{17}{}
455
\bitbox{3}{3'h0}
456
\bitbox[lrb]{1}{}
457
\bitbox[lrb]{1}{}
458
\bitbox[lrb]{1}{}
459
\bitbox[lrb]{1}{}
460
\bitbox[lrb]{8}{}
461 2 dgisselq
\end{bytefield}
462
\caption{TXDATA Register fields}\label{fig:TXDATA}
463
\end{center}\end{figure}
464
breaks out the various bit fields of the transmit data register used in
465 5 dgisselq
{\tt wbuart.v}.  The $C$ field indicates whether or not the receive
466 2 dgisselq
data line is high or low, the $O$ field indicates the same for the transmit
467 5 dgisselq
line.  These aren't particularly useful or valuable, but the $C$ bit doesn't
468
fit in the receive data register since it would violate the error condition
469
detector.  These two bits are thrown in here for whatever useful purpose one
470
might find.  The $B$ field, when set, sends a break condition down the wire.
471
Further, writes to the TXDATA register while in a break condition and with the
472
$B$ field clear, will clear the transmitter from any break condition without
473
transmitting anything.  The $S$ field is similar to the RXDATA strobe register.
474
It is a read--only bit that will be true any time the transmitter is busy.
475
It will be clear only when the transmitter is idle.
476 2 dgisselq
 
477 5 dgisselq
The final three bits, $H$, $Z$, and $E$, are present only in {\tt wbuart.v}.
478
These bits indicate $H$ if the FIFO is at least half full, $Z$ if the FIFO is
479
empty, and $E$ if the FIFO has experienced an overflow condition since the
480
last reset. Writing a {\tt 1'b1} to the $E$ bit will reset the transmit FIFO,
481
both clearing any error indication in the FIFO as well as clearing the FIFO
482
itself.
483 2 dgisselq
 
484 5 dgisselq
To use the transmitter, simply write a byte to the TXDATA register
485
with the upper 24--bits clear to transmit.
486
 
487 2 dgisselq
\chapter{Clocks}\label{ch:clocks}
488
The UART has been tested with a clock as fast as 200~MHz
489
(Tbl.~\ref{tbl:clocks}).
490
\begin{table}\begin{center}
491
\begin{clocklist}
492
{\tt i\_clk} & (System) & 200~MHz & & System clock\\\hline
493
\end{clocklist}
494
\caption{Clock Requirements}\label{tbl:clocks}
495
\end{center}\end{table}
496
It should be able to use slower clocks, but only subject to the ability to
497
properly set the baud rate as shown in Eqn.~\eqref{eqn:baudlimit} on
498
Page~\pageref{eqn:baudlimit}.
499
 
500
I do not recommend using this core with a baud rate greater than a quarter
501
of the system clock rate.
502
 
503
% This section specifies all of the clocks.  All clocks, clock domain passes
504
% and the clock relations should be described.
505
 
506
% Name | Source |    Rates (MHz)    | Remarks | Description
507
%               | Max|Min|Resolution|
508
\chapter{Wishbone Datasheet}\label{ch:wishbone}
509
 
510
Tbl.~\ref{tbl:wishbone}
511 5 dgisselq
\begin{table}[htbp]\begin{center}\begin{tabular}{|p{2.5in}|p{3.5in}|}\hline
512
\rowcolor[gray]{0.85} Description & Specification \\\hline\hline
513 2 dgisselq
Revision level of wishbone & WB B4 spec \\\hline
514
Type of interface & Slave, Read/Write, pipeline reads supported \\\hline
515
Port size & 32--bit \\\hline
516
Port granularity & 32--bit \\\hline
517
Maximum Operand Size & 32--bit \\\hline
518
Data transfer ordering & (Irrelevant) \\\hline
519
Clock constraints & None.\\\hline
520 5 dgisselq
Signal Names & \begin{tabular}{lll}
521
                {\tt wbuart.v} & {\tt wbuart-insert.v} & WB Equivalent \\\hline
522
                {\tt i\_clk} & {\tt i\_wb\_clk} & {\tt CLK\_I} \\
523
                {\tt i\_rst} & & {\tt RST\_I} \\
524
                {\tt i\_wb\_cyc}   & {\tt i\_wb\_cyc} & {\tt CYC\_I} \\
525
                {\tt i\_wb\_stb}   & {\tt i\_wb\_stb} & {\tt STB\_I} \\
526
                {\tt i\_wb\_we}    & {\tt i\_wb\_we} & {\tt WE\_I} \\
527
                {\tt i\_wb\_addr}  & {\tt i\_wb\_addr} & {\tt ADR\_I} \\
528
                {\tt i\_wb\_data}  & {\tt i\_wb\_data} & {\tt DAT\_I} \\
529
                {\tt o\_wb\_ack}   & {\tt o\_wb\_ack} & {\tt ACK\_O} \\
530
                {\tt o\_wb\_stall} & {\tt o\_wb\_stall} & {\tt STALL\_O} \\
531
                {\tt o\_wb\_data}  & {\tt o\_wb\_data} & {\tt DAT\_O}
532 2 dgisselq
                \end{tabular}\\\hline
533 5 dgisselq
\end{tabular}
534 2 dgisselq
\caption{Wishbone Datasheet}\label{tbl:wishbone}
535
\end{center}\end{table}
536
is required by the wishbone specification in order to declare the core as
537
wishbone compliant, and so it is included here.  It references the connections
538 5 dgisselq
used in {\tt wbuart.v} as well as those exemplified by {\tt wbuart-insert.v}.
539
The big thing to notice is that this core acts as a wishbone slave, and that
540
all accesses to the core registers are 32--bit reads and writes to this
541
interface---not the 8--bit reads or writes that might otherwise be expected.
542 2 dgisselq
 
543
What this table doesn't show is that all accesses to the port take a single
544 5 dgisselq
clock for {\tt wbuart-insert.v}, or two clocks for {\tt wbuart.v}.  That is, if
545
the {\tt i\_wb\_stb} line is high on one clock, the {\tt i\_wb\_ack} line will
546
be high the next for single clock access, or the clock after that for two
547
clock access.  Further, the {\tt o\_wb\_stall} line is tied to zero.
548 2 dgisselq
 
549
Also, this particular wishbone implementation assumes that if {\tt i\_wb\_stb},
550
then {\tt i\_wb\_cyc} will be high as well.  Hence it only checks whether or not
551
{\tt i\_wb\_stb} is true to determine if a transaction has taken place.  If your
552
bus does not meet this requirement, you'll need to AND {\tt i\_wb\_stb} with
553
{\tt i\_wb\_cyc} before using the core.
554
 
555
\chapter{I/O Ports}\label{ch:ioports}
556
% This section specifies all of the core IO ports
557
 
558 5 dgisselq
In it's simplest form, the UART offers simply two I/O ports: the
559
{\tt i\_uart\_rx} line to receive, and the {\tt o\_uart\_tx} line to transmit.
560
These lines need to be brought to the outside of your design.  Within
561
Verilator, they need to be connected inside your Verilator test bench, as in:
562 2 dgisselq
\begin{tabbing}
563
{\tt if (!clk)} \= \\
564 5 dgisselq
\> {\tt tb->i\_uart\_rx} {\tt = } {\tt uartsim(tb->o\_uart\_tx);}
565 2 dgisselq
\end{tabbing}
566
 
567
A more detailed discussion of the connections associated with these modules
568 5 dgisselq
can begin with Tbl.~\ref{tbl:rxports},
569 2 dgisselq
\begin{table}\begin{center}\begin{portlist}
570
{\tt i\_clk}    & 1 & Input & The system clock \\\hline
571
{\tt i\_reset}  & 1 & Input & A positive, synchronous reset \\\hline
572
{\tt i\_setup}  & 30 & Input & The 30--bit setup register \\\hline
573
{\tt i\_uart}   & 1 & Input & The input wire from the outside world. \\\hline
574
{\tt o\_wr}     & 1 & Output & True if a word was received.  At this time,
575
                {\tt o\_data}, {\tt o\_break}, {\tt o\_parity\_err}, and
576
                {\tt o\_frame\_err} will also be valid. \\\hline
577
{\tt o\_data}   & 8 & Output & The received data, valid if {\tt o\_wr} \\\hline
578
{\tt o\_break}  & 1 & Output & True in the case of a break condition \\\hline
579
{\tt o\_parity\_err}    & 1 & Output & True if a parity error was detected \\\hline
580
{\tt o\_frame\_err}     & 1 & Output & True if a frame error was detected \\\hline
581
{\tt o\_ck\_uart}       & 1 & Output & A synchronized copy of {\tt i\_uart} \\\hline
582
\end{portlist}\caption{RXUART port list}\label{tbl:rxports}
583
\end{center}\end{table}
584 5 dgisselq
detailing the I/O ports of the UART receiver, Tbl.~\ref{tbl:txports},
585 2 dgisselq
\begin{table}\begin{center}\begin{portlist}
586
{\tt i\_clk}    & 1 & Input & The system clock \\\hline
587
{\tt i\_reset}  & 1 & Input & A positive, synchronous reset \\\hline
588
{\tt i\_setup}  & 30 & Input & The 30--bit setup register \\\hline
589
{\tt i\_break}  & 1 & Input & Set to true to place the transmit channel into a break condition\\\hline
590
{\tt i\_wr}     & 1 & Input & An input strobe.  Set to one when you wish to transmit data, clear once it has been accepted\\\hline
591
{\tt i\_data}   & 8 & Input & The data to be transmitted, ignored unless
592
                {\tt (i\_wr)\&\&(!o\_busy)} \\\hline
593
{\tt o\_uart}   & 1 & Output & The wire to be connected to the external port\\\hline
594
{\tt o\_busy}   & 1 & Output & True if the transmitter is busy, false if it will receive data\\\hline
595
\end{portlist}\caption{TXUART port list}\label{tbl:txports}
596
\end{center}\end{table}
597 5 dgisselq
detailing the I/O ports of the UART transmitter, and Tbl.~\ref{tbl:wbports}
598
\begin{table}\begin{center}\begin{tabular}{|p{1.15in}|p{0.1in}|p{0.75in}|p{3.375in}|}
599
\rowcolor[gray]{0.85} Port & W & Direction & Description \\\hline\hline
600
{\tt i\_uart\_rx}& 1 & Input & The receive wire coming from the external port\\\hline
601
{\tt o\_uart\_tx}& 1 & Output & The transmit wire to be connected to the external port\\\hline
602
{\tt o\_uart\_rx\_int}  & 1 & Output & True if a byte may be read from the receiver\\\hline
603
{\tt o\_uart\_tx\_int}  & 1 & Output & True if the transmitter is idle\\\hline
604
{\tt o\_uart\_rxfifo\_int}&1& Output & True if the receive FIFO is half full\\\hline
605
{\tt o\_uart\_txfifo\_int}&1& Output & True if the transmit FIFO is half empty\\\hline
606
\end{tabular}\caption{WBUART port list}\label{tbl:wbports}
607
\end{center}\end{table}
608
detailing the non--wishbone I/O ports of the wishbone controller.
609 2 dgisselq
 
610
% Appendices
611
% A. May be added to outline different specifications.  (??)
612
 
613
 
614
% Index
615
\end{document}
616
 
617
 

powered by: WebSVN 2.1.0

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