Fork me on GitHub

## Freescale K64 PLL Calculator

### What Is It?

This is a calculator for the PLL configuration values for VDIV, and PDIV for the Freescale K64 processor. You put in your input frequency and Desired output frequency and it returns the value of PDIV and VDIV. These values are the numbers which are used in the equation: $$f_{out} = VDIV * \frac{f_{in}}{PDIV}$$ where: $$2MHz \leq \frac{f_{in}}{PDIV} \leq 4 MHz$$ There are also constraints on VDIV and PDIV in terms of min and max ranges. To get the actual register values of PDIV and VDIV you can look up the values in the datasheet on pages 589 and 590.

### How does it work?

A simple calculator could have been used, but instead I decided to learn a little about using z3 which is a high performance theorem prover. I make calls into z3 from python and provide an api for accessing these. The api entry point is at /solve To get the solution you can do the following:

/solve?fin=20e6&fout=80e6

Which will return:
{
"d": "8",
"f_in": "20000000",
"f_out": "80000000",
"m": "32"
},
"status": "success"
}

If the model can not converge and cannot find a solution given the constraints you will get the following result:
{