diff --git a/bs/TagEngine.bs b/bs/TagEngine.bs index d168ed4..cb21845 100644 --- a/bs/TagEngine.bs +++ b/bs/TagEngine.bs @@ -1,10 +1,51 @@ package TagEngine() where +import Vector import Util +#define UIntLog2N(n) (UInt (TLog n)) + +data Tag a + = Next (UInt a) + | Empty + deriving (Bits, Eq, FShow) + +initTagNext :: Integer -> Module(Reg (Tag a)) +initTagNext i = do + t :: Reg (Tag a) + t <- mkReg (Next (fromInteger i)) + return t + +initTagEmpty :: Integer -> Module(Reg (Tag a)) +initTagEmpty i = do + t :: Reg (Tag a) + t <- mkReg Empty + return t + interface (TagEngine :: # -> *) numTags = - requestTag :: ActionValue (UInt (TLog numTags)) - retireTag :: UInt (TLog numTags) -> Action + requestTag :: ActionValue UIntLog2N(numTags) + retireTag :: UIntLog2N(numTags) -> Action + + +mkTagEngine :: Module (TagEngine numTags) +mkTagEngine = + do + let v :: Vector numTags Integer = genVector + -- placeholder + counter <- mkReg(0 :: UIntLog2N(numTags)) + return $ + interface TagEngine + requestTag :: ActionValue UIntLog2N(numTags) + requestTag = do + -- placeholder + counter := counter + 1 + return counter + retireTag :: UIntLog2N(numTags) -> Action + retireTag tag = do + -- placeholder + counter := 0 + where + a = "Hello" a :: Integer -a = 3 \ No newline at end of file +a = 3