kansas-lava-cores- FPGA Cores Written in Kansas Lava.

Safe HaskellNone



The Clock module provides a utility function for simulating clock rate downsampling.



rate :: forall x clk. (Clock clk, Size x) => Witness x -> Rational -> Signal clk Bool Source

rate constructs a stream of enable bits used for clock-rate downsampling. For example, with a rate of n=1/2, every other value in the output stream will be True. If 1/n is not a integer, then the function uses http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm to approximate the given rate.

powerOfTwoRate :: forall x clk. (Clock clk, Size x) => Witness x -> Signal clk Bool Source

powerOfTwoRate generates a pulse every 2^n cycles, which is often good enough for polling, timeouts, etc.

rateP :: forall c sig. (Clock c, sig ~ Signal c) => sig Bool -> Patch () (sig (Enabled ())) () (sig Ack) Source

rateP takes a result from rate, and generates token, one per pulse, with unused tokens being discared.

throttleP :: forall sig c a x. (sig ~ Signal c, Clock c, Rep a) => sig Bool -> Patch (sig (Enabled a)) (sig (Enabled a)) (sig Ack) (sig Ack) Source

throttleP throttles input based on a given rate counter.