Skip to content

Commit

Permalink
Fix RS decoder for returning a CWD flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtajan committed Mar 23, 2022
1 parent 3b506a1 commit f95859e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
8 changes: 4 additions & 4 deletions include/Module/Decoder/RS/Decoder_RS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class Decoder_RS : public Decoder_SIHO<B,R>

protected:
virtual int _decode ( S *Y_N, const size_t frame_id) = 0;
virtual int _decode_hiho (const B *Y_N, B *V_K, const size_t frame_id);
virtual int _decode_hiho_cw(const B *Y_N, B *V_N, const size_t frame_id);
virtual int _decode_siho (const R *Y_N, B *V_K, const size_t frame_id);
virtual int _decode_siho_cw(const R *Y_N, B *V_N, const size_t frame_id);
virtual int _decode_hiho (const B *Y_N, int8_t *CWD, B *V_K, const size_t frame_id);
virtual int _decode_hiho_cw(const B *Y_N, int8_t *CWD, B *V_N, const size_t frame_id);
virtual int _decode_siho (const R *Y_N, int8_t *CWD, B *V_K, const size_t frame_id);
virtual int _decode_siho_cw(const R *Y_N, int8_t *CWD, B *V_N, const size_t frame_id);
};
}
}
Expand Down
15 changes: 8 additions & 7 deletions src/Module/Decoder/RS/Decoder_RS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ::clone() const

template <typename B, typename R>
int Decoder_RS<B, R>
::_decode_hiho(const B *Y_N, B *V_K, const size_t frame_id)
::_decode_hiho(const B *Y_N, int8_t *CWD, B *V_K, const size_t frame_id)
{
// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD
tools::Bit_packer::pack(Y_N, YH_N.data(), this->N, 1, false, this->m);
Expand All @@ -56,7 +56,7 @@ ::_decode_hiho(const B *Y_N, B *V_K, const size_t frame_id)
// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE
auto status = this->_decode(YH_N.data(), frame_id);
// auto d_decod = std::chrono::steady_clock::now() - t_decod;

CWD[0] = !status;
// auto t_store = std::chrono::steady_clock::now(); // --------------------------------------------------------- STORE
tools::Bit_packer::unpack(YH_N.data() + this->n_rdncy, V_K, this->K, 1, false, this->m);
// auto d_store = std::chrono::steady_clock::now() - t_store;
Expand All @@ -70,7 +70,7 @@ ::_decode_hiho(const B *Y_N, B *V_K, const size_t frame_id)

template <typename B, typename R>
int Decoder_RS<B, R>
::_decode_hiho_cw(const B *Y_N, B *V_N, const size_t frame_id)
::_decode_hiho_cw(const B *Y_N, int8_t *CWD, B *V_N, const size_t frame_id)
{
// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD
tools::Bit_packer::pack(Y_N, YH_N.data(), this->N, 1, false, this->m);
Expand All @@ -79,7 +79,7 @@ ::_decode_hiho_cw(const B *Y_N, B *V_N, const size_t frame_id)
// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE
auto status = this->_decode(YH_N.data(), frame_id);
// auto d_decod = std::chrono::steady_clock::now() - t_decod;

CWD[0] = !status;
// auto t_store = std::chrono::steady_clock::now(); // --------------------------------------------------------- STORE
tools::Bit_packer::unpack(YH_N.data(), V_N, this->N, 1, false, this->m);
// auto d_store = std::chrono::steady_clock::now() - t_store;
Expand All @@ -93,7 +93,7 @@ ::_decode_hiho_cw(const B *Y_N, B *V_N, const size_t frame_id)

template <typename B, typename R>
int Decoder_RS<B, R>
::_decode_siho(const R *Y_N, B *V_K, const size_t frame_id)
::_decode_siho(const R *Y_N, int8_t *CWD, B *V_K, const size_t frame_id)
{
// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD
tools::hard_decide(Y_N, YH_Nb.data(), this->N);
Expand All @@ -103,7 +103,7 @@ ::_decode_siho(const R *Y_N, B *V_K, const size_t frame_id)
// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE
auto status = this->_decode(YH_N.data(), frame_id);
// auto d_decod = std::chrono::steady_clock::now() - t_decod;

CWD[0] = !status;
// auto t_store = std::chrono::steady_clock::now(); // --------------------------------------------------------- STORE
tools::Bit_packer::unpack(YH_N.data() + this->n_rdncy, V_K, this->K, 1, false, this->m);
// auto d_store = std::chrono::steady_clock::now() - t_store;
Expand All @@ -117,7 +117,7 @@ ::_decode_siho(const R *Y_N, B *V_K, const size_t frame_id)

template <typename B, typename R>
int Decoder_RS<B, R>
::_decode_siho_cw(const R *Y_N, B *V_N, const size_t frame_id)
::_decode_siho_cw(const R *Y_N, int8_t *CWD, B *V_N, const size_t frame_id)
{
// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD
tools::hard_decide(Y_N, YH_Nb.data(), this->N);
Expand All @@ -126,6 +126,7 @@ ::_decode_siho_cw(const R *Y_N, B *V_N, const size_t frame_id)

// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE
auto status = this->_decode(YH_N.data(), frame_id);
CWD[0] = !status;
// auto d_decod = std::chrono::steady_clock::now() - t_decod;

// auto t_store = std::chrono::steady_clock::now(); // --------------------------------------------------------- STORE
Expand Down
3 changes: 2 additions & 1 deletion src/Module/Decoder/RS/Standard/Decoder_RS_std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,15 @@ ::_decode(S *Y_N, const size_t frame_id)
Y_N[loc[i]] ^= err[loc[i]]; // Y_N[i] must be in polynomial form
}
}
syn_error = false;
}
// else // no. roots != degree of elp => over t errors and cannot solve
}
// else // elp has degree has degree > t hence cannot solve
}
// else // no non-zero syndromes => no errors: output received codeword

return 0;
return (int)syn_error;
}

// ==================================================================================== explicit template instantiation
Expand Down

0 comments on commit f95859e

Please sign in to comment.