diff --git a/bs/TagEngine.bs b/bs/TagEngine.bs index aceebc2..68b39fd 100644 --- a/bs/TagEngine.bs +++ b/bs/TagEngine.bs @@ -1,4 +1,4 @@ -package TagEngine() where +package TagEngine(TagEngine(..), mkTagEngine) where import Vector import Util @@ -10,6 +10,10 @@ data Tag numTags | Tail deriving (Bits, Eq, FShow) +interface (TagEngine :: # -> *) numTags = + requestTag :: ActionValue UIntLog2N(numTags) + retireTag :: UIntLog2N(numTags) -> Action + initTagNext :: Integer -> Module(Reg (Tag numTags)) initTagNext i = do t :: Reg (Tag numTags) @@ -22,11 +26,6 @@ initTagTail = do t <- mkReg Tail return t -interface (TagEngine :: # -> *) numTags = - requestTag :: ActionValue UIntLog2N(numTags) - retireTag :: UIntLog2N(numTags) -> Action - - initTagVec :: Module(Vector numTags (Reg (Tag numTags))) initTagVec = do @@ -44,6 +43,20 @@ mkTagEngine = tagVec :: Vector numTags (Reg (Tag numTags)) tagVec <- initTagVec + fileHandle :: Handle <- openFile "compile.log" WriteMode + + cycle <- mkReg 0 + end_cycle <- mkReg 4 + + addRules (simulate_for cycle end_cycle) + + addRules $ + rules + "display": when True ==> + do + $display (fshow (tagVec !! 0)) + $finish + counter <- mkReg(0 :: UIntLog2N(numTags)) return $ interface TagEngine @@ -56,9 +69,3 @@ mkTagEngine = retireTag tag = do -- placeholder counter := 0 - where - a = "Hello" - idx_last :: Integer = (fromInteger |> valueOf numTags) - 1 - -a :: Integer -a = 3 diff --git a/bs/Top.bs b/bs/Top.bs index efddd18..e361286 100644 --- a/bs/Top.bs +++ b/bs/Top.bs @@ -101,6 +101,7 @@ mkSim :: Module Empty mkSim = do let cfg :: BRAM_Configure = defaultValue + tagEngine :: TagEngine 5 <- mkTagEngine count :: Reg (UInt 3) <- mkReg 0; initCFunctions :: Reg Bool <- mkReg False; core :: Core FCLK <- mkCore; diff --git a/bs/Util.bs b/bs/Util.bs index 1057087..49ac04e 100644 --- a/bs/Util.bs +++ b/bs/Util.bs @@ -1,4 +1,15 @@ -package Util((|>)) where +package Util((|>), simulate_for) where (|>) :: (a -> b) -> a -> b -f |> x = f x; \ No newline at end of file +f |> x = f x; + +simulate_for :: (Bits a n, Arith a, Eq a) => Reg a -> Reg a -> Rules +simulate_for curr_cycle end_cycle = + rules + "count_cycle_rule": when True ==> action + curr_cycle := curr_cycle + 1 + if curr_cycle == end_cycle + then + $finish + else + $display "cycle = " curr_cycle \ No newline at end of file