FPGA实验BDPSK调制解调器设计等通信工程实验报告文档格式.docx
《FPGA实验BDPSK调制解调器设计等通信工程实验报告文档格式.docx》由会员分享,可在线阅读,更多相关《FPGA实验BDPSK调制解调器设计等通信工程实验报告文档格式.docx(43页珍藏版)》请在冰豆网上搜索。
modulefre_div(clk,cp0);
//分频器
inputclk;
outputregcp0;
parameterN=32;
integeri=0;
initial
begin
cp0<
=0;
end
always@(posedgeclk)
begin
if(i<
N/2-1)i=i+1;
elsebegini=0;
cp0=~cp0;
end
endmodule
随机码序列产生器(m序列):
modulePN_Seq(clk,reset_n,dataout);
inputclk;
inputreset_n;
outputdataout;
reg[7:
1]c;
always@(posedgeclkornegedgereset_n)
if(!
reset_n)
c<
=7'
b1001110;
else
c[7]<
=c[6];
c[6]<
=c[5];
c[5]<
=c[4];
c[4]<
=c[3];
c[3]<
=c[2];
c[2]<
=c[1];
c[1]<
=c[2]^c[3]^c[4]^c[7];
end
assigndataout=c[7];
差分编码器:
moduledif(clk,reset_n,in,out);
inputin;
outputout;
reg[1:
0]o;
always@(posedgeclkornegedgereset_n)
if(!
reset_n)
o<
=1;
else
o<
=in^o;
end
assignout=o;
控制器:
moduleController(clk,reset_n,s,address,cp);
inputreset_n;
inputcp;
inputs;
//相对码
output[4:
0]address;
reg[4:
0]address_data;
0]count;
regsign;
always@(posedgecp)
begin
if(s==0)
count<
=5'
b10000;
elseif(s==1)count<
=5'
b00000;
sign<
address_data<
elsebegin
if(sign==1)
=count;
=address_data+1'
b1;
if(address_data==32)
address_data<
assignaddress=address_data;
正弦波形查找表:
moduleLookUpTable(clk,reset_n,address,dataout);
//正弦载波采样表
input[4:
output[7:
0]dataout;
0]LUT[0:
31];
if(!
reset_n)
begin
LUT[0]<
=128;
//用C编程计算出的查找表采样值填在这里
LUT[1]<
=152;
LUT[2]<
=176;
LUT[3]<
=198;
LUT[4]<
=218;
LUT[5]<
=234;
LUT[6]<
=245;
LUT[7]<
=253;
LUT[8]<
=255;
LUT[9]<
LUT[10]<
LUT[11]<
LUT[12]<
LUT[13]<
LUT[14]<
LUT[15]<
LUT[16]<
LUT[17]<
=103;
LUT[18]<
=79;
LUT[19]<
=57;
LUT[20]<
=37;
LUT[21]<
=22;
LUT[22]<
=10;
LUT[23]<
=2;
LUT[24]<
=0;
LUT[25]<
LUT[26]<
LUT[27]<
LUT[28]<
LUT[29]<
LUT[30]<
LUT[31]<
assigndataout=LUT[address];
3、功能仿真和时序仿真结果的波形
功能仿真:
时序仿真:
实验二MATLAB实验OFDM误码率仿真(AWGN)
一、实验目的:
1、掌握OFDM的基本原理。
2、掌握用Matlab搭建OFDM系统的基本方法
3、用MATLAB进行OFDM系统在AWGN信道下误码率分析。
1.所有程序完整的源代码(.m文件)以及注释。
2.仿真结果。
对于所有的图形结果(包括波形与仿真曲线等),将图形保存成.tif或者.emf的格式并插入word文档。
1、所有程序完整的源代码(.m文件)以及注释:
%16QAM的调制函数
function[complex_qam_data]=qam16(bitdata)
%modulationof16QAM,modulatebitdatato16QAMcomplexsignal
X1=reshape(bitdata,4,length(bitdata)/4)'
;
d=1;
%mindistanceofsymble
fori=1:
length(bitdata)/4;
forj=1:
4
X1(i,j)=X1(i,j)*(2^(4-j));
source(i,1)=1+sum(X1(i,:
));
%converttothenumber1to16
mapping=[-3*d3*d;
-d3*d;
d3*d;
3*d3*d;
-3*dd;
-dd;
dd;
3*dd;
-3*d-d;
-d-d;
d-d;
3*d-d;
-3*d-3*d;
-d-3*d;
d-3*d;
3*d-3*d];
fori=1:
length(bitdata)/4
qam_data(i,:
)=mapping(source(i),:
);
%datamapping
complex_qam_data=complex(qam_data(:
1),qam_data(:
2));
%16QAM的解调函数。
function[demodu_bit_symble]=demoduqam16(Rx_serial_complex_symbols)
%将得到的串行16QAM数据解调成二进制比特流
complex_symbols=reshape(Rx_serial_complex_symbols,length(Rx_serial_complex_symbols),1);
complex_mapping=complex(mapping(:
1),mapping(:
length(Rx_serial_complex_symbols);
16;
metrics(j)=abs(complex_symbols(i,1)-complex_mapping(j,1));
[min_metricdecode_symble(i)]=min(metrics);
%将离某星座点最近的值赋给decode_symble(i)
decode_bit_symble=de2bi((decode_symble-1)'
'
left-msb'
demodu_bit_symble=reshape(decode_bit_symble'
1,length(Rx_serial_complex_symbols)*4);
%加窗函数
function[rcosw]=rcoswindow(beta,Ts)
%定义升余弦窗,其中beta为滚降系数,Ts为包含循环前缀的OFDM符号的长度,Ts为正偶数
t=0:
(1+beta)*Ts;
rcosw=zeros(1,(1+beta)*Ts);
beta*Ts;
rcosw(i)=0.5+0.5*cos(pi+t(i)*pi/(beta*Ts));
rcosw(beta*Ts+1:
Ts)=1;
forj=Ts+1:
(1+beta)*Ts+1;
rcosw(j-1)=0.5+0.5*cos((t(j)-Ts)*pi/(beta*Ts));
rcosw=rcosw