clash-prelude-1.9.0: Clash: a functional hardware description language - Prelude library
Copyright(C) 2017 Google Inc
2019 Myrtle Software Ltd
2025 QBayLogic B.V.
LicenseBSD2 (see the file LICENSE)
MaintainerQBayLogic B.V. <devops@qbaylogic.com>
Safe HaskellNone
LanguageHaskell2010

Clash.Explicit.DDR

Contents

Description

We simulate DDR signal by using Signals which have exactly half the period (or double the speed) of our normal Signals.

The primitives in this module can be used to produce or consume DDR signals.

DDR signals are not meant to be used internally in a design, but only to communicate with the outside world.

In some cases hardware specific DDR IN registers can be inferred by synthesis tools from these generic primitives. But to be sure your design will synthesize to dedicated hardware resources use the functions from Clash.Intel.DDR or Clash.Xilinx.DDR.

Synopsis

Documentation

ddrIn Source #

Arguments

:: forall a dom domDDR. HasCallStack 
=> NFDataX a 
=> KnownDomain dom 
=> KnownDomain domDDR 
=> DomainPeriod dom ~ (2 * DomainPeriod domDDR) 
=> Clock dom 
-> Reset dom 
-> Enable dom 
-> (a, a, a)

Reset values

-> Signal domDDR a

DDR input signal

-> Signal dom (a, a)

Normal speed output pair (o0, o1)

DDR input primitive

Consumes a DDR input signal and produces a regular signal containing a pair of values.

Data is clocked in on both edges of the clock signal. We can discern the active edge of the clock and the other edge. When the domain has the rising edge as the active edge (which is the most common), this means that the rising edge is the active edge and the falling edge is the other edge.

Of the output pair (o0, o1), o0 is the data clocked in on the other edge and o1 is the data clocked in on the active edge, and o0 comes before o1 in time. With a domain where the rising edge is the active edge, this means o0 is clocked in on the falling clock edge and o1 is clocked in on the rising clock edge. For a domain with the falling edge as the active edge, this is the other way around, but o0 still comes before o1 in time.

>>> sampleN 5 $ ddrIn @Int @System @DDR clockGen resetGen enableGen (-1,-2,-3) (fromList [0..10])
[(-1,-2),(-1,-2),(-3,2),(3,4),(5,6)]

ddrOut Source #

Arguments

:: forall a dom domDDR. HasCallStack 
=> NFDataX a 
=> KnownDomain dom 
=> KnownDomain domDDR 
=> DomainPeriod dom ~ (2 * DomainPeriod domDDR) 
=> Clock dom 
-> Reset dom 
-> Enable dom 
-> a

Reset value

-> Signal dom (a, a)

Normal speed input pair (i0, i1)

-> Signal domDDR a

DDR output signal

DDR output primitive

Produces a DDR output signal from a normal signal of pairs of input.

Data is clocked out on both edges of the clock signal. We can discern the active edge of the clock and the other edge. When the domain has the rising edge as the active edge (which is the most common), this means that the rising edge is the active edge and the falling edge is the other edge.

Of the input pair (i0, i1), i0 is the data clocked out on the active edge and i1 is the data clocked out on the other edge, and i0 comes before i1 in time. With a domain where the rising edge is the active edge, this means i0 is clocked out on the rising clock edge and i1 is clocked out on the falling clock edge. For a domain with the falling edge as the active edge, this is the other way around, but i0 still comes before i1 in time.

>>> sampleN 7 (ddrOut @Int @System @DDR clockGen resetGen enableGen (-1) (fromList [(0,1),(2,3),(4,5)]))
[-1,-1,-1,2,3,4,5]

ddrForwardClock Source #

Arguments

:: forall domDDR domOut domIn. KnownDomain domOut 
=> DomainPeriod domIn ~ DomainPeriod domOut 
=> DomainPeriod domIn ~ (2 * DomainPeriod domDDR) 
=> Clock domIn 
-> Reset domIn 
-> Enable domIn 
-> Maybe Bit

idle: Output value when Enable is deasserted

-> Maybe Bit

phase: Value to output at active edge of incoming clock

-> (Clock domIn -> Reset domIn -> Enable domIn -> Signal domIn (Bit, Bit) -> Signal domDDR Bit)

ddrOut primitive to use

-> Clock domOut 

Use a DDR output primitive to forward a clock to an output pin

This function allows outputting a clock signal on a DDR-capable output pin. As with the DDR output primitive itself, the created clock cannot be used internally in the design.

The ddrOut primitive passed in will always have its enable asserted. If the Enable input of ddrForwardClock is deasserted, the data inputs of the ddrOut primitive will switch to achieve the desired output signal. This is because the behavior of the enable input of the DDR primitive differs between vendor-specific primitives.

The Reset input of this function is passed on to the ddrOut primitive and not otherwise used by ddrForwardClock.

With the phase argument, the phase relation between input and output clock can be defined. With the argument Nothing, the clocks are in phase: the active edge of the output clock is on the active edge of the input clock, even if the domains differ on what the active edge is.

With the idle argument, the output level when the Enable input is deasserted can be defined. With Nothing, it will be 0 for a clock with the rising edge as the active edge, and 1 for a clock with the falling edge as the active edge.

NB: The deassertion of the Enable input or the assertion of the Reset input is not faithfully simulated in Haskell simulation: Haskell simulation of a Clash design has clocks that always run. The generated HDL will actually output an idle state when Enable is deasserted (and the reset depends on the ddrOut primitive used).

Internal

ddrIn# :: forall a dom domDDR. HasCallStack => NFDataX a => KnownDomain dom => KnownDomain domDDR => DomainPeriod dom ~ (2 * DomainPeriod domDDR) => Clock dom -> Reset dom -> Enable dom -> a -> a -> a -> Signal domDDR a -> Signal dom (a, a) Source #

ddrOut# :: forall a dom domDDR. HasCallStack => NFDataX a => KnownDomain dom => KnownDomain domDDR => DomainPeriod dom ~ (2 * DomainPeriod domDDR) => Clock dom -> Reset dom -> Enable dom -> a -> Signal dom a -> Signal dom a -> Signal domDDR a Source #

ddrForwardClock# :: KnownDomain domOut => DomainPeriod domIn ~ DomainPeriod domOut => DomainPeriod domIn ~ (2 * DomainPeriod domDDR) => Clock domIn -> Signal domDDR Bit -> Clock domOut Source #