Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using module::Decoder_RSC_BCJR_intra_std #16

Open
jdayana opened this issue Jun 16, 2021 · 3 comments
Open

Using module::Decoder_RSC_BCJR_intra_std #16

jdayana opened this issue Jun 16, 2021 · 3 comments

Comments

@jdayana
Copy link

jdayana commented Jun 16, 2021

Hi,

I am interested in using the Decoder_RSC_BCJR_intra_std class. When I run the code, I receive an error saying "error showing 'mipp::nElReg()' has to be equal to 8" and I am not sure what it is that I should be changing. I hope to receive some assistance regarding this matter. Thanks!

	// ==========
	// PARAMETERS
	// ==========
	int   K           = 6144;                      // number of information bits in the frame (40)
	int   tail_length = 12;                        // tail length
	int   N           = 3 * K + tail_length;       // size of one frame (132)
	int   N_enc       = 2 * K + (tail_length / 2); // for each RSC constituent encoder (86)
	int   fe          = 100;                       // number of frame errors
	int   seed        = 0;                         // PRNG seed for the AWGN channel
	float ebn0_min    = 0.00f;                     // minimum SNR value
	float ebn0_max    = 1.01f;                     // maximum SNR value
	float ebn0_step   = 1.00f;                     // SNR step
	float R = (float)K / (float)N;                 // code rate (R=K/N)
	int   num_iters   = 5;                         // maximal number of iterations in the turbo decoder
	int   n_frames    = 1;                         // number of frames to process in the Decoder
	int   simd_inter_frame_level = 8;              // number of frames absorbed by the SIMD instructions
	std::vector<int> poly = { 013, 015 };          // polynomials that define the RSC code (or the trellis structure)
	                                               // LTE:{013,015}, CCSDS:{023,033}
	// =======
	// MODULES
	// =======
	std::unique_ptr<module::Source_random<>>              m_source;
	std::unique_ptr<tools::Interleaver_core_LTE<>>        m_intl_core;
	std::unique_ptr<module::Interleaver<>>                m_intl;
	std::unique_ptr<tools::Interleaver_core_LTE<>>        m_intl_core_inv;
	std::unique_ptr<module::Interleaver<float, uint32_t>> m_intl_inv;
	std::unique_ptr<module::Encoder_RSC_generic_sys<>>    m_encN;
	std::unique_ptr<module::Encoder_RSC_generic_sys<>>    m_encI;
	std::unique_ptr<module::Encoder_turbo<>>              m_encoder;
	std::unique_ptr<module::Modem_BPSK<>>                 m_modem;
	std::unique_ptr<module::Channel_AWGN_LLR<>>           m_channel;
	std::unique_ptr<module::Monitor_BFER<>>               m_monitor;

	// source
	m_source = std::unique_ptr<module::Source_random            <>>(new module::Source_random           <>(K));

	// interleaver
	m_intl_core = std::unique_ptr<tools::Interleaver_core_LTE   <>>(new tools::Interleaver_core_LTE     <>(K, n_frames));
	m_intl_core->init();
	m_intl = std::unique_ptr<module::Interleaver                <>>(new module::Interleaver             <>(*m_intl_core));

	// encoder
	m_encN = std::unique_ptr<module::Encoder_RSC_generic_sys    <>>(new module::Encoder_RSC_generic_sys <>(K, N_enc, true, poly, n_frames));
	m_encI = std::unique_ptr<module::Encoder_RSC_generic_sys    <>>(new module::Encoder_RSC_generic_sys <>(K, N_enc, true, poly, n_frames));
	m_encoder = std::unique_ptr<module::Encoder_turbo           <>>(new module::Encoder_turbo           <>(K, N, *m_intl, *m_encN, *m_encI));

	// channel
	m_modem = std::unique_ptr<module::Modem_BPSK                <>>(new module::Modem_BPSK              <>(N));
	m_channel = std::unique_ptr<module::Channel_AWGN_LLR        <>>(new module::Channel_AWGN_LLR        <>(N, seed));
	m_monitor = std::unique_ptr<module::Monitor_BFER            <>>(new module::Monitor_BFER            <>(K, fe));

	// de-interleaver
	m_intl_core_inv = std::unique_ptr<tools::Interleaver_core_LTE   <>>(new tools::Interleaver_core_LTE     <>(K, n_frames));
	m_intl_core_inv->init();
	m_intl_inv = std::unique_ptr<module::Interleaver<float, uint32_t>>(new module::Interleaver<float, uint32_t>(*m_intl_core_inv));

	// trellis
	const std::vector<std::vector<int>>& trellis_n = m_encN->get_trellis();
	const std::vector<std::vector<int>>& trellis_i = m_encI->get_trellis();

	// decoder
	// intra_std - error showing 'mipp::nElReg<R>()' has to be equal to 8
	std::cout << "# STD INTRA_STD\n";
	std::unique_ptr<module::Decoder_RSC_BCJR_intra_std<>> m_decN;
	std::unique_ptr<module::Decoder_RSC_BCJR_intra_std<>> m_decI;
	std::unique_ptr<module::Decoder_turbo_std<>>          m_decoder;
	m_decN = std::unique_ptr<module::Decoder_RSC_BCJR_intra_std   <>>(new module::Decoder_RSC_BCJR_intra_std<>(K, trellis_n, true, n_frames));
	m_decI = std::unique_ptr<module::Decoder_RSC_BCJR_intra_std   <>>(new module::Decoder_RSC_BCJR_intra_std<>(K, trellis_i, true, n_frames));
	m_decoder = std::unique_ptr<module::Decoder_turbo_std         <>>(new module::Decoder_turbo_std         <>(K, N, num_iters, *m_intl_inv, *m_decN, *m_decI, true));

	// ======
	// BUFFER
	// ======
	std::vector<int  > ref_bits;
	std::vector<int  > enc_bits;
	std::vector<float> symbols;
	std::vector<float> noisy_symbols;
	std::vector<float> LLRs;
	std::vector<int  > dec_bits;

	ref_bits		= std::vector<int  >(K);
	enc_bits		= std::vector<int  >(N);
	symbols			= std::vector<float>(N);
	noisy_symbols   = std::vector<float>(N);
	LLRs			= std::vector<float>(N);
	dec_bits		= std::vector<int  >(K);

	// =========
	// UTILITIES
	// =========
	std::unique_ptr<tools::Sigma<>>               noise;     // a sigma noise type
	std::vector<std::unique_ptr<tools::Reporter>> reporters; // list of reporters dispayed in the terminal
	std::unique_ptr<tools::Terminal_std>          terminal;  // manage the output text in the terminal

	// create a sigma noise type
	noise = std::unique_ptr<tools::Sigma<>>(new tools::Sigma<>());
	// report the noise values (Es/N0 and Eb/N0)
	reporters.push_back(std::unique_ptr<tools::Reporter>(new tools::Reporter_noise<>(*noise)));
	// report the bit/frame error rates
	reporters.push_back(std::unique_ptr<tools::Reporter>(new tools::Reporter_BFER<>(*m_monitor)));
	// report the simulation throughputs
	reporters.push_back(std::unique_ptr<tools::Reporter>(new tools::Reporter_throughput<>(*m_monitor)));
	// create a terminal that will display the collected data from the reporters
	terminal = std::unique_ptr<tools::Terminal_std>(new tools::Terminal_std(reporters));

	// ================
	// START SIMULATION
	// ================
	// get the AFF3CT version
	const std::string v = "v" + std::to_string(tools::version_major()) + "." +
		std::to_string(tools::version_minor()) + "." +
		std::to_string(tools::version_release());

	std::cout << "#----------------------------------------------------------" << std::endl;
	std::cout << "# This is a basic program using the AFF3CT library (" << v << ")" << std::endl;
	std::cout << "# Feel free to improve it as you want to fit your needs." << std::endl;
	std::cout << "#----------------------------------------------------------" << std::endl;
	std::cout << "#" << std::endl;

	// display the legend in the terminal
	terminal->legend();

	// loop over the various SNRs
	for (auto ebn0 = ebn0_min; ebn0 < ebn0_max; ebn0 += ebn0_step)
	{
		// compute the current sigma for the channel noise
		const auto esn0 = tools::ebn0_to_esn0(ebn0, R);
		const auto sigma = tools::esn0_to_sigma(esn0);

		noise->set_noise(sigma, ebn0, esn0);

		// update the sigma of the modem and the channel
		m_modem->set_noise(*noise);
		m_channel->set_noise(*noise);

		// display the performance (BER and FER) in real time (in a separate thread)
		terminal->start_temp_report();

		// run the simulation chain
		while (!m_monitor->fe_limit_achieved() && !terminal->is_interrupt())
		{
			m_source->generate      (ref_bits);
			m_encoder->encode       (ref_bits, enc_bits);
			m_modem->modulate       (enc_bits, symbols);
			m_channel->add_noise    (symbols, noisy_symbols);
			m_modem->demodulate     (noisy_symbols, LLRs);
			m_decoder->decode_siho  (LLRs, dec_bits);
			m_monitor->check_errors (dec_bits, ref_bits);
		}

		// display the performance (BER and FER) in the terminal
		terminal->final_report();

		// reset the monitor for the next SNR
		m_monitor->reset();
		terminal->reset();

		// if user pressed Ctrl+c twice, exit the SNRs loop
		if (terminal->is_over()) break;
	}

	std::cout << "# End of the simulation" << std::endl;
@kouchy
Copy link
Member

kouchy commented Jun 17, 2021

Hi @jdayana,

Try to compile the code with SSE instructions : -msse4.2 with GCC.

I hope it helps.

@jdayana
Copy link
Author

jdayana commented Jun 17, 2021

Hi @kouchy ,

Thanks for your reply. Do you mean when compiling the aff3ct source code at this step?

Is there any way to do this via Microsoft Visual Studio?

Thanks,
Dayana

@Hashiao
Copy link

Hashiao commented Apr 22, 2022

@jdayana Hi jdayana
I successfully run your code with aff3ct v2.3.5, VS2019 WIN10-64bit, and the result is quite coincident with the one given by aff3ct/refs/TURBO/AWGN/BPSK/RSC_RSC/BCJR/LTE/...
if you need the project or including or library files, send me email to [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants