fifo2 :: Fifo
{ 0, 1, 2 } --> fifo1.in
{ 0, 3, 4 } --> fifo2.in
- fifo1.out --> alu.inOp, alu.in1, alu.in2
- alu.out --> debug.in
+ fifo1.out --> alu.inOp, alu.in1, alu.in2
+ alu.out --> debug.in
;;
- fifo2.out --> alu.inOp, alu.in1, alu.in2
- alu.out --> debug.in
+ fifo2.out --> alu.inOp, alu.in1, alu.in2
+ alu.out --> debug.in
/*
double(a -> out) =
getInboxes :: Expr -> [Port]
getInboxes (Move 1 s d) = [d]
-getInboxes (Exprs d e) = getInboxes e
+getInboxes (Decl d e) = getInboxes e
getInboxes (Par e) = concatMap getInboxes e
getInboxes (Seq [a,b]) = getInboxes a
getInboxes _ = []
getOutboxes :: Expr -> [Port]
getOutboxes (Move 1 s d) = [s]
-getOutboxes (Exprs d e) = getOutboxes e
+getOutboxes (Decl d e) = getOutboxes e
getOutboxes (Par e) = concatMap getOutboxes e
getOutboxes (Seq [a,b]) = getOutboxes b
getOutboxes _ = []
compile (Literal 0 lit d) = [ ILiteral lit d, (accept d) {m_count=0} ]
compile (Literal 1 lit d) = [ ILiteral lit d, (accept d) ]
compile (Literal n lit d) = [ ILiteral lit d, (accept d) {m_count=n} ]
-compile (Exprs d e) = compile e
+compile (Decl d e) = compile e
compile (Seq [a,b]) = (compile a)++(bridge (getInboxes a) (uniq (getOutboxes b)))++(compile b)
compile (Par e) = concatMap compile e
compile (Move 1 s d) = [ (move s) { m_dest=(Just d) }, (accept d) ]
notifyInboxes = map (notify ib) ibs
waitForInboxNotifications = map wait ibs
-getdecls (Exprs d e) = map (\(Decl n t) -> ("#ship " ++ n ++ " : " ++ t)) d
+getdecls (Decl d e) = map (\(n,t) -> ("#ship " ++ n ++ " : " ++ t)) d
getdecls (Seq es) = concatMap getdecls es
getdecls (Par es) = concatMap getdecls es
getdecls _ = []
Def (fromTree name) (fromTree inp) (fromTree outp) (fromTree es)
fromTree (Tree "Def" q _) = error $ show q
+
-- Port ------------------------------------------------------------------------------
data Port = ShipPort String String
| IdPort String
-- Expr ------------------------------------------------------------------------------
-data Decl = Decl String String
- deriving (Show,Eq)
data Expr = Seq [Expr]
| Par [Expr]
- | Exprs [Decl] Expr
- | Move Int Port Port
- | Literal Int Int Port
+ | Decl [(String,String)] Expr
+ | Move Int Port Port
+ | Literal Int Int Port
| Nop
deriving (Show,Eq)
{-
show (Literal count i dest) = (show i) ++ " -["++(show count)++"]-> " ++ (show dest)
-}
-instance FromTree Decl where
- fromTree (Tree "::" [shipName,shipType] _) = Decl (fromTree shipName) (fromTree shipType)
-
instance FromTree Expr where
- fromTree (Tree "Exprs" [decls, sequents] _) = Exprs (fromTree decls) (seq $ map par $ fromTree sequents)
- where seq [] = Nop
+ fromTree (Tree "Exprs" [(Tree _ decls _), sequents] _) = Decl declist (seq $ map par $ fromTree sequents)
+ where
+ declist = map (\(Tree "::" [shipName,shipType] _) -> ((fromTree shipName), (fromTree shipType))) decls
+ seq [] = Nop
seq [x] = x
seq x = Seq x
par [] = Nop