[FPGA] clock dividers on FPGA
There is need to add local clock dividers inside the clock manager. The divide is nothing complicated, just a divide by 4 and a divide by 2. These do not need to synchronous to each other, or for that matter the source clock.
What might be the most FPGA friendly approach to do this? So far I have gathered a few options, but wanted to see if people have other preferences
- just leave it as RTL and hope the tool figures it out (I've actually seen this done, although i'm not sure if there was a huge timing cost)
- Add a second PLL to interface with the one currently sitting at the top level (this will be wrapped in a prim). This feels slightly like an overkill.
- Make use of the BUFR_DIVIDE primitive. The main drawback with this seems to be the clocks will not remain sync, but as mentioned, that is not something we care about.
- Use BUFCGE to create non- 50/50 duty cycle clocks. I really don't want to go down this route if possible.
Thoughts anyone?
if others not on the assignee's list want to chime in, please do so. I'm not an fpga expert and I don't really know the right answer in this area.
Can you generate in https://github.com/mdhayter/opentitan/blob/master/hw/top_earlgrey/rtl/clkgen_xil7series.sv
The PLLE2_ADV has three unused outputs and if you are looking for /2 and /4 of the 50MHz clock then that should be easy with divide by 48 and 96? .CLKOUT2_DIVIDE (48), .CLKOUT2_PHASE (0.000), .CLKOUT2_DUTY_CYCLE (0.500), .CLKOUT3_DIVIDE (96), .CLKOUT3_PHASE (0.000), .CLKOUT3_DUTY_CYCLE (0.500),
Then maybe buffer the clkout2 and 3.
I thought about it, but the problem is more hierarchy related. The clkgen module lives outside top_earlgrey, and eventually inside ast.
While the clkmgr lives within top_earlgrey as a comportable module. I would prefer not to have the number of clock inputs change based on which platform we are targeting. Sorry I should have clarified that point first.
On Mon, Jun 29, 2020 at 5:30 PM mdhayter [email protected] wrote:
Can you generate in https://github.com/mdhayter/opentitan/blob/master/hw/top_earlgrey/rtl/clkgen_xil7series.sv
The PLLE2_ADV has three unused outputs and if you are looking for /2 and /4 of the 50MHz clock then that should be easy with divide by 48 and 96? .CLKOUT2_DIVIDE (48), .CLKOUT2_PHASE (0.000), .CLKOUT2_DUTY_CYCLE (0.500), .CLKOUT3_DIVIDE (96), .CLKOUT3_PHASE (0.000), .CLKOUT3_DUTY_CYCLE (0.500),
Then maybe buffer the clkout2 and 3.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/2676#issuecomment-651442273, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2RSTIWLUGYYI65LFIYY3RZEW2TANCNFSM4OLVQKDA .
the PLL option that @mdhayter mentioned would probably be the best / most performant way to implement this for FPGAs. but given the hierarchy issue that @tjaychen mentioned, I think we should opt for one of the other solutions, since we do not intend to route additional clock signals into the design that are platform dependent. also, we use the FPGA as an emulation platform for the ASIC design - so there is not really a requirement to make this work at high clock frequencies.
wrapping up a second PLL in a clock divider primitive is in IMO also overkill, especially since we do not care about the phase (we might have to go that route if a known phase relationship is required).
I've never used the BUFR_DIVIDE parameter explicitly for BUFRs, but this variant sounds nice, since it solves everything with a native FPGA clocking primitive. the problem I see with this solution is that the BUFR is only a regional clock buffer, and depending on where the divided clock fans out to, this might not be mappable by the tool. however, if this is only for a local clock tree, this might work.
if it does not work, we're left with the BUFGCE and the RTL variant you mentioned. I find both more or less equally ugly. the tool might be happier if we are going with the BUFCE approach, since otherwise it will likely start to complain that it has to route clock signals through fabric logic... however, I also see that this produces a distorted duty cycle. do you think this could become a problem? if so, how about we try to divide it in RTL and declare it as a generated clock?
yeah my personal preference are RTL divide or BUFR. I don't really know what the larger implications of BUFR will be...or the RTL divide. I think I should try the RTL divide first and see what the tool does, what do you think?
On Mon, Jun 29, 2020 at 6:30 PM Michael Schaffner [email protected] wrote:
the PLL option that @mdhayter https://github.com/mdhayter mentioned would probably be the best / most performant way to implement this for FPGAs. but given the hierarchy issue that @tjaychen https://github.com/tjaychen mentioned, I think we should opt for one of the other solutions, since we do not intend to route additional clock signals into the design that are platform dependent. also, we use the FPGA as an emulation platform for the ASIC design - so there is not really a requirement to make this work at high clock frequencies.
wrapping up a second PLL in a clock divider primitive is in IMO also overkill, especially since we do not care about the phase (we might have to go that route if a known phase relationship is required).
I've never used the BUFR_DIVIDE parameter explicitly for BUFRs, but this variant sounds nice, since it solves everything with a native FPGA clocking primitive. the problem I see with this solution is that the BUFR is only a regional clock buffer, and depending on where the divided clock fans out to, this might not be mappable by the tool. however, if this is only for a local clock tree, this might work.
if it does not work, we're left with the BUFGCE and the RTL variant you mentioned. I find both more or less equally ugly. the tool might be happier if we are going with the BUFCE approach, since otherwise it will likely start to complain that it has to route clock signals through fabric logic... however, I also see that this produces a distorted duty cycle. do you think this could become a problem? if so, how about we try to divide it in RTL and declare it as a generated clock?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/2676#issuecomment-651463631, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2RSUVITKTUUABNBE77N3RZE5ZTANCNFSM4OLVQKDA .
yeah let's try. as mentioned, we treat the FPGA as an emulation platform, so I think this should be fine for our purposes. we should just be aware that Vivado may spit out critical warnings, and it does not work well at higher clock speeds.
Pure RTL dividers are probably fine for a start, but won't work forever (Vivado hasn't inferred PLLs from that in the past in my experience).
So at one point, we'll need to wrap things in a prim_clock_divider-style module; if we can do that right from the start (even if we only do a RTL divide in there for now), things will get easier down the road. Really up to you how much time you can spend on it right now.
Indeed, I am also in favor of putting this into a prim_generic from the beginning, since this will likely need an ASIC specific implementation with hand selected cells.
Note that I think the idea was really just to divide by powers of two and no other ratios.
yeah i think if we think long term there is a need to wrap it up using a PLL, it makes sense to use a prim for it now. That was the approach I was going to go anyways.
On Tue, Jun 30, 2020 at 1:46 PM Michael Schaffner [email protected] wrote:
Indeed, I am also in favor of putting this into a prim_generic from the beginning, since this will likely need an ASIC specific implementation with hand selected cells.
Note that I think the idea was really just to divide by powers of two and no other ratios.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/2676#issuecomment-652034039, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2RSWYBBAA4TA6NVXD76TRZJFK3ANCNFSM4OLVQKDA .
My 2c: some PLL instances may be configured to have clk/2 outputs, so you can use a single PLL for both of them. The other thing that comes to mind, is to use a simple RTL divider and let it drive a BUFG.
On Tue, Jun 30, 2020 at 2:26 PM tjaychen [email protected] wrote:
yeah i think if we think long term there is a need to wrap it up using a PLL, it makes sense to use a prim for it now. That was the approach I was going to go anyways.
On Tue, Jun 30, 2020 at 1:46 PM Michael Schaffner < [email protected]> wrote:
Indeed, I am also in favor of putting this into a prim_generic from the beginning, since this will likely need an ASIC specific implementation with hand selected cells.
Note that I think the idea was really just to divide by powers of two and no other ratios.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://github.com/lowRISC/opentitan/issues/2676#issuecomment-652034039 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AAH2RSWYBBAA4TA6NVXD76TRZJFK3ANCNFSM4OLVQKDA
.
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/2676#issuecomment-652054232, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANHQG2GFYX4HGXIUY6CMPZ3RZJJ67ANCNFSM4OLVQKDA .
-- -Ohad
thanks @gorusso ! The RTL + BUFG is another I had in mind, except we get into a situation where there are cascaded BUFG's, and the tool seems to really have a problem with that.
This is partially because our clock dividers are implemented as BUFGCE's in fpga land.. and a few others and I have wondered for awhile if it would be better if these are just made passthrough. Do you have any thoughts there?