change interface
This commit is contained in:
parent
e6b002f70e
commit
996febbff5
|
@ -9,7 +9,8 @@ import Util
|
||||||
|
|
||||||
interface (TagEngine :: # -> *) numTags =
|
interface (TagEngine :: # -> *) numTags =
|
||||||
requestTag :: ActionValue UIntLog2N(numTags)
|
requestTag :: ActionValue UIntLog2N(numTags)
|
||||||
retireTag :: UIntLog2N(numTags) -> Action
|
setTagToRetire :: UIntLog2N(numTags) -> Action
|
||||||
|
retireTag :: Action
|
||||||
|
|
||||||
-- The tag engine returns a tag that is unique for the duration of
|
-- The tag engine returns a tag that is unique for the duration of
|
||||||
-- the lifetime of the tag. Useful when you need to tag transactions
|
-- the lifetime of the tag. Useful when you need to tag transactions
|
||||||
|
@ -29,6 +30,9 @@ mkTagEngine =
|
||||||
stackPtr :: (Reg (Maybe(UIntLog2N(numTags))))
|
stackPtr :: (Reg (Maybe(UIntLog2N(numTags))))
|
||||||
stackPtr <- mkReg |> Just |> reifiedNumTags - 1
|
stackPtr <- mkReg |> Just |> reifiedNumTags - 1
|
||||||
|
|
||||||
|
tagToRetire :: RWire (UIntLog2N(numTags))
|
||||||
|
tagToRetire <- mkRWireSBR
|
||||||
|
|
||||||
debugOnce <- mkReg True
|
debugOnce <- mkReg True
|
||||||
|
|
||||||
addRules $
|
addRules $
|
||||||
|
@ -47,7 +51,7 @@ mkTagEngine =
|
||||||
requestTag :: ActionValue UIntLog2N(numTags)
|
requestTag :: ActionValue UIntLog2N(numTags)
|
||||||
requestTag =
|
requestTag =
|
||||||
do
|
do
|
||||||
stackPtr :=
|
stackPtr :=
|
||||||
if sampledStackPtr == 0
|
if sampledStackPtr == 0
|
||||||
then Nothing
|
then Nothing
|
||||||
else Just |> sampledStackPtr - 1
|
else Just |> sampledStackPtr - 1
|
||||||
|
@ -56,16 +60,27 @@ mkTagEngine =
|
||||||
when
|
when
|
||||||
Just sampledStackPtr <- stackPtr
|
Just sampledStackPtr <- stackPtr
|
||||||
|
|
||||||
retireTag :: UIntLog2N(numTags) -> Action
|
setTagToRetire :: UIntLog2N(numTags) -> Action
|
||||||
retireTag tag =
|
setTagToRetire tag =
|
||||||
|
let
|
||||||
|
tagValid = tag < (reifiedNumTags - 1)
|
||||||
|
tagInUse = readReg (select inUseVec tag)
|
||||||
|
in
|
||||||
|
do
|
||||||
|
if (tagValid && tagInUse)
|
||||||
|
then do tagToRetire.wset tag
|
||||||
|
else do action {}
|
||||||
|
|
||||||
|
retireTag :: Action
|
||||||
|
retireTag =
|
||||||
do
|
do
|
||||||
let nextStackPtrUint =
|
let nextStackPtrUint =
|
||||||
case stackPtr of
|
case stackPtr of
|
||||||
Nothing -> 0
|
Nothing -> 0
|
||||||
Just n -> n + 1
|
Just n -> n + 1
|
||||||
(select inUseVec tag) := False
|
|
||||||
(select freeStackVec nextStackPtrUint) := tag
|
(select freeStackVec nextStackPtrUint) := tag
|
||||||
stackPtr := Just nextStackPtrUint
|
stackPtr := Just nextStackPtrUint
|
||||||
-- when
|
(select inUseVec tag) := False
|
||||||
-- tag < (reifiedNumTags - 1),
|
when
|
||||||
-- readReg (select inUseVec tag)
|
Valid tag <- tagToRetire.wget
|
||||||
|
|
Loading…
Reference in a new issue