clash-lang / clash-compiler

Haskell to VHDL/Verilog/SystemVerilog compiler
https://clash-lang.org/
Other
1.4k stars 149 forks source link

Offer safe PLL's #2592

Closed DigitalBrains1 closed 9 months ago

DigitalBrains1 commented 9 months ago

We have the convention that if a function can lead to timing violations, we prefix the name of that function with unsafe. The functions in Clash.Intel.ClockGen and Clash.Xilinx.ClockGen before this PR do not follow that convention. The locked output of these clock generators is an asynchronous signal. All our examples showed the correct way to handle this, but it should be called out by an unsafe prefix, and we should offer an easy-to-use alternative. It was too easy for a user to forget to synchronise the locked signal.

This PR deprecates the Intel functions and adds new functions, both a safe variant and, for advanced use cases, an unsafe variant. The safe variant incorporates resetSynchronizer so there's just a ready-to-use Reset instead of the asynchronous locked signal.

For Xilinx, it was decided to not deprecate the functions but rather scrap them altogether and provide new, safe ones with the same name as the old unsafe ones. The functions in Clash 1.6 are so broken that keeping them around as deprecated functions doesn't add much utility for our users; better to bite the bullet. PR #2427 had already changed the API for Xilinx, by the way.

Still TODO:

DigitalBrains1 commented 9 months ago

Ah, I had neglected to mention that I was still working on the Intel documentation, I simply copied the Xilinx one and still need to adjust those things.

DigitalBrains1 commented 9 months ago

Since your review, I've made the following changes: