1{-
2  SockeyeASTInstantiator.hs: AST with instantiated module templates 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, Universitaetstrasse 6, CH-8092 Zurich,
13  Attn: Systems Group.
14-}
15
16module SockeyeASTInstantiator
17    ( module SockeyeASTInstantiator
18    , module SockeyeASTDecodingNet
19    ) where
20
21import Data.Map (Map)
22
23import SockeyeASTDecodingNet
24    ( NodeType(Core, Device, Memory, Other)
25    , BlockSpec(BlockSpec)
26    , base, limit, props
27    , PropSpec(PropSpec)
28    , identifiers
29    , Address
30    )
31
32data SockeyeSpec = SockeyeSpec
33    { root :: ModuleInst
34    , modules :: Map Identifier Module
35    } deriving (Show)
36
37data Module = Module
38    { inputPorts   :: [Port]
39    , outputPorts  :: [Port]
40    , moduleInsts  :: [ModuleInst]
41    , nodeDecls    :: [NodeDecl]
42    } deriving (Show)
43
44data Port
45    = InputPort
46        { portId    :: Identifier
47        , portWidth :: !Integer
48        }
49    | OutputPort
50        { portId    :: Identifier
51        , portWidth :: !Integer
52        }
53    deriving (Show)
54
55data ModuleInst
56    = ModuleInst
57        { namespace  :: Maybe Identifier
58        , moduleName :: Identifier
59        , inPortMap  :: PortMap
60        , outPortMap :: PortMap
61        } deriving (Show)
62
63type PortMap = Map Identifier Identifier
64
65data NodeDecl
66    = NodeDecl
67        { nodeId   :: Identifier
68        , nodeSpec :: NodeSpec
69        } deriving (Show)
70
71type Identifier = String
72
73data NodeSpec = NodeSpec
74    { nodeType  :: NodeType
75    , accept    :: [BlockSpec]
76    , translate :: [MapSpec]
77    , reserved  :: [BlockSpec]
78    , overlay   :: Maybe OverlaySpec
79    } deriving (Show)
80
81data MapSpec
82    = MapSpec
83        { srcBlock :: BlockSpec
84        , destNode :: !Identifier
85        , destBase :: !Address
86        , destProps :: PropSpec
87        } deriving (Show)
88
89data OverlaySpec
90    = OverlaySpec
91        { over  :: !Identifier
92        , width :: !Integer
93        } deriving (Show)
94