// TransmitterClass.cpp: implementation of the TransmitterClass class.
//
//
// Copyright 2002 The Mobile and Portable Radio Research Group
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "TransmitterClass.h"
//#define LOG2(a) log( (double) a) / log(2.000000)
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
TransmitterClass::TransmitterClass(SimConfigClass Config)
/*****************************************************************************************************
/TransmitterClass(SimConfigClass Config)
/
/
/ Copyright 2002 The Mobile and Portable Radio Research Group
/
/This constuctor initailizes the transmitter object. In initalizing the object, it performs the
/following operations
/ 1. Initializes the slot format configurations for the DPCH
/ 2. Initializes the slot format configurations for the S_CCPCH
/ 3. Initializes the slto format configurations for the PDSCH
/ 4. Generates the channelization code for each of the SF required for the transmitter
/ 5. Generates the overal scambling sequence (the scrambling codes will come from this sequence
/ 6. Completes the configuration of all of the remaining physical channels. This includes
/ a. Allocation of Channelization Codes
/ b. Allocation of Srambling Codes
/ c. Setting the STTDflag
/ d. Setting the TPC command
/ 7. Determines the timing offsets for each of the frames
/ 8. Computes the relative gains for each of the frames
/ 9. Generates the first two frames of data
/
/Parameter
/ Config structure Contains all the configuration paramters for the simulation
/ Generated by user input
/*****************************************************************************************************/
{
//Format configurartions for Dedicated Physical Channels--refer to standard
DPCH_FormatStructure DPCH_Format[49] = {{"0 ",15,7.5,512,10,0,4,2,0,4,15,15},
{"0A ",15,7.5,512,10,0,4,2,0,4,8,14},
{"0B ",30,15,256,20,0,8,4,0,8,8,14},
{"1 ",15,7.5,512,10,0,2,2,2,4,15,15},
{"1B ",30,15,256,20,0,4,4,4,8,8,14},
{"2 ",30,15,256,20,2,14,2,0,2,15,15},
{"2A ",30,15,256,20,2,14,2,0,2,8,14},
{"2B ",60,30,128,40,4,28,4,0,4,8,14},
{"3 ",30,15,256,20,2,12,2,2,2,15,15},
{"3A ",30,15,256,20,2,12,2,2,2,8,14},
{"3B ",60,30,128,40,4,24,4,4,4,8,14},
{"4 ",30,15,256,20,2,12,2,0,4,15,15},
{"4A ",30,15,256,20,2,12,2,0,4,8,14},
{"4B ",60,30,128,40,4,24,4,0,8,8,14},
{"5 ",30,15,256,20,2,10,2,2,4,15,15},
{"5A ",30,15,256,20,2,8,2,4,4,8,14},
{"5B ",60,30,128,40,4,20,4,4,8,8,14},
{"6 ",30,15,256,20,2,8,2,0,8,15,15},
{"6A ",30,15,256,20,2,8,2,0,8,8,14},
{"6B ",60,30,128,40,4,16,4,0,16,8,14},
{"7 ",30,15,256,20,2,6,2,2,8,15,15},
{"7A ",30,15,256,20,2,4,2,4,8,8,14},
{"7B ",60,30,128,40,4,12,4,4,16,8,14},
{"8 ",60,30,128,40,6,28,2,0,4,15,15},
{"8A ",60,30,128,40,6,28,2,0,4,8,14},
{"8B ",120,60,64,80,12,56,4,0,8,8,14},
{"9 ",60,30,128,40,6,26,2,2,4,15,15},
{"9A",60,30,128,40,6,24,2,4,4,8,14},
{"9B",120,60,64,40,12,52,4,4,8,8,14},
{"10 ",60,30,128,40,6,24,2,0,8,15,15},
{"10A",60,30,128,40,6,24,2,0,8,8,14},
{"10B",120,60,64,80,12,48,4,0,16,8,14},
{"11 ",60,30,128,40,6,22,2,2,8,15,15},
{"11A",60,30,128,40,6,20,2,4,8,8,14},
{"11B",120,60,64,80,12,44,4,4,16,15,15},
{"12 ",120,60,64,80,12,48,4,8,8,15,15},
{"12A",120,60,64,80,12,40,4,16,8,8,14},
{"12B",240,120,32,160,24,96,8,16,16,8,14},
{"13 ",240,120,32,160,28,112,4,8,8,15,15},
{"13A",240,120,32,160,28,104,4,16,8,8,14},
{"13B",480,240,16,320,56,224,8,16,16,8,14},
{"14 ",480,240,16,320,56,232,8,8,16,15,15},
{"14A",480,240,16,320,56,224,8,16,16,8,14},
{"14B",960,480,8,640,112,464,16,16,32,8,14},
{"15 ",960,480,8,640,120,488,8,8,16,15,15},
{"15A",960,480,8,640,120,480,8,16,16,8,14},
{"15B",1920,960,4,1280,240,976,16,16,32,8,14},
{"16 ",1920,960,4,1280,248,1000,8,8,16,15,15},
{"16A",1920,960,4,1280,248,992,8,16,16,8,14}};
//Format configurations for the Common Control Physical Channel -- See WCDMA standard
CCPCH_FormatStructure CCPCH_Format[18] = {{0 ,30,15,256,300,20,20,0,0},
{1 ,30,15,256,300,20,12,8,0},
{2 ,30,15,256,300,20,18,0,2},
{3 ,30,15,256,300,20,10,8,2},
{4 ,60,30,128,600,40,40,0,0},
{5 ,60,30,128,600,40,32,8,0},
{6 ,60,30,128,600,40,38,0,2},
{7 ,60,30,128,600,40,30,8,2},
{8 ,120,60,64,1200,80,72,0,8},
{9 ,120,60,64,1200,80,64,8,8},
{10,240,120,32,2400,160,152,0,8},
{11,240,120,32,2400,160,144,8,8},
{12,480,240,16,4800,320,312,0,8},
{13,480,240,16,4800,320,396,16,8},
{14,960,480,8,9600,640,632,0,8},
{15,960,480,8,9600,640,616,16,8},
{16,1920,960,4,19200,1280,1272,0,8},
{17,1920,960,4,19200,1280,1256,16,8}};
//Format configurations PDSCH -- See WCDMA standard
PDSCH_FormatStructure PDSCH_Format[7] = {{0,30,15,256,300,20,20},
{1,60,30,128,600,40,40},
{2,120,60,64,1200,80,80},
{3,240,120,32,2400,160,160},
{4,480,240,16,4800,320,320},
{5,960,480,8,9600,640,640},
{6,1920,960,4,19200,1280,1280}};
int RandomNumberGeneratorInitFlag = -1,RandomNumberGeneratorFlag = 1;
unsigned PrimaryScrambleCode;
unsigned ScrambleCodeGroup;
unsigned SecondaryScrambleCodes[16]; //There 16 Secondary Scrambling Codes to each Primary Scrambling Code
unsigned k; //Loop Counter
unsigned TPCcommand=1; //Fix TPCcommand to 1 -- Can be modified later and even incorporated into GUI
DPCH_FormatStructure *TempFormatPtr; //Temporary Pointer to DPCH format configurations
unsigned *SSCtoSCHmappingPtr; //Maps Secondary Synchronization Codes to Synchronzation channels
ComplexNumber *SSCptr; //Pointer to Secondary Synchronizatoin Codes
unsigned *UIFormatPtr; //Pointer to the format IDs contained in the input structure (Config)
//Generate the Scrambing Code Group
ScrambleCodeGroup = (unsigned) (UniformRandomNumberGenerator(&RandomNumberGeneratorInitFlag) * 64.0);
//Generate the Primary Scambling code number
PrimaryScrambleCode = 128 * ScrambleCodeGroup
+ 16 * ((unsigned) (UniformRandomNumberGenerator(&RandomNumberGeneratorFlag) * 8.0));
//Compute the secondary scrambling code numbers
for (k=1; k<=15; k++) SecondaryScrambleCodes[k] = PrimaryScrambleCode + k;
//Set the STTD flag
TxConfiguration.STTDflag = Config.STTDflag;
//Set the number of Secondary Common PIlot CHannels
TxConfiguration.NumS_CPICH = Config.NumS_CPICH;
//Set the format of the Secondary Common Control Physical Channel
TxConfiguration.S_CCPCHformat = *(CCPCH_Format + Config.S_CCPCHformatID);
//Set the format of the Physical Data Shared CHannel
TxConfiguration.PDSCHformat = *(PDSCH_Format + Config.PDSCHformatID);
//Set the number of Digital Physical Control Channels for the Common Packet Channel
TxConfiguration.NumDPCCHforCPCH = Config.NumDPCCHforCPCH;
//Get the TCP command for the DPCCHforCPCH
TxConfiguration.DPCCHforCPCH_TPCcommand = TPCcommand;
//Set the DESIRED DPCH format
TxConfiguration.DesiredDPCHformat = *(DPCH_Format + Config.DesiredDPCHformatID);
//Set the number of actual slots per frame to the maximum allowable -- Can be revised l