beginning of a linked list in hardware
This commit is contained in:
parent
7ad812d3da
commit
8e27ca877f
|
@ -9,9 +9,15 @@ import Util
|
||||||
|
|
||||||
data Tag numTags
|
data Tag numTags
|
||||||
= Next UIntLog2N(numTags)
|
= Next UIntLog2N(numTags)
|
||||||
|
| Freed
|
||||||
| Tail
|
| Tail
|
||||||
deriving (Bits, Eq, FShow)
|
deriving (Bits, Eq, FShow)
|
||||||
|
|
||||||
|
data TagPtr numTags
|
||||||
|
= SomeTagPtr UIntLog2N(numTags)
|
||||||
|
| None
|
||||||
|
deriving (Bits, Eq, FShow)
|
||||||
|
|
||||||
interface (TagEngine :: # -> *) numTags =
|
interface (TagEngine :: # -> *) numTags =
|
||||||
requestTag :: ActionValue UIntLog2N(numTags)
|
requestTag :: ActionValue UIntLog2N(numTags)
|
||||||
retireTag :: UIntLog2N(numTags) -> Action
|
retireTag :: UIntLog2N(numTags) -> Action
|
||||||
|
@ -32,10 +38,10 @@ initTagTail = do
|
||||||
return t
|
return t
|
||||||
|
|
||||||
initTagVec :: Module(Vector numTags (Reg (Tag numTags)))
|
initTagVec :: Module(Vector numTags (Reg (Tag numTags)))
|
||||||
initTagVec =
|
initTagVec =
|
||||||
let
|
let
|
||||||
lastIdx :: Integer = (fromInteger |> valueOf numTags) - 1
|
lastIdx :: Integer = (fromInteger |> valueOf numTags) - 1
|
||||||
initByIdx currIdx =
|
initByIdx currIdx =
|
||||||
if (currIdx < lastIdx)
|
if (currIdx < lastIdx)
|
||||||
then initTagNext (currIdx + 1)
|
then initTagNext (currIdx + 1)
|
||||||
else initTagTail
|
else initTagTail
|
||||||
|
@ -48,6 +54,9 @@ mkTagEngine =
|
||||||
tagVec :: Vector numTags (Reg (Tag numTags))
|
tagVec :: Vector numTags (Reg (Tag numTags))
|
||||||
tagVec <- initTagVec
|
tagVec <- initTagVec
|
||||||
|
|
||||||
|
head :: Reg(TagPtr(numTags)) <- mkReg(SomeTagPtr(0))
|
||||||
|
tail :: Reg(TagPtr(numTags)) <- mkReg(SomeTagPtr(lastIdx))
|
||||||
|
|
||||||
debugOnce <- mkReg True
|
debugOnce <- mkReg True
|
||||||
|
|
||||||
addRules $
|
addRules $
|
||||||
|
@ -61,11 +70,28 @@ mkTagEngine =
|
||||||
return $
|
return $
|
||||||
interface TagEngine
|
interface TagEngine
|
||||||
requestTag :: ActionValue UIntLog2N(numTags)
|
requestTag :: ActionValue UIntLog2N(numTags)
|
||||||
requestTag = do
|
requestTag =
|
||||||
-- placeholder
|
do
|
||||||
counter := counter + 1
|
let currHeadPtr :: UIntLog2N(numTags) =
|
||||||
return counter
|
case head of
|
||||||
|
SomeTagPtr ptr -> ptr
|
||||||
|
-- we technically will never hit this arm
|
||||||
|
-- due to when guard `SomeTagPtr ptr <- head`
|
||||||
|
None -> 0
|
||||||
|
let currHead :: (Reg (Tag numTags)) = (select tagVec currHeadPtr)
|
||||||
|
let nextHeadPtr :: UIntLog2N(numTags) =
|
||||||
|
case currHead of
|
||||||
|
Next ptr -> ptr
|
||||||
|
-- TODO : handle tail correctly
|
||||||
|
Tail -> 0
|
||||||
|
currHead := Freed
|
||||||
|
head := SomeTagPtr(nextHeadPtr)
|
||||||
|
return nextHeadPtr
|
||||||
|
when
|
||||||
|
SomeTagPtr ptr <- head
|
||||||
retireTag :: UIntLog2N(numTags) -> Action
|
retireTag :: UIntLog2N(numTags) -> Action
|
||||||
retireTag tag = do
|
retireTag tag = do
|
||||||
-- placeholder
|
-- placeholder
|
||||||
counter := 0
|
counter := 0
|
||||||
|
where
|
||||||
|
lastIdx :: UIntLog2N(numTags) = (fromInteger |> valueOf numTags) - 1
|
||||||
|
|
Loading…
Reference in a new issue