\hypertarget{BFP_8h}{
\section{BFP.h File Reference}
\label{BFP_8h}\index{BFP.h@{BFP.h}}
}
Bit Field Pack Routines. 

{\tt \#include \char`\"{}LDT/BW.h\char`\"{}}\par
{\tt \#include \char`\"{}LDT/BWP.h\char`\"{}}\par


Include dependency graph for BFP.h:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=151pt]{BFP_8h__incl}
\end{center}
\end{figure}


This graph shows which files directly or indirectly include this file:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=85pt]{BFP_8h__dep__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{CompactItemize}
\item 
static \_\-\_\-inline unsigned int \hyperlink{BFP_8h_a0}{BFP\_\-\_\-mask\-L} (int width)
\begin{CompactList}\small\item\em Produce a left justified mask of the specified width. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{BFP_8h_a1}{BFP\_\-\_\-mask\-R} (int width)
\begin{CompactList}\small\item\em Produce a right justified mask of the specified width. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{BFP_8h_a2}{BFP\_\-\_\-word\-L} (unsigned int $\ast$w, unsigned int position, unsigned int field, unsigned int width)
\begin{CompactList}\small\item\em Packs a left justified bit field into the current position. The width of the bit field must be less than or equal to 32 bits. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{BFP_8h_a3}{BFP\_\-\_\-word\-R} (unsigned int $\ast$w, unsigned int position, unsigned int field, unsigned int width)
\begin{CompactList}\small\item\em Packs a right justified bit field into the current position. The width of the bit field must be less than or equal to 32 bits. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{BFP_8h_a4}{BFP\_\-\_\-word\-LP} (unsigned int $\ast$w, unsigned int position, unsigned int field, unsigned int width)
\begin{CompactList}\small\item\em Packs a left justified bit field into the current position limiting the field to the specified width. The width of the bit field must be less than or equal to 32 bits. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{BFP_8h_a5}{BFP\_\-\_\-word\-RP} (unsigned int $\ast$w, unsigned int position, unsigned int field, unsigned int width)
\begin{CompactList}\small\item\em Packs a right justified bit field into the current position limiting the field to the specified width. The width of the bit field must be less than or equal to 32 bits. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{BFP_8h_a6}{BFP\_\-\_\-word\-B} (unsigned int $\ast$w, unsigned int position, unsigned int bit)
\begin{CompactList}\small\item\em Packs the value of the bit into the current bit position. The value of the bit is either 0 or 1, or said in a negative fashion, it is not the left justified version, {\em i.e\/}. 0x80000000 or 0. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{BFP_8h_a7}{BFP\_\-\_\-collapse} (unsigned int $\ast$w, unsigned int position, unsigned int wrd, unsigned int msk)
\begin{CompactList}\small\item\em Convenience routine to first collapse {\em wrd\/}, keeping only those bits set in {\em wrd\/}, then pack the collapsed word into {\em w\/} starting at bit {\em position\/}. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{BFP_8h_a8}{BFP\_\-\_\-copy\-W} (unsigned int $\ast$w, unsigned int position, const unsigned int $\ast$wrds, int nwrds)
\begin{CompactList}\small\item\em Copies the specified array of 32-bit words into the output bit array. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{BFP_8h_a9}{BFP\_\-\_\-convert} (unsigned int $\ast$w, unsigned int position, unsigned int val, unsigned int nval, unsigned int nexp)
\begin{CompactList}\small\item\em Convenience routine to pack small integers that are embedded in a larger field. \item\end{CompactList}\item 
static \_\-\_\-inline unsigned int \hyperlink{BFP_8h_a10}{BFP\_\-\_\-pack1s} (unsigned int $\ast$w, unsigned int position, unsigned int cnt)
\begin{CompactList}\small\item\em Packs {\em cnt\/} consecutive 1's terminated by a 0. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Bit Field Pack Routines. 

\begin{Desc}
\item[Author:]JJRussell - \href{mailto:russell@slac.stanford.edu}{\tt russell@slac.stanford.edu}\end{Desc}
\begin{Desc}
\item[]Inline functions to (left justified) pack bit fields into a 32-bit output vector. These routines assume that any bits ahead of the current bit position index can be overwritten. In this sense these routines are not equivalent to a bit field insert routine which only write the bits in the designated bit field.\end{Desc}
\begin{Desc}
\item[]The routines come in a 2 x 2 set. One can insert a field of a specified width that is either left or right justified. In addition one can use unprotected or protected routines, the distinction being that the unprotected routines are faster, but demand that the user guarantee that no more than the specified bits are non-zero. Conversely, the protected routines limit the bit field to the specified width.\end{Desc}


\subsection{Function Documentation}
\hypertarget{BFP_8h_a7}{
\index{BFP.h@{BFP.h}!BFP__collapse@{BFP\_\-\_\-collapse}}
\index{BFP__collapse@{BFP\_\-\_\-collapse}!BFP.h@{BFP.h}}
\subsubsection[BFP\_\-\_\-collapse]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int BFP\_\-\_\-collapse (unsigned int $\ast$ {\em w}, unsigned int {\em position}, unsigned int {\em wrd}, unsigned int {\em msk})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFP_8h_a7}


Convenience routine to first collapse {\em wrd\/}, keeping only those bits set in {\em wrd\/}, then pack the collapsed word into {\em w\/} starting at bit {\em position\/}. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em w}]The output word \item[{\em position}]The current bit position \item[{\em wrd}]The target word \item[{\em msk}]The selection mask \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The updated bit position\end{Desc}
\begin{Desc}
\item[Note:]There is no need for a {\em right\/} and {\em left\/} version of these routines.\end{Desc}
\hypertarget{BFP_8h_a9}{
\index{BFP.h@{BFP.h}!BFP__convert@{BFP\_\-\_\-convert}}
\index{BFP__convert@{BFP\_\-\_\-convert}!BFP.h@{BFP.h}}
\subsubsection[BFP\_\-\_\-convert]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int BFP\_\-\_\-convert (unsigned int $\ast$ {\em w}, unsigned int {\em position}, unsigned int {\em val}, unsigned int {\em nval}, unsigned int {\em nexp})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFP_8h_a9}


