1.DDC(Direct Digital Controller)
? DDC即在數字系統中對信號進行下變頻,實作從射頻(中頻)信號到基帶信號的轉變,模擬上下變頻的系統框圖如下:

對于QAM等調制信號,通常有同相和正交兩路基帶信號,對應正弦和余弦兩路同頻載波,其模擬上下變頻的系統框圖如下:

上圖描述的程序可用的數學表達如下:
s
(
t
)
=
I
(
t
)
cos
?
(
2
π
f
c
t
)
?
Q
(
t
)
sin
?
(
2
π
f
c
t
)
I
路
:
s
(
t
)
cos
?
(
2
π
f
c
t
)
=
I
(
t
)
cos
?
2
(
2
π
f
c
t
)
?
Q
(
t
)
cos
?
(
2
π
f
c
t
)
sin
?
(
2
π
f
c
t
)
=
I
(
t
)
1
+
cos
?
(
2
π
?
2
f
c
t
)
2
?
Q
(
t
)
sin
?
(
2
π
2
?
f
c
t
)
2
=
=
L
P
F
I
(
t
)
2
Q
路
:
s
(
t
)
(
?
sin
?
(
2
π
f
c
t
)
)
=
I
(
t
)
cos
?
(
2
π
f
c
t
)
sin
?
(
2
π
f
c
t
)
+
Q
(
t
)
sin
?
2
(
2
π
f
c
t
)
=
I
(
t
)
sin
?
(
2
π
2
?
f
c
t
)
2
+
Q
(
t
)
1
?
cos
?
(
2
π
?
2
f
c
t
)
2
=
=
L
P
F
Q
(
t
)
2
s(t)=I(t)\cos(2\pi f_ct)-Q(t)\sin(2\pi f_ct)\\ I路:s(t)\cos(2\pi f_ct)=I(t)\cos^2(2\pi f_ct)-Q(t)\cos(2\pi f_ct)\sin(2\pi f_ct)\\=I(t)\frac{1+\cos (2\pi*2f_ct)}{2}-Q(t)\frac{\sin(2\pi 2*f_ct)}{2}\overset{LPF}{==}\frac{I(t)}{2}\\ Q路:s(t)(-\sin(2\pi f_ct))=I(t)\cos(2\pi f_ct) \sin (2\pi f_ct)+Q(t)\sin^2(2\pi f_ct)\\=I(t)\frac{\sin(2\pi 2*f_ct)}{2}+Q(t)\frac{1-\cos (2\pi*2f_ct)}{2}\overset{LPF}{==}\frac{Q(t)}{2}
s(t)=I(t)cos(2πfc?t)?Q(t)sin(2πfc?t)I路:s(t)cos(2πfc?t)=I(t)cos2(2πfc?t)?Q(t)cos(2πfc?t)sin(2πfc?t)=I(t)21+cos(2π?2fc?t)??Q(t)2sin(2π2?fc?t)?==LPF2I(t)?Q路:s(t)(?sin(2πfc?t))=I(t)cos(2πfc?t)sin(2πfc?t)+Q(t)sin2(2πfc?t)=I(t)2sin(2π2?fc?t)?+Q(t)21?cos(2π?2fc?t)?==LPF2Q(t)?
若使用復信號表述該程序,則有:

