Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong PLL frequency in PHASE_AND_DELAY mode on UP5 #237

Open
HansHamster opened this issue Sep 23, 2019 · 3 comments
Open

Wrong PLL frequency in PHASE_AND_DELAY mode on UP5 #237

HansHamster opened this issue Sep 23, 2019 · 3 comments

Comments

@HansHamster
Copy link

Minimal example to show the problem:

`module top(
output clk_out
);

wire clk_48M;

SB_HFOSC inthosc (
.CLKHFPU(1'b1),
.CLKHFEN(1'b1),
.CLKHF(clk_48M)
);

defparam inthosc.CLKHF_DIV = "0b00";

wire clk1, clk2;

// icepll -i 48 -o 32 -S
SB_PLL40_2F_CORE #(
.FEEDBACK_PATH("PHASE_AND_DELAY"),
.DIVR(4'b0010), // DIVR = 2
.DIVF(7'b0000001), // DIVF = 1
.DIVQ(3'b101), // DIVQ = 5
.FILTER_RANGE(3'b001) // FILTER_RANGE = 1
) uut (
.LOCK(),
.RESETB(1'b1),
.BYPASS(1'b0),
.REFERENCECLK(clk_48M),
.PLLOUTGLOBALA(clk1),
.PLLOUTGLOBALB(clk2)
);

assign clk_out = clk1;

endmodule
`

The PLL parameters are calculated for a 48MHz input and a 32MHz output with icepll -i 48 -o 32 -S.
Connecting each clock to the output, I measure 48MHz on clk_48M, but 80MHz on clk1 and clk2 instead of 32MHz.
According to TN1251, the output clock should be Refclk*(DIVF+1)/(DIVR+1), so 48MHz*2/3=32MHz, but for some reason the actual frequency is much higher.

@daveshah1
Copy link
Contributor

I am not 100% sure where the factor of 2.5 is coming from, previously I have seen factors of either 4 or 7 depending on SHIFTREG_DIV_MODE (see #198)

@smunaut
Copy link
Contributor

smunaut commented Feb 12, 2020

I would check that the PLL is locked at all ...

@HansHamster
Copy link
Author

Finally had time to do some more digging.
Part of the issue was, that I simply forgot the
.PLLOUT_SELECT_PORTA("SHIFTREG_0deg"), .PLLOUT_SELECT_PORTB("SHIFTREG_90deg")
which brings the frequency down to 20 MHz.

I then compared the PLL parameters calculated by icepll and iceCube/Radiant and it looks like (at least for the cases I tried) that all parameters are identical except for DIVQ.
If I set DIVQ to 3 as calculated by iceCube instead of 5, I get the expected 32 MHz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants