GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > LDT / V0-2-0

Constituent: encdec_unit_test     Tag: linux-gcc


Interface   Data Structures   File List   Data Fields   Globals  

BA.h File Reference

Bit array structure. More...

#include "PBS/BSWP.ih"

Include dependency graph for BA.h:

This graph shows which files directly or indirectly include this file:


Data Structures

struct  _BA
 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. More...

Defines

#define BA_STORE(_out, _buf)   BSWP__store32b(_out, _buf)
#define BA_LOAD(_out)   BSWP__load32b(_out)
#define BA_WRITE_R(_out, _buffer, _to_go, _bits, _n)
#define BA_WRITE_L(_out, _buffer, _to_go, _bits, _n)

Typedefs

typedef _BA BA
 Typedef for struct _BA.

Detailed Description

Bit array structure.

Author:
JJRussell - russell@slac.stanford.edu
   CVS $Id: BA.h,v 1.1 2006/09/13 17:09:07 russell Exp $

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


Define Documentation

#define BA_WRITE_L _out,
_buffer,
_to_go,
_bits,
_n   ) 
 

Value:

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)

#define BA_WRITE_R _out,
_buffer,
_to_go,
_bits,
_n   ) 
 

Value:

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)


Generated on Thu Sep 14 09:10:44 2006 by  doxygen 1.4.4