⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 transmitterclass.h

📁 用matlab程序实现WCDMA系统的仿真
💻 H
字号:
// TransmitterClass.h: interface for the TransmitterClass class.
//
// Copyright 2002 The Mobile and Portable Radio Research Group
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_TRANSMITTERCLASS_H__5B796C11_11B3_11D5_817F_B57425EF4323__INCLUDED_)
#define AFX_TRANSMITTERCLASS_H__5B796C11_11B3_11D5_817F_B57425EF4323__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <math.h> 
#include <malloc.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
//#include "Complex.h"


//typedef class ComplexNumbertag
//{
//public:
//	double real;
//	double imaginary;
//} ComplexNumber;


#define	SEQUENCE_LENGTH	50000	
#define CHIPS_PER_FRAME	38400
#define BUFFER_LENGTH	18
#define ARRAY_LENGTH	20
#define SLOTS_PER_FRAME	15

#define LOG2(arg) (log( (double) arg)/log( (double) 2.00))


class DPCH_FormatStructure  
{
public:
	char format[4];
	unsigned BitRate;			//in kbps
	double SymbolRate;			//in kSps
	unsigned SF;				//Spreading Factor
	unsigned BitsPerSlot;		//Total number of bits per slot
	unsigned Ndata1;			//Number of data bits per slot in 1st data field
	unsigned Ndata2;			//Number of data bits per slot in 2nd data field
	unsigned Ntpc;				//Number of Transmit Power control bits per slot
	unsigned Ntfci;				//Number of TFCI bits per slot
	unsigned NPilot;			//Number of pilot bits per slot
	unsigned MinSlotsPerFrame;	//Minimum number of slots per frame
	unsigned MaxSlotsPerFrame;	//Maximum number of slots per frame
	unsigned ActualSlotsPerFrame;	//The number of slots actually used -> Filled by user
};


class CCPCH_FormatStructure
{
public:
	unsigned format;
	unsigned BitRate;			//in kbps
	double SymbolRate;			//in kSps
	unsigned SF;				//Spreading Factor
	unsigned BitsPerFrame;		//Total number of bits per frame
	unsigned BitsPerSlot;		//Total number of bits per slot
	unsigned Ndata;				//Number of data bits per slot in data field
	unsigned NPilot;			//Number of pilot bits per slot
	unsigned Ntfci;				//Number of TFCI bits per slot
};

class PDSCH_FormatStructure
{
public:
	unsigned format;
	unsigned BitRate;			//in kbps
	double SymbolRate;			//in kSps
	unsigned SF;				//Spreading Factor
	unsigned BitsPerFrame;		//Total number of bits per frame
	unsigned BitsPerSlot;		//Total number of bits per slot
	unsigned Ndata;				//Number of data bits per slot in data field
};




class TransmitterConfigClass
{
public:
		bool		STTDflag;			//TRUE of STTD is employed, otherwise FALSE

		//Desired DPCH
		DPCH_FormatStructure	DesiredDPCHformat;		//Format configuration for the desired DPCH
		int						*DesiredChannelCode;	//Pointer to the Channelization Code for the desired
		ComplexNumber			*DesiredScrambleCode;	//Pointer to the Scramble Code for the desired frame
		unsigned				DesiredTPCcommand;		//TPC command:  Either a 0 or a 1

		//All other DPCHs
		unsigned				NumOtherDPCH;			//Number of other (undesired) DPCHs
		DPCH_FormatStructure	*OtherDPCHformat;		//Pointer to an array of format configs for the remaining DPCHs
		int						**OtherChannelCodes;	//Pointer to an array of pointers, each which points to a different channelization code
		ComplexNumber			**OtherScrambleCodes;	//Pointer to an array of pointers, each which points to a different scramble code
		unsigned				OtherTPCcommand;		//Each channel has the same TPC command

		//DPCCHforCPCH
		unsigned				NumDPCCHforCPCH;			//Number of channels
		int						**DPCCHforCPCHChanCodes;//Pointer to an array of pointers, each which points to a different channelization code
		ComplexNumber			**DPCCHforCPCHScrambleCodes;	//Pointer to an array of pointers, each which points to a different scramble code
		unsigned				DPCCHforCPCH_TPCcommand;//Each channel has the same TPC command

		//P_CPICH
		ComplexNumber			*P_CPICHScrambleCode;	//Pointer to ScrambleCode for P_CPICH