上述程序的數學表達如下:
s
(
t
)
=
(
I
+
j
Q
)
e
j
2
π
f
c
t
=
(
I
+
j
Q
)
(
cos
?
(
2
π
f
c
t
)
+
j
sin
?
(
2
π
f
c
t
)
)
=
I
cos
?
(
2
π
f
c
t
)
+
j
I
sin
?
(
2
π
f
c
t
)
+
j
Q
cos
?
(
2
π
f
c
t
)
?
Q
sin
?
(
2
π
f
c
t
)
取
其
實
部
,
則
有
s
t
x
(
t
)
=
I
cos
?
(
2
π
f
c
t
)
?
Q
sin
?
(
2
π
f
c
t
)
恢
復
過
程
:
s
t
x
(
t
)
e
?
j
2
π
f
c
t
=
(
I
cos
?
(
2
π
f
c
t
)
?
Q
sin
?
(
2
π
f
c
t
)
)
(
cos
?
(
2
π
f
c
t
)
?
j
sin
?
(
2
π
f
c
t
)
)
=
I
(
cos
?
2
(
2
π
f
c
t
)
)
?
j
I
(
cos
?
(
2
π
f
c
t
)
sin
?
(
2
π
f
c
t
)
)
?
Q
(
sin
?
(
2
π
f
c
t
)
cos
?
(
2
π
f
c
t
)
)
+
j
Q
(
sin
?
2
(
2
π
f
c
t
)
)
=
I
1
+
cos
?
(
2
π
2
?
f
c
t
)
2
?
j
I
sin
?
(
2
π
2
?
f
c
t
)
2
?
Q
sin
?
(
2
π
2
?
f
c
t
)
2
+
j
Q
1
?
cos
?
(
2
π
2
?
f
c
t
)
2
=
=
L
P
F
I
+
j
Q
s(t)=(I+jQ)e^{j2\pi f_ct}=(I+jQ)(\cos(2\pi f_ct)+j\sin(2\pi f_ct))\\=I\cos(2\pi f_ct)+jI\sin(2\pi f_ct)+jQ\cos(2\pi f_ct)-Q\sin(2\pi f_ct)\\取其實部,則有s_{tx}(t)=I\cos(2\pi f_ct)-Q\sin(2\pi f_ct)\\恢復程序:s_{tx}(t)e^{-j2\pi f_ct}=(I\cos(2\pi f_ct)-Q\sin(2\pi f_ct))(\cos(2\pi f_ct)-j\sin(2\pi f_ct))\\=I(\cos^2(2\pi f_c t))-jI(\cos(2\pi f_ct)\sin(2\pi f_ct))-Q(\sin(2\pi f_ct)\cos(2\pi f_ct))+jQ(\sin^2(2\pi f_ct))\\=I\frac{1+\cos(2\pi 2*f_c t)}{2}-jI\frac{\sin(2\pi 2*f_c t)}{2}-Q\frac{\sin(2\pi 2*f_c t)}{2}+jQ\frac{1-\cos(2\pi 2*f_c t)}{2}\overset{LPF}{==}I+jQ
s(t)=(I+jQ)ej2πfc?t=(I+jQ)(cos(2πfc?t)+jsin(2πfc?t))=Icos(2πfc?t)+jIsin(2πfc?t)+jQcos(2πfc?t)?Qsin(2πfc?t)取其實部,則有stx?(t)=Icos(2πfc?t)?Qsin(2πfc?t)恢復過程:stx?(t)e?j2πfc?t=(Icos(2πfc?t)?Qsin(2πfc?t))(cos(2πfc?t)?jsin(2πfc?t))=I(cos2(2πfc?t))?jI(cos(2πfc?t)sin(2πfc?t))?Q(sin(2πfc?t)cos(2πfc?t))+jQ(sin2(2πfc?t))=I21+cos(2π2?fc?t)??jI2sin(2π2?fc?t)??Q2sin(2π2?fc?t)?+jQ21?cos(2π2?fc?t)?==LPFI+jQ
為什么使用復信號?
復信號的引入已有幾十年的歷史,無線通信中,往往使用一對正交的信號傳輸資訊,以提高帶寬利用率,有效的減少帶內和帶外干擾,為了簡單明了的描述這對信號,這些系統常被描述為一個復信號,系統的傳遞函式也用復數描述,使用復信號的好處有:
it often allows for image-reject architectures to be described more compactly and simply; it leads to a graphical or signal-flflow graph (SFG) description of signal-processing systems providing insight, and it often leads to the development of new systems where the use of high-frequency highly selective image-reject fifilters is minimized. The result is more highly integrated systems using less power and requiring less physical space[1].
即,使用復信號可以使得消除鏡像頻譜的結構的描述變得更簡潔;使得描述信號處理系統的信號流圖變得更為直觀;在開發新系統時,減少高頻高選擇性的鏡頻濾波器的使用;最終使得系統的集成度更高,有更小的體積和更少的功耗,
但該論文的題目《Complex Signal Processing is Not Complex》[1]亦指出,復信號的處理并不是復數(復雜)的,在論文中,作者給每一幅復數信號流圖都配上了對應的等價實數信號流圖,如下:

在實際處理中,還是使用實數信號流圖對應的物理結構,如ADI公司在一個回復當利用ADC內部數字下變頻(DDC)處理進行抽取時,我的單音實數輸入信號丟失了6 dB功率的問題時中提及的處理框圖如下:

