Skip to content

Commit 84f580b

Browse files
committed
Add unitaryPower flag for QAM power selection
- To be able to switch the normalization of the output power for the QAM mapping, a flag has been added. Now one can decide between unitary output values and default QAM values (-1,+1,-3,+3, ...)
1 parent 9131347 commit 84f580b

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

src/bitMapping.jl

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
Quadrature Amplitude Modulation (QAM) function
44
Apply symbol mapping to a input binary sequence (of size 1xL) with constellation size M.
55
Output is a vector (1xN) with N = L / log2(M)
6-
Conventional gray mapping is used. Output constellation is casted in float, with unitary average power
6+
Conventional gray mapping is used. Output constellation is casted in float, with unitary average power,
7+
except when `unitaryPower` is set to false.
78
Supported constellation
89
* QPSK
910
* 16-QAM
@@ -12,20 +13,25 @@ Quadrature Amplitude Modulation (QAM) function
1213
# --- Syntax
1314
bitMappingQAM!(qamMat,M,bitSeq)
1415
# --- Input parameters
15-
- qamMat : Complex Vector to populate of size length(bitSeq) / log2(M) [Array{Complex{Float64}}]
16-
- M : Modulation size (i.e from 4 to 256) such as bit per symbol is log2(M) [Int]
17-
- bitSeq : Binary sequence to be transformed into QPSK symbols [Array{UInt8}]
16+
- qamMat : Complex Vector to populate of size length(bitSeq) / log2(M) [Array{Complex{Float64}}]
17+
- M : Modulation size (i.e from 4 to 256) such as bit per symbol is log2(M) [Int]
18+
- bitSeq : Binary sequence to be transformed into QPSK symbols [Array{UInt8}]
19+
- unitaryPower : Normalize output power if set to true (default is true).
1820
# --- Output parameters
1921
- []
2022
"""
21-
function bitMappingQAM!(qamMat,M, bitSeq)
23+
function bitMappingQAM!(qamMat,M, bitSeq; unitaryPower=true)
2224
# ----------------------------------------------------
2325
# --- Overall parameters
2426
# ----------------------------------------------------
2527
# --- Defining scaling factor
26-
# Constellation output should have an unitary average power
28+
# Constellation output might have an unitary average power
2729
# σ^2 = ∑ p(a_i) ⃒ a_i ⃒ ^2 = 1
28-
scalingFactor = sqrt(2/3*(M-1));
30+
if unitaryPower
31+
scalingFactor = sqrt(2/3*(M-1));
32+
else
33+
scalingFactor = 1;
34+
end
2935
nbSymb = length(qamMat);
3036
# ----------------------------------------------------
3137
# --- Switch on modulation order
@@ -185,11 +191,11 @@ qamMat = bitMappingQAM(M,bitSeq)
185191
# --- Output parameters
186192
- qamMat : Complex Vector to populate of size length(bitSeq) / log2(M) [Array{Complex{Float64}}]
187193
"""
188-
function bitMappingQAM(M,bitSeq)
194+
function bitMappingQAM(M,bitSeq; unitaryPower=true)
189195
nbBits = length(bitSeq);
190196
nbSymb = Int( nbBits ÷ log2(M));
191197
buffer = zeros(Complex{Float64},nbSymb);
192-
bitMappingQAM!(buffer,M,bitSeq);
198+
bitMappingQAM!(buffer,M,bitSeq; unitaryPower);
193199
return buffer;
194200
end
195201

@@ -199,27 +205,27 @@ end
199205
# --- Multiple dispatch handling
200206
# ----------------------------------------------------
201207
# --- MD: String case for modulation order
202-
function bitMappingQAM!(qamMat,M::String, bitSeq)
208+
function bitMappingQAM!(qamMat,M::String, bitSeq; unitaryPower=true)
203209
# --- Casting modulation order to int8
204210
if M == "QPSK" || M == "4-QAM" || M == "QAM-4" || M=="4QAM" || M == "QAM4"
205-
bitMappingQAM!(qamMat,4,bitSeq);
211+
bitMappingQAM!(qamMat,4,bitSeq; unitaryPower);
206212
elseif M == "16-QAM" || M == "QAM-16" || M=="16QAM" || M == "QAM16"
207-
bitMappingQAM!(qamMat,16,bitSeq);
213+
bitMappingQAM!(qamMat,16,bitSeq; unitaryPower);
208214
elseif M == "64-QAM" || M == "QAM-64" || M=="64QAM" || M == "QAM64"
209-
bitMappingQAM!(qamMat,64,bitSeq);
215+
bitMappingQAM!(qamMat,64,bitSeq; unitaryPower);
210216
elseif M == "256-QAM" || M == "QAM-256" || M=="256QAM" || M == "QAM256"
211-
bitMappingQAM!(qamMat,256,bitSeq);
217+
bitMappingQAM!(qamMat,256,bitSeq; unitaryPower);
212218
end
213219
end
214-
function bitMappingQAM(M::String, bitSeq)
220+
function bitMappingQAM(M::String, bitSeq; unitaryPower=true)
215221
# --- Casting modulation order to int8
216222
if M == "QPSK" || M == "4-QAM" || M == "QAM-4" || M=="4QAM" || M == "QAM4"
217-
bitMappingQAM(4,bitSeq);
223+
bitMappingQAM(4,bitSeq; unitaryPower);
218224
elseif M == "16-QAM" || M == "QAM-16" || M=="16QAM" || M == "QAM16"
219-
bitMappingQAM(16,bitSeq);
225+
bitMappingQAM(16,bitSeq; unitaryPower);
220226
elseif M == "64-QAM" || M == "QAM-64" || M=="64QAM" || M == "QAM64"
221-
bitMappingQAM(64,bitSeq);
227+
bitMappingQAM(64,bitSeq; unitaryPower);
222228
elseif M == "256-QAM" || M == "QAM-256" || M=="256QAM" || M == "QAM256"
223-
bitMappingQAM(256,bitSeq);
229+
bitMappingQAM(256,bitSeq; unitaryPower);
224230
end
225231
end

0 commit comments

Comments
 (0)