?? transmitterclass.cpp
字號(hào):
// 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 later to fit in GUI
TxConfiguration.DesiredDPCHformat.ActualSlotsPerFrame = TxConfiguration.DesiredDPCHformat.MaxSlotsPerFrame;
//Get the TPC command for the Desired DPCH channel
TxConfiguration.DesiredTPCcommand = TPCcommand;
//Get the Number of Other DPCH Channels
TxConfiguration.NumOtherDPCH = Config.Num_DPCH;
//Get the TPC command for the other DPCH channels. We assume that all of these channels have the same TPC command
TxConfiguration.OtherTPCcommand = TPCcommand;
//Allocate an array to store the format configurations of the remaining DPCHs
TxConfiguration.OtherDPCHformat = (DPCH_FormatStructure *) calloc(TxConfiguration.NumOtherDPCH,sizeof(DPCH_FormatStructure));
//Assign Temporary Pointers to the format array
TempFormatPtr = TxConfiguration.OtherDPCHformat;
//Assign Temporary Pointer to the format ID array in the Config structure (input parameter
UIFormatPtr = Config.OtherDPCHformatID;
//Set the format for each of the "Other DPCH" channels. Store the format in the TxConfiguration.OtherDPCHforat
//array, which was just allocated
for (k=0; k<TxConfiguration.NumOtherDPCH; k++) *TempFormatPtr++ = *(DPCH_Format + *UIFormatPtr++);
//Assign Channelization Codes and Scrambling Codes
CodeManager(PrimaryScrambleCode,SecondaryScrambleCodes);
//*******************************************************************************
//Generate Primary Common Pilot channel
P_CPICHptr = GenP_CPICH(TxConfiguration.STTDflag,TxConfiguration.P_CPICHScrambleCode);
//Primary Common Pilot Channel generated
//*******************************************************************************
//Generate Primary Synch Channel
if (Config.STTDflag) TxConfiguration.A = 1.0;
else TxConfiguration.A = -1.0;
P_SCHptr = GenP_SCH(TxConfiguration.A,TxConfiguration.STTDflag);
//Primary Synch Channel Generated
//*******************************************************************************
//Generate Secondary Synch Channel
//Generate Secondary synchronization Sequence
SSCptr = GenSSC();
//Generate SSC to Secondary Synch Channel Mapping
SSCtoSCHmappingPtr = GetSSCtoSCHmap(ScrambleCodeGroup);
//Generate the Secondary Synch Channel
S_SCHptr = GenS_SCH(SSCptr,SSCtoSCHmappingPtr,TxConfiguration.A,TxConfiguration.STTDflag);
//free SSCtoSCH mapping pointer
free(SSCtoSCHmappingPtr);
//Secondary Synch Channel Generated
//*******************************************************************************
//Configure Gain Structure
//This can be configured dynamically by incorparated the setting of channel gains
//into the user interface or by making it some parameter of the simulation.
//However, for now all gains will be hard coded to 1
//For the Time being set all gain values to 1
Gains.DesiredDPCH = 1.0;
Gains.P_CCPCH = 0.0;
Gains.P_CPICH = 0.0;
Gains.P_SCH = 0.0;
Gains.PDSCH = 0.0;
Gains.S_CCPCH = 0.0;
Gains.S_SCH = 0.0;
Gains.DPCHforCPCH = (double *) calloc(TxConfiguration.NumDPCCHforCPCH,sizeof(double));
for (k=0; k<TxConfiguration.NumDPCCHforCPCH; k++) *(Gains.DPCHforCPCH + k) = 0.0;
Gains.OtherDPCH = (double *) calloc(TxConfiguration.NumOtherDPCH,sizeof(double));
for (k=0; k<TxConfiguration.NumOtherDPCH; k++) *(Gains.OtherDPCH + k) = 0.0;
Gains.S_CPICH = (double *) calloc(TxConfiguration.NumS_CPICH,sizeof(double));
for (k=0; k<TxConfiguration.NumS_CPICH; k++) *(Gains.S_CPICH + k) = 0.0;
//Gains Configured
//*******************************************************************************
//Determine channel frame offsets
//This can be configured dynamically by incorparated the setting of timing offesets
//into the user interface or by making it some parameter of the simulation.
//However, for now all timing offsets will be set to 0. This is done
//to ensure that all channels are orthogonal (when orthogonality is possible)
// ALL CHANNEL TIME OFFSETS WILL BE SET TO 0
// Timing.DesiredDPCH = GetTiming();
Timing.DesiredDPCH = 0;
Timing.P_CCPCH = 0;
Timing.P_CPICH = 0;
Timing.PDSCH = 0;
Timing.P_SCH = 0;
Timing.S_SCH = 0;
// Timing.S_CCPCH = GetTiming();
Timing.S_CCPCH = 0;
Timing.S_CPICH = (int *) calloc(TxConfiguration.NumS_CPICH,sizeof(int));
// for (k=0; k<TxConfiguration.NumS_CPICH; k++) *(Timing.S_CPICH+ k) = GetTiming();
for (k=0; k<TxConfiguration.NumS_CPICH; k++) *(Timing.S_CPICH+ k) = 0;
Timing.OtherDPCH = (int *) calloc(TxConfiguration.NumOtherDPCH,sizeof(int));
// for (k=0; k<TxConfiguration.NumOtherDPCH; k++) *(Timing.OtherDPCH + k) = GetTiming();
for (k=0; k<TxConfiguration.NumOtherDPCH; k++) *(Timing.OtherDPCH + k) = 0;
Timing.DPCHforCPCH = (int *) calloc(TxConfiguration.NumDPCCHforCPCH,sizeof(int));
// for (k=0; k<TxConfiguration.NumDPCCHforCPCH; k++) *(Timing.DPCHforCPCH + k) = GetTiming();
for (k=0; k<TxConfiguration.NumDPCCHforCPCH; k++) *(Timing.DPCHforCPCH + k) = 0;
//Channel frame offsets computed
//*******************************************************************************
//Compute offsets relative to the desired DPCH timeing
RelativeOffset.P_CCPCH= Timing.P_CCPCH- Timing.DesiredDPCH;
RelativeOffset.P_CPICH = Timing.P_CPICH - Timing.DesiredDPCH;
RelativeOffset.PDSCH = Timing.PDSCH - Timing.DesiredDPCH;
RelativeOffset.P_SCH = Timing.P_SCH - Timing.DesiredDPCH;
RelativeOffset.S_SCH = Timing.S_SCH - Timing.DesiredDPCH;
RelativeOffset.DesiredDPCH = 0;
RelativeOffset.S_CCPCH = Timing.S_CCPCH - Timing.DesiredDPCH;
RelativeOffset.S_CPICH = (int *) calloc(TxConfiguration.NumS_CPICH,sizeof(int));
for (k=0;k<TxConfiguration.NumS_CPICH; k++) *(RelativeOffset.S_CPICH + k) -= Timing.DesiredDPCH;
RelativeOffset.OtherDPCH = (int *) calloc(TxConfiguration.NumOtherDPCH,sizeof(int));
for (k=0; k<TxConfiguration.NumOtherDPCH; k++) *(RelativeOffset.OtherDPCH + k) = *(Timing.OtherDPCH + k) - Timing.DesiredDPCH;
RelativeOffset.DPCHforCPCH = (int *) calloc(TxConfiguration.NumDPCCHforCPCH,sizeof(int));
for (k=0; k<TxConfiguration.NumDPCCHforCPCH; k++) *(RelativeOffset.DPCHforCPCH + k) = *(Timing.DPCHforCPCH + k) - Timing.DesiredDPCH;
// Initialize Physical Channel Frames
PreviousPCHframe.ConfigurePCHframe(TxConfiguration);
CurrentPCHframe.ConfigurePCHframe(TxConfiguration);
NextPCHframe.ConfigurePCHframe(TxConfiguration);
// PreviousPCHframe = PCHframe;
// CurrentPCHframe = PCHframe;
// NextPCHframe = PCHframe;
}
TransmitterClass::~TransmitterClass()
/********************************************************************************************
/ TransmitterClass::~TransmitterClass()
/
/ Copyright 2002 The Mobile and Portable Radio Research Group
/
/ Destructor for objects of type TransmitterClass. Deallocates all dynamically allocted
/ arrays and matricies
/********************************************************************************************/
{
unsigned k;
free(TxConfiguration.OtherDPCHformat);
//Free memory storing OVSF codes
//These will (hopefully) not be freed elsewhere,
//so a null check should not be required
free(Chan4);
Chan4 = NULL;
free(Chan8);
Chan8 = NULL;
free(Chan16);
Chan16 = NULL;
free(Chan32);
Chan32 = NULL;
free(Chan64);
Chan64 = NULL;
free(Chan128);
Chan128 = NULL;
free(Chan256);
Chan256 = NULL;
free(Chan512);
Chan512 = NULL;
//Free Scramble Codes
//These will (hopefully) not be freed elsewhere,
//so a null check should not be required
free(TxConfiguration.DesiredScrambleCode);
TxConfiguration.DesiredScrambleCode = NULL;
for (k=0;k<TxConfiguration.NumDPCCHforCPCH;k++)
{
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -