diff --git a/rtl/z_dsp/IIR_Filter.v b/rtl/z_dsp/IIR_Filter.v index f0ce94f..a8e5a4c 100644 --- a/rtl/z_dsp/IIR_Filter.v +++ b/rtl/z_dsp/IIR_Filter.v @@ -172,7 +172,7 @@ inst_c4 ( assign y_re = v1_re + y2_re; assign y_im = v1_im + y2_im; -reg signed [data_in_width+frac_data_out_width+1:0] dout_round; +wire signed [data_in_width+frac_data_out_width+1:0] dout_round; FixRound #(data_in_width+frac_data_out_width+2,frac_data_out_width) u_round1 (clk, rstn, en, y_re, dout_round); diff --git a/rtl/z_dsp/mult_C.v b/rtl/z_dsp/mult_C.v index ecafc58..ce8599b 100644 --- a/rtl/z_dsp/mult_C.v +++ b/rtl/z_dsp/mult_C.v @@ -98,8 +98,8 @@ wire signed [A_width+D_width:0] Im_tmp; assign Re_tmp = ac - bd; assign Im_tmp = ad + bc; -reg signed [A_width+C_width:0] Re_round; -reg signed [A_width+D_width:0] Im_round; +wire signed [A_width+C_width:0] Re_round; +wire signed [A_width+D_width:0] Im_round; FixRound #(A_width+C_width+1,frac_coef_width) u_round1 (clk, rstn, en, Re_tmp, Re_round); FixRound #(A_width+C_width+1,frac_coef_width) u_round2 (clk, rstn, en, Im_tmp, Im_round); diff --git a/script_m/diff_plot_py.m b/script_m/diff_plot_py.m index 5d3c2a1..21c5eed 100644 --- a/script_m/diff_plot_py.m +++ b/script_m/diff_plot_py.m @@ -18,12 +18,12 @@ n1000_1100 = find((n>=edge+1000e-9-1e-12) & (n<=edge+1100e-9+1e-12));%下降沿 ne = find((abs(diff)>=1e-4) & (abs(diff)<1));%误差小于万分之一的点 ne(1) = 1; -% window_length = 100e-9*fs; -% diff_mean_window = movmean(diff,window_length); -% diff_std_window = movstd(diff,window_length); -% n_mean_window = find((abs(diff_mean_window)>=1e-4) );%100ns窗,误差均值小于万分之一点 -% n_std_window = find((abs(diff_std_window)>=1e-4) ); %100ns窗,误差方差小于万分之一点 -% n_common = max(n_mean_window(end),n_std_window(end)); +window_length = 100e-9*fs; +diff_mean_window = movmean(diff,window_length); +diff_std_window = movstd(diff,window_length); +n_mean_window = find((abs(diff_mean_window)>=1e-4) );%100ns窗,误差均值小于万分之一点 +n_std_window = find((abs(diff_std_window)>=1e-4) ); %100ns窗,误差方差小于万分之一点 +n_common = max(n_mean_window(end),n_std_window(end)); %原始数据作图 tiledlayout(2,1) ax1 = nexttile; @@ -68,10 +68,10 @@ elseif a(2) > 5e-6 plot_p(n1000(1)); %下降沿1us plot_p(ne(end)); %误差小于万分之一 fprintf("Falling edge of 20ns~40ns mean :%.4e\t std :%.4e\t",mean(diff(n20_40)),std(diff(n20_40))); - fprintf("Falling edge of 1us~1.1us mean :%.4e\t std :%.4e\n",mean(diff(n1000_1100)),std(diff(n1000_1100))); + fprintf("Falling edge of 1us~1.1us mean :%.4e\t std :%.4e\t",mean(diff(n1000_1100)),std(diff(n1000_1100))); % fprintf("The error after falling edge of 1us is:%.4e\t",diff(n1000(1))); % fprintf("The time of erroe less than 1e-4 is :%.4e us\n",(n(ne(end))-n(n_edge(1)))); - % fprintf("The mean and std stably less than 1e-4 is :%.4e s\n",(n(n_common)-n(n_edge(1)))); + fprintf("The mean and std stably less than 1e-4 is :%.4e s\n",(n(n_common)-n(n_edge(1)))); end diff --git a/script_m/z_dsp.m b/script_m/z_dsp.m index 5cdc4ed..8032c08 100644 --- a/script_m/z_dsp.m +++ b/script_m/z_dsp.m @@ -2,17 +2,17 @@ clc;clear;close all % hdlsetuptoolpath('ToolName','Xilinx Vivado','ToolPath','D:\SoftWare\Xilinx\Vivado\2019.2\bin\vivado.bat'); -addpath(genpath('D:\Work\EnvData')); -addpath(genpath('D:\Work\EnvData\data-v2')); +% addpath(genpath('D:\Work\EnvData')); +% addpath(genpath('D:\Work\EnvData\data-v2')); % addpath(genpath('D:\Work\TailCorr_20241008_NoGit')); - +% addpath('D:\Work\TailCorr\script_m'); cd("D:\Work\EnvData\acz"); obj1 = py.importlib.import_module('acz'); py.importlib.reload(obj1); cd("D:\Work\TailCorr_20241008_NoGit"); obj2 = py.importlib.import_module('wave_calculation'); py.importlib.reload(obj2); -cd("D:\Work\TailCorr\script_m"); +cd("D:\Work\TailCorr"); fs_L = 0.75e9; %硬件频率 fs_H = 12e9; %以高频近似理想信号 @@ -77,20 +77,10 @@ end %%%python脚本校正结果 %S21参数 -amp_real = [0.025 0.015 0.0002 0 0 0]; +amp_real = [0.025 0.015 0.0002 0.2 0 0]; amp_imag = [0 0 0 0 0 0]; -time_real = [-1/250, -1/650, -1/1600 0 0 0]; -time_imag = [0 0 0 0 0 0]; - -% amp_real = [0.0539981,-0.0319766,0.084015161,0.0048,0,0]; -% amp_imag = [0,-0.041014189,-0.052936266,0,0,0]; -% time_real = [-0.0024820146,-0.0080529118,-0.006728925,-0.0001,0,0]; -% time_imag = [0,-0.008137675,-0.0033212836,0,0,0]; -% -% amp_real = [0.025 0.015 0.0002 0.2 0 0]; -% amp_imag = [0 0 0 0 0 0]; -% time_real = [-1/250, -1/650, -1/1600 -1/20 0 0]; -% time_imag = [0 0 0 0 0 0]; +time_real = [-1/250, -1/650, -1/1600 -1/20 0 0]; +time_imag = [0 -1/300 -1/500 0 0 0]; amp_routing = amp_real + 1j*amp_imag; time_routing = time_real + 1j*time_imag; @@ -174,11 +164,11 @@ for i = 1:8 fig1 = figure('Units','normalized','Position',[0.000390625,0.517361111111111,0.49921875,0.422916666666667]); diff_plot_py(TargetFrequency,HardwareMeanIntpDataAlign{i}', DownsamplingBy12GDataAlign{i}(1:floor(TargetFrequency*20e-6)),'HardwareRevised','ScriptRevised',a{i},Amp,edge_Align(i)); title(name(i,1),Interpreter="none"); - savefig(name(i,1)); + % savefig(name(i,1)); fig2 = figure('Units','normalized','Position',[0.000390625,0.034027777777778,0.49921875,0.422916666666667]); diff_plot_py(TargetFrequency,HardwareMeanIntpDataAlign{i}', DownsamplingBy12GDataAlign{i}(1:floor(TargetFrequency*20e-6)),'HardwareRevised','ScriptRevised',b{i},Amp,edge_Align(i)); title(name(i,2),Interpreter="none"); - savefig(name(i,2)); + % savefig(name(i,2)); end %% 可视化S21参数