tag types and moodularity improving
This commit is contained in:
parent
4422947f9a
commit
6359ab833d
|
@ -5,21 +5,21 @@ import Util
|
|||
|
||||
#define UIntLog2N(n) (UInt (TLog n))
|
||||
|
||||
data Tag a
|
||||
= Next (UInt a)
|
||||
| Empty
|
||||
data Tag numTags
|
||||
= Next UIntLog2N(numTags)
|
||||
| Tail
|
||||
deriving (Bits, Eq, FShow)
|
||||
|
||||
initTagNext :: Integer -> Module(Reg (Tag a))
|
||||
initTagNext :: Integer -> Module(Reg (Tag numTags))
|
||||
initTagNext i = do
|
||||
t :: Reg (Tag a)
|
||||
t :: Reg (Tag numTags)
|
||||
t <- mkReg (Next (fromInteger i))
|
||||
return t
|
||||
|
||||
initTagEmpty :: Integer -> Module(Reg (Tag a))
|
||||
initTagEmpty i = do
|
||||
t :: Reg (Tag a)
|
||||
t <- mkReg Empty
|
||||
initTagTail :: Module(Reg (Tag numTags))
|
||||
initTagTail = do
|
||||
t :: Reg (Tag numTags)
|
||||
t <- mkReg Tail
|
||||
return t
|
||||
|
||||
interface (TagEngine :: # -> *) numTags =
|
||||
|
@ -27,11 +27,23 @@ interface (TagEngine :: # -> *) numTags =
|
|||
retireTag :: UIntLog2N(numTags) -> Action
|
||||
|
||||
|
||||
initTagVec :: Module(Vector numTags (Reg (Tag numTags)))
|
||||
initTagVec =
|
||||
do
|
||||
tagVecSequential :: Vector numTags (Reg (Tag numTags))
|
||||
tagVecSequential <- mapM (\idx -> initTagNext (idx+1)) genVector
|
||||
let idxLast :: Integer = (fromInteger |> valueOf numTags) - 1
|
||||
tailTag <- initTagTail
|
||||
-- the tail of our TagVec should be `Tail` not `Next`
|
||||
let finalTagVec = update tagVecSequential idxLast tailTag
|
||||
return finalTagVec
|
||||
|
||||
mkTagEngine :: Module (TagEngine numTags)
|
||||
mkTagEngine =
|
||||
do
|
||||
let v :: Vector numTags Integer = genVector
|
||||
-- placeholder
|
||||
tagVec :: Vector numTags (Reg (Tag numTags))
|
||||
tagVec <- initTagVec
|
||||
|
||||
counter <- mkReg(0 :: UIntLog2N(numTags))
|
||||
return $
|
||||
interface TagEngine
|
||||
|
@ -46,6 +58,7 @@ mkTagEngine =
|
|||
counter := 0
|
||||
where
|
||||
a = "Hello"
|
||||
idx_last :: Integer = (fromInteger |> valueOf numTags) - 1
|
||||
|
||||
a :: Integer
|
||||
a = 3
|
||||
|
|
Loading…
Reference in a new issue