TageEngine now typechecks
This commit is contained in:
parent
a3afd66715
commit
4422947f9a
|
@ -1,10 +1,51 @@
|
||||||
package TagEngine() where
|
package TagEngine() where
|
||||||
|
|
||||||
|
import Vector
|
||||||
import Util
|
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 =
|
interface (TagEngine :: # -> *) numTags =
|
||||||
requestTag :: ActionValue (UInt (TLog numTags))
|
requestTag :: ActionValue UIntLog2N(numTags)
|
||||||
retireTag :: UInt (TLog numTags) -> Action
|
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 :: Integer
|
||||||
a = 3
|
a = 3
|
||||||
|
|
Loading…
Reference in a new issue