帶通信號經過帶通采樣,再經DDC變換到基帶的MATLAB代碼如下:
`
clear;
close all;
clc;
f = 115e6; %中頻125MHz,則f0 = 115MHz 115-135MHz
t_p = 50e-6; %脈寬50us
b = 20e6; %帶寬20MHz
beta = b/t_p; %調頻斜率
f_s =100e6; %采樣率 100MHz
f_l = 25e6; %NCO 25MHz
t = 0: 1/f_s:16383/f_s;
NCO = exp(-1i.*2.*pi.*f_l.*t); %復本振
figure;plot3(t(1:200),real(NCO(1:200)),imag(NCO(1:200)));title('復本振時域波形');xlabel('時間');ylabel('實部');zlabel('虛部');
fft_plot(NCO,f_s,'復本振信號');
G = rectpuls(t-t_p/2,t_p);
chrip_bs = G.*exp(1i.*pi.*beta.*t.^2); %發送的復基帶信號
IF = exp(1i.*2.*pi.*f.*t); %復中頻載波
chrip = chrip_bs.*IF;
fft_plot(chrip,f_s,'待發射復基帶信號'); %復信號頻譜
chrip_tx = real(chrip); %發射中頻的實部,也是ADC采集進入進行下變頻的信號
fft_plot(chrip_tx,f_s,'發射實信號'); %ADC采集的信號的頻譜
chrip_LO = chrip_tx.*NCO;
fft_plot((chrip_LO),f_s,'乘以復本振后信號'); %乘以復本振后信號頻譜
[b,a] = fir1(50,15e6*2/f_s);
[H,W] = freqz(b,a);
Hf=abs(H); %取幅度值實部
Hx=angle(H); %取相位值對應相位角
figure;
plot(W,20*log(Hf)) %幅值變換為分貝單位
title('濾波器系統幅頻特性曲線')
figure;
plot(W,Hx)
title('濾波器系統相頻特性曲線')
chrip_b = filter(b,a,chrip_LO);
fft_plot((chrip_b),f_s,'低通濾波后信號');
chrip_fake_d = fake_decimation(chrip_b,4); %假4倍抽取
fft_plot((chrip_fake_d),f_s,'假的4倍抽取后信號');
chrip_bD = resample(chrip_b,f_s/2,f_s);%信號降采樣以降低資料率
fft_plot((chrip_bD),f_s/4,'4倍抽取后信號');
figure;
plot(t(1:2:4000),real(chrip_bD(1:2000)));
title('I');xlabel('時間');
figure;
plot(t(1:2:4000),imag(chrip_bD(1:2000)));
title('Q');xlabel('時間');
%% 虛假的抽取,只是隔位置零,采樣率不變,以獲取周期延拓
%% input:x,待抽取信號;n,抽取倍數
%% output: 抽取后信號
function yn= fake_decimation(x,n)
yn = zeros(1,length(x));
for i = 1 : length(x)
if mod(i,n)== 1
yn(i) = x(i);
else
x(i) = 0;
end
end
end
%% 對信號做FFT,并畫圖
%% input: y,待分析信號;fs,采樣率;s_name,信號名字
function fft_plot(y,fs,s_name)
L_i = length(y)*2;
s_i_fft = fft(y,L_i);
s_i_fftshfit = fftshift(s_i_fft);
P = abs(s_i_fftshfit/L_i);
fshift = (-L_i/2:L_i/2-1)*(fs/L_i);
figure;
plot(fshift,P);
title([s_name,'的雙邊譜 ']);
xlabel('f (Hz)');
ylabel('|P(f)|');
end
信號處理程序中的頻譜如下:

只有正頻率

發射時只有取實部,實信號有對稱的雙邊譜

乘以復本振,被單向搬移(由于是帶通采樣,有頻譜周期延拓,且FFT僅能繪制[-Fs/2,Fs/2]區間的頻譜)

低通濾波,取基帶部分信號

4倍抽取的中間程序

4倍抽取,以降低后續資料量

I路基帶信號時域

Q路基帶時域
FPGA處理流程,及波形
FPGA實作程序基于實數形式的信號流圖,主要涉及到DDS產生兩路正交本振,ROM存盤待下變頻信號,乘法模塊,FIR濾波,時域抽取等,大部分有現成IP核可供呼叫,
代碼:
module DDC(
input clk,
input en,
input rst,
output [55:0] i_d4,
output [55:0] q_d4,
output [55:0] i_data,
output [55:0] q_data,
output [15:0] sin,
output [15:0] cos,
output [15:0] LFM,
output [31:0] i_cos,
output [31:0] q_sin
);
wire [15:0] douta;
wire [31:0]m_axis_data_tdata;
wire [31:0]m_axis_phase_tdata;
wire [31:0] P_i;
wire [31:0] P_q;
reg [12:0]addra;
always @(posedge clk or posedge rst) begin
if (rst) begin
addra <= 1'b0;
end
else begin
addra <= addra + 1'b1;
end
end
assign LFM = douta;
assign sin = m_axis_data_tdata[15:0];
assign cos = m_axis_data_tdata[31:16];
assign i_cos= P_i;
assign q_sin= P_q;
blk_mem_gen_0 LFMWAVE (
.clka(clk), // input wire clka
.addra(addra), // input wire [12 : 0] addra
.douta(douta) // output wire [15 : 0] douta
);
LO sin_cos (
.aclk(clk), // input wire aclk
.m_axis_data_tvalid(), // output wire m_axis_data_tvalid
.m_axis_data_tdata(m_axis_data_tdata), // output wire [31 : 0] m_axis_data_tdata
.m_axis_phase_tvalid(), // output wire m_axis_phase_tvalid
.m_axis_phase_tdata(m_axis_phase_tdata) // output wire [31 : 0] m_axis_phase_tdata
);
mult_i mult_i (
.CLK(clk), // input wire CLK
.A(douta), // input wire [15 : 0] A
.B(m_axis_data_tdata[15:0]), // input wire [15 : 0] B
.P(P_i) // output wire [31 : 0] P
);
mult_i mult_q (
.CLK(clk), // input wire CLK
.A(douta), // input wire [15 : 0] A
.B(m_axis_data_tdata[31:16]), // input wire [15 : 0] B
.P(P_q) // output wire [31 : 0] P
);
fir_compiler_0 fir_i (
.aclk(clk), // input wire aclk
.s_axis_data_tvalid(en), // input wire s_axis_data_tvalid
.s_axis_data_tready(), // output wire s_axis_data_tready
.s_axis_data_tdata(P_i), // input wire [31 : 0] s_axis_data_tdata
.m_axis_data_tvalid(), // output wire m_axis_data_tvalid
.m_axis_data_tdata(i_data) // output wire [55 : 0] m_axis_data_tdata
);
fir_compiler_0 fir_q (
.aclk(clk), // input wire aclk
.s_axis_data_tvalid(en), // input wire s_axis_data_tvalid
.s_axis_data_tready(), // output wire s_axis_data_tready
.s_axis_data_tdata(P_q), // input wire [31 : 0] s_axis_data_tdata
.m_axis_data_tvalid(), // output wire m_axis_data_tvalid
.m_axis_data_tdata(q_data) // output wire [55 : 0] m_axis_data_tdata
);
decimation#(
.NDEC(56)
) inst_decimation_i (
.clk (clk),
.rst (rst),
.en (en),
.din (i_data),
.valid (),
.dout (i_d4)
);
decimation#(
.NDEC(56)
) inst_decimation_q (
.clk (clk),
.rst (rst),
.en (en),
.din (q_data),
.valid (),
.dout (q_d4)
);
endmodule
抽取模塊代碼:
module decimation
#(parameter NDEC = 56)
(
input clk,
input rst,
input en,
input [NDEC-1:0] din,
output valid,
output [NDEC-1:0] dout);
reg valid_r ;
reg [2:0] cnt ;
reg [NDEC-1:0] dout_r ;
//counter
always @(posedge clk or posedge rst) begin
if (rst) begin
cnt <= 3'b0;
end
else if (en) begin
if (cnt==3) begin
cnt <= 'b0 ;
end
else begin
cnt <= cnt + 1'b1 ;
end
end
end
//data, valid
always @(posedge clk or posedge rst) begin
if (rst) begin
valid_r <= 1'b0 ;
dout_r <= 'b0 ;
end
else if (en) begin
if (cnt==3) begin
valid_r <= 1'b1 ;
dout_r <= din;
end
else begin
valid_r <= 1'b0 ;
end
end
end
assign dout = dout_r ;
assign valid = valid_r ;
endmodule

FPGA仿真波形
綜合RTL視圖:

可見,與實數信號流圖描述結構相同,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/238638.html
標籤:其他
下一篇:【GDAL】C++加載矢量資料
