v04-delete unnecessary .m files
This commit is contained in:
		
							parent
							
								
									b995b832f8
								
							
						
					
					
						commit
						9068d5393d
					
				|  | @ -1,6 +0,0 @@ | ||||||
| %%% so means original, s_mean means mean value |  | ||||||
| function [s,s_mean] = MeanIntp(s,s_r1) |  | ||||||
| 
 |  | ||||||
|     s_mean = (s+s_r1)/2; |  | ||||||
| 
 |  | ||||||
| end |  | ||||||
|  | @ -1,35 +0,0 @@ | ||||||
| function out = MyIIR(a,b,x,YStartState,sel_double) |  | ||||||
| 
 |  | ||||||
| len = length(x); |  | ||||||
| 
 |  | ||||||
| switch sel_double  |  | ||||||
|     case 0 |  | ||||||
|         x = int64(x); |  | ||||||
|         a = int64(a); |  | ||||||
|         b = int64(b); |  | ||||||
|         y(1) = int64(YStartState); |  | ||||||
|     case 1 |  | ||||||
|         x = double(x); |  | ||||||
|         a = double(a); |  | ||||||
|         b = double(b); |  | ||||||
|         y(1) = double(YStartState); |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| switch sel_double  |  | ||||||
| 
 |  | ||||||
|     case 0 |  | ||||||
| 
 |  | ||||||
|         for i = 1:len-1        |  | ||||||
|             y_tmp(i+1) = a*x(i+1) - b*y(i)'; |  | ||||||
|             y(i+1) = bitsra(y_tmp(i+1),20) + bitget(y_tmp(i+1),64);        |  | ||||||
|         end |  | ||||||
|         out = bitsra(y,16); |  | ||||||
| 
 |  | ||||||
|     case 1 |  | ||||||
| 
 |  | ||||||
