% Gray coded QPSK modulation function\r
\r
function symbol = qpsk_mod(two_bits)\r
- two_bits_decimal = sum(two_bits .* [1 2]); \r
+ two_bits_decimal = sum(two_bits .* [2 1]); \r
switch(two_bits_decimal)\r
- case (0) symbol = 1+j;\r
- case (1) symbol = -1+j;\r
- case (2) symbol = 1-j;\r
- case (3) symbol = -1-j;\r
+ case (0) symbol = 1;\r
+ case (1) symbol = j;\r
+ case (2) symbol = -j;\r
+ case (3) symbol = -1;\r
endswitch\r
endfunction\r
\r
pout += 2;\r
luw -= 2;\r
end\r
+endfunction\r
+\r
+% removes a unique word from a frame of bits. The UW bits are spread\r
+% throughout the input frame 2 bits at a time.\r
+\r
+function frameout = remove_uw(framein, lvd, luw)\r
+\r
+ spacing = 2*lvd/luw;\r
+\r
+ frameout = [];\r
+\r
+ pin = 1; pout = 1;\r
+ while (luw)\r
+ %printf("pin %d pout %d luw %d ", pin, pout, luw);\r
+ %printf("pin+spacing-1 %d lvd %d lframein: %d\n", pin+spacing-1, lvd, length(framein));\r
+ frameout(pout:pout+spacing-1) = framein(pin:pin+spacing-1);\r
+ pin += spacing + 2; \r
+ pout += spacing;\r
+ luw -= 2;\r
+ end\r
\r
endfunction\r
\r
+\r
% builds up a sparse QPSK modulated version version of the UW for use\r
% in UW sync at the rx\r
\r
demod_type = 0;\r
decoder_type = 0;\r
max_iterations = 100;\r
+EsNo = 10;\r
\r
vocoderframesize = 52;\r
nvocoderframes = 8;\r
end\r
fclose(fc);\r
\r
-printf("framesize: %d data_bits_per_frame: %d code_bits_per_frame: %d\n", ...\r
- framesize, code_param.data_bits_per_frame, code_param.code_bits_per_frame);\r
+%printf("framesize: %d data_bits_per_frame: %d code_bits_per_frame: %d\n", ...\r
+% framesize, code_param.data_bits_per_frame, code_param.code_bits_per_frame);\r
\r
% rx simulation (separate later)\r
\r
mod_codeword = zeros(1, code_param.code_bits_per_frame/2);\r
lmod_codeword = code_param.code_bits_per_frame/2;\r
\r
-for m=1:16\r
+for m=1:8\r
\r
% read in one modem frame at a time\r
\r
mod_codeword(1:lmod_codeword-length(mod_unpackedmodem)) = mod_codeword(length(mod_unpackedmodem)+1:lmod_codeword);\r
mod_codeword(lmod_codeword-length(mod_unpackedmodem)+1:lmod_codeword) = mod_unpackedmodem;\r
\r
- look_for_uw(10*mod_codeword(1:length(mod_uw)), mod_uw)\r
+ uw_sync = look_for_uw(mod_codeword(1:length(mod_uw)), mod_uw);\r
+ if (uw_sync)\r
+ % force UW symbols as they are known (is this needed?)\r
+\r
+ % LDPC decode\r
+\r
+ detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, mod_codeword, EsNo);\r
+\r
+ % unpack payload data, removing UW\r
+\r
+ vd_rx = remove_uw(detected_data(1:code_param.data_bits_per_frame), length(vd), length(uw));\r
+\r
+ % measure BER\r
+\r
+ error_positions = xor(vd, vd_rx);\r
+ Nerrs = sum(error_positions);\r
+ if Nerrs>0, fprintf(1,'x'), else fprintf(1,'.'), end\r
+\r
+ % save packed payload data to disk\r
+ end\r
end\r
\r
+fprintf(1,'\n')\r
fclose(fc);\r
\r