Look-up table for converting N-bit digitized to floating point numbers. More...

#include <BitTable.h>

Inheritance diagram for dsp::BitTable:
Reference::Able Reference::HeapTracked dsp::TwoBitTable dsp::CODIFTwoBitTable dsp::EmerlinTwoBitTable dsp::Mark4TwoBitTable dsp::S2TwoBitTable dsp::VDIFTwoBitTable

Public Types

enum  Type { OffsetBinary, TwosComplement, SignMagnitude }
 Interpretation of the bits in each value.
 
enum  Order { MostToLeast, LeastToMost }
 The order of values in each byte (bit significance)
 

Public Member Functions

 BitTable (unsigned nbit, Type type, bool reverse_bits=false)
 Constructor.
 
virtual ~BitTable ()
 Destructor.
 
void set_effective_nbit (unsigned bits)
 Set the effective number of bits. More...
 
unsigned get_effective_nbit () const
 
void set_order (Order)
 Set the order of the samples in each byte.
 
Order get_order () const
 
void set_zero_is_a_threshold (bool)
 Set to true if zero is a threshold; set to false if zero is a value. More...
 
bool get_zero_is_a_threshold () const
 
unsigned get_values_per_byte () const
 Get the number of floating point values per byte, 8/N.
 
unsigned get_unique_values () const
 Get the number of unique values of an N-bit integer, 2^N.
 
double get_scale () const
 Get the scale factor used to normalize the variance to unity.
 
Type get_type () const
 Return the digitization convention.
 
const float * get_values (unsigned byte=0) const
 Returns pointer to values_per_byte floats represented by byte.
 
void generate (float *table) const
 Generate a look-up table for conversion to floating point. More...
 
virtual void generate_unique_values (float *values) const
 Generate a look-up table of unique_values floats.
 
virtual unsigned extract (unsigned byte, unsigned i) const
 Extract the ith sample from byte. More...
 
virtual double get_optimal_variance () const
 Return the optimal variance of normally distributed samples.
 
virtual double get_nlow_threshold () const
 Return the optimal threshold closest to and less than unity.
 
virtual void get_nlow_lookup (char *nlow_lookup) const
 Return the number of low voltage states in each of 256 bytes.
 
- Public Member Functions inherited from Reference::Able
 Able (const Able &)
 
Ableoperator= (const Able &)
 
unsigned get_reference_count () const
 
- Public Member Functions inherited from Reference::HeapTracked
 HeapTracked (const HeapTracked &)
 
HeapTrackedoperator= (const HeapTracked &)
 
bool __is_on_heap () const
 

Static Public Attributes

static const unsigned bits_per_byte = 8
 Number of bits per bytes.
 
static const unsigned unique_bytes = 1 << bits_per_byte
 Number of unique 8-bit combinations.
 

Protected Member Functions

void build ()
 Build the lookup table.
 
void destroy ()
 Destroy the lookup table.
 
- Protected Member Functions inherited from Reference::Able
Handle__reference (bool active) const
 
void __dereference (bool auto_delete=true) const
 

Protected Attributes

float * table
 For each unsigned char, values of the two output voltage states.
 
Type type
 Digitization convention.
 
const unsigned nbit
 Number of bits.
 
unsigned zero_is_a_threshold
 Zero is a threshold.
 
unsigned effective_nbit
 The effective number of bits.
 
const bool reverse_bits
 Reverse the order of the bits.
 
Order order
 The order of the samples in each byte.
 
const unsigned values_per_byte
 Number of N-bit values per byte.
 
const unsigned unique_values
 Number of unique N-bit values.
 
const unsigned nbit_mask
 N-bit mask.
 
double scale
 The scale factor used to normalize the variance to unity.
 

Additional Inherited Members

- Static Public Member Functions inherited from Reference::Able
static size_t get_instance_count ()
 
- Static Public Member Functions inherited from Reference::HeapTracked
static void * operator new (size_t size, void *ptr=0)
 
static void operator delete (void *location, void *ptr)
 
static void operator delete (void *location)
 
static size_t get_heap_queue_size ()
 

Detailed Description

Look-up table for converting N-bit digitized to floating point numbers.

Member Function Documentation

◆ extract()

unsigned dsp::BitTable::extract ( unsigned  byte,
unsigned  i 
) const
virtual

Extract the ith sample from byte.

Each byte is treated as unique_values consecutive values, from most significant bit to least significant bit, or vice versa (depending on order).

Parameters
bytethe byte pattern containing unique_values values
ithe index of the value to extract from the byte

Reimplemented in dsp::EmerlinTwoBitTable, dsp::CODIFTwoBitTable, and dsp::VDIFTwoBitTable.

◆ generate()

void dsp::BitTable::generate ( float *  table) const

Generate a look-up table for conversion to floating point.

Parameters
tablepointer to space for at least unique_bytes * values_per_byte floating point values

Referenced by dsp::TwoBitFour::get_lookup_block().

◆ set_effective_nbit()

void dsp::BitTable::set_effective_nbit ( unsigned  bits)

Set the effective number of bits.

For example, a digitizer may set 8-bit thresholds to effect a 6-bit digitizer, leaving head room for RFI

◆ set_zero_is_a_threshold()

void dsp::BitTable::set_zero_is_a_threshold ( bool  flag)

Set to true if zero is a threshold; set to false if zero is a value.

If zero is a threshold, then there are an equal number of +ve and -ve states and no representation of the value 0; e.g. in signed 8-bit values, the range [-128,127] is shifted by +0.5 to [-127.5,127.5] and there is no zero, only -0.5 and +0.5 on either side of it.

If zero is a value, then [-128,127] remains [-128,127] and zero remains zero.


The documentation for this class was generated from the following files:

Generated using doxygen 1.8.17