Clock Divider and PLL Best Practices
Hi Everybody,
I am new to FPGA programming and have some questions regarding the clocks in FPGA. I started to learn Verilog and as part of the first project design, I need to use I2C to communicate to an external device. Since I am new to FPGA I decided not to use existing I2C cores, but write my own (just for learning purpose). In my case, it is simplified one master to one slave communication, so I2C looks simple enough to implement.
I actually have a working design, but now I have a few questions about clock signals. My clock is running at 50MHz. For I2C I need SCL clock to run at 400kHZ/100kHZ. I created a clock divider with a counter. However, I saw that this type of clock divider in FPGA is frowned upon.
So, here is my first question - is this "clock" for SCL considered a clock? I don't use it to drive always @ (posedge ) blocks (it is run by system 50MHz **bleep**). I use this "clock" to generate the SCL signal and use it inside always block to know when to change the SDA signal.
The next question is about PLL. I can use PLL to generate a 400kHz clock. But it looks like to be able to work with the rest of the logic which is driven by 50MHz clock I either need to use 50Mhz clock inside I2C logic and use PLL just to drive SCL, or drive I2C logic with 400kHz clock. The latter will require extra synchronization between 50MHz logic and 400kHz logic. In fact, it is not 400kHz but at least 800kHz since the SDA signal can change only in the middle of positive or negative SCL cycle. It looks like an overcomplicated design, but if it will make system more stable it is worth it. So my question is - does it make sense to use PLL for this purpose?
And one more PLL related question. Is the clock generated by PLL a different clock domain with regards to the clock that drives PLL?
Thanks,
Alex.