From add70f61770ffe652f73602a5435a3051bea9b9b Mon Sep 17 00:00:00 2001 From: Robin Gerzaguet Date: Thu, 6 May 2021 15:17:59 +0200 Subject: [PATCH] Update documentation --- src/bitDeMapping.jl | 19 ++++++++++++++++--- src/bitMapping.jl | 23 ++++++++++++++++++++--- src/genBitSequence.jl | 20 +++++++------------- src/hardConstellation.jl | 14 ++++++++++++-- src/symbolDemapper.jl | 4 +--- test/test_genBitSequence.jl | 6 +++--- 6 files changed, 59 insertions(+), 27 deletions(-) diff --git a/src/bitDeMapping.jl b/src/bitDeMapping.jl index a87999b..166c4a8 100644 --- a/src/bitDeMapping.jl +++ b/src/bitDeMapping.jl @@ -14,8 +14,6 @@ Output bitsream is Array{Int8} - qamVect : Complex observation vector to decode. # --- Output parameters - [] -# --- -# v 1.0 - Robin Gerzaguet. """ function bitDemappingQAM!(hardBits,M, qamVect) # ---------------------------------------------------- @@ -376,7 +374,22 @@ function bitDemappingQAM!(hardBits,M, qamVect) end - +""" +--- +Quadrature Amplitude Modulation (QAM) hard decoding function +Apply symbol hard demapping to a input symbol sequence (of size 1xN) with constellation size M. +Output is a binary (1xL) with N = L / log2(M) +Conventional gray demapping is used. +Input constellation is Array{Complex{Float64}} +Output bitsream is Array{Int8} +# --- Syntax +hardBits = bitDemappingQAM!(hardBits,M,qamVect) +# --- Input parameters +- M : Constellation size (i.e from 4 to 256) +- qamVect : Complex observation vector to decode. +# --- Output parameters +- hardBits : Vector of bits to populate [Array{UInt8}, length(qamVect)/log2(M)] +""" function bitDemappingQAM(M,qamVect); # --- Create receive bit vector hardBits = zeros(UInt8, Int(length(qamVect)*log2(M))); diff --git a/src/bitMapping.jl b/src/bitMapping.jl index 460100a..3b02d13 100644 --- a/src/bitMapping.jl +++ b/src/bitMapping.jl @@ -17,8 +17,6 @@ Quadrature Amplitude Modulation (QAM) function - bitSeq : Binary sequence to be transformed into QPSK symbols [Array{UInt8}] # --- Output parameters - [] -# --- -# v 1.0 - Robin Gerzaguet. """ function bitMappingQAM!(qamMat,M, bitSeq) # ---------------------------------------------------- @@ -166,8 +164,27 @@ function bitMappingQAM!(qamMat,M, bitSeq) end # ---------------------------------------------------- -# --- No allocation function +# --- Allocating function # ---------------------------------------------------- +""" +--- +Quadrature Amplitude Modulation (QAM) function + Apply symbol mapping to a input binary sequence (of size 1xL) with constellation size M. + Output is a vector (1xN) with N = L / log2(M) + Conventional gray mapping is used. Output constellation is casted in float, with unitary average power + Supported constellation +* QPSK +* 16-QAM +* 64-QAM +* 256-QAM +# --- Syntax +qamMat = bitMappingQAM(M,bitSeq) +# --- Input parameters +- M : Modulation size (i.e from 4 to 256) such as bit per symbol is log2(M) [Int] +- bitSeq : Binary sequence to be transformed into QPSK symbols [Array{UInt8}] +# --- Output parameters +- qamMat : Complex Vector to populate of size length(bitSeq) / log2(M) [Array{Complex{Float64}}] +""" function bitMappingQAM(M,bitSeq) nbBits = length(bitSeq); nbSymb = Int( nbBits รท log2(M)); diff --git a/src/genBitSequence.jl b/src/genBitSequence.jl index 31fc746..08bfcf4 100644 --- a/src/genBitSequence.jl +++ b/src/genBitSequence.jl @@ -12,7 +12,7 @@ using Random """ --- -Create a binary sequence and populate input buffer with nbBits bits +Create a binary sequence and populate input buffer with bits The array is of type UInt8 with x00 or x01) If stated, randSeed controls the seed of the random generator # --- Syntax @@ -20,13 +20,11 @@ If stated, randSeed controls the seed of the random generator # --- Input parameters - buffer : Buffer to populate [Array{UInt8,nbBits}] - nbBits : Number of bits to generate [Int] -- randSeed : Seed of random process (default -> -1) +- randSeed : Seed of random process (default -> -1, no seed is used) # --- Output parameters - buffer : Populated buffer [Array{UInt8}] -# --- -# v 1.0 - Robin Gerzaguet. """ -function genBitSequence!(buffer::Array{UInt8},nbBits,randSeed=-1) +function genBitSequence!(buffer::Array{UInt8},randSeed=-1) # --- Setting the random seed if given if randSeed != -1 # --- Seed as the second parameter @@ -47,14 +45,12 @@ Create a binary sequence and return a buffer with nbBits bits The array is of type UInt8 with x00 or x01) If stated, randSeed controls the seed of the random generator # --- Syntax - genBitsequence!(nbBits,randSeed=-1); + genBitsequence(nbBits,randSeed=-1); # --- Input parameters - nbBits : Number of bits to generate [Int] - randSeed : Seed of random process (default -> -1) [Int] # --- Output parameters - buffer : Populated buffer [Array{UInt8}] -# --- -# v 1.0 - Robin Gerzaguet. """ function genBitSequence(nbBits,randSeed=-1) # --- Setting the random seed if given @@ -65,7 +61,7 @@ function genBitSequence(nbBits,randSeed=-1) # --- Create the input buffer buffer = zeros(UInt8,nbBits); # --- Call the bang method - genBitSequence!(buffer,nbBits,randSeed); + genBitSequence!(buffer,randSeed); # --- Return the buffer return buffer; end @@ -81,14 +77,13 @@ If stated, randSeed controls the seed of the random generator genByteSequence!(buffer,nbBytes,randSeed=-1); # --- Input parameters - buffer : Buffer to populate [Array{UInt8,nbByte}] -- nbBytes : Number of byte to generate [Int] - randSeed : Seed of random process (default -> -1) # --- Output parameters - buffer : Populated buffer [Array{UInt8}] # --- # v 1.0 - Robin Gerzaguet. """ -function genByteSequence!(buffer::Array{UInt8},nbBytes,randSeed=-1) +function genByteSequence!(buffer::Array{UInt8},randSeed=-1) # --- Setting the random seed if given if randSeed != -1 # --- Seed as the second parameter @@ -97,7 +92,6 @@ function genByteSequence!(buffer::Array{UInt8},nbBytes,randSeed=-1) # --- Generating byte sequence Random.rand!(buffer, 0x00:0x01:0xff); # --- Switch to "pure" random system - RandomDevice(); if randSeed != -1 RandomDevice(); end @@ -123,7 +117,7 @@ function genByteSequence(nbBytes,randSeed=-1) # --- Create buffer buffer = zeros(UInt8,nbBytes); # --- Call ! - genByteSequence!(buffer,nbBytes,randSeed); + genByteSequence!(buffer,randSeed); end diff --git a/src/hardConstellation.jl b/src/hardConstellation.jl index 9c29f86..9752f4c 100644 --- a/src/hardConstellation.jl +++ b/src/hardConstellation.jl @@ -10,8 +10,6 @@ Return the hard decoded constellation with voronoi baseds decision. The differen - qamMat : Vector to decode # --- Output parameters - [] -# --- -# v 1.0 - Robin Gerzaguet. """ function hardConstellation!(qamThres,M, qamMat) # ---------------------------------------------------- @@ -132,6 +130,18 @@ function hardConstellation!(qamThres,M, qamMat) return qamThres; end +""" +--- +Quadrature Amplitude Modulation (QAM) hard decoding function +Return the hard decoded constellation with voronoi baseds decision. The difference with bitDeMapping is that bitDeMapping returns the decoded bit sequence whereas hardConstellation returns the closest constellation point. This can be use to compute raw EVM estimation (assuming a sufficiently high SNR to avoid errors). +# --- Syntax +qamDec = hardConstellation!(qamDec,M,qamMat) +# --- Input parameters +- M : Constellation size (i.e 4 to 256) +- qamMat : Vector to decode +# --- Output parameters +- qamDec : Vector to populate [Array{Complex{Float64},N}] with N = length(qamMat) +""" function hardConstellation(M,qamMat) qamThres = zeros(Complex{Float64},length(qamMat)); hardConstellation!(qamThres,M,qamMat); diff --git a/src/symbolDemapper.jl b/src/symbolDemapper.jl index 5505302..6100dfa 100644 --- a/src/symbolDemapper.jl +++ b/src/symbolDemapper.jl @@ -69,15 +69,13 @@ Returns the log likelihood ratio of the incoming sequence qamSeq based on the ch qamSeq is an input noisy QAM sequence with same size of channel estimate vector Output is a vector of soft output binary sequence to be fed in a FEC # --- Syntax - output = :symbolDemappingQAM(mcs,qamSeq,channel) + output = symbolDemappingQAM(mcs,qamSeq,channel) # --- Input parameters - mcs : Constellation size (from 4 to 256) [Int] - qamSeq : Complex noisy received sequence (after equalization) [Array{Float64},N] - channel : Complex channel estimate [Array{Float64},N] # --- Output parameters - output : Soft bits [Array{UInt8},N*log2(mcs)] -# --- -# v 1.0 - Robin Gerzaguet. """ function symbolDemappingQAM(mcs,qamSeq,channel) # --- Creating output array for allocation diff --git a/test/test_genBitSequence.jl b/test/test_genBitSequence.jl index 63c8589..c6a3cb1 100644 --- a/test/test_genBitSequence.jl +++ b/test/test_genBitSequence.jl @@ -20,7 +20,7 @@ println("Tests for binary sequence generation"); @test unique(bitSeq) == [0x00,0x01] || unique(bitSeq) == [0x01,0x00] ; # --- Checking bang method bitSeq2 = zeros(UInt8,N); - genBitSequence!(bitSeq2,N,rSeed); + genBitSequence!(bitSeq2,rSeed); # --- Ensure that output is a UInt8 vector @test typeof(bitSeq2) == Array{UInt8,1}; # --- Checking 0 and 1 populate the buffer @@ -42,11 +42,11 @@ end @test typeof(byteSeq) == Array{UInt8,1}; # --- Checking bang method byteSeq2 = zeros(UInt8,N); - genByteSequence!(byteSeq2,N,rSeed); + genByteSequence!(byteSeq2,rSeed); # --- Ensure that output is a UInt8 vector @test typeof(byteSeq2) == Array{UInt8,1}; # --- Seed should have generated same vector for both call @test (byteSeq == byteSeq2) - # --- Forcing a random seed and check taht vector is different + # --- Forcing a random seed and check that vector is different @test (genByteSequence(N) != byteSeq) end