		//S_CPICH
		unsigned				NumS_CPICH;				//Number of channels
		int						**S_CPICHChanCodes;		//Pointer to an array of pointers, each which points to a different channelization code
		ComplexNumber			**S_CPICHScramCodes;	//Pointer to an array of pointers, each which points to a different scramble code

		//P_CCPCH
		int						*P_CCPCHChanCode;		//Pointer to the array containing the channelization code
		ComplexNumber			*P_CCPCHScramCode;		//Pointer to the array containing the scamble code

		//S_CCPCH
		CCPCH_FormatStructure	S_CCPCHformat;			//Format configuratino fo rhte S_CCPCH
		int						*S_CCPCHChanCode;		//Pointer to the array containing the channelization code
		ComplexNumber			*S_CCPCHScramCode;		//Pointer to the array containing the scamble code

		//PDSCH
		PDSCH_FormatStructure	PDSCHformat;			//Format configuratino fo rhte PDSCH
		int						*PDSCHChanCode;		//Pointer to the array containing the channelization code
		ComplexNumber			*PDSCHScramCode;		//Pointer to the array containing the scamble code

		//P_SCH and S_SCH
		double					A;						//Modulation Symbol

		//S_SCH only
		int						*SSC;					//Pointer to the Secondary Synchronization Codes
		unsigned				*SSCtoSCHmap;			//Pointer to the mapping from the SSC to the S_SCH sequence

		//Gains
		double					*Gains;					//Poiner to the vector that contains all of the gains

		//TimeOffsets
		int						*TimingOffset;			//Pointer to the array that contains the timing offset for each channel

};

class PCHFrameClass  
{
public:
	ComplexNumber *DesiredDPCH;		//Pointer to the desired DPCH frame
	unsigned NumOtherDPCHs;			//Number of remaining DPCHs
	ComplexNumber ** OtherDPCHs;	//Array of Pointers to the remaining DPCH frames
	unsigned NumDPCCHforCPCH;		//Number of DPCCH for CPCH frames
	ComplexNumber **DPCCHforCPCH;	//Array of Pointers to the DPCCH for CPCH frames
	ComplexNumber *P_CPICH;			//Pointer to the P_CPICH frame
	unsigned NumS_CPICH;			//Number of S_CPICH frames
	ComplexNumber **S_CPICH;		//Array of Pointers to the S_CPICH frames
	ComplexNumber *P_CCPCH;			//Pointer to the P_CCPCH frame
	ComplexNumber *S_CCPCH;			//Pointer to the S_CCPCH frame
	ComplexNumber *PDSCH;			//Pointer to the PDSCH frame
	ComplexNumber *P_SCH;			//Pointer to the P_SCH frame
	ComplexNumber *S_SCH;			//Pointer to the S_SCH frame
	int *DataBitsPtr;				//Pointer to the desired DataBits
	PCHFrameClass();
	ConfigurePCHframe(TransmitterConfigClass Tx);
	virtual ~PCHFrameClass();

};

class GainStructure
{
public:
	double	DesiredDPCH;	//Gain for the desired DPCH
	double	*OtherDPCH;		//Pointer to the array of gains for the remaining DPCHs
	double	*DPCHforCPCH;	//Pointer to the array of gains for the DPCH for CPCH
	double	P_CPICH;		//Gain for hte P_CPICH
	double	*S_CPICH;		//Pointer to the array of gains for the S_CPICH
	double	P_CCPCH;		//Gain for the P_CCPCH
	double	S_CCPCH;		//Gain for the S_CCPCH
	double	PDSCH;			//Gain for the PDSCH
	double	P_SCH;			//Gain for the P_SCH
	double	S_SCH;			//Gain for the S_SCH
};

class TimingStructure
{
public:
	int	DesiredDPCH;	//Gain for the desired DPCH
	int	*OtherDPCH;		//Pointer to the array of gains for the remaining DPCHs
	int	*DPCHforCPCH;	//Pointer to the array of gains for the DPCH for CPCH
	int	P_CPICH;		//Gain for hte P_CPICH
	int	*S_CPICH;		//Pointer to the array of gains for the S_CPICH
	int	P_CCPCH;		//Gain for the P_CCPCH
	int	S_CCPCH;		//Gain for the S_CCPCH
	int	PDSCH;			//Gain for the PDSCH
	int	P_SCH;			//Gain for the P_SCH
	int	S_SCH;			//Gain for the S_SCH
};

class TransmittedFrameClass
{
public:
	ComplexNumber *Chips;
	int *DataBits;
};

class TransmitterClass  
{
public:
	int DumpPCHframe(bool STTDflag);
	TransmitterClass(SimConfigClass Config);
	virtual ~TransmitterClass();
	TransmitterConfigClass TxConfiguration;
	TransmittedFrameClass PreviousFrame;
	TransmittedFrameClass CurrentFrame;
	TransmittedFrameClass NextFrame;
	TransmittedFrameClass GenerateFrame();
	TransmittedFrameClass GenerateInitialFrame();


private:
	void CodeManager(unsigned PrimaryScrambleCode, unsigned *SecondaryScrambleCode);
	void ShiftandAccumulate(int Offset,ComplexNumber *PreviousFrame,ComplexNumber *CurrentFrame,ComplexNumber *NextFrame,double gain,ComplexNumber *RadioFrame);
	ComplexNumber * GenerateControlFrame(PCHFrameClass *PCHframe);
	PCHFrameClass PreviousPCHframe;	//Pointers to the physical channels associated with the preveious frame
	PCHFrameClass CurrentPCHframe;	//Pointers to the physical channels associated with the current frame
	PCHFrameClass NextPCHframe;		//Pointers to the physical channels associated with the next frame
	void GeneratePCHframe(TransmitterConfigClass TxConfiguration,PCHFrameClass *RadioFrame);  //Generates the PH channels for a particular frame
																	//And stores the pointers in a PCHFrameClass Object

	int GetTiming();
	unsigned * GetSSCtoSCHmap(unsigned ScrambleCodeGroup);
	ComplexNumber * GenSSC();
	int * GetChannelCodeBasePointer(unsigned SF, int **ChanCodeBasePtrs);
	ComplexNumber * GenP_SCH(double A, bool STTDflag);
	ComplexNumber * GenS_SCH(ComplexNumber *SSC,unsigned *SSCtoSCHmap, double A, bool STTDflag);
	ComplexNumber * GenPDSCH(PDSCH_FormatStructure format, int *ChannelCode, ComplexNumber *ScrambleCode, bool STTDflag);
	ComplexNumber * GenP_CCPCH(int *ChanCode, ComplexNumber *ScrambleCode, bool STTDflag);
	ComplexNumber * GenS_CCPCH(CCPCH_FormatStructure format,int *ChannelCode, ComplexNumber *ScrambleCode, bool STTDflag);
	ComplexNumber * GenS_CPICH(bool STTDflag,ComplexNumber *ScrambleCode,int *ChannelCode);
	ComplexNumber * GenP_CPICH(bool STTDflag,ComplexNumber *ScrambleCode);
	ComplexNumber *GenDPCCHforCPCH(int *ChanCode,ComplexNumber *ScrambleCode,unsigned TPCCommand,bool STTDflag);
	ComplexNumber *GenDPCH(DPCH_FormatStructure format,int *ChanCode,ComplexNumber *ScrambleCode,unsigned TPCCommand,bool STTDflag,bool DesiredFrame,int *DesiredData);		
	ComplexNumber *ScrambleCode(unsigned N);
	int FillDesiredFrame(DPCH_FormatStructure format,int *PilotPtr,unsigned TPCCommand,ComplexNumber *FrameBufferPtr,int *DataBitsPtr,int *DesiredDataPtr);
	int FillUndesiredFrame(DPCH_FormatStructure format,int *PilotPtr,unsigned TPCCommand,ComplexNumber *FrameBufferPtr,int *DataBitsPtr);
	double UniformRandomNumberGenerator(int *idum);
	int * OVSF_Code(unsigned SF);
	int STTDcodeDPCH(ComplexNumber *FrameBufferPtr,DPCH_FormatStructure format,unsigned SymbolsPerFrame);
	int *Hadamard( unsigned N );
	ComplexNumber *P_SCHptr;
	ComplexNumber *S_SCHptr;
	ComplexNumber *ScrambleSequencePtr;
	int *Chan4,*Chan8,*Chan16,*Chan32,*Chan64,*Chan128,*Chan256,*Chan512;
	ComplexNumber *P_CPICHptr;
	GainStructure Gains;
	TimingStructure Timing,RelativeOffset;
	

};


#endif // !defined(AFX_TRANSMITTERCLASS_H__5B796C11_11B3_11D5_817F_B57425EF4323__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -