Skip to content

Commit

Permalink
ecppll: Fixed inconsistent tab/space usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanG077 committed Jul 28, 2021
1 parent dff1cbc commit 541e398
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions libtrellis/tools/ecppll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,24 +278,24 @@ void calc_pll_params(pll_params &params, float input, float output){
continue;
for(int feedback_div=1;feedback_div <= 80; feedback_div++){
for(int output_div=1;output_div <= 128; output_div++){
float fvco = fpfd * (float)feedback_div * (float) output_div;

if(fvco < VCO_MIN || fvco > VCO_MAX)
continue;

float fout = fvco / (float) output_div;
if(fabsf(fout - output) < error ||
(fabsf(fout-output) == error && fabsf(fvco - 600) < fabsf(params.fvco - 600))){
error = fabsf(fout-output);
params.refclk_div = input_div;
params.feedback_div = feedback_div;
params.output_div = output_div;
params.fout = fout;
params.fvco = fvco;
// shift the primary by 180 degrees. Lattice seems to do this
float ns_phase = 1/(fout * 1e6) * 0.5;
params.primary_cphase = ns_phase * (fvco * 1e6);
}
float fvco = fpfd * (float)feedback_div * (float) output_div;

if(fvco < VCO_MIN || fvco > VCO_MAX)
continue;

float fout = fvco / (float) output_div;
if(fabsf(fout - output) < error ||
(fabsf(fout-output) == error && fabsf(fvco - 600) < fabsf(params.fvco - 600))){
error = fabsf(fout-output);
params.refclk_div = input_div;
params.feedback_div = feedback_div;
params.output_div = output_div;
params.fout = fout;
params.fvco = fvco;
// shift the primary by 180 degrees. Lattice seems to do this
float ns_phase = 1/(fout * 1e6) * 0.5;
params.primary_cphase = ns_phase * (fvco * 1e6);
}
}
}
}
Expand All @@ -310,29 +310,29 @@ void calc_pll_params_highres(pll_params &params, float input, float output){
continue;
for(int feedback_div=1;feedback_div <= 80; feedback_div++){
for(int output_div=1;output_div <= 128; output_div++){
float fvco = fpfd * (float)feedback_div * (float) output_div;

if(fvco < VCO_MIN || fvco > VCO_MAX)
continue;
float ffeedback = fvco / (float) output_div;
if(ffeedback < OUTPUT_MIN || ffeedback > OUTPUT_MAX)
continue;
for(int secondary_div = 1; secondary_div <= 128; secondary_div++){
float fout = fvco / (float) secondary_div;
if(fabsf(fout - output) < error ||
(fabsf(fout-output) == error && fabsf(fvco - 600) < fabsf(params.fvco - 600))){
error = fabsf(fout-output);
params.mode = pll_mode::HIGHRES;
params.refclk_div = input_div;
params.feedback_div = feedback_div;
params.output_div = output_div;
params.secondary[0].div = secondary_div;
params.secondary[0].enabled = true;
params.secondary[0].freq = fout;
params.fout = fout;
params.fvco = fvco;
}
}
float fvco = fpfd * (float)feedback_div * (float) output_div;

if(fvco < VCO_MIN || fvco > VCO_MAX)
continue;
float ffeedback = fvco / (float) output_div;
if(ffeedback < OUTPUT_MIN || ffeedback > OUTPUT_MAX)
continue;
for(int secondary_div = 1; secondary_div <= 128; secondary_div++){
float fout = fvco / (float) secondary_div;
if(fabsf(fout - output) < error ||
(fabsf(fout-output) == error && fabsf(fvco - 600) < fabsf(params.fvco - 600))){
error = fabsf(fout-output);
params.mode = pll_mode::HIGHRES;
params.refclk_div = input_div;
params.feedback_div = feedback_div;
params.output_div = output_div;
params.secondary[0].div = secondary_div;
params.secondary[0].enabled = true;
params.secondary[0].freq = fout;
params.fout = fout;
params.fvco = fvco;
}
}
}
}
}
Expand Down Expand Up @@ -504,6 +504,6 @@ void write_pll_config(const pll_params & params, const string &name, ofstream& f
file << " .PLLWAKESYNC(1'b0),\n";
file << " .ENCLKOP(1'b0),\n";
file << " .LOCK(locked)\n";
file << " );\n";
file << " );\n";
file << "endmodule\n";
}

0 comments on commit 541e398

Please sign in to comment.