MCPcopy Create free account
hub / github.com/aff3ct/aff3ct / Encoder_RSC_generic_sys

Method Encoder_RSC_generic_sys

src/Module/Encoder/RSC/Encoder_RSC_generic_sys.cpp:12–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11template<typename B>
12Encoder_RSC_generic_sys<B>::Encoder_RSC_generic_sys(const int& K,
13 const int& N,
14 const bool buffered_encoding,
15 const std::vector<int> poly)
16 : Encoder_RSC_sys<B>(K, N, (int)std::floor(std::log2(poly[0])), buffered_encoding)
17 , out_parity()
18 , next_state()
19 , sys_tail()
20{
21 const std::string name = "Encoder_RSC_generic_sys";
22 this->set_name(name);
23 for (auto& t : this->tasks)
24 t->set_replicability(true);
25
26 if (poly.size() < 2)
27 {
28 std::stringstream message;
29 message << "'poly.size()' has to be equal or greater than 2 ('poly.size()' = " << poly.size() << ").";
30 throw spu::tools::length_error(__FILE__, __LINE__, __func__, message.str());
31 }
32
33 if (std::floor(std::log2(poly[0])) != std::floor(std::log2(poly[1])))
34 {
35 std::stringstream message;
36 message << "floor(log2('poly[0]')) has to be equal to floor(log2('poly[1]')) ('poly[0]' = " << poly[0]
37 << ", 'poly[1]' = " << poly[1] << ").";
38 throw spu::tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());
39 }
40
41 for (auto s = 0; s < this->n_states; s++)
42 {
43 auto temp_tail = 0, temp_parity = 0;
44 for (auto i = 0; i < this->n_ff; i++)
45 {
46 temp_tail ^= ((s >> i) & 0x1) & ((poly[0] >> i) & 0x1);
47 temp_parity ^= ((s >> i) & 0x1) & ((poly[1] >> i) & 0x1);
48 }
49
50 out_parity.push_back(temp_tail ^ temp_parity);
51 out_parity.push_back((1 - temp_tail) ^ temp_parity);
52
53 sys_tail.push_back(temp_tail);
54
55 next_state.push_back((s >> 1) ^ (temp_tail << (this->n_ff - 1)));
56 next_state.push_back((s >> 1) ^ ((1 - temp_tail) << (this->n_ff - 1)));
57 }
58}
59
60template<typename B>
61Encoder_RSC_generic_sys<B>*

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected