%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% filename : DespreadProcess.m
% description : spreading processing (调制输出的速率为码速率的1倍 25MHz)
% input :
% DataType : 数据类型,如同步段数据(0)、控制段数据(1)、业务段数据(2)
% DespreadType :解扩类型 ,1软解扩,0硬解扩
% Gain :扩频增益
% ReDataInput :解调输出,比特流{0,1} 或 对数似然比
% CodeOffset :码相位
% DCHopSeedLevel:业务段OVSF码的跳码速率等级(即一帧数据里面跳几次)
% output :
% DS_DeOutput :解扩输出比特流{0,1}
%
% calling :CH_Pattern.m
% OVSF.m
% DCH_Pattern.m
% calling by :
function DS_DeOutput = DespreadProcess(DataType,DespreadType,Gain,ReDataInput,CodeOffset,DCHopSeedLevel)
if (DespreadType == 0)
DataInputB = 2*ReDataInput - 1;
else
DataInputB = ReDataInput;
end
% fsample = 800e6;%采样频率
% fcode = 10e6; %扩频码频率
% PerCode = fsample/fcode;
% HalfCode = PerCode/2;
% Number = length(ReDataInput);%输入数据长度
if (CodeOffset ~= 0)
DespreadDataBuff = DataInputB(Gain-CodeOffset+1:end);
else
DespreadDataBuff = DataInputB;
end
DeData = length(DespreadDataBuff);
if ( DataType == 0)
DS_DeOutput = [];
elseif( DataType == 1)
%=================控制段 =============
% CHPattern = CH_Pattern(DeData/Gain);%跳码图案
% [balance_code,~] = generatebalancegoldcode(3);%跳码扩频码
CHPattern = CH_Pattern(DeData/Gain);%跳码图案
OVSFArray=OVSF(Gain);%跳码扩频码
balance_code =[OVSFArray(2:end,:);OVSFArray(end,:)];
DataBuff = balance_code(CHPattern,:);
DS_OutputB = reshape(DataBuff',1,DeData);
DS_OutputBuff = DS_OutputB.*DespreadDataBuff;
DataIntegral = sum(reshape(DS_OutputBuff,Gain,DeData/Gain));
DS_DeOutput = zeros(1,DeData/Gain);
for CntD = 1:DeData/Gain
if(DespreadType) %软解扩
% if(DataIntegral(CntD) < 0)
% DS_DeOutput(CntD) = 1;
% elseif (DataIntegral(CntD) > 0)
% DS_DeOutput(CntD) = 0;
% else
% if CntD == 1
% DS_DeOutput(CntD) = 0;
% else
% DS_DeOutput(CntD) = DS_DeOutput(CntD - 1);
% end
% end
DS_DeOutput = DataIntegral;
else %硬解扩
if(DataIntegral(CntD) < 0)
DS_DeOutput(CntD) = 0;
elseif (DataIntegral(CntD) > 0)
DS_DeOutput(CntD) = 1;
else
if CntD == 1
DS_DeOutput(CntD) = 0;
else
DS_DeOutput(CntD) = DS_DeOutput(CntD - 1);
end
end
end
end
elseif( DataType == 2)
%=================数据段 =============
DCHopSeedLevel = DeData/Gain;
DCHNumber = round(DeData/Gain/DCHopSeedLevel);
OVSFPattern = DCH_Pattern(Gain,DCHNumber,DCHopSeedLevel);%跳码图案
CodeOVSF = OVSF(Gain);
DS_DeOutput = zeros(1,DeData/Gain);
% DataBuff = zeros(Number,Gain);
DataBuff = CodeOVSF(OVSFPattern,:);
DataBuff0 = reshape(DespreadDataBuff,Gain,DeData/Gain);
DataIntegral = sum(DataBuff'.*DataBuff0);%相关运算,累加
for CntD = 1:DeData/Gain
if(DespreadType) %软解扩
% if(DataIntegral(CntD) < 0)
% DS_DeOutput(CntD) = 1;
% elseif (DataIntegral(CntD) > 0)
% DS_DeOutput(CntD) = 0;
% else
% if CntD == 1
% DS_DeOutput(CntD) = 0;
% else
% DS_DeOutput(CntD) = DS_DeOutput(CntD - 1);
% end
% end
DS_DeOutput = DataIntegral;
else %硬解扩
if(DataIntegral(CntD) < 0)%Gain/3
DS_DeOutput(CntD) = 0;
elseif (DataIntegral(CntD) > 0)
DS_DeOutput(CntD) = 1;
else
if CntD == 1
DS_DeOutput(CntD) = 0;
else
DS_DeOutput(CntD) = DS_DeOutput(CntD - 1);
end
end
end
end
end
没有合适的资源?快使用搜索试试~ 我知道了~
解扩代码程序
共1个文件
m:1个
3星 · 超过75%的资源 需积分: 9 10 下载量 64 浏览量
2014-10-21
20:20:03
上传
评论 1
收藏 1KB ZIP 举报
温馨提示
该代码是关于解扩模块部分,采用的伪码是gold序列,增益可任意输入
资源推荐
资源详情
资源评论
收起资源包目录
DespreadProcess.zip (1个子文件)
DespreadProcess.m 4KB
共 1 条
- 1
资源评论
- weareu2018-09-15cdma的解扩,要调用的几个文件没有。了解下大概思路可以。
qq_20671267
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功