Skip to content
This repository has been archived by the owner on Sep 22, 2019. It is now read-only.

Commit

Permalink
Simplify the types of window/windowD
Browse files Browse the repository at this point in the history
Closes clash-lang#110.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
  • Loading branch information
thoughtpolice committed Sep 3, 2017
1 parent 25c8ecd commit a90d3d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
21 changes: 6 additions & 15 deletions src/CLaSH/Explicit/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,9 @@ window
=> Clock domain gated
-- ^ Clock to which the incoming signal is synchronized
-> Reset domain synchronous
-> Signal domain a -- ^ Signal to create a window over
-> Vec (n + 1) (Signal domain a) -- ^ Window of at least size 1
window clk rst x = res
where
res = x :> prev
prev = case natVal (asNatProxy prev) of
0 -> repeat def
_ -> let next = x +>> prev
in registerB clk rst (repeat def) next
-> Signal domain a -- ^ Signal to create a window over
-> Vec n (Signal domain a) -- ^ Window of at least size 1
window clk rst = iterateI (register clk rst def)
{-# INLINABLE window #-}

-- | Give a delayed window over a 'Signal'
Expand All @@ -208,10 +202,7 @@ windowD
=> Clock domain gated
-- ^ Clock to which the incoming signal is synchronized
-> Reset domain synchronous
-> Signal domain a -- ^ Signal to create a window over
-> Vec (n + 1) (Signal domain a) -- ^ Window of at least size 1
windowD clk rst x =
let prev = registerB clk rst (repeat def) next
next = x +>> prev
in prev
-> Signal domain a -- ^ Signal to create a window over
-> Vec n (Signal domain a) -- ^ Window of at least size 1
windowD clk rst = iterateI (register clk rst def) . register clk rst def
{-# INLINABLE windowD #-}
8 changes: 4 additions & 4 deletions src/CLaSH/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ It instead exports the identically named functions defined in terms of
-- ...
window
:: (KnownNat n, Default a, HasClockReset domain gated synchronous)
=> Signal domain a -- ^ Signal to create a window over
-> Vec (n + 1) (Signal domain a) -- ^ Window of at least size 1
=> Signal domain a -- ^ Signal to create a window over
-> Vec n (Signal domain a) -- ^ Window of at least size 1
window = E.window hasClock hasReset
{-# INLINE window #-}

Expand All @@ -211,7 +211,7 @@ window = E.window hasClock hasReset
-- ...
windowD
:: (KnownNat n, Default a, HasClockReset domain gated synchronous)
=> Signal domain a -- ^ Signal to create a window over
-> Vec (n + 1) (Signal domain a) -- ^ Window of at least size 1
=> Signal domain a -- ^ Signal to create a window over
-> Vec n (Signal domain a) -- ^ Window of at least size 1
windowD = E.windowD hasClock hasReset
{-# INLINE windowD #-}

0 comments on commit a90d3d6

Please sign in to comment.