TageEngine now typechecks

This commit is contained in:
Yehowshua Immanuel 2025-03-19 22:10:14 -04:00
parent a3afd66715
commit 4422947f9a

View file

@ -1,10 +1,51 @@
package TagEngine() where
import Vector
import Util
#define UIntLog2N(n) (UInt (TLog n))
data Tag a
= Next (UInt a)
| Empty
deriving (Bits, Eq, FShow)
initTagNext :: Integer -> Module(Reg (Tag a))
initTagNext i = do
t :: Reg (Tag a)
t <- mkReg (Next (fromInteger i))
return t
initTagEmpty :: Integer -> Module(Reg (Tag a))
initTagEmpty i = do
t :: Reg (Tag a)
t <- mkReg Empty
return t
interface (TagEngine :: # -> *) numTags =
requestTag :: ActionValue (UInt (TLog numTags))
retireTag :: UInt (TLog numTags) -> Action
requestTag :: ActionValue UIntLog2N(numTags)
retireTag :: UIntLog2N(numTags) -> Action
mkTagEngine :: Module (TagEngine numTags)
mkTagEngine =
do
let v :: Vector numTags Integer = genVector
-- placeholder
counter <- mkReg(0 :: UIntLog2N(numTags))
return $
interface TagEngine
requestTag :: ActionValue UIntLog2N(numTags)
requestTag = do
-- placeholder
counter := counter + 1
return counter
retireTag :: UIntLog2N(numTags) -> Action
retireTag tag = do
-- placeholder
counter := 0
where
a = "Hello"
a :: Integer
a = 3
a = 3