Commit 9c87a640 authored by sydney's avatar sydney

Fix incorrect estimations(saturation and minimum)

parent 857a24b4
CC=g++
CFLAGS= -g -I../cpp_src -W -Wall -O0 \
CFLAGS= -g -I../cpp_src -W -Wall -O3 \
-fopenmp -finline -funroll-loops -opt-prefetch -unroll-aggressive \
-m64 -DMKL_ILP64 -I../src -msse4a -march=native -I${MKL_ROOT}/include/
......
......@@ -70,7 +70,6 @@ void CDecoder_MS_fixed_reds::decode(
char Rprime_fix[],
int nombre_iterations)
{
/* TODO : initialize those variables */
char *llr_vn = var_nodes;
char *vn = CDecoder_fixed_reds::var_nodes;
char *vn_msgs = CDecoder_fixed_reds::var_msgs;
......@@ -97,37 +96,25 @@ void CDecoder_MS_fixed_reds::decode(
* to each of its neighbouring variable node.
*/
for(size_t cn_idx = 0; cn_idx < nb_cn; cn_idx++) {
char global_sign = 1;
char global_minLLR = 0x7F;
char vn_to_cn_msgs[cn_deg];
/* FIXME : in DVB-S2, the H matrix has one row with different degree:
* the last one. */
cn_deg = cn_idx == (nb_cn-1) ? DEG_2 : cn_deg;
/* First we retrieve all messages of VNs neighboring the current CN */
for(size_t edge_idx = 0; edge_idx < cn_deg; edge_idx++) {
vn_to_cn_msgs[edge_idx] = *p_vn_addr[cn_idx*cn_deg + edge_idx];
}
/* Second, we evaluate a global estimate which will be adapted thereafter
* for each neighboring VN */
for(size_t edge_idx = 0; edge_idx < cn_deg; edge_idx++) {
char msg = vn_to_cn_msgs[edge_idx];
char abs_msg = (msg >= 0 ? msg : -msg);
global_sign *= (msg >= 0) ? 1 : -1;
global_minLLR = global_minLLR > abs_msg ? abs_msg : global_minLLR;
}
/* Third, we compute a different estimate (the message sent), for each
/* We compute a different estimate (the message sent), for each
* neighbouring VN */
for(size_t edge_idx = 0; edge_idx < cn_deg; edge_idx++) {
char msg = vn_to_cn_msgs[edge_idx];
char abs_msg = (msg >= 0 ? msg : -msg);
char sign = (msg >= 0) ? 1 : -1;
char minLLR = global_minLLR > abs_msg ? global_minLLR : abs_msg;
/* TODO : verify the operation on the sign. Is it what we want ? */
cn_msgs[cn_idx*cn_deg + edge_idx] = (sign * global_sign) * minLLR;
char sign = 1;
char minLLR = 127;
for(size_t other_edge_idx = 0; other_edge_idx < cn_deg; other_edge_idx++) {
if(other_edge_idx == edge_idx) continue;
char msg = *p_vn_addr[cn_idx*cn_deg + other_edge_idx];
char abs_msg = (msg >= 0 ? msg : -msg);
sign *= (msg >= 0) ? 1 : -1;
minLLR = minLLR > abs_msg ? abs_msg : minLLR;
}
cn_msgs[cn_idx*cn_deg + edge_idx] = (sign * minLLR);
}
}
......@@ -143,7 +130,13 @@ void CDecoder_MS_fixed_reds::decode(
edge_idx < vn_deg && p_cn_addr[vn_idx*vn_deg + edge_idx] != NULL;
edge_idx++)
{
vn[vn_idx] += *p_cn_addr[vn_idx*vn_deg + edge_idx];
int a = *p_cn_addr[vn_idx*vn_deg + edge_idx];
int b = vn[vn_idx];
int c = a + b;
// 8 bit signed saturation
if(c > 127) c = 127;
else if(c < -128) c = -128;
vn[vn_idx] = (char)c;
}
for(
......@@ -151,15 +144,19 @@ void CDecoder_MS_fixed_reds::decode(
edge_idx < vn_deg && p_cn_addr[vn_idx*vn_deg + edge_idx] != NULL;
edge_idx++)
{
vn_msgs[vn_idx*vn_deg + edge_idx] =
vn[vn_idx] - *p_cn_addr[vn_idx*vn_deg + edge_idx];
int a = *p_cn_addr[vn_idx*vn_deg + edge_idx];
int b = vn[vn_idx];
int c = b - a;
//8 bit signed saturation
if(c > 127) c = 127;
else if(c < -128) c = -128;
vn_msgs[vn_idx*vn_deg + edge_idx] = (char)c;
}
}
}
/* Hard decision */
for(size_t vn_idx = 0; vn_idx < nb_vn; vn_idx++) {
// FIXME : write in Rprime_fix ?
vn[vn_idx] = vn[vn_idx] > threshold ? 1 : 0;
Rprime_fix[vn_idx] = vn[vn_idx] > threshold ? 1 : 0;
}
}
\ No newline at end of file
/**
Copyright (c) 2012-2015 "Bordeaux INP, Bertrand LE GAL"
[http://legal.vvv.enseirb-matmeca.fr]
This file is part of LDPC_C_Simulator.
LDPC_C_Simulator is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//int EncValues[] = { 0, 0 };
//int N_LDPC = 1;
//int K_LDPC = 1;
//int NmK_LDPC = 1;
//int M_LDPC = 1;
//int Q_LDPC = 1;
//int N_LINES = 0;
int EncValues[] = {
13, 0, 2084, 1613, 1548, 1286, 1460, 3196, 4297, 2481, 3369, 3451, 4620, 2622,
13, 1, 122, 1516, 3448, 2880, 1407, 1847, 3799, 3529, 373, 971, 4358, 3108,
13, 2, 259, 3399, 929, 2650, 864, 3996, 3833, 107, 5287, 164, 3125, 2350,
3, 3, 342, 3529,
3, 4, 4198, 2147,
3, 5, 1880, 4836,
3, 6, 3864, 4910,
3, 7, 243, 1542,
3, 8, 3011, 1436,
3, 9, 2167, 2512,
3, 10, 4606, 1003,
3, 11, 2835, 705,
3, 12, 3426, 2365,
3, 13, 3848, 2474,
3, 14, 1360, 1743,
3, 0, 163, 2536,
3, 1, 2583, 1180,
3, 2, 1542, 509,
3, 3, 4418, 1005,
3, 4, 5212, 5117,
3, 5, 2155, 2922,
3, 6, 347, 2696,
3, 7, 226, 4296,
3, 8, 1560, 487,
3, 9, 3926, 1640,
3, 10, 149, 2928,
3, 11, 2364, 563,
3, 12, 635, 688,
3, 13, 231, 1684,
3, 14, 1129, 3894
8, 54, 9318, 14392, 27561, 26909, 10219, 2534, 8597,
8, 55, 7263, 4635, 2530, 28130, 3033, 23830, 3651,
8, 56, 24731, 23583, 26036, 17299, 5750, 792, 9169,
8, 57, 5811, 26154, 18653, 11551, 15447, 13685, 16264,
8, 58, 12610, 11347, 28768, 2792, 3174, 29371, 12997,
8, 59, 16789, 16018, 21449, 6165, 21202, 15850, 3186,
8, 60, 31016, 21449, 17618, 6213, 12166, 8334, 18212,
8, 61, 22836, 14213, 11327, 5896, 718, 11727, 9308,
8, 62, 2091, 24941, 29966, 23634, 9013, 15587, 5444,
8, 63, 22207, 3983, 16904, 28534, 21415, 27524, 25912,
8, 64, 25687, 4501, 22193, 14665, 14798, 16158, 5491,
8, 65, 4520, 17094, 23397, 4264, 22370, 16941, 21526,
8, 66, 10490, 6182, 32370, 9597, 30841, 25954, 2762,
8, 67, 22120, 22865, 29870, 15147, 13668, 14955, 19235,
8, 68, 6689, 18408, 18346, 9918, 25746, 5443, 20645,
8, 69, 29982, 12529, 13858, 4746, 30370, 10023, 24828,
8, 70, 1262, 28032, 29888, 13063, 24033, 21951, 7863,
8, 71, 6594, 29642, 31451, 14831, 9509, 9335, 31552,
8, 72, 1358, 6454, 16633, 20354, 24598, 624, 5265,
8, 73, 19529, 295, 18011, 3080, 13364, 8032, 15323,
8, 74, 11981, 1510, 7960, 21462, 9129, 11370, 25741,
8, 75, 9276, 29656, 4543, 30699, 20646, 21921, 28050,
8, 76, 15975, 25634, 5520, 31119, 13715, 21949, 19605,
8, 77, 18688, 4608, 31755, 30165, 13103, 10706, 29224,
8, 78, 21514, 23117, 12245, 26035, 31656, 25631, 30699,
8, 79, 9674, 24966, 31285, 29908, 17042, 24588, 31857,
8, 80, 21856, 27777, 29919, 27000, 14897, 11409, 7122,
8, 81, 29773, 23310, 263, 4877, 28622, 20545, 22092,
8, 82, 15605, 5651, 21864, 3967, 14419, 22757, 15896,
8, 83, 30145, 1759, 10139, 29223, 26086, 10556, 5098,
8, 84, 18815, 16575, 2936, 24457, 26738, 6030, 505,
8, 85, 30326, 22298, 27562, 20131, 26390, 6247, 24791,
8, 86, 928, 29246, 21246, 12400, 15311, 32309, 18608,
8, 87, 20314, 6025, 26689, 16302, 2296, 3244, 19613,
8, 88, 6237, 11943, 22851, 15642, 23857, 15112, 20947,
8, 89, 26403, 25168, 19038, 18384, 8882, 12719, 7093,
3, 0, 14567, 24965,
3, 1, 3908, 100,
3, 2, 10279, 240,
3, 3, 24102, 764,
3, 4, 12383, 4173,
3, 5, 13861, 15918,
3, 6, 21327, 1046,
3, 7, 5288, 14579,
3, 8, 28158, 8069,
3, 9, 16583, 11098,
3, 10, 16681, 28363,
3, 11, 13980, 24725,
3, 12, 32169, 17989,
3, 13, 10907, 2767,
3, 14, 21557, 3818,
3, 15, 26676, 12422,
3, 16, 7676, 8754,
3, 17, 14905, 20232,
3, 18, 15719, 24646,
3, 19, 31942, 8589,
3, 20, 19978, 27197,
3, 21, 27060, 15071,
3, 22, 6071, 26649,
3, 23, 10393, 11176,
3, 24, 9597, 13370,
3, 25, 7081, 17677,
3, 26, 1433, 19513,
3, 27, 26925, 9014,
3, 28, 19202, 8900,
3, 29, 18152, 30647,
3, 30, 20803, 1737,
3, 31, 11804, 25221,
3, 32, 31683, 17783,
3, 33, 29694, 9345,
3, 34, 12280, 26611,
3, 35, 6526, 26122,
3, 36, 26165, 11241,
3, 37, 7666, 26962,
3, 38, 16290, 8480,
3, 39, 11774, 10120,
3, 40, 30051, 30426,
3, 41, 1335, 15424,
3, 42, 6865, 17742,
3, 43, 31779, 12489,
3, 44, 32120, 21001,
3, 45, 14508, 6996,
3, 46, 979, 25024,
3, 47, 4554, 21896,
3, 48, 7989, 21777,
3, 49, 4972, 20661,
3, 50, 6612, 2730,
3, 51, 12742, 4418,
3, 52, 29194, 595,
3, 53, 19267, 20113
};
int N_LDPC = 16200;
int K_LDPC = 10800;
int NmK_LDPC = 5400;
int N_LDPC = 64800;
int K_LDPC = 32400;
int NmK_LDPC = 32400;
int M_LDPC = 360;
int Q_LDPC = 15;
int N_LINES = 30;
int Q_LDPC = 90.0;
int N_LINES = 90;
......@@ -78,7 +78,7 @@ CErrorAnalyzer::CErrorAnalyzer(CTrame *t, int max_fe, bool auto_fe_mode, bool wo
}
}
#define SHOW_FAULTY_BITS false
#define SHOW_FAULTY_BITS true
CErrorAnalyzer::~CErrorAnalyzer(){
delete buf_en_bits;
......
......@@ -437,6 +437,7 @@ int main(int argc, char* argv[]) {
encoder[i]->encode();
}
for(int i=0; i<4; i++){
noise[i]->generate();
}
......@@ -449,6 +450,19 @@ int main(int argc, char* argv[]) {
errCounter[i]->store_enc_bits();
}
// TODO : remove after tests
decoder[0]->decode(simu_data[0]->get_t_fpoint_data(), simu_data[0]->get_t_decode_data(), NB_ITERATIONS);
FILE *in = fopen("encoded.txt", "w+");
FILE *out = fopen("decoded.txt", "w+");
for(size_t i = 0; i < 64800; i++) {
fprintf(in, "%d ", simu_data[0]->get_t_coded_bits()[i]);
fprintf(out, "%d ", simu_data[0]->get_t_decode_data()[i]);
}
fclose(out);
fclose(in);
//
// ON CREE UN OBJET POUR LA MESURE DU TEMPS DE SIMULATION (REMISE A ZERO POUR CHAQUE Eb/N0)
//
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment