├── CoreLib ├── AddCpCs.m ├── ApplyChannel.m ├── BlockDemultiplexing.m ├── BlockMultiplexing.m ├── CGFDMModulatorFrequency.m ├── CRC.m ├── ComputeSNR.m ├── CreatePulse.m ├── Decoder.m ├── Encoder.m ├── FDMAdemaping.m ├── FDMAmaping.m ├── Filtering.m ├── GenFadingChannel.m ├── GenRandomNoise.m ├── GeneralDemodulator.m ├── GeneralModulator.m ├── GenerateCode.m ├── GenerateEncodedData.m ├── ModulationMatrixFrequency.m ├── PSD_Estimation.m ├── Psd_th.m ├── PulseToWindow.m ├── ReceiveWindow.m ├── RemoveCpCs.m ├── ResourceDemap.m ├── ResourceMap.m ├── Test │ ├── T_CRC.m │ ├── T_Complexity.m │ ├── T_GFDM_modulator.m │ ├── T_GeneralModemFrequency.m │ ├── T_GeneralModemTime.m │ ├── T_General_Matrix_notation.m │ ├── T_PsdSubcarrier.m │ ├── T_TurboCoding.m │ ├── T_channel.m │ ├── T_computeSNR.m │ ├── T_constellation.m │ ├── T_general_Modulator.m │ ├── ref_GFDM_DeMod.m │ ├── ref_GFDM_Mod.m │ └── test_CRC.m ├── WindowToPulse.m ├── Windowing.m └── ~$cumnets.docx ├── GFDM.pdf ├── GFDM_LabView_Host ├── GFDM_project.lvproject ├── Host │ ├── Configurations_scripts │ │ ├── Filter.m │ │ ├── gen_gfdm.m │ │ └── gen_pre.m │ ├── GFDMParallel │ │ ├── Channel.gvi │ │ ├── GenRadomData.gvi │ │ ├── Noise.gvi │ │ ├── ReadAll.gvi │ │ ├── Rx.gvi │ │ ├── Sync.gvi │ │ ├── Test │ │ │ ├── Test_Frame.gvi │ │ │ ├── Test_Gen_Params.gvi │ │ │ ├── reftest.gvi │ │ │ ├── test_RX.gvi │ │ │ └── test_TX.gvi │ │ ├── Tx.gvi │ │ ├── control.gvi │ │ └── subVIs │ │ │ ├── CE_estimation.gvi │ │ │ ├── CreateQueues.gvi │ │ │ ├── CreateRxRefControl.gvi │ │ │ ├── CreateTxRefControl.gvi │ │ │ ├── DecodeFrame.gvi │ │ │ ├── DemodGFDMblock.gvi │ │ │ ├── Equalizer.gvi │ │ │ ├── FIRConv.gvi │ │ │ ├── GEN_GFDM_Params.gvi │ │ │ ├── GEN_Preamble.gvi │ │ │ ├── ModGFDMblock.gvi │ │ │ ├── PrepareFrame.gvi │ │ │ ├── ReadQueue.gvi │ │ │ ├── ReleaseQueues.gvi │ │ │ ├── ReleaseRxRefControl.gvi │ │ │ └── ReleaseTxRefControl.gvi │ ├── GFDM_core_lib │ │ ├── AddCpCsWindowing.gvi │ │ ├── Bit2byte.gvi │ │ ├── Byte2bit.gvi │ │ ├── CCdecoder.gvi │ │ ├── CCencoder.gvi │ │ ├── ChannelEstimation.gvi │ │ ├── Demodulator.gvi │ │ ├── FrameParams.gvi │ │ ├── GenPreample.gvi │ │ ├── GenWindow.gvi │ │ ├── Modulator.gvi │ │ ├── Overlapping.gvi │ │ ├── QAMdemapper.gvi │ │ ├── QAMmapper.gvi │ │ └── RemoveCpCs.gvi │ ├── Main.gvi │ ├── Measure │ │ └── MSE.gvi │ ├── Types │ │ ├── Frame_in.gtype │ │ ├── Frame_out.gtype │ │ ├── GFDM_params.gtype │ │ ├── Preamble_params.gtype │ │ ├── RX.queue.gtype │ │ ├── RXRefControl.gtype │ │ ├── TX.queue.gtype │ │ ├── TXRefControl.gtype │ │ ├── Type.gtype │ │ └── Variable_ alpha.gtype │ └── Utilities │ │ ├── Check Stop.gvi │ │ ├── Create Stop.gvi │ │ ├── GetType.gvi │ │ └── Stop On Error.gvi └── Test_individual │ ├── TestConvolutionalCode.gvi │ ├── test_Byte2bit_bit2Byte.gvi │ ├── test_ChannelEstimation.gvi │ ├── test_CpCsWindowing_removeCPCS.gvi │ ├── test_FrameParams.gvi │ ├── test_Genpreamble.gvi │ ├── test_Modulator_Demodulator.gvi │ ├── test_QAMmapper_demapper.gvi │ └── test_overlpapping.gvi ├── LICENSE ├── OTFSvsGFDM ├── CC │ ├── Doppler_1404_GFDM-short-CC-1-2.mat │ ├── Doppler_1404_OFDM-short-CC-1-2.mat │ ├── Doppler_1404_OTFS-short-CC-1-2.mat │ ├── _1304_GFDM-long-CC-1-2.mat │ ├── _1304_GFDM-short-CC-1-2.mat │ ├── _1304_GFDM-shortT2-CC-1-2.mat │ ├── _1304_OFDM-long-CC-1-2.mat │ ├── _1304_OFDM-short-CC-1-2.mat │ ├── _1304_OTFS-long-CC-1-2.mat │ └── _1304_OTFS-short-CC-1-2.mat ├── Doppler_Evaluation.m ├── Doppler_FER.eps ├── GFDM_LTV.m ├── GFDM_LTV_Doppler.m ├── Generate_common_Doppler.m ├── Generate_common_fD.m ├── LTV_Evaluation.m ├── MMSE_Plot_BER_FER.m ├── MMSE_Plot_Doppler.m ├── MMSE_Plot_Symbol_SNR.m ├── OTFS_LTV.m ├── OTFS_LTV_Doppler.m ├── TC │ ├── Doppler_1504_GFDM-short-TC-1-2.mat │ ├── Doppler_1504_OFDM-short-TC-1-2.mat │ ├── Doppler_1504_OTFS-short-TC-1-2.mat │ ├── LTV_1404_GFDM-long-TC-1-2.mat │ ├── LTV_1404_GFDM-short-TC-1-2.mat │ ├── LTV_1404_OFDM-long-TC-1-2.mat │ ├── LTV_1404_OFDM-short-TC-1-2.mat │ ├── LTV_1404_OTFS-long-TC-1-2.mat │ └── LTV_1404_OTFS-short-TC-1-2.mat └── perSymSNR.eps ├── README.md ├── Setup.m ├── VIsualization ├── CompareMeasure.m ├── ComparePSD.m └── CreateMeasurments.m └── cml ├── CmlStartup.m ├── data ├── bandwidth │ ├── BW99percent.mat │ ├── cal_bandwidth.m │ └── specfun.m └── tables │ └── Jtable.mat ├── demos └── HsdpaDemo.m ├── documentation ├── CMLoverview.pdf ├── license.txt ├── readme.pdf ├── ~$readme.doc └── ~WRL1980.tmp ├── mat ├── BitCollection.m ├── BitDecollection.m ├── BtcDecode.m ├── BtcEncode.m ├── CalculateMinSNR.m ├── CalculateMinSNRvsB.m ├── CalculateThroughput.m ├── CmlChannel.m ├── CmlDecode.m ├── CmlEncode.m ├── CmlPlot.m ├── CmlSimulate.m ├── CmlTouch.m ├── CreateConstellation.m ├── CreateDvbInterleaver.m ├── CreateDvbPuncturingPattern.m ├── CreateLTEInterleaver.m ├── CreateWimaxInterleaver.m ├── CreateWimaxPuncturingPattern.m ├── DefineStructures.m ├── HarqDematch.m ├── HarqMatch.m ├── InitializeCodeParam.m ├── InitializeWiMaxLDPC.m ├── PnGenerator.m ├── ReadScenario.m ├── SimulateCapacity.m ├── SimulateMod.m ├── SimulateOutage.m ├── SimulateUGI.m ├── SingleRead.m ├── SingleSimulate.m ├── TurboDecode.m ├── TurboDuobinaryCRSCDecode.m ├── TurboDuobinaryCRSCEncode.m ├── TurboEncode.m └── UmtsPunPattern.m ├── matalt ├── CapacityTableLookup.m ├── RateDematch.m └── RateMatch.m ├── mex ├── Capacity.dll ├── Capacity.mexw64 ├── CapacityTableLookup.dll ├── CapacityTableLookup.mexw64 ├── ConvEncode.dll ├── ConvEncode.mexw64 ├── CreateCcsdsInterleaver.dll ├── CreateCcsdsInterleaver.mexw64 ├── CreateSRandomInterleaver.dll ├── CreateSRandomInterleaver.mexw64 ├── CreateUmtsInterleaver.dll ├── CreateUmtsInterleaver.mexw64 ├── Deinterleave.dll ├── Deinterleave.mexw64 ├── Demod2D.dll ├── Demod2D.mexw64 ├── DemodFSK.dll ├── DemodFSK.mexw64 ├── Depuncture.dll ├── Depuncture.mexw64 ├── DuobinaryCRSCDecode.dll ├── DuobinaryCRSCEncode.dll ├── InitializeDVBS2.dll ├── InitializeDVBS2.mexw64 ├── Interleave.dll ├── Interleave.mexw64 ├── LdpcEncode.dll ├── LdpcEncode.mexw64 ├── Modulate.dll ├── Modulate.mexw64 ├── MpDecode.dll ├── MpDecode.mexw64 ├── Puncture.dll ├── Puncture.mexw64 ├── RateDematch.dll ├── RateDematch.mexw64 ├── RateMatch.dll ├── RateMatch.mexw64 ├── SisoDecode.dll ├── SisoDecode.mexw64 ├── Somap.dll ├── Somap.mexw64 ├── ViterbiDecode.dll └── ViterbiDecode.mexw64 ├── mexhelp ├── Capacity.m ├── ConvEncode.m ├── CreateCcsdsInterleaver.m ├── CreateSRandomInterleaver.m ├── CreateUmtsInterleaver.m ├── Deinterleave.m ├── Demod2D.m ├── DemodFSK.m ├── Depuncture.m ├── InitializeDVBS2.m ├── Interleave.m ├── LdpcEncode.m ├── Modulate.m ├── MpDecode.m ├── Puncture.m ├── SisoDecode.m ├── Somap.m └── ViterbiDecode.m ├── scenarios ├── BlockcodeScenarios.m ├── BtcScenarios.m ├── CapacityScenarios.m ├── CcsdsScenarios.m ├── Cdma2000Scenarios.m ├── CmlHome.mat ├── ConvolutionalScenarios.m ├── DVBRCSScenarios.m ├── DVBS2Scenarios.m ├── FskCapacity.m ├── FskScenarios.m ├── HsdpaScenarios.m ├── LTEScenarios.m ├── OutageScenarios.m ├── TailbitingScenarios.m ├── ThroughputScenarios.m ├── UmtsScenarios.m ├── UncodedScenarios.m ├── WiMaxCTCScenarios.m ├── WiMaxLDPCScenarios.m ├── hFskAWGNBICMCapacity.m ├── hFskAWGNCapacity.m ├── hFskFadingCapacity.m └── hFskScenarios.m └── source ├── Capacity.c ├── CapacityTableLookup.c ├── ConvEncode.c ├── CreateCcsdsInterleaver.c ├── CreateSRandomInterleaver.c ├── CreateUmtsInterleaver.c ├── Deinterleave.c ├── Demod2D.c ├── DemodFSK.c ├── Depuncture.c ├── DuobinaryCRSCDecode.c ├── DuobinaryCRSCEncode.c ├── InitializeDVBS2.c ├── Interleave.c ├── LdpcEncode.c ├── Modulate.c ├── MpDecode.c ├── Puncture.c ├── RateDematch.c ├── RateMatch.c ├── SisoDecode.c ├── Somap.c ├── ViterbiDecode.c ├── include ├── DVBS2lookup.h ├── convolutional.h ├── interleaver.h ├── maxstar.h ├── siso.h └── srandom.h └── make.m /CoreLib/AddCpCs.m: -------------------------------------------------------------------------------- 1 | %% CP/CS insertion 2 | % $$ X = X_0(_N,:),~ n = 0,\cdots, N+N_{cp}+N_{cs}-1 $$ 3 | function X = AddCpCs( X0, N, Ncp, Ncs) 4 | No = Ncp+ Ncs; 5 | Nt = N+No; 6 | nt = 0:Nt-1; 7 | X = X0(mod(nt-Ncp, N)+1,:); 8 | end 9 | 10 | -------------------------------------------------------------------------------- /CoreLib/ApplyChannel.m: -------------------------------------------------------------------------------- 1 | % Apply channel on signal arranged in Ns x NB samples 2 | % Ncp is CP length 3 | function [ He, Y ] = ApplyChannel( rchan, X, Ncp) 4 | release(rchan); 5 | rchan.Seed = rchan.Seed+1; 6 | [Ns, NB] = size(X); 7 | D = zeros(Ns,NB); 8 | %% Estimate the channel appling a pulse 9 | D(Ncp+1,:) = 1; 10 | He = zeros(size(D)); 11 | for nb=1:NB 12 | He(:,nb) = step(rchan, D(:,nb)); 13 | end 14 | %% reset the channel to first state which correspond to the estimation 15 | reset(rchan); 16 | y = step(rchan, X(:)); 17 | Y = reshape(y,Ns, NB); 18 | end 19 | 20 | -------------------------------------------------------------------------------- /CoreLib/BlockDemultiplexing.m: -------------------------------------------------------------------------------- 1 | %% Block demultiplexing 2 | % extract blocks of length Nt 3 | % it is used to separate blocks before processing 4 | % Ns block spacing 5 | function Yr = BlockDemultiplexing(y, Ns, No) 6 | Nt = No+Ns; 7 | Ny = length(y); 8 | Nb = ceil((Ny-No)/Ns); 9 | Yr = zeros(Nt, Nb); 10 | for nb=0:Nb-1 11 | Yr(:,nb+1) = y((1:Nt)+nb*Ns); 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /CoreLib/BlockMultiplexing.m: -------------------------------------------------------------------------------- 1 | %% Block multiplexing 2 | % The block in X are transmitted with overlap and add of No samples 3 | % No > 0, ovelapping 4 | % No < 0, Zero padding 5 | function [xt, Ns] = BlockMultiplexing(X, No) 6 | [Nt, Nb] = size(X); 7 | Ns = Nt-No; 8 | N_sig = Ns*(Nb-1)+ Nt; 9 | %x = X(:); 10 | xt = zeros(N_sig,1); 11 | xt(1:Nt) = X(:,1); 12 | for nb=1:Nb-1 13 | xt((1:Nt)+nb*Ns) = xt((1:Nt)+nb*Ns)+X(:,nb+1); 14 | end 15 | end -------------------------------------------------------------------------------- /CoreLib/CGFDMModulatorFrequency.m: -------------------------------------------------------------------------------- 1 | %%conventional Modulator in frequency 2 | function Xf = CGFDMModulatorFrequency(D, K_set, gp, gn, shift) 3 | if nargin < 5 4 | shift = 1; 5 | end 6 | if shift == 1 7 | ln = 0; 8 | lp = 1; 9 | else 10 | ln=1; 11 | lp = 0; 12 | end 13 | [K,M] = size(D); 14 | K_on = length(K_set); 15 | M1 = length(gn); 16 | M2 = length(gp); 17 | gn = reshape(gn,1, M1); 18 | gp = reshape(gp,1, M2); 19 | if M>1 20 | DMf = transpose(fft(transpose(D(K_set,:)))); 21 | else 22 | DMf = D(K_set,:); 23 | end 24 | K_set = K_set-1; % restor indexing from 0 25 | 26 | Xf = zeros(K,M); 27 | if M1>0 28 | m1 = mod(-M1:-1,M)+1; 29 | Xf(mod(K_set-ln,K)+1,m1) = repmat(gn,K_on,1).*DMf(:,m1); 30 | end 31 | if M2>0 32 | m2 = 1:M2; 33 | Xf(mod(K_set+lp,K)+1, m2) = Xf(mod(K_set+lp,K)+1, m2) + repmat(gp,K_on,1).*DMf(:,m2); 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /CoreLib/CRC.m: -------------------------------------------------------------------------------- 1 | function [ r, y ] = CRC( x, g ) 2 | % x: input bits index zero is MSB 3 | % g: polynomial index zero is MSB 4 | % r: reminder index zero is MSB 5 | % y: div index zero is MSB 6 | K = length(x); 7 | Q = length(g); 8 | 9 | r = zeros(1,Q); 10 | y = zeros(1,K); % div result is already in MSB first 11 | % reverse g for indexing 12 | g = flip(g); 13 | for m=1:K 14 | y(m) = xor(r(Q),x(m)); 15 | for q=Q:-1:2 16 | r(q) = xor(r(q-1), and(g(q), y(m))); 17 | end 18 | r(1) = and(g(1),y(m)); 19 | end 20 | % to store in MSB 21 | r = flip(r); 22 | end 23 | 24 | -------------------------------------------------------------------------------- /CoreLib/ComputeSNR.m: -------------------------------------------------------------------------------- 1 | % Low complex computation of the SNR vector after demodulator 2 | % Considering demodulator in Frequency domain 3 | % Vg = ifft(Wfr) 4 | % hf estimated channel 5 | % hf_eq: equalization channel: is generated using ReceiveWindow i.e. MMSE, ZF, MF 6 | % EsN0: Es/N0 7 | % isOFDM = true is used with OFDM to reduce complexity 8 | %% Important: the rsults are vaild for orthogonal Window only... 9 | function v_snr = ComputeSNR( Vg, hf, hf_eq, EsN0 ,isOFDM ) 10 | [K,M] = size(Vg); 11 | N = K*M; 12 | Heq = transpose(reshape(hf_eq, M, K)); 13 | Hi = transpose(reshape(hf_eq.*hf-1, M, K)); 14 | if isOFDM 15 | Pn = abs(Vg(1)*Heq).^2; 16 | Pi = abs(Vg(1)*Hi).^2; 17 | else 18 | Pn = Power(Heq, Vg); 19 | Pi = Power(Hi, Vg); 20 | end 21 | v_snr =1./ repmat(N*Pi+ Pn*N/EsN0, M,1); 22 | end 23 | 24 | function P = Power(H, Vg) 25 | %Vg = ifft(Wfr); 26 | % Z = 1/M*FK(W.*(1/K*FK' *(H.*V)))FM' 27 | % Zm = [FK*diag(w(:,m)FK'/K vm.*hm] 28 | % U = ZFM'/M; 29 | [K,M] = size(Vg); 30 | P = zeros(K,1); 31 | for k = 0:K-1 32 | P(k+1) = norm(H.*shiftMat(Vg, k), 'fro')^2; 33 | end 34 | P = P/M^2; 35 | end 36 | function Vgs = shiftMat(Vg, k) 37 | K = size(Vg,1); 38 | k_in = mod((0:K-1)-k, K)+1; 39 | Vgs = Vg(k_in,:); 40 | end -------------------------------------------------------------------------------- /CoreLib/Decoder.m: -------------------------------------------------------------------------------- 1 | %% Channel Decoder 2 | % it uses soft input i.e. LLRs of the symbols 3 | % ChCode: a structure contains information about CMS generated by 4 | % 'GenerateCode.m' 5 | % data a vector of demodulated data, Esno is the Es/No ratio of each symbol 6 | function [ bits_e, encoded_bits_e ] = Decoder( ChCode, data_e, Esno, h) 7 | 8 | constellation = ChCode.Constellation; 9 | Nb = ChCode.Nb; 10 | Ncbpsym = ChCode.Ncbpsym; 11 | % Symbol to bits LLR mapping 12 | if nargin < 4 13 | LLRs_symb = Demod2D(data_e.',constellation, Esno.'); 14 | else 15 | LLRs_symb = Demod2D(data_e.',constellation, Esno.', h.'); 16 | end 17 | %LLRs_symb = LLRs_symb -repmat(max(LLRs_symb,[],1),2^bps,1); 18 | % convert symbols LLRs to bits LLRs 19 | 20 | llrs_dem = Somap(LLRs_symb, ChCode.demod_type); 21 | encoded_bits_e = llrs_dem' > 0; 22 | llrs_dem = reshape(llrs_dem,Ncbpsym,Nb); 23 | % Deinterleaving 24 | llrs_dem(ChCode.interleaver1,:) = llrs_dem; 25 | llrs_un_dec = zeros(1,length(ChCode.punc_flg)); 26 | llrs_un_dec(ChCode.punc_flg == 1) = llrs_dem; 27 | cnst = size(ChCode.g,2)-1; 28 | 29 | llrs_un_dec = llrs_un_dec(1:(ChCode.Nr_infobits+cnst)*2); 30 | if ChCode.Alg == 0 %CC encoder 31 | bits_e = ViterbiDecode(llrs_un_dec, ChCode.g, ChCode.nsc_flag); 32 | elseif ChCode.Alg == 1 % turbo encoder 33 | g1 = ChCode.Turbo_g; %13 15 34 | g2 = g1; %13 15 35 | nsc_flag1 = ChCode.Turbo_nsc_flag ; 36 | nsc_flag2 = nsc_flag1; 37 | pun_pattern = ChCode.Turbo_pun_pattern; % rate 1/2; 38 | tail_pattern = ChCode.Turbo_tail_pattern; 39 | interleaver = ChCode.Turbo_interleaver; 40 | bits_e = TurboDecode( llrs_un_dec, ChCode.info_bits.', ChCode.number_itr, ChCode.decoder_type, interleaver, pun_pattern, tail_pattern, g1, nsc_flag1, g2, nsc_flag2 ); 41 | end 42 | bits_e = bits_e.'; 43 | end 44 | 45 | -------------------------------------------------------------------------------- /CoreLib/Encoder.m: -------------------------------------------------------------------------------- 1 | %% Channel Decoder 2 | % ChCode: a structure contains information about CMS generated by 3 | % 'GenerateCode.m' and frame length, etc. 4 | % info bits 5 | function [ qam_data, encoded_bits] = Encoder( ChCode, info_bits) 6 | % CC Encoding 7 | % info_bits: column vector 8 | bps = ChCode.bps; 9 | Nb = ChCode.Nb; 10 | Non = ChCode.Non; 11 | Ncbpsym = ChCode.Ncbpsym; 12 | constellation = ChCode.Constellation; 13 | 14 | % zero padding 15 | pad_bits = randi([0 1],ChCode.Nr_padbits,1); % the type of pad_bits does not matter here 16 | if ChCode.Alg == 0 %CC encoder 17 | codeword_o = ConvEncode(info_bits',ChCode.g,ChCode.nsc_flag); 18 | elseif ChCode.Alg == 1 % turbo encoder 19 | g1 = ChCode.Turbo_g; %13 15 20 | g2 = g1; 21 | nsc_flag1 = ChCode.Turbo_nsc_flag ; 22 | nsc_flag2 = nsc_flag1; 23 | pun_pattern = ChCode.Turbo_pun_pattern; % rate 1/2; 24 | tail_pattern = ChCode.Turbo_tail_pattern; 25 | interleaver = ChCode.Turbo_interleaver; 26 | codeword_o = TurboEncode( info_bits', interleaver, pun_pattern, tail_pattern, g1, nsc_flag1, g2, nsc_flag2 ); 27 | end 28 | codeword_pad = ConvEncode(pad_bits',ChCode.g,ChCode.nsc_flag); % padding bit are just encoded with covolutional code 29 | % Puncture 30 | encoded_bits = [codeword_o'; codeword_pad']; 31 | encoded_bits = encoded_bits(ChCode.punc_flg == 1); 32 | 33 | % Interleaving 34 | encoded_mtx = reshape(encoded_bits,Ncbpsym,Nb); 35 | encoded_mtx = encoded_mtx(ChCode.interleaver1,:); 36 | encoded_bits = encoded_mtx(:); 37 | % QAM Modulating 38 | data_symb_idx = bi2de(reshape(encoded_bits,bps,length(encoded_bits)/bps)','left-msb') + 1; 39 | data_symb_idx = reshape(data_symb_idx,Non, Nb); 40 | qam_data = constellation(data_symb_idx); 41 | end -------------------------------------------------------------------------------- /CoreLib/FDMAdemaping.m: -------------------------------------------------------------------------------- 1 | function Xf = FDMAdemaping( Xf_o, ind, Nu, n0) 2 | % Map to frequency bins 3 | % ind: the index of the non-zero samples of Xf_in 4 | % n0 the shift 5 | [N, Nb] = size(Xf_o); 6 | Xf = zeros(Nu, Nb); 7 | Xf(ind+1,:) = Xf_o(mod(ind+n0,N)+1,:); 8 | end 9 | 10 | -------------------------------------------------------------------------------- /CoreLib/FDMAmaping.m: -------------------------------------------------------------------------------- 1 | function Xf = FDMAmaping( Xf_in, ind, N, n0) 2 | % Map to frequency bins 3 | % ind: the index of the non-zero samples of Xf_in 4 | % n0 the shift 5 | Xf = zeros(N, size(Xf_in, 2)); 6 | Xf(mod(ind+n0,N)+1,:) = Xf_in(ind+1,:); 7 | end 8 | 9 | -------------------------------------------------------------------------------- /CoreLib/Filtering.m: -------------------------------------------------------------------------------- 1 | %% Filter on Block 2 | % filter the wole block (filtering might include CP) 3 | function Xh = Filtering(X, h) 4 | [Nt, Nb] = size(X); 5 | Nh = length(h)+Nt-1; 6 | Xh = zeros(Nh,Nb); 7 | for nb=1:Nb 8 | Xh(:,nb) = conv(h,X(:,nb)); 9 | end 10 | end -------------------------------------------------------------------------------- /CoreLib/GenFadingChannel.m: -------------------------------------------------------------------------------- 1 | %% Generate Fading channels 2 | % ChType = EPA, EVA, TGn, FLAT 3 | function rchan = GenFadingChannel( ChType, fD, fs) 4 | %GENFADINGCHANNEL Summary of this function goes here 5 | % Detailed explanation goes here 6 | EPAT = [0, 30, 70, 90, 110, 190, 410]*1E-9; 7 | EVAT = [0, 30, 150, 310, 370, 710, 1090, 1730, 2510]*1E-9; 8 | 9 | EPAP = [0, -1, -2, -3, -8, -17.2, -20.8]; 10 | EVAP = [0, -1.5, -1.4, -3.6, -0.6, -9.1, -7.0, -12.0 -16.9]; 11 | 12 | tau = [0 10 20 30 40 50 60 70 80]*1e-9; % Path delays, in seconds 13 | 14 | % Average path gains of cluster 1, in dB 15 | pdb1 = [0 -5.4 -10.8 -16.2 -21.7 -inf -inf -inf -inf]; 16 | % Average path gains of cluster 2, in dB 17 | pdb2 = [-inf -inf -3.2 -6.3 -9.4 -12.5 -15.6 -18.7 -21.8]; 18 | % Total average path gains for both clusters, in dB 19 | pdb = 10*log10(10.^(pdb1/10) + 10.^(pdb2/10)); 20 | 21 | switch ChType 22 | case 'EPA' 23 | pathDelays = EPAT; 24 | avgPathGains = EPAP; 25 | case 'EVA' 26 | pathDelays = EVAT; 27 | avgPathGains = EVAP; 28 | case 'TGn' 29 | pathDelays = tau; 30 | avgPathGains = pdb; 31 | otherwise 32 | pathDelays = 0; 33 | avgPathGains = 1; 34 | end 35 | rchan = comm.RayleighChannel('SampleRate',fs, ... 36 | 'PathDelays',pathDelays, ... 37 | 'AveragePathGains',avgPathGains, ... 38 | 'MaximumDopplerShift',fD,... 39 | 'RandomStream','mt19937ar with seed', ... 40 | 'Seed',22); 41 | end -------------------------------------------------------------------------------- /CoreLib/GenRandomNoise.m: -------------------------------------------------------------------------------- 1 | %% Generate Gaussian noise 2 | % N0: white noise variance 3 | function v = GenRandomNoise(siz, N0) 4 | v = sqrt(N0/2) * (randn(siz)+1j*randn(siz)); 5 | end 6 | -------------------------------------------------------------------------------- /CoreLib/GeneralDemodulator.m: -------------------------------------------------------------------------------- 1 | %type = 'TD', 'FD' 2 | % w receiver window in time or frequency domain 3 | % K_Set active subcarriers 4 | % D: data matrix K x M, zeros are for non allocated data 5 | function D = GeneralDemodulator( X, K_set, W, type ) 6 | if strcmp(type,'TD') 7 | [M, K] = size(X); 8 | if M>1 9 | X = transpose(fft(X)); 10 | else 11 | X = transpose(X); 12 | end 13 | else 14 | [K, M] = size(X); 15 | if K>1 16 | X = ifft(X); 17 | end 18 | end 19 | % windowing 20 | D = X.*W; 21 | % dePrecoding 22 | if K>1 23 | D = fft(D); 24 | end 25 | if M>1 26 | D(K_set,:) = transpose(ifft(transpose(D(K_set,:)))); % M x K 27 | end 28 | end 29 | 30 | -------------------------------------------------------------------------------- /CoreLib/GeneralModulator.m: -------------------------------------------------------------------------------- 1 | % General modulator 2 | %type = 'TD', 'FD' 3 | % w transmitter window in time or frequency domain 4 | % K_Set active subcarriers 5 | % D: data matrix K x M, zeros are for non allocated data 6 | function X = GeneralModulator( D, K_set, W, type ) 7 | % Precoding 8 | [K,M] = size(D); 9 | % Precoding 10 | Dp = zeros(K,M); 11 | if M>1 12 | Dp(K_set,:) = transpose(fft(transpose(D(K_set,:)))); % M x K 13 | else 14 | Dp(K_set,:) = D(K_set,:); % M x K 15 | end 16 | 17 | if K>1 18 | Dp = ifft(Dp); 19 | end 20 | % windowing 21 | X = Dp.*W; 22 | % domain specific 23 | if strcmp(type,'TD') 24 | if M>1 25 | X = ifft(X.'); 26 | else 27 | X = X.'; 28 | end 29 | else 30 | if K>1 31 | X = fft(X); 32 | end 33 | end 34 | end 35 | 36 | -------------------------------------------------------------------------------- /CoreLib/GenerateCode.m: -------------------------------------------------------------------------------- 1 | %% Generate chanel coding structure 2 | % Mc: QAM Modulation length 3 | % active data 4 | % payload size in Bytes 5 | % Code type = 'CC-1-2', 'CC-2-3', 'CC-3-4', 'CC-5-6' : Convolution 6 | % Code type = 'TC-1-2', 'TC-2-3', 'TC-3-4', 'TC-5-6' : Turbo 7 | % all parameters related are geneaten internally 8 | % random interleavers are used 9 | % punctures are used 10 | % sdeed is used to for random interleaver 11 | function ChCode = GenerateCode( CodeType,Payload_size,Non,Mc, seed ) 12 | if nargin < 5 13 | seed = 199; 14 | end 15 | % Nf : number of frames 16 | bps = log2(Mc); 17 | if Mc == 4 18 | ChCode.Constellation = CreateConstellation( 'QAM', Mc); 19 | else 20 | ChCode.Constellation = CreateConstellation( 'QAM', Mc,'gray'); 21 | end 22 | ChCode.Constellation = reshape(ChCode.Constellation,numel(ChCode.Constellation),1); 23 | ChCode.Non = Non; 24 | ChCode.bps = bps; 25 | ChCode.g = [1 0 1 1 0 1 1; 1 1 1 1 0 0 1]; %133 171 26 | ChCode.nsc_flag = 1; 27 | ChCode.Nr_infobits = Payload_size*8 ; 28 | 29 | % Turbo LTE 30 | ChCode.Turbo_g = [1,0,1,1; 1,1,0,1]; %13 15 31 | ChCode.Turbo_nsc_flag = 0; 32 | ChCode.Turbo_pun_pattern = [1; 1; 0; 0]; % rate 1/2; 33 | ChCode.Turbo_tail_pattern = ones(4,3); 34 | ChCode.Turbo_interleaver = CreateLTEInterleaver(ChCode.Nr_infobits); 35 | 36 | %hSCR = comm.Scrambler(2, [1 0 0 0 1 0 0 1],[1 0 1 1 1 0 1]); 37 | %hDSCR = comm.Descrambler(2, [1 0 0 0 1 0 0 1],[1 0 1 1 1 0 1]); 38 | %scr_seq = step(hSCR, zeros(Nr_infobits,1)); 39 | %scr_seq = scr_seq'; 40 | ChCode.CodeType = CodeType; 41 | rate = CodeType(end-3+1:end); 42 | alg = ChCode.CodeType(1:2); 43 | switch alg 44 | case 'CC' 45 | ChCode.Alg = 0; % convolutional 46 | case 'TC' 47 | ChCode.Alg = 1; % turbo 48 | otherwise 49 | warning('Unexpected Coding type.') 50 | end 51 | switch rate 52 | case '1-2' 53 | Nbit_per_block = Non*bps/2; 54 | case '2-3' 55 | Nbit_per_block = Non*bps/3*2; 56 | case '3-4' 57 | Nbit_per_block = Non*bps/4*3; 58 | case '5-6' 59 | Nbit_per_block = Non*bps/6*5; 60 | otherwise 61 | warning('Unexpected Coding Rate.') 62 | end 63 | % 6: is the constraint number. I.e. number of shift registers. 64 | cnst = size(ChCode.g,2)-1; 65 | Nb = ceil((ChCode.Nr_infobits+cnst)/Nbit_per_block); 66 | ChCode.Nb = Nb; 67 | % to fix numeric precesion error 68 | ChCode.Nr_padbits = Nb*Nbit_per_block - ChCode.Nr_infobits; 69 | Nr_unpuncbits = (ChCode.Nr_infobits + ChCode.Nr_padbits)*2; 70 | switch rate 71 | case '1-2' 72 | ChCode.punc_flg = ones(1,Nr_unpuncbits); 73 | case '2-3' 74 | ChCode.punc_flg = ones(1,Nr_unpuncbits); 75 | ChCode.punc_flg(4:4:end) = 0; 76 | case '3-4' 77 | ChCode.punc_flg = ones(1,Nr_unpuncbits); 78 | ChCode.punc_flg(3:6:end) = 0; 79 | ChCode.punc_flg(5:6:end) = 0; 80 | case '5-6' 81 | ChCode.punc_flg = ones(1,Nr_unpuncbits); 82 | ChCode.punc_flg(4:10:end) = 0; 83 | ChCode.punc_flg(5:10:end) = 0; 84 | ChCode.punc_flg(8:10:end) = 0; 85 | ChCode.punc_flg(9:10:end) = 0; 86 | otherwise 87 | warning('Unexpected Coding Scheme.') 88 | end 89 | Ncbpsym = Non*bps; 90 | ChCode.Ncbpsym = Ncbpsym; 91 | rng(seed); % to keep the interleaver 92 | ChCode.interleaver1 = randperm(Ncbpsym); 93 | ChCode.interleaver2 = randperm(Ncbpsym); 94 | ChCode.decoder_type = 2; 95 | ChCode.demod_type = 2; 96 | ChCode.info_bits = zeros(ChCode.Nr_infobits,1); 97 | ChCode.number_itr = 20; 98 | % the decoder type 99 | % = 0 For linear-log-MAP algorithm, i.e. correction function is a straght line. 100 | % = 1 For max-log-MAP algorithm (i.e. max*(x,y) = max(x,y) ), i.e. correction function = 0. 101 | % = 2 For Constant-log-MAP algorithm, i.e. correction function is a constant. 102 | % = 3 For log-MAP, correction factor from small nonuniform table and interpolation. 103 | % = 4 For log-MAP, correction factor uses C function calls. 104 | end 105 | 106 | -------------------------------------------------------------------------------- /CoreLib/GenerateEncodedData.m: -------------------------------------------------------------------------------- 1 | %% Generate random data 2 | % random info bits and there encoding 3 | function [ qam_data, info_bits, encoded_bits] = GenerateEncodedData( ChCode) 4 | % CC Encoding 5 | info_bits = randi([0 1],ChCode.Nr_infobits,1); % here we skip scrambling, coz we have randomly generated the source bit sequence. 6 | [ qam_data, encoded_bits] = Encoder( ChCode, info_bits); 7 | end -------------------------------------------------------------------------------- /CoreLib/ModulationMatrixFrequency.m: -------------------------------------------------------------------------------- 1 | % Get the modulation matrix of GFDM in the freuency domain 2 | function Af = ModulationMatrixFrequency( gf, K, M, K_set, M_set) 3 | Non = numel(K_set)*numel(M_set); 4 | N = M*K; 5 | Af = zeros(N,Non); 6 | ind_n = (0:N-1)'; 7 | n = 1; 8 | for m = M_set-1 9 | for k = K_set-1 10 | Af(:, n)= gf(mod(ind_n-k*M,N)+1).*exp(-1j*2*pi*m*ind_n/M); 11 | n = n+1; 12 | end 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /CoreLib/PSD_Estimation.m: -------------------------------------------------------------------------------- 1 | %% PSD estimatin 2 | % of signal x with window Nw 3 | function [Sx, f] = PSD_Estimation( x, Nw) 4 | %PSD_ESTIMATION Summary of this function goes here 5 | % Detailed explanation goes here 6 | f = (0:Nw-1)'./Nw; 7 | NT = floor(length(x)/Nw); 8 | X = zeros(Nw,NT); 9 | X(1:length(x)) = x; 10 | Xf = abs(fft(X)).^2; 11 | Sx = mean(Xf,2)/Nw; 12 | end 13 | 14 | -------------------------------------------------------------------------------- /CoreLib/Psd_th.m: -------------------------------------------------------------------------------- 1 | %% PSD 2 | % theoritical PSD of filter matrix G 3 | function S = Psd_th( G, R) 4 | % R is the resolution 5 | N = size(G,1); 6 | S = real(sum(abs(fft(G, N*R)).^2,2)/N); 7 | end 8 | 9 | -------------------------------------------------------------------------------- /CoreLib/PulseToWindow.m: -------------------------------------------------------------------------------- 1 | % Wt: KxM output window 2 | % type = {'TD', 'FD'} 3 | % gr = a pulse. This pulse in time domain or frequency domain 4 | % depending on the selected type 5 | function Wt = PulseToWindow( g, K, M, type) 6 | if strcmp(type,'TD') 7 | 8 | if M>1 9 | Wt = K*fft(transpose(reshape(g, K,M))); 10 | else 11 | Wt = K*transpose(reshape(g, K,M)); 12 | end 13 | Wt = Wt.'; 14 | else % FD 15 | if K>1 16 | Wt = K*ifft(transpose(reshape(g, M,K))); 17 | else 18 | Wt = transpose(reshape(g, M,K)); 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /CoreLib/ReceiveWindow.m: -------------------------------------------------------------------------------- 1 | %Generate receiver window according to the type of receiver 2 | function Wr = ReceiveWindow( Wt, rxType, SNR) 3 | if nargin < 3 4 | SNR = 1E5; 5 | end 6 | if strcmp(rxType, 'ZF') 7 | Wr =1./Wt; 8 | elseif strcmp(rxType, 'MMSE') 9 | Wr = conj(Wt)./(abs(Wt).^2 + 1./SNR); 10 | elseif strcmp(rxType, 'MF') 11 | % not that MF in frequncy must have total norm of N 12 | Wr = conj(Wt); 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /CoreLib/RemoveCpCs.m: -------------------------------------------------------------------------------- 1 | %% Remove CP/CS 2 | % Extract blocks of length N, it start counting from n0, which can be the 3 | % CP length itself. 4 | function Yo = RemoveCpCs( Yr, N, n0) 5 | Yo = Yr(n0+(1:N),:); 6 | end 7 | 8 | -------------------------------------------------------------------------------- /CoreLib/ResourceDemap.m: -------------------------------------------------------------------------------- 1 | %% Resource Demap 2 | % extract allocated data 3 | function d = ResourceDemap(D, K_set, M_set) 4 | K_on = length(K_set); 5 | M_on = length(M_set); 6 | d = reshape(D(K_set, M_set), M_on*K_on,1); 7 | end 8 | -------------------------------------------------------------------------------- /CoreLib/ResourceMap.m: -------------------------------------------------------------------------------- 1 | %% Resource Map 2 | % map data to the big allocation matrix 3 | % indexing must be from 1, 4 | function D = ResourceMap(d, K_set, M_set, K,M) 5 | % The allocation is with respect to subcarriers. 6 | D = zeros(K,M); 7 | K_on = length(K_set); 8 | M_on = length(M_set); 9 | D(K_set, M_set) = reshape(d, K_on, M_on); 10 | end 11 | 12 | -------------------------------------------------------------------------------- /CoreLib/Test/T_CRC.m: -------------------------------------------------------------------------------- 1 | g = [0,0,1,1,0,0,0,1]; 2 | x = [1 0 0 0 1 1 1 1 1 0 0 0 1 1 1 1]; 3 | 4 | [r, y] = CRC(x, g); 5 | 6 | Q = length(g); 7 | Ug = toint([1,g]) 8 | Ux = toint([x,zeros(1,Q)]) 9 | Ux1 = toint([x, zeros(1,Q)]) 10 | 11 | Ur = toint(r) 12 | Uy = toint(y) 13 | 14 | dm = floor(Ux/Ug) 15 | rm = mod(Ux,Ug) 16 | r1 = mod(Ux,Uy) 17 | function val = toint(x) 18 | % MSB first 19 | N = length(x); 20 | x = reshape(x, 1,N); 21 | val = sum(x.*2.^(N-1:-1:0)); 22 | end -------------------------------------------------------------------------------- /CoreLib/Test/T_Complexity.m: -------------------------------------------------------------------------------- 1 | function [TD, FD, FD_opt, FD_r] = Complexity( K, M, K_on, M_on, N_p, U ) 2 | %UNTITLED Summary of this function goes here 3 | % Detailed explanation goes here 4 | N = M*K; 5 | TD_fft = U*M_on*K*log2(U*K); 6 | FD_fft = K_on*M*log2(M) + U*N*log2(U*N); 7 | TD = zeros(1,3); 8 | FD = zeros(1,3); 9 | TD(1) = TD_fft + U*N*M_on; 10 | TD(2) = TD_fft + U*N+ 2*U*N*log2(M); 11 | TD(3) = TD_fft + U*N*M_on; 12 | 13 | FD(1) = FD_fft + N*K_on; 14 | FD(2) = FD_fft + N+ 2*N*log2(K); 15 | FD(3) = FD_fft + N_p*K_on; 16 | FD_opt = M*log2(M) + U*N*log2(U*N) + 2*M*K_on; 17 | FD_r = K_on*M*log2(M)+K_on*N_p; 18 | end 19 | 20 | -------------------------------------------------------------------------------- /CoreLib/Test/T_GFDM_modulator.m: -------------------------------------------------------------------------------- 1 | Kt = [16, 1, 16]; 2 | Mt = [8, 16, 1]; 3 | M1t = [6, 1, 0]; 4 | M2t = [6, 0, 1]; 5 | err_T_shift = zeros(3,1); 6 | err_T_ref = zeros(3,1); 7 | err_T_shift2= zeros(3,1); 8 | err_gr= zeros(3,1); 9 | for i =1:3 10 | K = Kt(i); 11 | M = Mt(i); 12 | M1 = M1t(i); 13 | M2 = M2t(i); 14 | N = M *K; 15 | 16 | D = zeros(K,M); 17 | if K>1 18 | K_set = [1 , 3, 4]; 19 | else 20 | K_set = 1; 21 | end 22 | 23 | D(K_set, :) = rand(length(K_set),M); 24 | gn = randn(1,M1); 25 | gp = randn(1,M2); 26 | 27 | gf = zeros(N,1); 28 | gf(1:M2) = gp; 29 | gf(end-(M1-1:-1:0)) = gn; 30 | 31 | Xf = ModulatorGFDMFrequency(D, K_set, gp, gn, 0); 32 | xt = ifft(reshape(Xf.', N,1)); 33 | gt = ifft(gf); 34 | xt_ref = ref_GFDM_Mod(D,gt,K,M); 35 | err_T_ref(i) = norm(xt_ref-xt, 'fro'); 36 | 37 | %with shift 38 | gf = zeros(N,1); 39 | gf(M+(1:M2)) = gp; 40 | gf(M-(M1-1:-1:0)) = gn; 41 | 42 | Xf = ModulatorGFDMFrequency(D, K_set, gp, gn, 1); 43 | xt = ifft(reshape(Xf.', N,1)); 44 | gt = ifft(gf); 45 | xt_ref = ref_GFDM_Mod(D,gt,K,M); 46 | err_T_shift(i) = norm(xt_ref-xt, 'fro'); 47 | 48 | %with shift 49 | gf = zeros(N,1); 50 | if K>1 51 | gf(1:2*M) = rand(2*M,1); 52 | gp = gf(M+(1:M)); 53 | gn = gf(1:M); 54 | else 55 | gf(1:M) = rand(M,1); 56 | gp = []; 57 | gn = gf(1:M); 58 | end 59 | 60 | Xf = ModulatorGFDMFrequency(D, K_set, gp, gn, 1); 61 | xt = ifft(reshape(Xf.', N,1)); 62 | gt = ifft(gf); 63 | xt_ref = ref_GFDM_Mod(D,gt,K,M); 64 | err_T_shift2(i) = norm(xt_ref-xt, 'fro'); 65 | 66 | end 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /CoreLib/Test/T_GeneralModemFrequency.m: -------------------------------------------------------------------------------- 1 | Kt = [16, 1, 16]; 2 | Mt = [8, 16, 1]; 3 | 4 | for i =1:3 5 | K = Kt(i); 6 | M = Mt(i); 7 | N = M*K; 8 | K_set = 1:K; 9 | gf = randn(N,1) + 1j*randn(N,1); 10 | Wt = PulseToWindow( gf, K, M ,'FD'); 11 | Wr = ReceiveWindow(Wt,'ZF'); 12 | D = rand(K,M); 13 | 14 | Xf = GeneralModulator(D, K_set, Wt, 'FD'); 15 | D_e = GeneralDemodulator(Xf, K_set,Wr, 'FD'); 16 | err(i) = norm(D-D_e, 'fro'); 17 | end 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /CoreLib/Test/T_GeneralModemTime.m: -------------------------------------------------------------------------------- 1 | Kt = [16, 1, 16]; 2 | Mt = [8, 16, 1]; 3 | 4 | 5 | for i =1:3 6 | K = Kt(i); 7 | M = Mt(i); 8 | N = M *K; 9 | gt = randn(N,1) + 1j*randn(N,1); 10 | 11 | D = rand(K,M); 12 | K_set = 1:K; 13 | Wt = PulseToWindow( gt, K, M ,'TD'); 14 | Wr = ReceiveWindow(Wt,'ZF'); 15 | D = rand(K,M); 16 | 17 | Xf = GeneralModulator(D, K_set, Wt, 'TD'); 18 | D_e = GeneralDemodulator(Xf, K_set,Wr, 'TD'); 19 | err(i) = norm(D-D_e, 'fro'); 20 | end 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /CoreLib/Test/T_General_Matrix_notation.m: -------------------------------------------------------------------------------- 1 | %% Test parameters 2 | K = 32; 3 | K_set = 1:3:K; 4 | Ku = length(K_set); 5 | M = 16; 6 | N = M*K; 7 | 8 | % pulse shape 9 | g = randn(N,1)+1j*randn(N,1); 10 | gf = fft(g,N); 11 | 12 | % DFt matricea 13 | FM = dftmtx(M); 14 | FK = dftmtx(K); 15 | FN = dftmtx(N); 16 | % Windows 17 | % ZAK transform time 18 | Zgt = transpose(FM* reshape(g,K,M).'); 19 | % ZAK transform Frequency 20 | Zgf = 1/K*FK'* reshape(gf,M,K).'; 21 | 22 | % random data 23 | D = zeros(K,M); 24 | D(K_set,:) = randn(Ku,M)+1j*randn(Ku,M); 25 | 26 | % reference signal 27 | xref = ref_GFDM_Mod(D,g,K,M); 28 | 29 | %% Test matrix 30 | %1. precoding 31 | 32 | Ds = 1/K*FK'*D*FM; 33 | 34 | %------- time domain generation 35 | % 2. windowing 36 | % time % freq 37 | Xt = K*Zgt.*Ds; Xf = K*Zgf.*Ds; 38 | % 3. transformation 39 | % time % freq 40 | VxMK = 1/M*FM'*Xt.'; VxfKM = FK*Xf; 41 | % 4. allocation 42 | % time % freq 43 | x = reshape(VxMK.',N,1); xf = reshape(VxfKM.',N,1); 44 | 45 | % DFT for % freq 46 | xft = 1/N*FN'*xf; 47 | %% Error check 48 | 49 | err = norm(xref-x); 50 | disp(['error time-domain - ref ' num2str(err)]); 51 | 52 | err = norm(xref-xft); 53 | disp(['error frequency-domain - ref ' num2str(err)]); 54 | 55 | -------------------------------------------------------------------------------- /CoreLib/Test/T_PsdSubcarrier.m: -------------------------------------------------------------------------------- 1 | K = 32; 2 | M = 1; 3 | P = -M/2:M/2-1; 4 | Ncp = 0; 5 | Ncs = 0; 6 | N = K*M; 7 | Ns = N+Ncp+Ncs; 8 | %n0= Ncp; 9 | n0 = 0; 10 | gf = ones(length(P),1); 11 | m = 0; 12 | k = 0; 13 | U = 4; 14 | w = ones(Ns,1)/Ns; 15 | K_set = -K/4:K/4; 16 | M_set = 1; 17 | Non = length(K_set)*length(M_set); 18 | Sx_th = zeros(N*U,1); 19 | Sx2_th = zeros(N*U,1); 20 | for k = K_set 21 | for m = M_set 22 | [Skm0, f0] = PsdSubcarrier2( gf, P, k, m, K, M, n0, Ns, U); 23 | Sx2_th = Sx2_th+PsdSubcarrier2( gf, P, k, m, K, M, n0, Ns, U); 24 | Sx_th = Sx_th + Skm0; 25 | end 26 | end 27 | 28 | 29 | 30 | Nb = 2048*10; 31 | Don = 2*(randi([0,1],Non,Nb)-0.5); 32 | X = Modulator(Don, K, M, K_set, M_set, gf,P,1); 33 | Xo = AddCpCs( X, N, Ncp, Ncs); 34 | x = Xo(:); 35 | Nfft = Ns*U; 36 | [Sx, f1] = PSD_Estimation( x, Nfft); 37 | S0_th = sum(fftshift(Sx_th))/Ns*1/(N*U); 38 | S0_th2 = sum(fftshift(Sx2_th))/Ns*1/(N*U); 39 | S0 = sum(fftshift(Sx))*1/(Nfft); 40 | close all 41 | figure(1) 42 | plot(f0, 10*log10(fftshift(Sx_th)/Ns/S0_th)) 43 | hold on 44 | plot(f0, 10*log10(fftshift(Sx2_th)/Ns/S0_th2)) 45 | hold on 46 | plot(f1,10*log10(fftshift(Sx/S0))); 47 | legend('th','th2','Es') 48 | -------------------------------------------------------------------------------- /CoreLib/Test/T_TurboCoding.m: -------------------------------------------------------------------------------- 1 | Mc = 4; 2 | Non = 128; 3 | Payload_size = 10; 4 | CodeType = 'CC-1-2'; 5 | ChCode = GenerateCode( CodeType,Payload_size,Non,Mc ); 6 | 7 | 8 | g1 = [1,0,1,1; 1,1,0,1]; 9 | g2 = g1; 10 | nsc_flag1 = 0; 11 | nsc_flag2 = 0; 12 | 13 | pun_pattern = [1; 1; 0; 0]; 14 | tail_pattern = ones(4,3); 15 | 16 | K = 1024; 17 | %code_interleaver = CreateLTEInterleaver(K) ; 18 | 19 | data = randi([0 1],1, ChCode.Nr_infobits); 20 | 21 | ChCode.interleaver1 = randperm(ChCode.Nr_infobits); 22 | encoded_bits = TurboEncode( data, ChCode.interleaver1, pun_pattern, tail_pattern, g1, nsc_flag1, g2, nsc_flag2 ); 23 | bps = ChCode.bps; 24 | Nb = ChCode.Nb; 25 | Non = ChCode.Non; 26 | Ncbpsym = ChCode.Ncbpsym; 27 | constellation = ChCode.Constellation; 28 | 29 | data_symb_idx = bi2de(reshape(encoded_bits,bps,length(encoded_bits)/bps)','left-msb') + 1; 30 | qam_data = constellation(data_symb_idx); 31 | 32 | a = 2; 33 | EsN0 = 10; 34 | N0 = 1/EsN0; 35 | qam_data_e = a*qam_data + GenRandomNoise(size(qam_data), N0); 36 | Esno = repmat(EsN0, numel(qam_data),1); 37 | fad = repmat(a, numel(qam_data),1); 38 | LLRs_symb = Demod2D(qam_data_e.',constellation, Esno.', fad.'); 39 | %LLRs_symb = LLRs_symb -repmat(max(LLRs_symb,[],1),2^bps,1); 40 | % convert symbols LLRs to bits LLRs 41 | llrs_dem = Somap(LLRs_symb, 3); 42 | 43 | [detected_data, errors, output_decoder_c ] = TurboDecode( llrs_dem, data, 14, 3, ChCode.interleaver1, pun_pattern, tail_pattern, g1, nsc_flag1, g2, nsc_flag2 ); 44 | 45 | 46 | 47 | % -------------------------------------------------------------------------------- /CoreLib/Test/T_channel.m: -------------------------------------------------------------------------------- 1 | fs = 30.72e6; 2 | fs = 40e6; 3 | fD = 300; 4 | L = 192; 5 | ChType = 'EVA'; 6 | rchan = GenFadingChannel( ChType, fD, fs); 7 | L= 41; 8 | x = zeros(L,1); 9 | x(1) = 1; 10 | H = zeros(L,1000); 11 | for i = 1:1000 12 | H(:,i) = genChannel(rchan, L); 13 | end 14 | 15 | N = 64*16; 16 | Hf = mean(abs(fft(H,N).^2),2); 17 | plot(Hf); 18 | 19 | 20 | function h = genChannel(rchan, L) 21 | x = zeros(L,1); 22 | x(1) = 1; 23 | reset(rchan); 24 | release(rchan); 25 | % change the seed to get different realization 26 | rchan.Seed = rchan.Seed+1; 27 | h = step(rchan, x); 28 | end -------------------------------------------------------------------------------- /CoreLib/Test/T_computeSNR.m: -------------------------------------------------------------------------------- 1 | K = 16; 2 | M = 8; 3 | N = K*M; 4 | alpha = 0; 5 | 6 | psFunc = CreatePulse; 7 | 8 | [~, gf_rc] = psFunc.ISIFree(K, M, alpha, psFunc.FuncRC, 'real', 0.5); 9 | %[~, gf_rc] = psFunc.ISIFreeMatched(K, M, alpha,psFunc.FuncRC,psFunc.FuncXia,0, 0.5 ) 10 | gf_rc = sqrt(N)/norm(gf_rc)*gf_rc; 11 | 12 | g = ifft(gf_rc); 13 | g = g/norm(g); 14 | 15 | GFDM_func = Create_GFDM_functions; 16 | out = GFDM_func.GenMatrices(g,K,M); 17 | Af = out.Gf_M; 18 | Af_inv = out.Gf_M'/N; 19 | 20 | gf = fft(g); 21 | 22 | Wt = PulseToWindow( g, K, M, 'TD'); 23 | Wft= PulseToWindow( gf, K, M, 'FD'); 24 | Wfr = ReceiveWindow( Wft, 'ZF'); 25 | rxType = 'ZF'; 26 | EsN0 = 10; 27 | hf = randn(N,1)+1j*randn(N,1); 28 | hf_eq = ReceiveWindow( hf, rxType, EsN0); 29 | Pi = transpose((hf_eq.*hf -1)); 30 | Pn = transpose(hf_eq); 31 | temp = abs(Af_inv .* repmat(Pi, N,1)).^2 + abs(Af_inv .* repmat(Pn, N,1)).^2/EsN0; 32 | EsNo_vec = 1./sum(temp, 2)/N; 33 | Vg = ifft(Wfr); 34 | v_snr = ComputeSNR( Vg, hf, hf_eq, EsN0 ); 35 | 36 | err = norm(v_snr-EsNo_vec); -------------------------------------------------------------------------------- /CoreLib/Test/T_constellation.m: -------------------------------------------------------------------------------- 1 | Mc = 16; 2 | m = log2(Mc); 3 | S = GrayCode(Mc); 4 | 5 | diff = zeros(Mc,1); 6 | for i=0:Mc-1 7 | diff(i+1) = sum(S(mod(i,Mc)+1,:)~=S(mod(i+1,Mc)+1,:)); 8 | end 9 | pw = 2.^(0:m-1)'; 10 | ind = (~S)*pw; 11 | 12 | const = QAMConstellation(Mc) -------------------------------------------------------------------------------- /CoreLib/Test/T_general_Modulator.m: -------------------------------------------------------------------------------- 1 | Kt = [16, 1, 16]; 2 | Mt = [8, 16, 1]; 3 | 4 | err_F_T = zeros(3,1); 5 | err_T_ref = zeros(3,1); 6 | err_D= zeros(3,1); 7 | err_gr= zeros(3,1); 8 | err_Dt= zeros(3,1); 9 | err_Df= zeros(3,1); 10 | 11 | for i =1:3 12 | K = Kt(i); 13 | M = Mt(i); 14 | N = M *K; 15 | 16 | D = rand(K,M); 17 | 18 | gt = randn(N,1) + 1j*randn(N,1); 19 | K_set = 1:K; 20 | Wt = PulseToWindow( gt, K, M, 'TD'); 21 | 22 | Wft= PulseToWindow( fft(gt), K, M, 'FD'); 23 | 24 | Xf = GeneralModulator(D, K_set, Wft, 'FD'); 25 | xf = reshape(Xf.',N,1); 26 | X = GeneralModulator(D, K_set, Wt,'TD'); 27 | xt = reshape(X.',N,1); 28 | Wr = ReceiveWindow( Wt, 'ZF'); 29 | gr = WindowToPulse( conj(Wr), 'TD'); 30 | 31 | Wfr = ReceiveWindow( Wft, 'ZF'); 32 | gfr = WindowToPulse( conj(Wfr), 'FD'); 33 | 34 | xt_ref = ref_GFDM_Mod(D,gt,K,M); 35 | D_e = ref_GFDM_DeMod(xt_ref,gr,K,M); 36 | Dt_e = GeneralDemodulator( X, K_set, Wr, 'TD' ); 37 | Df_e = GeneralDemodulator( Xf, K_set, Wfr, 'FD' ); 38 | err_F_T(i) = norm(xf-fft(xt), 'fro'); 39 | err_T_ref(i) = norm(xt_ref-xt, 'fro'); 40 | err_D (i) = norm(D-D_e, 'fro'); 41 | err_Dt (i) = norm(D-Dt_e, 'fro'); 42 | err_Df (i) = norm(D-Df_e, 'fro'); 43 | err_gr (i) = norm(gr-ifft(gfr), 'fro'); 44 | end 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /CoreLib/Test/ref_GFDM_DeMod.m: -------------------------------------------------------------------------------- 1 | function D = ref_GFDM_DeMod(x,gr,K,M) 2 | N = M*K; 3 | D = zeros(K,M); 4 | for m=0:M-1 5 | for k=0:K-1 6 | % Note that N_cp can be included here 7 | for n=0:N-1 8 | D(k+1,m+1) = D(k+1,m+1) + x(n+1)* conj(gr(mod(n-m*K,N)+1))*exp(-2*1j*pi*n*k/K); 9 | end 10 | end 11 | end 12 | end -------------------------------------------------------------------------------- /CoreLib/Test/ref_GFDM_Mod.m: -------------------------------------------------------------------------------- 1 | function x = ref_GFDM_Mod(D,g,K,M) 2 | N = M*K; 3 | tmp = zeros(N,1); 4 | x = zeros(N,1); 5 | for m=0:M-1 6 | for k=0:K-1 7 | % Note that N_cp can be included here 8 | for n=0:N-1 9 | tmp(n+1) = D(k+1,m+1) * g(mod(n-m*K, N)+1)*exp(2*1j*pi*n*k/K); 10 | end 11 | x = x+ tmp; 12 | end 13 | end 14 | end -------------------------------------------------------------------------------- /CoreLib/Test/test_CRC.m: -------------------------------------------------------------------------------- 1 | g = [1,0,0,1 ,1,0,0,0 ,1,1,1,1 ,1,1,1,1]; 2 | x = [1 0 0 0 1 1 1 1 1 0 0 0 1 1 1 1 0 1 1 0 1 ]; 3 | 4 | [r, y] = CRC(x, g); 5 | 6 | Q = length(g); 7 | Ug = toint([1,g]) 8 | Ux = toint([x,zeros(1,Q)]) 9 | Ux1 = toint([x, zeros(1,Q)]) 10 | 11 | Ur = toint(r) 12 | Uy = toint(y) 13 | 14 | dm = floor(Ux/Ug) 15 | rm = mod(Ux,Ug) 16 | r1 = mod(Ux,Uy) 17 | function val = toint(x) 18 | % MSB first 19 | N = length(x); 20 | x = reshape(x, 1,N); 21 | val = sum(x.*2.^(N-1:-1:0)); 22 | end -------------------------------------------------------------------------------- /CoreLib/WindowToPulse.m: -------------------------------------------------------------------------------- 1 | % W: KxM input window 2 | % type = {'TD', 'FD'} 3 | % gr = receive pulse. This pulse in time domain or frequency domain 4 | % depending on the selected type 5 | function gr = WindowToPulse( W, type) 6 | [K,M] = size(W); 7 | 8 | if strcmp(type,'TD') 9 | W = W.'; 10 | if M>1 11 | gr = reshape(transpose(ifft(W)), K*M,1); 12 | else 13 | gr = reshape(transpose(W), K*M,1); 14 | end 15 | else % FD 16 | if K>1 17 | gr = reshape(transpose(conj(W)), K*M,1); 18 | else 19 | gr = reshape(transpose(W), K*M,1); 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /CoreLib/Windowing.m: -------------------------------------------------------------------------------- 1 | %% Windowing 2 | % Window over symbol 3 | % N_Cs length of Cs used for edges of the window. 4 | function X = Windowing(X, w, Ncs) 5 | Nb = size(X,2); 6 | % Widow works only on the edges 7 | for nb=1:Nb 8 | X(1:Ncs,nb) = w(1:Ncs).*X(1:Ncs,nb); 9 | X(end+1-(1:Ncs),nb) = w(end+1-(1:Ncs)).*X(end+1-(1:Ncs),nb); 10 | end 11 | end -------------------------------------------------------------------------------- /CoreLib/~$cumnets.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/CoreLib/~$cumnets.docx -------------------------------------------------------------------------------- /GFDM.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/GFDM.pdf -------------------------------------------------------------------------------- /GFDM_LabView_Host/Host/Configurations_scripts/Filter.m: -------------------------------------------------------------------------------- 1 | function g = Filter(K,M,alpha) 2 | if mod(M,2) == 0 3 | shift = 0.5; 4 | else 5 | shift = 0.0; 6 | end 7 | N = K*M; 8 | %alpha; 9 | f=(-1/2:1/N: (1/2-1/N))'+shift/N; 10 | g_f = zeros(length(f),1); 11 | ind = abs(f)<= (1-alpha)/(2*K); 12 | g_f(ind) = 1; 13 | ind = ((abs(f)> (1-alpha)/(2*K))& (abs(f) <= (1+alpha)/(2*K))); 14 | f1 = f(ind); 15 | g_f(ind)= 1/2*(1-sin(pi/2*(2*K/alpha*(abs(f1)-1/(2*K))))); 16 | g_f = fftshift(g_f); 17 | g = ifft(g_f); 18 | 19 | end 20 | 21 | -------------------------------------------------------------------------------- /GFDM_LabView_Host/Host/Configurations_scripts/gen_gfdm.m: -------------------------------------------------------------------------------- 1 | function [K,M, N, N_cp, N_cs, N_on, Wt, Wrf, w_cs, N_s, K_set, M_set] = gen_gfdm(K,M,N_cp,N_cs,alpha, select, sub0ff) 2 | N = M*K; 3 | g = Filter(K,M,alpha); 4 | gf = fft(g); 5 | if sub0ff ==1 6 | M_set = int32(mod(1:M-1, M)'+1); 7 | else 8 | M_set = int32(mod(0:M-1, M)'+1); 9 | end 10 | if (select == 1) 11 | 12 | % To acheive 20 MHz with FS of 30.27 Mhz 13 | % K_on = 10/30.72*K 14 | % two subcarriers are guard and Dc is off 15 | 16 | K_set = int32( mod([0:K-1 ],K)'+1); 17 | M_on = int32(length(M_set)); 18 | K_on = int32(length(K_set)); 19 | N_on = M_on*K_on; 20 | elseif (select == 2) 21 | 22 | % To acheive 20 MHz with FS of 30.27 Mhz 23 | % K_on = 10/30.72*K 24 | % two subcarriers are guard and Dc is off 25 | K_on = K/2; 26 | K_on2 = floor(K_on/2); 27 | K_set = int32( mod([1:K_on2,-K_on2:-1 ],K)'+1); 28 | 29 | M_on = int32(length(M_set)); 30 | K_on = int32(length(K_set)); 31 | N_on = M_on*K_on; 32 | 33 | else 34 | K = 64; 35 | M = 16; 36 | Fs = 30.72; 37 | B = 20; 38 | M_set = int32(mod(1:M-1, M)'+1); 39 | % To acheive 20 MHz with FS of 30.27 Mhz 40 | % K_on = 10/30.72*K 41 | % two subcarriers are guard and Dc is off 42 | K_on = floor(B/Fs*K)-3; 43 | K_on2 = floor(K_on/2); 44 | K_set = int32( mod([1:K_on2,-K_on2:-1 ],K)'+1); 45 | M_on = int32(length(M_set)); 46 | K_on = int32(length(K_set)); 47 | N_on = M_on*K_on; 48 | N = M*K; 49 | gf = zeros(N,1); 50 | gf(1:M/2) = 1; 51 | gf(end-(0:M/2-1)) = 1; 52 | gf = gf*sqrt(N)/ norm(gf); 53 | g = ifft(gf); 54 | % Tx window 55 | if M>1 56 | Wt = fft(transpose(reshape(g,K,M))); 57 | else 58 | Wt = transpose(reshape(g,K,M)); 59 | end 60 | % 61 | if K>1 62 | Wtf = fft(transpose(reshape(gf,M,K))); 63 | else 64 | Wtf = transpose(reshape(gf,M,K)); 65 | end 66 | end 67 | % Tx window 68 | if M>1 69 | Wt = fft(transpose(reshape(g,K,M))); 70 | else 71 | Wt = transpose(reshape(g,K,M)); 72 | end 73 | % 74 | if K>1 75 | Wtf = fft(transpose(reshape(gf,M,K))); 76 | else 77 | Wtf = transpose(reshape(gf,M,K)); 78 | end 79 | 80 | Wrf = 1./Wtf; 81 | K = int32(K); 82 | M = int32(M); 83 | N = int32(N); 84 | N_cp = int32(K/2); 85 | N_cs = int32(K/2); 86 | w_cs = zeros(N_cs,1); 87 | N_s = N+N_cp+N_cs; 88 | 89 | end -------------------------------------------------------------------------------- /GFDM_LabView_Host/Host/Configurations_scripts/gen_pre.m: -------------------------------------------------------------------------------- 1 | function [d, pre_cp, pref64, pre64] = gen_pre(select, Ncs, Ncp, S, R) 2 | M = 2; 3 | K = 64; 4 | N = K*M; 5 | d = zeros(K,1); 6 | k = double((0:K-1)'); 7 | d0 = sqrt(64)*[1, -1, -1, -1, -1,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 8 | -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 9 | -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 1]'; 10 | 11 | if(select == 1) 12 | d(1:K) = d0(1:K); 13 | 14 | elseif (select == 2) 15 | d = d0 16 | S = 25; 17 | s = double( (1:S)'); 18 | K2 = floor(K/2); 19 | d(K2+(1:S)) = d(K2+(1:S)).*sin(pi/2*s/S); 20 | d(K2-(0:S-1)) = d(K2-(0:S-1)).*sin(pi/2*s/S); 21 | 22 | else 23 | Kd = double(K); 24 | Rd = double(R); 25 | d = sqrt(64)*exp(-1j*pi*Rd*k.*(k+1)/Kd); 26 | Sd = double(S); 27 | s = double( (1:S)'); 28 | K2 = floor(K/2); 29 | d(K2+(1:S)) = d(K2+(1:S)).*sin(pi/2*s/Sd); 30 | d(K2-(0:S-1)) = d(K2-(0:S-1)).*sin(pi/2*s/Sd); 31 | end 32 | 33 | pre64 = ifft(d)/4; 34 | 35 | pre = repmat(pre64,2,1); 36 | pref64 = 2*fft(pre(1:K)); 37 | 38 | No = Ncp+ Ncs; 39 | Nt = N+No; 40 | nt = 0:Nt-1; 41 | pre_cp = pre(mod(nt-Ncp, N)+1); 42 | 43 | end 44 | -------------------------------------------------------------------------------- /GFDM_LabView_Host/Host/GFDMParallel/Test/test_RX.gvi: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /OTFSvsGFDM/CC/Doppler_1404_GFDM-short-CC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/CC/Doppler_1404_GFDM-short-CC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/CC/Doppler_1404_OFDM-short-CC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/CC/Doppler_1404_OFDM-short-CC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/CC/Doppler_1404_OTFS-short-CC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/CC/Doppler_1404_OTFS-short-CC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/CC/_1304_GFDM-long-CC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/CC/_1304_GFDM-long-CC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/CC/_1304_GFDM-short-CC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/CC/_1304_GFDM-short-CC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/CC/_1304_GFDM-shortT2-CC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/CC/_1304_GFDM-shortT2-CC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/CC/_1304_OFDM-long-CC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/CC/_1304_OFDM-long-CC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/CC/_1304_OFDM-short-CC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/CC/_1304_OFDM-short-CC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/CC/_1304_OTFS-long-CC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/CC/_1304_OTFS-long-CC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/CC/_1304_OTFS-short-CC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/CC/_1304_OTFS-short-CC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/Doppler_Evaluation.m: -------------------------------------------------------------------------------- 1 | clear all; 2 | 3 | close all; 4 | 5 | rxType = 'MMSE'; 6 | % OTFS parameters 7 | Mo = 128; 8 | Ko = 16; 9 | No = Mo*Ko; 10 | % Channel parameters 11 | ChType = 'EVA'; 12 | fs = 8e6 ; 13 | Ncp = 32; 14 | nu_M = 0.005:0.005:0.05; 15 | %nu_M = [0.0000:0.005:0.01]; 16 | fD = nu_M*fs/Mo; 17 | 18 | CodeType = 'TC-1-2'; 19 | Mc = 16; 20 | 21 | 22 | GFDM_M = [Mo, 8, Ko ]; 23 | GFDM_K = [Ko, Ko, 8]; 24 | 25 | OFDM_K = [No, Mo]; 26 | 27 | long = 1; 28 | short = 2; 29 | short_2 = 3; 30 | % all GFDM and OTFS uses the Rc(0) 31 | 32 | Wv = {'GFDM-long', 'OFDM-long', 'GFDM-short', 'OFDM-short'}; 33 | ncps = 8; % number of bit per symbols 34 | Nf_OTFS = [1, Ko]; 35 | Nspf = [No, Mo, Mo]; 36 | 37 | payloadSize = 2*Nspf/ncps-[8,1,1]; 38 | frame_type = {'long', 'short', 'shortT2'}; 39 | 40 | SNR = [18 20 22 ] ; 41 | N_run1 = 100*[1 1 1; 10 10 10 ]; 42 | 43 | seed = 12345; 44 | fpre = 'Doppler_1504_'; 45 | 46 | %% OTFS 47 | for l_f = 2 48 | ChCode = GenerateCode( CodeType, payloadSize(l_f),Nspf(l_f),Mc); 49 | tic 50 | for i = 1:length(SNR) 51 | imp_cell{i} = OTFS_LTV_Doppler(Ko, Mo, Ncp, ChCode, N_run1(1,i), SNR(i), rxType, ChType, fs, fD, seed, Nf_OTFS(l_f)); 52 | disp(['OTFS' num2str([l_f, i])]) 53 | end 54 | toc 55 | save([fpre 'OTFS-' frame_type{l_f} '-' CodeType]); 56 | end 57 | %% OFDM 58 | is_OFDM = 1; 59 | for l_f = 2 60 | ChCode = GenerateCode( CodeType, payloadSize(l_f),Nspf(l_f),Mc); 61 | tic 62 | for i = 1:length(SNR) 63 | imp_cell{i} = GFDM_LTV_Doppler(OFDM_K(l_f), 1, Ncp, ChCode, N_run1(l_f,i), SNR(i), rxType, ChType, fs, fD, seed, is_OFDM); 64 | disp(['OFDM' num2str([l_f, i])]) 65 | end 66 | toc 67 | save([fpre 'OFDM-' frame_type{l_f} '-' CodeType]); 68 | end 69 | 70 | %% GFDM 71 | is_OFDM = 0; 72 | for l_f = 2 73 | ChCode = GenerateCode( CodeType, payloadSize(l_f),Nspf(l_f),Mc); 74 | tic 75 | for i = 1:length(SNR) 76 | imp_cell{i} = GFDM_LTV_Doppler(GFDM_K(l_f), GFDM_M(l_f), Ncp, ChCode, N_run1(l_f,i), SNR(i), rxType, ChType, fs, fD, seed, is_OFDM); 77 | disp(['GFDM' num2str([l_f, i])]) 78 | end 79 | toc 80 | save([fpre 'GFDM-' frame_type{l_f} '-' CodeType]); 81 | end 82 | toc 83 | 84 | 85 | -------------------------------------------------------------------------------- /OTFSvsGFDM/GFDM_LTV.m: -------------------------------------------------------------------------------- 1 | function imp = GFDM_LTV(K, M, Ncp, ChCode, N_run1, SNR, rxType, ChType, fs, fD, seed, isOFDM) 2 | % Core parameters 3 | rng(seed); 4 | N = M*K; 5 | NB = ChCode.Nb; 6 | 7 | [K_set, M_set, Wt, Wfr, Vg, rchan, EsN0, N0, imp, params, N_run, N_SNR] = Generate_common_fD( K,M, NB, SNR, N_run1, ChType, fD, fs, isOFDM ); 8 | 9 | for n_run = 1: N_run(end) 10 | %% generated data 11 | info_bits = randi([0 1],ChCode.Nr_infobits,1); 12 | [ qam_data, encoded_bits] = Encoder(ChCode, info_bits); 13 | 14 | Tx.InfoBits = info_bits; 15 | Tx.EncodedBits = encoded_bits; 16 | Tx.Symbols = qam_data; 17 | 18 | % generate noise per run 19 | v = GenRandomNoi 20 | se([NB*(N+Ncp),1], 1); 21 | Xt_gfdm = zeros(N,NB); 22 | %% GFDM TX 23 | for nb=1:NB 24 | D = ResourceMap(qam_data(:,nb), K_set, M_set, K,M); 25 | X = GeneralModulator(D, K_set, Wt,'TD'); 26 | Xt_gfdm(:,nb) = reshape(X.',N,1); 27 | end 28 | Tx.Xf = Xt_gfdm; 29 | Tx.xt = 0; 30 | Xt_gfdm_CP = AddCpCs( Xt_gfdm, N, Ncp, 0); 31 | %% LTV channel 32 | [ He_gfdm, Yr_gfdm ] = ApplyChannel( rchan, Xt_gfdm_CP, Ncp); 33 | %% Evaluate for SNR 34 | for n_snr = 1:N_SNR 35 | if(n_run> N_run(n_snr)) 36 | continue; 37 | else 38 | %% Additive noise 39 | Yr = Yr_gfdm + sqrt(N0(n_snr))*reshape(v(1:numel(Yr_gfdm)), size(Yr_gfdm)); 40 | %% remove CP 41 | Y = RemoveCpCs( Yr, N, Ncp); 42 | Yf = fft(Y); 43 | Rx.Xf = Y; 44 | Rx.Vf = 0; % noise sample 45 | 46 | %% channel estimation 47 | He = He_gfdm(Ncp+(1:N),:); 48 | Hfe = fft(He); 49 | 50 | qam_data_e = zeros(size(qam_data)); 51 | EsNo_vec = zeros(size(qam_data)); 52 | for nb=1:NB 53 | %% equalizer 54 | Hfeq = ReceiveWindow( Hfe(:,nb), rxType, EsN0(n_snr)); 55 | y_eq = Hfeq.*Yf(:,nb); 56 | %% Demodulator 57 | Yeqf = transpose(reshape(y_eq, M,K)); 58 | if (~isOFDM) % bypass demodulator 59 | D_e = GeneralDemodulator( Yeqf, K_set, Wfr, 'FD' ); 60 | else 61 | D_e = Yeqf*Wfr(1); % only scaler window 62 | end 63 | %% Demap 64 | qam_data_e(:,nb) = ResourceDemap(D_e, K_set, M_set); 65 | %% SNRs per symbols 66 | EsNo_vec(:,nb) = ComputeSNR( Vg, Hfe(:,nb), Hfeq, EsN0(n_snr), isOFDM ); 67 | end 68 | %% Decoder 69 | ChCode.info_bits = info_bits; 70 | [ bits_e, encoded_bits_e ] = Decoder( ChCode, qam_data_e(:), EsNo_vec(:)); 71 | 72 | Rx.InfoBits = bits_e; 73 | Rx.EncodedBits = encoded_bits_e; 74 | Rx.Symbols = qam_data_e; 75 | 76 | end 77 | imp{n_snr} = imp{n_snr}.Measure(imp{n_snr}, params,Tx, Rx); 78 | end 79 | end 80 | %% 81 | imp = imp{1}.AverageAndConcatenate(imp); 82 | end 83 | -------------------------------------------------------------------------------- /OTFSvsGFDM/GFDM_LTV_Doppler.m: -------------------------------------------------------------------------------- 1 | function imp = GFDM_LTV_Doppler(K, M, Ncp, ChCode, N_run1, SNR, rxType, ChType, fs, fD, seed, isOFDM) 2 | % Core parameters 3 | rng(seed); 4 | N = M*K; 5 | NB = ChCode.Nb; 6 | 7 | [ K_set, M_set, Wt, Wfr, Vg, EsN0, N0, imp, params, N_run, N_fD] = Generate_common_Doppler( K,M,NB, SNR, N_run1, fD, isOFDM ); 8 | 9 | for n_fd =1:N_fD 10 | rchan = GenFadingChannel( ChType, fD(n_fd), fs); 11 | for n_run = 1: N_run(n_fd) 12 | %% generated data 13 | info_bits = randi([0 1],ChCode.Nr_infobits,1); 14 | [ qam_data, encoded_bits] = Encoder(ChCode, info_bits); 15 | 16 | Tx.InfoBits = info_bits; 17 | Tx.EncodedBits = encoded_bits; 18 | Tx.Symbols = qam_data; 19 | 20 | % generate noise per run 21 | v = GenRandomNoise([NB*(N+Ncp),1], 1); 22 | Xt_gfdm = zeros(N,NB); 23 | %% GFDM TX 24 | for nb=1:NB 25 | D = ResourceMap(qam_data(:,nb), K_set, M_set, K,M); 26 | X = GeneralModulator(D, K_set, Wt,'TD'); 27 | Xt_gfdm(:,nb) = reshape(X.',N,1); 28 | end 29 | Tx.Xf = Xt_gfdm; 30 | Tx.xt = 0; 31 | Xt_gfdm_CP = AddCpCs( Xt_gfdm, N, Ncp, 0); 32 | %% LTV channel 33 | [ He_gfdm, Yr_gfdm ] = ApplyChannel( rchan, Xt_gfdm_CP, Ncp); 34 | 35 | %% Additive noise 36 | Yr = Yr_gfdm + sqrt(N0)*reshape(v(1:numel(Yr_gfdm)), size(Yr_gfdm)); 37 | %% remove CP 38 | Y = RemoveCpCs( Yr, N, Ncp); 39 | Yf = fft(Y); 40 | Rx.Xf = Y; 41 | Rx.Vf = 0; % noise sample 42 | 43 | %% channel estimation 44 | He = He_gfdm(Ncp+(1:N),:); 45 | Hfe = fft(He); 46 | 47 | qam_data_e = zeros(size(qam_data)); 48 | EsNo_vec = zeros(size(qam_data)); 49 | for nb=1:NB 50 | %% equalizer 51 | Hfeq = ReceiveWindow( Hfe(:,nb), rxType, EsN0); 52 | y_eq = Hfeq.*Yf(:,nb); 53 | %% Demodulator 54 | Yeqf = transpose(reshape(y_eq, M,K)); 55 | if (~isOFDM) % bypass demodulator 56 | D_e = GeneralDemodulator( Yeqf, K_set, Wfr, 'FD' ); 57 | else 58 | D_e = Yeqf*Wfr(1); % only scaler window 59 | end 60 | %% Demap 61 | qam_data_e(:,nb) = ResourceDemap(D_e, K_set, M_set); 62 | %% SNRs per symbols 63 | EsNo_vec(:,nb) = ComputeSNR( Vg, Hfe(:,nb), Hfeq, EsN0, isOFDM ); 64 | end 65 | %% Decoder 66 | ChCode.info_bits = info_bits; 67 | [ bits_e, encoded_bits_e ] = Decoder( ChCode, qam_data_e(:), EsNo_vec(:)); 68 | 69 | Rx.InfoBits = bits_e; 70 | Rx.EncodedBits = encoded_bits_e; 71 | Rx.Symbols = qam_data_e; 72 | 73 | imp{n_fd} = imp{n_fd}.Measure(imp{n_fd}, params,Tx, Rx); 74 | end 75 | end 76 | %% 77 | imp = imp{1}.AverageAndConcatenate(imp); 78 | end 79 | -------------------------------------------------------------------------------- /OTFSvsGFDM/Generate_common_Doppler.m: -------------------------------------------------------------------------------- 1 | function [ K_set, M_set, Wt, Wfr, Vg, EsN0, N0, imp, params, N_run, N_fD] = Generate_common_Doppler( K,M,NB, SNR, N_run1, fD, isOFDM ) 2 | K_set = 1:K; 3 | M_set = 1:M; 4 | N = M*K; 5 | % TX and RX window 6 | psFunc = CreatePulse; 7 | alpha = 0.0; 8 | if ~isOFDM 9 | [~, gf_rc] = psFunc.ISIFree(K, M, alpha, psFunc.FuncRC, 'real', 0.5); 10 | gf_rc = sqrt(N)/norm(gf_rc)*gf_rc; 11 | g = ifft(gf_rc); 12 | else % GFDM 13 | g = ones(N,1); 14 | end 15 | g = g/norm(g); 16 | 17 | gf = fft(g); 18 | Wt = PulseToWindow( g, K, M, 'TD'); 19 | Wft= PulseToWindow( gf, K, M, 'FD'); 20 | Wfr = ReceiveWindow( Wft, 'ZF'); 21 | Vg = ifft(Wfr); 22 | 23 | %% chanel params 24 | N_fD = length(fD); 25 | 26 | EsN0 = 10.^(SNR/10); 27 | N0 = 1./EsN0; 28 | 29 | %% Measuremnt 30 | 31 | 32 | for n_fd = 1:N_fD 33 | imp{n_fd} = CreateMeasurments(); 34 | end 35 | params.N_useful = 1:N; % only the useful FD samples 36 | params.Nb = NB; 37 | 38 | %% Evalution 39 | if N_run1>0 40 | N_run = N_run1*(N_fD:-1:1); 41 | else 42 | N_run = 10*ones(1,N_SNR); 43 | end 44 | end 45 | 46 | -------------------------------------------------------------------------------- /OTFSvsGFDM/Generate_common_fD.m: -------------------------------------------------------------------------------- 1 | function [ K_set, M_set, Wt, Wfr, Vg, rchan, EsN0, N0, imp, params, N_run, N_SNR] = Generate_common_fD( K,M,NB, SNR, N_run1,ChType, fD, fs, isOFDM ) 2 | K_set = 1:K; 3 | M_set = 1:M; 4 | N = M*K; 5 | % TX and RX window 6 | psFunc = CreatePulse; 7 | alpha = 0.0; 8 | if ~isOFDM 9 | [~, gf_rc] = psFunc.ISIFree(K, M, alpha, psFunc.FuncRC, 'real', 0.5); 10 | gf_rc = sqrt(N)/norm(gf_rc)*gf_rc; 11 | g = ifft(gf_rc); 12 | else % GFDM 13 | g = ones(N,1); 14 | end 15 | g = g/norm(g); 16 | 17 | gf = fft(g); 18 | Wt = PulseToWindow( g, K, M, 'TD'); 19 | Wft= PulseToWindow( gf, K, M, 'FD'); 20 | Wfr = ReceiveWindow( Wft, 'ZF'); 21 | Vg = ifft(Wfr); 22 | 23 | %% chanel params 24 | rchan = GenFadingChannel( ChType, fD, fs); 25 | EsN0 = 10.^(SNR/10); 26 | N0 = 1./EsN0; 27 | 28 | %% Measuremnt 29 | N_SNR = length(SNR); 30 | 31 | for n_snr = 1:N_SNR 32 | imp{n_snr} = CreateMeasurments(); 33 | end 34 | params.N_useful = 1:N; % only the useful FD samples 35 | params.Nb = NB; 36 | 37 | %% Evalution 38 | if N_run1 > 0 39 | N_run = max(10*N_run1*(1:N_SNR),N_run1*2.^(1:N_SNR)); 40 | else 41 | N_run = 10*ones(1,N_SNR); 42 | end 43 | end 44 | 45 | -------------------------------------------------------------------------------- /OTFSvsGFDM/LTV_Evaluation.m: -------------------------------------------------------------------------------- 1 | 2 | clear all; 3 | close all; 4 | 5 | rxType = 'MMSE'; 6 | % OTFS parameters 7 | Mo = 128; 8 | Ko = 16; 9 | No = Mo*Ko; 10 | % Channel parameters 11 | ChType = 'EVA'; 12 | fs = 8e6 ; 13 | Ncp = 32; 14 | nu_M = [0.0005, 0.005, 0.05]; 15 | fD = nu_M*fs/Mo; 16 | 17 | CodeType = 'TC-1-2'; 18 | Mc = 16; 19 | 20 | 21 | GFDM_M = [Mo, 8, Ko ]; 22 | GFDM_K = [Ko, Ko, 8]; 23 | 24 | OFDM_K = [No, Mo]; 25 | 26 | long = 1; 27 | short = 2; 28 | short_2 = 3; 29 | % all GFDM and OTFS uses the Rc(0) 30 | 31 | Wv = {'GFDM-long', 'OFDM-long', 'GFDM-short', 'OFDM-short'}; 32 | ncps = 8; % number of bit per symbols 33 | Nf_OTFS = [1, Ko]; 34 | Nspf = [No, Mo, Mo]; 35 | 36 | payloadSize = 2*Nspf/ncps-[8,1,1]; 37 | frame_type = {'long', 'short', 'shortT2'}; 38 | 39 | 40 | SNR = 4:2:24; 41 | N_run1 = 0; 42 | tic 43 | 44 | seed = 12345; 45 | fpre = 'LTV_1504_'; 46 | 47 | %% OTFS 48 | for l_f =1:2 49 | ChCode = GenerateCode( CodeType, payloadSize(l_f),Nspf(l_f),Mc); 50 | tic 51 | for i = 1:length(fD) 52 | imp_cell{i} = OTFS_LTV(Ko, Mo, Ncp, ChCode, N_run1, SNR, rxType, ChType, fs, fD(i), seed, Nf_OTFS(l_f)); 53 | end 54 | toc 55 | disp(['OTFS' num2str([l_f, i])]) 56 | save([fpre 'OTFS-' frame_type{l_f} '-' CodeType]); 57 | end 58 | %% OFDM 59 | is_OFDM = 1; 60 | for l_f =1:2 61 | ChCode = GenerateCode( CodeType, payloadSize(l_f),Nspf(l_f),Mc); 62 | tic 63 | for i = 1:length(fD) 64 | imp_cell{i} = GFDM_LTV(OFDM_K(l_f), 1, Ncp, ChCode, N_run1, SNR, rxType, ChType, fs, fD(i), seed, is_OFDM); 65 | end 66 | disp(['OFDM' num2str([l_f, i])]) 67 | toc 68 | save([fpre 'OFDM-' frame_type{l_f} '-' CodeType]); 69 | end 70 | 71 | %% GFDM 72 | is_OFDM = 0; 73 | for l_f =1:2 74 | ChCode = GenerateCode( CodeType, payloadSize(l_f),Nspf(l_f),Mc); 75 | tic 76 | for i = 1:length(fD) 77 | imp_cell{i} = GFDM_LTV(GFDM_K(l_f), GFDM_M(l_f), Ncp, ChCode, N_run1, SNR, rxType, ChType, fs, fD(i), seed, is_OFDM); 78 | end 79 | disp(['GFDM' num2str([l_f, i])]) 80 | toc 81 | save([fpre 'GFDM-' frame_type{l_f} '-' CodeType]); 82 | end 83 | -------------------------------------------------------------------------------- /OTFSvsGFDM/MMSE_Plot_BER_FER.m: -------------------------------------------------------------------------------- 1 | clear all; 2 | long = 1; 3 | short = 2; 4 | short2 = 3; 5 | 6 | meas = cell(3,1); 7 | code = 'CC-1-2'; 8 | pref = '.\CC\_1304_'; 9 | %pref = '.\TC\_1404_'; 10 | wv = {'OTFS-','GFDM-', 'OFDM-'}; 11 | 12 | flength = {'long-', 'short-', 'shortT2-'}; 13 | 14 | %% What to show 15 | frame_length = 1; 16 | fD_index = [1, 2, 3]; 17 | nu_M = [0.0005, 0.005, 0.05, 0.1]; 18 | useFD = 1; 19 | if ~useFD 20 | betad = {'5\cdot 10^{-4}', '5\cdot 10^{-3}', '5\cdot 10^{-2}', '1\cdot 10^{-1}' }; 21 | else 22 | betad = {' $$31.25~\mbox{Hz}$$', '$$312.5~\mbox{Hz}$$', ' $$3125~~\mbox{Hz}$$', '$$6250~~\mbox{Hz}$$' }; 23 | end 24 | wv_index = [1, 2, 3]; 25 | wv_leg = {'OTFS$$~$$ ', 'GFDM ', 'OFDM '}; 26 | 27 | ylable = 'BER'; 28 | 29 | cols_set = {'b','r','k'}; 30 | mark_set = {'+','o','*','d'}; 31 | 32 | titl = [flength{min(frame_length,2)} code]; 33 | 34 | xlable = '$$ E_s/N_0$$ [dB]'; 35 | 36 | N_SNR = 10; 37 | %%%%%%%%%%%%% Data collection 38 | for Wv_i =1:3 39 | if Wv_i ~=2 && frame_length == 3 40 | fname = [pref wv{Wv_i} flength{2} code ]; 41 | else 42 | fname = [pref wv{Wv_i} flength{frame_length} code ]; 43 | end 44 | load(fname); 45 | meas{Wv_i} = imp_cell; 46 | end 47 | 48 | close all; 49 | fig = figure(1); 50 | 51 | x = SNR(1:N_SNR); 52 | 53 | NfD = length(fD_index); 54 | 55 | Nwf = length(wv_index); 56 | Leg_cell = cell(NfD*Nwf,1); 57 | cols = cell(NfD*Nwf,1); 58 | mark = cell(NfD*Nwf,1); 59 | Y = zeros(N_SNR,NfD*Nwf); 60 | 61 | for i=0:Nwf-1 62 | for j=1:NfD 63 | 64 | imp_cell = meas{wv_index(i+1)}{fD_index(j)}{1}; 65 | if ~useFD 66 | lgname = '$$(\beta_d = '; 67 | else 68 | lgname = '($$f_d =$$ '; 69 | end 70 | Leg_cell{j+i*NfD} = [wv_leg{wv_index(i+1)} lgname betad{fD_index(j)} ')']; 71 | 72 | cols{j+i*NfD} = cols_set{wv_index(i+1)}; 73 | mark{j+i*NfD} = mark_set{fD_index(j)}; 74 | if strcmp(ylable, 'BER') 75 | Y(:,j+i*NfD) = imp_cell.CodedBER(1:N_SNR); 76 | type = 'semilog' ; 77 | elseif strcmp(ylable, 'FER') 78 | Y(:,j+i*NfD) = imp_cell.FER(1:N_SNR); 79 | type = 'semilog' ; 80 | elseif strcmp(ylable, 'NMSE') 81 | type = 'lin' ; 82 | 83 | Y(:,j+i*NfD) = imp_cell.SymbolNMSE(1:N_SNR); 84 | end 85 | end 86 | end 87 | 88 | xrang = [x(1), x(end)]; 89 | [~,ax] = CompareMeasure( Y, x, Leg_cell,xlable, ylable, titl, xrang, fig,type,cols,mark ); 90 | 91 | %% Configiure view area 92 | ax.Title.Visible = 'off'; 93 | ax.Position = [0.12, 0.12, 0.865,.855]; 94 | %ax.Title.Position = [-4.7,18]; 95 | 96 | if strcmp(ylable, 'BER') 97 | if frame_length == 1 98 | ax.YLim = [2e-5,5e-1]; 99 | else 100 | ax.YLim = [2e-5,2e-1]; 101 | end 102 | elseif strcmp(ylable, 'FER') 103 | if frame_length == 1 104 | ax.YLim = [8e-3,1]; 105 | else 106 | ax.YLim = [5e-4,1]; 107 | end 108 | end 109 | 110 | %fig.Position = [0, 0, 1200, 600 ]; 111 | 112 | %% Save file 113 | flength = {'long', 'short', 'shortT2-'}; 114 | 115 | %saveas(fig, [flength{frame_length}, '_MMSE_' ylable '.eps'],'epsc' ) 116 | -------------------------------------------------------------------------------- /OTFSvsGFDM/MMSE_Plot_Doppler.m: -------------------------------------------------------------------------------- 1 | clear all; 2 | long = 1; 3 | short = 2; 4 | short2 = 3; 5 | 6 | meas = cell(3,1); 7 | pref = 'TC/Doppler_1504_'; 8 | %pref = 'CC/Doppler_1404_'; 9 | wv = {'OTFS-','GFDM-', 'OFDM-'}; 10 | code = 'TC-1-2'; 11 | flength = {'long-', 'short-', 'shortT2-'}; 12 | 13 | %% What to show 14 | frame_length = 2; 15 | SNR = [18 20 22 ] ; 16 | snr_index = [1, 3]; 17 | nu_M = [0.0005, 0.005, 0.05, 0.1]; 18 | useFD = 1; 19 | 20 | snr_leg = {'($$18$$ dB)', '($$20$$ dB)', '($$22$$ dB)' }; 21 | 22 | wv_index = [1, 2, 3]; 23 | wv_leg = {'OTFS$$~$$ ', 'GFDM ', 'OFDM '}; 24 | 25 | ylable = 'FER'; 26 | 27 | cols_set = {'b','r','k'}; 28 | mark_set = {'+','o','*','d'}; 29 | 30 | titl = [flength{min(frame_length,2)} code]; 31 | 32 | xlable = '$$ f_D$$ [Hz]'; 33 | 34 | %%%%%%%%%%%%% Data collection 35 | for Wv_i =1:3 36 | if Wv_i ~=2 && frame_length == 3 37 | fname = [pref wv{Wv_i} flength{2} code ]; 38 | else 39 | fname = [pref wv{Wv_i} flength{frame_length} code ]; 40 | end 41 | load(fname); 42 | meas{Wv_i} = imp_cell; 43 | end 44 | 45 | close all; 46 | fig = figure(1); 47 | 48 | NfD = length(fD); 49 | x = fD(1:NfD); 50 | Nsnr = length(snr_index); 51 | 52 | 53 | Nwf = length(wv_index); 54 | Leg_cell = cell(Nsnr*Nwf,1); 55 | cols = cell(Nsnr*Nwf,1); 56 | mark = cell(Nsnr*Nwf,1); 57 | Y = zeros(NfD,Nsnr*Nwf); 58 | 59 | for i=0:Nwf-1 60 | for j=1:Nsnr 61 | 62 | imp_cell = meas{wv_index(i+1)}{snr_index(j)}{1}; 63 | Leg_cell{j+i*Nsnr} = [wv_leg{wv_index(i+1)} snr_leg{snr_index(j)} ')']; 64 | 65 | cols{j+i*Nsnr} = cols_set{wv_index(i+1)}; 66 | mark{j+i*Nsnr} = mark_set{snr_index(j)}; 67 | if strcmp(ylable, 'BER') 68 | Y(:,j+i*Nsnr) = imp_cell.CodedBER(1:NfD); 69 | type = 'semilog' ; 70 | elseif strcmp(ylable, 'FER') 71 | Y(:,j+i*Nsnr) = imp_cell.FER(1:NfD); 72 | type = 'semilog' ; 73 | elseif strcmp(ylable, 'NMSE') 74 | type = 'lin' ; 75 | 76 | Y(:,j+i*Nsnr) = imp_cell.SymbolNMSE(1:NfD); 77 | end 78 | end 79 | end 80 | 81 | xrang = [x(1), x(end)]; 82 | [~,ax] = CompareMeasure( Y, x, Leg_cell,xlable, ylable, titl, xrang, fig,type,cols,mark ); 83 | 84 | %% Configiure view area 85 | ax.Title.Visible = 'off'; 86 | ax.Position = [0.12, 0.12, 0.865,.855]; 87 | ax.Legend.Location = 'southeast'; 88 | %fname = 'Times New Roman'; 89 | %lgd = legend('line1','line2','line3'); 90 | % [lgd,icons,plots,txt] =legend(ax,Leg_cell,'FontName',fname,'Interpreter', 'latex' ,'Location','southwest'); 91 | % for n = 4:9 92 | % icons(n).Visible = 'off'; 93 | % end 94 | % for n = 10:2:27 95 | % icons(n).Visible = 'off'; 96 | % end 97 | %ax.Title.Position = [-4.7,18]; 98 | % if strcmp(ylable, 'BER') 99 | ax.YLim = [1e-4,2e-1]; 100 | % elseif strcmp(ylable, 'FER') 101 | % ax.YLim = [1e-4,1]; 102 | % end 103 | 104 | %fig.Position = [0, 0, 1200, 600 ]; 105 | 106 | %% Save file 107 | saveas(fig, ['Doppler_FER.eps'],'epsc' ) 108 | -------------------------------------------------------------------------------- /OTFSvsGFDM/MMSE_Plot_Symbol_SNR.m: -------------------------------------------------------------------------------- 1 | 2 | clear all; 3 | clear all; 4 | long = 1; 5 | short = 2; 6 | short2 = 3; 7 | 8 | meas = cell(3,1); 9 | pref = '.\CC\_1304_'; 10 | wv = {'OTFS-','GFDM-', 'OFDM-'}; 11 | code = 'CC-1-2'; 12 | flength = {'long-', 'short-', 'shortT2-'}; 13 | 14 | %% What to show 15 | frame_length = 1; 16 | fD_index = 4; 17 | SNR_ind = 8; 18 | 19 | nu_M = [0.0005, 0.005, 0.05, 0.1]; 20 | useFD = 1; 21 | if ~useFD 22 | betad = {'5\cdot 10^{-4}', '5\cdot 10^{-3}', '5\cdot 10^{-2}', '1\cdot 10^{-1}' }; 23 | else 24 | betad = {' $$31~\mbox{Hz}$$', '$$312\mbox{ Hz}$$', ' $$3.1\mbox{ KHz}$$', '$$6.2\mbox{KHz}$$' }; 25 | end 26 | wv_index = [3,2,1]; 27 | wv_leg = {'OTFS$$~$$ ', 'GFDM ', 'OFDM '}; 28 | 29 | 30 | cols_set = {'b','r','k'}; 31 | mark_set = {}; 32 | 33 | %titl = [flength{min(frame_length,2)} code]; 34 | 35 | xlable = 'Symbol index $$ n $$'; 36 | 37 | ylable = 'SNR [dB]'; 38 | 39 | %%%%%%%%%%%%% Data collection 40 | for Wv_i =1:3 41 | if Wv_i ~=2 && frame_length == 3 42 | fname = [pref wv{Wv_i} flength{2} code ]; 43 | else 44 | fname = [pref wv{Wv_i} flength{frame_length} code ]; 45 | end 46 | load(fname); 47 | meas{Wv_i} = imp_cell; 48 | end 49 | 50 | close all; 51 | fig = figure(1); 52 | Ns = 2048; 53 | x = 1:Ns; 54 | 55 | NfD = length(fD_index); 56 | 57 | Nwf = length(wv_index); 58 | Leg_cell = cell(NfD*Nwf,1); 59 | cols = cell(NfD*Nwf,1); 60 | mark = cell(NfD*Nwf,1); 61 | Y = zeros(Ns,NfD*Nwf); 62 | 63 | for i=0:Nwf-1 64 | for j=1:NfD 65 | 66 | imp_cell = meas{wv_index(i+1)}{fD_index(j)}{1}; 67 | if ~useFD 68 | lgname = '$$(\beta_d = '; 69 | else 70 | lgname = '($$f_d =$$ '; 71 | end 72 | Leg_cell{j+i*NfD} = [wv_leg{wv_index(i+1)}]; 73 | 74 | cols{j+i*NfD} = cols_set{wv_index(i+1)}; 75 | %mark{j+i*NfD} = mark_set{fD_index(j)}; 76 | 77 | Y(:,j+i*NfD) = -imp_cell.PerSymbolNMSE(1:Ns,SNR_ind); 78 | 79 | type = 'lin' ; 80 | 81 | end 82 | end 83 | if ~useFD 84 | lgname = '($$\beta_d = '; 85 | else 86 | lgname = '($$f_d =$$'; 87 | end 88 | titl = [lgname betad{fD_index} ', $$E_s/N_0 =' num2str(SNR(SNR_ind)) ' \mbox{ dB} $$']; 89 | 90 | xrang = [x(1), x(end)]; 91 | [~,ax] = CompareMeasure( Y, x, Leg_cell,xlable, ylable, titl, xrang, fig,type,cols,[] ); 92 | 93 | %% Configiure view area 94 | ax.Title.Visible = 'on'; 95 | ax.Position = [0.12, 0.12, 0.865,.855]; 96 | 97 | %ax.Title.Position = [-4.7,18]; 98 | if strcmp(ylable, 'BER') 99 | ax.YLim = [1e-5,5e-1]; 100 | elseif strcmp(ylable, 'FER') 101 | ax.YLim = [1e-3,1]; 102 | end 103 | 104 | %fig.Position = [0, 0, 1200, 600 ]; 105 | 106 | %% Save file 107 | saveas(fig, 'perSymSNR.eps','epsc' ) 108 | -------------------------------------------------------------------------------- /OTFSvsGFDM/OTFS_LTV.m: -------------------------------------------------------------------------------- 1 | function imp = OTFS_LTV(K, M, Ncp, ChCode, N_run1, SNR, rxType, ChType, fs, fD, seed, Nf) 2 | % Core parameters 3 | rng(seed); 4 | N = M*K; 5 | NB = ChCode.Nb; 6 | 7 | [ K_set, M_set, Wt, ~, ~, rchan, EsN0, N0, imp, params, N_run, N_SNR] = Generate_common_fD( K,M, NB, SNR, N_run1, ChType, fD, fs, 0); 8 | Non = ChCode.Non; 9 | for n_run = 1: N_run(end) 10 | %% generated data 11 | info_bits = zeros(ChCode.Nr_infobits, Nf); 12 | encoded_bits = zeros(ChCode.Ncbpsym,Nf); 13 | qam_data = zeros(ChCode.Non* Nf, NB); 14 | for nf =1:Nf 15 | info_bits(:,nf) = randi([0 1],ChCode.Nr_infobits,1); 16 | [ qam_data((1:Non)+Non*(nf-1),:), encoded_bits(:,nf)] = Encoder(ChCode, info_bits(:,nf)); 17 | end 18 | 19 | Tx.InfoBits = info_bits; 20 | Tx.EncodedBits = encoded_bits; 21 | Tx.Symbols = qam_data(:); 22 | 23 | %% generate noise per run 24 | 25 | v = GenRandomNoise([NB*(N+K*Ncp),1], 1); 26 | Xt_otfs = zeros(M, NB*K); 27 | %% OTFS TX 28 | for nb=1:NB 29 | D = ResourceMap(qam_data(:,nb), K_set, M_set, K,M); 30 | X = GeneralModulator(D, K_set, Wt,'TD'); 31 | Xt_otfs(:, (nb-1)*K+(1:K)) = X; 32 | end 33 | %% OTFS TX ............................... 34 | Tx.Xf = Xt_otfs(:); 35 | Tx.xt = 0; 36 | 37 | Xt_otfs_CP = AddCpCs( Xt_otfs, M, Ncp, 0); 38 | 39 | %% LTV channel 40 | [ He_otfs, Yr_otfs ] = ApplyChannel( rchan, Xt_otfs_CP, Ncp); 41 | %% Evaluate for SNR 42 | for n_snr = 1:N_SNR 43 | if(n_run> N_run(n_snr)) 44 | continue; 45 | else 46 | %% OTFS RX 47 | Yr = Yr_otfs + sqrt(N0(n_snr))*(reshape(v,M+Ncp,K)); 48 | %% remove CP 49 | Yeq = RemoveCpCs( Yr, M, Ncp); 50 | Rx.Xf = Yeq(:); 51 | Rx.Vf = 0; % noise sample 52 | %% channel estimation 53 | He = He_otfs(Ncp+(1:M),:); 54 | Hfe = fft(He); 55 | 56 | qam_data_e = zeros(size(qam_data)); 57 | EsNo_vec = zeros(size(qam_data)); 58 | for nb=0:NB-1 59 | %% combined demodulation equlaization 60 | Wte = Wt.* transpose(Hfe(:,nb*K+(1:K))); 61 | Wre = ReceiveWindow( Wte , rxType, EsN0(n_snr)/K); 62 | D_e = GeneralDemodulator( Yeq(:,nb*K+(1:K)), K_set, Wre, 'TD' ); 63 | 64 | qam_data_e(:,nb+1) = ResourceDemap(D_e, K_set, M_set); 65 | temp = 1/M/EsN0(n_snr)*norm(Wre, 'fro')^2+ 1/N*norm(Wre.*Wte-1,'fro')^2; 66 | EsNo_vec(:,nb+1) = 1/temp ; 67 | end 68 | %% Decoder 69 | bits_e = zeros(ChCode.Nr_infobits, Nf); 70 | encoded_bits_e = zeros(ChCode.Ncbpsym,Nf); 71 | qam_data_e = reshape(qam_data_e, Non, Nf,NB); 72 | EsNo_vec = reshape(EsNo_vec, Non, Nf,NB); 73 | for nf =1:Nf 74 | ChCode.info_bits = info_bits(:,nf); 75 | [ bits_e(:,nf), encoded_bits_e(:,nf)] = Decoder( ChCode, reshape(qam_data_e(:,nf,:),Non*NB,1), reshape(EsNo_vec(:,nf,:),Non*NB,1) ); 76 | end 77 | 78 | Rx.InfoBits = bits_e; 79 | Rx.EncodedBits = encoded_bits_e; 80 | Rx.Symbols = qam_data_e(:); 81 | end 82 | imp{n_snr} = imp{n_snr}.Measure(imp{n_snr}, params,Tx, Rx); 83 | end 84 | end 85 | %% 86 | imp = imp{1}.AverageAndConcatenate(imp); 87 | end 88 | -------------------------------------------------------------------------------- /OTFSvsGFDM/OTFS_LTV_Doppler.m: -------------------------------------------------------------------------------- 1 | function imp = OTFS_LTV_Doppler(K, M, Ncp, ChCode, N_run1, SNR, rxType, ChType, fs, fD, seed, Nf) 2 | % Core parameters 3 | rng(seed); 4 | N = M*K; 5 | NB = ChCode.Nb; 6 | 7 | [ K_set, M_set, Wt, ~, ~, EsN0, N0, imp, params, N_run, N_fD] = Generate_common_Doppler( K,M,NB, SNR, N_run1, fD, 0 ); 8 | Non = ChCode.Non; 9 | for n_fd =1:N_fD 10 | rchan = GenFadingChannel( ChType, fD(n_fd), fs); 11 | for n_run = 1: N_run(n_fd) 12 | info_bits = zeros(ChCode.Nr_infobits, Nf); 13 | encoded_bits = zeros(ChCode.Ncbpsym,Nf); 14 | qam_data = zeros(ChCode.Non* Nf, NB); 15 | for nf =1:Nf 16 | info_bits(:,nf) = randi([0 1],ChCode.Nr_infobits,1); 17 | [ qam_data((1:Non)+Non*(nf-1),:), encoded_bits(:,nf)] = Encoder(ChCode, info_bits(:,nf)); 18 | end 19 | 20 | Tx.InfoBits = info_bits; 21 | Tx.EncodedBits = encoded_bits; 22 | Tx.Symbols = qam_data(:); 23 | 24 | %% generate noise per run 25 | 26 | v = GenRandomNoise([NB*(N+K*Ncp),1], 1); 27 | Xt_otfs = zeros(M, NB*K); 28 | %% OTFS TX 29 | for nb=1:NB 30 | D = ResourceMap(qam_data(:,nb), K_set, M_set, K,M); 31 | X = GeneralModulator(D, K_set, Wt,'TD'); 32 | Xt_otfs(:, (nb-1)*K+(1:K)) = X; 33 | end 34 | %% OTFS TX ............................... 35 | Tx.Xf = Xt_otfs(:); 36 | Tx.xt = 0; 37 | 38 | Xt_otfs_CP = AddCpCs( Xt_otfs, M, Ncp, 0); 39 | 40 | %% LTV channel 41 | [ He_otfs, Yr_otfs ] = ApplyChannel( rchan, Xt_otfs_CP, Ncp); 42 | 43 | 44 | %% OTFS RX 45 | Yr = Yr_otfs + sqrt(N0)*(reshape(v,M+Ncp,K)); 46 | %% remove CP 47 | Yeq = RemoveCpCs( Yr, M, Ncp); 48 | Rx.Xf = Yeq(:); 49 | Rx.Vf = 0; % noise sample 50 | %% channel estimation 51 | He = He_otfs(Ncp+(1:M),:); 52 | Hfe = fft(He); 53 | 54 | qam_data_e = zeros(size(qam_data)); 55 | EsNo_vec = zeros(size(qam_data)); 56 | for nb=0:NB-1 57 | %% combined demodulation equlaization 58 | Wte = Wt.* transpose(Hfe(:,nb*K+(1:K))); 59 | Wre = ReceiveWindow( Wte , rxType, EsN0/K); 60 | D_e = GeneralDemodulator( Yeq(:,nb*K+(1:K)), K_set, Wre, 'TD' ); 61 | 62 | qam_data_e(:,nb+1) = ResourceDemap(D_e, K_set, M_set); 63 | temp = 1/M/EsN0*norm(Wre, 'fro')^2+ 1/N*norm(Wre.*Wte-1,'fro')^2; 64 | EsNo_vec(:,nb+1) = 1/temp ; 65 | end 66 | %% Decoder 67 | bits_e = zeros(ChCode.Nr_infobits, Nf); 68 | encoded_bits_e = zeros(ChCode.Ncbpsym,Nf); 69 | qam_data_e = reshape(qam_data_e, Non, Nf,NB); 70 | EsNo_vec = reshape(EsNo_vec, Non, Nf,NB); 71 | for nf =1:Nf 72 | ChCode.info_bits = info_bits(:,nf); 73 | [ bits_e(:,nf), encoded_bits_e(:,nf)] = Decoder( ChCode, reshape(qam_data_e(:,nf,:),Non*NB,1), reshape(EsNo_vec(:,nf,:),Non*NB,1) ); 74 | end 75 | 76 | Rx.InfoBits = bits_e; 77 | Rx.EncodedBits = encoded_bits_e; 78 | Rx.Symbols = qam_data_e(:); 79 | imp{n_fd} = imp{n_fd}.Measure(imp{n_fd}, params,Tx, Rx); 80 | end 81 | end 82 | %% 83 | imp = imp{1}.AverageAndConcatenate(imp); 84 | end 85 | 86 | -------------------------------------------------------------------------------- /OTFSvsGFDM/TC/Doppler_1504_GFDM-short-TC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/TC/Doppler_1504_GFDM-short-TC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/TC/Doppler_1504_OFDM-short-TC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/TC/Doppler_1504_OFDM-short-TC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/TC/Doppler_1504_OTFS-short-TC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/TC/Doppler_1504_OTFS-short-TC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/TC/LTV_1404_GFDM-long-TC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/TC/LTV_1404_GFDM-long-TC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/TC/LTV_1404_GFDM-short-TC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/TC/LTV_1404_GFDM-short-TC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/TC/LTV_1404_OFDM-long-TC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/TC/LTV_1404_OFDM-long-TC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/TC/LTV_1404_OFDM-short-TC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/TC/LTV_1404_OFDM-short-TC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/TC/LTV_1404_OTFS-long-TC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/TC/LTV_1404_OTFS-long-TC-1-2.mat -------------------------------------------------------------------------------- /OTFSvsGFDM/TC/LTV_1404_OTFS-short-TC-1-2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/OTFSvsGFDM/TC/LTV_1404_OTFS-short-TC-1-2.mat -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Generalized-GFDM-Framework- 2 | Reference implementation of GFDM framework 3 | -------------------------------------------------------------------------------- /Setup.m: -------------------------------------------------------------------------------- 1 | 2 | addpath('CoreLib'); 3 | addpath('CoreLib/test'); 4 | 5 | addpath('VIsualization'); 6 | addpath('cml'); 7 | cd cml 8 | CmlStartup; 9 | cd .. -------------------------------------------------------------------------------- /VIsualization/CompareMeasure.m: -------------------------------------------------------------------------------- 1 | function [meas_plot, ax] = CompareMeasure( Y, x, Leg_cell,xlable, ylable, titl, xrang, fig, type, cols, mark) 2 | Nw = size(Y,2); 3 | x = x(:); 4 | % figure settings 5 | 6 | ax = axes('Parent', fig); 7 | width = 1; 8 | fsize = 14; 9 | fname = 'Times New Roman'; 10 | if strcmp(type, 'semilog') 11 | meas_plot = semilogy(x,Y, 'Parent',ax,'LineWidth', width); 12 | else 13 | meas_plot = plot(x,Y, 'Parent',ax,'LineWidth', width); 14 | end 15 | set(ax,'FontSize',fsize,'FontName','Times New Roman'); 16 | 17 | for nw = 1: Nw 18 | meas_plot(nw).Color = cols{mod(nw-1,Nw)+1}; 19 | if ~isempty(mark ) 20 | meas_plot(nw).Marker = mark{mod(nw-1,Nw)+1}; 21 | end 22 | end 23 | grid(ax,'on'); 24 | ax.XLim = xrang; 25 | legend(ax,Leg_cell,'FontName',fname,'Interpreter', 'latex' ,'Location','southwest'); 26 | ax.XLabel = xlabel(ax, xlable,'FontName',fname,'Interpreter', 'latex'); 27 | ax.YLabel = ylabel (ax,ylable,'FontName',fname,'Interpreter', 'latex'); 28 | ax.Title = title (ax,titl,'FontName',fname,'Interpreter', 'latex'); 29 | 30 | ax.Title.Rotation = 0; 31 | ax.Title.HorizontalAlignment = 'left'; 32 | ax.FontSize = fsize; 33 | ax.GridAlpha = 0.05; 34 | ax.GridColor = [.08 .08 .08]; 35 | 36 | 37 | -------------------------------------------------------------------------------- /VIsualization/ComparePSD.m: -------------------------------------------------------------------------------- 1 | function [psd_plot] = ComparePSD( Af_cell, Leg_cell, U, M, R, fig, xrang) 2 | % R resolution R/N 3 | % M subcarrier spacing in samples 4 | % U upsampling 5 | 6 | Nw = length(Af_cell); 7 | [N, Non] = size(Af_cell{1}); 8 | NU = N*U; 9 | n_in = -N/2:N/2-1; 10 | S = zeros(NU*R,Nw); 11 | for nw = 1: Nw 12 | AfU = zeros(NU, Non); 13 | % upsampling considering FFT interpolation which is accurate if 14 | AfU(mod(n_in, NU)+1,:) = Af_cell{nw}(mod(n_in, N)+1,:); 15 | AU = sqrt(U)*ifft(AfU); 16 | S(:,nw) = 10*log10(fftshift(Psd_th( AU, R))); 17 | end 18 | k=((0:U*R*N-1)-U*R*N/2)/M/R; % subcarrier index 19 | K = N/M; 20 | % figure settings 21 | cols = {'b','r','m','k'}; 22 | ax = axes('Parent', fig); 23 | width = 1; 24 | fsize = 14; 25 | fname = 'Times New Roman'; 26 | psd_plot = plot(k,S, 'Parent',ax,'LineWidth', width); 27 | set(ax,'FontSize',fsize,'FontName','Times New Roman'); 28 | ax.Position = [0.105, 0.130, .88,.87]; 29 | for nw = 1: Nw 30 | psd_plot(nw).Color = cols{mod(nw-1,4)+1}; 31 | 32 | end 33 | grid(ax,'on'); 34 | ax.XLim = xrang; 35 | ax.XTick = xrang(1):xrang(2); 36 | ax.YLim = [-80,1]; 37 | legend(ax,Leg_cell,'FontName',fname); 38 | ax.XLabel = xlabel(ax,'Subcarrier index ','FontName',fname); 39 | ax.YLabel = ylabel (ax,'PSD[dB]','FontName',fname); 40 | ax.FontSize = fsize; 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /cml/CmlStartup.m: -------------------------------------------------------------------------------- 1 | % CmlStartup 2 | % 3 | % Initializes the Coded Modulation Library 4 | % 5 | % Last updated Sep. 9, 2007 6 | 7 | % determine the version of matlab version 8 | version_text = version; 9 | if ( str2num( version_text(1) ) > 6) 10 | save_flag = '-v6'; 11 | else 12 | save_flag = '-mat'; 13 | end 14 | 15 | % determine the home directory 16 | cml_home = pwd; 17 | 18 | if ispc 19 | % setup the path 20 | addpath( strcat( cml_home, '\mex'), ... 21 | strcat( cml_home, '\mat'), ... 22 | strcat( cml_home, '\matalt' ), ... 23 | strcat( cml_home, '\mexhelp'), ... 24 | strcat( cml_home, '\demos' ), ... 25 | strcat( cml_home, '\scenarios'), ... 26 | strcat( cml_home, '\localscenarios'),... 27 | strcat( cml_home, '\data\interleavers'), ... 28 | strcat( cml_home, '\data\ldpc'), ... 29 | strcat( cml_home, '\data\tables'), ... 30 | strcat( cml_home, '\data\bandwidth') ); 31 | 32 | % if CML grid is installed 33 | if exist( '.\grid\mat' ) 34 | addpath( strcat( cml_home, '\grid\mat' ) ); 35 | end 36 | 37 | % save the home directory 38 | save_directory = strcat( cml_home, '\scenarios\CmlHome.mat' ); 39 | else 40 | % setup the path 41 | addpath( strcat( cml_home, '/mex'), ... 42 | strcat( cml_home, '/mat'), ... 43 | strcat( cml_home, '/matalt' ), ... 44 | strcat( cml_home, '/mexhelp'), ... 45 | strcat( cml_home, '/demos' ), ... 46 | strcat( cml_home, '/scenarios'), ... 47 | strcat( cml_home, '/localscenarios'),... 48 | strcat( cml_home, '/data/interleavers'), ... 49 | strcat( cml_home, '/data/ldpc'), ... 50 | strcat( cml_home, '/data/tables'), ... 51 | strcat( cml_home, '/data/bandwidth') ); 52 | 53 | % if CML grid is installed 54 | if exist( './grid/mat' ) 55 | addpath( strcat( cml_home, '/grid/mat' ) ); 56 | end 57 | 58 | % save the home directory 59 | save_directory = strcat( cml_home, '/scenarios/CmlHome.mat' ); 60 | end 61 | 62 | save( save_directory, save_flag, 'cml_home' ); -------------------------------------------------------------------------------- /cml/data/bandwidth/BW99percent.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/data/bandwidth/BW99percent.mat -------------------------------------------------------------------------------- /cml/data/bandwidth/cal_bandwidth.m: -------------------------------------------------------------------------------- 1 | function BwMatrix = cal_bandwidth(sim_M_vec, sim_h_vec, percent, precision, filename) 2 | 3 | % some constants 4 | infinity = 100000; 5 | epsilon = 1e-4; 6 | target_tail = (1-percent)*0.5; 7 | 8 | % append .mat to filename, if necessary 9 | if ~strcmpi( filename( (length(filename)-3):length(filename)), '.mat' ) 10 | filename=[filename,'.mat']; 11 | end 12 | 13 | BwMatrix = zeros(0,3); 14 | % read in the previously saved file 15 | if ( fopen( filename ) > 0 ) 16 | load( filename ) 17 | end 18 | 19 | Mtotal = length( sim_M_vec ); 20 | htotal = length( sim_h_vec ); 21 | 22 | % update the BwMatrix with new entries 23 | BwMatrixCount = size( BwMatrix, 1 ); 24 | 25 | for m_count=1:Mtotal 26 | for h_count=1:htotal 27 | 28 | % see if this entry already exists in the database 29 | M_values = find( BwMatrix(:,1) == sim_M_vec( m_count ) ); 30 | h_values = find( abs(BwMatrix(:,2) - sim_h_vec( h_count ) ) < epsilon); 31 | Matching_row = min( intersect( M_values, h_values ) ); 32 | 33 | if ( length( Matching_row ) ) 34 | % row exists 35 | fprintf( 'An entry exists of M = %d and h = %f\n', sim_M_vec(m_count), sim_h_vec(h_count) ); 36 | else 37 | % need to make a new row in the matrix 38 | BwMatrixCount = BwMatrixCount + 1; 39 | BwMatrix( BwMatrixCount, : ) = [ sim_M_vec( m_count ) sim_h_vec( h_count ) -1 ]; 40 | end 41 | end 42 | end 43 | 44 | 45 | % Sort the Matrix 46 | maxM = max( BwMatrix(:,1) ); 47 | 48 | BwMatrixSorted = []; 49 | for mu_count = 1:log2( maxM ) 50 | M = 2^mu_count; 51 | M_values = find( BwMatrix(:,1) == M ); 52 | TempMatrix = BwMatrix( M_values, : ); 53 | [temp,sort_index] = sort( TempMatrix(:,2) ); 54 | BwMatrixSorted = [BwMatrixSorted 55 | TempMatrix(sort_index,:) ]; 56 | end 57 | 58 | BwMatrix = BwMatrixSorted; 59 | 60 | % compute each entry 61 | for ( BwMatrixCount = 1:length( BwMatrix ) ) 62 | if ( BwMatrix( BwMatrixCount, 3 ) <= 0 ) 63 | % entry has not been computed yet 64 | M = BwMatrix(BwMatrixCount,1); 65 | h = BwMatrix(BwMatrixCount,2); 66 | 67 | fprintf( 'Calculating M=%d and h=%f\n', M, h ); 68 | 69 | if (h>0.99) 70 | % need logic to handle h as it approaches 1. 71 | else 72 | % approximate the integral as a summation 73 | power = 0.5*specfun(0,M,h)*precision; % only take half the power at f=0 74 | PSDcounter = 1; 75 | while ( 2*power <= percent ) 76 | f = precision*PSDcounter; 77 | power = power + specfun( f, M, h )*precision; 78 | PSDcounter = PSDcounter + 1; 79 | end 80 | BwMatrix(BwMatrixCount,3) = 2*(f-precision); 81 | end 82 | 83 | save( filename, 'BwMatrix' ); 84 | 85 | 86 | end 87 | end 88 | 89 | 90 | -------------------------------------------------------------------------------- /cml/data/bandwidth/specfun.m: -------------------------------------------------------------------------------- 1 | function y = specfun(x,M,h) 2 | 3 | 4 | fei = sin(pi*M*h)/M/sin(pi*h); 5 | y=0; 6 | for n =1 : M 7 | y = y + 1/M * (sinc( x - 0.5*( 2*n -1-M)*h)).^2; 8 | for m = 1:M 9 | alpha(n,m) = pi*h*( m+ n-1-M); 10 | B = (cos( 2*pi*x - alpha(n,m) ) - fei*cos( alpha(n,m)) )./( 1+ fei^2 - 2*fei*cos(2*pi*x)); 11 | y = y + 2/M/M * (sinc( x - 0.5*( 2*n -1-M)*h)).*(sinc( x - 0.5*( 2*m -1-M)*h)).*B; 12 | end 13 | end 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /cml/data/tables/Jtable.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/data/tables/Jtable.mat -------------------------------------------------------------------------------- /cml/documentation/CMLoverview.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/documentation/CMLoverview.pdf -------------------------------------------------------------------------------- /cml/documentation/readme.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/documentation/readme.pdf -------------------------------------------------------------------------------- /cml/documentation/~$readme.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/documentation/~$readme.doc -------------------------------------------------------------------------------- /cml/documentation/~WRL1980.tmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/documentation/~WRL1980.tmp -------------------------------------------------------------------------------- /cml/mat/BitCollection.m: -------------------------------------------------------------------------------- 1 | function y = BitCollection( systematic_t, parity_1_t, parity_2_t, N_row ) 2 | % BitCollection performs the bit collection operation (used in HSDPA encoder) 3 | % 4 | % The calling syntax is: 5 | % y = BitCollection( systematic_t, parity_1_t, parity_2_t, N_row ) 6 | % 7 | % y = the punctured codeword formed by collecting the systematic and parity bits 8 | % 9 | % systematic_t = the punctured systematic bits 10 | % parity_1_t = the punctured upper parity bits 11 | % parity_2_t = the punctured lower parity bits 12 | % N_row = Number of rows in the internal matrix (2 for QPSK and 4 for QAM) 13 | % 14 | % Copyright (C) 2005, Matthew C. Valenti 15 | % 16 | % Last updated on Dec. 13, 2005 17 | % 18 | % Function BitCollection is part of the Iterative Solutions Coded Modulation 19 | % Library (ISCML). 20 | % 21 | % The Iterative Solutions Coded Modulation Library is free software; 22 | % you can redistribute it and/or modify it under the terms of 23 | % the GNU Lesser General Public License as published by the 24 | % Free Software Foundation; either version 2.1 of the License, 25 | % or (at your option) any later version. 26 | % 27 | % This library is distributed in the hope that it will be useful, 28 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 29 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 30 | % Lesser General Public License for more details. 31 | % 32 | % You should have received a copy of the GNU Lesser General Public 33 | % License along with this library; if not, write to the Free Software 34 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 35 | 36 | % calculate constant values 37 | N_t_sys = length( systematic_t ); 38 | N_t_p1 = length( parity_1_t ); 39 | N_t_p2 = length( parity_2_t ); 40 | 41 | % more constant values 42 | N_data = N_t_sys + N_t_p1 + N_t_p2; 43 | N_col = N_data/N_row; 44 | N_r = floor( N_t_sys/N_col ); 45 | N_c = N_t_sys - N_r*N_col; 46 | 47 | % initialize the internal matrix 48 | w = zeros( N_row, N_col ); 49 | 50 | % feed in systematic bits 51 | if (N_t_sys > 0) % are there any systematic bits? 52 | if (N_c == 0) 53 | w(1:N_r,:) = reshape( systematic_t, N_r, N_col ); 54 | else 55 | w(1:N_r+1,1:N_c) = reshape( systematic_t(1:N_c*(N_r+1) ), N_r+1, N_c ); 56 | w(1:N_r, N_c+1:N_col ) = reshape( systematic_t( N_c*(N_r+1)+1:N_t_sys), N_r, N_col - N_c ); 57 | end 58 | end 59 | 60 | % feed in parity bits 61 | if ( (N_t_p1+N_t_p2) > 0 ) % are there any parity bits? 62 | parity_temp(1,:) = parity_2_t(1:N_t_p1); 63 | parity_temp(2,:) = parity_1_t; 64 | 65 | parity = reshape( parity_temp, 1, 2*N_t_p1 ); 66 | if ( N_t_p2 > N_t_p1 ) 67 | parity( N_t_p1 + N_t_p2 ) = parity_2_t( N_t_p2 ); 68 | end 69 | 70 | if (N_c == 0) 71 | w(N_r+1:N_row,:) = reshape( parity, N_row-N_r, N_col ); 72 | else 73 | if (N_row > N_r+1) 74 | w(N_r+2:N_row,1:N_c) = reshape( parity(1:N_c*(N_row-N_r-1)), N_row-N_r-1, N_c ); 75 | end 76 | w(N_r+1:N_row,N_c+1:N_col) = reshape( parity( N_c*(N_row-N_r-1)+1:N_t_p1+N_t_p2), N_row-N_r, N_col-N_c ); 77 | end 78 | end 79 | 80 | % form the codeword as a row vector 81 | y = reshape( w, 1, N_data ); 82 | 83 | 84 | -------------------------------------------------------------------------------- /cml/mat/BitDecollection.m: -------------------------------------------------------------------------------- 1 | function [systematic_t, parity_1_t, parity_2_t] = BitDecollection( x, N_row, s, N_TTI, N_IR ); 2 | % BitDecollection reverses the bit collection operation (used in HSDPA decoder) 3 | % 4 | % The calling syntax is: 5 | % [systematic_t, parity_1_t, parity_2_t] = BitDecollection( x, N_row, s, N_TTI, N_IR ); 6 | % 7 | % systematic_t = the punctured systematic bits 8 | % parity_1_t = the punctured upper parity bits 9 | % parity_2_t = the punctured lower parity bits 10 | % 11 | % x = the received, punctured codeword 12 | % N_row = Number of rows in the internal matrix (2 for QPSK and 4 for QAM) 13 | % s = RV flag that determines if priority placed on systematic (1) or parity (0) bits 14 | % N_TTI = Length of the unpunctured turbo codeword 15 | % N_IR = Size of the virtual IR buffer 16 | % 17 | % Copyright (C) 2005, Matthew C. Valenti 18 | % 19 | % Last updated on Dec. 13, 2005 20 | % 21 | % Function BitDecollection is part of the Iterative Solutions Coded Modulation 22 | % Library (ISCML). 23 | % 24 | % The Iterative Solutions Coded Modulation Library is free software; 25 | % you can redistribute it and/or modify it under the terms of 26 | % the GNU Lesser General Public License as published by the 27 | % Free Software Foundation; either version 2.1 of the License, 28 | % or (at your option) any later version. 29 | % 30 | % This library is distributed in the hope that it will be useful, 31 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 32 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 33 | % Lesser General Public License for more details. 34 | % 35 | % You should have received a copy of the GNU Lesser General Public 36 | % License along with this library; if not, write to the Free Software 37 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 38 | 39 | % calculate constant values 40 | N_data = length( x ); 41 | N_sys = N_TTI/3; % N_sys should be multiple of 3. 42 | 43 | % Figure out N_p1 and N_p2 44 | N_p1 = floor( (N_IR - N_sys)/2 ); 45 | N_p2 = ceil( (N_IR - N_sys)/2 ); 46 | 47 | % more parameter 48 | if (s==1) 49 | N_t_sys = min( N_sys, N_data ); 50 | else 51 | N_t_sys = max( N_data - (N_p1+N_p2), 0 ); 52 | end 53 | N_t_p1 = floor( (N_data - N_t_sys)/2 ); 54 | N_t_p2 = ceil( (N_data-N_t_sys)/2 ); 55 | 56 | % more constant values 57 | N_col = N_data/N_row; 58 | N_r = floor( N_t_sys/N_col ); 59 | N_c = N_t_sys - N_r*N_col; 60 | 61 | % initialize storage 62 | if (N_t_sys > 0) 63 | systematic_t = zeros(1,N_t_sys); 64 | else 65 | systematic_t = []; 66 | end 67 | 68 | parity_temp = zeros(1,N_t_p1+N_t_p2); 69 | y = reshape( x, N_row, N_col ); 70 | 71 | % extract systematic bits 72 | if (N_t_sys > 0) % are there any systematic bits? 73 | if (N_c == 0) 74 | % First N_r rows are the systematic bits 75 | systematic_t = reshape( y(1:N_r,:), 1, N_t_sys ); 76 | else 77 | % First N_c columns contain systematic bits in first N_r + 1 rows 78 | systematic_t(1:N_c*(N_r+1)) = reshape( y(1:N_r+1,1:N_c), 1, N_c*(N_r+1) ); 79 | % Remaining columns contain systematic bits in first N_r rows 80 | systematic_t(N_c*(N_r+1)+1:N_t_sys) = reshape( y(1:N_r,N_c+1:N_col), 1, N_r*(N_col-N_c) ); 81 | end 82 | end 83 | 84 | % extract parity bits 85 | if ( N_t_p1 + N_t_p2 > 0 ) % are there any parity bits? 86 | if (N_c == 0) 87 | % Last N_row-N_r rows are the parity bits 88 | parity_temp = reshape( y(N_r+1:N_row,:), 1, N_t_p1 + N_t_p2 ); 89 | else 90 | if (N_row > N_r+1) 91 | % First N_c columns contain parity bits in last N_row-N_r-1 rows (if they exist) 92 | parity_temp(1:N_c*(N_row-N_r-1) ) = reshape( y(N_r+2:N_row,1:N_c), 1, N_c*(N_row-N_r-1) ); 93 | end 94 | % Last N_col-N_c columns contain parity bits in last N_row-N_r rows 95 | parity_temp(N_c*(N_row-N_r-1)+1:N_t_p1+N_t_p2 ) = reshape( y(N_r+1:N_row,N_c+1:N_col), 1, (N_col-N_c)*(N_row-N_r) ); 96 | end 97 | end 98 | 99 | % create parity streams 100 | parity = reshape( parity_temp(1:2*N_t_p1), 2, N_t_p1 ); 101 | parity_1_t = parity(2,:); 102 | parity_2_t = parity(1,:); 103 | parity_2_t(N_t_p2) = parity_temp(N_t_p1+N_t_p2); 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /cml/mat/BtcEncode.m: -------------------------------------------------------------------------------- 1 | function codeword = BtcEncode( data, grows, gcolumns, k_per_row, k_per_column, B, Q ) 2 | % BTCEncode encodes a data sequence using a block turbo encoder. 3 | % 4 | % The calling syntax is: 5 | % codeword = BtcEncode( data, grows, gcolumns, k_per_row, k_per_column, B, Q ) 6 | % 7 | % codeword = the codeword generated by the encoder, 8 | % 9 | % data = the row vector of data bits 10 | % grows = the generator used to encode the rows 11 | % gcolumns = the generator used to encode the columns 12 | % k_per_row = number of data bits per row 13 | % k_per_column = number of data bits per column 14 | % B = number of zeros padded before data but not transmitted 15 | % Q = number of zeros padded before data and transmitted 16 | % 17 | % Copyright (C) 2008, Matthew C. Valenti and Sushma Mamidipaka 18 | % 19 | % Last updated on May 22, 2008 20 | % 21 | % Function BtcEncode is part of the Iterative Solutions Coded Modulation 22 | % Library (ISCML). 23 | % 24 | % The Iterative Solutions Coded Modulation Library is free software; 25 | % you can redistribute it and/or modify it under the terms of 26 | % the GNU Lesser General Public License as published by the 27 | % Free Software Foundation; either version 2.1 of the License, 28 | % or (at your option) any later version. 29 | % 30 | % This library is distributed in the hope that it will be useful, 31 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 32 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 33 | % Lesser General Public License for more details. 34 | % 35 | % You should have received a copy of the GNU Lesser General Public 36 | % License along with this library; if not, write to the Free Software 37 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 38 | 39 | % create a matrix of data bits padded with B+Q zeros at the beginning 40 | padded_data = [zeros( 1, B+Q ) data]; 41 | 42 | % turn data into rectangular matrix 43 | data_matrix = reshape( padded_data, k_per_row, k_per_column )'; 44 | 45 | % Encode each row 46 | for i=1:k_per_column 47 | encoded_rows(i,:) = ConvEncode( data_matrix(i,:), grows, 0); 48 | end 49 | 50 | % Encode each column 51 | for i=1:size( encoded_rows, 2 ) 52 | encoded_columns(:,i)=ConvEncode( encoded_rows(:,i)', gcolumns, 0)'; 53 | end 54 | 55 | % Turn into a row vector 56 | codeword = reshape( encoded_columns', 1, prod( size( encoded_columns ) ) ); 57 | 58 | % Strip out first B bits of codeword 59 | codeword = codeword( B+1:length(codeword) ); 60 | -------------------------------------------------------------------------------- /cml/mat/CalculateMinSNRvsB.m: -------------------------------------------------------------------------------- 1 | function [sim_param, sim_state] = CalculateMinSNRvsB( sim_param, sim_state ) 2 | % CalculateMinSNRvsB determines the minimum SNR as a function of BW 3 | % constraint B. 4 | % 5 | % The calling syntax is: 6 | % [sim_param, sim_state] = CalculateMinSNRvsB(( sim_param, sim_state ) 7 | % 8 | % Required inputs/outputs: 9 | % sim_param = A structure containing simulation parameters. 10 | % 11 | % Required output 12 | % sim_state = A structure containing the simulation state. 13 | % 14 | % Required input 15 | % code_param = A structure contining derived information. 16 | % 17 | % Note: See readme.txt for a description of the structure formats. 18 | % 19 | % Copyright (C) 2006-2007, Matthew C. Valenti 20 | % 21 | % Last updated on Oct. 12, 2007 22 | % 23 | % Function CalculateMinSNR is part of the Iterative Solutions Coded Modulation 24 | % Library (ISCML). 25 | % 26 | % The Iterative Solutions Coded Modulation Library is free software; 27 | % you can redistribute it and/or modify it under the terms of 28 | % the GNU Lesser General Public License as published by the 29 | % Free Software Foundation; either version 2.1 of the License, 30 | % or (at your option) any later version. 31 | % 32 | % This library is distributed in the hope that it will be useful, 33 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 34 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 35 | % Lesser General Public License for more details. 36 | % 37 | % You should have received a copy of the GNU Lesser General Public 38 | % License along with this library; if not, write to the Free Software 39 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 40 | 41 | % read in the simulation results 42 | [read_param, read_state] = ReadScenario( sim_param.input_filename, sim_param.scenarios, [] ); 43 | number_records = length( sim_param.scenarios ); 44 | 45 | % go through each record 46 | for record=1:number_records 47 | 48 | sim_param.bwconstraint(record) = read_param(record).bwconstraint; 49 | 50 | % determine the minimum Eb/No 51 | [value, index] = min( read_state(record).min_EbNodB ); 52 | if ( length(index) > 0 ) 53 | sim_state.min_EbNodB(record) = read_state(record).min_EbNodB(index(1)); 54 | sim_param.h(record) = read_param(record).h(index(1)); 55 | sim_state.best_rate(record) = read_state(record).best_rate(index(1)); 56 | else 57 | sim_state.min_EbNodB(record) = NaN; 58 | sim_param.h(record) = NaN; 59 | sim_state.best_rate(record) = NaN; 60 | end 61 | end 62 | 63 | % save results 64 | save_state = sim_state; 65 | save_param = sim_param; 66 | save( code_param.filename, code_param.save_flag, 'save_state', 'save_param'); 67 | 68 | 69 | -------------------------------------------------------------------------------- /cml/mat/CalculateThroughput.m: -------------------------------------------------------------------------------- 1 | function [sim_param, sim_state] = CalculateThroughput( sim_param, sim_state, code_param ) 2 | % CalculateThroughput determines the throughput of hybrid-ARQ 3 | % 4 | % The calling syntax is: 5 | % sim_param, sim_state] = CalculateThroughput( sim_param, sim_state ) 6 | % 7 | % Required inputs/outputs: 8 | % sim_param = A structure containing simulation parameters. 9 | % 10 | % Required output 11 | % sim_state = A structure containing the simulation state. 12 | % 13 | % Required input 14 | % code_param = A structure contining derived information. 15 | % 16 | % Note: See readme.txt for a description of the structure formats. 17 | % 18 | % Copyright (C) 2005-2007, Matthew C. Valenti 19 | % 20 | % Last updated on Oct. 12, 2007 21 | % 22 | % Function CalculateThroughput is part of the Iterative Solutions Coded Modulation 23 | % Library (ISCML). 24 | % 25 | % The Iterative Solutions Coded Modulation Library is free software; 26 | % you can redistribute it and/or modify it under the terms of 27 | % the GNU Lesser General Public License as published by the 28 | % Free Software Foundation; either version 2.1 of the License, 29 | % or (at your option) any later version. 30 | % 31 | % This library is distributed in the hope that it will be useful, 32 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 33 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 34 | % Lesser General Public License for more details. 35 | % 36 | % You should have received a copy of the GNU Lesser General Public 37 | % License along with this library; if not, write to the Free Software 38 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 39 | 40 | % read in the simulation results 41 | [read_param, read_state] = ReadScenario( sim_param.input_filename, sim_param.scenarios ); 42 | number_records = length( sim_param.scenarios ); 43 | 44 | % initialize 45 | sim_param.SNR_type = 'Es/No in dB'; 46 | sim_param.SNR = read_param(1).SNR; 47 | 48 | for record=1:number_records 49 | % make SNR is stored as Es/No 50 | if ( read_param(record).SNR_type(2) ~= 's' ) 51 | error( 'SNR type must be Es/No in dB' ); 52 | end 53 | 54 | % make sure all the simulations have the same SNR values 55 | if sum( read_param(record).SNR ~= sim_param.SNR ) 56 | error( 'All records must have the same SNR vector' ); 57 | end 58 | 59 | end 60 | 61 | % create a cmf matrix 62 | fer = zeros( number_records, length( sim_param.SNR ) ); 63 | pmf = fer; 64 | blocks = fer; 65 | sim_state.throughput = zeros(1,length(sim_param.SNR)); 66 | 67 | for (m=1:number_records) 68 | % assume SNR vectors are the same 69 | [FER_rows, FER_cols] = size( read_state(m).FER ); 70 | fer(m,:) = read_state(m).FER( FER_rows, : ); 71 | pmf(m,:) = (1-fer(m,:)).*prod( fer(1:m-1,:), 1 ); 72 | blocks(m,:) = m*pmf(m,:); 73 | end 74 | 75 | % this is for numerical stability (avoids NaN due to divide by zero) 76 | temp_indices = find( sum(blocks) ); 77 | 78 | sim_state.throughput(temp_indices) = (1-fer(number_records, temp_indices )).^2./sum(blocks(:,temp_indices)); 79 | 80 | % save results 81 | save_state = sim_state; 82 | save_param = sim_param; 83 | save( code_param.filename, code_param.save_flag, 'save_state', 'save_param'); 84 | 85 | 86 | -------------------------------------------------------------------------------- /cml/mat/CmlChannel.m: -------------------------------------------------------------------------------- 1 | function [symbol_likelihood] = CmlChannel( s, sim_param, code_param, EsNo ) 2 | % CmlChannel sends the signal vector s over a channel, resulting in 3 | % sufficient statistics in symbol_likelihood 4 | % 5 | % The calling syntax is: 6 | % [symbol_likelihood] = CmlChannel( s, sim_param, code_param, EsNo ) 7 | % 8 | % symbol_likelihood = M row matrix of likelihoods 9 | % s = a row vector containing encoded/modulated symbols 10 | % sim_param = A structure containing simulation parameters. 11 | % code_param = A structure containing the code paramaters. 12 | % EsNo = Ratio of Es/No (linear units -- not dB). 13 | % 14 | % Copyright (C) 2006, Matthew C. Valenti 15 | % 16 | % Last updated on May 6, 2006 17 | % 18 | % Function CmlChannel is part of the Iterative Solutions Coded Modulation 19 | % Library (ISCML). 20 | % 21 | % The Iterative Solutions Coded Modulation Library is free software; 22 | % you can redistribute it and/or modify it under the terms of 23 | % the GNU Lesser General Public License as published by the 24 | % Free Software Foundation; either version 2.1 of the License, 25 | % or (at your option) any later version. 26 | % 27 | % This library is distributed in the hope that it will be useful, 28 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 29 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 30 | % Lesser General Public License for more details. 31 | % 32 | % You should have received a copy of the GNU Lesser General Public 33 | % License along with this library; if not, write to the Free Software 34 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 35 | 36 | % determine the noise variance 37 | variance = 1/(2*EsNo); 38 | 39 | % create the fading coefficients 40 | if (code_param.channel_type==1) % Ergodic Rayleigh fading 41 | a = sqrt(0.5)*( randn( 1, code_param.symbols_per_frame) + j*randn( 1, code_param.symbols_per_frame) ); 42 | elseif ( code_param.channel_type==2 ) % Rayleigh block fading 43 | for block_count=1:sim_param.blocks_per_frame 44 | a( (block_count-1)*code_param.symbols_per_block+1: block_count*code_param.symbols_per_block) = sqrt(0.5)*(randn(1,1) + j*randn(1,1))*ones(1, code_param.symbols_per_block ); 45 | end 46 | else % AWGN 47 | a = ones(1,code_param.symbols_per_frame); 48 | end 49 | 50 | % Add noise and then demodulate 51 | if (code_param.bpsk) % BPSK 52 | noise = sqrt(variance)*randn(1, code_param.symbols_per_frame ); 53 | r = abs(a).*s + noise; 54 | symbol_likelihood = -2*r.*abs(a)/variance; % This is the LLR 55 | elseif (code_param.fsk) % FSK 56 | % repeat fading coefficient since this is a multidimensional modulation 57 | for i=1:sim_param.mod_order 58 | a_matrix(i,:) = a; 59 | end 60 | 61 | % permutation matrix, to handle non-natural mappings. 62 | perm_matrix( code_param.mapping + 1, : ) = eye( sim_param.mod_order ); 63 | 64 | noise = sqrt(variance)*( randn(sim_param.mod_order,code_param.symbols_per_frame) + j*randn(sim_param.mod_order,code_param.symbols_per_frame) ); 65 | r = a_matrix.*s + code_param.fil_noise*noise; 66 | symbol_likelihood = DemodFSK( perm_matrix*r, EsNo, sim_param.csi_flag, a ); 67 | 68 | else 69 | % Complex modulation 70 | noise = sqrt(variance)*( randn(1,code_param.symbols_per_frame) + j*randn(1,code_param.symbols_per_frame) ); % complex noise 71 | r = a.*s + noise; 72 | symbol_likelihood = Demod2D( r, code_param.S_matrix, EsNo, a ); 73 | end -------------------------------------------------------------------------------- /cml/mat/CmlEncode.m: -------------------------------------------------------------------------------- 1 | function [s, codeword] = CmlEncode( data, sim_param, code_param ) 2 | % CmlEncode encodes and modulates a single codeword 3 | % 4 | % The calling syntax is: 5 | % [s, codeword] = CmlEncode( data, sim_param, code_param ) 6 | % 7 | % Outputs: 8 | % s = a row vector containing encoded and modulated symbols 9 | % codeword = the codeword generated by the encoder 10 | % 11 | % Required inputs: 12 | % data = the row vector of data bits 13 | % sim_param = A structure containing simulation parameters. 14 | % code_param = A structure containing the code paramaters. 15 | % 16 | % Copyright (C) 2005-2008, Matthew C. Valenti 17 | % 18 | % Last updated on May 22, 2008 19 | % 20 | % Function CmlEncode is part of the Iterative Solutions Coded Modulation 21 | % Library (ISCML). 22 | % 23 | % The Iterative Solutions Coded Modulation Library is free software; 24 | % you can redistribute it and/or modify it under the terms of 25 | % the GNU Lesser General Public License as published by the 26 | % Free Software Foundation; either version 2.1 of the License, 27 | % or (at your option) any later version. 28 | % 29 | % This library is distributed in the hope that it will be useful, 30 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 31 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32 | % Lesser General Public License for more details. 33 | % 34 | % You should have received a copy of the GNU Lesser General Public 35 | % License along with this library; if not, write to the Free Software 36 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 37 | 38 | if (code_param.coded) 39 | switch sim_param.code_configuration 40 | case {0} % convolutional code 41 | codeword = ConvEncode( data, sim_param.g1, sim_param.nsc_flag1 ); 42 | 43 | % puncture [DOES NOT CURRENTLY WORK FOR TAIL-BITING CODES] 44 | if ( length (sim_param.pun_pattern1 ) ) 45 | [N,K] = size( sim_param.g1 ); 46 | codeword = reshape( codeword, N, length(codeword)/N ); 47 | codeword = Puncture( codeword, sim_param.pun_pattern1, sim_param.tail_pattern1 ); 48 | end 49 | case {1,4} % PCCC 50 | codeword = TurboEncode( data, code_param.code_interleaver, code_param.pun_pattern, code_param.tail_pattern, sim_param.g1, sim_param.nsc_flag1, sim_param.g2, sim_param.nsc_flag2 ); 51 | case {2} % LDPC 52 | codeword = LdpcEncode( data, code_param.H_rows, code_param.P_matrix ); 53 | case {3} % HSDPA 54 | % generate a turbo codeword 55 | turbo_codeword = TurboEncode( data, code_param.code_interleaver, code_param.pun_pattern, code_param.tail_pattern, sim_param.g1, sim_param.nsc_flag1, sim_param.g2, sim_param.nsc_flag2 ); 56 | 57 | % Rate Match according to the redundancy version 58 | M_arq = length(sim_param.X_set); 59 | for harq_transmission=1:M_arq 60 | [channel_streams] = HarqMatch( turbo_codeword, sim_param.X_set(harq_transmission), sim_param.N_IR, code_param.modulation, sim_param.P ); 61 | harq_codeword(harq_transmission,:) = reshape( channel_streams', 1, code_param.number_codewords*code_param.N_data); 62 | end 63 | 64 | codeword = reshape( harq_codeword', 1, M_arq*code_param.N_data*code_param.number_codewords ); 65 | case {5,6} % CTC code from WiMAX (5) or DVB-RCS (6) 66 | codeword = TurboDuobinaryCRSCEncode( data, code_param.code_interleaver, code_param.pun_pattern ); 67 | case {7} % BTC code 68 | codeword = BtcEncode( data, sim_param.g1, sim_param.g2, sim_param.k_per_row, sim_param.k_per_column, sim_param.B, sim_param.Q ); 69 | end 70 | 71 | % BICM interleave 72 | if ( length(code_param.bicm_interleaver) >= 1 ) 73 | codeword = Interleave( codeword, code_param.bicm_interleaver ); 74 | end 75 | else 76 | codeword = data; 77 | end 78 | 79 | % modulate 80 | s = Modulate( codeword, code_param.S_matrix ); 81 | 82 | -------------------------------------------------------------------------------- /cml/mat/CmlSimulate.m: -------------------------------------------------------------------------------- 1 | function [sim_param, sim_state] = CmlSimulate( varargin ) 2 | % CmlSimulate runs a set of simulations. 3 | % 4 | % The calling syntax is: 5 | % [sim_param, sim_state] = CmlSimulate( scenario_filename, cases ) 6 | % 7 | % Outputs: 8 | % sim_param = A structure containing simulation parameters. 9 | % sim_state = A structure containing the simulation state. 10 | % Note: See readme.txt for a description of the structure formats. 11 | % 12 | % Required inputs: 13 | % scenario_filename = the name of the file containing an array of sim_param structures. 14 | % cases = a list of the array indices to simulate. 15 | % 16 | % Note: Multiple scenario files can be specified. In this case, the argument list 17 | % should contain each scenario file to be used followed by the list of array indices 18 | % to read from that file. 19 | % 20 | % Example: 21 | % [sim_param, sim_state] = CmlSimulate( 'Scenario1', [1 2 5], 'Scenario2', [1 4 6] ); 22 | % 23 | % Copyright (C) 2005-2007, Matthew C. Valenti 24 | % 25 | % Last updated on Oct. 12, 2007 26 | % 27 | % Function CmlSimulate is part of the Iterative Solutions Coded Modulation 28 | % Library (ISCML). 29 | % 30 | % The Iterative Solutions Coded Modulation Library is free software; 31 | % you can redistribute it and/or modify it under the terms of 32 | % the GNU Lesser General Public License as published by the 33 | % Free Software Foundation; either version 2.1 of the License, 34 | % or (at your option) any later version. 35 | % 36 | % This library is distributed in the hope that it will be useful, 37 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 38 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 39 | % Lesser General Public License for more details. 40 | % 41 | % You should have received a copy of the GNU Lesser General Public 42 | % License along with this library; if not, write to the Free Software 43 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 44 | 45 | % setup structures and retrieve data 46 | [sim_param, sim_state] = ReadScenario( varargin{:} ); 47 | number_cases = length( sim_param ); 48 | 49 | % determine location of CmlHome 50 | load( 'CmlHome.mat' ); 51 | 52 | for ( case_number=1:number_cases ) 53 | fprintf( '\n\nRecord %d\n', case_number ); 54 | % Initialize code_param 55 | [sim_param(case_number), code_param] = InitializeCodeParam( sim_param(case_number), cml_home ); 56 | 57 | if ( ( strcmp( sim_param(case_number).sim_type, 'throughput' ) ) ) 58 | % calculate the throughput 59 | [sim_param(case_number), sim_state(case_number)] = CalculateThroughput( sim_param(case_number), sim_state(case_number), code_param ); 60 | elseif ( ( strcmp( sim_param(case_number).sim_type, 'bwcapacity' ) ) ) 61 | % calculate the bandwidth constrained capacity of CPFSK 62 | [sim_param(case_number), sim_state(case_number)] = CalculateMinSNR( sim_param(case_number), sim_state(case_number), code_param ); 63 | elseif ( ( strcmp( sim_param(case_number).sim_type, 'minSNRvsB' ) ) ) 64 | % calculate the throughput 65 | fprintf( '\n minSNRvsB\n\n' ); 66 | [sim_param(case_number), sim_state(case_number)] = CalculateMinSNRvsB( sim_param(case_number), sim_state(case_number), code_param ); 67 | else 68 | % Call SingleSimulate for this case 69 | 70 | % determine if mat or exe is called 71 | if ( sim_param(case_number).compiled_mode == 0 ) 72 | % run the matlab version 73 | sim_state(case_number) = SingleSimulate( sim_param(case_number), sim_state(case_number), code_param ); 74 | else 75 | % run the compiled exe in stand-alone mode 76 | save('SimSetup.mat','code_param'); 77 | save_param = sim_param(case_number); 78 | save_state = sim_state(case_number); 79 | 80 | save('SimState.mat','save_param','save_state'); 81 | !SingleSimulate & 82 | end 83 | end 84 | end -------------------------------------------------------------------------------- /cml/mat/CmlTouch.m: -------------------------------------------------------------------------------- 1 | function [sim_param, sim_state] = CmlTouch( varargin ) 2 | % CmlTouch touches files, useful for upgrading to new version. 3 | % 4 | % The calling syntax is: 5 | % [sim_param, sim_state] = CmlTouch( scenario_filename, cases ) 6 | % 7 | % Outputs: 8 | % sim_param = A structure containing simulation parameters. 9 | % sim_state = A structure containing the simulation state. 10 | % Note: See readme.txt for a description of the structure formats. 11 | % 12 | % Required inputs: 13 | % scenario_filename = the name of the file containing an array of sim_param structures. 14 | % cases = a list of the array indices to simulate. 15 | % 16 | % Note: Multiple scenario files can be specified. In this case, the argument list 17 | % should contain each scenario file to be used followed by the list of array indices 18 | % to read from that file. 19 | % 20 | % Example: 21 | % [sim_param, sim_state] = CmlTouch( 'Scenario1', [1 2 5], 'Scenario2', [1 4 6] ); 22 | % 23 | % Copyright (C) 2005-2006, Matthew C. Valenti 24 | % 25 | % Last updated on Mar. 15, 2006 26 | % 27 | % Function CmlSimulate is part of the Iterative Solutions Coded Modulation 28 | % Library (ISCML). 29 | % 30 | % The Iterative Solutions Coded Modulation Library is free software; 31 | % you can redistribute it and/or modify it under the terms of 32 | % the GNU Lesser General Public License as published by the 33 | % Free Software Foundation; either version 2.1 of the License, 34 | % or (at your option) any later version. 35 | % 36 | % This library is distributed in the hope that it will be useful, 37 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 38 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 39 | % Lesser General Public License for more details. 40 | % 41 | % You should have received a copy of the GNU Lesser General Public 42 | % License along with this library; if not, write to the Free Software 43 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 44 | 45 | % setup structures and retrieve data 46 | [sim_param, sim_state] = ReadScenario( varargin{:} ); 47 | number_cases = length( sim_param ); 48 | 49 | for ( case_number=1:number_cases ) 50 | % Initialize code_param (will be [] if not a coded simulation) 51 | code_param = InitializeCodeParam( sim_param(case_number) ); 52 | 53 | sim_param(case_number).rate = code_param.rate; % needed for CmlPlot to work correctly 54 | 55 | fprintf( '\n' ); 56 | fprintf( sim_param(case_number).comment ); 57 | fprintf( '\n' ); 58 | 59 | % save 60 | save_state = sim_state(case_number); 61 | save_param = sim_param(case_number); 62 | save(sim_param(case_number).filename, code_param.save_flag, 'save_state', 'save_param' ); 63 | 64 | 65 | end -------------------------------------------------------------------------------- /cml/mat/CreateDvbInterleaver.m: -------------------------------------------------------------------------------- 1 | function code_interleaver = CreateDvbInterleaver(Nbits) 2 | % CreateDvbInterleaver intializes an interleaver for use with the duobinary 3 | % tailbiting turbo code from the DVB-RCS standard 4 | % 5 | % The calling syntax is: 6 | % code_interleaver = CreateDvbInterleaver(Nbits) 7 | % 8 | % code_interleaver = a structure with the following members 9 | % code_interleaver.subblk_intl = subblock bit-wise interleaver, 1 by Nbits/2 vector 10 | % code_interleaver.info_intl = information interleaver over GF(2), 11 | % a row vector of length Nbits. 12 | % 13 | % Nbits = number of bits (i.e. twice the number of couples) 14 | % valid range = {48 64 212 220 228 424 432 440 848 856 864 752} 15 | % 16 | % Copyright (C) 2007, Matthew C. Valenti and Shi Cheng 17 | % 18 | % Last updated on Oct. 12, 2007 19 | % 20 | % Function CreateDvbInterleaver is part of the Iterative Solutions Coded Modulation 21 | % Library (ISCML). 22 | % 23 | % The Iterative Solutions Coded Modulation Library is free software; 24 | % you can redistribute it and/or modify it under the terms of 25 | % the GNU Lesser General Public License as published by the 26 | % Free Software Foundation; either version 2.1 of the License, 27 | % or (at your option) any later version. 28 | % 29 | % This library is distributed in the hope that it will be useful, 30 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 31 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32 | % Lesser General Public License for more details. 33 | % 34 | % You should have received a copy of the GNU Lesser General Public 35 | % License along with this library; if not, write to the Free Software 36 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 37 | % USA 38 | 39 | N = Nbits/2; %% N is the number of couples 40 | 41 | NN= [ 48, 64, 212 220, 228, 424, 432, 440, 848, 856, 864, 752].'; 42 | 43 | PP=[11, 24, 0, 24; 44 | 7, 34, 32, 2; 45 | 13, 106, 108, 2; 46 | 23, 112, 4, 116; 47 | 17, 116, 72, 188; 48 | 11, 6, 8, 2; 49 | 13, 0, 4, 8; 50 | 13, 10, 4, 2; 51 | 19, 2, 16, 6; 52 | 19, 428, 224, 652; 53 | 19, 2, 16, 6; 54 | 19, 376, 224, 600]; 55 | 56 | 57 | Nindex = find( NN== N); 58 | 59 | if (length(Nindex) ~= 1) 60 | disp('Wrong interleaver size of WiMax CTC'); 61 | end 62 | 63 | P0 = PP(Nindex, 1); 64 | P1 = PP(Nindex, 2); 65 | P2 = PP(Nindex, 3); 66 | P3 = PP(Nindex, 4); 67 | 68 | 69 | x= zeros(2,N); 70 | x(1:2*N) = 1:2*N; 71 | 72 | %% intra-couple shifting 73 | t = 1:2:N; 74 | x(1,t) = 2*t; 75 | x(2,t) = 2*t -1; 76 | 77 | y= zeros(2,N); 78 | for index = 0: N-1 79 | if mod(index,4) == 0 80 | P = 0; 81 | elseif mod(index,4) ==1 82 | P = N/2 +P1; 83 | elseif mod(index,4) ==2 84 | P = P2; 85 | else 86 | P = N/2 +P3; 87 | end 88 | i = mod( P0* index + P +1, N); 89 | y(:, index+1) = x(:,i+1); 90 | end 91 | 92 | code_interleaver.info_intl = reshape(y, 1, Nbits); 93 | 94 | % create subblock interleaver 95 | code_interleaver.subblk_intl= []; 96 | 97 | 98 | -------------------------------------------------------------------------------- /cml/mat/CreateDvbPuncturingPattern.m: -------------------------------------------------------------------------------- 1 | function pun_pattern = CreateDvbPuncturingPattern( Nbits_pun, Nbits_unpun ) 2 | % CreateDvbPuncturingPattern creates the puncturing pattern for use with the duobinary 3 | % tailbiting turbo code from the DVB-RCS standard. 4 | % 5 | % The calling syntax is: 6 | % pun_pattern = CreateDvbPuncturingPattern( Nbits_pun, Nbits_unpun ) 7 | % 8 | % pun_pattern = the puncturing pattern (length Nbits_pun vector) 9 | % 10 | % Nbits_pun = the number of bits after puncturing 11 | % Nbits_unpun = the number of bits prior to puncturing 12 | % 13 | % Copyright (C) 2007, Matthew C. Valenti and Shi Cheng 14 | % 15 | % Last updated on Oct. 12, 2007 16 | % 17 | % Function CreateDvbPuncturingPattern is part of the Iterative Solutions Coded Modulation 18 | % Library (ISCML). 19 | % 20 | % The Iterative Solutions Coded Modulation Library is free software; 21 | % you can redistribute it and/or modify it under the terms of 22 | % the GNU Lesser General Public License as published by the 23 | % Free Software Foundation; either version 2.1 of the License, 24 | % or (at your option) any later version. 25 | % 26 | % This library is distributed in the hope that it will be useful, 27 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | % Lesser General Public License for more details. 30 | % 31 | % You should have received a copy of the GNU Lesser General Public 32 | % License along with this library; if not, write to the Free Software 33 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 34 | % USA 35 | 36 | N = Nbits_unpun/6; 37 | 38 | if ( abs( Nbits_pun - ceil( N/(1/3) ) * 2 ) < 1E-5) 39 | pun_pattern = 1:Nbits_pun; 40 | elseif ( abs( Nbits_pun - ceil( N/(2/5) ) * 2 ) < 1E-5) 41 | t = reshape( [ [1:2:N]*2-1 ; [1:2:N]*2], 1, N); 42 | pun_pattern = [1:4*N, 4*N+t]; 43 | elseif ( abs( Nbits_pun - ceil( N/(1/2) ) * 2 ) < 1E-5) 44 | pun_pattern = 1:Nbits_pun; 45 | elseif ( abs( Nbits_pun - ceil( N/(2/3) ) * 2 ) < 1E-5) 46 | t = reshape( [ [1:2:N]*2-1 ; [1:2:N]*2], 1, N); 47 | pun_pattern = [1:2*N, 2*N+t]; 48 | elseif ( abs( Nbits_pun - ceil( N/(3/4) ) * 2 ) < 1E-5) 49 | t = reshape( [ [1:3:N]*2-1 ; [1:3:N]*2], 1, Nbits_pun-2*N); 50 | pun_pattern = [1:2*N, 2*N+t]; 51 | elseif ( abs( Nbits_pun - ceil( N/(4/5) ) * 2 ) < 1E-5) 52 | t = reshape( [ [1:4:N]*2-1 ; [1:4:N]*2], 1, Nbits_pun-2*N); 53 | pun_pattern = [1:2*N, 2*N+t]; 54 | elseif ( abs( Nbits_pun - ceil( N/(6/7) ) * 2 ) < 1E-5) 55 | t = reshape( [ [1:6:N]*2-1 ; [1:6:N]*2], 1, Nbits_pun-2*N); 56 | pun_pattern = [1:2*N, 2*N+t]; 57 | else 58 | disp('DVB interleaver: Wrong punctured size'); 59 | end 60 | 61 | -------------------------------------------------------------------------------- /cml/mat/CreateWimaxPuncturingPattern.m: -------------------------------------------------------------------------------- 1 | function pun_pattern = CreateWimaxPuncturingPattern( Nbits_pun, Nbits_unpun ) 2 | % CreateWimaxPuncturingPattern creates the puncturing pattern for use with the duobinary 3 | % tailbiting turbo code (CTC) from the mobile WiMAX (IEEE 802.16e) standard. 4 | % 5 | % The calling syntax is: 6 | % pun_pattern = CreateWimaxPuncturingPattern( Nbits_pun, Nbits_unpun ) 7 | % 8 | % pun_pattern = the puncturing pattern (length Nbits_pun vector) 9 | % 10 | % Nbits_pun = the number of bits after puncturing 11 | % Nbits_unpun = the number of bits prior to puncturing (not used) 12 | % 13 | % Copyright (C) 2007, Matthew C. Valenti and Shi Cheng 14 | % 15 | % Last updated on Oct. 12, 2007 16 | % 17 | % Function CreateWimaxPuncturingPattern is part of the Iterative Solutions Coded Modulation 18 | % Library (ISCML). 19 | % 20 | % The Iterative Solutions Coded Modulation Library is free software; 21 | % you can redistribute it and/or modify it under the terms of 22 | % the GNU Lesser General Public License as published by the 23 | % Free Software Foundation; either version 2.1 of the License, 24 | % or (at your option) any later version. 25 | % 26 | % This library is distributed in the hope that it will be useful, 27 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | % Lesser General Public License for more details. 30 | % 31 | % You should have received a copy of the GNU Lesser General Public 32 | % License along with this library; if not, write to the Free Software 33 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 34 | % USA 35 | 36 | pun_pattern = 1:Nbits_pun; 37 | -------------------------------------------------------------------------------- /cml/mat/DefineStructures.m: -------------------------------------------------------------------------------- 1 | function [sim_param_changeable, sim_param_unchangeable, sim_state_prototype] = DefineStructures 2 | % DefineStructures specifies the prototype structures. 3 | % 4 | % The calling syntax is: 5 | % [sim_param_changeable, sim_param_unchangeable, sim_state_prototype] = DefineStructures 6 | % 7 | % sim_param_changeable = Prototype structure containing simulation parametes that can be changed 8 | % sim_param_unchangeable = Prototype structure containing simulation parametes that cannot be changed 9 | % sim_state_prototype = Prototype of structure containing simulation results 10 | % 11 | % Note: See readme.pdf for a description of the structure formats. 12 | % 13 | % Copyright (C) 2006-2008, Matthew C. Valenti 14 | % 15 | % Last updated on May 22, 2008 16 | % 17 | % Function DefineStructures is part of the Iterative Solutions Coded Modulation 18 | % Library (ISCML). 19 | % 20 | % The Iterative Solutions Coded Modulation Library is free software; 21 | % you can redistribute it and/or modify it under the terms of 22 | % the GNU Lesser General Public License as published by the 23 | % Free Software Foundation; either version 2.1 of the License, 24 | % or (at your option) any later version. 25 | % 26 | % This library is distributed in the hope that it will be useful, 27 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | % Lesser General Public License for more details. 30 | % 31 | % You should have received a copy of the GNU Lesser General Public 32 | % License along with this library; if not, write to the Free Software 33 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 34 | % USA 35 | 36 | % unchangeable paramaters and their default values 37 | sim_param_unchangeable = struct(... 38 | 'sim_type', [], ... 39 | 'SNR_type', 'Eb/No in dB', ... 40 | 'framesize', [], ... 41 | 'bicm', 1, ... 42 | 'modulation', 'BPSK', ... 43 | 'mod_order', 2, ... 44 | 'mapping', 'gray', ... 45 | 'h', [], ... 46 | 'demod_type', [], ... 47 | 'code_configuration', [], ... 48 | 'g1', [], ... 49 | 'nsc_flag1', [], ... 50 | 'pun_pattern1', [], ... 51 | 'tail_pattern1', [], ... 52 | 'g2', [], ... 53 | 'nsc_flag2', [], ... 54 | 'pun_pattern2', [], ... 55 | 'tail_pattern2', [], ... 56 | 'decoder_type', [], ... 57 | 'max_iterations', 1, ... 58 | 'code_interleaver', [], ... 59 | 'parity_check_matrix', [], ... 60 | 'channel', 'AWGN', ... 61 | 'blocks_per_frame', [], ... 62 | 'N_IR', [], ... 63 | 'X_set', [], ... 64 | 'P', [], ... 65 | 'combining_type', [], ... 66 | 'rate', [], ... 67 | 'csi_flag', [], ... 68 | 'bwconstraint', [], ... 69 | 'bwdatabase', [], ... 70 | 'code_bits_per_frame', [], ... 71 | 'S_matrix', [], ... 72 | 'k_per_row', [], ... 73 | 'k_per_column', [], ... 74 | 'B', [], ... 75 | 'Q', [], ... 76 | 'depth', 6 ); 77 | 78 | sim_param_changeable = struct( ... 79 | 'SNR', [], ... 80 | 'filename', [], ... 81 | 'comment', [], ... 82 | 'legend', [], ... 83 | 'linetype', 'k', ... 84 | 'plot_iterations', [], ... 85 | 'save_rate', 100, ... 86 | 'reset', 0, ... 87 | 'max_trials', [], ... 88 | 'minBER', 1e-8, ... 89 | 'minFER', 1e-8, ... 90 | 'max_frame_errors', [], ... 91 | 'compiled_mode', 0, ... 92 | 'input_filename', [], ... 93 | 'trial_size', 1, ... 94 | 'scenarios', [] ); 95 | 96 | sim_state_prototype = struct( ... 97 | 'trials', [], ... 98 | 'capacity_sum', [], ... 99 | 'capacity_avg', [], ... 100 | 'frame_errors', [], ... 101 | 'symbol_errors', [], ... 102 | 'bit_errors', [], ... 103 | 'FER', [], ... 104 | 'SER', [], ... 105 | 'BER', [], ... 106 | 'throughput', [], ... 107 | 'min_rate', [], ... 108 | 'best_rate', [], ... 109 | 'min_EsNodB', [], ... 110 | 'min_EbNodB', [] ); 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /cml/mat/PnGenerator.m: -------------------------------------------------------------------------------- 1 | function sequence = PnGenerator( sequence_length, g ) 2 | % PnGenerator creates a PN sequence using polynomial g 3 | % 4 | % The calling syntax is: 5 | % sequence = PnGenerator( sequence_length, g ) 6 | % 7 | % sequence = the PN sequence 8 | % 9 | % sequence_length = the length of the sequence 10 | % g = the generator polynomial coefficients 11 | % 12 | % Copyright (C) 2006, Matthew C. Valenti 13 | % 14 | % Last updated on June 20, 2006 15 | % 16 | % Function PnGenerator is part of the Iterative Solutions Coded Modulation 17 | % Library (ISCML). 18 | % 19 | % The Iterative Solutions Coded Modulation Library is free software; 20 | % you can redistribute it and/or modify it under the terms of 21 | % the GNU Lesser General Public License as published by the 22 | % Free Software Foundation; either version 2.1 of the License, 23 | % or (at your option) any later version. 24 | % 25 | % This library is distributed in the hope that it will be useful, 26 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 28 | % Lesser General Public License for more details. 29 | % 30 | % You should have received a copy of the GNU Lesser General Public 31 | % License along with this library; if not, write to the Free Software 32 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 33 | 34 | K = length(g); 35 | m = K-1; 36 | pun_pattern = [0 1]'; 37 | tail_pattern = zeros(2,m); 38 | 39 | g_encoder = [g 40 | [1 zeros(1,m) ] ]; 41 | 42 | input = [1 zeros(1,sequence_length-1)]; 43 | 44 | codeword = ConvEncode( input, g_encoder ); 45 | 46 | sequence = Puncture( reshape( codeword, 2, length(codeword)/2 ), pun_pattern, tail_pattern ); 47 | 48 | -------------------------------------------------------------------------------- /cml/mat/ReadScenario.m: -------------------------------------------------------------------------------- 1 | function [sim_param_output, sim_state_output] = ReadScenario( varargin ); 2 | % ReadScenario reads simulation parameters from a list of scenario files and the simulation 3 | % results from the corresponding stored data files 4 | % 5 | % The calling syntax is: 6 | % [sim_param, sim_state] = ReadScenario( scenario_filename, cases [, ...] ) 7 | % 8 | % sim_param = A structure containing simulation parameters. 9 | % sim_state = A structure containing the simulation state. 10 | % Note: See readme.txt for a description of the structure formats. 11 | % 12 | % scenario_filename = the name of the file containing an array of sim_param structures. 13 | % cases = a list of the array indices to read. Set to 'all' to read all the 14 | % scenarios in the file. 15 | % 16 | % Note: Multiple scenario files can be specified. In this case, the argument list 17 | % should contain each scenario file to be used followed by the list of array indices 18 | % to read from that file. 19 | % 20 | % Example: 21 | % [sim_param, sim_state] = ReadScenario( 'Scenario1', [1 2 5], 'Scenario2', [1 4 6] ); 22 | % 23 | % Copyright (C) 2006, Matthew C. Valenti 24 | % 25 | % Last updated on Oct. 12, 2007 26 | % 27 | % Function ReadScenario is part of the Iterative Solutions Coded Modulation 28 | % Library (ISCML). 29 | % 30 | % The Iterative Solutions Coded Modulation Library is free software; 31 | % you can redistribute it and/or modify it under the terms of 32 | % the GNU Lesser General Public License as published by the 33 | % Free Software Foundation; either version 2.1 of the License, 34 | % or (at your option) any later version. 35 | % 36 | % This library is distributed in the hope that it will be useful, 37 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 38 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 39 | % Lesser General Public License for more details. 40 | % 41 | % You should have received a copy of the GNU Lesser General Public 42 | % License along with this library; if not, write to the Free Software 43 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 44 | 45 | number_of_files = nargin/2; 46 | if (floor(number_of_files) ~= number_of_files) 47 | % odd number of arguments is a signal to not reset 48 | % used when plotting 49 | dont_reset = 1; 50 | else 51 | dont_reset = 0; 52 | end 53 | 54 | % loop over each Scenario file 55 | offset = 0; 56 | for file=1:number_of_files 57 | scenario_filename = varargin{file*2-1}; 58 | cases = varargin{file*2}; 59 | 60 | % clear, then initialize sim_param and sim_state structures 61 | clear sim_param sim_state 62 | 63 | % load the scenario file 64 | eval( scenario_filename ); 65 | 66 | % set cases to 'all' to read all parameters 67 | if isstr(cases) 68 | sim_param = sim_param; 69 | cases=1:length(sim_param); 70 | else 71 | sim_param = sim_param( cases ); 72 | end 73 | 74 | % load/initialize each scenario 75 | num_cases = length( cases ); 76 | 77 | for (case_number=1:num_cases) 78 | fprintf( strcat( 'Initializing case (%d):\t', sim_param(case_number).comment, '\n' ), cases( case_number ) ); 79 | 80 | if ( ( strcmpi( sim_param(case_number).sim_type, 'throughput' ) )|... 81 | ( strcmpi( sim_param(case_number).sim_type, 'bwcapacity' ) ) | ... 82 | ( strcmpi( sim_param(case_number).sim_type, 'minSNRvsB' ) ) ) 83 | sim_param(case_number).reset = 1; 84 | end 85 | 86 | if dont_reset 87 | sim_param(case_number).reset = 0; 88 | end 89 | 90 | [sim_param_out(case_number), sim_state(case_number)] = SingleRead( sim_param(case_number) ); 91 | 92 | end 93 | sim_param_output(offset+1:offset+num_cases) = sim_param_out(1:num_cases); 94 | sim_state_output(offset+1:offset+num_cases) = sim_state(1:num_cases); 95 | offset = offset + num_cases; 96 | end 97 | 98 | -------------------------------------------------------------------------------- /cml/mat/SingleSimulate.m: -------------------------------------------------------------------------------- 1 | function sim_state = SingleSimulate( varargin ) 2 | % Simulate runs a single simulation 3 | % 4 | % The calling syntax is: 5 | % [sim_param, sim_state] = SingleSimulate( sim_param, sim_state, code_param ) 6 | % 7 | % sim_param = A structure containing simulation parameters. 8 | % sim_state = A structure containing the simulation state. 9 | % code_param = A structure contining information about the channel code. 10 | % Note: See readme.txt for a description of the structure formats. 11 | % 12 | % Copyright (C) 2006-2007, Matthew C. Valenti 13 | % 14 | % Last updated on Dec. 30, 2007 15 | % 16 | % Function CmlSimulate is part of the Iterative Solutions Coded Modulation 17 | % Library (ISCML). 18 | % 19 | % The Iterative Solutions Coded Modulation Library is free software; 20 | % you can redistribute it and/or modify it under the terms of 21 | % the GNU Lesser General Public License as published by the 22 | % Free Software Foundation; either version 2.1 of the License, 23 | % or (at your option) any later version. 24 | % 25 | % This library is distributed in the hope that it will be useful, 26 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 28 | % Lesser General Public License for more details. 29 | % 30 | % You should have received a copy of the GNU Lesser General Public 31 | % License along with this library; if not, write to the Free Software 32 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 33 | 34 | % If there are no input arguments, then look for a .mat file in the local 35 | % director with a predetermined file name. 36 | % This hook is for future development. 37 | if (nargin == 0) 38 | load('SimSetup'); % Contains the code_param structure 39 | load('SimState'); % Contains sim_param and sim_state 40 | sim_param = save_param; 41 | sim_state = save_state; 42 | code_param.filename = 'SimState.mat'; 43 | elseif (nargin == 3) 44 | sim_param = varargin{1}; 45 | sim_state = varargin{2}; 46 | code_param = varargin{3}; 47 | else 48 | error( 'SingleSimulate must have either 0 or 3 inputs' ); 49 | end 50 | 51 | fprintf( '\n' ); 52 | fprintf( sim_param.comment ); 53 | fprintf( '\n' ); 54 | 55 | % randomly seed the random number generators 56 | rand('state',sum(100*clock)); 57 | randn('state',sum(100*clock)); 58 | 59 | % close open files (4/22/06) 60 | fclose all; 61 | 62 | % determine the simulation type 63 | if ( strcmpi( sim_param.sim_type, 'capacity' ) ) 64 | % capacity simulation 65 | sim_state = SimulateCapacity( sim_param, sim_state, code_param ); 66 | elseif ( ( strcmpi( sim_param.sim_type, 'uncoded' ) )|( strcmpi( sim_param.sim_type, 'coded' ) )| (strcmpi( sim_param.sim_type, 'bloutage') ) ) 67 | % uncoded or coded modulation 68 | if (sim_param.mod_order>0) 69 | sim_state = SimulateMod( sim_param, sim_state, code_param ); 70 | else % added 12/30/07 71 | sim_state = SimulateUGI( sim_param, sim_state, code_param ); 72 | end 73 | elseif ( strcmpi( sim_param.sim_type, 'outage' ) ) 74 | % simulates outage probability in block fading 75 | sim_state = SimulateOutage( sim_param, sim_state, code_param ); 76 | else 77 | error( 'Simulation type is not supported' ); 78 | end 79 | -------------------------------------------------------------------------------- /cml/mat/TurboDuobinaryCRSCEncode.m: -------------------------------------------------------------------------------- 1 | function codeword = TurboDuobinaryCRSCEncode( data, code_interleaver, pun_pattern ) 2 | % TurboDuobinaryCRSCEncode encodes a data sequence using a duobinary tailbiting 3 | % turbo encoder. 4 | % 5 | % The calling syntax is: 6 | % codeword = TurboDuobinaryCRSCEncode( data, code_interleaver, pun_pattern ) 7 | % 8 | % codeword = the codeword generated by the encoder (a row vector) 9 | % 10 | % data = the row vector of data bits 11 | % code_interleaver = the turbo interleaver 12 | % pun_pattern = the puncturing pattern 13 | % 14 | % Copyright (C) 2007, Matthew C. Valenti and Shi Cheng 15 | % 16 | % Last updated on Nov. 16, 2007 17 | % 18 | % Function TurboDuobinaryCRSCEncode is part of the Iterative Solutions Coded Modulation 19 | % Library (ISCML). 20 | % 21 | % The Iterative Solutions Coded Modulation Library is free software; 22 | % you can redistribute it and/or modify it under the terms of 23 | % the GNU Lesser General Public License as published by the 24 | % Free Software Foundation; either version 2.1 of the License, 25 | % or (at your option) any later version. 26 | % 27 | % This library is distributed in the hope that it will be useful, 28 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 29 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 30 | % Lesser General Public License for more details. 31 | % 32 | % You should have received a copy of the GNU Lesser General Public 33 | % License along with this library; if not, write to the Free Software 34 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 35 | % USA 36 | 37 | Nbits= length(data); 38 | N = Nbits/2; 39 | poly = [1,0,1,1;1,0,0,1]; 40 | couple_data = reshape(data, 2, N); 41 | outz = DuobinaryCRSCEncode(couple_data, poly); 42 | intl_data = zeros(2,N); 43 | intl_data = data(code_interleaver.info_intl); 44 | intl_outz = DuobinaryCRSCEncode( intl_data, poly); 45 | 46 | if (length( code_interleaver.subblk_intl ) > 0 ) 47 | % WiMax uses a sub-block interleaver 48 | unpun_codeword = [reshape(couple_data(:,code_interleaver.subblk_intl).' ,1,2*N),... 49 | reshape( [outz(1,code_interleaver.subblk_intl);intl_outz(1,code_interleaver.subblk_intl)], 1, 2*N),... 50 | reshape( [outz(2,code_interleaver.subblk_intl);intl_outz(2,code_interleaver.subblk_intl)], 1, 2*N)]; 51 | else 52 | % DVB-RCS does not use a sub-block interleaver 53 | unpun_codeword = [reshape(couple_data,1,2*N),... 54 | reshape( [outz(1,:);intl_outz(1,:)], 1, 2*N),... 55 | reshape( [outz(2,:);intl_outz(2,:)], 1, 2*N)]; 56 | end 57 | 58 | if (length(pun_pattern)>1) 59 | codeword = unpun_codeword( pun_pattern); 60 | else 61 | codeword = unpun_codeword( 1:3*Nbits ); 62 | end 63 | -------------------------------------------------------------------------------- /cml/mat/TurboEncode.m: -------------------------------------------------------------------------------- 1 | function codeword = TurboEncode( data, code_interleaver, pun_pattern, tail_pattern, g1, nsc_flag1, g2, nsc_flag2 ) 2 | % TurboEncode encodes a data sequence using a binary turbo encoder. 3 | % If the data length is an integer multiple of the interleaver length, then 4 | % multiple codewords are returned, (one per row of the codeword matrix). 5 | % 6 | % The calling syntax is: 7 | % codeword = TurboEncode( data, code_interleaver, pun_pattern, tail_pattern, g1, nsc_flag1, g2, nsc_flag2 ) 8 | % 9 | % codeword = the codeword generated by the encoder, 10 | % will contain multiple rows if the data is longer than the 11 | % interleaver 12 | % 13 | % data = the row vector of data bits 14 | % code_interleaver = the turbo interleaver 15 | % pun_pattern = the puncturing pattern for all but the tail 16 | % tail_pattern = the puncturing pattern just for the tail 17 | % g1 = the first generator polynomial 18 | % nsc_flag1 = 0 if first encoder is RSC and 1 if NSC 19 | % g2 = the second generator polynomial 20 | % nsc_flag2 = 0 if second encoder is RSC and 1 if NSC 21 | % 22 | % Copyright (C) 2005, Matthew C. Valenti 23 | % 24 | % Last updated on Dec. 13, 2005 25 | % 26 | % Function TurboEncode is part of the Iterative Solutions Coded Modulation 27 | % Library (ISCML). 28 | % 29 | % The Iterative Solutions Coded Modulation Library is free software; 30 | % you can redistribute it and/or modify it under the terms of 31 | % the GNU Lesser General Public License as published by the 32 | % Free Software Foundation; either version 2.1 of the License, 33 | % or (at your option) any later version. 34 | % 35 | % This library is distributed in the hope that it will be useful, 36 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 37 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 38 | % Lesser General Public License for more details. 39 | % 40 | % You should have received a copy of the GNU Lesser General Public 41 | % License along with this library; if not, write to the Free Software 42 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 43 | 44 | % determine the size of the two generators 45 | [N1,K1] = size( g1 ); 46 | [N2,K2] = size( g2 ); 47 | 48 | % in the future, we will allow constituent codes with different constraint lengths 49 | if ( K1 ~= K2 ) 50 | error( 'The constraint lengths of the two PCCC constituent codes must be indentical' ); 51 | end 52 | 53 | % check interleaver length against data length 54 | K_data = length( data ); 55 | K_interleaver = length( code_interleaver ); 56 | if ( rem( K_data, K_interleaver ) ) 57 | error( 'The data length needs to be an integer multiple of the interleaver length' ); 58 | end 59 | number_codewords = K_data/K_interleaver; 60 | 61 | data = reshape( data, K_interleaver, number_codewords)'; 62 | 63 | for codeword_index=1:number_codewords 64 | % Encode in parallel (fixed on 2-1-06) 65 | upper_output = ConvEncode( data(codeword_index,:), g1, nsc_flag1 ); 66 | lower_output = ConvEncode( Interleave( data(codeword_index,:), code_interleaver), g2, nsc_flag2 ); 67 | 68 | % convert to matrices (each row is from one row of the generator) 69 | upper_reshaped = [ reshape( upper_output, N1, length(upper_output)/N1 ) ]; 70 | lower_reshaped = [ reshape( lower_output, N2, length(lower_output)/N2 ) ]; 71 | 72 | % parallel concatenate 73 | unpunctured_word = [upper_reshaped 74 | lower_reshaped]; 75 | 76 | codeword(codeword_index,:) = Puncture( unpunctured_word, pun_pattern, tail_pattern ); 77 | end 78 | -------------------------------------------------------------------------------- /cml/mat/UmtsPunPattern.m: -------------------------------------------------------------------------------- 1 | function [pun_pattern, tail_pattern] = UmtsPunPattern( framesize, code_bits_per_frame ) 2 | 3 | N = 3*framesize+12; 4 | X_i = N/3; 5 | 6 | % This is the combined pun_pattern and tail_pattern 7 | total_pattern = zeros(3,X_i); 8 | 9 | % don't puncture the systematic part 10 | total_pattern(1,:) = ones(1,X_i); 11 | 12 | % set up parameters 13 | delta_N = code_bits_per_frame - N; 14 | e_ini = X_i; 15 | 16 | % puncture first parity stream 17 | e_plus = 2*X_i; 18 | e_minus = 2*abs( floor( delta_N/2 ) ); 19 | parity_1 = RateMatch( 1:X_i, X_i, e_ini, e_plus, e_minus ); 20 | total_pattern(2,parity_1) = ones( size(parity_1) ); 21 | 22 | % puncture second parity stream 23 | e_plus = X_i; 24 | e_minus = abs( ceil( delta_N/2 ) ); 25 | parity_2 = RateMatch( 1:X_i, X_i, e_ini, e_plus, e_minus ); 26 | total_pattern(3,parity_2) = ones( size(parity_2) ); 27 | 28 | % bit collection 29 | pun_pattern(1,:) = ones(1,framesize); 30 | pun_pattern(2,:) = total_pattern(2,1:framesize); 31 | pun_pattern(3,:) = zeros(1,framesize); 32 | pun_pattern(4,:) = total_pattern(3,1:framesize); 33 | 34 | tail_pattern = reshape( total_pattern(:,framesize+1:X_i),4, 3 ); 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /cml/matalt/CapacityTableLookup.m: -------------------------------------------------------------------------------- 1 | function cap = CapacityTableLookup( EsNo_AWGN, capacity_AWGN, slope, gamma ) 2 | % CapacityTableLookup returns the instantaneous capacity for a particular 3 | % channel realization by using a precalculated AWGN capacity table. 4 | % Since the table does not generally contain capacity values for the exact 5 | % SNR, linear interpolation is used to estimate the value. 6 | % 7 | % The calling syntax is: 8 | % cap = CapacityTableLoookup( EsNo_AWGN, capacity_AWGN, slope, gamma ) 9 | % 10 | % cap = The instantaneous capacity, a column vector with same number of 11 | % rows as gamma. 12 | % 13 | % EsNo_AWGN = The SNR values stored in the table 14 | % capacity_AWGN = The AWGN capacity values stored in the table. 15 | % slope = The slope of the AWGN capacity curve. 16 | % gamma = The instantaneous SNRs for the channel realization. 17 | % Each row correpsonds to a distinct codeword, 18 | % And the columns correspond to the blocks of that codeword. 19 | % 20 | % Copyright (C) 2005, Tarik Ghanim and Matthew C. Valenti 21 | % 22 | % Last updated on Dec. 23, 2005 23 | % 24 | % Function CapacityTableLookup is part of the Iterative Solutions Coded Modulation 25 | % Library (ISCML). 26 | % 27 | % The Iterative Solutions Coded Modulation Library is free software; 28 | % you can redistribute it and/or modify it under the terms of 29 | % the GNU Lesser General Public License as published by the 30 | % Free Software Foundation; either version 2.1 of the License, 31 | % or (at your option) any later version. 32 | % 33 | % This library is distributed in the hope that it will be useful, 34 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 35 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 36 | % Lesser General Public License for more details. 37 | % 38 | % You should have received a copy of the GNU Lesser General Public 39 | % License along with this library; if not, write to the Free Software 40 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 41 | 42 | % L is the number of blocks per codeword, 43 | % while trial_size is the number of codewords per trial 44 | [trial_size, L] = size( gamma ); 45 | 46 | max_SNR = max( EsNo_AWGN ); 47 | min_SNR = min( EsNo_AWGN ); 48 | max_cap = max( capacity_AWGN ); 49 | 50 | cap = zeros(size(gamma,1),1); 51 | 52 | for codeword=1:trial_size 53 | for block=1:L 54 | if ( gamma(codeword,block) >= max_SNR ) 55 | % SNR above smallest value in table; use largest capacity 56 | inst_cap(block) = max_cap; 57 | elseif ( gamma(codeword,block) > min_SNR ) 58 | % Need to interpolate 59 | index_below = max( find( EsNo_AWGN < gamma(codeword,block) ) ); 60 | correction = slope(index_below)*(gamma(codeword,block)-EsNo_AWGN(index_below)); 61 | inst_cap(block) = capacity_AWGN(index_below) + correction; 62 | else 63 | % SNR below smallest value in table; assume capacity is zero 64 | inst_cap(block) = 0; 65 | end 66 | % add instantaneous capacities 67 | cap(codeword) = sum( inst_cap ); 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /cml/matalt/RateDematch.m: -------------------------------------------------------------------------------- 1 | function y = RateDematch( x, X_i, e_ini, e_plus, e_minus ); 2 | % RateDematch reverses the basic UMTS/HSDPA Rate Matching algorithm 3 | % 4 | % The calling syntax is: 5 | % y = RateDematch( x, X_i, e_ini, e_plus, e_minus ); 6 | % 7 | % y = depunctured output (length X_i) 8 | % 9 | % x = input consisting of received/punctured bits 10 | % X_i = length of the depunctured output 11 | % e_ini = parameter used by algorithm 12 | % e_plus = parameter used by algorithm 13 | % e_minus = parameter used by algorithm 14 | % 15 | % Copyright (C) 2005, Matthew C. Valenti 16 | % 17 | % Last updated on Nov. 28, 2005 18 | % 19 | % Function RateDematch is part of the Iterative Solutions Coded Modulation 20 | % Library (ISCML). 21 | % 22 | % The Iterative Solutions Coded Modulation Library is free software; 23 | % you can redistribute it and/or modify it under the terms of 24 | % the GNU Lesser General Public License as published by the 25 | % Free Software Foundation; either version 2.1 of the License, 26 | % or (at your option) any later version. 27 | % 28 | % This library is distributed in the hope that it will be useful, 29 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 31 | % Lesser General Public License for more details. 32 | % 33 | % You should have received a copy of the GNU Lesser General Public 34 | % License along with this library; if not, write to the Free Software 35 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 36 | e = e_ini; 37 | y_index = 1; 38 | 39 | for m=1:X_i 40 | e = e - e_minus; 41 | if (e<=0) 42 | % mark for puncturing 43 | e = e + e_plus; 44 | y(m) = 0; 45 | else 46 | y(m) = x(y_index); 47 | y_index = y_index + 1; 48 | end 49 | end -------------------------------------------------------------------------------- /cml/matalt/RateMatch.m: -------------------------------------------------------------------------------- 1 | function y = RateMatch( x, X_i, e_ini, e_plus, e_minus ) 2 | % RateMatch performs the basic UMTS/HSDPA Rate Matching algorithm 3 | % 4 | % The calling syntax is: 5 | % y = RateMatch( x, X_i, e_ini, e_plus, e_minus ) 6 | % 7 | % y = output of rate matching algorithm 8 | % 9 | % x = input to rate matching algorithm (length X_i) 10 | % X_i = length of the input 11 | % e_ini = parameter used by algorithm 12 | % e_plus = parameter used by algorithm 13 | % e_minus = parameter used by algorithm 14 | % 15 | % Copyright (C) 2005, Matthew C. Valenti 16 | % 17 | % Last updated on Nov. 28, 2005 18 | % 19 | % Function RateMatch is part of the Iterative Solutions Coded Modulation 20 | % Library (ISCML). 21 | % 22 | % The Iterative Solutions Coded Modulation Library is free software; 23 | % you can redistribute it and/or modify it under the terms of 24 | % the GNU Lesser General Public License as published by the 25 | % Free Software Foundation; either version 2.1 of the License, 26 | % or (at your option) any later version. 27 | % 28 | % This library is distributed in the hope that it will be useful, 29 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 31 | % Lesser General Public License for more details. 32 | % 33 | % You should have received a copy of the GNU Lesser General Public 34 | % License along with this library; if not, write to the Free Software 35 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 36 | 37 | y = []; 38 | 39 | e = e_ini; 40 | 41 | y_index = 1; 42 | 43 | for m=1:X_i 44 | e = e - e_minus; 45 | if (e<=0) 46 | e = e + e_plus; 47 | else 48 | y(y_index) = x(m); 49 | y_index = y_index + 1; 50 | end 51 | end -------------------------------------------------------------------------------- /cml/mex/Capacity.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/Capacity.dll -------------------------------------------------------------------------------- /cml/mex/Capacity.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/Capacity.mexw64 -------------------------------------------------------------------------------- /cml/mex/CapacityTableLookup.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/CapacityTableLookup.dll -------------------------------------------------------------------------------- /cml/mex/CapacityTableLookup.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/CapacityTableLookup.mexw64 -------------------------------------------------------------------------------- /cml/mex/ConvEncode.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/ConvEncode.dll -------------------------------------------------------------------------------- /cml/mex/ConvEncode.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/ConvEncode.mexw64 -------------------------------------------------------------------------------- /cml/mex/CreateCcsdsInterleaver.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/CreateCcsdsInterleaver.dll -------------------------------------------------------------------------------- /cml/mex/CreateCcsdsInterleaver.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/CreateCcsdsInterleaver.mexw64 -------------------------------------------------------------------------------- /cml/mex/CreateSRandomInterleaver.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/CreateSRandomInterleaver.dll -------------------------------------------------------------------------------- /cml/mex/CreateSRandomInterleaver.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/CreateSRandomInterleaver.mexw64 -------------------------------------------------------------------------------- /cml/mex/CreateUmtsInterleaver.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/CreateUmtsInterleaver.dll -------------------------------------------------------------------------------- /cml/mex/CreateUmtsInterleaver.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/CreateUmtsInterleaver.mexw64 -------------------------------------------------------------------------------- /cml/mex/Deinterleave.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/Deinterleave.dll -------------------------------------------------------------------------------- /cml/mex/Deinterleave.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/Deinterleave.mexw64 -------------------------------------------------------------------------------- /cml/mex/Demod2D.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/Demod2D.dll -------------------------------------------------------------------------------- /cml/mex/Demod2D.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/Demod2D.mexw64 -------------------------------------------------------------------------------- /cml/mex/DemodFSK.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/DemodFSK.dll -------------------------------------------------------------------------------- /cml/mex/DemodFSK.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/DemodFSK.mexw64 -------------------------------------------------------------------------------- /cml/mex/Depuncture.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/Depuncture.dll -------------------------------------------------------------------------------- /cml/mex/Depuncture.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/Depuncture.mexw64 -------------------------------------------------------------------------------- /cml/mex/DuobinaryCRSCDecode.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/DuobinaryCRSCDecode.dll -------------------------------------------------------------------------------- /cml/mex/DuobinaryCRSCEncode.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/DuobinaryCRSCEncode.dll -------------------------------------------------------------------------------- /cml/mex/InitializeDVBS2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/InitializeDVBS2.dll -------------------------------------------------------------------------------- /cml/mex/InitializeDVBS2.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/InitializeDVBS2.mexw64 -------------------------------------------------------------------------------- /cml/mex/Interleave.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/Interleave.dll -------------------------------------------------------------------------------- /cml/mex/Interleave.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/Interleave.mexw64 -------------------------------------------------------------------------------- /cml/mex/LdpcEncode.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/LdpcEncode.dll -------------------------------------------------------------------------------- /cml/mex/LdpcEncode.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/LdpcEncode.mexw64 -------------------------------------------------------------------------------- /cml/mex/Modulate.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/Modulate.dll -------------------------------------------------------------------------------- /cml/mex/Modulate.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/Modulate.mexw64 -------------------------------------------------------------------------------- /cml/mex/MpDecode.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/MpDecode.dll -------------------------------------------------------------------------------- /cml/mex/MpDecode.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/MpDecode.mexw64 -------------------------------------------------------------------------------- /cml/mex/Puncture.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/Puncture.dll -------------------------------------------------------------------------------- /cml/mex/Puncture.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/Puncture.mexw64 -------------------------------------------------------------------------------- /cml/mex/RateDematch.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/RateDematch.dll -------------------------------------------------------------------------------- /cml/mex/RateDematch.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/RateDematch.mexw64 -------------------------------------------------------------------------------- /cml/mex/RateMatch.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/RateMatch.dll -------------------------------------------------------------------------------- /cml/mex/RateMatch.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/RateMatch.mexw64 -------------------------------------------------------------------------------- /cml/mex/SisoDecode.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/SisoDecode.dll -------------------------------------------------------------------------------- /cml/mex/SisoDecode.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/SisoDecode.mexw64 -------------------------------------------------------------------------------- /cml/mex/Somap.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/Somap.dll -------------------------------------------------------------------------------- /cml/mex/Somap.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/Somap.mexw64 -------------------------------------------------------------------------------- /cml/mex/ViterbiDecode.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/ViterbiDecode.dll -------------------------------------------------------------------------------- /cml/mex/ViterbiDecode.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/mex/ViterbiDecode.mexw64 -------------------------------------------------------------------------------- /cml/mexhelp/Capacity.m: -------------------------------------------------------------------------------- 1 | % Capacity determines the ergodic capacity under modulation constraints 2 | % 3 | % The calling syntax is: 4 | % [output] = capacity( input, data ) 5 | % 6 | % output = Instantaneous capacity of this frame 7 | % 8 | % input = M by N matrix of symbol likelihoods 9 | % where M is the modulation order, or 10 | % M=1 is used to indicate that the input is a bitwise LLR. 11 | % data = 1 by N*log2(M) vector of data bits 12 | % 13 | % 14 | % Copyright (C) 2005, Matthew C. Valenti 15 | % 16 | % Last updated on Nov. 28, 2005 17 | % 18 | % Function Capacity is part of the Iterative Solutions 19 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 20 | % Library is free software; you can redistribute it and/or modify it 21 | % under the terms of the GNU Lesser General Public License as published 22 | % by the Free Software Foundation; either version 2.1 of the License, 23 | % or (at your option) any later version. 24 | % 25 | % This library is distributed in the hope that it will be useful, 26 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 28 | % Lesser General Public License for more details. 29 | % 30 | % You should have received a copy of the GNU Lesser General Public 31 | % License along with this library; if not, write to the Free Software 32 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /cml/mexhelp/ConvEncode.m: -------------------------------------------------------------------------------- 1 | % ConvEncode encodes a NSC or RSC convolutional code with a tail. 2 | % 3 | % The calling syntax is: 4 | % [output] = ConvEncode(input, g_encoder, [code_type] ) 5 | % 6 | % output = code word 7 | % 8 | % Required inputs: 9 | % input = data word 10 | % g_encoder = generator matrix for convolutional code 11 | % (If RSC, then feedback polynomial is first) 12 | % 13 | % Optional inputs: 14 | % code_type = 0 for recursive systematic convolutional (RSC) code (default) 15 | % = 1 for non-systematic convolutional (NSC) code 16 | % = 2 for tail-biting NSC code 17 | % 18 | % Copyright (C) 2005-2008, Matthew C. Valenti 19 | % 20 | % Last updated on May 21, 2008 21 | % 22 | % Function ConvEncode is part of the Iterative Solutions 23 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 24 | % Library is free software; you can redistribute it and/or modify it 25 | % under the terms of the GNU Lesser General Public License as published 26 | % by the Free Software Foundation; either version 2.1 of the License, 27 | % or (at your option) any later version. 28 | % 29 | % This library is distributed in the hope that it will be useful, 30 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 31 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32 | % Lesser General Public License for more details. 33 | % 34 | % You should have received a copy of the GNU Lesser General Public 35 | % License along with this library; if not, write to the Free Software 36 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /cml/mexhelp/CreateCcsdsInterleaver.m: -------------------------------------------------------------------------------- 1 | % CreateCcsdsInterleaver produces an interleaver according to the CCSDS spec. 2 | % 3 | % The calling syntax is: 4 | % [alpha] = CreateCcsdsInterleaver( K ) 5 | % 6 | % alpha = the interleaver in a length K vector 7 | % 8 | % K = the size of the interleaver 9 | % 10 | % Copyright (C) 2006, Matthew C. Valenti 11 | % 12 | % Last updated on June 25, 2006 13 | % 14 | % Function CreateCcsdsInterleaver is part of the Iterative Solutions 15 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 16 | % Library is free software; you can redistribute it and/or modify it 17 | % under the terms of the GNU Lesser General Public License as published 18 | % by the Free Software Foundation; either version 2.1 of the License, 19 | % or (at your option) any later version. 20 | % 21 | % This library is distributed in the hope that it will be useful, 22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24 | % Lesser General Public License for more details. 25 | % 26 | % You should have received a copy of the GNU Lesser General Public 27 | % License along with this library; if not, write to the Free Software 28 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /cml/mexhelp/CreateSRandomInterleaver.m: -------------------------------------------------------------------------------- 1 | % CreateSRandomInterleaver produces a S-random interleaver. 2 | % Warning: It can take a significant time to run. 3 | % 4 | % The calling syntax is: 5 | % [alpha] = CreateSRandomInterleaver( K, S ) 6 | % 7 | % alpha = the interleaver in a length K vector 8 | % 9 | % K = the size of the interleaver 10 | % S = S value (determines amount of spread) 11 | % Note: the value of S greatly influences run time. 12 | % 13 | % Copyright (C) 2005, Matthew C. Valenti and Yufei Wu 14 | % 15 | % Last updated on Nov. 28, 2005 16 | % 17 | % Function CreateSRandomInterleaver is part of the Iterative Solutions 18 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 19 | % Library is free software; you can redistribute it and/or modify it 20 | % under the terms of the GNU Lesser General Public License as published 21 | % by the Free Software Foundation; either version 2.1 of the License, 22 | % or (at your option) any later version. 23 | % 24 | % This library is distributed in the hope that it will be useful, 25 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | % Lesser General Public License for more details. 28 | % 29 | % You should have received a copy of the GNU Lesser General Public 30 | % License along with this library; if not, write to the Free Software 31 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /cml/mexhelp/CreateUmtsInterleaver.m: -------------------------------------------------------------------------------- 1 | % CreateUmtsInterleaver produces an interleaver according to the UMTS spec. 2 | % 3 | % The calling syntax is: 4 | % [alpha] = CreateUmtsInterleaver( K ) 5 | % 6 | % alpha = the interleaver in a length K vector 7 | % 8 | % K = the size of the interleaver 9 | % 10 | % Copyright (C) 2005, Matthew C. Valenti 11 | % 12 | % Last updated on Nov. 28, 2005 13 | % 14 | % Function CreateUmtsInterleaver is part of the Iterative Solutions 15 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 16 | % Library is free software; you can redistribute it and/or modify it 17 | % under the terms of the GNU Lesser General Public License as published 18 | % by the Free Software Foundation; either version 2.1 of the License, 19 | % or (at your option) any later version. 20 | % 21 | % This library is distributed in the hope that it will be useful, 22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24 | % Lesser General Public License for more details. 25 | % 26 | % You should have received a copy of the GNU Lesser General Public 27 | % License along with this library; if not, write to the Free Software 28 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /cml/mexhelp/Deinterleave.m: -------------------------------------------------------------------------------- 1 | % Deinterleave reverses the interleaving of one block of data. 2 | % 3 | % The calling syntax is: 4 | % [output] = Deinterleave(input, alpha_code ) 5 | % 6 | % output = deinterleaved data 7 | % 8 | % input = interleaved data or LLR values 9 | % alpha_code = interleaver pattern 10 | % 11 | % Copyright (C) 2005, Matthew C. Valenti 12 | % 13 | % Last updated on Nov. 28, 2005 14 | % 15 | % Function Deinterleave is part of the Iterative Solutions 16 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 17 | % Library is free software; you can redistribute it and/or modify it 18 | % under the terms of the GNU Lesser General Public License as published 19 | % by the Free Software Foundation; either version 2.1 of the License, 20 | % or (at your option) any later version. 21 | % 22 | % This library is distributed in the hope that it will be useful, 23 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 25 | % Lesser General Public License for more details. 26 | % 27 | % You should have received a copy of the GNU Lesser General Public 28 | % License along with this library; if not, write to the Free Software 29 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /cml/mexhelp/Demod2D.m: -------------------------------------------------------------------------------- 1 | % Demod2D transforms received symbol values into log-likelihoods 2 | % 3 | % The calling syntax is: 4 | % [output] = Demod2D( input, S_matrix, EsNo, [fade_coef] ) 5 | % 6 | % output = M by N matrix of symbol log-likelihoods 7 | % 8 | % Required inputs: 9 | % input = 1 by N matrix of (complex) matched filter outputs 10 | % S_matrix = M by 1 complex matrix representing the constellation 11 | % EsNo = the symbol SNR (in linear, not dB, units) 12 | % 13 | % Optional inputs: 14 | % fade_coef = 1 by N matrix of (complex) fading coefficients (defaults to all-ones) 15 | % 16 | % Copyright (C) 2005, Matthew C. Valenti 17 | % 18 | % Last updated on Nov. 28, 2005 19 | % 20 | % Function Demod2D is part of the Iterative Solutions 21 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 22 | % Library is free software; you can redistribute it and/or modify it 23 | % under the terms of the GNU Lesser General Public License as published 24 | % by the Free Software Foundation; either version 2.1 of the License, 25 | % or (at your option) any later version. 26 | % 27 | % This library is distributed in the hope that it will be useful, 28 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 29 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 30 | % Lesser General Public License for more details. 31 | % 32 | % You should have received a copy of the GNU Lesser General Public 33 | % License along with this library; if not, write to the Free Software 34 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /cml/mexhelp/DemodFSK.m: -------------------------------------------------------------------------------- 1 | % DemodFSK transforms M-dimensional FSK symbols into ML symbol log-likelihoods 2 | % 3 | % The calling syntax is: 4 | % [output] = FskDemod( input, EsNo, [csi_flag], [fade_coef] ) 5 | % 6 | % output = M by N matrix of symbol log-likelihoods 7 | % 8 | % Required inputs: 9 | % input = M by N matrix of (complex) matched filter outputs 10 | % EsNo = the symbol SNR (in linear, not dB, units) 11 | % 12 | % Optional inputs: 13 | % csi_flag = 0 for coherent reception (default) 14 | % 1 for noncoherent reception w/ perfect amplitude estimates 15 | % 2 for noncoherent reception without amplitude estimates 16 | % fade_coef = 1 by N matrix of (complex) fading coefficients (defaults to all-ones, i.e. AWGN) 17 | % 18 | % Copyright (C) 2006, Matthew C. Valenti 19 | % 20 | % Last updated on June 25, 2006 21 | % 22 | % Function DemodFSK is part of the Iterative Solutions 23 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 24 | % Library is free software; you can redistribute it and/or modify it 25 | % under the terms of the GNU Lesser General Public License as published 26 | % by the Free Software Foundation; either version 2.1 of the License, 27 | % or (at your option) any later version. 28 | % 29 | % This library is distributed in the hope that it will be useful, 30 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 31 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32 | % Lesser General Public License for more details. 33 | % 34 | % You should have received a copy of the GNU Lesser General Public 35 | % License along with this library; if not, write to the Free Software 36 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /cml/mexhelp/Depuncture.m: -------------------------------------------------------------------------------- 1 | % Depuncture reverses puncturing by by zero-padding deleted bits. 2 | % 3 | % The calling syntax is: 4 | % [output] = Depuncture(input, pun_pattern, tail_pattern ) 5 | % 6 | % output = Unpunctured codeword 7 | % 8 | % input = Punctured codeword 9 | % pun_pattern = Puncturing pattern for encoded data bits 10 | % tail_pattern = Puncturing pattern for encoded tail bits 11 | % 12 | % Copyright (C) 2005, Matthew C. Valenti 13 | % 14 | % Last updated on Nov. 28, 2005 15 | % 16 | % Function Depuncture is part of the Iterative Solutions 17 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 18 | % Library is free software; you can redistribute it and/or modify it 19 | % under the terms of the GNU Lesser General Public License as published 20 | % by the Free Software Foundation; either version 2.1 of the License, 21 | % or (at your option) any later version. 22 | % 23 | % This library is distributed in the hope that it will be useful, 24 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | % Lesser General Public License for more details. 27 | % 28 | % You should have received a copy of the GNU Lesser General Public 29 | % License along with this library; if not, write to the Free Software 30 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /cml/mexhelp/InitializeDVBS2.m: -------------------------------------------------------------------------------- 1 | % InitializeDVBS2 creates H_rows and H_cols matrices for the DVB-S2 LDPC code. 2 | % 3 | % The calling syntax is: 4 | % [H_rows, H_cols] = InitializeDVBS2( rate, size ) 5 | % 6 | % H_rows = a M-row matrix containing the indices of the non-zero rows of H. 7 | % H_cols = a (N-M)-row matrix containing the indices of the non-zeros rows of H. 8 | % 9 | % rate = the code rate 10 | % size = the size of the code (number of code bits): 11 | % = 64,800 for normal (n=64,800) 12 | % = 16,200 for short (n=16,200) 13 | % 14 | % Copyright (C) 2005, Matthew C. Valenti and Rohit Iyer Seshadri 15 | % 16 | % Last updated on Nov. 28, 2005 17 | % 18 | % Function InitializeDVBS2 is part of the Iterative Solutions 19 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 20 | % Library is free software; you can redistribute it and/or modify it 21 | % under the terms of the GNU Lesser General Public License as published 22 | % by the Free Software Foundation; either version 2.1 of the License, 23 | % or (at your option) any later version. 24 | % 25 | % This library is distributed in the hope that it will be useful, 26 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 28 | % Lesser General Public License for more details. 29 | % 30 | % You should have received a copy of the GNU Lesser General Public 31 | % License along with this library; if not, write to the Free Software 32 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /cml/mexhelp/Interleave.m: -------------------------------------------------------------------------------- 1 | % Interleave permutes the order of a block of data according to pattern alpha_code 2 | % 3 | % The calling syntax is: 4 | % [output] = Interleave(input, alpha_code ) 5 | % 6 | % output = interleaved data 7 | % 8 | % input = uninterleaved data 9 | % alpha_code = interleaver pattern 10 | % 11 | % Copyright (C) 2005, Matthew C. Valenti 12 | % 13 | % Last updated on Nov. 28, 2005 14 | % 15 | % Function Interleave is part of the Iterative Solutions 16 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 17 | % Library is free software; you can redistribute it and/or modify it 18 | % under the terms of the GNU Lesser General Public License as published 19 | % by the Free Software Foundation; either version 2.1 of the License, 20 | % or (at your option) any later version. 21 | % 22 | % This library is distributed in the hope that it will be useful, 23 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 25 | % Lesser General Public License for more details. 26 | % 27 | % You should have received a copy of the GNU Lesser General Public 28 | % License along with this library; if not, write to the Free Software 29 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /cml/mexhelp/LdpcEncode.m: -------------------------------------------------------------------------------- 1 | % LdpcEncode encodes an LDPC codeword. Code must be an "eIRA-LDPC" type code, such as the one 2 | % in the DVB-S2 standard, or WiMax standard. 3 | % 4 | % The calling syntax is: 5 | % codeword = LdpcEncode( data, H_rows, [P]) 6 | % 7 | % Where: 8 | % codeword = the encoded codeword 9 | % 10 | % data = a row vector containing the data 11 | % H_rows = a M-row matrix containing the indices of the non-zero rows of H excluding the dual-diagonal part. 12 | % P = (optional) z times z matrix used to generate the first z check bits for WiMax (default =[]) 13 | % 14 | % Copyright (C) 2005-2007, Matthew C. Valenti and Rohit Iyer Seshadri 15 | % 16 | % Last updated on July 10, 2007 17 | % 18 | % Function LdpcEncode is part of the Iterative Solutions 19 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 20 | % Library is free software; you can redistribute it and/or modify it 21 | % under the terms of the GNU Lesser General Public License as published 22 | % by the Free Software Foundation; either version 2.1 of the License, 23 | % or (at your option) any later version. 24 | % 25 | % This library is distributed in the hope that it will be useful, 26 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 28 | % Lesser General Public License for more details. 29 | % 30 | % You should have received a copy of the GNU Lesser General Public 31 | % License along with this library; if not, write to the Free Software 32 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /cml/mexhelp/Modulate.m: -------------------------------------------------------------------------------- 1 | % Modulate transforms bits into K-dimensional channel symbols 2 | % 3 | % The calling syntax is: 4 | % [output] = Modulate( input, S_matrix ) 5 | % 6 | % output = K by N vector of modulated symbols 7 | % 8 | % Required inputs: 9 | % input = 1 by N*log2(M) vector of data bits 10 | % S_Matrix = K by M complex matrix containing the constellation signals 11 | % Each Column is one signal, each signal is K-dimensional 12 | % 13 | % Note: For legacy purposes, S_matrix can be a M by 1 matrix when signal 14 | % set can be characterized by a one-dimensional complex value (QAM, etc). 15 | % 16 | % Copyright (C) 2006, Matthew C. Valenti 17 | % 18 | % Last updated on June 21, 2006 19 | % 20 | % Function Modulate is part of the Iterative Solutions 21 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 22 | % Library is free software; you can redistribute it and/or modify it 23 | % under the terms of the GNU Lesser General Public License as published 24 | % by the Free Software Foundation; either version 2.1 of the License, 25 | % or (at your option) any later version. 26 | % 27 | % This library is distributed in the hope that it will be useful, 28 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 29 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 30 | % Lesser General Public License for more details. 31 | % 32 | % You should have received a copy of the GNU Lesser General Public 33 | % License along with this library; if not, write to the Free Software 34 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /cml/mexhelp/MpDecode.m: -------------------------------------------------------------------------------- 1 | % MpDecode decodes a block code (e.g. LDPC) using the message passing algorithm. 2 | % 3 | % The calling syntax is: 4 | % [output, errors] = MpDecode(input, H_rows, H_cols, [max_iter], [dec_type], [r_scale_factor], [q_scale_factor], [data] ) 5 | % 6 | % Required outputs: 7 | % output = matrix of dimension maxiter by N that has the decoded code bits for each iteration 8 | % 9 | % Optional outputs: 10 | % errors = (optional) column vector showing the number of (code bit) errors after each iteration. 11 | % 12 | % Required inputs: 13 | % input = the decoder input in LLR form 14 | % H_cols = a N row matrix specifying the locations of the nonzero entries in each column of the H matrix. 15 | % The number or columns in the matrix is the max column weight. 16 | % OR 17 | % a K row matrix specifying locations of the nonzero entries in each coulmn of an extended IRA type 18 | % sparse H1 matrix 19 | % H_rows = a N-K row matrix specifying the locations of the nonzero entries in each row of the H matrix. 20 | % The number or columns in the matrix is the max row weight, unless this is for an H1 matrix, 21 | % in which case the last n-k columns of the H matrix are equal to a known H2 matrix. 22 | % 23 | % Optional inputs: 24 | % max_iter = the maximum number of decoder iterations (default = 30). 25 | % dec_type = the decoder type: 26 | % = 0 Sum-product (default) 27 | % = 1 Min-sum 28 | % = 2 Approximate-min-star 29 | % r_scale_factor = amount to scale extrinsic output of c-nodes in min-sum decoding (default = 1) 30 | % q_scale_factor = amount to scale extrinsic output of v-nodes in min-sum decoding (default = 1) 31 | % data = a vector containing the data bits (used for counting errors and for early halting) (default all zeros) 32 | % 33 | % Copyright (C) 2005-2007, Matthew C. Valenti and Rohit Iyer Seshadri 34 | % 35 | % Last updated on July 21, 2007 36 | % 37 | % Function Mpdecode is part of the Iterative Solutions 38 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 39 | % Library is free software; you can redistribute it and/or modify it 40 | % under the terms of the GNU Lesser General Public License as published 41 | % by the Free Software Foundation; either version 2.1 of the License, 42 | % or (at your option) any later version. 43 | % 44 | % This library is distributed in the hope that it will be useful, 45 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 46 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 47 | % Lesser General Public License for more details. 48 | % 49 | % You should have received a copy of the GNU Lesser General Public 50 | % License along with this library; if not, write to the Free Software 51 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /cml/mexhelp/Puncture.m: -------------------------------------------------------------------------------- 1 | % Puncture deletes bits at output of encoder according to puncutring pattern 2 | % 3 | % The calling syntax is: 4 | % [output] = Puncture(input, pun_pattern, tail_pattern ) 5 | % 6 | % output = Punctured sequence 7 | % 8 | % input = Code bits to be punctured 9 | % pun_pattern = Puncturing pattern for encoded data bits 10 | % tail_pattern = Puncturing pattern for encoded tail bits 11 | % 12 | % Copyright (C) 2005, Matthew C. Valenti 13 | % 14 | % Last updated on Nov. 28, 2005 15 | % 16 | % Function Puncture is part of the Iterative Solutions 17 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 18 | % Library is free software; you can redistribute it and/or modify it 19 | % under the terms of the GNU Lesser General Public License as published 20 | % by the Free Software Foundation; either version 2.1 of the License, 21 | % or (at your option) any later version. 22 | % 23 | % This library is distributed in the hope that it will be useful, 24 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 | % Lesser General Public License for more details. 27 | % 28 | % You should have received a copy of the GNU Lesser General Public 29 | % License along with this library; if not, write to the Free Software 30 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /cml/mexhelp/SisoDecode.m: -------------------------------------------------------------------------------- 1 | % SisoDecode performs soft-in/soft-out decodeing of a convolutional code. 2 | % 3 | % The calling syntax is: 4 | % [output_u, output_c] = SisoDecode(input_u, input_c, g_encoder, [code_type], [dec_type] ) 5 | % 6 | % output_u = LLR of the data bits 7 | % output_c = LLR of the code bits 8 | % 9 | % Required inputs: 10 | % input_u = APP of the data bits 11 | % input_c = APP of the code bits 12 | % g_encoder = generator matrix for convolutional code 13 | % (If RSC, then feedback polynomial is first) 14 | % 15 | % Optional inputs: 16 | % code_type = 0 for RSC outer code (default) 17 | % = 1 for NSC outer code 18 | % dec_type = the decoder type: 19 | % = 0 For linear approximation to log-MAP (DEFAULT) 20 | % = 1 For max-log-MAP algorithm (i.e. max*(x,y) = max(x,y) ) 21 | % = 2 For Constant-log-MAP algorithm 22 | % = 3 For log-MAP, correction factor from small nonuniform table and interpolation 23 | % = 4 For log-MAP, correction factor uses C function calls (slow) ) 24 | % 25 | % Copyright (C) 2005, Matthew C. Valenti 26 | % 27 | % Last updated on Nov. 28, 2005 28 | % 29 | % Function SisoDecode is part of the Iterative Solutions 30 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 31 | % Library is free software; you can redistribute it and/or modify it 32 | % under the terms of the GNU Lesser General Public License as published 33 | % by the Free Software Foundation; either version 2.1 of the License, 34 | % or (at your option) any later version. 35 | % 36 | % This library is distributed in the hope that it will be useful, 37 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 38 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 39 | % Lesser General Public License for more details. 40 | % 41 | % You should have received a copy of the GNU Lesser General Public 42 | % License along with this library; if not, write to the Free Software 43 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /cml/mexhelp/Somap.m: -------------------------------------------------------------------------------- 1 | % Somap performs soft demapping (converts M-ary symbol likelihoods to bitwise LLRs). 2 | % 3 | % The calling syntax is: 4 | % [output] = Somap( input, [demod_type], [extrinsic_info] ) 5 | % 6 | % output = Length N*log2(M) stream of LLR values 7 | % 8 | % Required inputs: 9 | % input = M by N matrix of symbol likelihoods 10 | % 11 | % Optional inputs: 12 | % demod_type = The type of max_star algorithm that is used 13 | % = 0 For linear approximation to log-MAP (DEFAULT) 14 | % = 1 For max-log-MAP algorithm (i.e. max*(x,y) = max(x,y) ) 15 | % = 2 For Constant-log-MAP algorithm 16 | % = 3 For log-MAP, correction factor from small nonuniform table and interpolation 17 | % = 4 For log-MAP, correction factor uses C function calls 18 | % extrinsic_info = 1 by N*log2(M) vector of extrinsic info (defaults to all-zero) 19 | % 20 | % Copyright (C) 2005, Matthew C. Valenti 21 | % 22 | % Last updated on Nov. 28, 2005 23 | % 24 | % Function Somap is part of the Iterative Solutions 25 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 26 | % Library is free software; you can redistribute it and/or modify it 27 | % under the terms of the GNU Lesser General Public License as published 28 | % by the Free Software Foundation; either version 2.1 of the License, 29 | % or (at your option) any later version. 30 | % 31 | % This library is distributed in the hope that it will be useful, 32 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 33 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 34 | % Lesser General Public License for more details. 35 | % 36 | % You should have received a copy of the GNU Lesser General Public 37 | % License along with this library; if not, write to the Free Software 38 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -------------------------------------------------------------------------------- /cml/mexhelp/ViterbiDecode.m: -------------------------------------------------------------------------------- 1 | % ViterbiDecode performs soft-in/hard-out decoding for a convolutional code using the Viterbi algorithm 2 | % 3 | % The calling syntax is: 4 | % [output_u] = ViterbiDecode( input_c, g_encoder, [code_type], [depth] ) 5 | % 6 | % output_u = hard decisions on the data bits (0 or 1) 7 | % 8 | % Required inputs: 9 | % input_c = LLR of the code bits (based on channel observations) 10 | % g_encoder = generator matrix for convolutional code 11 | % (If RSC, then feedback polynomial is first) 12 | % 13 | % Optional inputs: 14 | % code_type = 0 for recursive systematic convolutional (RSC) code (default) 15 | % = 1 for non-systematic convolutional (NSC) code 16 | % = 2 for tail-biting NSC code 17 | % depth = wrap depth used for tail-biting decoding 18 | % default is 6 times the constraint length 19 | % 20 | % Copyright (C) 2005-2008, Matthew C. Valenti 21 | % 22 | % Last updated on May 21, 2008 23 | % 24 | % Function ViterbiDecode is part of the Iterative Solutions 25 | % Coded Modulation Library. The Iterative Solutions Coded Modulation 26 | % Library is free software; you can redistribute it and/or modify it 27 | % under the terms of the GNU Lesser General Public License as published 28 | % by the Free Software Foundation; either version 2.1 of the License, 29 | % or (at your option) any later version. 30 | % 31 | % This library is distributed in the hope that it will be useful, 32 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 33 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 34 | % Lesser General Public License for more details. 35 | % 36 | % You should have received a copy of the GNU Lesser General Public 37 | % License along with this library; if not, write to the Free Software 38 | % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 39 | -------------------------------------------------------------------------------- /cml/scenarios/CmlHome.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahmadnimr/Generalized-GFDM-Framework-/048256608576d7eefa6d90c2a43fd13d04d00893/cml/scenarios/CmlHome.mat -------------------------------------------------------------------------------- /cml/source/CreateCcsdsInterleaver.c: -------------------------------------------------------------------------------- 1 | /* file: CreateCcsdsInterleaver.c 2 | 3 | Description: Produce an interleaver according to the CCSDS spec. 4 | 5 | The calling syntax is: 6 | 7 | [alpha] = CreateCcsdsInterleaver( K ) 8 | 9 | alpha = the interleaver in a length K vector 10 | 11 | K = the size of the interleaver 12 | 13 | Copyright (C) 2006, Matthew C. Valenti 14 | 15 | Last updated on June 24, 2006 16 | 17 | Function CreateCcsdsInterleaver is part of the Iterative Solutions 18 | Coded Modulation Library. The Iterative Solutions Coded Modulation 19 | Library is free software; you can redistribute it and/or modify it 20 | under the terms of the GNU Lesser General Public License as published 21 | by the Free Software Foundation; either version 2.1 of the License, 22 | or (at your option) any later version. 23 | 24 | This library is distributed in the hope that it will be useful, 25 | but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | Lesser General Public License for more details. 28 | 29 | You should have received a copy of the GNU Lesser General Public 30 | License along with this library; if not, write to the Free Software 31 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 32 | 33 | */ 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | /* library of functions */ 40 | #include "./include/interleaver.h" 41 | 42 | /* Input Arguments */ 43 | #define INPUT prhs[0] 44 | 45 | /* Output Arguments */ 46 | #define OUTPUT plhs[0] 47 | 48 | /* main function that interfaces with MATLAB */ 49 | void mexFunction( 50 | int nlhs, 51 | mxArray *plhs[], 52 | int nrhs, 53 | const mxArray *prhs[] ) 54 | { 55 | int DataLength; 56 | double *output_p; 57 | int *alpha_code; /* interleaver */ 58 | int i; 59 | 60 | /* Check for proper number of arguments */ 61 | if (nrhs < 1) { 62 | mexErrMsgTxt("[alpha] = CreateCcsdsInterleaver( K )"); 63 | } else if (nlhs > 1) { 64 | mexErrMsgTxt("[alpha] = CreateCcsdsInterleaver( K )"); 65 | } 66 | 67 | /* initialize the input data */ 68 | DataLength = (int) *mxGetPr(INPUT); 69 | 70 | if ( !( ( DataLength == 1784 )||( DataLength == 3568 )||( DataLength == 7136 )||( DataLength == 8920 ) ) ) 71 | mexErrMsgTxt("CreateCcsdsInterleaver: CCSDS Interleaver size must be 7184, 3568, 7136, or 8920"); 72 | 73 | /* Create the interleaver */ 74 | /* printf( "\nMaking interleaver\n" ); */ 75 | alpha_code = calloc( DataLength, sizeof(int) ); 76 | 77 | CreateCcsdsInterleaver( DataLength, alpha_code ); 78 | /* printf( "Done making the interleaver\n" ); 79 | printf( "K = %d\n", DataLength ); */ 80 | 81 | /* Output encoded data */ 82 | OUTPUT = mxCreateDoubleMatrix(1, DataLength, mxREAL); 83 | output_p = mxGetPr(OUTPUT); 84 | 85 | for (i=0;i 36 | #include 37 | #include 38 | #include 39 | 40 | /* library of functions */ 41 | #include "./include/srandom.h" 42 | 43 | /* Input Arguments */ 44 | #define LENGTH prhs[0] 45 | #define SVAL prhs[1] 46 | 47 | /* Output Arguments */ 48 | #define OUTPUT plhs[0] 49 | 50 | /* main function that interfaces with MATLAB */ 51 | void mexFunction( 52 | int nlhs, 53 | mxArray *plhs[], 54 | int nrhs, 55 | const mxArray *prhs[] ) 56 | { 57 | int DataLength; 58 | double *output_p; 59 | int *alpha_code; /* interleaver */ 60 | int i; 61 | int s_value; 62 | 63 | /* Check for proper number of arguments */ 64 | if (nrhs != 2) { 65 | mexErrMsgTxt("[alpha] = CreateSRandomInterleaver( Length, S )"); 66 | } else if (nlhs > 1) { 67 | mexErrMsgTxt("[alpha] = CreateSRandomInterleaver( Length, S )"); 68 | } 69 | 70 | /* initialize the input data */ 71 | DataLength = (int) *mxGetPr(LENGTH); 72 | s_value = (int) *mxGetPr(SVAL); 73 | 74 | /* Create the interleaver */ 75 | /* printf( "\nMaking interleaver\n" ); */ 76 | alpha_code = calloc( DataLength, sizeof(int) ); 77 | 78 | CreateSRandomInterleaver( DataLength, s_value, alpha_code ); 79 | /* printf( "Done making the interleaver\n" ); 80 | printf( "K = %d\n", DataLength ); */ 81 | 82 | /* Output encoded data */ 83 | OUTPUT = mxCreateDoubleMatrix(1, DataLength, mxREAL); 84 | output_p = mxGetPr(OUTPUT); 85 | 86 | for (i=0;i 35 | #include 36 | #include 37 | #include 38 | 39 | /* library of functions */ 40 | #include "./include/interleaver.h" 41 | 42 | /* Input Arguments */ 43 | #define INPUT prhs[0] 44 | 45 | /* Output Arguments */ 46 | #define OUTPUT plhs[0] 47 | 48 | /* main function that interfaces with MATLAB */ 49 | void mexFunction( 50 | int nlhs, 51 | mxArray *plhs[], 52 | int nrhs, 53 | const mxArray *prhs[] ) 54 | { 55 | int DataLength; 56 | double *output_p; 57 | int *alpha_code; /* interleaver */ 58 | int *interleaver_input; /* Temporary array used to initialize the interleaver. */ 59 | int i; 60 | 61 | /* Check for proper number of arguments */ 62 | if (nrhs < 1) { 63 | mexErrMsgTxt("[alpha] = CreateUmtsInterleaver( K )"); 64 | } else if (nlhs > 2) { 65 | mexErrMsgTxt("[alpha] = CreateUmtsInterleaver( K )"); 66 | } 67 | 68 | /* initialize the input data */ 69 | DataLength = (int) *mxGetPr(INPUT); 70 | 71 | if ( (DataLength < 40)|( DataLength > 5114) ) 72 | mexErrMsgTxt("CreateUmtsInterleaver: Input must be between 40 and 5114"); 73 | 74 | /* Create the interleaver */ 75 | alpha_code = calloc( DataLength, sizeof(int) ); 76 | interleaver_input = calloc( DataLength, sizeof(int) ); 77 | for (i=0;i 36 | #include 37 | #include 38 | #include 39 | 40 | /* Input Arguments */ 41 | #define INPUT prhs[0] 42 | #define ALPHA prhs[1] 43 | 44 | /* Output Arguments */ 45 | #define OUTPUT plhs[0] 46 | 47 | /* main function that interfaces with MATLAB */ 48 | void mexFunction( 49 | int nlhs, 50 | mxArray *plhs[], 51 | int nrhs, 52 | const mxArray *prhs[] ) 53 | { 54 | double *input, *alpha; 55 | double *output_p; 56 | int InterleaverLength, i, index; 57 | 58 | /* Check for proper number of arguments */ 59 | if ((nrhs < 2 )||(nlhs > 1)) { 60 | mexErrMsgTxt("Usage: [output] = Deinterleave(input, alpha_code )"); 61 | } else { 62 | /* first input is the data word */ 63 | input = mxGetPr(INPUT); 64 | InterleaverLength = mxGetN(INPUT); /* number of data bits */ 65 | 66 | /* second input is the interleaver */ 67 | if ( mxGetN(ALPHA) != InterleaverLength ) 68 | mexErrMsgTxt("Deinterleave: Error input and alpha_code must be same length"); 69 | alpha = mxGetPr(ALPHA); 70 | 71 | OUTPUT = mxCreateDoubleMatrix(1, InterleaverLength, mxREAL ); 72 | output_p = mxGetPr(OUTPUT); 73 | 74 | /* Interleave */ 75 | for(i=0;i 35 | #include 36 | #include 37 | #include 38 | 39 | /* Input Arguments */ 40 | #define INPUT prhs[0] 41 | #define ALPHA prhs[1] 42 | 43 | /* Output Arguments */ 44 | #define OUTPUT plhs[0] 45 | 46 | /* main function that interfaces with MATLAB */ 47 | void mexFunction( 48 | int nlhs, 49 | mxArray *plhs[], 50 | int nrhs, 51 | const mxArray *prhs[] ) 52 | { 53 | double *input, *alpha; 54 | double *output_p; 55 | int InterleaverLength, i, index; 56 | 57 | /* Check for proper number of arguments */ 58 | if ((nrhs < 2 )||(nlhs > 1)) { 59 | mexErrMsgTxt("Usage: [output] = Interleave(input, alpha_code )"); 60 | } else { 61 | /* first input is the data word */ 62 | input = mxGetPr(INPUT); 63 | InterleaverLength = mxGetN(INPUT); /* number of data bits */ 64 | 65 | /* second input is the interleaver */ 66 | if ( mxGetN(ALPHA) != InterleaverLength ) 67 | mexErrMsgTxt("Interleave: Error input and alpha_code must be same length"); 68 | alpha = mxGetPr(ALPHA); 69 | 70 | OUTPUT = mxCreateDoubleMatrix(1, InterleaverLength, mxREAL ); 71 | output_p = mxGetPr(OUTPUT); 72 | 73 | /* Interleave */ 74 | for(i=0;i 38 | #include 39 | #include 40 | #include 41 | 42 | /* main function that interfaces with MATLAB */ 43 | void mexFunction( 44 | int nlhs, 45 | mxArray *plhs[], 46 | int nrhs, 47 | const mxArray *prhs[] ) 48 | { 49 | double *input, *output_p; 50 | int X_i, e_ini, e_plus, e_minus; 51 | int m, e, index, input_length; 52 | 53 | /* Check for proper number of arguments */ 54 | if ((nrhs < 5 )||(nlhs > 1)) { 55 | mexErrMsgTxt("Usage: y = RateDematch( x, X_i, e_ini, e_plus, e_minus )"); 56 | } 57 | 58 | /* first input vector that needs to have rate matching reversed */ 59 | input = mxGetPr( prhs[0] ); 60 | input_length = mxGetN( prhs[0] ); /* length of input */ 61 | 62 | /* remaining inputs (all ints) */ 63 | X_i = (int) *mxGetPr( prhs[1] ); 64 | e_ini = (int) *mxGetPr( prhs[2] ); 65 | e_plus = (int) *mxGetPr( prhs[3] ); 66 | e_minus = (int) *mxGetPr( prhs[4] ); 67 | 68 | /* verify that input length is correct 69 | development note: eventually this could be replaced by a formula */ 70 | e = e_ini; 71 | index = 1; 72 | for (m=1;m<=X_i;m++) { 73 | e -= e_minus; 74 | if (e<=0) 75 | e += e_plus; 76 | else 77 | index++; 78 | } 79 | 80 | index--; 81 | if ( index != input_length ) 82 | mexErrMsgTxt("Input length is invalid"); 83 | 84 | /* Create output */ 85 | plhs[0] = mxCreateDoubleMatrix( 1, X_i, mxREAL ); 86 | output_p = mxGetPr( plhs[0] ); 87 | 88 | /* Dematch */ 89 | e = e_ini; 90 | index = 1; 91 | for (m=1;m<=X_i;m++) { 92 | e -= e_minus; 93 | if (e<=0) { 94 | /* zero pad */ 95 | e += e_plus; 96 | } else { 97 | output_p[m-1] = input[index-1]; 98 | index++; 99 | } 100 | } 101 | 102 | return; 103 | } 104 | -------------------------------------------------------------------------------- /cml/source/RateMatch.c: -------------------------------------------------------------------------------- 1 | /* RateMatch performs the basic HSDPA Rate Matching algorithm 2 | 3 | The calling syntax is: 4 | y = RateMatch( x, X_i, e_ini, e_plus, e_minus ) 5 | 6 | y = output of rate matching algorithm 7 | 8 | x = input to rate matching algorithm (length X_i) 9 | X_i = length of the depunctured output 10 | e_ini = parameter used by algorithm 11 | e_plus = parameter used by algorithm 12 | e_minus = parameter used by algorithm 13 | 14 | Copyright (C) 2005, Matthew C. Valenti 15 | 16 | Last updated on Dec. 3, 2005 17 | 18 | 19 | Function RateMatch is part of the Iterative Solutions 20 | Coded Modulation Library. The Iterative Solutions Coded Modulation 21 | Library is free software; you can redistribute it and/or modify it 22 | under the terms of the GNU Lesser General Public License as published 23 | by the Free Software Foundation; either version 2.1 of the License, 24 | or (at your option) any later version. 25 | 26 | This library is distributed in the hope that it will be useful, 27 | but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | Lesser General Public License for more details. 30 | 31 | You should have received a copy of the GNU Lesser General Public 32 | License along with this library; if not, write to the Free Software 33 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 34 | 35 | */ 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | /* main function that interfaces with MATLAB */ 43 | void mexFunction( 44 | int nlhs, 45 | mxArray *plhs[], 46 | int nrhs, 47 | const mxArray *prhs[] ) 48 | { 49 | double *input, *output_p; 50 | int X_i, e_ini, e_plus, e_minus; 51 | int m, e, index, input_length, output_length; 52 | 53 | /* Check for proper number of arguments */ 54 | if ((nrhs < 5 )||(nlhs > 1)) { 55 | mexErrMsgTxt("Usage: y = RateMatch( x, X_i, e_ini, e_plus, e_minus )"); 56 | } 57 | 58 | /* first input vector that needs to be rate matched */ 59 | input = mxGetPr( prhs[0] ); 60 | input_length = mxGetN( prhs[0] ); /* length of input */ 61 | 62 | /* remaining inputs (all ints) */ 63 | X_i = (int) *mxGetPr( prhs[1] ); 64 | e_ini = (int) *mxGetPr( prhs[2] ); 65 | e_plus = (int) *mxGetPr( prhs[3] ); 66 | e_minus = (int) *mxGetPr( prhs[4] ); 67 | 68 | /* verify that input length is correct */ 69 | if ( X_i != input_length ) 70 | mexErrMsgTxt("Input length is not consistent with X_i"); 71 | 72 | /* determine output length 73 | development note: eventually this could be replaced by a formula */ 74 | e = e_ini; 75 | index = 1; 76 | for (m=1;m<=X_i;m++) { 77 | e -= e_minus; 78 | if (e<=0) 79 | e += e_plus; 80 | else 81 | index++; 82 | } 83 | 84 | output_length = index-1; 85 | 86 | 87 | /* Create output */ 88 | plhs[0] = mxCreateDoubleMatrix( 1, output_length, mxREAL ); 89 | output_p = mxGetPr( plhs[0] ); 90 | 91 | /* Match */ 92 | e = e_ini; 93 | index = 1; 94 | for (m=1;m<=X_i;m++) { 95 | e -= e_minus; 96 | if (e<=0) { 97 | /* zero pad */ 98 | e += e_plus; 99 | } else { 100 | output_p[index-1] = input[m-1]; 101 | index++; 102 | } 103 | } 104 | 105 | return; 106 | } 107 | -------------------------------------------------------------------------------- /cml/source/make.m: -------------------------------------------------------------------------------- 1 | % makefile for the CML mex files 2 | % 3 | % Last updated July 4, 2006 4 | 5 | % first clear all the mex files 6 | clear Capacity.c 7 | clear CapacityTableLookup.c 8 | clear ConvEncode.c 9 | clear CreateSRandomInterleaver.c 10 | clear CreateUmtsInterleaver.c 11 | clear CreateCcsdsInterleaver.c 12 | clear Deinterleave.c 13 | clear Depuncture.c 14 | clear InitializeDVBS2.c 15 | clear Interleave.c 16 | clear LdpcEncode.c 17 | clear MpDecode.c 18 | clear Puncture.c 19 | clear RateDematch.c 20 | clear RateMatch.c 21 | clear SisoDecode.c 22 | clear Somap.c 23 | clear ViterbiDecode.c 24 | clear Modulate.c 25 | clear DemodFSK.c 26 | clear Demod2D.c 27 | 28 | % if this is linux, the files need to be deleted 29 | if isunix 30 | delete ../mex/* 31 | end 32 | 33 | % determine version 34 | tempstring = version; 35 | if (( strcmp(tempstring(1:3), '7.2' )|strcmp(tempstring(1:3), '7.1' ) )&ispc) % version 7.1 or 7.2 36 | mex -output ../mex/Capacity.dll Capacity.c 37 | mex -output ../mex/CapacityTableLookup.dll CapacityTableLookup.c 38 | mex -output ../mex/ConvEncode.dll ConvEncode.c 39 | mex -output ../mex/CreateSRandomInterleaver.dll CreateSRandomInterleaver.c 40 | mex -output ../mex/CreateUmtsInterleaver.dll CreateUmtsInterleaver.c 41 | mex -output ../mex/CreateCcsdsInterleaver.dll CreateCcsdsInterleaver.c 42 | mex -output ../mex/Deinterleave.dll Deinterleave.c 43 | mex -output ../mex/Depuncture.dll Depuncture.c 44 | mex -output ../mex/InitializeDVBS2.dll InitializeDVBS2.c 45 | mex -output ../mex/Interleave.dll Interleave.c 46 | mex -output ../mex/LdpcEncode.dll LdpcEncode.c 47 | mex -output ../mex/MpDecode.dll MpDecode.c 48 | mex -output ../mex/Puncture.dll Puncture.c 49 | mex -output ../mex/RateDematch.dll RateDematch.c 50 | mex -output ../mex/RateMatch.dll RateMatch.c 51 | mex -output ../mex/SisoDecode.dll SisoDecode.c 52 | mex -output ../mex/Somap.dll Somap.c 53 | mex -output ../mex/ViterbiDecode.dll ViterbiDecode.c 54 | mex -output ../mex/Modulate.dll Modulate.c 55 | mex -output ../mex/DemodFSK.dll DemodFSK.c 56 | mex -output ../mex/Demod2D.dll Demod2D.c 57 | else 58 | mex -output ../mex/Capacity Capacity.c 59 | mex -output ../mex/CapacityTableLookup CapacityTableLookup.c 60 | mex -output ../mex/ConvEncode ConvEncode.c 61 | mex -output ../mex/CreateSRandomInterleaver CreateSRandomInterleaver.c 62 | mex -output ../mex/CreateUmtsInterleaver CreateUmtsInterleaver.c 63 | mex -output ../mex/CreateCcsdsInterleaver CreateCcsdsInterleaver.c 64 | mex -output ../mex/Deinterleave Deinterleave.c 65 | mex -output ../mex/Depuncture Depuncture.c 66 | mex -output ../mex/InitializeDVBS2 InitializeDVBS2.c 67 | mex -output ../mex/Interleave Interleave.c 68 | mex -output ../mex/LdpcEncode LdpcEncode.c 69 | mex -output ../mex/MpDecode MpDecode.c 70 | mex -output ../mex/Puncture Puncture.c 71 | mex -output ../mex/RateDematch RateDematch.c 72 | mex -output ../mex/RateMatch RateMatch.c 73 | mex -output ../mex/SisoDecode SisoDecode.c 74 | mex -output ../mex/Somap Somap.c 75 | mex -output ../mex/ViterbiDecode ViterbiDecode.c 76 | mex -output ../mex/Modulate Modulate.c 77 | mex -output ../mex/DemodFSK DemodFSK.c 78 | mex -output ../mex/Demod2D Demod2D.c 79 | end --------------------------------------------------------------------------------