Commit feddce19 authored by Paolo Baesso's avatar Paolo Baesso

Added trigger script explanation

parent 4419d010
...@@ -104,7 +104,7 @@ DEC & I5 & I4 & I3 & I2 & I1 & I0 & PATTERN & \multicolumn{1}{l|}{\begin{tabular ...@@ -104,7 +104,7 @@ DEC & I5 & I4 & I3 & I2 & I1 & I0 & PATTERN & \multicolumn{1}{l|}{\begin{tabular
63 & 1 & 1 & 1 & 1 & 1 & 1 & \rotatebox[origin=c]{90}{1} & & & 2147483648 \\ \hline 63 & 1 & 1 & 1 & 1 & 1 & 1 & \rotatebox[origin=c]{90}{1} & & & 2147483648 \\ \hline
\end{tabular} \end{tabular}
\end{table} \end{table}
\noindent The default configuration in the firmware is Hi=~0xFFFFFFFF, Low=~0xFFFEFFFE, which means that as long as any trigger input fires, a trigger will be generated. These words are loaded in the \gls{fpga} every time the firmware is flushed.\\ \noindent The default configuration in the firmware is Hi=~0xFFFFFFFF, Low=~0xFFFEFFFE, which means that as long as any trigger input fires, a trigger will be generated. These words are loaded in the \gls{fpga} every time a new image is programmed.\\
\begin{alertinfo}{Trigger logic definition} \begin{alertinfo}{Trigger logic definition}
The user should pay attention to what trigger logic they want to define in order to avoid confusion in the data.\\ The user should pay attention to what trigger logic they want to define in order to avoid confusion in the data.\\
...@@ -112,15 +112,43 @@ DEC & I5 & I4 & I3 & I2 & I1 & I0 & PATTERN & \multicolumn{1}{l|}{\begin{tabular ...@@ -112,15 +112,43 @@ DEC & I5 & I4 & I3 & I2 & I1 & I0 & PATTERN & \multicolumn{1}{l|}{\begin{tabular
\end{alertinfo} \end{alertinfo}
\begin{alertinfo}{Bit 0 meaning} \begin{alertinfo}{Bit 0 meaning}
A 1 in the lowest bit of the \gls{lsb} word indicates that $\overline{I_{5}}$ * $\overline{I_{4}}$ * $\overline{I_{3}}$ * $\overline{I_{2}}$ * $\overline{I_{1}}$ * $\overline{I_{0}}$ is a valid trigger combination, so the \gls{tlu} will produce a trigger when all the inputs are unactive (i.e. even if all the inputs are unplugged). Apart from very specific cases, this is generally not a desired behaviour. A 1 in the lowest bit of the \gls{lsb} word indicates that $\overline{I_{5}}$ * $\overline{I_{4}}$ * $\overline{I_{3}}$ * $\overline{I_{2}}$ * $\overline{I_{1}}$ * $\overline{I_{0}}$ is a valid trigger combination, so the \gls{tlu} will produce a trigger when all the inputs are inactive (i.e. even if all the inputs are unplugged). Apart from very specific cases, this is generally not a desired behaviour.
\end{alertinfo} \end{alertinfo}
\subsubsection{Example} \subsubsection{Trigger configuration helper script}
In this example we have connected a pulser to two inputs of the \gls{tlu}, namely \verb|IN_1| and \verb|IN_5|. The inputs fire with a small, random delay with respect to each other.\\ A lightweight script is available to help configuring the \gls{tlu} trigger.\\
The file can be found in the:\\
\verb|./Documentation/Misc|\\
folder of the \gls{ohwr} documentation repository (\href{https://ohwr.org/project/fmc-mtlu}{AIDA-2020 TLU}).\\
The script is written in Python 3.x and it should be possible to run it in stand-alone mode on any machine by simply using the command\\
\verb|Python trigger_configuration_helper|\\
This will create an interactive sell; when started, the shell will ask a series of questions to the user and then generates the two 32-bit words that need to be written in the trigger registers.\\
The script is only meant to be a quick and simple way to generate the configuration words without having to dwell too much in the details provided in section~\ref{ch:triggerLogic}. This means that it can only offer a limited set of configurations that should, nonetheless, be enough for most of the user cases.\\
To take advantage of the full flexibility of the \gls{tlu} trigger and generate more advanced configurations (such as mutually excluding trigger inputs) the user should refer to section~\ref{ch:triggerLogic}.\\
To use the script:
\begin{itemize}
\item In the script folder, type \verb|Python trigger_configuration_helper|. This will open an interactive shell. The shell supports tab-autocompletion.
\item In the shell, type \verb|start|
\item For each of the LEMO trigger inputs, specify if the signal is to be considered ACTIVE or VETO. Active signals must be asserted to create a valid trigger. VETO signals must be de-asserted to create a valid signal. There is also the option to set an input as DO-NOT-CARE (DNC).\\
The VETO option should be used, for instance, for any inputs that is used as a shutter signal (see section~\ref{ch:shutter}).
\item If more than one active input is present, it is possible to configure the \gls{tlu} to generate a trigger if at least $N$ are asserted (as opposed to all of them). The shell will ask for the minimum number of ACTIVE signals that should be asserted, at the same time, to generate a valid trigger.
\item The shell will produce a list of all the configurations that will produce a valid trigger, followed by the two values to be written in the registers.
\item If the user is happy with those, they can just copy those values and use them to configure the \gls{tlu} for instance by including them in the EUDAQ configuration file. It is always possible to restart the procedure by typing \verb|start| again.
\item Please note that a VETO signal is always prioritized: if a VETO signal is asserted, the \gls{tlu} will not produce any trigger.
\item Also note that a DNC signal can only contribute to the minimum number of active inputs $N$ if asserted.
\end{itemize}
\begin{alertinfo}{Warning}
The script only tells the user what values to write in the trigger configuration registers, but does not write them itself.\\
It is up to the user to program the \gls{tlu} with those values, in whichever method is preferred (EUDAQ, Python scripts, etc).
\end{alertinfo}
\subsubsection{Example of trigger configurations}
In this example we have connected a pulse generator to two inputs of the \gls{tlu}, namely \verb|IN_1| and \verb|IN_5|. The inputs fire with a small, random delay with respect to each other.\\
In order to ensure that the signals overlap adequately, we use the \emph{stretch} register (see chapter~\ref{ch:triggerLogic}) to increase the length of the pulses: we extend \emph{in0} to 10 clock cycles and \emph{in4} to 8 clock cycles, where the clock has a frequency of 160~MHz. The resulting signals are shown in figure~\ref{Fig:exampleExtendedTriggers}. In order to ensure that the signals overlap adequately, we use the \emph{stretch} register (see chapter~\ref{ch:triggerLogic}) to increase the length of the pulses: we extend \emph{in0} to 10 clock cycles and \emph{in4} to 8 clock cycles, where the clock has a frequency of 160~MHz. The resulting signals are shown in figure~\ref{Fig:exampleExtendedTriggers}.
\begin{figure} \begin{figure}[h]
\centering \centering
\includegraphics[width=.90\textwidth]{./Images/Initial.png} \includegraphics[width=.99\textwidth]{./Images/Initial.png}
\caption{Input pulses (yellow) and corresponding stretched signals (red). Input 0 is stretched by 10 cycles, input 4 by 8, hence the difference in pulse widths.} \caption{Input pulses (yellow) and corresponding stretched signals (red). Input 0 is stretched by 10 cycles, input 4 by 8, hence the difference in pulse widths.}
\label{Fig:exampleExtendedTriggers} \label{Fig:exampleExtendedTriggers}
\end{figure}\\ \end{figure}\\
...@@ -129,14 +157,14 @@ We can now define the trigger logic to be used to assert a valid trigger: we onl ...@@ -129,14 +157,14 @@ We can now define the trigger logic to be used to assert a valid trigger: we onl
\item Trigger \gls{lsb} word= 0x00020000. This indicates that the only valid trigger combination occurs when both \verb|IN_1| and \verb|IN_5| are high. The valid trigger goes high 1 clock cycle after this condition is met and remains high up to 1 clock cycle after the condition is no longer valid. This is illustrated in figure~\ref{Fig:exampleTrig00020000}. \item Trigger \gls{lsb} word= 0x00020000. This indicates that the only valid trigger combination occurs when both \verb|IN_1| and \verb|IN_5| are high. The valid trigger goes high 1 clock cycle after this condition is met and remains high up to 1 clock cycle after the condition is no longer valid. This is illustrated in figure~\ref{Fig:exampleTrig00020000}.
\begin{figure} \begin{figure}
\centering \centering
\includegraphics[width=.90\textwidth]{./Images/Trigger0x00020000.png} \includegraphics[width=.99\textwidth]{./Images/Trigger0x00020000.png}
\caption{Trigger configuration 0x00020000. The valid trigger (blue) is asserted only when both signals are high. This condition occurs at frame 39. The trigger is asserted on the following frame.} \caption{Trigger configuration 0x00020000. The valid trigger (blue) is asserted only when both signals are high. This condition occurs at frame 39. The trigger is asserted on the following frame.}
\label{Fig:exampleTrig00020000} \label{Fig:exampleTrig00020000}
\end{figure}\\ \end{figure}\\
\item Trigger \gls{lsb} word= 0x00020002. This indicates that a valid trigger is achieved in two separated configurations (in logic OR): when both inputs are high at the same time (as in the previous case) or if \verb|IN_1| is active on its own. This is illustrated in figure~\ref{Fig:exampleTrig00020002}. It can be seen that the valid trigger is asserted immediately one clock cycle after \verb|IN_1| is high and remains high as long as this condition is met. One might assume that specifying the combination with \verb|IN_5| is redundant, but the following example should show that this is not the case. \item Trigger \gls{lsb} word= 0x00020002. This indicates that a valid trigger is achieved in two separated configurations (in logic OR): when both inputs are high at the same time (as in the previous case) or if \verb|IN_1| is active on its own. This is illustrated in figure~\ref{Fig:exampleTrig00020002}. It can be seen that the valid trigger is asserted immediately one clock cycle after \verb|IN_1| is high and remains high as long as this condition is met. One might assume that specifying the combination with \verb|IN_5| is redundant, but the following example should show that this is not the case.
\begin{figure} \begin{figure}
\centering \centering
\includegraphics[width=.90\textwidth]{./Images/Trigger0x00020002.png} \includegraphics[width=.99\textwidth]{./Images/Trigger0x00020002.png}
\caption{Trigger configuration 0x00020002. The valid trigger (blue) is asserted if \texttt{IN\_1} is high OR when \texttt{IN\_1} and \texttt{IN\_5} are both high at the same time.} \caption{Trigger configuration 0x00020002. The valid trigger (blue) is asserted if \texttt{IN\_1} is high OR when \texttt{IN\_1} and \texttt{IN\_5} are both high at the same time.}
\label{Fig:exampleTrig00020002} \label{Fig:exampleTrig00020002}
\end{figure}\\ \end{figure}\\
...@@ -144,7 +172,7 @@ We can now define the trigger logic to be used to assert a valid trigger: we onl ...@@ -144,7 +172,7 @@ We can now define the trigger logic to be used to assert a valid trigger: we onl
In figure~\ref{Fig:exampleTrig00000002} it is possible to see that the logic produces two separated trigger valid pulses, both shorter than the ones in previous examples: the first one is due to \verb|IN_1| going high while \verb|IN_5| is low. As soon as \verb|IN_5| goes high, the trigger condition is no longer met. When \verb|IN_5| returns low, a trigger condition is met again because \verb|IN_1| is still high. In this specific case, the double pulse is caused by the different width of the pulses. In figure~\ref{Fig:exampleTrig00000002} it is possible to see that the logic produces two separated trigger valid pulses, both shorter than the ones in previous examples: the first one is due to \verb|IN_1| going high while \verb|IN_5| is low. As soon as \verb|IN_5| goes high, the trigger condition is no longer met. When \verb|IN_5| returns low, a trigger condition is met again because \verb|IN_1| is still high. In this specific case, the double pulse is caused by the different width of the pulses.
\begin{figure} \begin{figure}
\centering \centering
\includegraphics[width=.90\textwidth]{./Images/Trigger0x00000002.png} \includegraphics[width=.99\textwidth]{./Images/Trigger0x00000002.png}
\caption{Trigger configuration 0x00000002. The valid trigger (blue) is asserted only when \texttt{IN\_1} is active on its own. As such, two separated trigger pulses are produced because \texttt{IN\_5} goes high and returns low before \texttt{IN\_1}.} \caption{Trigger configuration 0x00000002. The valid trigger (blue) is asserted only when \texttt{IN\_1} is active on its own. As such, two separated trigger pulses are produced because \texttt{IN\_5} goes high and returns low before \texttt{IN\_1}.}
\label{Fig:exampleTrig00000002} \label{Fig:exampleTrig00000002}
\end{figure}\\ \end{figure}\\
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment