Add shiftL and shiftR operators for signed and unsigned. Update name of shiftl and...
[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, shiftIntoLId, shiftIntoRId, 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, xorId, shiftLId , shiftRId
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 shiftIntoLId :: String
158 shiftIntoLId = "shiftIntoL"
159
160 -- | shiftr function identifier
161 shiftIntoRId :: String
162 shiftIntoRId = "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 xorId :: String
245 xorId = "xor"
246
247 shiftLId :: String
248 shiftLId = "shiftL"
249
250 shiftRId :: String
251 shiftRId = "shiftR"
252
253 lengthTId :: String
254 lengthTId = "lengthT"
255
256 fstId :: String
257 fstId = "fst"
258
259 sndId :: String
260 sndId = "snd"
261
262 splitId :: String
263 splitId = "split"
264
265 -- Equality Operations
266 equalityId :: String
267 equalityId = "=="
268
269 inEqualityId :: String
270 inEqualityId = "/="
271
272 gtId :: String
273 gtId = ">"
274
275 ltId :: String
276 ltId = "<"
277
278 gteqId :: String
279 gteqId = ">="
280
281 lteqId :: String
282 lteqId = "<="
283
284 boolOrId :: String
285 boolOrId = "||"
286
287 boolAndId :: String
288 boolAndId = "&&"
289
290 boolNot :: String
291 boolNot = "not"
292
293 -- Numeric Operations
294
295 -- | plus operation identifier
296 plusId :: String
297 plusId = "+"
298
299 -- | times operation identifier
300 timesId :: String
301 timesId = "*"
302
303 -- | negate operation identifier
304 negateId :: String
305 negateId = "negate"
306
307 -- | minus operation identifier
308 minusId :: String
309 minusId = "-"
310
311 -- | convert sizedword to ranged
312 fromSizedWordId :: String
313 fromSizedWordId = "fromUnsigned"
314
315 fromRangedWordId :: String
316 fromRangedWordId = "fromIndex"
317
318 toIntegerId :: String
319 toIntegerId = "to_integer"
320
321 fromIntegerId :: String
322 fromIntegerId = "fromInteger"
323
324 toSignedId :: String
325 toSignedId = "to_signed"
326
327 toUnsignedId :: String
328 toUnsignedId = "to_unsigned"
329
330 resizeId :: String
331 resizeId = "resize"
332
333 resizeWordId :: String
334 resizeWordId = "resizeWord"
335
336 resizeIntId :: String
337 resizeIntId = "resizeInt"
338
339 smallIntegerId :: String
340 smallIntegerId = "smallInteger"
341
342 sizedIntId :: String
343 sizedIntId = "Signed"
344
345 tfvecId :: String
346 tfvecId = "Vector"
347
348 blockRAMId :: String
349 blockRAMId = "blockRAM"
350
351 -- | output file identifier (from std.textio)
352 showIdString :: String
353 showIdString = "show"
354
355 showId :: AST.VHDLId
356 showId = AST.unsafeVHDLExtId showIdString
357
358 -- | write function identifier (from std.textio)
359 writeId :: AST.VHDLId
360 writeId = AST.unsafeVHDLBasicId "write"
361
362 -- | output file identifier (from std.textio)
363 outputId :: AST.VHDLId
364 outputId = AST.unsafeVHDLBasicId "output"
365
366 ------------------
367 -- VHDL type marks
368 ------------------
369
370 -- | The Bit type mark
371 bitTM :: AST.TypeMark
372 bitTM = AST.unsafeVHDLBasicId "Bit"
373
374 -- | Stardard logic type mark
375 std_logicTM :: AST.TypeMark
376 std_logicTM = AST.unsafeVHDLBasicId "std_logic"
377
378 -- | boolean type mark
379 booleanTM :: AST.TypeMark
380 booleanTM = AST.unsafeVHDLBasicId "boolean"
381
382 -- | fsvec_index AST. TypeMark
383 tfvec_indexTM :: AST.TypeMark
384 tfvec_indexTM = AST.unsafeVHDLBasicId "tfvec_index"
385
386 -- | natural AST. TypeMark
387 naturalTM :: AST.TypeMark
388 naturalTM = AST.unsafeVHDLBasicId "natural"
389
390 -- | integer TypeMark
391 integerTM :: AST.TypeMark
392 integerTM = AST.unsafeVHDLBasicId "integer"
393
394 -- | signed TypeMark
395 signedTM :: AST.TypeMark
396 signedTM = AST.unsafeVHDLBasicId "signed"
397
398 -- | unsigned TypeMark
399 unsignedTM :: AST.TypeMark
400 unsignedTM = AST.unsafeVHDLBasicId "unsigned"
401
402 -- | string TypeMark
403 stringTM :: AST.TypeMark
404 stringTM = AST.unsafeVHDLBasicId "string"
405
406 -- | tup VHDLName suffix
407 tupVHDLSuffix :: AST.VHDLId -> AST.Suffix
408 tupVHDLSuffix id = AST.SSimple id