On 15/08/18 10:35, Anmol Sahoo wrote:
> The other option would be to manually
> maintain state inside the module and update the state based on the
> number of clock cycles that have ellapsed, to meet the required
> frequency. I'm not really sure how this would work out, thus would like
> some directions.
This is what I wrote in CλaSH v0.3.3 (really ancient) to implement an
UART. Well, the clock scaling was for many more purposes as well. I
ported it to CλaSH v0.7, I don't have a version for v0.99 yet.
See the gist: [1]
To instantiate an UART, use, f.e.:
--8<---------------cut here---------------start------------->8---
tTick = mealy $(CS.staticAvgRate fClk 115200) 1 sCmd
(sCmd, txDone, txd) = Serial.output (tTick, txiV, txi)
rTick = mealy $(CS.staticAvgRate fClk (16*115200)) 1 (pure CS.Run)
(rxoF, rxoV) = Serial.input (rTick, rxd)
--8<---------------cut here---------------end--------------->8---
txd, rxd are the pins on the FPGA (add synchronization on rxd). txi byte
to send when txiV True. When rxoV is True, rxoF is received data (see
documentation).
HTH,
Peter.
[1] <https://gist.github.com/DigitalBrains1/f428e3edf5043723f8f3f0705e637a32>
--
I use the GNU Privacy Guard (GnuPG) in combination with Enigmail.
You can send me encrypted mail if you want some privacy.
My key is available at <http://digitalbrains.com/2012/openpgp-key-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.
For more options, visit https://groups.google.com/d/optout.
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/c2bf0cf6-0834-4974-b3de-40e37c2ed6ccn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clash-language/c937ca12-dd5b-4d91-af7d-44f18c0c303dn%40googlegroups.com.