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