converted to bluespec haskell
This commit is contained in:
parent
72788b8436
commit
cf68a5e683
17 changed files with 342 additions and 339 deletions
76
bs/Top.bs
Normal file
76
bs/Top.bs
Normal file
|
@ -0,0 +1,76 @@
|
|||
package Top(mkTop, ITop(..)) where
|
||||
|
||||
import Deserializer
|
||||
import Core
|
||||
import Serializer
|
||||
import BRAM
|
||||
import CBindings
|
||||
|
||||
type FCLK = 25000000
|
||||
type BAUD = 9600
|
||||
|
||||
interface ITop = {
|
||||
ftdi_rxd :: Bit 1 {-# always_ready #-}
|
||||
;led :: Bit 8 {-# always_ready #-}
|
||||
;ftdi_txd :: Bit 1 -> Action {-# always_ready , always_enabled #-}
|
||||
};
|
||||
|
||||
mkTop :: Module ITop
|
||||
mkTop = do
|
||||
fileHandle :: Handle <- openFile "compile.log" WriteMode
|
||||
deserializer :: IDeserializer FCLK BAUD <- mkDeserialize fileHandle
|
||||
serializer :: ISerializer FCLK BAUD <- mkSerialize fileHandle
|
||||
core :: Core FCLK <- mkCore
|
||||
persistLed :: Reg (Bit 8) <- mkReg 0
|
||||
messageM $ "Hallo!!" + (realToString 5)
|
||||
|
||||
-- refactor such that the following rules are let-bound to
|
||||
-- `attachIO` identifier
|
||||
addRules $
|
||||
rules
|
||||
"coreLedO" : when True ==>
|
||||
persistLed := core.getLed
|
||||
|
||||
"coreCharDeviceO" : when True ==>
|
||||
serializer.putBit8 core.getChar
|
||||
|
||||
"coreCharDeviceO" : when True ==>
|
||||
serializer.putBit8 core.getChar
|
||||
|
||||
"coreCharDeviceI" : when True ==>
|
||||
core.putChar deserializer.get
|
||||
|
||||
return $
|
||||
interface ITop
|
||||
ftdi_rxd = serializer.bitLineOut
|
||||
ftdi_txd bitIn =
|
||||
do
|
||||
deserializer.putBitIn bitIn
|
||||
led = persistLed
|
||||
|
||||
mkSim :: Module Empty
|
||||
mkSim = do
|
||||
let cfg :: BRAM_Configure = defaultValue
|
||||
|
||||
count :: Reg (UInt 3) <- mkReg 0;
|
||||
initCFunctions :: Reg Bool <- mkReg False;
|
||||
core :: Core FCLK <- mkCore;
|
||||
|
||||
addRules $
|
||||
rules
|
||||
"initCFunctionsOnce": when not initCFunctions ==>
|
||||
do
|
||||
initTerminal
|
||||
setupSigintHandler
|
||||
initCFunctions := True
|
||||
"coreCharDeviceO": when True ==>
|
||||
do
|
||||
writeCharToTerminal core.getChar
|
||||
"coreCharDeviceI": when (isCharAvailable == 1) ==>
|
||||
do
|
||||
core.putChar getCharFromTerminal
|
||||
"endSim": when wasCtrlCReceived ==>
|
||||
do
|
||||
restoreTerminal
|
||||
$display "GOT CTRL+C"
|
||||
$finish
|
Reference in a new issue