1 |
145 |
lanttu |
\documentclass[a4paper,10pt,oneside,final]{article}
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
\usepackage[english]{babel}
|
5 |
|
|
\usepackage[T1]{fontenc}
|
6 |
|
|
\usepackage{tabularx}
|
7 |
|
|
\usepackage[usenames,dvipsnames]{color}
|
8 |
|
|
\usepackage[table]{xcolor}
|
9 |
|
|
\usepackage[left=3.0cm, right=2.5cm, top=2.5cm, bottom=2.5cm]{geometry}
|
10 |
|
|
\usepackage{graphicx}
|
11 |
|
|
\usepackage{float}
|
12 |
|
|
\usepackage{caption}
|
13 |
|
|
\usepackage{listings}
|
14 |
|
|
\usepackage{subfigure}
|
15 |
|
|
\usepackage{here}
|
16 |
|
|
\usepackage{multirow}
|
17 |
|
|
|
18 |
|
|
\lstdefinestyle{ccc}
|
19 |
|
|
{
|
20 |
|
|
numbers=none,
|
21 |
|
|
basicstyle=\small\ttfamily,
|
22 |
|
|
keywordstyle=\bf\color[rgb]{0,0,0},
|
23 |
|
|
%commentstyle=\color[rgb]{0.133,0.545,0.133},
|
24 |
|
|
stringstyle=\color[rgb]{0.627,0.126,0.941},
|
25 |
|
|
backgroundcolor=\color{white},
|
26 |
|
|
frame=tb, %frame= lrtb,
|
27 |
|
|
framerule=0.5pt,
|
28 |
|
|
linewidth=\textwidth,
|
29 |
|
|
%aboveskip=-4.0pt,
|
30 |
|
|
%belowskip=-4.0pt,
|
31 |
|
|
lineskip=-5.0pt,
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
%
|
35 |
|
|
% Define author(s) and component's name
|
36 |
|
|
%
|
37 |
|
|
\def\defauthor{Antti Alhonen}
|
38 |
|
|
\def\deftitle{FPGA---PC Ethernet Communication IPs\\Reference Manual}
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
\author{\defauthor}
|
42 |
|
|
\title{\deftitle}
|
43 |
|
|
|
44 |
|
|
\usepackage{fancyhdr}
|
45 |
|
|
\pagestyle{fancy}
|
46 |
|
|
\lhead{\bfseries Department of Computer Systems\\
|
47 |
|
|
Faculty of Computing and Electrical Engineering}
|
48 |
|
|
\chead{}
|
49 |
|
|
\rhead{\bfseries \deftitle}
|
50 |
|
|
\lfoot{\thepage}
|
51 |
|
|
\cfoot{}
|
52 |
|
|
\rfoot{\includegraphics[height=1.0cm]{fig/tty_logo.png}}
|
53 |
|
|
\renewcommand{\headrulewidth}{0.4pt}
|
54 |
|
|
\renewcommand{\footrulewidth}{0.4pt}
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
\def\deftablecolora{blue!10!white}
|
58 |
|
|
\def\deftablecolorb{white}
|
59 |
|
|
|
60 |
|
|
\setlength{\parskip}{2ex}
|
61 |
|
|
|
62 |
|
|
\begin{document}
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
%\maketitle
|
66 |
|
|
%\thispagestyle{empty}
|
67 |
|
|
|
68 |
|
|
\begin{titlepage}
|
69 |
|
|
\begin{center}
|
70 |
|
|
|
71 |
|
|
\vspace{6.0cm}
|
72 |
|
|
\textsc{\LARGE Tampere University of Technology}\\[1.0cm]
|
73 |
|
|
\textsc{\Large Faculty of Computing and Electrical Engineering}\\[1.0cm]
|
74 |
|
|
\textsc{\Large Department of Computer Systems}\\[1.0cm]
|
75 |
|
|
\vspace{6.0cm}
|
76 |
|
|
\hrule
|
77 |
|
|
\vspace{0.4cm}
|
78 |
|
|
{ \huge \bfseries FPGA---PC Ethernet Communication IPs\\[0.5cm]Reference Manual}
|
79 |
|
|
\vspace{0.4cm}
|
80 |
|
|
\hrule
|
81 |
|
|
|
82 |
|
|
%\vspace{2.0cm}
|
83 |
|
|
|
84 |
|
|
\vfill
|
85 |
|
|
|
86 |
|
|
\begin{minipage}{0.4\textwidth}
|
87 |
|
|
\begin{flushleft} \large
|
88 |
|
|
\emph{Author:}\\
|
89 |
|
|
Antti Alhonen
|
90 |
|
|
\end{flushleft}
|
91 |
|
|
\end{minipage}
|
92 |
|
|
\begin{minipage}{0.4\textwidth}
|
93 |
|
|
\begin{flushright} \large
|
94 |
|
|
\emph{Updated:} \\
|
95 |
|
|
\today
|
96 |
|
|
\end{flushright}
|
97 |
|
|
\end{minipage}
|
98 |
|
|
|
99 |
|
|
\end{center}
|
100 |
|
|
\end{titlepage}
|
101 |
|
|
|
102 |
|
|
\newpage
|
103 |
|
|
\tableofcontents
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
\newpage
|
108 |
|
|
\section{REVISION HISTORY}
|
109 |
|
|
\setcounter{page}{1}
|
110 |
|
|
|
111 |
|
|
\begin{center}
|
112 |
|
|
\rowcolors{3}{\deftablecolora}{\deftablecolorb}
|
113 |
|
|
|
114 |
|
|
\captionof{table}{}
|
115 |
|
|
\begin{tabularx}{\textwidth}{|lllX|}
|
116 |
|
|
\hline
|
117 |
|
|
Revision & Author & Date & Description\\
|
118 |
|
|
\hline
|
119 |
|
|
1.0 & Antti Alhonen & 28.10.2011 & First published version\\
|
120 |
|
|
& & & \\
|
121 |
|
|
& & & \\
|
122 |
|
|
& & & \\
|
123 |
|
|
\hline
|
124 |
|
|
\end{tabularx}
|
125 |
|
|
\end{center}
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
\newpage
|
130 |
|
|
\section{DOCUMENT OVERVIEW}
|
131 |
|
|
|
132 |
|
|
\subsection{SCOPE}
|
133 |
|
|
|
134 |
|
|
This documentation describes the usage of DCS/TUT made IPs to
|
135 |
|
|
allow simple communication between a computer and various FPGA
|
136 |
|
|
development boards. We give an overview to all parts needed for
|
137 |
|
|
bi-directional communication over UDP/IP protocol at 100 Mbit/s
|
138 |
|
|
with one computer.
|
139 |
|
|
|
140 |
|
|
The main scope is on the simplicity of usage; therefore, some
|
141 |
|
|
features such as reliable operation in a network consisting of
|
142 |
|
|
numerous devices and computers are not guaranteed to work.
|
143 |
|
|
|
144 |
|
|
\subsection{AUDIENCE}
|
145 |
|
|
|
146 |
|
|
\begin{itemize}
|
147 |
|
|
\item SoC developers
|
148 |
|
|
\item Kactus 2 design tool users
|
149 |
|
|
\item Users of development boards that include an FPGA and Davicom DM9000A (or possibly SMSC LAN91C111) Ethernet MAC/PHY
|
150 |
|
|
\end{itemize}
|
151 |
|
|
|
152 |
|
|
\subsection{RELATED DOCUMENTATION}
|
153 |
|
|
|
154 |
|
|
\begin{center}
|
155 |
|
|
\rowcolors[]{2}{\deftablecolora}{\deftablecolorb}
|
156 |
|
|
|
157 |
|
|
\captionof{table}{}
|
158 |
|
|
\begin{tabularx}{\textwidth}{ | p{8cm} | X | } %{|lX|}
|
159 |
|
|
\hline
|
160 |
|
|
Document & Description\\
|
161 |
|
|
\hline
|
162 |
|
|
UDP/IP with VHDL & Implementation specification of the UDP/IP packetizer used in Trace Monitor \\
|
163 |
|
|
DM9kA controller & Implementation specification of the DM9000A ethernet MAC/PHY interface \\
|
164 |
|
|
\hline
|
165 |
|
|
\end{tabularx}
|
166 |
|
|
\end{center}
|
167 |
|
|
|
168 |
|
|
%\subsection{DOCUMENT CONVENTIONS}
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
\newpage
|
173 |
|
|
\section{INTRODUCTION}
|
174 |
|
|
|
175 |
|
|
\subsection{CONTACT INFORMATION}
|
176 |
|
|
|
177 |
|
|
If you face any problems using the IPs offered, please
|
178 |
|
|
do not hesitate to ask for help or to give suggestions.
|
179 |
|
|
You can contact Antti Alhonen (\textit{antti.alhonen@tut.fi}).
|
180 |
|
|
|
181 |
|
|
\subsection{INTRODUCTION}
|
182 |
|
|
|
183 |
|
|
It is very usual to use FPGA's for non-self-contained systems that
|
184 |
|
|
need to communicate with computers to transfer large amounts of data.
|
185 |
|
|
Standard UART is very simple for transferring small commands and
|
186 |
|
|
debug information, but not fast enough to transfer, for example, video
|
187 |
|
|
or audio data.
|
188 |
|
|
|
189 |
|
|
Multiple solutions exist, such as USB, PCI, PCI Express, Firewire and
|
190 |
|
|
Ethernet connection. Ethernet connection has some benefits such as
|
191 |
|
|
simplicity and existing communication routines in all major operating
|
192 |
|
|
systems without a need to write device drivers. The biggest drawback
|
193 |
|
|
is the lack of guarantee for transfers. However, this problem can be
|
194 |
|
|
managed.
|
195 |
|
|
|
196 |
|
|
Usually, a soft-core processor is synthesized on FPGA; then, a
|
197 |
|
|
\textit{software} controller and drivers are provided for the external
|
198 |
|
|
ethernet chip. In this case, it is possible to implement complex
|
199 |
|
|
protocols such as TCP/IP. The drawback is the area overhead of the
|
200 |
|
|
processor, extra latency because of the software, possible bandwidth
|
201 |
|
|
decrease depending on the processor and the need of embedded processor
|
202 |
|
|
and software. Sometimes, a more simple HW approach is needed or
|
203 |
|
|
preferred.
|
204 |
|
|
|
205 |
|
|
\subsection{BRIEF DESCRIPTION}
|
206 |
|
|
|
207 |
|
|
This solution implements UDP/IP protocol; a simple, packet-switched,
|
208 |
|
|
low-latency, low-overhead communication between
|
209 |
|
|
two devices: an FPGA board and a PC.
|
210 |
|
|
|
211 |
|
|
The HW interface consists of two FIFO interfaces (send and receive) and a
|
212 |
|
|
few intuitive control signals and busses such as ``start new transfer'',
|
213 |
|
|
``destination IP address'', ``new packet received'' etc. These separate
|
214 |
|
|
control signals allow very simple usage from HW (VHDL, Verilog etc.)
|
215 |
|
|
applications.
|
216 |
|
|
|
217 |
|
|
The implementation includes UDP/IP packetizer and controllers for
|
218 |
|
|
external Ethernet MAC/PHY chips -- currently, two different brands are
|
219 |
|
|
supported with some restrictions. Our implementation exploits the FIFO
|
220 |
|
|
buffers provided by these external chips, thus the on-chip FPGA memory
|
221 |
|
|
requirement is zero.
|
222 |
|
|
|
223 |
|
|
Ethernet controllers currently supported by us include:
|
224 |
|
|
\begin{itemize}
|
225 |
|
|
\item Davicom DM9000A
|
226 |
|
|
\item SMSC LAN91C111 (partially)
|
227 |
|
|
\end{itemize}
|
228 |
|
|
|
229 |
|
|
A GMII output will be offered in the future to enable Gigabit Ethernet
|
230 |
|
|
operation.
|
231 |
|
|
|
232 |
|
|
%\begin{figure}[H]
|
233 |
|
|
%\begin{centering}
|
234 |
|
|
% \includegraphics[width=0.8\textwidth]{fig/router_connections.pdf}
|
235 |
|
|
% \captionof{figure}{Links and FIFOs in one network router in a mesh
|
236 |
|
|
% NoC. The FIFO handshake signals are actually monitored; for
|
237 |
|
|
% Trace Monitor HW and SW.}
|
238 |
|
|
% \label{fig:router_connections}
|
239 |
|
|
%\end{centering}
|
240 |
|
|
%\end{figure}
|
241 |
|
|
|
242 |
|
|
%Fig.~\ref{fig:mesh3x3} shows a mesh NoC. All links shown as arrows are
|
243 |
|
|
|
244 |
|
|
It is \textbf{very strongly recommended} that you connect these
|
245 |
|
|
controllers to a separate network interface card in your PC directly,
|
246 |
|
|
i.e. without any switch, let alone a router. Both of the network
|
247 |
|
|
chips mentioned support autonegotiation that should be capable of
|
248 |
|
|
working with normal cable in this situation, but if the link does not
|
249 |
|
|
go up, you can try a cross-over cable (cable with RX and TX swapped to
|
250 |
|
|
allow direct connection).
|
251 |
|
|
|
252 |
|
|
\subsection{Designs provided}
|
253 |
|
|
|
254 |
|
|
\begin{center}
|
255 |
|
|
% \rowcolors[]{2}{\deftablecolora}{\deftablecolorb}
|
256 |
|
|
|
257 |
|
|
\captionof{table}{}
|
258 |
|
|
\begin{tabular}{ | p{3cm} | p{5cm} | p{6cm} | } %{|lX|}
|
259 |
|
|
\hline
|
260 |
|
|
Design & Files & Description\\
|
261 |
|
|
\hline
|
262 |
|
|
\multirow{9}{3cm}{UDP/IP Packetizer} & udp\_ip.vhd (toplevel) & \multirow{9}{6cm}{Offers a simple interface for user application logic
|
263 |
|
|
to perform TX and RX operations over Ethernet with UDP/IP protocol. The MAC/IP addresses for the FPGA board are set in udp\_ip\_pkg.vhd.
|
264 |
|
|
This block is connected to either one of the Ethernet Chip Controllers provided. Combined toplevels to provide this connection are provided, too.} \\
|
265 |
|
|
& udp\_ip\_pkg.vhd (config package) & \\
|
266 |
|
|
& udp.vhd & \\
|
267 |
|
|
& udp\_arp\_data\_mux.vhd & \\
|
268 |
|
|
& ip\_checksum.vhd & \\
|
269 |
|
|
& arp3.vhd (optional) & \\
|
270 |
|
|
& arpsnd.vhd (optional) & \\
|
271 |
|
|
& & \\
|
272 |
|
|
& & \\
|
273 |
|
|
\hline
|
274 |
|
|
\multirow{9}{3cm}{DM9000A or LAN91C111 Controller} & DM9kA\_controller.vhd (toplevel) & \multirow{9}{6cm}{Connected between UDP/IP block and IO pins of
|
275 |
|
|
the FPGA, these control blocks first initialize the external Ethernet MAC/PHY in question and then control the writes and reads to/from the TX/RX
|
276 |
|
|
FIFOs, commands etc. The entity-level construction is identical for the two supported controllers but the implementations differ due to very different
|
277 |
|
|
interfaces of these chips. You can set the FPGA board MAC address in \_ctrl\_pkg.vhd.} \\
|
278 |
|
|
& DM9kA\_ctrl\_pkg.vhd (config package) & \\
|
279 |
|
|
& DM9kA\_comm\_module.vhd & \\
|
280 |
|
|
& DM9kA\_init\_module.vhd & \\
|
281 |
|
|
& DM9kA\_interrupt\_handler.vhd & \\
|
282 |
|
|
& DM9kA\_read\_module.vhd & \\
|
283 |
|
|
& DM9kA\_send\_module.vhd & \\
|
284 |
|
|
& (substitute lan91c111 for DM9kA for LAN91C111 Controller) & \\
|
285 |
|
|
& & \\
|
286 |
|
|
\hline
|
287 |
|
|
Simple UDP\newline Flood Example & simple\_udp\_\newline flood\_example.vhd &
|
288 |
|
|
A minimum example to show how TX operations are performed. Creates continuous traffic with
|
289 |
|
|
adjustable packet size to an IP/MAC address defined as generic parameters. First four bytes include an increasing count to detect packet loss.
|
290 |
|
|
Connects to the UDP/IP block. A Kactus 2 example file is provided. Also includes the interface for RX operations; it reads out and ignores all incoming
|
291 |
|
|
packets. You can leave it disconnected if you want to connect the Receiver Example at the same time. \\
|
292 |
|
|
\hline
|
293 |
|
|
Simple UDP\newline Receiver Example & simple\_udp\_\newline receiver\_example.vhd &
|
294 |
|
|
A minimum example to show how incoming packets can be handled. It reads out the
|
295 |
|
|
incoming packet from the RX FIFO and changes a LED status every time a packet is received.
|
296 |
|
|
Connects to the UDP/IP block. A Kactus 2 example file is provided. Includes also the interface for TX operations; it never sends anything. You can
|
297 |
|
|
leave it disconnected if you want to connect the Flood Example at the same time. \\
|
298 |
|
|
\hline
|
299 |
|
|
\end{tabular}
|
300 |
|
|
\end{center}
|
301 |
|
|
|
302 |
|
|
|
303 |
|
|
\subsection{Clock and reset}
|
304 |
|
|
|
305 |
|
|
Ethernet controller block and UDP/IP block both run on a synchronous
|
306 |
|
|
25 MHz clock. You may need to instantiate an FPGA vendor specific PLL
|
307 |
|
|
to generate this clock. Naturally, you can use an integer-multiple
|
308 |
|
|
synchronous higher clock for your own application as long as you
|
309 |
|
|
make sure the control signals connected to UDP/IP are synchronous and
|
310 |
|
|
stable to the 25 MHz clock.
|
311 |
|
|
|
312 |
|
|
Our DM9000A controller outputs the incoming 25 MHz clock directly to an
|
313 |
|
|
output IO pin that is connected to the clock input of DM9000A, hence,
|
314 |
|
|
the communication with the chip is synchronous. DM9000A is connected
|
315 |
|
|
like this in Altera DE2 development board.
|
316 |
|
|
|
317 |
|
|
Our LAN91C111 controller, on the other hand, communicates asynchrously
|
318 |
|
|
with the chip. Hence, the chip needs its own clock source. LAN91C111 is
|
319 |
|
|
connected like this in Altera Stratix II S180 development board.
|
320 |
|
|
|
321 |
|
|
An asynchronous active low reset signal is used throughout these
|
322 |
|
|
designs. After the reset is released (to the high level), the external
|
323 |
|
|
ethernet chip is reset and the autonegotiation process is
|
324 |
|
|
automatically started. This will take around five to ten seconds, after
|
325 |
|
|
which the link\_up signal is provided high, new tx operations accepted
|
326 |
|
|
and incoming packets handled. Note that LAN91C111 uses a ``soft'' reset
|
327 |
|
|
in the initialization process and therefore the link does not go down
|
328 |
|
|
when activating reset but when it is released from the reset.
|
329 |
|
|
|
330 |
|
|
\subsection{DM9000A}
|
331 |
|
|
|
332 |
|
|
Our implementation of DM9000A controller is complete for basic TX and RX
|
333 |
|
|
operations and comparably well-tested.
|
334 |
|
|
|
335 |
|
|
\subsection{LAN91C111}
|
336 |
|
|
\label{sec:LAN91C111}
|
337 |
|
|
|
338 |
|
|
Due to the very high complexity of usage of LAN91C111 controller and a
|
339 |
|
|
number of critical HW bugs in the chip, we have not been able to
|
340 |
|
|
demonstrate a reliably working connection with this chip. We are not
|
341 |
|
|
sure if we want to work with this chip anymore, so we cannot guarantee
|
342 |
|
|
any updates. Hence, we would encourage not to use this very peculiar
|
343 |
|
|
and obsolete chip unless absolutely necessary.
|
344 |
|
|
|
345 |
|
|
Currently, simple TX-only and RX-only operations are working in test
|
346 |
|
|
environments, but using ARP causing simultaneous TX and RX operations
|
347 |
|
|
causes a freezing of the chip hard to analyze. The chip simply stops
|
348 |
|
|
giving receive interrupts.
|
349 |
|
|
|
350 |
|
|
Furthermore, due to a critical HW bug in LAN91C111, sending smaller than
|
351 |
|
|
66-byte long packets does not work as intended. As a workaround, our controller
|
352 |
|
|
pads the packets with zeros but cannot provide correct packet length field.
|
353 |
|
|
|
354 |
|
|
\subsection{IP-XACT files provided}
|
355 |
|
|
|
356 |
|
|
We have created a set of IP-XACT descriptions in Kactus 2 design software.
|
357 |
|
|
It is possible to construct a complete working example using these. Two
|
358 |
|
|
examples are provided; a TX (send) example and an RX (receive) example.
|
359 |
|
|
|
360 |
|
|
You need to instantiate one (or both) of the two examples and one of the
|
361 |
|
|
UDP/IP/Eth CTRL combinations, depending on your external MAC/PHY chip brand.
|
362 |
|
|
|
363 |
|
|
Ready-to-use examples are provided. Please note that as described in the
|
364 |
|
|
previous subsection, the LAN91C111 examples may or may not work depending
|
365 |
|
|
on the network setup.
|
366 |
|
|
|
367 |
|
|
\newpage
|
368 |
|
|
\section{Usage}
|
369 |
|
|
\subsection{Sending a packet (TX)}
|
370 |
|
|
|
371 |
|
|
First, make sure the link is up, i.e., link\_up is high. Usually, it
|
372 |
|
|
takes a few seconds from a reset to link go up, but this can depend on
|
373 |
|
|
the PC, too. Status LED at the RJ-45 connector lits a few seconds
|
374 |
|
|
before the link\_up signal goes high.
|
375 |
|
|
|
376 |
|
|
When you have the first word (16 bits) of your payload data ready, do
|
377 |
|
|
the following:
|
378 |
|
|
|
379 |
|
|
\begin{enumerate}
|
380 |
|
|
\item Output the amount of your actual payload data \textbf{in bytes} in tx\_len
|
381 |
|
|
\item Output the destination IP address (the PC) in target\_addr, most
|
382 |
|
|
significant byte first, e.g. x"0A000001" in VHDL for 10.0.0.1.
|
383 |
|
|
\item \textbf{If} the ARP functionality is not enabled, output the destination
|
384 |
|
|
MAC address (the PC) in no\_arp\_target\_mac.
|
385 |
|
|
\item Output the IP port number where you want the packet to be sent
|
386 |
|
|
in target\_port. (Remember that you need to open this port
|
387 |
|
|
when designing the PC software.)
|
388 |
|
|
\item Output the desired IP port number of the FPGA board in
|
389 |
|
|
source\_port. Usually this does not matter but you can check it
|
390 |
|
|
in your PC software.
|
391 |
|
|
\item Output the first data word in tx\_data. This will be in
|
392 |
|
|
\textbf{MSbyte last} endianness; thus, the first byte on the line is
|
393 |
|
|
located in tx\_data(7~downto~0).
|
394 |
|
|
\item Output tx\_data\_valid = '1'. If you are using a FIFO buffer,
|
395 |
|
|
you can use not empty signal for this one.
|
396 |
|
|
\item Raise the new\_tx signal---this, alongwith tx\_data\_valid,
|
397 |
|
|
causes the UDP/IP packetizer to start reading the
|
398 |
|
|
data. \footnotemark
|
399 |
|
|
\item tx\_re works as an acknowledgement signal; supply the next data
|
400 |
|
|
word immediately, or, if not possible with the next clock cycle,
|
401 |
|
|
lower the data\_valid for the next cycle.
|
402 |
|
|
\item After the amount of data indicated by tx\_len (i.e., ceiling of
|
403 |
|
|
tx\_len/2) has been read, the chip starts sending
|
404 |
|
|
\textbf{automatically}. Just make sure you feed the amount of data
|
405 |
|
|
you promised in step 1.
|
406 |
|
|
\item You can now start the next packet almost immediately. The
|
407 |
|
|
controllers have FIFO buffer memory area for the next packet while
|
408 |
|
|
it is sending the previous one.
|
409 |
|
|
\end{enumerate}
|
410 |
|
|
|
411 |
|
|
\footnotetext{If the ARP functionality is enabled and the FPGA does
|
412 |
|
|
not yet have the PC MAC address (i.e., this is the first TX
|
413 |
|
|
operation after power-up, programming or reset), the ARP query will
|
414 |
|
|
be sent before any payload data is read. It may take a variable time
|
415 |
|
|
for the PC to answer. Therefore, for time-critical applications, or
|
416 |
|
|
just to keep things simple, we recommend to disable the ARP if it's
|
417 |
|
|
not needed. The downside to this is that you need to supply the PC
|
418 |
|
|
MAC address to the FPGA and if you don't have a separate input
|
419 |
|
|
system, you need to resynthesize every time if you use multiple
|
420 |
|
|
PCs.\newline~}
|
421 |
|
|
|
422 |
|
|
You can set all of these signals simultaneously. However, if you don't,
|
423 |
|
|
then set the new\_tx last.
|
424 |
|
|
|
425 |
|
|
If you communicate with only one PC and want to hard-code the
|
426 |
|
|
addresses (necessiating a re-synthesis if the addresses or ports have
|
427 |
|
|
to be changed), it's easiest to hard-wire these ports when
|
428 |
|
|
instantiating the component.
|
429 |
|
|
|
430 |
|
|
Please see the provided example design, simple\_udp\_flood\_example.vhd.
|
431 |
|
|
|
432 |
|
|
\newpage
|
433 |
|
|
\subsection{Receiving a packet (RX)}
|
434 |
|
|
|
435 |
|
|
After the chip receives a packet from the network with a matching MAC
|
436 |
|
|
address and a matching IP address (set your FPGA's IP address in
|
437 |
|
|
udp\_ip\_pkg.vhd), having correct UDP protocol headers, your
|
438 |
|
|
application will be notified by rising new\_rx. If the IP address or
|
439 |
|
|
protocol is wrong, the packet will be ignored without a notification.
|
440 |
|
|
|
441 |
|
|
When the new\_rx is up, you can read out the packet as follows:
|
442 |
|
|
\begin{enumerate}
|
443 |
|
|
\item If you need the information, you can read source\_addr (source
|
444 |
|
|
IP address, i.e. the PC), source\_port (i.e. the output IP port on
|
445 |
|
|
the PC, usually not interesting), dest\_port (the ``FPGA port''
|
446 |
|
|
where it was ``sent to'', may be interesting to check to ignore
|
447 |
|
|
(read out) accidental interactions from PC.)
|
448 |
|
|
\item Copy rx\_len to a register; you will need to count the bytes you
|
449 |
|
|
are going to read.
|
450 |
|
|
\item If you decide to ignore the packet, still read it out like any
|
451 |
|
|
data.
|
452 |
|
|
\item When rx\_data\_valid is high and you did not read on the
|
453 |
|
|
previous clock cycle, you can read out the next data word from
|
454 |
|
|
rx\_data and acknowledge it by setting rx\_re = '1' for one cycle.
|
455 |
|
|
\item After you have asserted rx\_re high for ceil(rx\_len/2) times
|
456 |
|
|
correctly, you have read the whole packet. You don't need to do
|
457 |
|
|
anything more.
|
458 |
|
|
\end{enumerate}
|
459 |
|
|
|
460 |
|
|
Please note that if you do not read out the whole packet, no new
|
461 |
|
|
packets are received after a few packets (RX FIFO gets full).
|
462 |
|
|
|
463 |
|
|
Please see the provided example design, simple\_udp\_receiver\_example.vhd.
|
464 |
|
|
|
465 |
|
|
\newpage
|
466 |
|
|
\section{Application development tips}
|
467 |
|
|
|
468 |
|
|
\subsection{MANAGING PACKET LOSS IN HIGH-DATA RATE APPLICATIONS}
|
469 |
|
|
|
470 |
|
|
UDP/IP is a ``send-and-forget'' protocol. The HW reliability is,
|
471 |
|
|
however, very high if not practically perfect in a direct connection.
|
472 |
|
|
|
473 |
|
|
However, due to the nature of PC's and especially their operating
|
474 |
|
|
systems, a small percentage of packets may be dropped in high-data
|
475 |
|
|
rate applications; it depends on your needs whether this is a problem
|
476 |
|
|
or not.
|
477 |
|
|
|
478 |
|
|
First, to identify the possible problem, it is recommended that your
|
479 |
|
|
application inserts a packet number to the start of every packet
|
480 |
|
|
payload, increasing by one after every packet. This way, dropped
|
481 |
|
|
packets can be counted. You can design your application so that the
|
482 |
|
|
PC software part can ask to resend a missed packet, however, if the
|
483 |
|
|
data cannot be regenerated in-situ, you will need a relatively large
|
484 |
|
|
buffer memory near the FPGA to do this.
|
485 |
|
|
|
486 |
|
|
Luckily, in practice, it is possible to reduce the number of dropped
|
487 |
|
|
packets to zero even in long runs with data rates close to maximum. Naturally,
|
488 |
|
|
this cannot be formally guaranteed but it is a very attractive option due
|
489 |
|
|
to the simplicity.
|
490 |
|
|
|
491 |
|
|
There are practically two reasons for dropping a packet:
|
492 |
|
|
|
493 |
|
|
\begin{itemize}
|
494 |
|
|
\item (1) Your PC software does not have enough time to read out packets
|
495 |
|
|
from the the RX buffer of the network socket in the OS network
|
496 |
|
|
implementation; after the buffer is full, packets are thrown away.
|
497 |
|
|
\item (2) The operating system's network kernel or device driver does
|
498 |
|
|
not have enough time to read out the packets from the RX FIFO of the
|
499 |
|
|
Ethernet card and place them to the buffer mentioned in (1).
|
500 |
|
|
\end{itemize}
|
501 |
|
|
|
502 |
|
|
To solve problem 1, increase the RX buffer size. You will need OS-specific
|
503 |
|
|
API calls. If you don't want to do it in your software, you can just increase
|
504 |
|
|
the default RX buffer of your OS for all programs that do not use their
|
505 |
|
|
own setting. For example, in MS Windows XP, open regedit, locate\\
|
506 |
|
|
HKEY$\backslash$LOCAL\_MACHINE$\backslash$SYSTEM$\backslash$CurrentControlSet$\backslash$Services$\backslash$AFD$\backslash$Parameters
|
507 |
|
|
and add a new DWORD value named DefaultReceiveWindow with a desired RX
|
508 |
|
|
buffer size in bytes. I have used values in range of about 300~000 with great
|
509 |
|
|
results (zero drops at 80 Mbps of payload). The default is very small,
|
510 |
|
|
only 8192 bytes. Note that this will be used for all programs as a
|
511 |
|
|
default unless the programs define a different buffer size and thus
|
512 |
|
|
the memory usage may increase. For Linux and other systems, you have to Google around.
|
513 |
|
|
|
514 |
|
|
To solve problem 2, buy a network adapter with longer RX
|
515 |
|
|
buffer. Simply put, the older 100 Mbps cards have very short
|
516 |
|
|
buffers, regardless of the manufacturer. On the other hand, Gigabit
|
517 |
|
|
cards, even the cheapest ones, have longer buffers. I have about
|
518 |
|
|
10-100 ppm of packet loss with a 3Com 100 Mbps card (with 8 kbyte RX
|
519 |
|
|
FIFO) but zero packet loss with a cheap Realtek Gigabit card, at 80
|
520 |
|
|
Mbps, on Windows XP, with increased OS RX buffer size.
|
521 |
|
|
|
522 |
|
|
\newpage
|
523 |
|
|
\section{KNOWN ISSUES}
|
524 |
|
|
|
525 |
|
|
\begin{itemize}
|
526 |
|
|
\item Lack of workarounds for some LAN91C111 problems; see Section \ref{sec:LAN91C111}.
|
527 |
|
|
\end{itemize}
|
528 |
|
|
|
529 |
|
|
\end{document}
|