\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 $<$LDT/BW.h$>$}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
\hyperlink{struct__BW__vector}{BW\_\-vector} \hyperlink{BWP_8h_655421137840c8d8f601bc205cbe46a8}{BWP\_\-collapseL} (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_f64e9fe860981dfd316dadc5655e5820}{BWP\_\-collapseR} (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_d9c93c345c6586606127af524f4e6698}{BWP\_\-convertL} (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_a8beb20281947ce8a8a2bf970c3c18cb}{BWP\_\-convertR} (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.2 2011/03/25 23:57:13 russell Exp $
\end{verbatim}
\normalsize
 

\subsection{Function Documentation}
\hypertarget{BWP_8h_655421137840c8d8f601bc205cbe46a8}{
\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}{\bf BW\_\-vector} BWP\_\-collapseL (unsigned int {\em val}, \/  unsigned int {\em msk})}}
\label{BWP_8h_655421137840c8d8f601bc205cbe46a8}


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}


References \_\-BW\_\-vector::bits, and \_\-BW\_\-vector::nbits.

Referenced by BFP\_\-\_\-collapse().\hypertarget{BWP_8h_f64e9fe860981dfd316dadc5655e5820}{
\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}{\bf BW\_\-vector} BWP\_\-collapseR (unsigned int {\em val}, \/  unsigned int {\em msk})}}
\label{BWP_8h_f64e9fe860981dfd316dadc5655e5820}


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}


References \_\-BW\_\-vector::bits, and \_\-BW\_\-vector::nbits.\hypertarget{BWP_8h_d9c93c345c6586606127af524f4e6698}{
\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}{\bf BW\_\-vector} BWP\_\-convertL (unsigned int {\em val}, \/  unsigned int {\em nval}, \/  unsigned int {\em nexp})}}
\label{BWP_8h_d9c93c345c6586606127af524f4e6698}


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\_\-convertR for a complete description. (This routine just produces a right justified version of the bit pattern.) 

References \_\-BW\_\-vector::bits, and BWP\_\-convertR().\hypertarget{BWP_8h_a8beb20281947ce8a8a2bf970c3c18cb}{
\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 {\bf BW\_\-vector} BWP\_\-convertR (unsigned int {\em val}, \/  unsigned int {\em nval}, \/  unsigned int {\em nexp})}}
\label{BWP_8h_a8beb20281947ce8a8a2bf970c3c18cb}


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}


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



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. 

References \_\-BW\_\-vector::bits, and \_\-BW\_\-vector::nbits.

Referenced by BFP\_\-\_\-convert(), and BWP\_\-convertL().