Last active
July 15, 2019 08:49
-
-
Save martijnbastiaan/e04450c8d0780598e3920b86e47f5632 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Pipeline where | |
import Clash.Prelude | |
(<@>) | |
:: ( HiddenClockResetEnable dom | |
, Undefined b | |
, Default b | |
) | |
=> (a -> b) | |
-> Signal dom a | |
-> Signal dom b | |
f <@> s = | |
register def (f <$> s) | |
infixr 9 <@> | |
in1 :: Signal dom Int | |
in1 = fromList [10..100] | |
added1 :: HiddenClockResetEnable dom => Signal dom Int | |
added1 = (+1) <@> in1 | |
multiplied1 :: HiddenClockResetEnable dom => Signal dom Int | |
multiplied1 = (*2) <@> added1 | |
in2 :: HiddenClockResetEnable dom => Signal dom Int | |
in2 = register 10 (in2 + 1) | |
added2 :: HiddenClockResetEnable dom => Signal dom Int | |
added2 = (+1) <@> in2 | |
multiplied2 :: HiddenClockResetEnable dom => Signal dom Int | |
multiplied2 = (*2) <@> added2 | |
{- | |
*Pipeline> sampleN @System 5 in1 | |
[10,11,12,13,14] | |
*Pipeline> sampleN @System 5 added1 | |
[0,0,12,13,14] | |
*Pipeline> sampleN @System 5 multiplied1 | |
[0,0,0,24,26] | |
*Pipeline> sampleN @System 5 in2 | |
[10,10,11,12,13] | |
*Pipeline> sampleN @System 5 added2 | |
[0,0,11,12,13] | |
*Pipeline> sampleN @System 5 multiplied2 | |
[0,0,0,22,24] | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment