kopia lustrzana https://github.com/M17-Project/M17_Implementations
rodzic
e71b3546cb
commit
a6c75950e6
|
@ -84,6 +84,7 @@ void encode_LICH(uint8_t outp[12], const uint8_t inp[6]);
|
||||||
extern const uint16_t intrl_seq[SYM_PER_PLD*2];
|
extern const uint16_t intrl_seq[SYM_PER_PLD*2];
|
||||||
|
|
||||||
void reorder_bits(uint8_t outp[SYM_PER_PLD*2], const uint8_t inp[SYM_PER_PLD*2]);
|
void reorder_bits(uint8_t outp[SYM_PER_PLD*2], const uint8_t inp[SYM_PER_PLD*2]);
|
||||||
|
void reorder_soft_bits(uint16_t outp[SYM_PER_PLD*2], const uint16_t inp[SYM_PER_PLD*2]);
|
||||||
|
|
||||||
// M17 C library - lib/math/math.c
|
// M17 C library - lib/math/math.c
|
||||||
uint16_t q_abs_diff(const uint16_t v1, const uint16_t v2);
|
uint16_t q_abs_diff(const uint16_t v1, const uint16_t v2);
|
||||||
|
@ -93,6 +94,7 @@ uint16_t soft_to_int(const uint16_t* in, const uint8_t len);
|
||||||
uint16_t div16(const uint16_t a, const uint16_t b);
|
uint16_t div16(const uint16_t a, const uint16_t b);
|
||||||
uint16_t mul16(const uint16_t a, const uint16_t b);
|
uint16_t mul16(const uint16_t a, const uint16_t b);
|
||||||
uint16_t soft_bit_XOR(const uint16_t a, const uint16_t b);
|
uint16_t soft_bit_XOR(const uint16_t a, const uint16_t b);
|
||||||
|
uint16_t soft_bit_NOT(const uint16_t a);
|
||||||
void soft_XOR(uint16_t* out, const uint16_t* a, const uint16_t* b, const uint8_t len);
|
void soft_XOR(uint16_t* out, const uint16_t* a, const uint16_t* b, const uint8_t len);
|
||||||
|
|
||||||
// M17 C library - lib/phy/randomize.c
|
// M17 C library - lib/phy/randomize.c
|
||||||
|
|
|
@ -153,6 +153,17 @@ uint16_t soft_bit_XOR(const uint16_t a, const uint16_t b)
|
||||||
return add16(mul16(a, sub16(0xFFFF, b)), mul16(b, sub16(0xFFFF, a)));
|
return add16(mul16(a, sub16(0xFFFF, b)), mul16(b, sub16(0xFFFF, a)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Soft logic NOT.
|
||||||
|
*
|
||||||
|
* @param a Input A.
|
||||||
|
* @return uint16_t Output = not A.
|
||||||
|
*/
|
||||||
|
uint16_t soft_bit_NOT(const uint16_t a)
|
||||||
|
{
|
||||||
|
return 0xFFFFU-a;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief XOR for vectors of soft-valued logic.
|
* @brief XOR for vectors of soft-valued logic.
|
||||||
* Max length is 255.
|
* Max length is 255.
|
||||||
|
|
|
@ -36,7 +36,7 @@ const uint16_t intrl_seq[SYM_PER_PLD*2]=
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reorder (interleave) unpacked payload bits.
|
* @brief Reorder (interleave) 368 unpacked payload bits.
|
||||||
*
|
*
|
||||||
* @param outp Reordered, unpacked type-4 bits.
|
* @param outp Reordered, unpacked type-4 bits.
|
||||||
* @param inp Input unpacked type-2/3 bits.
|
* @param inp Input unpacked type-2/3 bits.
|
||||||
|
@ -46,3 +46,15 @@ void reorder_bits(uint8_t outp[SYM_PER_PLD*2], const uint8_t inp[SYM_PER_PLD*2])
|
||||||
for(uint16_t i=0; i<SYM_PER_PLD*2; i++)
|
for(uint16_t i=0; i<SYM_PER_PLD*2; i++)
|
||||||
outp[i]=inp[intrl_seq[i]];
|
outp[i]=inp[intrl_seq[i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reorder (interleave) 368 soft bits.
|
||||||
|
*
|
||||||
|
* @param outp Reordered soft bits.
|
||||||
|
* @param inp Input soft bits.
|
||||||
|
*/
|
||||||
|
void reorder_soft_bits(uint16_t outp[SYM_PER_PLD*2], const uint16_t inp[SYM_PER_PLD*2])
|
||||||
|
{
|
||||||
|
for(uint16_t i=0; i<SYM_PER_PLD*2; i++)
|
||||||
|
outp[i]=inp[intrl_seq[i]];
|
||||||
|
}
|
||||||
|
|
|
@ -121,15 +121,12 @@ int main(void)
|
||||||
//derandomize
|
//derandomize
|
||||||
for(uint16_t i=0; i<SYM_PER_PLD*2; i++)
|
for(uint16_t i=0; i<SYM_PER_PLD*2; i++)
|
||||||
{
|
{
|
||||||
if((rand_seq[i/8]>>(7-(i%8)))&1) //soft XOR. flip soft bit if "1"
|
if((rand_seq[i/8]>>(7-(i%8)))&1) //soft NOT. flip soft bit if "1"
|
||||||
soft_bit[i]=0xFFFF-soft_bit[i];
|
soft_bit[i]=soft_bit_NOT(soft_bit[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//deinterleave
|
//deinterleave
|
||||||
for(uint16_t i=0; i<SYM_PER_PLD*2; i++)
|
reorder_soft_bits(d_soft_bit, soft_bit);
|
||||||
{
|
|
||||||
d_soft_bit[i]=soft_bit[intrl_seq[i]];
|
|
||||||
}
|
|
||||||
|
|
||||||
//if it is a frame
|
//if it is a frame
|
||||||
if(!fl)
|
if(!fl)
|
||||||
|
|
Ładowanie…
Reference in New Issue