| 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 v1~~~-~~~September 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 16\,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. Some modules within the FTU design have built-in clock dividers to
|
|---|
| 133 | generate custom frequencies which are, however, all derived from the central
|
|---|
| 134 | clock.
|
|---|
| 135 |
|
|---|
| 136 | \subsection{\tt FTU\_dual\_port\_ram}
|
|---|
| 137 | \label{sec:organization:design:ram}
|
|---|
| 138 |
|
|---|
| 139 | All FTU registers which can be set from outside during operation are stored in
|
|---|
| 140 | a dual-port block RAM (Random Access Memory). The FPGA provides specific
|
|---|
| 141 | resources for this purpose, and therefore the RAM has been created using the
|
|---|
| 142 | Xilinx core generator tools. The entity {\tt FTU\_dual\_port\_ram} serves as
|
|---|
| 143 | an interface to the RAM, the actual gate level description is stored directly
|
|---|
| 144 | in the net-list file {\tt FTU\_dual\_port\_ram.ngc}. Thus this file is part of
|
|---|
| 145 | the design, although not available as source code. The RAM has a size of
|
|---|
| 146 | 32\,bytes and two fully featured ports to access its content. One port is
|
|---|
| 147 | based on 1-byte words, the other one on 2-byte words. The corresponding
|
|---|
| 148 | address space is presented together with the register tables in
|
|---|
| 149 | chapter~\ref{cha:registers}. In addition to the control registers, also the
|
|---|
| 150 | current counter readings are stored in the RAM.
|
|---|
| 151 |
|
|---|
| 152 | \subsection{\tt FTU\_rate\_counter}
|
|---|
| 153 | \label{sec:organization:design:counter}
|
|---|
| 154 |
|
|---|
| 155 | Here the trigger counting is done. A rate counter has a range of 16\,bit and
|
|---|
| 156 | counts until a defined period is finished. This period is derived from an
|
|---|
| 157 | 8-bit prescaling value $y$ as $ T = \frac{y+1}{2}$\,s. In total five such
|
|---|
| 158 | counters are instantiated which are running and set up synchronously. If the
|
|---|
| 159 | FTU settings are changed during operation all counters are reset. Only in case
|
|---|
| 160 | a full period has been finished without interruption, the number of counts
|
|---|
| 161 | from each counter is stored in the RAM. An overflow flag is set by the
|
|---|
| 162 | counters if necessary.
|
|---|
| 163 |
|
|---|
| 164 | \subsection{\tt FTU\_spi\_interface}
|
|---|
| 165 |
|
|---|
| 166 | The octal DAC defining the trigger thresholds is controlled by means of a
|
|---|
| 167 | SPI. As soon as the {\tt FTU\_spi\_interface} entity receives a start signal,
|
|---|
| 168 | it will clock out the data pending at one of its input ports to the DAC. These
|
|---|
| 169 | data are provided in form of a customized array. The generation of the serial
|
|---|
| 170 | clock, the distribution of the DAC values to the right addresses and the
|
|---|
| 171 | actual transmission of the data to the chip are performed by three more
|
|---|
| 172 | entities, which are instantiated inside {\tt FTU\_spi\_interface}. Once the
|
|---|
| 173 | transmission has started or finished, respectively, a signal is pulled.
|
|---|
| 174 |
|
|---|
| 175 | \subsection{\tt FTU\_rs485\_control}
|
|---|
| 176 |
|
|---|
| 177 | The communication between the FTU and the FTM is handled by a RS485
|
|---|
| 178 | interface. The top level entity of this module is called {\tt
|
|---|
| 179 | FTU\_rs485\_control}. It contains a state machine and further sub-entities
|
|---|
| 180 | for frame receiving or transmitting, byte buffering and instruction
|
|---|
| 181 | decoding. The details of the underlying protocol and the possible instructions
|
|---|
| 182 | are detailed in chapter~\ref{cha:communication}. In case an instruction has
|
|---|
| 183 | been decoded successfully, the main FTU control is informed and the
|
|---|
| 184 | corresponding data (like new DAC values) are provided. After the command has
|
|---|
| 185 | been executed an answer is send to the FTM. {\tt FTU\_rs485\_control} has
|
|---|
| 186 | direct control of the involved transmitter/receiver chip outside the FPGA and
|
|---|
| 187 | takes care that it is only transmitting if this particular FTU has been
|
|---|
| 188 | contacted by the FTM. In this way also the rates are send on request. The baud
|
|---|
| 189 | rate is adjustable and defined in the library {\tt ftu\_definitions}.
|
|---|
| 190 |
|
|---|
| 191 | \subsection{\tt FTU\_control}
|
|---|
| 192 |
|
|---|
| 193 | This entity contains the main state machine of the FTU firmware. It receives
|
|---|
| 194 | control, ready, start, etc. flags from all modules and interfaces and reacts
|
|---|
| 195 | accordingly by changing to a new state. This may be done with some delay,
|
|---|
| 196 | depending on what the board is doing at the moment. {\tt FTU\_control} is
|
|---|
| 197 | furthermore the only place in the design from where the RAM is read or
|
|---|
| 198 | written. The state machine is described in more detail in
|
|---|
| 199 | chapter~\ref{cha:fsm}.
|
|---|
| 200 |
|
|---|
| 201 | \section{File Structure}
|
|---|
| 202 |
|
|---|
| 203 | Table~\ref{tab:files} specifies all source files necessary to compile the
|
|---|
| 204 | firmware for the FTU boards\footnote{As of September 2010; the list might be
|
|---|
| 205 | extended, for example, to include source files for the read out of the FPGA
|
|---|
| 206 | serial number (device ID).}. For each file its location path inside the
|
|---|
| 207 | directory {\tt firmware} of the FACT repository is stated. Furthermore it is
|
|---|
| 208 | indicated whether a certain file is needed for the simulation and/or the
|
|---|
| 209 | hardware implementation. The design entities described in
|
|---|
| 210 | section~\ref{sec:organization:design} are contained in those files which have
|
|---|
| 211 | the corresponding prefix. The file {\tt ucrc\_par.vhd} has been downloaded
|
|---|
| 212 | from OpenCores\footnote{Ultimate CRC project:
|
|---|
| 213 | \url{http://www.opencores.org/cores/ultimate_crc} (free software under the
|
|---|
| 214 | terms of the GNU General Public License).}.
|
|---|
| 215 |
|
|---|
| 216 | \begin{table}[htbp]
|
|---|
| 217 | \centering
|
|---|
| 218 | \begin{tabular}{|l|l|l|l|l|}
|
|---|
| 219 | \hline
|
|---|
| 220 | file name & location & simulation & implement & comment \\
|
|---|
| 221 | \hline\hline
|
|---|
| 222 | {\tt FTU\_top.vhd} & {\tt FTU} & yes & yes & top level entity\\
|
|---|
| 223 | \hline
|
|---|
| 224 | {\tt FTU\_top\_tb.vhd} & {\tt FTU} & yes & no & test bench\\
|
|---|
| 225 | \hline
|
|---|
| 226 | {\tt ftu\_definitions.vhd} & {\tt FTU} & yes & yes & library\\
|
|---|
| 227 | \hline
|
|---|
| 228 | {\tt ftu\_board.ucf} & {\tt FTU} & no & yes & pin constraints\\
|
|---|
| 229 | \hline
|
|---|
| 230 | {\tt FTU\_control.vhd} & {\tt FTU} & yes & yes & top state machine\\
|
|---|
| 231 | \hline\hline
|
|---|
| 232 | {\tt FTU\_clk\_gen.vhd} & {\tt FTU/clock} & yes & yes & clock interface\\
|
|---|
| 233 | \hline
|
|---|
| 234 | {\tt FTU\_dcm\_50M\_to\_50M.vhd} & {\tt FTU/clock} & yes & yes & clock manager\\
|
|---|
| 235 | \hline\hline
|
|---|
| 236 | {\tt FTU\_rate\_counter.vhd} & {\tt FTU/counter} & yes & yes & trigger counter\\
|
|---|
| 237 | \hline\hline
|
|---|
| 238 | {\tt FTU\_spi\_interface.vhd} & {\tt FTU/dac\_spi} & yes & yes & SPI top entity\\
|
|---|
| 239 | \hline
|
|---|
| 240 | {\tt FTU\_spi\_clock\_gen.vhd} & {\tt FTU/dac\_spi} & yes & yes & serial clock\\
|
|---|
| 241 | \hline
|
|---|
| 242 | {\tt FTU\_distributor.vhd} & {\tt FTU/dac\_spi} & yes & yes & DAC loop\\
|
|---|
| 243 | \hline
|
|---|
| 244 | {\tt FTU\_controller.vhd} & {\tt FTU/dac\_spi} & yes & yes & low level SPI\\
|
|---|
| 245 | \hline\hline
|
|---|
| 246 | {\tt FTU\_dual\_port\_ram.vhd} & {\tt FTU/ram} & yes & yes & RAM interface\\
|
|---|
| 247 | \hline
|
|---|
| 248 | {\tt FTU\_dual\_port\_ram.ngc} & {\tt FTU/ram} & no & yes & RAM netlist\\
|
|---|
| 249 | \hline\hline
|
|---|
| 250 | {\tt FTU\_rs485\_control.vhd} & {\tt FTU/rs485} & yes & yes & RS485 top entity\\
|
|---|
| 251 | \hline
|
|---|
| 252 | {\tt FTU\_rs485\_interpreter.vhd} & {\tt FTU/rs485} & yes & yes & data decoding\\
|
|---|
| 253 | \hline
|
|---|
| 254 | {\tt FTU\_rs485\_receiver.vhd} & {\tt FTU/rs485} & yes & yes & 16~byte buffer\\
|
|---|
| 255 | \hline
|
|---|
| 256 | {\tt FTU\_rs485\_interface.vhd} & {\tt FTU/rs485} & yes & yes & low level RS485\\
|
|---|
| 257 | \hline
|
|---|
| 258 | {\tt ucrc\_par.vhd} & {\tt FTU/rs485} & yes & yes & check sum\\
|
|---|
| 259 | \hline
|
|---|
| 260 | \end{tabular}
|
|---|
| 261 | \caption{List of all source files needed to compile the FTU firmware.}
|
|---|
| 262 | \label{tab:files}
|
|---|
| 263 | \end{table}
|
|---|
| 264 |
|
|---|
| 265 | \chapter{Register Tables}
|
|---|
| 266 | \label{cha:registers}
|
|---|
| 267 |
|
|---|
| 268 | There are 31 control and rate registers implemented in the FTU firmware, each
|
|---|
| 269 | with a size of 8\,bit. They are organized as a 32-byte RAM (see also
|
|---|
| 270 | section~\ref{sec:organization:design:ram}), the last byte of which is empty
|
|---|
| 271 | and serves as spare. Table~\ref{tab:RAM} presents an overview of the address
|
|---|
| 272 | space inside the RAM, more details can be found in tables~\ref{tab:enables} -
|
|---|
| 273 | \ref{tab:overflow}. Registers marked as read-only cannot be written by the
|
|---|
| 274 | FTM, but are updated by the FTU itself.
|
|---|
| 275 |
|
|---|
| 276 | \begin{table}[htbp]
|
|---|
| 277 | \centering
|
|---|
| 278 | \begin{tabular}{|c|l|l|}
|
|---|
| 279 | \hline
|
|---|
| 280 | RAM address & register block & comment\\
|
|---|
| 281 | \hline\hline
|
|---|
| 282 | $0 \dots 7$ & enable patterns & read/write\\
|
|---|
| 283 | \hline
|
|---|
| 284 | $8 \dots 17$ & rate counters & read-only\\
|
|---|
| 285 | \hline
|
|---|
| 286 | $18 \dots 27$ & DAC settings & read/write\\
|
|---|
| 287 | \hline
|
|---|
| 288 | $28$ & prescaling $y$ (see section~\ref{sec:organization:design:counter}) & read/write \\
|
|---|
| 289 | \hline
|
|---|
| 290 | $29$ & overflow bits & read-only \\
|
|---|
| 291 | \hline
|
|---|
| 292 | $30$ & check sum error counter & read-only\\
|
|---|
| 293 | \hline
|
|---|
| 294 | $31$ & empty & spare \\
|
|---|
| 295 | \hline
|
|---|
| 296 | \end{tabular}
|
|---|
| 297 | \caption{Overview of the register mapping inside the RAM.}
|
|---|
| 298 | \label{tab:RAM}
|
|---|
| 299 | \end{table}
|
|---|
| 300 |
|
|---|
| 301 | \section{Enable Patterns}
|
|---|
| 302 |
|
|---|
| 303 | \begin{table}[htbp]
|
|---|
| 304 | \centering
|
|---|
| 305 | %\small
|
|---|
| 306 | \begin{tabular}{|c||l|l|l|l|l|l|l|l|}
|
|---|
| 307 | \hline
|
|---|
| 308 | address & bit~7 & bit~6 & bit~5 & bit~4 & bit~3 & bit~2 & bit~1 & bit~0 \\
|
|---|
| 309 | \hline\hline
|
|---|
| 310 | 00 & En\_A7 & En\_A6 & En\_A5 & En\_A4 & En\_A3 & En\_A2 & En\_A1 &
|
|---|
| 311 | En\_A0 \\
|
|---|
| 312 | \hline
|
|---|
| 313 | 01 & \- & \- & \- & \- & \- & \- & \- & En\_A8 \\
|
|---|
| 314 | \hline
|
|---|
| 315 | 02 & En\_B7 & En\_B6 & En\_B5 & En\_B4 & En\_B3 & En\_B2 & En\_B1 &
|
|---|
| 316 | En\_B0 \\
|
|---|
| 317 | \hline
|
|---|
| 318 | 03 & \- & \- & \- & \- & \- & \- & \- & En\_B8 \\
|
|---|
| 319 | \hline
|
|---|
| 320 | 04 & En\_C7 & En\_C6 & En\_C5 & En\_C4 & En\_C3 & En\_C2 & En\_C1 &
|
|---|
| 321 | En\_C0 \\
|
|---|
| 322 | \hline
|
|---|
| 323 | 05 & \- & \- & \- & \- & \- & \- & \- & En\_C8 \\
|
|---|
| 324 | \hline
|
|---|
| 325 | 06 & En\_D7 & En\_D6 & En\_D5 & En\_D4 & En\_D3 & En\_D2 & En\_D1 &
|
|---|
| 326 | En\_D0 \\
|
|---|
| 327 | \hline
|
|---|
| 328 | 07 & \- & \- & \- & \- & \- & \- & \- & En\_D8\\
|
|---|
| 329 | \hline
|
|---|
| 330 | \end{tabular}
|
|---|
| 331 | \caption{Mapping of the $4 \times 9$ enable bits inside the RAM.}
|
|---|
| 332 | \label{tab:enables}
|
|---|
| 333 | \end{table}
|
|---|
| 334 |
|
|---|
| 335 | \section{Rate Counters}
|
|---|
| 336 |
|
|---|
| 337 | \begin{table}[htbp]
|
|---|
| 338 | \centering
|
|---|
| 339 | %\small
|
|---|
| 340 | \begin{tabular}{|c||l|l|l|l|l|l|l|l|}
|
|---|
| 341 | \hline
|
|---|
| 342 | address & bit~7 & bit~6 & bit~5 & bit~4 & bit~3 & bit~2 & bit~1 & bit~0 \\
|
|---|
| 343 | \hline\hline
|
|---|
| 344 | 08 & Ct\_A7 & Ct\_A6 & Ct\_A5 & Ct\_A4 & Ct\_A3 & Ct\_A2 & Ct\_A1 & Ct\_A0 \\
|
|---|
| 345 | \hline
|
|---|
| 346 | 09 & Ct\_A15 & Ct\_A14 & Ct\_A13 & Ct\_A12 & Ct\_A11 & Ct\_A10 & Ct\_A9 & Ct\_A8 \\
|
|---|
| 347 | \hline
|
|---|
| 348 | 10 & Ct\_B7 & Ct\_B6 & Ct\_B5 & Ct\_B4 & Ct\_B3 & Ct\_B2 & Ct\_B1 & Ct\_B0 \\
|
|---|
| 349 | \hline
|
|---|
| 350 | 11 & Ct\_B15 & Ct\_B14 & Ct\_B13 & Ct\_B12 & Ct\_B11 & Ct\_B10 & Ct\_B9 & Ct\_B8 \\
|
|---|
| 351 | \hline
|
|---|
| 352 | 12 & Ct\_C7 & Ct\_C6 & Ct\_C5 & Ct\_C4 & Ct\_C3 & Ct\_C2 & Ct\_C1 & Ct\_C0 \\
|
|---|
| 353 | \hline
|
|---|
| 354 | 13 & Ct\_C15 & Ct\_C14 & Ct\_C13 & Ct\_C12 & Ct\_C11 & Ct\_C10 & Ct\_C9 & Ct\_C8 \\
|
|---|
| 355 | \hline
|
|---|
| 356 | 14 & Ct\_D7 & Ct\_D6 & Ct\_D5 & Ct\_D4 & Ct\_D3 & Ct\_D2 & Ct\_D1 & Ct\_D0 \\
|
|---|
| 357 | \hline
|
|---|
| 358 | 15 & Ct\_D15 & Ct\_D14 & Ct\_D13 & Ct\_D12 & Ct\_D11 & Ct\_D10 & Ct\_D9 & Ct\_D8 \\
|
|---|
| 359 | \hline
|
|---|
| 360 | 16 & Ct\_T7 & Ct\_T6 & Ct\_T5 & Ct\_T4 & Ct\_T3 & Ct\_T2 & Ct\_T1 & Ct\_T0 \\
|
|---|
| 361 | \hline
|
|---|
| 362 | 17 & Ct\_T15 & Ct\_T14 & Ct\_T13 & Ct\_T12 & Ct\_T11 & Ct\_T10 & Ct\_T9 & Ct\_T8 \\
|
|---|
| 363 | \hline
|
|---|
| 364 | \end{tabular}
|
|---|
| 365 | \caption{Mapping of the four patch counters and the trigger counter inside the RAM.}
|
|---|
| 366 | \label{tab:rates}
|
|---|
| 367 | \end{table}
|
|---|
| 368 |
|
|---|
| 369 | \section{DAC Settings}
|
|---|
| 370 |
|
|---|
| 371 | \begin{table}[htbp]
|
|---|
| 372 | \centering
|
|---|
| 373 | \begin{tabular}{|c|l|}
|
|---|
| 374 | \hline
|
|---|
| 375 | address & data[$7 \dots 0$]\\
|
|---|
| 376 | \hline\hline
|
|---|
| 377 | 18 & DAC\_A\_[$7 \dots 0$] \\
|
|---|
| 378 | \hline
|
|---|
| 379 | 19 & DAC\_A\_[$15 \dots 8$] \\
|
|---|
| 380 | \hline
|
|---|
| 381 | 20 & DAC\_B\_[$7 \dots 0$] \\
|
|---|
| 382 | \hline
|
|---|
| 383 | 21 & DAC\_B\_[$15 \dots 8$] \\
|
|---|
| 384 | \hline
|
|---|
| 385 | 22 & DAC\_C\_[$7 \dots 0$] \\
|
|---|
| 386 | \hline
|
|---|
| 387 | 23 & DAC\_C\_[$15 \dots 8$] \\
|
|---|
| 388 | \hline
|
|---|
| 389 | 24 & DAC\_D\_[$7 \dots 0$] \\
|
|---|
| 390 | \hline
|
|---|
| 391 | 25 & DAC\_D\_[$15 \dots 8$] \\
|
|---|
| 392 | \hline
|
|---|
| 393 | 26 & DAC\_H\_[$7 \dots 0$] \\
|
|---|
| 394 | \hline
|
|---|
| 395 | 27 & DAC\_H\_[$15 \dots 8$] \\
|
|---|
| 396 | \hline
|
|---|
| 397 | \end{tabular}
|
|---|
| 398 | \caption{Mapping of the DAC values (12\,bit) for the thresholds (DAC\_A -- DAC\_D) and the
|
|---|
| 399 | $n$-out-of-4 logic (DAC\_H) inside the RAM; the bits $15\dots 12$ are filled up with zeros.}
|
|---|
| 400 | \label{tab:dacs}
|
|---|
| 401 | \end{table}
|
|---|
| 402 |
|
|---|
| 403 | \section{Overflow Bits}
|
|---|
| 404 |
|
|---|
| 405 | \begin{table}[htbp]
|
|---|
| 406 | \centering
|
|---|
| 407 | \begin{tabular}{|l|c|c|c|c|c|c|}
|
|---|
| 408 | \hline
|
|---|
| 409 | bit & $7 \dots 5$ & 4 & 3 & 2 & 1 & 0 \\
|
|---|
| 410 | \hline\hline
|
|---|
| 411 | 0 & not used & overflow\_T & overflow\_D & overflow\_C & overflow\_B & overflow\_A \\
|
|---|
| 412 | \hline
|
|---|
| 413 | \end{tabular}
|
|---|
| 414 | \caption{Bit mapping inside the RAM overflow register (address 29).}
|
|---|
| 415 | \label{tab:overflow}
|
|---|
| 416 | \end{table}
|
|---|
| 417 |
|
|---|
| 418 | \chapter{Communication with FTM}
|
|---|
| 419 | \label{cha:communication}
|
|---|
| 420 |
|
|---|
| 421 | The slow control system between the FTU boards (slaves) and the FTM (master)
|
|---|
| 422 | is based on two transmission sequences: Either the FTM is sending data to a
|
|---|
| 423 | particular FTU, or a particular FTU is answering to the FTM. Broadcast
|
|---|
| 424 | commands are not supported. Each board has an unique 1-byte address for
|
|---|
| 425 | unambiguous identification, which is 0--39 for the FTUs and 192 for the
|
|---|
| 426 | FTM. The transmission sequences are of fixed length (16\,byte) and, if
|
|---|
| 427 | necessary, filled up with arbitrary data. In case the data transmission is
|
|---|
| 428 | disturbed or not complete, a time-out system ensures that the communication
|
|---|
| 429 | doesn't get stuck\footnote{At a baud rate of 250\,kHz, for example, this
|
|---|
| 430 | time-out is set to 2\,ms on the FTU side.}. In the following, the slow
|
|---|
| 431 | control protocol, the instruction codes and the check sum error-detection are
|
|---|
| 432 | discussed.
|
|---|
| 433 |
|
|---|
| 434 | \section{Transmission Protocol}
|
|---|
| 435 |
|
|---|
| 436 | Table~\ref{tab:protocol} summarizes the structure of the data sequences sent
|
|---|
| 437 | between the FTM and the FTUs. An FTU only replies if contacted by the FTM. The
|
|---|
| 438 | answer is a copy of the received data package with swapped source/destination
|
|---|
| 439 | address and eventually the requested data.
|
|---|
| 440 |
|
|---|
| 441 | \begin{table}[htbp]
|
|---|
| 442 | \centering
|
|---|
| 443 | \begin{tabular}{|c|l|l|}\hline
|
|---|
| 444 | byte & content & comment \\
|
|---|
| 445 | \hline\hline
|
|---|
| 446 | 0 & start delimiter & ASCI @ (binary "01000000")\\
|
|---|
| 447 | \hline
|
|---|
| 448 | 1 & destination address & 192 (FTM) or slot position 0--39 (FTUs)\\
|
|---|
| 449 | \hline
|
|---|
| 450 | 2 & source address & 192 (FTM) or slot position 0--39 (FTUs)\\
|
|---|
| 451 | \hline
|
|---|
| 452 | 3 & instruction / info & see section~\ref{cha:communication:instr}\\
|
|---|
| 453 | \hline
|
|---|
| 454 | 4--14 & 11 byte data & DACs, rates, etc.\\
|
|---|
| 455 | \hline
|
|---|
| 456 | 15 & check sum & CRC-8-CCITT, see section~\ref{cha:communication:crc}\\
|
|---|
| 457 | \hline
|
|---|
| 458 | \end{tabular}
|
|---|
| 459 | \caption{Composition of the FTM-FTU slow control data packages.}
|
|---|
| 460 | \label{tab:protocol}
|
|---|
| 461 | \end{table}
|
|---|
| 462 |
|
|---|
| 463 | \section{Instruction Table}
|
|---|
| 464 | \label{cha:communication:instr}
|
|---|
| 465 |
|
|---|
| 466 | A set of eight instructions has been foreseen for the communication between
|
|---|
| 467 | the FTM and the FTUs. They are listed in table~\ref{tab:instructions}
|
|---|
| 468 | including a short description. For the ping-pong command it is currently
|
|---|
| 469 | investigated whether the FTUs can, in addition to just answer, return also the
|
|---|
| 470 | FPGA device identifier\footnote{This unique identifier has 57\,bit and is
|
|---|
| 471 | built-in for each FPGA of the Spartan-3A series. For more information see:
|
|---|
| 472 | \url{http://www.xilinx.com/support/documentation/user_guides/ug332.pdf}
|
|---|
| 473 | (Spartan-3 Generation Configuration User Guide).} (DNA).
|
|---|
| 474 |
|
|---|
| 475 | \begin{table}[htbp]
|
|---|
| 476 | \centering
|
|---|
| 477 | \begin{tabular}{|c|l|l|}
|
|---|
| 478 | \hline
|
|---|
| 479 | code & instruction & description \\
|
|---|
| 480 | \hline\hline
|
|---|
| 481 | 00 & set DAC & write new values into DAC registers \\
|
|---|
| 482 | \hline
|
|---|
| 483 | 01 & read DAC & read back content of DAC registers \\
|
|---|
| 484 | \hline
|
|---|
| 485 | 02 & read rates & read out rates and overflow bits \\
|
|---|
| 486 | \hline
|
|---|
| 487 | 03 & set enable & write new patterns into enable registers \\
|
|---|
| 488 | \hline
|
|---|
| 489 | 04 & read enable & read back content of enable registers \\
|
|---|
| 490 | \hline
|
|---|
| 491 | 05 & ping-pong & ping a FTU to check communication (see text)\\
|
|---|
| 492 | \hline
|
|---|
| 493 | 06 & set counter mode & write into the prescaling register \\
|
|---|
| 494 | \hline
|
|---|
| 495 | 07 & read counter mode & read back prescaling and overflow registers \\
|
|---|
| 496 | \hline
|
|---|
| 497 | \end{tabular}
|
|---|
| 498 | \caption{Instruction set for the FTM-FTU slow control communication.}
|
|---|
| 499 | \label{tab:instructions}
|
|---|
| 500 | \end{table}
|
|---|
| 501 |
|
|---|
| 502 | \section{CRC Calculation}
|
|---|
| 503 | \label{cha:communication:crc}
|
|---|
| 504 |
|
|---|
| 505 | The integrity of the 16-byte data packages is evaluated by means of a Cyclic
|
|---|
| 506 | Redundancy Check (CRC). An 8-CCITT CRC has been chosen which is based on the
|
|---|
| 507 | polynomial $x^8 + x^2 + x + 1$ (100000111). Bytes 0--14 of
|
|---|
| 508 | table~\ref{tab:protocol} constitute the input vector for the CRC calculation,
|
|---|
| 509 | the resulting 1-byte check sum being compared with the one transmitted by the
|
|---|
| 510 | FTM (byte 15 in table~\ref{tab:protocol}). If the check sum turns out to be
|
|---|
| 511 | wrong, the FTU doesn't answer and increases the number of error counts in its
|
|---|
| 512 | corresponding register (RAM address 30). The FTM will consequently run into a
|
|---|
| 513 | time-out and repeat its command.
|
|---|
| 514 |
|
|---|
| 515 | \chapter{Finite State Machines}
|
|---|
| 516 | \label{cha:fsm}
|
|---|
| 517 |
|
|---|
| 518 | There are several finite state machines (FSM) used in the FTU firmware design,
|
|---|
| 519 | distributed over several files. They are in principal all running in parallel,
|
|---|
| 520 | some of them are, however, only waking up if triggered by the main
|
|---|
| 521 | control. This is for example the case for the SPI interface controlling the
|
|---|
| 522 | DAC settings. Since the most complicated FSMs are inside {\tt FTU\_control}
|
|---|
| 523 | and {\tt FTU\_rs485\_control} (see section~\ref{sec:organization:design}),
|
|---|
| 524 | they are explained in more detail in this chapter.
|
|---|
| 525 |
|
|---|
| 526 | \section{Main Control FSM}
|
|---|
| 527 |
|
|---|
| 528 | This state machine has full control over the FTU board during operation. After
|
|---|
| 529 | power-up or reboot it is in an {\tt IDLE} state, waiting for the DCMs to
|
|---|
| 530 | lock. Afterwards it passes through an {\tt INIT} sequence, where default
|
|---|
| 531 | values for all registers are written to the RAM. These defaults are all
|
|---|
| 532 | defined in the library {\tt ftu\_definitions}. When {\tt INIT} has finished,
|
|---|
| 533 | the {\tt RUNNING} state is entered. This is the principal state during which
|
|---|
| 534 | the board is counting triggers. {\tt RUNNING} is left only if a counting
|
|---|
| 535 | period has finished and the number of counts is stored in the RAM, or if a
|
|---|
| 536 | command has arrived via RS485 and is communicated by the responsible FSM (see
|
|---|
| 537 | next section). A dedicated state has been implemented for each possible
|
|---|
| 538 | command and, if appropriate, also for the subsequent change of settings
|
|---|
| 539 | (e.g. {\tt CONFIG\_DAC}). In any case the board goes back to {\tt RUNNING}.
|
|---|
| 540 |
|
|---|
| 541 | \section{RS485 Control FSM}
|
|---|
| 542 |
|
|---|
| 543 | The main and default state of this FSM is {\tt RECEIVE}. This means that the
|
|---|
| 544 | RS485 receiver is enabled and the board is waiting for commands from the
|
|---|
| 545 | FTM. If a full 16-byte package has arrived and correctly been
|
|---|
| 546 | decoded\footnote{This involves a further state machine which is inside the
|
|---|
| 547 | file {\tt FTU\_rs485\_interpreter.vhd}}, the main control FSM is informed
|
|---|
| 548 | about the instruction (e.g. new DACs). The RS485 FSM then enters a wait state
|
|---|
| 549 | (e.g. {\tt SET\_DAC\_WAIT}) until it gets an internal ready signal. It
|
|---|
| 550 | subsequently sends the answer to the FTM (e.g. {\tt SET\_DAC\_TRANSMIT}) and
|
|---|
| 551 | goes back to {\tt RECEIVE}. While during {\tt RECEIVE} the RS485 FSM and all
|
|---|
| 552 | processes below are running in parallel to the main control FSM, the sequence
|
|---|
| 553 | of states in case a command has arrived is prescribed.
|
|---|
| 554 |
|
|---|
| 555 | \end{document} |
|---|