1{-
2  SockeyeASTDecodingNet.hs: Decoding net AST for Sockeye
3
4  Part of Sockeye
5
6  Copyright (c) 2017, ETH Zurich.
7
8  All rights reserved.
9
10  This file is distributed under the terms in the attached LICENSE file.
11  If you do not find this file, copies can be found by writing to:
12  ETH Zurich D-INFK, CAB F.78, Universitaetstr. 6, CH-8092 Zurich,
13  Attn: Systems Group.
14-}
15
16module SockeyeASTDecodingNet where
17
18import Data.List (intercalate)
19import Data.Map (Map)
20
21type NetSpec = Map NodeId NodeSpec
22
23data NodeId = NodeId
24    { name      :: !String
25    , namespace :: [String]
26    } deriving (Eq, Ord)
27
28instance Show NodeId where
29    show (NodeId n ns) =
30        let noEmpty = filter ((> 0) . length) ns
31        in intercalate "." $ reverse (n:noEmpty)
32
33data NodeSpec = NodeSpec
34    { nodeType  :: NodeType
35    , accept    :: [BlockSpec]
36    , translate :: [MapSpec]
37    , reserved  :: [BlockSpec]
38    , overlay   :: Maybe OverlaySpec
39    } deriving (Show)
40
41data NodeType
42    = Core
43    | Device
44    | Memory
45    | Other
46    deriving (Show)
47
48data BlockSpec = BlockSpec
49    { base  :: Address
50    , limit :: Address
51    , props :: PropSpec
52    } deriving (Show)
53
54data PropSpec
55    = PropSpec
56      { identifiers :: [String] }
57    deriving(Show)
58
59data MapSpec = MapSpec
60    { srcBlock :: BlockSpec
61    , destNode :: NodeId
62    , destBase :: Address
63    , destProps :: PropSpec
64    } deriving (Show)
65
66data OverlaySpec
67    = OverlaySpec
68        { over  :: NodeId
69        , width :: !Integer
70        } deriving (Show)
71
72type Address = Integer
73