1{-
2    SockeyeASTParser.hs: AST for the Sockeye parser
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 SockeyeASTParser
17( module SockeyeASTParser
18, module SockeyeASTTypeChecker
19) where
20
21import SockeyeASTTypeChecker
22    ( Identifier(SimpleIdent, TemplateIdent)
23    , prefix, varName, suffix
24    , ModuleParamType(NaturalParam, AddressParam)
25    , ModuleArg(NumericalArg, ParamArg)
26    , NodeSpec(NodeSpec)
27    , nodeType, accept, translate, reserved, overlay
28    , NodeType(Core, Device, Memory, Other)
29    , BlockSpec(SingletonBlock, RangeBlock, LengthBlock)
30    , PropSpec(PropSpec)
31    , base, limit, bits
32    , MapSpec(MapSpec)
33    , OverlaySpec(OverlaySpec)
34    , over, width
35    , block, destNode, destBase, destProps
36    , Address(LiteralAddress, ParamAddress)
37    , ForLimit(LiteralLimit, ParamLimit)
38    )
39
40data SockeyeSpec = SockeyeSpec
41    { imports :: [Import]
42    , modules :: [Module]
43    , net     :: [NetSpec]
44    } deriving (Show)
45
46data Import = Import
47    { filePath :: !FilePath }
48    deriving (Show)
49
50data Module = Module
51    { name       :: String
52    , parameters :: [ModuleParam]
53    , moduleBody :: ModuleBody
54    } deriving (Show)
55
56data ModuleParam = ModuleParam
57    { paramName :: !String
58    , paramType :: ModuleParamType
59    } deriving (Show)
60
61data ModuleBody = ModuleBody
62    { ports     :: [Port]
63    , moduleNet :: [NetSpec]
64    } deriving (Show)
65
66data NetSpec
67    = ModuleInstSpec ModuleInst
68    | NodeDeclSpec NodeDecl
69    deriving (Show)
70
71data Port
72    = InputPort
73        { portId    :: Identifier
74        , portWidth :: !Integer
75        }
76    | OutputPort
77        { portId    :: Identifier
78        , portWidth :: !Integer
79        }
80    | MultiPort (For Port)
81    deriving (Show)
82
83data ModuleInst
84    = ModuleInst
85        { moduleName   :: String
86        , namespace    :: Identifier
87        , arguments    :: [ModuleArg]
88        , portMappings :: [PortMap]
89        }
90    | MultiModuleInst (For ModuleInst)
91    deriving (Show)
92
93data PortMap
94    = InputPortMap
95        { mappedId   :: Identifier
96        , mappedPort :: Identifier
97        }
98    | OutputPortMap
99        { mappedId   :: Identifier
100        , mappedPort :: Identifier
101        }
102    | MultiPortMap (For PortMap)
103    deriving (Show)
104
105data NodeDecl
106    = NodeDecl
107        { nodeId   :: Identifier
108        , nodeSpec :: NodeSpec
109        }
110    | MultiNodeDecl (For NodeDecl)
111    deriving (Show)
112
113data For a
114    = For
115        { varRanges :: [ForVarRange]
116        , body      :: a
117        } deriving (Show)
118
119data ForVarRange
120    = ForVarRange
121    { var   :: !String
122    , start :: ForLimit
123    , end   :: ForLimit
124    } deriving (Show)
125