23ac95d5e12c725e65e4502ac50763479489a5cf
[matthijs/master-project/cλash.git] / clash / CLasH / VHDL / Constants.hs
1 module CLasH.VHDL.Constants where
2
3 -- VHDL Imports  
4 import qualified Language.VHDL.AST as AST
5
6 -- | A list of all builtin functions. Partly duplicates the name table
7 -- in VHDL.Generate, but we can't use that map everywhere due to
8 -- circular dependencie.
9 builtinIds = [ exId, replaceId, headId, lastId, tailId, initId, takeId, dropId
10              , selId, plusgtId, ltplusId, plusplusId, mapId, zipWithId, foldlId
11              , foldrId, zipId, unzipId, shiftlId, shiftrId, rotlId, rotrId
12              , concatId, reverseId, iteratenId, iterateId, generatenId, generateId
13              , emptyId, singletonId, copynId, copyId, lengthTId, nullId
14              , hwxorId, hwandId, hworId, hwnotId, equalityId, inEqualityId, ltId
15              , lteqId, gtId, gteqId, boolOrId, boolAndId, plusId, timesId
16              , negateId, minusId, fromSizedWordId, fromIntegerId, resizeWordId
17              , resizeIntId, sizedIntId, smallIntegerId, fstId, sndId, blockRAMId
18              , splitId, minimumId, fromRangedWordId 
19              ]
20 --------------
21 -- Identifiers
22 --------------
23
24 -- | reset and clock signal identifiers in String form
25 resetStr, clockStr :: String
26 resetStr = "resetn"
27 clockStr = "clock"
28
29 -- | reset and clock signal identifiers in basic AST.VHDLId form
30 resetId, clockId :: AST.VHDLId
31 resetId = AST.unsafeVHDLBasicId resetStr
32 clockId = AST.unsafeVHDLBasicId clockStr
33
34 integerId :: AST.VHDLId
35 integerId = AST.unsafeVHDLBasicId "integer"
36
37 -- | \"types\" identifier
38 typesId :: AST.VHDLId
39 typesId = AST.unsafeVHDLBasicId "types"
40
41 -- | work identifier
42 workId :: AST.VHDLId
43 workId = AST.unsafeVHDLBasicId "work"
44
45 -- | std identifier
46 stdId :: AST.VHDLId
47 stdId = AST.unsafeVHDLBasicId "std"
48
49
50 -- | textio identifier
51 textioId :: AST.VHDLId
52 textioId = AST.unsafeVHDLBasicId "textio"
53
54 -- | range attribute identifier
55 rangeId :: AST.VHDLId
56 rangeId = AST.unsafeVHDLBasicId "range"
57
58
59 -- | high attribute identifier
60 highId :: AST.VHDLId
61 highId = AST.unsafeVHDLBasicId "high"
62
63 -- | range attribute identifier
64 imageId :: AST.VHDLId
65 imageId = AST.unsafeVHDLBasicId "image"
66
67 -- | event attribute identifie
68 eventId :: AST.VHDLId
69 eventId = AST.unsafeVHDLBasicId "event"
70
71
72 -- | default function identifier
73 defaultId :: AST.VHDLId
74 defaultId = AST.unsafeVHDLBasicId "default"
75
76 -- FSVec function identifiers
77
78 -- | ex (operator ! in original Haskell source) function identifier
79 exId :: String
80 exId = "!"
81
82 -- | sel (function select in original Haskell source) function identifier
83 selId :: String
84 selId = "select"
85
86
87 -- | ltplus (function (<+) in original Haskell source) function identifier
88 ltplusId :: String
89 ltplusId = "<+"
90
91
92 -- | plusplus (function (++) in original Haskell source) function identifier
93 plusplusId :: String
94 plusplusId = "++"
95
96
97 -- | empty function identifier
98 emptyId :: String
99 emptyId = "empty"
100
101 -- | plusgt (function (+>) in original Haskell source) function identifier
102 plusgtId :: String
103 plusgtId = "+>"
104
105 -- | singleton function identifier
106 singletonId :: String
107 singletonId = "singleton"
108
109 -- | length function identifier
110 lengthId :: String
111 lengthId = "length"
112
113
114 -- | isnull (function null in original Haskell source) function identifier
115 nullId :: String
116 nullId = "null"
117
118
119 -- | replace function identifier
120 replaceId :: String
121 replaceId = "replace"
122
123
124 -- | head function identifier
125 headId :: String
126 headId = "head"
127
128
129 -- | last function identifier
130 lastId :: String
131 lastId = "last"
132
133
134 -- | init function identifier
135 initId :: String
136 initId = "init"
137
138
139 -- | tail function identifier
140 tailId :: String
141 tailId = "tail"
142
143 -- | minimum ftp function identifier
144 minimumId :: String
145 minimumId = "minimum"
146
147 -- | take function identifier
148 takeId :: String
149 takeId = "take"
150
151
152 -- | drop function identifier
153 dropId :: String
154 dropId = "drop"
155
156 -- | shiftl function identifier
157 shiftlId :: String
158 shiftlId = "shiftIntoL"
159
160 -- | shiftr function identifier
161 shiftrId :: String
162 shiftrId = "shiftIntoR"
163
164 -- | rotl function identifier
165 rotlId :: String
166 rotlId = "rotl"
167
168 -- | reverse function identifier
169 rotrId :: String
170 rotrId = "rotr"
171
172 -- | concatenate the vectors in a vector
173 concatId :: String
174 concatId = "concat"
175
176 -- | reverse function identifier
177 reverseId :: String
178 reverseId = "reverse"
179
180 -- | iterate function identifier
181 iterateId :: String
182 iterateId = "iterate"
183
184 -- | iteraten function identifier
185 iteratenId :: String
186 iteratenId = "iteraten"
187
188 -- | iterate function identifier
189 generateId :: String
190 generateId = "generate"
191
192 -- | iteraten function identifier
193 generatenId :: String
194 generatenId = "generaten"
195
196 -- | copy function identifier
197 copyId :: String
198 copyId = "copy"
199
200 -- | copyn function identifier
201 copynId :: String
202 copynId = "copyn"
203
204 -- | map function identifier
205 mapId :: String
206 mapId = "map"
207
208 -- | zipwith function identifier
209 zipWithId :: String
210 zipWithId = "zipWith"
211
212 -- | foldl function identifier
213 foldlId :: String
214 foldlId = "foldl"
215
216 -- | foldr function identifier
217 foldrId :: String
218 foldrId = "foldr"
219
220 -- | zip function identifier
221 zipId :: String
222 zipId = "zip"
223
224 -- | unzip function identifier
225 unzipId :: String
226 unzipId = "unzip"
227
228 -- | hwxor function identifier
229 hwxorId :: String
230 hwxorId = "hwxor"
231
232 -- | hwor function identifier
233 hworId :: String
234 hworId = "hwor"
235
236 -- | hwnot function identifier
237 hwnotId :: String
238 hwnotId = "hwnot"
239
240 -- | hwand function identifier
241 hwandId :: String
242 hwandId = "hwand"
243
244 lengthTId :: String
245 lengthTId = "lengthT"
246
247 fstId :: String
248 fstId = "fst"
249
250 sndId :: String
251 sndId = "snd"
252
253 splitId :: String
254 splitId = "split"
255
256 -- Equality Operations
257 equalityId :: String
258 equalityId = "=="
259
260 inEqualityId :: String
261 inEqualityId = "/="
262
263 gtId :: String
264 gtId = ">"
265
266 ltId :: String
267 ltId = "<"
268
269 gteqId :: String
270 gteqId = ">="
271
272 lteqId :: String
273 lteqId = "<="
274
275 boolOrId :: String
276 boolOrId = "||"
277
278 boolAndId :: String
279 boolAndId = "&&"
280
281 boolNot :: String
282 boolNot = "not"
283
284 -- Numeric Operations
285
286 -- | plus operation identifier
287 plusId :: String
288 plusId = "+"
289
290 -- | times operation identifier
291 timesId :: String
292 timesId = "*"
293
294 -- | negate operation identifier
295 negateId :: String
296 negateId = "negate"
297
298 -- | minus operation identifier
299 minusId :: String
300 minusId = "-"
301
302 -- | convert sizedword to ranged
303 fromSizedWordId :: String
304 fromSizedWordId = "fromUnsigned"
305
306 fromRangedWordId :: String
307 fromRangedWordId = "fromIndex"
308
309 toIntegerId :: String
310 toIntegerId = "to_integer"
311
312 fromIntegerId :: String
313 fromIntegerId = "fromInteger"
314
315 toSignedId :: String
316 toSignedId = "to_signed"
317
318 toUnsignedId :: String
319 toUnsignedId = "to_unsigned"
320
321 resizeId :: String
322 resizeId = "resize"
323
324 resizeWordId :: String
325 resizeWordId = "resizeWord"
326
327 resizeIntId :: String
328 resizeIntId = "resizeInt"
329
330 smallIntegerId :: String
331 smallIntegerId = "smallInteger"
332
333 sizedIntId :: String
334 sizedIntId = "Signed"
335
336 tfvecId :: String
337 tfvecId = "Vector"
338
339 blockRAMId :: String
340 blockRAMId = "blockRAM"
341
342 -- | output file identifier (from std.textio)
343 showIdString :: String
344 showIdString = "show"
345
346 showId :: AST.VHDLId
347 showId = AST.unsafeVHDLExtId showIdString
348
349 -- | write function identifier (from std.textio)
350 writeId :: AST.VHDLId
351 writeId = AST.unsafeVHDLBasicId "write"
352
353 -- | output file identifier (from std.textio)
354 outputId :: AST.VHDLId
355 outputId = AST.unsafeVHDLBasicId "output"
356
357 ------------------
358 -- VHDL type marks
359 ------------------
360
361 -- | The Bit type mark
362 bitTM :: AST.TypeMark
363 bitTM = AST.unsafeVHDLBasicId "Bit"
364
365 -- | Stardard logic type mark
366 std_logicTM :: AST.TypeMark
367 std_logicTM = AST.unsafeVHDLBasicId "std_logic"
368
369 -- | boolean type mark
370 booleanTM :: AST.TypeMark
371 booleanTM = AST.unsafeVHDLBasicId "boolean"
372
373 -- | fsvec_index AST. TypeMark
374 tfvec_indexTM :: AST.TypeMark
375 tfvec_indexTM = AST.unsafeVHDLBasicId "tfvec_index"
376
377 -- | natural AST. TypeMark
378 naturalTM :: AST.TypeMark
379 naturalTM = AST.unsafeVHDLBasicId "natural"
380
381 -- | integer TypeMark
382 integerTM :: AST.TypeMark
383 integerTM = AST.unsafeVHDLBasicId "integer"
384
385 -- | signed TypeMark
386 signedTM :: AST.TypeMark
387 signedTM = AST.unsafeVHDLBasicId "signed"
388
389 -- | unsigned TypeMark
390 unsignedTM :: AST.TypeMark
391 unsignedTM = AST.unsafeVHDLBasicId "unsigned"
392
393 -- | string TypeMark
394 stringTM :: AST.TypeMark
395 stringTM = AST.unsafeVHDLBasicId "string"
396
397 -- | tup VHDLName suffix
398 tupVHDLSuffix :: AST.VHDLId -> AST.Suffix
399 tupVHDLSuffix id = AST.SSimple id