--
You received this message because you are subscribed to the Google Groups "Clash - Hardware Description Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clash-languag...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clash-language/4e1deb0e-59da-474d-a14d-465fb87ff046n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clash-language/e507a832-943a-49cf-8bd4-1a2f0cb0155bn%40googlegroups.com.
The definition of `cnt` depends on itself:
cnt =
if (state == Valid && cnt == 0) || (cnt > 0
&& cnt < n) then cnt + 1
else (if cnt == n && out_ready == True then
0 else cnt_)
I.e., if we assume `state` equals `Valid` and we want to know what `cnt` is, we first need to know what `cnt` is - as we want to check whether it's equal to zero. This is a combinatorial loop - Clash will never insert memory elements implicitly. The simulation will therefore get stuck in an infinite loop try to evaluate `cnt`.
To view this discussion on the web visit https://groups.google.com/d/msgid/clash-language/CADsoAZoz%2Bmk8J0mo1cvYbjeCMhY88p4PC5FnHO81oXyONE3QUg%40mail.gmail.com.
Also, I see you're using the underlying representation of the various Hidden* constructs we've got. (This makes sense as this is unfortunately what is being shown in error messages.) You could replace:
KnownDomain dom,
GHC.Classes.IP (Clash.Signal.HiddenClockName dom) (Clock dom),
GHC.Classes.IP (Clash.Signal.HiddenEnableName dom) (Enable dom),
GHC.Classes.IP (Clash.Signal.HiddenResetName dom) (Reset dom)
with
HiddenClockResetEnable dom
To view this discussion on the web visit https://groups.google.com/d/msgid/clash-language/CADsoAZoz%2Bmk8J0mo1cvYbjeCMhY88p4PC5FnHO81oXyONE3QUg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clash-language/e88a05cb-9d47-44c5-5fd8-ab51e50203e0%40qbaylogic.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clash-language/f5dc8646-ce33-40a4-8af6-3b58ae5bf4cfn%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "Clash - Hardware Description Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clash-language/nhnc_dNOOxg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clash-languag...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clash-language/5eed4632-b527-4cd8-bdb9-d51e6a3c6fa9n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clash-language/CADsoAZon9atOgeKPDwXaNfELuEQO%2BMqaWNA0LROiBSrp1ATUMQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clash-language/a6f781f1-25c6-4f8f-985f-0d31908f21b5n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clash-language/c043370c-1b47-4a55-ae9c-c042ce958ff3n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clash-language/40526ccc-b368-4515-a998-634450d1853en%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Clash - Hardware Description Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clash-languag...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clash-language/CAJ7DA-_UjNwqJce_EE1iAkpzAV4hq1mJuRVmT2aODDhLmurRGg%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Clash - Hardware Description Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clash-languag...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clash-language/CAJ7DA-80yYOKhVAbHibRr5Pyx0Xx11oOPcbLsEd_-gK3LjerWA%40mail.gmail.com.
Hello Mahshid!
On Wed, 9 Jun 2021, Mahshid Shahmohammadian wrote:
Thank you all for the effort, I've got many ideas of what could have
been wrong with the second code (register with fold) and what other
options to consider!
You're welcome, I hope you'll like using Clash!
It occurred to me that I'm not listening to my own advice! :-) I'm using complicated syntax for register in plStage when I said that moore is much more readable.
This one is so much nicer and identical in function:
plStage f = moore (const (fmap f)) id Nothing
I hadn't mentioned that you can use Hoogle for Clash documentation as well:
https://hoogle.haskell.org/?hoogle=moore
It gives two results inside clash-prelude, one with explicit clock, reset and enable and one with implicit ones. I'm using the implicit one here.
And I thought that Google Groups destroyed the formatting of code for everyone, but it appears it only happens for plain text mails, it looks like people using HTML mails can properly format code. So I'll try to paste all my code below in a form that is not a pain to read.
The two variants from my first mail, as an example of "mealy style" and "Signal composition style" are:
variant1
:: HiddenClockResetEnable dom
=> Signal dom Bool
-> Signal dom (Unsigned 8)
-> (Signal dom Bool, Signal dom (Unsigned 8))
variant1 valid inp = mealyB transF (repeat False, 0, 0) (valid, inp)
where
transF
:: (Vec 2 Bool, Unsigned 8, Unsigned 8)
-> (Bool, Unsigned 8)
-> ( (Vec 2 Bool, Unsigned 8, Unsigned 8)
, (Bool, Unsigned 8))
transF (valids, d1, d2) (valid, inp) =
let valids0 = valid +>> valids
d1_0 = inp + 3
d2_0 = d1 `shiftL` 1
validO = last valids
in ((valids0, d1_0, d2_0), (validO, d2))
variant2
:: forall dom
. HiddenClockResetEnable dom
=> Signal dom Bool
-> Signal dom (Unsigned 8)
-> (Signal dom Bool, Signal dom (Unsigned 8))
variant2 valid inp = (validO, d2)
where
valids :: Signal dom (Vec 2 Bool)
valids = register (repeat False) (liftA2 (+>>) valid valids)
validO = last <$> valids
d1 = register 0 (inp + 3)
d2 = register 0 ((`shiftL` 1) <$> d1)
The variants of the pipeline from my second mail:
var2Trans
:: Num a
=> Vec 17 (Maybe a)
-> Maybe a
-> (Vec 17 (Maybe a), Maybe a)
var2Trans s i = (s', last s)
where
s' = i :> zipWith (flip (fmap . (+)))
(init s)
( 2 :> 3 :> 5 :> 7 :> 11 :> 13 :> 17 :> 19
:> 23 :> 29 :> 31 :> 37 :> 41 :> 43 :> 47 :> 53 :> Nil)
variant3
variant3_2 =
plStage (`xor` 32767)
. plStage (+ 5)
. plStage (`shiftL` 2)
. plStage (.&. 682)
. register Nothing
plStage
:: ( HiddenClockResetEnable dom
, NFDataX a
)
=> (a -> a)
-> Signal dom (Maybe a)
-> Signal dom (Maybe a)
plStage f = moore (const (fmap f)) id Nothing
--8<---------------cut here---------------end--------------->8---
I'd really like to improve the situation with needing about 15 lines of code just to do
let en0 = CEP.enable en ready
so I'm going to see if we can do something about that.
HTH,
Peter.
--
You received this message because you are subscribed to the Google Groups "Clash - Hardware Description Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clash-languag...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clash-language/alpine.DEB.2.21.2106091428490.4065%40terrence.lucas.digitalbrains.com.
Also, I could not find CEP.enable in Clash.Explicit.Prelude, I see
that you have: import qualified Clash.Explicit.Prelude as CEP
Can you point me to more documents to read about these implicit and
explicit Clock Reset Enable in Clash system? and when we should hide
and expose them?
Why do you think this should be linked to Enable and not Reset?
How can I tell CLash compiler to connect the reset signal used in my
function to the default reset port after VHDL generation?