1 #include "../../firmware.h"
2 #include "../../test.h"
4 #define MESSAGE_LENGTH_TC512 32 // 256/8
5 #define CODEWORD_LENGTH_TC512 (2*MESSAGE_LENGTH_TC512)
7 uint8_t packet_reference_TC512[MESSAGE_LENGTH_TC512];
9 uint8_t packet_test_TC512[CODEWORD_LENGTH_TC512];
11 uint8_t decode_workbuf_TC512[LABRADOR_LDPC_BF_WORKING_LEN(TC512)];
12 uint8_t message_output_TC512[LABRADOR_LDPC_OUTPUT_LEN(TC512)];
14 static bool test_ldpc_TC512(
void)
19 for(i=0; i<MESSAGE_LENGTH_TC512; i++)
21 packet_reference_TC512[i] = (uint8_t)(
Random(255));
22 packet_test_TC512[i] = packet_reference_TC512[i];
36 labrador_ldpc_encode(LABRADOR_LDPC_CODE_TC512, packet_test_TC512);
47 for(i=0; i<BIT_FLIPS; i++)
49 bit_index = (uint8_t)(
Random(CODEWORD_LENGTH_TC512));
50 packet_test_TC512[bit_index >> 3] = (uint8_t)(packet_test_TC512[bit_index >> 3] ^ (0x80 >> (bit_index & 0x07)));
53 size_t iters_count = 0;
54 labrador_ldpc_decode_bf(LABRADOR_LDPC_CODE_TC512, packet_test_TC512, message_output_TC512, decode_workbuf_TC512, 50, &iters_count);
58 Debug_print(
"Used %d/50 iterations\r\n", iters_count);
63 if(memcmp(message_output_TC512, packet_reference_TC512, MESSAGE_LENGTH_TC512) == 0)
75 return test_ldpc_TC512();
uint32_t Random(uint32_t max)
void Debug_print(char *fmt,...)
void buffer_print_bin(uint8_t *buffer, uint32_t length)