Last active
April 13, 2018 17:20
-
-
Save cemerick/bf64daf795823e0289c689af4386317c to your computer and use it in GitHub Desktop.
This file contains 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
data Validity = Invalid | Valid deriving (Eq, Show, Generic, NFData) | |
data Readiness = NotReady | Ready deriving (Eq, Show, Generic, NFData) | |
asValid x = if x then Valid else Invalid | |
asReady x = if x then Ready else NotReady | |
data DFIO a = DFIO { valid :: Validity, ready :: Readiness, val :: a } deriving (Eq, Show, Generic, NFData) | |
dfio iV oR dat = DFIO (asValid iV) (asReady oR) dat | |
pending placeholder = DFIO Invalid NotReady placeholder | |
done result = DFIO Valid Ready result | |
isValid DFIO{..} = valid == Valid | |
isReady DFIO{..} = ready == Ready | |
mealyDF' :: HiddenClockReset dom gated sync | |
=> (s -> DFIO i -> (s, DFIO o)) | |
-> s | |
-> DataFlow dom Bool Bool i o | |
mealyDF' f s = liftDF (\i iV oR -> let dfo = mealy f s $ dfio <$> iV <*> oR <*> i | |
in (fmap val dfo, fmap isValid dfo, fmap isReady dfo)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment