Gray Mapping
This commit is contained in:
416
QAM/constellation.dat
Normal file
416
QAM/constellation.dat
Normal file
@ -0,0 +1,416 @@
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-1.34164079 1.34164079
|
||||
0.44721360 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
1.34164079 1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 0.44721360
|
||||
-0.44721360 0.44721360
|
||||
1.34164079 -0.44721360
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
1.34164079 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
0.44721360 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-1.34164079 1.34164079
|
||||
0.44721360 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
1.34164079 1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 0.44721360
|
||||
-0.44721360 0.44721360
|
||||
1.34164079 -0.44721360
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
1.34164079 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
0.44721360 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-1.34164079 1.34164079
|
||||
0.44721360 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
1.34164079 1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 0.44721360
|
||||
-0.44721360 0.44721360
|
||||
1.34164079 -0.44721360
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
1.34164079 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
0.44721360 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-1.34164079 1.34164079
|
||||
0.44721360 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
1.34164079 1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 0.44721360
|
||||
-0.44721360 0.44721360
|
||||
1.34164079 -0.44721360
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
1.34164079 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
0.44721360 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-1.34164079 1.34164079
|
||||
0.44721360 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
1.34164079 1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -1.34164079
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
1.34164079 0.44721360
|
||||
-0.44721360 0.44721360
|
||||
1.34164079 -0.44721360
|
||||
-1.34164079 1.34164079
|
||||
-1.34164079 -1.34164079
|
||||
-0.44721360 1.34164079
|
||||
-1.34164079 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-1.34164079 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
1.34164079 -1.34164079
|
||||
16
QAM/constellation_ref.dat
Normal file
16
QAM/constellation_ref.dat
Normal file
@ -0,0 +1,16 @@
|
||||
-1.34164079 -1.34164079
|
||||
-1.34164079 -0.44721360
|
||||
-1.34164079 0.44721360
|
||||
-1.34164079 1.34164079
|
||||
-0.44721360 -1.34164079
|
||||
-0.44721360 -0.44721360
|
||||
-0.44721360 0.44721360
|
||||
-0.44721360 1.34164079
|
||||
0.44721360 -1.34164079
|
||||
0.44721360 -0.44721360
|
||||
0.44721360 0.44721360
|
||||
0.44721360 1.34164079
|
||||
1.34164079 -1.34164079
|
||||
1.34164079 -0.44721360
|
||||
1.34164079 0.44721360
|
||||
1.34164079 1.34164079
|
||||
68
QAM/qam.c
68
QAM/qam.c
@ -39,6 +39,18 @@ void init_constellation (qam_system* qam) {
|
||||
}
|
||||
}
|
||||
|
||||
int bin_to_gray (int x) {
|
||||
return x ^ (x >> 1);
|
||||
}
|
||||
|
||||
// Iteration de XOR
|
||||
int gray_to_bin(int g) {
|
||||
int b = g;
|
||||
while (g >>= 1)
|
||||
b ^= g;
|
||||
return b;
|
||||
}
|
||||
|
||||
// Modulation QAM
|
||||
void modulate (qam_system* qam, double complex* symbols, int nb_symbols, double complex* s) {
|
||||
for (int k = 0; k < nb_symbols; k++) {
|
||||
@ -80,12 +92,30 @@ void demodulate(qam_system* qam, double complex* s, int nb_symbols, uint8_t* bit
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// Ancienne methode (non gray)
|
||||
// index du symbole (id) : même mappage que dans bits_to_symbols()
|
||||
int id = i_cl * sm + j_cl;
|
||||
|
||||
for (int b = 0; b < qam->k; b++) {
|
||||
bits_hat[k * qam->k + b] = (id >> (qam->k - 1 - b)) & 1;
|
||||
}
|
||||
*/
|
||||
|
||||
// Gray mapping
|
||||
if (qam->k % 2 != 0) {
|
||||
printf("demodulate : k pair (k = %d)\n", qam->k);
|
||||
exit(1);
|
||||
}
|
||||
int bits_per_axis = qam->k / 2;
|
||||
|
||||
int i_bin = gray_to_bin(i_cl);
|
||||
int j_bin = gray_to_bin(j_cl);
|
||||
|
||||
for (int b = 0; b < bits_per_axis; b++) {
|
||||
bits_hat[k * qam->k + b] = (i_bin >> (bits_per_axis - 1 - b)) & 1;
|
||||
bits_hat[k * qam->k + bits_per_axis + b] = (j_bin >> (bits_per_axis - 1 - b)) & 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,7 +141,7 @@ void add_noise (double complex* s, int len, double sigma) {
|
||||
}
|
||||
|
||||
// Changer le tableau de bits en boolen ou alors la represenation binaire et shifter pour extraire les bits (pas bien si M plus grand)
|
||||
void bits_to_symbols (qam_system* qam, uint8_t* bits, int nb_bits, double complex* symbols) {
|
||||
/*void bits_to_symbols (qam_system* qam, uint8_t* bits, int nb_bits, double complex* symbols) {
|
||||
int nb_symbols = nb_bits / qam->k;
|
||||
int sm = sqrt(qam->M);
|
||||
for (int k = 0; k < nb_symbols; k++) {
|
||||
@ -123,6 +153,37 @@ void bits_to_symbols (qam_system* qam, uint8_t* bits, int nb_bits, double comple
|
||||
int j = id % sm;
|
||||
symbols[k] = qam->constellation[i][j];
|
||||
}
|
||||
}*/
|
||||
|
||||
void bits_to_symbols (qam_system* qam, uint8_t* bits, int nb_bits, double complex* symbols) {
|
||||
int nb_symbols = nb_bits / qam->k;
|
||||
int sm = (int)sqrt(qam->M);
|
||||
|
||||
// k pair
|
||||
if (qam->k % 2 != 0) {
|
||||
printf("bits_to_symbols : k doit être pair (k = %d) \n", qam->k);
|
||||
exit(1);
|
||||
}
|
||||
int bits_per_axis = qam->k / 2;
|
||||
|
||||
for (int sym = 0; sym < nb_symbols; sym++) {
|
||||
// Construire les indices binaires i_bin (MSB...) et j_bin (LSB...)
|
||||
int i_bin = 0;
|
||||
int j_bin = 0;
|
||||
for (int b = 0; b < bits_per_axis; b++) {
|
||||
i_bin = (i_bin << 1) | bits[sym * qam->k + b];
|
||||
j_bin = (j_bin << 1) | bits[sym * qam->k + bits_per_axis + b];
|
||||
}
|
||||
|
||||
int i_gray = bin_to_gray(i_bin);
|
||||
int j_gray = bin_to_gray(j_bin);
|
||||
|
||||
if (i_gray < 0 || i_gray >= sm || j_gray < 0 || j_gray >= sm) {
|
||||
printf("bits_to_symbols : IOOR i_gray = %d j_gray = %d sm = %d \n", i_gray, j_gray, sm);
|
||||
exit(1);
|
||||
}
|
||||
symbols[sym] = qam->constellation[i_gray][j_gray];
|
||||
}
|
||||
}
|
||||
|
||||
double compare_bits(uint8_t* bits1, uint8_t* bits2, int nb_bits) {
|
||||
@ -166,7 +227,7 @@ void reconstruction_text(int nb_chars, uint8_t* output_bits, char* texte_recup)
|
||||
texte_recup[nb_chars] = '\0';
|
||||
}
|
||||
|
||||
void conversion_text_to_bits(int nb_chars, int nb_bits, char* texte, uint8_t* input_bits) {
|
||||
void text_to_bits(int nb_chars, int nb_bits, char* texte, uint8_t* input_bits) {
|
||||
for(int i = 0; i < nb_chars; i++){
|
||||
for(int b = 0; b < 8; b++){
|
||||
input_bits[i*8 + b] = (texte[i] >> (7-b)) & 1;
|
||||
@ -183,6 +244,7 @@ void free_constellation(qam_system* qam) {
|
||||
}
|
||||
|
||||
int main () {
|
||||
// Initialisation du system qam
|
||||
qam_system qam;
|
||||
qam.M = 16;
|
||||
qam.k = (int)log2((double)(qam.M));
|
||||
@ -198,7 +260,7 @@ int main () {
|
||||
int nb_bits = nb_chars * 8;
|
||||
int nb_symbols = (nb_bits + qam.k - 1) / qam.k;
|
||||
uint8_t* input_bits = malloc(nb_bits * sizeof(uint8_t));
|
||||
conversion_text_to_bits(nb_chars, nb_bits, texte, input_bits);
|
||||
text_to_bits(nb_chars, nb_bits, texte, input_bits);
|
||||
|
||||
// Conversion en symboles
|
||||
double complex* symbols = malloc(sizeof(double complex) * nb_symbols);
|
||||
|
||||
@ -210,7 +210,7 @@ int main () {
|
||||
modulate(&qam, symbols, nb_symbols, s);
|
||||
|
||||
// Ajout du bruit
|
||||
add_noise(s, total_samples, 0);
|
||||
add_noise(s, total_samples, 120);
|
||||
|
||||
FILE *fp_ref = fopen("constellation_ref.dat", "w");
|
||||
fill_constellation_data(&qam, fp_ref);
|
||||
|
||||
Reference in New Issue
Block a user