Convenience routine to pack small integers that are embedded in a larger field. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em w}]The output word \item[{\em position}]The current bit position \item[{\em val}]The interger value to be encoded \item[{\em nval}]The bit field width of val \item[{\em nexp}]The number of bits to devote to the exponent encoding\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The updated bit position\end{Desc}
\begin{Desc}
\item[Note:]There is no need for a {\em right\/} and {\em left\/} version of these routines. See BWP\_\-reduce\-L for a complete description of the packing algorithm\end{Desc}
\hypertarget{BFP_8h_a8}{
\index{BFP.h@{BFP.h}!BFP__copyW@{BFP\_\-\_\-copyW}}
\index{BFP__copyW@{BFP\_\-\_\-copyW}!BFP.h@{BFP.h}}
\subsubsection[BFP\_\-\_\-copyW]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int BFP\_\-\_\-copy\-W (unsigned int $\ast$ {\em w}, unsigned int {\em position}, const unsigned int $\ast$ {\em wrds}, int {\em nwrds})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFP_8h_a8}


Copies the specified array of 32-bit words into the output bit array. 

\begin{Desc}
\item[Returns:]The updated bit position\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em w}]The output word \item[{\em position}]The current bit position \item[{\em wrds}]The array of 32-bit words to copy \item[{\em nwrds}]The number of 32-bit words to copy\end{description}
\end{Desc}
\hypertarget{BFP_8h_a0}{
\index{BFP.h@{BFP.h}!BFP__maskL@{BFP\_\-\_\-maskL}}
\index{BFP__maskL@{BFP\_\-\_\-maskL}!BFP.h@{BFP.h}}
\subsubsection[BFP\_\-\_\-maskL]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int BFP\_\-\_\-mask\-L (int {\em width})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFP_8h_a0}


Produce a left justified mask of the specified width. 

\begin{Desc}
\item[Returns:]A left justified mask of the specified width\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em width}]The width of the mask\end{description}
\end{Desc}
\begin{Desc}
\item[]The BFP\_\-\_\-word packing routines do not protect themselves against stray bits ({\em i.e\/}. bits set outside the specified width) for efficiency reasons. On most occasions this protection occurs naturally as part of composing the field, so this would be a waste of time. However, when it is needed this inline provides a tidy way to produce the necessary mask.\end{Desc}
\hypertarget{BFP_8h_a1}{
\index{BFP.h@{BFP.h}!BFP__maskR@{BFP\_\-\_\-maskR}}
\index{BFP__maskR@{BFP\_\-\_\-maskR}!BFP.h@{BFP.h}}
\subsubsection[BFP\_\-\_\-maskR]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int BFP\_\-\_\-mask\-R (int {\em width})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFP_8h_a1}


Produce a right justified mask of the specified width. 

\begin{Desc}
\item[Returns:]A right justified mask of the specified width\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em width}]The width of the mask, must be between 0 and 31.\end{description}
\end{Desc}
\begin{Desc}
\item[]The BFP\_\-\_\-word packing routines do not protect themselves against stray bits ({\em i.e\/}. bits set outside the specified width) for efficiency reasons. On most occasions this protection occurs naturally as part of composing the field, so this would be a waste of time. However, when it is needed this inline provides a tidy way to produce the necessary mask.\end{Desc}
\hypertarget{BFP_8h_a10}{
\index{BFP.h@{BFP.h}!BFP__pack1s@{BFP\_\-\_\-pack1s}}
\index{BFP__pack1s@{BFP\_\-\_\-pack1s}!BFP.h@{BFP.h}}
\subsubsection[BFP\_\-\_\-pack1s]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int BFP\_\-\_\-pack1s (unsigned int $\ast$ {\em w}, unsigned int {\em position}, unsigned int {\em cnt})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFP_8h_a10}


