1 | \documentclass[a4paper,11pt]{report}
|
---|
2 |
|
---|
3 | \usepackage{float}
|
---|
4 | \usepackage{graphicx}
|
---|
5 | \usepackage{url}
|
---|
6 | \usepackage[T1]{fontenc}
|
---|
7 | \usepackage{amsmath}
|
---|
8 | \usepackage{longtable}
|
---|
9 | \usepackage{parskip}
|
---|
10 | \usepackage{pifont}
|
---|
11 | \usepackage{array}
|
---|
12 |
|
---|
13 | \setlength{\oddsidemargin}{0cm}
|
---|
14 | \setlength{\evensidemargin}{0cm}
|
---|
15 | \setlength{\topmargin}{0cm}
|
---|
16 |
|
---|
17 | \textwidth 6.2in
|
---|
18 | \textheight 9in
|
---|
19 | \columnsep 0.25in
|
---|
20 |
|
---|
21 | \pagestyle{plain}
|
---|
22 | \setcounter{tocdepth}{1}
|
---|
23 |
|
---|
24 | \title{\vspace*{-7cm} \Huge \bf FTU Firmware Specifications}
|
---|
25 | \author{\Large Quirin Weitzel\footnote{Contact for questions and suggestions concerning this
|
---|
26 | document: {\tt qweitzel@phys.ethz.ch}}, Patrick Vogler}
|
---|
27 | \date{\vspace*{0.5cm} \Large v3~~~-~~~November 2010}
|
---|
28 |
|
---|
29 | \begin{document}
|
---|
30 |
|
---|
31 | \maketitle
|
---|
32 |
|
---|
33 | \newpage
|
---|
34 |
|
---|
35 | \tableofcontents
|
---|
36 |
|
---|
37 | \chapter{Introduction}
|
---|
38 |
|
---|
39 | The FACT Trigger Unit (FTU) is a Mezzanine Card attached to the FACT
|
---|
40 | Pre-Amplifier (FPA) board. On the FPA, the analog signals of nine adjacent
|
---|
41 | pixels are summed up, and the total signal is compared to a threshold. Four
|
---|
42 | such trigger patches are hosted by one FPA. The corresponding four digital
|
---|
43 | trigger signals are processed further by the FTU, generating a single trigger
|
---|
44 | primitive out of them. A total of 40 FTU boards exists in the FACT
|
---|
45 | camera. Their trigger primitives are collected at one central point, the FACT
|
---|
46 | Trigger Master (FTM)\footnote{For more information about the FACT trigger
|
---|
47 | system see: P.~Vogler, {\it Development of a trigger system for a Cherenkov
|
---|
48 | Telescope Camera based on Geiger-mode avalanche photodiodes}, Master
|
---|
49 | Thesis, ETH Zurich, 2010.}. The FTM serves also as slow control master for
|
---|
50 | the FTUs, which are connected in groups of ten to RS485 data buses for this
|
---|
51 | purpose. These buses are realized on the midplanes of the four crates inside
|
---|
52 | the camera.
|
---|
53 |
|
---|
54 | The main component on each FTU is a FPGA\footnote{Xilinx Spartan-3AN family
|
---|
55 | (XC3S400AN-4FGG400C); for programming information see:
|
---|
56 | \url{http://www.xilinx.com/support/documentation/user_guides/ug331.pdf}
|
---|
57 | (Spartan-3 Generation FPGA User Guide).}, fulfilling different tasks within
|
---|
58 | the board. The purpose of this document is to describe the main features of
|
---|
59 | the firmware of this device, which is identical for all 40 boards. After a
|
---|
60 | brief summary of the FTU functionality and its digital components, a general
|
---|
61 | overview of the firmware design is given. In the following, all FPGA registers
|
---|
62 | available for reading and writing are listed. Afterwards the communication
|
---|
63 | with the FTM is detailed, and the most important finite state machines
|
---|
64 | implemented are explained.
|
---|
65 |
|
---|
66 | \chapter{FTU Tasks and Digital Components}
|
---|
67 |
|
---|
68 | In order to define the thresholds for the individual trigger patches, four
|
---|
69 | channels of an octal \mbox{12-bit} Digital-to-Analog Converter (DAC) are
|
---|
70 | used. This chip\footnote{Details concerning specific electronics components as
|
---|
71 | well as schematics can be found at the FACT construction page:
|
---|
72 | \url{http://ihp-pc1.ethz.ch/FACT} (password protected).} is accessed by the
|
---|
73 | FPGA through a Serial Peripheral Interface (SPI). A fifth channel of the same
|
---|
74 | DAC is employed to control a $n$-out-of-4 majority coincidence logic,
|
---|
75 | generating the trigger primitive out of the patch signals. The FTU can
|
---|
76 | furthermore switch off single pixels within the trigger patches by disabling
|
---|
77 | the corresponding input buffers just before the summation stage on the
|
---|
78 | FPA. However, the decision to switch off a pixel for the trigger or to change
|
---|
79 | the threshold for a patch is not taken by the FTU itself, but has to come in
|
---|
80 | form of a command from the FTM.
|
---|
81 |
|
---|
82 | For each of the four trigger patches, the FTU counts the number of triggers
|
---|
83 | within a certain time period. Also the number of trigger primitives after the
|
---|
84 | $n$-out-of-4 majority coincidence is counted. In this way, the rates per patch
|
---|
85 | and per board are known for each FTU. The counters are implemented inside the
|
---|
86 | FPGA with a range of 30\,bit. In case the number of triggers exceeds this
|
---|
87 | limit, an overflow flag is set. The counting period is changeable from outside
|
---|
88 | between 500\,ms and 128\,s with a resolution of 8\,bit.
|
---|
89 |
|
---|
90 | Each FTU board has one RS485 communication interface to the FTM. Ten boards
|
---|
91 | are connected to one bus, where they are operated in slave-mode. Only in case
|
---|
92 | a read or write command for a specific FTU arrives from the FTM, this board
|
---|
93 | will react and answer. Broadcast commands are not supported by the current
|
---|
94 | firmware version. To avoid data collisions on the buses, the FTM has to
|
---|
95 | address the FTUs one by one to read out the rates for example. A RS485
|
---|
96 | interface is implemented inside the FPGA, including frame receiving, data
|
---|
97 | buffering and instruction decoding. It is minimal in the sense that no stacked
|
---|
98 | commands, command buffering or interrupts are supported. Outside the FPGA, a
|
---|
99 | RS485 driver/receiver chip translates the signal levels between the
|
---|
100 | differential bus lines and the FPGA logic levels. This chip is enabled for
|
---|
101 | data transmission or data receiving, respectively.
|
---|
102 |
|
---|
103 | \chapter{Firmware Organization}
|
---|
104 | \label{cha:organization}
|
---|
105 |
|
---|
106 | The FTU firmware is written in VHDL (VHSIC Hardware Description Language). For
|
---|
107 | some of its components the Xilinx core generator tools\footnote{Xilinx ISE
|
---|
108 | Design Suite, release 11.5, homepage: \url{http://www.xilinx.com}
|
---|
109 | (downloads, documentation).} have been used. In this chapter, an overview of
|
---|
110 | the firmware content is given, followed by a listing of the files containing
|
---|
111 | the source code. The complete project is available from the FACT
|
---|
112 | repository\footnote{Project page: \url{https://fact.isdc.unige.ch/trac}
|
---|
113 | (password protected).}.
|
---|
114 |
|
---|
115 | \section{Design Overview}
|
---|
116 | \label{sec:organization:design}
|
---|
117 |
|
---|
118 | The highest level entity in the firmware is called {\tt FTU\_top}. Its ports
|
---|
119 | are the physical connections of the FPGA on the FTU board. Inside {\tt
|
---|
120 | FTU\_top} other entities are instantiated, representing different functional
|
---|
121 | modules. They are discussed in the following subsections. For important
|
---|
122 | numbers and constants the package {\tt ftu\_constants} inside the library {\tt
|
---|
123 | ftu\_definitions} has been created. A second package {\tt ftu\_array\_types}
|
---|
124 | contains customized array types.
|
---|
125 |
|
---|
126 | \subsection{\tt FTU\_clk\_gen}
|
---|
127 |
|
---|
128 | This is an interface to the Digital Clock Managers (DCM) of the FPGA. At the
|
---|
129 | moment only one DCM is used, providing the central 50\,MHz clock. Once the DCM
|
---|
130 | has locked and is providing a stable frequency {\tt FTU\_clk\_gen} sends a
|
---|
131 | ready signal. This is a prerequisite for the board to enter the {\tt RUNNING}
|
---|
132 | state. {\tt FTU\_clk\_gen} also generates a central 1\,MHz clock for the rate
|
---|
133 | counters (by division, not using a second DCM). In addition, some modules
|
---|
134 | within the FTU design have their own built-in clock dividers to generate
|
---|
135 | custom frequencies.
|
---|
136 |
|
---|
137 | \subsection{\tt FTU\_dual\_port\_ram64}
|
---|
138 | \label{sec:organization:design:ram}
|
---|
139 |
|
---|
140 | All FTU registers which can be set from outside during operation are stored in
|
---|
141 | a dual-port block RAM (Random Access Memory). The FPGA provides specific
|
---|
142 | resources for this purpose, and therefore the RAM has been created using the
|
---|
143 | Xilinx core generator tools. The entity {\tt FTU\_dual\_port\_ram64} serves as
|
---|
144 | an interface to the RAM, the actual gate level description is stored directly
|
---|
145 | in the net-list file {\tt FTU\_dual\_port\_ram64.ngc}. Thus this file is part
|
---|
146 | of the design, although not available as source code. The RAM has a size of
|
---|
147 | 64\,bytes and two fully featured ports to access its content. One port is
|
---|
148 | based on 1-byte words, the other one on 2-byte words. The corresponding
|
---|
149 | address space is presented together with the register tables in
|
---|
150 | chapter~\ref{cha:registers}. In addition to the control registers, also the
|
---|
151 | current counter readings are stored in the RAM.
|
---|
152 |
|
---|
153 | \subsection{\tt FTU\_rate\_counter}
|
---|
154 | \label{sec:organization:design:counter}
|
---|
155 |
|
---|
156 | Here the trigger counting is done. A rate counter has a range of 30\,bit and
|
---|
157 | counts until a defined period is finished. This period is derived from an
|
---|
158 | 8-bit prescaling value $y$ as $ T = \frac{y+1}{2}$\,s. In total five such
|
---|
159 | counters are instantiated which are running and set up synchronously. If the
|
---|
160 | FTU settings are changed during operation all counters are reset. Only in case
|
---|
161 | a full period has been finished without interruption, the number of counts
|
---|
162 | from each counter is stored in the RAM. An overflow flag is set by the
|
---|
163 | counters if necessary.
|
---|
164 |
|
---|
165 | \subsection{\tt FTU\_spi\_interface}
|
---|
166 |
|
---|
167 | The octal DAC defining the trigger thresholds is controlled by means of a
|
---|
168 | SPI. As soon as the {\tt FTU\_spi\_interface} entity receives a start signal,
|
---|
169 | it will clock out the data pending at one of its input ports to the DAC. These
|
---|
170 | data are provided in form of a customized array. The generation of the serial
|
---|
171 | clock, the distribution of the DAC values to the right addresses and the
|
---|
172 | actual transmission of the data to the chip are performed by three more
|
---|
173 | entities, which are instantiated inside {\tt FTU\_spi\_interface}. Once the
|
---|
174 | transmission has started or finished, respectively, a signal is pulled.
|
---|
175 |
|
---|
176 | \subsection{\tt FTU\_rs485\_control}
|
---|
177 |
|
---|
178 | The communication between the FTU and the FTM is handled by a RS485
|
---|
179 | interface. The top level entity of this module is called {\tt
|
---|
180 | FTU\_rs485\_control}. It contains a state machine and further sub-entities
|
---|
181 | for frame receiving or transmitting, byte buffering and instruction
|
---|
182 | decoding. The details of the underlying protocol and the possible instructions
|
---|
183 | are detailed in chapter~\ref{cha:communication}. In case an instruction has
|
---|
184 | been decoded successfully, the main FTU control is informed and the
|
---|
185 | corresponding data (like new DAC values) are provided. After the command has
|
---|
186 | been executed an answer is send to the FTM. {\tt FTU\_rs485\_control} has
|
---|
187 | direct control of the involved transmitter/receiver chip outside the FPGA and
|
---|
188 | takes care that it is only transmitting if this particular FTU has been
|
---|
189 | contacted by the FTM. In this way also the rates are send on request. The baud
|
---|
190 | rate is adjustable and defined in the library {\tt ftu\_definitions}.
|
---|
191 |
|
---|
192 | \subsection{\tt FTU\_control}
|
---|
193 |
|
---|
194 | This entity contains the main state machine of the FTU firmware. It receives
|
---|
195 | control, ready, start, etc. flags from all modules and interfaces and reacts
|
---|
196 | accordingly by changing to a new state. This may be done with some delay,
|
---|
197 | depending on what the board is doing at the moment. {\tt FTU\_control} is
|
---|
198 | furthermore the only place in the design from where the RAM is read or
|
---|
199 | written. The state machine is described in more detail in
|
---|
200 | chapter~\ref{cha:fsm}.
|
---|
201 |
|
---|
202 | \subsection{\tt FTU\_dna\_gen}
|
---|
203 | \label{sec:organization:design:dna}
|
---|
204 |
|
---|
205 | In order to be able to unambiguously identify each FTU during operation, the
|
---|
206 | device identifier\footnote{This unique identifier has 57\,bit and is built-in
|
---|
207 | for each FPGA of the Spartan-3A series. For more information see:
|
---|
208 | \url{http://www.xilinx.com/support/documentation/user_guides/ug332.pdf}
|
---|
209 | (Spartan-3 Generation Configuration User Guide).} (DNA) of its FPGA is
|
---|
210 | used. After power-up this DNA is read-out once by {\tt FTU\_dna\_gen} and
|
---|
211 | stored for later usage inside {\tt FTU\_top} as a permanent signal.
|
---|
212 |
|
---|
213 | \section{File Structure}
|
---|
214 |
|
---|
215 | Table~\ref{tab:files} specifies all source files necessary to compile the
|
---|
216 | firmware for the FTU boards\footnote{As of November 2010; the file structure
|
---|
217 | might still be changed.}. For each file its location path inside the
|
---|
218 | directory {\tt firmware} of the FACT repository is stated. Furthermore it is
|
---|
219 | indicated whether a certain file is needed for the simulation and/or the
|
---|
220 | hardware implementation. The design entities described in
|
---|
221 | section~\ref{sec:organization:design} are contained in those files which have
|
---|
222 | the corresponding prefix. The file {\tt ucrc\_par.vhd} has been downloaded
|
---|
223 | from OpenCores\footnote{Ultimate CRC project:
|
---|
224 | \url{http://www.opencores.org/cores/ultimate_crc} (free software under the
|
---|
225 | terms of the GNU General Public License).}.
|
---|
226 |
|
---|
227 | \begin{table}[htbp]
|
---|
228 | \centering
|
---|
229 | \begin{tabular}{|l|l|l|l|l|}
|
---|
230 | \hline
|
---|
231 | file name & location & simulation & implement & comment \\
|
---|
232 | \hline\hline
|
---|
233 | {\tt FTU\_top.vhd} & {\tt FTU} & yes & yes & top level entity\\
|
---|
234 | \hline
|
---|
235 | {\tt FTU\_top\_tb.vhd} & {\tt FTU} & yes & no & test bench\\
|
---|
236 | \hline
|
---|
237 | {\tt ftu\_definitions.vhd} & {\tt FTU} & yes & yes & library\\
|
---|
238 | \hline
|
---|
239 | {\tt ftu\_board.ucf} & {\tt FTU} & no & yes & pin constraints\\
|
---|
240 | \hline
|
---|
241 | {\tt FTU\_control.vhd} & {\tt FTU} & yes & yes & top state machine\\
|
---|
242 | \hline\hline
|
---|
243 | {\tt FTU\_clk\_gen.vhd} & {\tt FTU/clock} & yes & yes & clock interface\\
|
---|
244 | \hline
|
---|
245 | {\tt FTU\_dcm\_50M\_to\_50M.vhd} & {\tt FTU/clock} & yes & yes & clock manager\\
|
---|
246 | \hline\hline
|
---|
247 | {\tt FTU\_rate\_counter.vhd} & {\tt FTU/counter} & yes & yes & trigger counter\\
|
---|
248 | \hline\hline
|
---|
249 | {\tt FTU\_spi\_interface.vhd} & {\tt FTU/dac\_spi} & yes & yes & SPI top entity\\
|
---|
250 | \hline
|
---|
251 | {\tt FTU\_spi\_clock\_gen.vhd} & {\tt FTU/dac\_spi} & yes & yes & serial clock\\
|
---|
252 | \hline
|
---|
253 | {\tt FTU\_distributor.vhd} & {\tt FTU/dac\_spi} & yes & yes & DAC loop\\
|
---|
254 | \hline
|
---|
255 | {\tt FTU\_controller.vhd} & {\tt FTU/dac\_spi} & yes & yes & low level SPI\\
|
---|
256 | \hline\hline
|
---|
257 | {\tt FTU\_dna\_gen.vhd} & {\tt FTU/dna} & yes & yes & DNA readout\\
|
---|
258 | \hline\hline
|
---|
259 | {\tt FTU\_dual\_port\_ram64.vhd} & {\tt FTU/ram64} & yes & yes & RAM interface\\
|
---|
260 | \hline
|
---|
261 | {\tt FTU\_dual\_port\_ram64.ngc} & {\tt FTU/ram64} & no & yes & RAM netlist\\
|
---|
262 | \hline\hline
|
---|
263 | {\tt FTU\_rs485\_control.vhd} & {\tt FTU/rs485} & yes & yes & RS485 top entity\\
|
---|
264 | \hline
|
---|
265 | {\tt FTU\_rs485\_interpreter.vhd} & {\tt FTU/rs485} & yes & yes & data decoding\\
|
---|
266 | \hline
|
---|
267 | {\tt FTU\_rs485\_receiver.vhd} & {\tt FTU/rs485} & yes & yes & 28-byte buffer\\
|
---|
268 | \hline
|
---|
269 | {\tt FTU\_rs485\_interface.vhd} & {\tt FTU/rs485} & yes & yes & low level RS485\\
|
---|
270 | \hline
|
---|
271 | {\tt ucrc\_par.vhd} & {\tt FTU/rs485} & yes & yes & check sum\\
|
---|
272 | \hline
|
---|
273 | \end{tabular}
|
---|
274 | \caption{List of all source files needed to compile the FTU firmware.}
|
---|
275 | \label{tab:files}
|
---|
276 | \end{table}
|
---|
277 |
|
---|
278 | \chapter{Register Tables}
|
---|
279 | \label{cha:registers}
|
---|
280 |
|
---|
281 | There are 40 accessible control and rate registers implemented in the FTU
|
---|
282 | firmware, each with a size of 8\,bit. They are organized as a 64-byte RAM (see
|
---|
283 | also section~\ref{sec:organization:design:ram}), the last 24 bytes of which
|
---|
284 | are empty and serve as spares. Table~\ref{tab:RAM} presents an overview of the
|
---|
285 | address space inside the RAM, more details can be found in
|
---|
286 | tables~\ref{tab:enables} - \ref{tab:overflow}. Registers marked as read-only
|
---|
287 | cannot be written by the FTM, but are updated by the FTU itself.
|
---|
288 |
|
---|
289 | \begin{table}[htbp]
|
---|
290 | \centering
|
---|
291 | \begin{tabular}{|c|l|l|}
|
---|
292 | \hline
|
---|
293 | RAM address & register block & comment\\
|
---|
294 | \hline\hline
|
---|
295 | $00 \dots 07$ & enable patterns & read/write\\
|
---|
296 | \hline
|
---|
297 | $08 \dots 27$ & rate counters & read-only\\
|
---|
298 | \hline
|
---|
299 | $28 \dots 37$ & DAC settings & read/write\\
|
---|
300 | \hline
|
---|
301 | $38$ & prescaling $y$ (see section~\ref{sec:organization:design:counter}) & read/write \\
|
---|
302 | \hline
|
---|
303 | $39$ & overflow bits & read-only \\
|
---|
304 | \hline
|
---|
305 | $40 \dots 63$ & empty & spare \\
|
---|
306 | \hline
|
---|
307 | \end{tabular}
|
---|
308 | \caption{Overview of the register mapping inside the RAM.}
|
---|
309 | \label{tab:RAM}
|
---|
310 | \end{table}
|
---|
311 |
|
---|
312 | \section{Enable Patterns}
|
---|
313 |
|
---|
314 | \begin{table}[htbp]
|
---|
315 | \centering
|
---|
316 | %\small
|
---|
317 | \begin{tabular}{|c||l|l|l|l|l|l|l|l|}
|
---|
318 | \hline
|
---|
319 | address & bit~7 & bit~6 & bit~5 & bit~4 & bit~3 & bit~2 & bit~1 & bit~0 \\
|
---|
320 | \hline\hline
|
---|
321 | 00 & En\_A7 & En\_A6 & En\_A5 & En\_A4 & En\_A3 & En\_A2 & En\_A1 &
|
---|
322 | En\_A0 \\
|
---|
323 | \hline
|
---|
324 | 01 & \- & \- & \- & \- & \- & \- & \- & En\_A8 \\
|
---|
325 | \hline
|
---|
326 | 02 & En\_B7 & En\_B6 & En\_B5 & En\_B4 & En\_B3 & En\_B2 & En\_B1 &
|
---|
327 | En\_B0 \\
|
---|
328 | \hline
|
---|
329 | 03 & \- & \- & \- & \- & \- & \- & \- & En\_B8 \\
|
---|
330 | \hline
|
---|
331 | 04 & En\_C7 & En\_C6 & En\_C5 & En\_C4 & En\_C3 & En\_C2 & En\_C1 &
|
---|
332 | En\_C0 \\
|
---|
333 | \hline
|
---|
334 | 05 & \- & \- & \- & \- & \- & \- & \- & En\_C8 \\
|
---|
335 | \hline
|
---|
336 | 06 & En\_D7 & En\_D6 & En\_D5 & En\_D4 & En\_D3 & En\_D2 & En\_D1 &
|
---|
337 | En\_D0 \\
|
---|
338 | \hline
|
---|
339 | 07 & \- & \- & \- & \- & \- & \- & \- & En\_D8\\
|
---|
340 | \hline
|
---|
341 | \end{tabular}
|
---|
342 | \caption{Mapping of the $4 \times 9$ enable bits inside the RAM.}
|
---|
343 | \label{tab:enables}
|
---|
344 | \end{table}
|
---|
345 |
|
---|
346 | \section{Rate Counters}
|
---|
347 |
|
---|
348 | \begin{table}[htbp]
|
---|
349 | \centering
|
---|
350 | %\small
|
---|
351 | \begin{tabular}{|c||l|l|l|l|l|l|l|l|}
|
---|
352 | \hline
|
---|
353 | address & bit~7 & bit~6 & bit~5 & bit~4 & bit~3 & bit~2 & bit~1 & bit~0 \\
|
---|
354 | \hline\hline
|
---|
355 | 08 & Ct\_A7 & Ct\_A6 & Ct\_A5 & Ct\_A4 & Ct\_A3 & Ct\_A2 & Ct\_A1 & Ct\_A0 \\
|
---|
356 | \hline
|
---|
357 | 09 & Ct\_A15 & Ct\_A14 & Ct\_A13 & Ct\_A12 & Ct\_A11 & Ct\_A10 & Ct\_A9 & Ct\_A8 \\
|
---|
358 | \hline
|
---|
359 | 10 & Ct\_A23 & Ct\_A22 & Ct\_A21 & Ct\_A20 & Ct\_A19 & Ct\_A18 & Ct\_A17 & Ct\_A16 \\
|
---|
360 | \hline
|
---|
361 | 11 & 0 & 0 & Ct\_A29 & Ct\_A28 & Ct\_A27 & Ct\_A26 & Ct\_A25 & Ct\_A24 \\
|
---|
362 | \hline\hline
|
---|
363 | $\dots$ & $\dots$ & $\dots$ & $\dots$ & $\dots$ & $\dots$ & $\dots$ & $\dots$ & $\dots$ \\
|
---|
364 | \hline\hline
|
---|
365 | 20 & Ct\_D7 & Ct\_D6 & Ct\_D5 & Ct\_D4 & Ct\_D3 & Ct\_D2 & Ct\_D1 & Ct\_D0 \\
|
---|
366 | \hline
|
---|
367 | 21 & Ct\_D15 & Ct\_D14 & Ct\_D13 & Ct\_D12 & Ct\_D11 & Ct\_D10 & Ct\_D9 & Ct\_D8 \\
|
---|
368 | \hline
|
---|
369 | 22 & Ct\_D23 & Ct\_D22 & Ct\_D21 & Ct\_D20 & Ct\_D19 & Ct\_D18 & Ct\_D17 & Ct\_D16 \\
|
---|
370 | \hline
|
---|
371 | 23 & 0 & 0 & Ct\_D29 & Ct\_D28 & Ct\_D27 & Ct\_D26 & Ct\_D25 & Ct\_D24 \\
|
---|
372 | \hline\hline
|
---|
373 | 24 & Ct\_T7 & Ct\_T6 & Ct\_T5 & Ct\_T4 & Ct\_T3 & Ct\_T2 & Ct\_T1 & Ct\_T0 \\
|
---|
374 | \hline
|
---|
375 | 25 & Ct\_T15 & Ct\_T14 & Ct\_T13 & Ct\_T12 & Ct\_T11 & Ct\_T10 & Ct\_T9 & Ct\_T8 \\
|
---|
376 | \hline
|
---|
377 | 26 & Ct\_T23 & Ct\_T22 & Ct\_T21 & Ct\_T20 & Ct\_T19 & Ct\_T18 & Ct\_T17 & Ct\_T16 \\
|
---|
378 | \hline
|
---|
379 | 27 & 0 & 0 & Ct\_T29 & Ct\_T28 & Ct\_T27 & Ct\_T26 & Ct\_T25 & Ct\_T24 \\
|
---|
380 | \hline
|
---|
381 | \end{tabular}
|
---|
382 | \caption{Mapping of the four patch counter (A--D) and the trigger counter
|
---|
383 | reading (T) inside the RAM. The two most significant bits of the 32 bits per counter are always
|
---|
384 | set to 0.}
|
---|
385 | \label{tab:rates}
|
---|
386 | \end{table}
|
---|
387 |
|
---|
388 | \section{DAC Settings}
|
---|
389 |
|
---|
390 | \begin{table}[htbp]
|
---|
391 | \centering
|
---|
392 | \begin{tabular}{|c|l|}
|
---|
393 | \hline
|
---|
394 | address & data[$7 \dots 0$]\\
|
---|
395 | \hline\hline
|
---|
396 | 28 & DAC\_A\_[$7 \dots 0$] \\
|
---|
397 | \hline
|
---|
398 | 29 & DAC\_A\_[$15 \dots 8$] \\
|
---|
399 | \hline
|
---|
400 | $\dots$ & $\dots$\\
|
---|
401 | \hline
|
---|
402 | 34 & DAC\_D\_[$7 \dots 0$] \\
|
---|
403 | \hline
|
---|
404 | 35 & DAC\_D\_[$15 \dots 8$] \\
|
---|
405 | \hline
|
---|
406 | 36 & DAC\_H\_[$7 \dots 0$] \\
|
---|
407 | \hline
|
---|
408 | 37 & DAC\_H\_[$15 \dots 8$] \\
|
---|
409 | \hline
|
---|
410 | \end{tabular}
|
---|
411 | \caption{Mapping of the DAC values (12\,bit) for the thresholds (DAC\_A -- DAC\_D) and the
|
---|
412 | $n$-out-of-4 logic (DAC\_H) inside the RAM; the bits $15\dots 12$ are filled up with zeros.}
|
---|
413 | \label{tab:dacs}
|
---|
414 | \end{table}
|
---|
415 |
|
---|
416 | \section{Overflow Bits}
|
---|
417 |
|
---|
418 | \begin{table}[htbp]
|
---|
419 | \centering
|
---|
420 | \begin{tabular}{|l|c|c|c|c|c|c|}
|
---|
421 | \hline
|
---|
422 | bit & $7 \dots 5$ & 4 & 3 & 2 & 1 & 0 \\
|
---|
423 | \hline\hline
|
---|
424 | content & not used & overflow\_T & overflow\_D & overflow\_C & overflow\_B & overflow\_A \\
|
---|
425 | \hline
|
---|
426 | \end{tabular}
|
---|
427 | \caption{Bit mapping inside the RAM overflow register (address 39).}
|
---|
428 | \label{tab:overflow}
|
---|
429 | \end{table}
|
---|
430 |
|
---|
431 | \chapter{Communication with FTM}
|
---|
432 | \label{cha:communication}
|
---|
433 |
|
---|
434 | The slow control system between the FTU boards (slaves) and the FTM (master)
|
---|
435 | is based on two transmission sequences: Either the FTM is sending data to a
|
---|
436 | particular FTU, or a particular FTU is answering to the FTM. Broadcast
|
---|
437 | commands are not supported. Each board has a unique 1-byte address for
|
---|
438 | identification on the RS485 buses, which is 0--63 for the FTUs\footnote{Two
|
---|
439 | bits are used to specify the crate, four bits to indicate the slot position
|
---|
440 | within a crate. This 6-bit address is different from the 57-bit DNA which is
|
---|
441 | FPGA-bound (see section~\ref{sec:organization:design:dna}).} and 192 for the
|
---|
442 | FTM. The transmission sequences are of fixed length (28\,byte) and, if
|
---|
443 | necessary, filled up with arbitrary data. In case the data transmission is
|
---|
444 | disturbed or not complete, a time-out system ensures that the communication
|
---|
445 | doesn't get stuck\footnote{At a baud rate of 250\,kHz, for example, this
|
---|
446 | time-out is set to 2\,ms on the FTU side.}. In the following, the slow
|
---|
447 | control protocol, the instruction codes and the check sum error-detection are
|
---|
448 | discussed.
|
---|
449 |
|
---|
450 | \section{Transmission Protocol}
|
---|
451 |
|
---|
452 | Table~\ref{tab:protocol} summarizes the structure of the data sequences sent
|
---|
453 | between the FTM and the FTUs. A FTU only replies if contacted by the FTM. The
|
---|
454 | answer is a copy of the received data package with swapped source/destination
|
---|
455 | address and eventually the requested data. Byte 26 is used to transmit the
|
---|
456 | number of CRC errors counted by a FTU until a valid sequence arrived. In that
|
---|
457 | case the number of errors is communicated and the error counter is set to 0.
|
---|
458 |
|
---|
459 | \begin{table}[htbp]
|
---|
460 | \centering
|
---|
461 | \begin{tabular}{|c|l|l|}\hline
|
---|
462 | byte & content & comment \\
|
---|
463 | \hline\hline
|
---|
464 | $00$ & start delimiter & ASCI @ (binary "01000000")\\
|
---|
465 | \hline
|
---|
466 | $01$ & destination address & 192 (FTM) or slot position 0--63 (FTUs)\\
|
---|
467 | \hline
|
---|
468 | $02$ & source address & 192 (FTM) or slot position 0--63 (FTUs)\\
|
---|
469 | \hline
|
---|
470 | $03$ & firmware ID & firmware version of source FPGA\\
|
---|
471 | \hline
|
---|
472 | $04$ & instruction / info & see section~\ref{cha:communication:instr}\\
|
---|
473 | \hline
|
---|
474 | $05 \dots 25$ & 21 byte data & DACs, rates, etc.\\
|
---|
475 | \hline
|
---|
476 | $26$ & CRC error counter & number of CRC errors on FTU \\
|
---|
477 | \hline
|
---|
478 | $27$ & check sum & CRC-8-CCITT, see section~\ref{cha:communication:crc}\\
|
---|
479 | \hline
|
---|
480 | \end{tabular}
|
---|
481 | \caption{Composition of the FTM-FTU slow control data packages.}
|
---|
482 | \label{tab:protocol}
|
---|
483 | \end{table}
|
---|
484 |
|
---|
485 | \section{Instruction Table}
|
---|
486 | \label{cha:communication:instr}
|
---|
487 |
|
---|
488 | A set of eight instructions has been foreseen for the communication between
|
---|
489 | the FTM and the FTUs. They are listed in table~\ref{tab:instructions}
|
---|
490 | including a short description. In case a FTU receives the ping-pong command,
|
---|
491 | it returns also the DNA of its FPGA (see
|
---|
492 | section~\ref{sec:organization:design:dna}). Combined with the 6-bit address,
|
---|
493 | which is related to the geographical position insided the camera crates, it is
|
---|
494 | therefore possible to identify each FTU.
|
---|
495 |
|
---|
496 | \begin{table}[htbp]
|
---|
497 | \centering
|
---|
498 | \begin{tabular}{|c|l|l|}
|
---|
499 | \hline
|
---|
500 | code & instruction & description \\
|
---|
501 | \hline\hline
|
---|
502 | 00 & set DAC & write new values into DAC registers \\
|
---|
503 | \hline
|
---|
504 | 01 & read DAC & read back content of DAC registers \\
|
---|
505 | \hline
|
---|
506 | 02 & read rates & read out rates and overflow bits \\
|
---|
507 | \hline
|
---|
508 | 03 & set enable & write new patterns into enable registers \\
|
---|
509 | \hline
|
---|
510 | 04 & read enable & read back content of enable registers \\
|
---|
511 | \hline
|
---|
512 | 05 & ping-pong & ping a FTU to check communication (see text)\\
|
---|
513 | \hline
|
---|
514 | 06 & set counter mode & write into the prescaling register \\
|
---|
515 | \hline
|
---|
516 | 07 & read counter mode & read back prescaling and overflow registers \\
|
---|
517 | \hline
|
---|
518 | \end{tabular}
|
---|
519 | \caption{Instruction set for the FTM-FTU slow control communication.}
|
---|
520 | \label{tab:instructions}
|
---|
521 | \end{table}
|
---|
522 |
|
---|
523 | \section{CRC Calculation}
|
---|
524 | \label{cha:communication:crc}
|
---|
525 |
|
---|
526 | The integrity of the 28-byte data packages is evaluated by means of a Cyclic
|
---|
527 | Redundancy Check (CRC). The 8-CCITT CRC has been chosen which is based on the
|
---|
528 | polynomial $x^8 + x^2 + x + 1$ (00000111, omitting the most significant
|
---|
529 | bit). Bytes 0--26 of table~\ref{tab:protocol} constitute the input vector for
|
---|
530 | the CRC calculation, the resulting 1-byte check sum being compared with the
|
---|
531 | one transmitted by the FTM (byte 27 in table~\ref{tab:protocol}). If the check
|
---|
532 | sum turns out to be wrong, the FTU doesn't answer and increases the number of
|
---|
533 | error counts. The FTM will consequently run into a time-out and repeat its
|
---|
534 | command. After a valid sequence has finally arrived, the FTU will include in
|
---|
535 | its answer the number of CRC errors counted (byte 26 in
|
---|
536 | table~\ref{tab:protocol}) and reset the error counter.
|
---|
537 |
|
---|
538 | \chapter{Finite State Machines}
|
---|
539 | \label{cha:fsm}
|
---|
540 |
|
---|
541 | There are several finite state machines (FSM) used in the FTU firmware design,
|
---|
542 | distributed over several files. They are in principal all running in parallel,
|
---|
543 | some of them are, however, only waking up if triggered by the main
|
---|
544 | control. This is for example the case for the SPI interface controlling the
|
---|
545 | DAC settings. Since the most complicated FSMs are inside {\tt FTU\_control}
|
---|
546 | and {\tt FTU\_rs485\_control} (see section~\ref{sec:organization:design}),
|
---|
547 | they are explained in more detail in this chapter.
|
---|
548 |
|
---|
549 | \section{Main Control FSM}
|
---|
550 |
|
---|
551 | This state machine has full control over the FTU board during operation. After
|
---|
552 | power-up or reboot it is in an {\tt IDLE} state, waiting for the DCMs to
|
---|
553 | lock. Afterwards it passes through two {\tt INIT} sequences, where default
|
---|
554 | values for all registers are written to the RAM and the DNA is read out. The
|
---|
555 | defaults are all defined in the library {\tt ftu\_definitions}. When the
|
---|
556 | initialization has finished, the {\tt RUNNING} state is entered. This is the
|
---|
557 | principal state during which the board is counting triggers. {\tt RUNNING} is
|
---|
558 | left only if a counting period has finished and the number of counts is stored
|
---|
559 | in the RAM, or if a command has arrived via RS485 and is communicated by the
|
---|
560 | responsible FSM (see next section). A dedicated state has been implemented for
|
---|
561 | each possible command and, if appropriate, also for the subsequent change of
|
---|
562 | settings (e.g. {\tt CONFIG\_DAC}). In any case the board goes back to {\tt
|
---|
563 | RUNNING}.
|
---|
564 |
|
---|
565 | \section{RS485 Control FSM}
|
---|
566 |
|
---|
567 | The main and default state of this FSM is {\tt RECEIVE}. This means that the
|
---|
568 | RS485 receiver is enabled and the board is waiting for commands from the
|
---|
569 | FTM. If a full 28-byte package has arrived and correctly been
|
---|
570 | decoded\footnote{This involves a further state machine which is inside the
|
---|
571 | file {\tt FTU\_rs485\_interpreter.vhd}}, the main control FSM is informed
|
---|
572 | about the instruction (e.g. new DACs). The RS485 FSM then enters a wait state
|
---|
573 | (e.g. {\tt SET\_DAC\_WAIT}) until it gets an internal ready signal. It
|
---|
574 | subsequently sends the answer to the FTM (e.g. {\tt SET\_DAC\_TRANSMIT}) and
|
---|
575 | goes back to {\tt RECEIVE}. While during {\tt RECEIVE} the RS485 FSM and all
|
---|
576 | processes below are running in parallel to the main control FSM, the sequence
|
---|
577 | of states in case a command has arrived is prescribed.
|
---|
578 |
|
---|
579 | \end{document} |
---|