\hypertarget{BA_8h}{
\section{BA.h File Reference}
\label{BA_8h}\index{BA.h@{BA.h}}
}
Bit array structure. 

{\tt \#include \char`\"{}PBS/BSWP.ih\char`\"{}}\par


Include dependency graph for BA.h:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=101pt]{BA_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=129pt]{BA_8h__dep__incl}
\end{center}
\end{figure}
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct \hyperlink{struct__BA}{\_\-BA}
\begin{CompactList}\small\item\em Provides the bare minimum context to keep track of a buffered array of bits. Since, in general, the bits are buffered in a temporary structure before being output, they must be flushed. \item\end{CompactList}\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\hypertarget{BA_8h_a0}{
\#define {\bf BA\_\-STORE}(\_\-out, \_\-buf)~BSWP\_\-\_\-store32b(\_\-out, \_\-buf)}
\label{BA_8h_a0}

\item 
\hypertarget{BA_8h_a1}{
\#define {\bf BA\_\-LOAD}(\_\-out)~BSWP\_\-\_\-load32b(\_\-out)}
\label{BA_8h_a1}

\item 
\#define {\bf BA\_\-WRITE\_\-R}(\_\-out, \_\-buffer, \_\-to\_\-go, \_\-bits, \_\-n)
\item 
\#define {\bf BA\_\-WRITE\_\-L}(\_\-out, \_\-buffer, \_\-to\_\-go, \_\-bits, \_\-n)
\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{BA_8h_a4}{
typedef \hyperlink{struct__BA}{\_\-BA} \hyperlink{BA_8h_a4}{BA}}
\label{BA_8h_a4}

\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__BA}{\_\-BA}. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Bit array structure. 

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


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


Provides a fast way to pack bits into an array. The bits are packed big endian style, i.e. msb -$>$ lsb

\subsection{Define Documentation}
\hypertarget{BA_8h_a3}{
\index{BA.h@{BA.h}!BA_WRITE_L@{BA\_\-WRITE\_\-L}}
\index{BA_WRITE_L@{BA\_\-WRITE\_\-L}!BA.h@{BA.h}}
\subsubsection[BA\_\-WRITE\_\-L]{\setlength{\rightskip}{0pt plus 5cm}\#define BA\_\-WRITE\_\-L(\_\-out, \_\-buffer, \_\-to\_\-go, \_\-bits, \_\-n)}}
\label{BA_8h_a3}


{\bf Value:}

\footnotesize\begin{verbatim}do                                                                    \
{                                                                     \
    int left = _n - _to_go;                                           \
    if (left >= 0)                                                    \
    {                                                                 \
        /* Not enough room for all the bits, put in what will fit */  \
       _buffer <<= _to_go;                                            \
       _buffer  |= (unsigned)_bits >> (32 - _to_go);                  \
        BA_STORE(_out, _buffer);                                      \
        printf ("Storing %x\n", *_out);                               \
       _out++;                                                        \
       _buffer = 0;                                                   \
       if (left)                                                      \
       {                                                              \
          _buffer  |= ((unsigned)_bits << _to_go) >> (32 - left);     \
       }                                                              \
       _to_go  = 32 - left;                                           \
    }                                                                 \
    else                                                              \
    {                                                                 \
       /* Put the last bits in */                                     \
      _buffer <<= _n;                                                 \
      _buffer  |= (unsigned)_bits >> (32 - _n);                       \
      _to_go   -= _n;                                                 \
    }                                                                 \
} while (0)
\end{verbatim}\normalsize 
\hypertarget{BA_8h_a2}{
\index{BA.h@{BA.h}!BA_WRITE_R@{BA\_\-WRITE\_\-R}}
\index{BA_WRITE_R@{BA\_\-WRITE\_\-R}!BA.h@{BA.h}}
\subsubsection[BA\_\-WRITE\_\-R]{\setlength{\rightskip}{0pt plus 5cm}\#define BA\_\-WRITE\_\-R(\_\-out, \_\-buffer, \_\-to\_\-go, \_\-bits, \_\-n)}}
\label{BA_8h_a2}


{\bf Value:}

\footnotesize\begin{verbatim}do                                                                    \
{                                                                     \
    int left = _n - _to_go;                                           \
    /* _dprintf ("N:%2u B:%x T:%2u L:%3d", _n, _bits, _to_go, left); */    \
    if (left >= 0)                                                    \
    {                                                                 \
        /* Not enough room for all the bits, put in what will fit */  \
       _buffer <<= _to_go;                                            \
       _buffer  |= (unsigned)_bits >> left;                           \
        BA_STORE(_out, _buffer);                                      \
       /* _dprintf (" %8.8x", *_out); */                                 \
       _out++;                                                        \
/*     _buffer = 0; */                                                  \
       if (left)                                                      \
       {                                                              \
          _buffer  = ((unsigned)_bits & ((1 << left) - 1));           \
          /* _dprintf (" %8.8x", _buffer); */                               \
       }                                                              \
       /* _dprintf ("\n"); */                                               \
       _to_go  = 32 - left;                                           \
    }                                                                 \
    else                                                              \
    {                                                                 \
       /* Put the last bits in */                                     \
      _buffer <<= _n;                                                 \
      _buffer  |= (unsigned)_bits;                                    \
      /* _dprintf (" %8.8x\n", _buffer); */                                \
      _to_go   -= _n;                                                 \
    }                                                                 \
} while (0)
\end{verbatim}\normalsize 
