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

3 wrap existing clashcores uart transmit in packetstream protocol :) #41

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clash-eth.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ library
Clash.Cores.Ethernet.RGMII
Clash.Cores.Ethernet.PacketStream
Clash.Lattice.ECP5.Prims
Clash.Lattice.ECP5.UART
Clash.Lattice.ECP5.Colorlight.CRG
default-language: Haskell2010
build-depends:
Expand Down
31 changes: 31 additions & 0 deletions src/Clash/Lattice/ECP5/UART.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{-#language FlexibleContexts #-}

module Clash.Lattice.ECP5.UART
(uartTxC) where

import Data.Maybe

import Clash.Prelude
import Clash.Cores.Ethernet.PacketStream
import Clash.Cores.UART
import Protocols
import Protocols.Internal


convertToTx :: Signal dom (Maybe (PacketStreamM2S 1 ())) -> Signal dom (Maybe (BitVector 8))
convertToTx = fmap $ fmap $ (head . _data)

uartTxC
:: forall (dom :: Domain)
(baud :: Nat)
. HiddenClockResetEnable dom
=> ValidBaud dom baud
=> SNat baud
-- ^ The UART baud
-> Circuit (PacketStream dom 1 ()) (CSignal dom Bit)
-- ^ This component receives a PacketStream and converts it to the UART transmitter input while relaying backpressure from the UART
uartTxC baud = fromSignals ckt
t-wallet marked this conversation as resolved.
Show resolved Hide resolved
where
ckt (fwd, _) = (PacketStreamS2M <$> ack, CSignal txBit)
where
(txBit, ack) = uartTx baud (convertToTx fwd)
Loading