ECP5: Adjust PLL constants so the PLL lock indication works
authorPaul Mackerras <paulus@ozlabs.org>
Sat, 16 Oct 2021 08:24:14 +0000 (19:24 +1100)
committerPaul Mackerras <paulus@ozlabs.org>
Sat, 16 Oct 2021 09:14:12 +0000 (20:14 +1100)
commitd458b5845c80d526b6701671c52c63a62bceb30c
tree8bfa33d32bb64e9a6653ab4321e7798fa8f09e21
parent8a030502a22c206d2efefe28415ff367bc01c4f6
ECP5: Adjust PLL constants so the PLL lock indication works

At present, code (such as simple_random) which produces serial port
output during the first few milliseconds of operation produces garbled
output.  The reason is that the clock has not yet stabilized and is
running slow, resulting in the bit time of the serial characters being
too long.

The ECP5 data sheet says that the phase detector should be operated
between 10 and 400 MHz.  The current code operates it at 2MHz.
Consequently, the PLL lock indication doesn't work, i.e. it is always
zero.  The current code works around that by inverting it, i.e. taking
the "not locked" indication to mean "locked".

Instead, we now run it at 12MHz, chosen because the common external
clock inputs on ECP5 boards are 12MHz and 48MHz.  Normally this would
mean that the available system clock frequencies would be multiples of
12MHz, but this is a little inconvenient as we use 40MHz on the Orange
Crab v0.21 boards.  Instead, by using the secondary clock output for
feedback, we can have any divisor of the PLL frequency as the system
clock frequency.

The ECP5 data sheet says the PLL oscillator can run at 400 to 800
MHz.  Here we choose 480MHz since that allows us to generate 40MHz and
48MHz easily and is a multiple of 12MHz.

With this, the lock signal works correctly, and the inversion can be
removed.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
fpga/clk_gen_ecp5.vhd