|         for i = 1:len-1 |  | ||||||
|             y_tmp(i+1) = floor(a*x(i+1) - b*y(i)'); |  | ||||||
|             y(i+1) = floor(y_tmp(i+1)/2^20) + bitget(int64(y_tmp(i+1)),64);     |  | ||||||
|         end |  | ||||||
|         out = floor(y/2^16); |  | ||||||
| end |  | ||||||
|  | @ -1,31 +0,0 @@ | ||||||
| clc;clear;close all |  | ||||||
| 
 |  | ||||||
| %%%verification of single IIR Filter by comparing matlab and verilog |  | ||||||
| cd('/data/work/thfu/TailCorr/script_m'); |  | ||||||
| 
 |  | ||||||
| a = 13740916; |  | ||||||
| b = -1047703; |  | ||||||
| y(1) = 0; |  | ||||||
| 
 |  | ||||||
| sel_double = 0; |  | ||||||
| 
 |  | ||||||
| switch sel_double |  | ||||||
|     case 0 |  | ||||||
|         iir_in = int64(importdata("/home/thfu/work/TailCorr/v02/sim/in") -32768); |  | ||||||
|         iir_out = int64(importdata("/home/thfu/work/TailCorr/v02/sim/out") -32768); |  | ||||||
|     case 1 |  | ||||||
|         iir_in = double(importdata("/home/thfu/work/TailCorr/v02/sim/in") -32768); |  | ||||||
|         iir_out = double(importdata("/home/thfu/work/TailCorr/v02/sim/out") -32768); |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| Script_out = MyIIR(a,b,iir_in,y(1),sel_double)'; |  | ||||||
| y_revised = iir_in + Script_out; |  | ||||||
| tau = finddelay(y_revised,iir_out); |  | ||||||
| 
 |  | ||||||
| Script_outPhi = cat(1,zeros(1,tau)',Script_out(1:end-tau,1)); |  | ||||||
| 
 |  | ||||||
| n = 1:length(iir_in); |  | ||||||
| diff = iir_out(n)-Script_outPhi(n); |  | ||||||
| 
 |  | ||||||
| diff_plot(iir_out, Script_outPhi) |  | ||||||
| tau |  | ||||||
|  | @ -1,45 +0,0 @@ | ||||||
| %%%verification of polyphase structures using trig |  | ||||||
| clc;clear all;close all |  | ||||||
| 
 |  | ||||||
| fs = 1e8; |  | ||||||
| t = (0:1:1e2)'/fs; |  | ||||||
| % f = 20e6; |  | ||||||
| % s = sin(2*pi*f*t); |  | ||||||
| s = triang(1e2-1); |  | ||||||
| s = [zeros(1,10) s' zeros(1,10)]'; |  | ||||||
| N = length(s); |  | ||||||
| ts = (0:1:N-1)'/fs; |  | ||||||
| %%% |  | ||||||
| s_r1 = [0 s(1:end-1,1)']'; |  | ||||||
| [s2,s2_mean] = MeanIntp(s,s_r1); |  | ||||||
| 
 |  | ||||||
| s_intp2 = zeros(2*N,1); |  | ||||||
| s_intp2(1:2:2*N) = s2_mean; |  | ||||||
| s_intp2(2:2:2*N) = s2; |  | ||||||
| t_intp2 = (0:1:2*N-1)'/fs/2; |  | ||||||
| %%% |  | ||||||
| s2_r1 = [0 s2(1:end-1,1)']'; |  | ||||||
| 
 |  | ||||||
| [s4_4,s4_3] = MeanIntp(s2,s2_mean); |  | ||||||
| [s4_2,s4_1] = MeanIntp(s2_mean,s2_r1); |  | ||||||
| 
 |  | ||||||
| s_intp4 = zeros(4*N,1); |  | ||||||
| s_intp4(1:4:4*N) = s4_1; |  | ||||||
| s_intp4(2:4:4*N) = s4_2; |  | ||||||
| s_intp4(3:4:4*N) = s4_3; |  | ||||||
| s_intp4(4:4:4*N) = s4_4; |  | ||||||
| 
 |  | ||||||
| t_intp4 = (0:1:4*N-1)'/fs/4; |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| figure('Units','normalized','Position',[0.000390625,0.517361111111111,0.49921875,0.422916666666667]); |  | ||||||
| plot(ts,s,t_intp2,s_intp2) |  | ||||||
| grid on |  | ||||||
| % xlim([0.58 0.62]*1e-6) |  | ||||||
| %  |  | ||||||
| %  |  | ||||||
| figure('Units','normalized','Position',[0.500390625,0.517361111111111,0.49921875,0.422916666666667]); |  | ||||||
| plot(t_intp4,s_intp4) |  | ||||||
| grid on |  | ||||||
| % xlim([0.58 0.62]*1e-6) |  | ||||||
| 
 |  | ||||||
|  | @ -1,27 +0,0 @@ | ||||||
| function out = TailCorr(alpha,beta,iir_in,YStartState,sel_double) |  | ||||||
| 
 |  | ||||||
| len = length(iir_in); |  | ||||||
| N = length(alpha); |  | ||||||
| 
 |  | ||||||
| iir_inR1 = cat(1,0,iir_in(1:end-1,1)); |  | ||||||
| 
 |  | ||||||
| diff = iir_in - iir_inR1; |  | ||||||
| 
 |  | ||||||
| Ystart = YStartState; |  | ||||||
| 
 |  | ||||||
| for i = 1:1:N |  | ||||||
|     y(1:len,i) = MyIIR(alpha(i),beta(i),diff,Ystart,sel_double); |  | ||||||
|     y = floor(y); |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| switch sel_double  |  | ||||||
| 
 |  | ||||||
|     case 0 |  | ||||||
|         y_sum = int64(sum(y,2));       |  | ||||||
| 
 |  | ||||||
|     case 1 |  | ||||||
|         y_sum = double(sum(y,2));       |  | ||||||
| 
 |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| out = iir_in+y_sum; |  | ||||||
|  | @ -1,63 +0,0 @@ | ||||||
| %%%2024-10-15 |  | ||||||
| %%%verification 8 linear interpolation result by comparing matlab and verilog result |  | ||||||
| clc;clear;close all |  | ||||||
| 
 |  | ||||||
| cd('/data/work/thfu/TailCorr/script_m'); |  | ||||||
| 
 |  | ||||||
| sel_double = 0; |  | ||||||
| 
 |  | ||||||
| switch sel_double |  | ||||||
| 
 |  | ||||||
|     case 0 |  | ||||||
|         iir_in_verilog     = int64(importdata("/home/thfu/work/TailCorr/sim/in.dat") - 32768); |  | ||||||
| %        iir_out_x1 = int64(importdata("/home/thfu/work/TailCorr/sim/X1_data.dat") -32768); |  | ||||||
| %        iir_out_x2 = int64(importdata("/home/thfu/work/TailCorr/sim/X2_data.dat") -32768); |  | ||||||
| %        iir_out_x4 = int64(importdata("/home/thfu/work/TailCorr/sim/X4_data.dat") -32768); |  | ||||||
|         iir_out_verilog_x8 = int64(importdata("/home/thfu/work/TailCorr/sim/X8_data.dat") -32768); |  | ||||||
|          |  | ||||||
|     case 1 |  | ||||||
|         iir_in     = double(importdata("/home/thfu/work/TailCorr/sim/in") + 0); |  | ||||||
|         iir_out_x1 = double(importdata("/home/thfu/work/TailCorr/sim/X1_data.dat") - 32768); |  | ||||||
|         iir_out_x2 = double(importdata("/home/thfu/work/TailCorr/sim/X2_data.dat") - 32768); |  | ||||||
|         iir_out_x4 = double(importdata("/home/thfu/work/TailCorr/sim/X4_data.dat") - 32768); |  | ||||||
|         iir_out_x8 = double(importdata("/home/thfu/work/TailCorr/sim/X8_data.dat") - 32768); |  | ||||||
|          |  | ||||||
| end |  | ||||||
| % iir_out_x1 = [iir_out_x1' zeros(1,2)]'; |  | ||||||
| % iir_out_x2 = [iir_out_x2' zeros(1,3)]'; |  | ||||||
| % iir_out_x4 = [iir_out_x4' zeros(1,6)]'; |  | ||||||
| 
 |  | ||||||
| alpha = [1757225200, 1045400392, 13740916]; |  | ||||||
| beta = -[1042856 1046395 1047703]; |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| Ystart = 0; |  | ||||||
| 
 |  | ||||||
| y_revised_matlab = TailCorr(alpha,beta,iir_in_verilog,Ystart,sel_double); |  | ||||||
| 
 |  | ||||||
| N = length(y_revised_matlab); |  | ||||||
| x1 = (1:1:N)'; |  | ||||||
| x8 = (1:1/8:N+1-1/8)'; |  | ||||||
| y_revised_intp8_matlab = int64(interp1(x1,double(y_revised_matlab),x8,'linear')); |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| %%% |  | ||||||
| %tau0 = finddelay(y_revised_matlab,iir_out_x1); |  | ||||||
| %y_revisedPhi0 = cat(1,zeros(1,tau0)',y_revised_matlab(1:end-tau0,1)); |  | ||||||
| %figure('Units','normalized','Position',[0.500390625,0.517361111111111,0.49921875,0.422916666666667]); |  | ||||||
| %diff_plot(iir_out_x1, y_revisedPhi0,'verdi','matlab',[200 N]); |  | ||||||
| %%% |  | ||||||
| %tau2 = finddelay(s_intp2,iir_out_x2); |  | ||||||
| %y_revisedPhi2 = cat(1,zeros(1,tau2)',s_intp2(1:end-tau2,1)); |  | ||||||
| %figure('Units','normalized','Position',[0.500390625,0.517361111111111,0.49921875,0.422916666666667]); |  | ||||||
| %diff_plot(iir_out_x2, y_revisedPhi2,'verdi','matlab',[0 4e4]) |  | ||||||
| %%% |  | ||||||
| %tau4 = finddelay(s_intp4,iir_out_x4); |  | ||||||
| %y_revisedPhi4 = cat(1,zeros(1,tau4)',s_intp4(1:end-tau4,1)); |  | ||||||
| %figure('Units','normalized','Position',[0.000390625,0.034027777777778,0.49921875,0.422916666666667]); |  | ||||||
| %diff_plot(iir_out_x4, y_revisedPhi4,'verdi','matlab',[0 8e4]) |  | ||||||
| %%% |  | ||||||
| tau8 = finddelay(y_revised_intp8_matlab,iir_out_verilog_x8); |  | ||||||
| y_revisedPhi8 = cat(1,zeros(1,tau8)',y_revised_intp8_matlab(1:end-tau8,1)); |  | ||||||
| figure('Units','normalized','Position',[0.000390625,0.517361111111111,0.49921875,0.422916666666667]); |  | ||||||
| diff_plot(iir_out_verilog_x8, y_revisedPhi8,'verdi','matlab',[400 800]); |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| %2024-11-09-verify IIR IP core | %in+iir_out with 8 intp | ||||||
| clc;clear;close all | clc;clear;close all | ||||||
| 
 | 
 | ||||||
| in         = importdata("/home/thfu/work/TailCorr/sim/in.dat");        | in         = importdata("/home/thfu/work/TailCorr/sim/in.dat");        | ||||||
|  | @ -35,26 +35,27 @@ wave_float_8 = interp1(1:wave_float_len,wave_float,1:1/8:(wave_float_len+1-1/8), | ||||||
| 
 | 
 | ||||||
| [cs_wave_A,wave_float_8_A,Delay] = alignsignals(cs_wave,wave_float_8); | [cs_wave_A,wave_float_8_A,Delay] = alignsignals(cs_wave,wave_float_8); | ||||||
| N = min(length(wave_float_8_A),length(cs_wave_A)); | N = min(length(wave_float_8_A),length(cs_wave_A)); | ||||||
| figure(2) | figure() | ||||||
| diff_plot(wave_float_8_A(90:end), cs_wave_A(154:end),'float','verdi',[0 N]); | diff_plot(wave_float_8_A(90:end), cs_wave_A(154:end),'float','verdi',[0 N]); | ||||||
| %% | %% | ||||||
|  | %Test of iir filter | ||||||
| [wave_float_A,wave_verdi_A,Delay] = alignsignals(wave_float,wave_verdi); | [wave_float_A,wave_verdi_A,Delay] = alignsignals(wave_float,wave_verdi); | ||||||
| N = min(length(wave_float_A),length(wave_verdi_A)); | N = min(length(wave_float_A),length(wave_verdi_A)); | ||||||
| figure(1)git sh | figure() | ||||||
| diff_plot(wave_float_A, wave_verdi_A,'float','verdi',[0 N]); | diff_plot(wave_float_A, wave_verdi_A,'float','verdi',[0 N]); | ||||||
| %% | %% | ||||||
| signalAnalyzer(wave_float,wave_verdi,'SampleRate',1); | signalAnalyzer(wave_float,wave_verdi,'SampleRate',1); | ||||||
| %% | %% | ||||||
| fprintf("a is %.10f\n",a) | fprintf("a is %.10f\n",a) | ||||||
| fprintf("b is %.10f\n",b) | fprintf("b is %.10f\n",b) | ||||||
| %% | 
 | ||||||
| a_fix = round(a*2^31); | a_fix = round(a*2^31); | ||||||
| b_fix = round(b*2^31); | b_fix = round(b*2^31); | ||||||
| 
 | 
 | ||||||
| dec2hex(a_fix,8) | a_hex = dec2hex(a_fix,8); | ||||||
| dec2hex(b_fix,8) | b_hex = dec2hex(b_fix,8); | ||||||
| 
 | 
 | ||||||
| % dec2bin(a_fix,32) | a_bin = dec2bin(a_fix,32); | ||||||
| % dec2bin(b_fix,32) | b_bin = dec2bin(b_fix,32); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,27 +0,0 @@ | ||||||
| clc;clear;close all |  | ||||||
| 
 |  | ||||||
| cd('/data/work/thfu/TailCorr/script_m'); |  | ||||||
| 
 |  | ||||||
| sel_double = 1; |  | ||||||
| 
 |  | ||||||
| switch sel_double |  | ||||||
|     case 0 |  | ||||||
|         iir_in = int64(importdata("/home/thfu/work/TailCorr/v02/sim/in") -32768); |  | ||||||
|         iir_out = int64(importdata("/home/thfu/work/TailCorr/v02/sim/out") -32768); |  | ||||||
|     case 1 |  | ||||||
|         iir_in = double(importdata("/home/thfu/work/TailCorr/v02/sim/in") -32768); |  | ||||||
|         iir_out = double(importdata("/home/thfu/work/TailCorr/v02/sim/out") -32768); |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| alpha = [1757225200, 1045400392, 13740916]; |  | ||||||
| beta = -[1042856 1046395 1047703]; |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| Ystart = 0; |  | ||||||
| 
 |  | ||||||
| y_revised = TailCorr(alpha,beta,iir_in,Ystart,sel_double); |  | ||||||
| 
 |  | ||||||
| tau = finddelay(y_revised,iir_out); |  | ||||||
| y_revisedPhi = cat(1,zeros(1,tau)',y_revised(1:end-tau,1)); |  | ||||||
| 
 |  | ||||||
| diff_plot(iir_out, y_revisedPhi,'verdi','matlab',[0 1e4]) |  | ||||||
|  | @ -1,73 +0,0 @@ | ||||||
| %%%20241009,comparing matlab and verilog result |  | ||||||
| clc;clear;close all |  | ||||||
| 
 |  | ||||||
| cd('/data/work/thfu/TailCorr/script_m'); |  | ||||||
| 
 |  | ||||||
| sel_double = 1; |  | ||||||
| 
 |  | ||||||
| switch sel_double |  | ||||||
| 
 |  | ||||||
|     case 0 |  | ||||||
|         iir_in     = int64(importdata("/home/thfu/work/TailCorr/Test/sim/in") -32768); |  | ||||||
|         iir_out_x1 = int64(importdata("/home/thfu/work/TailCorr/Test/sim/X1_data.dat") -32768); |  | ||||||
|         iir_out_x2 = int64(importdata("/home/thfu/work/TailCorr/Test/sim/X2_data.dat") -32768); |  | ||||||
|         iir_out_x4 = int64(importdata("/home/thfu/work/TailCorr/Test/sim/X4_data.dat") -32768); |  | ||||||
|     case 1 |  | ||||||
|         iir_in     = double(importdata("/home/thfu/work/TailCorr/Test/sim/in") + 0); |  | ||||||
|         iir_out_x1 = double(importdata("/home/thfu/work/TailCorr/Test/sim/X1_data.dat") - 32768); |  | ||||||
|         iir_out_x2 = double(importdata("/home/thfu/work/TailCorr/Test/sim/X2_data.dat") - 32768); |  | ||||||
|         iir_out_x4 = double(importdata("/home/thfu/work/TailCorr/Test/sim/X4_data.dat") - 32768); |  | ||||||
|          |  | ||||||
| end |  | ||||||
| % iir_out_x1 = [iir_out_x1' zeros(1,2)]'; |  | ||||||
| % iir_out_x2 = [iir_out_x2' zeros(1,3)]'; |  | ||||||
| % iir_out_x4 = [iir_out_x4' zeros(1,6)]'; |  | ||||||
| 
 |  | ||||||
| alpha = [1757225200, 1045400392, 13740916]; |  | ||||||
| beta = -[1042856 1046395 1047703]; |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| Ystart = 0; |  | ||||||
| 
 |  | ||||||
| y_revised = TailCorr(alpha,beta,iir_in,Ystart,sel_double); |  | ||||||
| 
 |  | ||||||
| s = round(y_revised); |  | ||||||
| N = length(s); |  | ||||||
| 
 |  | ||||||
| s_r1 = [0 s(1:end-1,1)']'; |  | ||||||
| [s2,s2_mean] = MeanIntp(s,s_r1); |  | ||||||
| s2 = floor(s2); |  | ||||||
| s2_mean = floor(s2_mean); |  | ||||||
| 
 |  | ||||||
| s2_r1 = [0 s2(1:end-1,1)']'; |  | ||||||
| [s4_4,s4_3] = MeanIntp(s2,s2_mean); |  | ||||||
| [s4_2,s4_1] = MeanIntp(s2_mean,s2_r1); |  | ||||||
| s4_1 = floor(s4_1); |  | ||||||
| s4_2 = floor(s4_2); |  | ||||||
| s4_3 = floor(s4_3); |  | ||||||
| s4_4 = floor(s4_4); |  | ||||||
| 
 |  | ||||||
| s_intp2 = zeros(2*N,1); |  | ||||||
| s_intp2(1:2:2*N) = s2_mean; |  | ||||||
| s_intp2(2:2:2*N) = s2; |  | ||||||
| 
 |  | ||||||
| s_intp4 = zeros(4*N,1); |  | ||||||
| s_intp4(1:4:4*N) = s4_1; |  | ||||||
| s_intp4(2:4:4*N) = s4_2; |  | ||||||
| s_intp4(3:4:4*N) = s4_3; |  | ||||||
| s_intp4(4:4:4*N) = s4_4; |  | ||||||
| %%% |  | ||||||
| tau1 = finddelay(y_revised,iir_out_x1); |  | ||||||
| y_revisedPhi1 = cat(1,zeros(1,tau1)',y_revised(1:end-tau1,1)); |  | ||||||
| figure('Units','normalized','Position',[0.000390625,0.517361111111111,0.49921875,0.422916666666667]); |  | ||||||
| diff_plot(iir_out_x1, y_revisedPhi1,'verdi','matlab',[0 2e4]) |  | ||||||
| 
 |  | ||||||
| tau2 = finddelay(s_intp2,iir_out_x2); |  | ||||||
| y_revisedPhi2 = cat(1,zeros(1,tau2)',s_intp2(1:end-tau2,1)); |  | ||||||
| figure('Units','normalized','Position',[0.500390625,0.517361111111111,0.49921875,0.422916666666667]); |  | ||||||
| diff_plot(iir_out_x2, y_revisedPhi2,'verdi','matlab',[0 4e4]) |  | ||||||
| 
 |  | ||||||
| tau4 = finddelay(s_intp4,iir_out_x4); |  | ||||||
| y_revisedPhi4 = cat(1,zeros(1,tau4)',s_intp4(1:end-tau4,1)); |  | ||||||
| figure('Units','normalized','Position',[0.000390625,0.034027777777778,0.49921875,0.422916666666667]); |  | ||||||
| diff_plot(iir_out_x4, y_revisedPhi4,'verdi','matlab',[0 8e4]) |  | ||||||
|  | @ -1,21 +0,0 @@ | ||||||
| %%%2024-10-17,verify 8 intp by comparing matlab and verilog |  | ||||||
| clc;clear all;close all; |  | ||||||
| 
 |  | ||||||
| in = importdata("/home/thfu/work/TailCorr/sim/in_intp8.dat"); |  | ||||||
| intp8_verilog = importdata("/home/thfu/work/TailCorr/sim/out_intp8.dat"); |  | ||||||
| 
 |  | ||||||
| N = length(in); |  | ||||||
| time = 1:1:N; |  | ||||||
| time8 = 1:1/8:N+1-1/8; |  | ||||||
| intp8_matlab = floor(interp1(time,in,time8,'linear'))'; |  | ||||||
| 
 |  | ||||||
| %figure |  | ||||||
| %plot(time,in); |  | ||||||
| %hold on |  | ||||||
| %plot(time8,intp8_verilog); |  | ||||||
| %xlim([4500 5500]) |  | ||||||
| 
 |  | ||||||
| tau8 = finddelay(intp8_matlab(1.8e4:3e4),intp8_verilog(1.8e4:3e4)); |  | ||||||
| intp8_matlab_revised = cat(1,zeros(1,tau8)',intp8_matlab(1:end-tau8,1)); |  | ||||||
| figure('Units','normalized','Position',[0.000390625,0.517361111111111,0.49921875,0.422916666666667]); |  | ||||||
| diff_plot(intp8_verilog, intp8_matlab_revised,'verdi','matlab',[2e4 2.2e4]); |  | ||||||
		Loading…
	
		Reference in New Issue