After thinking about it for a couple of days, I've decided not to use two separated RLL blocks.
Instead, I made a block as below:
In work() function:
get_tags_in_range(tags, 0, nitems_read(0),
nitems_read(0) + ninput_items[0],
pmt::mp("rll_coding"));
RLL_CODE rll_code = (RLL_CODE)pmt::to_long(tags[0].value);
// ... omitted trivial things
switch (rll_code) {
case RLLMANCHESTER:
for(int i = 0; i < ninput_items[0]; i++) {
out[2 * i] = !!in[i];
out[2 * i + 1] = !in[i];
}
break;
case RLL4B6B:
for(int i = 0; i < ninput_items[0] / 4; i += 4) {
int rll4B = 0;
for (int j = 0; j < 4; j++) {
// make four bits into one bytes
rll4B |= (in[i + j] & 1) << j;
}
for (int j = 0; j < 6; j++) {
// put six bits corresponding to rll4B
out[6 * i + j] = !!(rll4B6B[rll4B] & (1 << j));
}
}
break;
}
// mapping definition
const char rll4B6B[16] = {
0b011100, 0b101100, 0b110010, 0b011010,
0b101010, 0b110001, 0b011001, 0b101001,
0b100110, 0b010110, 0b001110, 0b100011,
0b010011, 0b100101, 0b010101, 0b001101
};
And please note that each in[i] is either 0b00000000 or 0b00000001.
By using a tag, RLL coding scheme are not changing during the stream.
Currently, I haven't built it and tested yet.
What do you think of it?
I will make some notes after build and test the entire system.
Regrads,
Jeon.