\hypertarget{BWP_8h}{
\section{BWP.h File Reference}
\label{BWP_8h}\index{BWP.h@{BWP.h}}
}
Bit Word interface definitions, packing specific routines. 

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


Include dependency graph for BWP.h:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=100pt]{BWP_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=128pt]{BWP_8h__dep__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{CompactItemize}
\item 
\hyperlink{struct__BW__vector}{BW\_\-vector} \hyperlink{BWP_8h_a0}{BWP\_\-collapse\-L} (unsigned int val, unsigned int msk)
\begin{CompactList}\small\item\em Collapses the bit pattern in {\em val\/} considering only those bits that are set in {\em msk\/}. The bit pattern is left justified. \item\end{CompactList}\item 
\hyperlink{struct__BW__vector}{BW\_\-vector} \hyperlink{BWP_8h_a1}{BWP\_\-collapse\-R} (unsigned int val, unsigned int msk)
\begin{CompactList}\small\item\em Collapses the bit pattern in {\em val\/} considering only those bits that are set in {\em msk\/}. The bit pattern is right justified. \item\end{CompactList}\item 
\hyperlink{struct__BW__vector}{BW\_\-vector} \hyperlink{BWP_8h_a2}{BWP\_\-convert\-L} (unsigned int val, unsigned int nsig, unsigned int nexp)
\begin{CompactList}\small\item\em Encodes small integer values that are embedded in a large field. \item\end{CompactList}\item 
\hyperlink{struct__BW__vector}{BW\_\-vector} \hyperlink{BWP_8h_a3}{BWP\_\-convert\-R} (unsigned int val, unsigned int nsig, unsigned int nexp)
\begin{CompactList}\small\item\em Encodes small integer values that are embedded in a large field. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Bit Word interface definitions, packing specific routines. 

\begin{Desc}
\item[Author:]JJRussell - \href{mailto:russell@slac.stanford.edu}{\tt russell@slac.stanford.edu}\end{Desc}


\footnotesize\begin{verbatim}   CVS $Id: BWP.h,v 1.1 2006/09/13 17:09:08 russell Exp $
\end{verbatim}
\normalsize


\subsection{Function Documentation}
\hypertarget{BWP_8h_a0}{
\index{BWP.h@{BWP.h}!BWP_collapseL@{BWP\_\-collapseL}}
\index{BWP_collapseL@{BWP\_\-collapseL}!BWP.h@{BWP.h}}
\subsubsection[BWP\_\-collapseL]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{struct__BW__vector}{BW\_\-vector} BWP\_\-collapse\-L (unsigned int {\em val}, unsigned int {\em msk})}}
\label{BWP_8h_a0}


Collapses the bit pattern in {\em val\/} considering only those bits that are set in {\em msk\/}. The bit pattern is left justified. 

\begin{Desc}
\item[Returns:]The bit pattern and the number of significant bits\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em val}]The word to extract the bits from \item[{\em msk}]The mask of bits to consider\end{description}
\end{Desc}
\begin{Desc}
\item[Note:]There should be a PPC specific version of this. The rotate left and insert under mask is perfect for this routine.\end{Desc}
\hypertarget{BWP_8h_a1}{
\index{BWP.h@{BWP.h}!BWP_collapseR@{BWP\_\-collapseR}}
\index{BWP_collapseR@{BWP\_\-collapseR}!BWP.h@{BWP.h}}
\subsubsection[BWP\_\-collapseR]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{struct__BW__vector}{BW\_\-vector} BWP\_\-collapse\-R (unsigned int {\em val}, unsigned int {\em msk})}}
\label{BWP_8h_a1}


Collapses the bit pattern in {\em val\/} considering only those bits that are set in {\em msk\/}. The bit pattern is right justified. 

\begin{Desc}
\item[Returns:]The bit pattern and the number of significant bits\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em val}]The word to extract the bits from \item[{\em msk}]The mask of bits to consider\end{description}
\end{Desc}
\hypertarget{BWP_8h_a2}{
\index{BWP.h@{BWP.h}!BWP_convertL@{BWP\_\-convertL}}
\index{BWP_convertL@{BWP\_\-convertL}!BWP.h@{BWP.h}}
\subsubsection[BWP\_\-convertL]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{struct__BW__vector}{BW\_\-vector} BWP\_\-convert\-L (unsigned int {\em val}, unsigned int {\em nval}, unsigned int {\em nexp})}}
\label{BWP_8h_a2}


Encodes small integer values that are embedded in a large field. 

\begin{Desc}
\item[Returns:]The left justified bit pattern and the number of significant bits.\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em val}]The 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}
See BWP\_\-convert\-R for a complete description. (This routine just produces a right justified version of the bit pattern.)\hypertarget{BWP_8h_a3}{
\index{BWP.h@{BWP.h}!BWP_convertR@{BWP\_\-convertR}}
\index{BWP_convertR@{BWP\_\-convertR}!BWP.h@{BWP.h}}
\subsubsection[BWP\_\-convertR]{\setlength{\rightskip}{0pt plus 5cm}\_\-\_\-inline \hyperlink{struct__BW__vector}{BW\_\-vector} BWP\_\-convert\-R (unsigned int {\em val}, unsigned int {\em nval}, unsigned int {\em nexp})}}
\label{BWP_8h_a3}


Encodes small integer values that are embedded in a large field. 

\begin{Desc}
\item[Returns:]The right justified bit pattern and the number of significant bits.\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\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}
This encoding is most effective on small integer values that are embedded in a larger field. The {\em val\/} is broken into two pieces. The first piece a field consisting of the number of leading zeros, while the second piece is all the rest, sans the first bit, which, in all but one case must be a 1, so therefore need not be encoded. That special case is when the number of leading zeroes is greater than or equal to (1 $<$$<$ nexp) - 1. Since only that many zeroes can be encoded, one cannot make any assumptions about the value of the next bit.

\begin{Desc}
\item[Example]Consider the number 0x1fff embedded in a 25-bit field using nexp = 4. The call would be\end{Desc}


\footnotesize\begin{verbatim}   bwv = BWP__convertR (0x1fff, 25, 4);
\end{verbatim}
\normalsize


One can encode up to 15 leading zeroes. In this case there are only 8. This gets encoded as EXP = 7 (this is the usual n-1), MANTISSA = 0xfff or 0x7fff, NBITS = 16.

\begin{Desc}
\item[Warning:]As currently written, this routine can safely accomodate\end{Desc}
\begin{itemize}
\item nexp = 5 27-bit integer\item nexp = 4 28-bit integer\item nexp = 3 29-bit integer\item nexp = 2 30-bit integer\item nexp = 1 31-bit integer\end{itemize}


Of course, some of these are silly combinations in the sense that the would produce no compression and would more than likely result in an expansion.