Packs {\em cnt\/} consecutive 1's terminated by a 0. 

\_\-\_\-inline unsigned int BFP\_\-pack1s (unsigned int $\ast$w, unsigned int position, unsigned int cnt) \begin{Desc}
\item[Returns:]The next bit position to write, must be pos + cnt + 1\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em w}]The output word \item[{\em position}]The current bit position \item[{\em cnt}]The number of 1s to pack\end{description}
\end{Desc}
\hypertarget{BFP_8h_a6}{
\index{BFP.h@{BFP.h}!BFP__wordB@{BFP\_\-\_\-wordB}}
\index{BFP__wordB@{BFP\_\-\_\-wordB}!BFP.h@{BFP.h}}
\subsubsection[BFP\_\-\_\-wordB]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int BFP\_\-\_\-word\-B (unsigned int $\ast$ {\em w}, unsigned int {\em position}, unsigned int {\em bit})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFP_8h_a6}


Packs the value of the bit into the current bit position. The value of the bit is either 0 or 1, or said in a negative fashion, it is not the left justified version, {\em i.e\/}. 0x80000000 or 0. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em w}]The output word \item[{\em position}]The current bit position \item[{\em bit}]The value of the bit to insert (0 or 1) \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The updated bit position\end{Desc}
\hypertarget{BFP_8h_a2}{
\index{BFP.h@{BFP.h}!BFP__wordL@{BFP\_\-\_\-wordL}}
\index{BFP__wordL@{BFP\_\-\_\-wordL}!BFP.h@{BFP.h}}
\subsubsection[BFP\_\-\_\-wordL]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int BFP\_\-\_\-word\-L (unsigned int $\ast$ {\em w}, unsigned int {\em position}, unsigned int {\em field}, unsigned int {\em width})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFP_8h_a2}


Packs a left justified bit field into the current position. The width of the bit field must be less than or equal to 32 bits. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em w}]The output word array to insert the bit field into \item[{\em position}]The current bit position in the output bit field \item[{\em field}]The left justified field to insert \item[{\em width}]The width of the field to insert \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The new bit position (essentially position + width).\end{Desc}
\hypertarget{BFP_8h_a4}{
\index{BFP.h@{BFP.h}!BFP__wordLP@{BFP\_\-\_\-wordLP}}
\index{BFP__wordLP@{BFP\_\-\_\-wordLP}!BFP.h@{BFP.h}}
\subsubsection[BFP\_\-\_\-wordLP]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int BFP\_\-\_\-word\-LP (unsigned int $\ast$ {\em w}, unsigned int {\em position}, unsigned int {\em field}, unsigned int {\em width})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFP_8h_a4}


Packs a left justified bit field into the current position limiting the field to the specified width. The width of the bit field must be less than or equal to 32 bits. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em w}]The output word array to insert the bit field into \item[{\em position}]The current bit position in the output bit field \item[{\em field}]The left justified field to insert \item[{\em width}]The width of the field to insert \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The new bit position (essentially position + width).\end{Desc}
\hypertarget{BFP_8h_a3}{
\index{BFP.h@{BFP.h}!BFP__wordR@{BFP\_\-\_\-wordR}}
\index{BFP__wordR@{BFP\_\-\_\-wordR}!BFP.h@{BFP.h}}
\subsubsection[BFP\_\-\_\-wordR]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int BFP\_\-\_\-word\-R (unsigned int $\ast$ {\em w}, unsigned int {\em position}, unsigned int {\em field}, unsigned int {\em width})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFP_8h_a3}


Packs a right justified bit field into the current position. The width of the bit field must be less than or equal to 32 bits. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em w}]The output word array to insert the bit field into \item[{\em position}]The current bit position in the output bit field \item[{\em field}]The left justified field to insert \item[{\em width}]The width of the field to insert \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The new bit position (essentially position + width).\end{Desc}
\hypertarget{BFP_8h_a5}{
\index{BFP.h@{BFP.h}!BFP__wordRP@{BFP\_\-\_\-wordRP}}
\index{BFP__wordRP@{BFP\_\-\_\-wordRP}!BFP.h@{BFP.h}}
\subsubsection[BFP\_\-\_\-wordRP]{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline unsigned int BFP\_\-\_\-word\-RP (unsigned int $\ast$ {\em w}, unsigned int {\em position}, unsigned int {\em field}, unsigned int {\em width})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFP_8h_a5}


Packs a right justified bit field into the current position limiting the field to the specified width. The width of the bit field must be less than or equal to 32 bits. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em w}]The output word array to insert the bit field into \item[{\em position}]The current bit position in the output bit field \item[{\em field}]The right justified field to insert \item[{\em width}]The width of the field to insert \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The new bit position (essentially position + width).\end{Desc}
