reverting as it seems we really cant condition rules on arguments safely
This commit is contained in:
parent
996febbff5
commit
35fc49382d
|
@ -9,8 +9,7 @@ import Util
|
|||
|
||||
interface (TagEngine :: # -> *) numTags =
|
||||
requestTag :: ActionValue UIntLog2N(numTags)
|
||||
setTagToRetire :: UIntLog2N(numTags) -> Action
|
||||
retireTag :: Action
|
||||
retireTag :: UIntLog2N(numTags) -> Action
|
||||
|
||||
-- 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
|
||||
|
@ -30,9 +29,6 @@ mkTagEngine =
|
|||
stackPtr :: (Reg (Maybe(UIntLog2N(numTags))))
|
||||
stackPtr <- mkReg |> Just |> reifiedNumTags - 1
|
||||
|
||||
tagToRetire :: RWire (UIntLog2N(numTags))
|
||||
tagToRetire <- mkRWireSBR
|
||||
|
||||
debugOnce <- mkReg True
|
||||
|
||||
addRules $
|
||||
|
@ -60,27 +56,19 @@ mkTagEngine =
|
|||
when
|
||||
Just sampledStackPtr <- stackPtr
|
||||
|
||||
setTagToRetire :: UIntLog2N(numTags) -> Action
|
||||
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 =
|
||||
retireTag :: UIntLog2N(numTags) -> Action
|
||||
retireTag tag =
|
||||
do
|
||||
let nextStackPtrUint =
|
||||
let
|
||||
tagValid = tag < reifiedNumTags
|
||||
tagInUse = readReg (select inUseVec tag)
|
||||
nextStackPtrUint =
|
||||
case stackPtr of
|
||||
Nothing -> 0
|
||||
Just n -> n + 1
|
||||
|
||||
(select freeStackVec nextStackPtrUint) := tag
|
||||
stackPtr := Just nextStackPtrUint
|
||||
(select inUseVec tag) := False
|
||||
when
|
||||
Valid tag <- tagToRetire.wget
|
||||
if (tagValid && tagInUse)
|
||||
then do
|
||||
(select inUseVec tag) := False
|
||||
(select freeStackVec nextStackPtrUint) := tag
|
||||
stackPtr := Just nextStackPtrUint
|
||||
else action {}
|
||||
|
|
35
bs/Top.bs
35
bs/Top.bs
|
@ -8,6 +8,7 @@ import CBindings
|
|||
import Bus
|
||||
import TagEngine
|
||||
import List
|
||||
import ActionSeq
|
||||
|
||||
type FCLK = 25000000
|
||||
type BAUD = 9600
|
||||
|
@ -102,12 +103,44 @@ mkSim = do
|
|||
let cfg :: BRAM_Configure = defaultValue
|
||||
|
||||
tagEngine :: TagEngine 5 <- mkTagEngine
|
||||
count :: Reg (UInt 3) <- mkReg 0;
|
||||
count :: Reg (UInt 4) <- mkReg 0;
|
||||
initCFunctions :: Reg Bool <- mkReg False;
|
||||
core :: Core FCLK <- mkCore;
|
||||
|
||||
s :: ActionSeq
|
||||
s <- actionSeq
|
||||
$ do
|
||||
$display "got tag : " tagEngine.requestTag
|
||||
|> do
|
||||
$display "got tag : " tagEngine.requestTag
|
||||
|> do
|
||||
$display "got tag : " tagEngine.requestTag
|
||||
|> do
|
||||
$display "retiring tag : 3"
|
||||
tagEngine.retireTag 3
|
||||
|> do
|
||||
$display "got tag : " tagEngine.requestTag
|
||||
|> do
|
||||
$display "got tag : " tagEngine.requestTag
|
||||
|> do
|
||||
$display "retiring tag : 4"
|
||||
tagEngine.retireTag 4
|
||||
|> do
|
||||
$display "got tag : " tagEngine.requestTag
|
||||
|> do
|
||||
$display "got tag : " tagEngine.requestTag
|
||||
|> do
|
||||
$display "retiring tag : 1"
|
||||
tagEngine.retireTag 1
|
||||
|> do
|
||||
$display "got tag : " tagEngine.requestTag
|
||||
|
||||
addRules $
|
||||
rules
|
||||
"testIncrement": when (count < 10) ==>
|
||||
do
|
||||
count := count + 1
|
||||
s.start
|
||||
"initCFunctionsOnce": when not initCFunctions ==>
|
||||
do
|
||||
initTerminal
|
||||
|
|
Loading…
Reference in a new issue