Hi all,
I want to write code for simulating interpolator.
I have two clock domain CLK_low , CLK_high.
I want to increase sample rate by this ratio CLk_h/CLK_l.
I write code below and feed it with ramp but in some place it did not work correctly.
please help
![Cry Cry](https://designers-guide.org/forum/Templates/Forum/default/cry.gif)
Clk_h=150 MHz;
CLK_l=61.44 MHz;
this program use linear interpolation y=(1-n)*Xn-1+n*Xn
that n is 0<n<1;
module SRC (in,out,CLK_l,CLK_h);
parameter integer OSR_1 = floor((1/(150/61.44))*pow(2,9));
parameter integer scale = pow(2,9);
input in,CLK_l,CLK_h;
output out;
wreal in,out;
integer fraq_cnt = 0;
real xn,xn_1,y_lin,frq,frq1;
always @(posedge CLK_h ) begin
fraq_cnt = fraq_cnt + OSR_1;
frq1 = (fraq_cnt % scale);
frq = frq1/scale;
y_lin = (1-(frq)) * xn_1 + (frq) * xn;
end
always @(posedge CLK_l ) begin
xn_1 = xn;
xn = in;
end
assign out = y_lin;
endmodule