riscv-bluespec-classic/bs/Core.bs
Yehowshua Immanuel 5efef8b19c quieter builds, more type uniformity, full compiles
- made builds less verbose on Mac by removing `-cpp`
 - made type constructors for most instances of `(UInt (TLog n))`
 - addressed cases where types built upon `(UInt (TLog n))` may have
   a max value of `n`, which necessitates changing the type to
   ` (UInt (TLog (TAdd 1 n)))`
 - compiler wouldn't fully evaluate types unless mkBus was
   instantiated
2025-04-10 20:46:53 -04:00

40 lines
1,012 B
Haskell

package Core(Core(..), mkCore) where
import ClkDivider
import Prelude
interface (Core :: # -> *) clkFreq = {
getChar :: Bit 8
;getLed :: Bit 8
;putChar :: Bit 8 -> Action
}
mkCore :: Module (Core clkFreq)
mkCore = do
counter :: Reg (MkClkDivType clkFreq) <- mkReg 0
tickSecond :: Wire Bool <- mkDWire False
uartOut :: Wire (Bit 8) <- mkWire;
ledOut :: Reg (Bit 8) <- mkReg 0
let clkFreqInt :: Integer = valueOf clkFreq
let clkFreqUInt :: (MkClkDivType clkFreq) = fromInteger clkFreqInt
let val :: Real = fromInteger clkFreqInt
messageM $ "mkCore clkFreq" + realToString val
let pulseEverySecond :: Bool = (counter == clkFreqUInt)
addRules $
rules
"count" : when True ==>
counter := if (counter == clkFreqUInt) then 0 else (counter + 1)
"countingLed" : when pulseEverySecond ==>
ledOut := ledOut + 1
return $
interface Core
getChar = uartOut
getLed = ledOut
putChar byteIn =
do
uartOut := byteIn