Skip to content

Commit 428fa24

Browse files
Merge pull request #2592 from clash-lang/safe_pll
Offer safe PLL's
2 parents 5b055fb + de5e00b commit 428fa24

32 files changed

+1476
-860
lines changed

changelog/2023-03-01T12_18_28+01_00_xilinx_clocking_wizard

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
NEW: `seClockToDiffClock`, to create a differential clock signal in a test
2-
bench. It is not suitable for synthesising a differential output in hardware.
1+
NEW: `clockToDiffClock`, to create a differential clock signal in a test bench. It is not suitable for synthesizing a differential output in hardware.
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
ADDED: A new clock type `DiffClock` is introduced to signify a differential
22
clock signal that is passed to the design on two ports in antiphase. This is
3-
used by the Xilinx `clockWizardDifferential` IP generator.
4-
5-
CHANGED: Xilinx `clockWizardDifferential` now gets its input clock as a
6-
`DiffClock` type; use `seClockToDiffClock` to generate this in your test bench
7-
if needed. Previously, the function received two clock inputs, but this
8-
generated `create_clock` statements in the top-level SDC file for both phases
9-
which is incorrect.
3+
used by the differential Xilinx clock wizards in `Clash.Xilinx.ClockGen`.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
REMOVED: The module `Clash.Clocks.Deriving` has been removed.
2+
3+
FIXED: `altpll` and `alteraPll` in `Clash.Intel.ClockGen` now account for the input domain's `ResetPolarity`. Before this fix, the reset was always interpreted as an active-high signal.
4+
5+
CHANGED: The IP core generators in `Clash.Intel.ClockGen` now declare that their input domain needs to have asynchronous resets (`HasAsynchronousReset`), as the functions react asynchronously to their reset input and thus need to be glitch-free. The functions marked `unsafe` do not have this constraint; instead, the function documentation calls attention to the requirement.
6+
7+
INTERNAL NEW: `Clash.Primitives.DSL.declareN`, a companion to `declare` which declares multiple signals in one go.
8+
9+
DEPRECATED: The functions `altpll` and `alteraPll` in `Clash.Intel.ClockGen` have been deprecated because they are unsafe to use while this is not apparent from the name. The `locked` output signal of these functions is an asynchronous signal which needs to be synchronized before it can be used (something the examples did in fact demonstrate). For the common use case, new functions are available, named `altpllSync` and `alteraPllSync`. These functions are safe. For advanced use cases, the old functionality can be obtained through `unsafeAltpll` and `unsafeAlteraPll`.
10+
11+
NEW: `altpllSync` and `alteraPllSync` in `Clash.Intel.ClockGen`. These replace the deprecated functions without the `Sync` suffix. Unlike the old functions, these functions are safe to use and have a reset signal for each output domain that can be used to keep the domain in reset while the clock output stabilizes. All PLL functions now also support multiple clock outputs like the old `alteraPll` did.
12+
13+
CHANGED: The wizards in `Clash.Xilinx.ClockGen` have been completely overhauled. The original functions were unsafe and broken in several ways. See the documentation in `Clash.Xilinx.ClockGen` for how to use the new functions. Significant changes are:
14+
* `clockWizard` and `clockWizardDifferential` now output a `Clock` and a `Reset` which can be directly used by logic. Previously, it outputted a clock and an asynchronous `locked` signal which first needed to be synchronized before it could be used (hence the old function being unsafe). Additionally, the original `locked` signal was strange: it mistakenly was an `Enable` instead of a `Signal dom Bool` and there was a polarity mismatch between Clash simulation and HDL. The `locked` signal was also not resampled to the output domain in Clash simulation.
15+
* There are new functions `unsafeClockWizard` and `unsafeClockWizardDifferential` for advanced use cases which directly expose the `locked` output of the wizard.
16+
* All clock generators now have the option to output multiple clocks from a single instance.
17+
* `clockWizardDifferential` now gets its input clock as a `DiffClock` type; use `clockToDiffClock` to generate this in your test bench if needed. Previously, the function received two clock inputs, but this generated `create_clock` statements in the top-level SDC file for both phases which is incorrect.
18+
* A constraint was removed: The /output/ clock domain no longer requires asynchronous resets. This was originally intended to signal that the outgoing lock signal is an asynchronous signal. The constraint does not convey this information at all and is wrong; it also prevents using synchronous resets in the circuit as recommended by Xilinx. Note that if you use the `unsafe` functions, it is still necessary to synchronize the `locked` output in your design.
19+
* The port names of the primitives in HDL are now correctly lower case.
20+
* Add Tcl generation. This moves the responsibility of MMCM component generation from the user to `clashConnector.tcl`, which can be found in [`clash-lib:Clash.DataFiles`](https://hackage.haskell.org/package/clash-lib-1.8.0/docs/Clash-DataFiles.html).
21+
* The wizards now use the user-provided name as the name of the /instance/ rather than the name of the /IP core/. This change was also done for `Clash.Intel.ClockGen` in Clash v1.2.0 in March 2020, when Clash started generating Intel Qsys files. Before that, the user needed to generate a Qsys component manually. Now, in Clash v1.8.0, we also generate the Tcl for Xilinx wizards. When the user is responsible for creating the IP core, it makes sense to always set the component name to the user-provided value. But when that is also generated by Clash, that is no longer needed. Allowing users to set the instance name instead makes it possible to match on the instance in SDC files and such.

clash-lib/prims/common/Clash_Intel_ClockGen.primitives.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
- BlackBox:
2-
name: Clash.Intel.ClockGen.altpll
2+
name: Clash.Intel.ClockGen.unsafeAltpll
33
format: Haskell
44
includes:
55
- name: altpll
@@ -10,7 +10,7 @@
1010
templateFunction: Clash.Primitives.Intel.ClockGen.altpllTF
1111
workInfo: Always
1212
- BlackBox:
13-
name: Clash.Intel.ClockGen.alteraPll
13+
name: Clash.Intel.ClockGen.unsafeAlteraPll
1414
format: Haskell
1515
includes:
1616
- name: altera_pll

clash-lib/prims/common/Clash_Xilinx_ClockGen.primitives.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
- BlackBox:
2-
name: Clash.Xilinx.ClockGen.clockWizardDifferential
2+
name: Clash.Xilinx.ClockGen.unsafeClockWizard
3+
kind: Declaration
4+
format: Haskell
5+
templateFunction: Clash.Primitives.Xilinx.ClockGen.clockWizardTF
6+
includes:
7+
- name: clk_wiz
8+
extension: clash.tcl
9+
format: Haskell
10+
templateFunction: Clash.Primitives.Xilinx.ClockGen.clockWizardTclTF
11+
workInfo: Always
12+
- BlackBox:
13+
name: Clash.Xilinx.ClockGen.unsafeClockWizardDifferential
314
kind: Declaration
415
format: Haskell
516
templateFunction: Clash.Primitives.Xilinx.ClockGen.clockWizardDifferentialTF

clash-lib/prims/commonverilog/Clash_Explicit_Testbench.primitives.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
template: assign ~RESULT = 1'b1;
77
workInfo: Always
88
- BlackBox:
9-
name: Clash.Explicit.Testbench.seClockToDiffClock
9+
name: Clash.Explicit.Testbench.clockToDiffClock
1010
kind: Expression
1111
template: '{~ARG[1], ~ ~ARG[1]}'

clash-lib/prims/commonverilog/Clash_Xilinx_ClockGen.primitives.yaml

Lines changed: 0 additions & 25 deletions
This file was deleted.

clash-lib/prims/vhdl/Clash_Explicit_Testbench.primitives.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,6 @@
156156
template: ~RESULT <= true;
157157
workInfo: Always
158158
- BlackBox:
159-
name: Clash.Explicit.Testbench.seClockToDiffClock
159+
name: Clash.Explicit.Testbench.clockToDiffClock
160160
kind: Expression
161161
template: (~ARG[1], not ~ARG[1])

clash-lib/prims/vhdl/Clash_Xilinx_ClockGen.primitives.yaml

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)