Hi list,

I’d like to write a custom block that takes 1, 4-bit symbol and remaps

it to 1, 32-bit symbol. Some code for a general_work() method is below

[1], but it doesn’t quite work yet.

It isn’t convolutional - i.e. the 4-bits of symbol k, do not overlap

with the 4-bits of symbol k-1 - so it doesn’t really fall into the

concept of a filter. It also must operate on multiples of 4-bits in

one operation (at least 4).

In a sense, it’s an interpolating block that operates on 4 bits at a

time.

I originally thought that I should be operating on vectors, but

haven’t really found many examples of the stream_to_vector_ii block or

the vector_to_stream_ii block.

Does anyone on the list have any thoughts or suggestions?

Thanks,

C

[1]

#define N 4

#define M 32

#define K (M/N)

forecast():

// input items requires for nout < 4 = 0

ninput_items_required[0] = ( noutput_items / N ) * N * K;

general_work():

// input is a binary stream encoded as integers

// output is a binary stream encoded as integers

int *in = (int *) input_items[ 0 ];

int *out = (int *) output_items[ 0 ];

int j, nchips = 0;

for( j=0; j < noutput_items; j += M, nchips++, in += j/K, out += j ) {

// FIXME: throw some sort of exception if j / K >= ninput_items

// Do symbol-to-chip mapping

// pack the first four input items and form a nibble

unsigned symbol = 0;

for( int i=0; i < N; i++ ) {

int bit = !! in[ i ];

symbol |= bit << i;

}

// form a word via the LUT

unsigned chip = LUT[ symbol ];

// unpack the word into output items

for( int i=0; i < M; i++ ) {

int bit = ( chip >> i ) & 0x1;

out[ i ] = bit;

}

}

// Tell runtime system how many input items we consumed on each input

stream.

consume_each ( nchips * N );

// Tell runtime system how many output items we produced.

return nchips * M;