Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
RGerzaguet committed May 6, 2021
1 parent 4f46c8d commit add70f6
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 27 deletions.
19 changes: 16 additions & 3 deletions src/bitDeMapping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
# ----------------------------------------------------
Expand Down Expand Up @@ -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)));
Expand Down
23 changes: 20 additions & 3 deletions src/bitMapping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
# ----------------------------------------------------
Expand Down Expand Up @@ -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));
Expand Down
20 changes: 7 additions & 13 deletions src/genBitSequence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,19 @@ 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
genBitsequence!(buffer,nbBits,randSeed=-1);
# --- 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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -123,7 +117,7 @@ function genByteSequence(nbBytes,randSeed=-1)
# --- Create buffer
buffer = zeros(UInt8,nbBytes);
# --- Call !
genByteSequence!(buffer,nbBytes,randSeed);
genByteSequence!(buffer,randSeed);
end


14 changes: 12 additions & 2 deletions src/hardConstellation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
# ----------------------------------------------------
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions src/symbolDemapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/test_genBitSequence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit add70f6

Please sign in to comment.