Skip to content

Commit

Permalink
Merge pull request #1804 from zeldin/ecp5_pll_phase
Browse files Browse the repository at this point in the history
cores/clocks/lattice_ecp5: Fix phase calculation to match Diamond output
  • Loading branch information
enjoy-digital authored Oct 27, 2023
2 parents 63159aa + 6636560 commit e55cf0f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions litex/soc/cores/clock/lattice_ecp5.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ def do_finalize(self):
self.comb += self.locked.eq(locked & ~self.reset)
for n, (clk, f, p, m, dpa) in sorted(self.clkouts.items()):
div = config[f"clko{n}_div"]
cphase = int(p*(div + 1)/360 + div - 1)
phase = round(p*div/45)
self.params[f"p_CLKO{n_to_l[n]}_ENABLE"] = "ENABLED"
self.params[f"p_CLKO{n_to_l[n]}_DIV"] = div
self.params[f"p_CLKO{n_to_l[n]}_FPHASE"] = 0
self.params[f"p_CLKO{n_to_l[n]}_CPHASE"] = cphase
self.params[f"p_CLKO{n_to_l[n]}_FPHASE"] = phase & 7
self.params[f"p_CLKO{n_to_l[n]}_CPHASE"] = (phase >> 3) + (div - 1)
self.params[f"o_CLKO{n_to_l[n]}"] = clk
if f > 0: # i.e. not a feedback-only clock
self.params["attr"].append((f"FREQUENCY_PIN_CLKO{n_to_l[n]}", str(f/1e6)))
Expand Down

0 comments on commit e55cf0f

Please sign in to comment.