Number of bits per symbol (m) range in Reed-Solomon coding

5 views (last 30 days)
I'm playing around with Reed-Solomon codes. In the parameters of rsenc, help shows m represents the "number of bits per symbol" and has the range of "3 to 16".
The way I understood on m is that it has minimum three bits per symbol, i.e., 000, 001, 010, ..., 111. Am I correct? What if I need to use two bits or one bit per symbol? What am I supposed to do if I want to construct a message with length of 20 (as an example) and each symbol has bit (i.e., 0 or 1)?

Accepted Answer

Umar
Umar on 27 Sep 2024

Hi @Jay,

After reviewing the documentation regarding rsenc function provided at the link below

https://www.mathworks.com/help/comm/ref/rsenc.html

The parameters n and k in the context of rsenc represent the codeword length and message length, respectively. The condition for n is that it should be of the form 2^m - 1 , where m ranges from 3 to 16. Here are the key points regarding m listed below.

Bits per Symbol

For m = 3, you can represent symbols as:

(000) (0), 
 (001 ) (1), 
  ... up to 
  ( 111 ) (7)

This implies you can represent values between 0 and 2^m - 1.

Using Fewer Bits

If you want to use only 1 or 2 bits per symbol, Reed-Solomon codes, as defined in your context, won't support this directly as mentioned by @Walter Roberson and I do agree with his comments. Notice the minimum value for m is 3. To work with fewer bits, you would need a different coding scheme (like binary coding).

So, if you still wish to use Reed-Solomon codes then your message needs to be represented with binary symbols, consider the following approach; convert your binary data into a suitable format that fits within the constraints of Reed-Solomon encoding. For instance, you can group your binary data into blocks that correspond to the minimum symbol size allowed (i.e., groups of three bits). Here is an example code snippet that demonstrates how to encode a message of length 20 using Reed-Solomon codes with (m = 3).

% Define parameters
m = 3;           % Number of bits per symbol
n = 2^m - 1;    % Codeword length: n = 7
k = floor(20 / (2^m)); % Message length based on total bits available
% Create a binary message of length 20
binary_message = randi([0, 1], [1, 20]); % Random binary message
% Convert binary message to Galois field representation
% Group into symbols based on m
msg_symbols = zeros(1, k);
for i = 1:k
  % Convert each group of three bits into a single symbol
  start_index = (i-1)*3 + 1;
  msg_symbols(i) = bi2de(binary_message(start_index:start_index+2));
end
% Create Galois field array
msg = gf(msg_symbols, m);
% Generate RS codewords
code = rsenc(msg, n, k);
% Display results
disp('Original Binary Message:');
disp(binary_message);
disp('Encoded Reed-Solomon Code:');
disp(code.x); % Display code in Galois field representation

Try implementing the code above. For more information on bit2int function, please refer to

https://www.mathworks.com/help/comm/ref/bit2int.html

Note: bit2int requires Communications Toolbox.

The above snippet code example assumes that the binary message can be effectively divided into groups that match the constraints of your chosen symbol size. Now, if you need to work exclusively with binary data without grouping into larger symbols, consider using simpler coding methods like Hamming codes or other forms of linear block codes that are designed for binary input.

This comprehensive approach should help you provide clarity on how to proceed with Reed-Solomon codes while addressing your requirement for binary messaging.

Please let us know if you have any further questions.

  3 Comments
Jay
Jay on 27 Sep 2024
Thanks @Umar for the code and it helps.
I found the code has an error in the line below. Perhaps you meant the floor to be ceil?
k = ceil(20 / (2^m)); % Message length based on total bits available
Umar
Umar on 28 Sep 2024

Hi @Jay,

You mentioned the following, “Perhaps I need a further clarification what I understood. In MATLAB example states that m is the number of bits per symbol which I understood it as a modulation scheme, e.g., 8-PAM, 8-FSK, or 8-PSK, etc. So, in the parameters definition below, an each input message length has 3 symbols (=k) where each symbol has a value of 0 - 7 (m) and the output RS codeword is the length 7 (=n=2^3-1). Am I correct?

m = 3; % Number of bits per symbol n = 2^m - 1; % Codeword length k = 3; % Message length

If my understanding above is correct, you are sying that a binary or a quadrature (4-4-PAM, 4-FSK, or 4-PSK) modulation scheme (e.g., m = 1 or 2) is not supported by Reed-Solomon. Is this correct understanding? I found the code has an error in the line below. Perhaps you meant the floor to be ceil? k = ceil(20 / (2^m)); % Message length based on total bits available “

Please see my response to your comments below.

So, first it would be better to understand rsenc parameters

Parameter Definitions

m: This represents the number of bits per symbol. For Reed-Solomon codes, m must be at least 3, meaning each symbol can represent values from 0 to 2^m - 1.

n: This is the total length of the codeword and is defined as n = 2^m - 1. For example, if m = 3, then n = 7.

k: This denotes the length of the message (in symbols) that can be encoded. The relationship between these parameters is critical, particularly that n must be greater than k by a positive even integer.

Now, this will help understand symbol representation example provided above in your comments. So, when m = 3, you can represent up to 8 symbols (from 0 to 7). In your example:

     m = 3;           % Number of bits per symbol
     n = 2^m - 1;     % Codeword length 
     k = 3;           % Message length

This indicates you can encode a message consisting of three symbols (values between 0 and 7), which aligns with your understanding.

Now, addressing your query regarding, “ Binary Representation with Reed-Solomon Codes ”, you correctly noted that Reed-Solomon does not support fewer than three bits per symbol directly. If you wish to encode binary data (using only 1 or 2 bits per symbol), you would need to group your data into blocks that fit within the constraints of RS coding. The provided code snippet illustrates how to convert a binary message into a format suitable for RS encoding by grouping bits into sets of three.

Addressing your final query regarding, “ Code Correction Regarding Message Length ”, in your comment about using ceil instead of floor, it is important to note that using floor makes sure that you do not exceed the maximum number of symbols available for encoding based on your total bit count divided by 2^m. However, if you want to make sure all bits are used when they don't fit perfectly into groups, then using ceil could be appropriate depending on your specific use case.

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 27 Sep 2024
What am I supposed to do if I want to construct a message with length of 20 (as an example) and each symbol has bit (i.e., 0 or 1)?
In that case, you do not use Reed-Solomon encoding.
Reed-Solomon effectively needs room for overhead bits. It cannot handle having no overhead bits.

Products


Release

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!