1
|
let base_types =
|
2
|
["integer";
|
3
|
"character";
|
4
|
"bit";
|
5
|
"real";
|
6
|
"natural";
|
7
|
"positive";
|
8
|
"std_logic";
|
9
|
"std_logic_vector"]
|
10
|
let std_logic_cst = ["U"; "X"; "0"; "1"; "Z"; "W"; "L"; "H"; "-"]
|
11
|
let literal_base = ["B"; "O"; "X"; "UB"; "UO"; "UX"; "SB"; "SO"; "SX"; "D"]
|
12
|
type vhdl_cst_val_t =
|
13
|
| CstInt of int
|
14
|
| CstStdLogic of string
|
15
|
| CstLiteral of string [@name "CST_LITERAL"]
|
16
|
|
17
|
let rec (pp_vhdl_cst_val_t :
|
18
|
Format.formatter -> vhdl_cst_val_t -> Ppx_deriving_runtime.unit)
|
19
|
=
|
20
|
((let open! Ppx_deriving_runtime in
|
21
|
fun fmt ->
|
22
|
function
|
23
|
| CstInt a0 ->
|
24
|
(Format.fprintf fmt "%d") a0;
|
25
|
| CstStdLogic a0 ->
|
26
|
(Format.fprintf fmt "%S") a0;
|
27
|
| CstLiteral a0 ->
|
28
|
(Format.fprintf fmt "%s") a0;)
|
29
|
[@ocaml.warning "-A"])
|
30
|
|
31
|
and show_vhdl_cst_val_t : vhdl_cst_val_t -> Ppx_deriving_runtime.string =
|
32
|
fun x -> Format.asprintf "%a" pp_vhdl_cst_val_t x
|
33
|
|
34
|
let rec (vhdl_cst_val_t_to_yojson : vhdl_cst_val_t -> Yojson.Safe.json) =
|
35
|
((let open! Ppx_deriving_yojson_runtime in
|
36
|
function
|
37
|
| CstInt arg0 ->
|
38
|
`List
|
39
|
[`String "CstInt";
|
40
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg0]
|
41
|
| CstStdLogic arg0 ->
|
42
|
`List
|
43
|
[`String "CstStdLogic";
|
44
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0]
|
45
|
| CstLiteral arg0 ->
|
46
|
`List
|
47
|
[`String "CST_LITERAL";
|
48
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0])
|
49
|
[@ocaml.warning "-A"])
|
50
|
|
51
|
and (vhdl_cst_val_t_of_yojson :
|
52
|
Yojson.Safe.json -> vhdl_cst_val_t Ppx_deriving_yojson_runtime.error_or)
|
53
|
=
|
54
|
((let open! Ppx_deriving_yojson_runtime in
|
55
|
function
|
56
|
| `List ((`String "CstInt")::arg0::[]) ->
|
57
|
((function
|
58
|
| `Int x -> Result.Ok x
|
59
|
| _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>=
|
60
|
((fun arg0 -> Result.Ok (CstInt arg0)))
|
61
|
| `List ((`String "CstStdLogic")::arg0::[]) ->
|
62
|
((function
|
63
|
| `String x -> Result.Ok x
|
64
|
| _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>=
|
65
|
((fun arg0 -> Result.Ok (CstStdLogic arg0)))
|
66
|
| `List ((`String "CST_LITERAL")::arg0::[]) ->
|
67
|
((function
|
68
|
| `String x -> Result.Ok x
|
69
|
| _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>=
|
70
|
((fun arg0 -> Result.Ok (CstLiteral arg0)))
|
71
|
| _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t")
|
72
|
[@ocaml.warning "-A"])
|
73
|
|
74
|
type vhdl_type_t =
|
75
|
| Base of string
|
76
|
| Range of string option * int * int
|
77
|
| Bit_vector of int * int
|
78
|
| Array of
|
79
|
{
|
80
|
indexes: vhdl_name_t list [@default []];
|
81
|
const: vhdl_constraint_t option [@default None];
|
82
|
definition: vhdl_subtype_indication_t } [@name "ARRAY_TYPE_DEFINITION"]
|
83
|
| Record of vhdl_element_declaration_t list
|
84
|
[@name "RECORD_TYPE_DEFINITION"]
|
85
|
| Enumerated of vhdl_name_t list [@name "ENUMERATION_TYPE_DEFINITION"]
|
86
|
| Void
|
87
|
and vhdl_element_declaration_t =
|
88
|
{
|
89
|
names: vhdl_name_t list ;
|
90
|
definition: vhdl_subtype_indication_t }
|
91
|
and vhdl_subtype_indication_t =
|
92
|
{
|
93
|
name: vhdl_name_t [@default NoName];
|
94
|
functionName: vhdl_name_t [@default NoName];
|
95
|
const: vhdl_constraint_t [@default NoConstraint]}
|
96
|
and vhdl_discrete_range_t =
|
97
|
| SubDiscreteRange of vhdl_subtype_indication_t
|
98
|
[@name "SUB_DISCRETE_RANGE"]
|
99
|
| NamedRange of vhdl_name_t [@name "NAMED_RANGE"]
|
100
|
| DirectedRange of
|
101
|
{
|
102
|
direction: string ;
|
103
|
from: vhdl_expr_t ;
|
104
|
_to: vhdl_expr_t } [@name "RANGE_WITH_DIRECTION"]
|
105
|
and vhdl_constraint_t =
|
106
|
| RefConstraint of {
|
107
|
ref_name: vhdl_name_t }
|
108
|
| RangeConstraint of {
|
109
|
range: vhdl_discrete_range_t } [@name "RANGE_CONSTRAINT"]
|
110
|
| IndexConstraint of {
|
111
|
ranges: vhdl_discrete_range_t list } [@name "INDEX_CONSTRAINT"]
|
112
|
| ArrayConstraint of
|
113
|
{
|
114
|
ranges: vhdl_discrete_range_t list ;
|
115
|
sub: vhdl_constraint_t } [@name "ARRAY_CONSTRAINT"]
|
116
|
| RecordConstraint
|
117
|
| NoConstraint
|
118
|
and vhdl_definition_t =
|
119
|
| Type of {
|
120
|
name: vhdl_name_t ;
|
121
|
definition: vhdl_type_t } [@name "TYPE_DECLARATION"]
|
122
|
| Subtype of {
|
123
|
name: vhdl_name_t ;
|
124
|
typ: vhdl_subtype_indication_t } [@name "SUBTYPE_DECLARATION"]
|
125
|
and vhdl_expr_t =
|
126
|
| Call of vhdl_name_t [@name "CALL"]
|
127
|
| Cst of
|
128
|
{
|
129
|
value: vhdl_cst_val_t ;
|
130
|
unit_name: vhdl_name_t option [@default None]} [@name "CONSTANT_VALUE"]
|
131
|
| Op of {
|
132
|
id: string [@default ""];
|
133
|
args: vhdl_expr_t list [@default []]} [@name "EXPRESSION"]
|
134
|
| IsNull [@name "IsNull"]
|
135
|
| Time of {
|
136
|
value: int ;
|
137
|
phy_unit: string [@default ""]}
|
138
|
| Sig of {
|
139
|
name: vhdl_name_t ;
|
140
|
att: vhdl_signal_attributes_t option }
|
141
|
| SuffixMod of {
|
142
|
expr: vhdl_expr_t ;
|
143
|
selection: vhdl_suffix_selection_t }
|
144
|
| Aggregate of {
|
145
|
elems: vhdl_element_assoc_t list } [@name "AGGREGATE"]
|
146
|
| QualifiedExpression of
|
147
|
{
|
148
|
type_mark: vhdl_name_t ;
|
149
|
aggregate: vhdl_element_assoc_t list ;
|
150
|
expression: vhdl_expr_t option } [@name "QUALIFIED_EXPRESSION"]
|
151
|
| Others [@name "OTHERS"]
|
152
|
and vhdl_name_t =
|
153
|
| Simple of string [@name "SIMPLE_NAME"]
|
154
|
| Identifier of string [@name "IDENTIFIER"]
|
155
|
| Selected of vhdl_name_t list [@name "SELECTED_NAME"]
|
156
|
| Index of {
|
157
|
id: vhdl_name_t ;
|
158
|
exprs: vhdl_expr_t list } [@name "INDEXED_NAME"]
|
159
|
| Slice of {
|
160
|
id: vhdl_name_t ;
|
161
|
range: vhdl_discrete_range_t } [@name "SLICE_NAME"]
|
162
|
| Attribute of
|
163
|
{
|
164
|
id: vhdl_name_t ;
|
165
|
designator: vhdl_name_t ;
|
166
|
expr: vhdl_expr_t [@default IsNull]} [@name "ATTRIBUTE_NAME"]
|
167
|
| Function of {
|
168
|
id: vhdl_name_t ;
|
169
|
assoc_list: vhdl_assoc_element_t list } [@name "FUNCTION_CALL"]
|
170
|
| NoName
|
171
|
and vhdl_assoc_element_t =
|
172
|
{
|
173
|
formal_name: vhdl_name_t option [@default None];
|
174
|
formal_arg: vhdl_name_t option [@default None];
|
175
|
actual_name: vhdl_name_t option [@default None];
|
176
|
actual_designator: vhdl_name_t option [@default None];
|
177
|
actual_expr: vhdl_expr_t option [@default None]}
|
178
|
and vhdl_element_assoc_t = {
|
179
|
choices: vhdl_expr_t list [@default []];
|
180
|
expr: vhdl_expr_t }
|
181
|
and vhdl_array_attributes_t =
|
182
|
| AAttInt of {
|
183
|
id: string ;
|
184
|
arg: int }
|
185
|
| AAttAscending
|
186
|
and vhdl_signal_attributes_t =
|
187
|
| SigAtt of string
|
188
|
and vhdl_string_attributes_t =
|
189
|
| StringAtt of string
|
190
|
and vhdl_suffix_selection_t =
|
191
|
| Idx of int
|
192
|
| SuffixRange of int * int
|
193
|
|
194
|
let rec pp_vhdl_type_t :
|
195
|
Format.formatter -> vhdl_type_t -> Ppx_deriving_runtime.unit =
|
196
|
let __4 () = pp_vhdl_name_t
|
197
|
|
198
|
and __3 () = pp_vhdl_element_declaration_t
|
199
|
|
200
|
and __2 () = pp_vhdl_subtype_indication_t
|
201
|
|
202
|
and __1 () = pp_vhdl_constraint_t
|
203
|
|
204
|
and __0 () = pp_vhdl_name_t
|
205
|
in
|
206
|
((let open! Ppx_deriving_runtime in
|
207
|
fun fmt ->
|
208
|
function
|
209
|
| Base a0 ->
|
210
|
(Format.fprintf fmt "%s") a0;
|
211
|
| Range (a0,a1,a2) ->
|
212
|
((
|
213
|
(Format.fprintf fmt "%d") a1);
|
214
|
((function
|
215
|
| None -> Format.pp_print_string fmt ""
|
216
|
| Some x ->
|
217
|
(Format.fprintf fmt "%s") x;
|
218
|
)) a0;
|
219
|
(Format.fprintf fmt "%d") a2);
|
220
|
| Bit_vector (a0,a1) ->
|
221
|
(Format.fprintf fmt "array (%d,%d) of bit") a0 a1;
|
222
|
| Array
|
223
|
{ indexes = aindexes; const = aconst; definition = adefinition }
|
224
|
->
|
225
|
Format.fprintf fmt "array";
|
226
|
(match aindexes with
|
227
|
| [] -> Format.fprintf fmt "";
|
228
|
| _ ->
|
229
|
Format.fprintf fmt "(@[<v>";
|
230
|
((fun x ->
|
231
|
ignore
|
232
|
(List.fold_left
|
233
|
(fun sep ->
|
234
|
fun x ->
|
235
|
if sep then Format.fprintf fmt ",@ ";
|
236
|
((__0 ()) fmt) x;
|
237
|
Format.fprintf fmt " range <>";
|
238
|
true) false x)) aindexes);
|
239
|
Format.fprintf fmt ")@]");
|
240
|
(function
|
241
|
| None -> Format.pp_print_string fmt ""
|
242
|
| Some x ->
|
243
|
((__1 ()) fmt) x) aconst;
|
244
|
Format.fprintf fmt " of ";
|
245
|
((__2 ()) fmt) adefinition;
|
246
|
| Record a0 ->
|
247
|
Format.fprintf fmt "@[<v 2>record@;";
|
248
|
(fun x ->
|
249
|
ignore
|
250
|
(List.fold_left
|
251
|
(fun sep ->
|
252
|
fun x ->
|
253
|
if sep then Format.fprintf fmt ";@;";
|
254
|
((__3 ()) fmt) x;
|
255
|
true) false x);
|
256
|
Format.fprintf fmt "@]@;end record") a0;
|
257
|
| Enumerated a0 ->
|
258
|
(Format.fprintf fmt "(";
|
259
|
((fun x ->
|
260
|
ignore
|
261
|
(List.fold_left
|
262
|
(fun sep ->
|
263
|
fun x ->
|
264
|
if sep then Format.fprintf fmt ",@ ";
|
265
|
((__4 ()) fmt) x;
|
266
|
true) false x))) a0;
|
267
|
Format.fprintf fmt ")");
|
268
|
| Void -> Format.pp_print_string fmt "")
|
269
|
[@ocaml.warning "-A"])
|
270
|
|
271
|
and show_vhdl_type_t : vhdl_type_t -> Ppx_deriving_runtime.string =
|
272
|
fun x -> Format.asprintf "%a" pp_vhdl_type_t x
|
273
|
|
274
|
and pp_vhdl_element_declaration_t :
|
275
|
Format.formatter -> vhdl_element_declaration_t -> Ppx_deriving_runtime.unit
|
276
|
=
|
277
|
let __1 () = pp_vhdl_subtype_indication_t
|
278
|
|
279
|
and __0 () = pp_vhdl_name_t
|
280
|
in
|
281
|
((let open! Ppx_deriving_runtime in
|
282
|
fun fmt ->
|
283
|
fun x ->
|
284
|
(fun x ->
|
285
|
ignore
|
286
|
(List.fold_left
|
287
|
(fun sep ->
|
288
|
fun x ->
|
289
|
if sep then Format.fprintf fmt ",@ ";
|
290
|
((__0 ()) fmt) x;
|
291
|
true) false x)) x.names;
|
292
|
Format.fprintf fmt ":@ ";
|
293
|
((__1 ()) fmt) x.definition)
|
294
|
[@ocaml.warning "-A"])
|
295
|
|
296
|
and show_vhdl_element_declaration_t :
|
297
|
vhdl_element_declaration_t -> Ppx_deriving_runtime.string =
|
298
|
fun x -> Format.asprintf "%a" pp_vhdl_element_declaration_t x
|
299
|
|
300
|
and pp_vhdl_subtype_indication_t :
|
301
|
Format.formatter -> vhdl_subtype_indication_t -> Ppx_deriving_runtime.unit
|
302
|
=
|
303
|
let __2 () = pp_vhdl_constraint_t
|
304
|
|
305
|
and __1 () = pp_vhdl_name_t
|
306
|
|
307
|
and __0 () = pp_vhdl_name_t
|
308
|
in
|
309
|
((let open! Ppx_deriving_runtime in
|
310
|
fun fmt ->
|
311
|
fun x ->
|
312
|
((__0 ()) fmt) x.name;
|
313
|
((__1 ()) fmt) x.functionName;
|
314
|
(match x.const with
|
315
|
| NoConstraint -> Format.fprintf fmt "";
|
316
|
| _ -> Format.fprintf fmt " ";
|
317
|
((__2 ()) fmt) x.const))
|
318
|
[@ocaml.warning "-A"])
|
319
|
|
320
|
and show_vhdl_subtype_indication_t :
|
321
|
vhdl_subtype_indication_t -> Ppx_deriving_runtime.string =
|
322
|
fun x -> Format.asprintf "%a" pp_vhdl_subtype_indication_t x
|
323
|
|
324
|
and pp_vhdl_discrete_range_t :
|
325
|
Format.formatter -> vhdl_discrete_range_t -> Ppx_deriving_runtime.unit =
|
326
|
let __3 () = pp_vhdl_expr_t
|
327
|
|
328
|
and __2 () = pp_vhdl_expr_t
|
329
|
|
330
|
and __1 () = pp_vhdl_name_t
|
331
|
|
332
|
and __0 () = pp_vhdl_subtype_indication_t
|
333
|
in
|
334
|
((let open! Ppx_deriving_runtime in
|
335
|
fun fmt ->
|
336
|
function
|
337
|
| SubDiscreteRange a0 ->
|
338
|
((__0 ()) fmt) a0;
|
339
|
| NamedRange a0 ->
|
340
|
((__1 ()) fmt) a0;
|
341
|
| DirectedRange { direction = adirection; from = afrom; _to = a_to }
|
342
|
->
|
343
|
((__2 ()) fmt) afrom;
|
344
|
(Format.fprintf fmt " %s ") adirection;
|
345
|
((__3 ()) fmt) a_to;
|
346
|
)
|
347
|
[@ocaml.warning "-A"])
|
348
|
|
349
|
and show_vhdl_discrete_range_t :
|
350
|
vhdl_discrete_range_t -> Ppx_deriving_runtime.string =
|
351
|
fun x -> Format.asprintf "%a" pp_vhdl_discrete_range_t x
|
352
|
|
353
|
(* TODO Adapt for: ArrayConstraint, RecordConstraint *)
|
354
|
and pp_vhdl_constraint_t :
|
355
|
Format.formatter -> vhdl_constraint_t -> Ppx_deriving_runtime.unit =
|
356
|
let __4 () = pp_vhdl_constraint_t
|
357
|
|
358
|
and __3 () = pp_vhdl_discrete_range_t
|
359
|
|
360
|
and __2 () = pp_vhdl_discrete_range_t
|
361
|
|
362
|
and __1 () = pp_vhdl_discrete_range_t
|
363
|
|
364
|
and __0 () = pp_vhdl_name_t
|
365
|
in
|
366
|
((let open! Ppx_deriving_runtime in
|
367
|
fun fmt ->
|
368
|
function
|
369
|
| RefConstraint { ref_name = aref_name } ->
|
370
|
(Format.fprintf fmt "(";
|
371
|
((__0 ()) fmt) aref_name;
|
372
|
Format.fprintf fmt ")");
|
373
|
| RangeConstraint { range = arange } ->
|
374
|
(Format.fprintf fmt "(";
|
375
|
((__1 ()) fmt) arange;
|
376
|
Format.fprintf fmt ")");
|
377
|
| IndexConstraint { ranges = aranges } ->
|
378
|
Format.fprintf fmt "(";
|
379
|
((fun x ->
|
380
|
ignore
|
381
|
(List.fold_left
|
382
|
(fun sep ->
|
383
|
fun x ->
|
384
|
if sep then Format.fprintf fmt ", ";
|
385
|
((__2 ()) fmt) x;
|
386
|
true) false x))) aranges;
|
387
|
Format.fprintf fmt ")";
|
388
|
| ArrayConstraint { ranges = aranges; sub = asub } ->
|
389
|
(Format.fprintf fmt "@[<2>ArrayConstraint {@,";
|
390
|
((Format.fprintf fmt "@[%s =@ " "ranges";
|
391
|
((fun x ->
|
392
|
Format.fprintf fmt "@[<2>[";
|
393
|
ignore
|
394
|
(List.fold_left
|
395
|
(fun sep ->
|
396
|
fun x ->
|
397
|
if sep then Format.fprintf fmt ";@ ";
|
398
|
((__3 ()) fmt) x;
|
399
|
true) false x);
|
400
|
Format.fprintf fmt "@,]@]")) aranges;
|
401
|
Format.fprintf fmt "@]");
|
402
|
Format.fprintf fmt ";@ ";
|
403
|
Format.fprintf fmt "@[%s =@ " "sub";
|
404
|
((__4 ()) fmt) asub;
|
405
|
Format.fprintf fmt "@]");
|
406
|
Format.fprintf fmt "@]}")
|
407
|
| RecordConstraint -> Format.pp_print_string fmt ""
|
408
|
| NoConstraint -> Format.pp_print_string fmt "")
|
409
|
[@ocaml.warning "-A"])
|
410
|
|
411
|
and show_vhdl_constraint_t : vhdl_constraint_t -> Ppx_deriving_runtime.string
|
412
|
= fun x -> Format.asprintf "%a" pp_vhdl_constraint_t x
|
413
|
|
414
|
and pp_vhdl_definition_t :
|
415
|
Format.formatter -> vhdl_definition_t -> Ppx_deriving_runtime.unit =
|
416
|
let __3 () = pp_vhdl_subtype_indication_t
|
417
|
|
418
|
and __2 () = pp_vhdl_name_t
|
419
|
|
420
|
and __1 () = pp_vhdl_type_t
|
421
|
|
422
|
and __0 () = pp_vhdl_name_t
|
423
|
in
|
424
|
((let open! Ppx_deriving_runtime in
|
425
|
fun fmt ->
|
426
|
function
|
427
|
| Type { name = aname; definition = adefinition } ->
|
428
|
Format.fprintf fmt "type ";
|
429
|
((__0 ()) fmt) aname;
|
430
|
Format.fprintf fmt " is ";
|
431
|
((__1 ()) fmt) adefinition;
|
432
|
| Subtype { name = aname; typ = atyp } ->
|
433
|
Format.fprintf fmt "subtype ";
|
434
|
((__2 ()) fmt) aname;
|
435
|
Format.fprintf fmt " is ";
|
436
|
((__3 ()) fmt) atyp;
|
437
|
)
|
438
|
[@ocaml.warning "-A"])
|
439
|
|
440
|
and show_vhdl_definition_t : vhdl_definition_t -> Ppx_deriving_runtime.string
|
441
|
= fun x -> Format.asprintf "%a" pp_vhdl_definition_t x
|
442
|
|
443
|
(* TODO adapt for Op, Time, Sig, suffixMod *)
|
444
|
and pp_vhdl_expr_t :
|
445
|
Format.formatter -> vhdl_expr_t -> Ppx_deriving_runtime.unit =
|
446
|
let __11 () = pp_vhdl_expr_t
|
447
|
|
448
|
and __10 () = pp_vhdl_element_assoc_t
|
449
|
|
450
|
and __9 () = pp_vhdl_name_t
|
451
|
|
452
|
and __8 () = pp_vhdl_element_assoc_t
|
453
|
|
454
|
and __7 () = pp_vhdl_suffix_selection_t
|
455
|
|
456
|
and __6 () = pp_vhdl_expr_t
|
457
|
|
458
|
and __5 () = pp_vhdl_signal_attributes_t
|
459
|
|
460
|
and __4 () = pp_vhdl_name_t
|
461
|
|
462
|
and __3 () = pp_vhdl_expr_t
|
463
|
|
464
|
and __2 () = pp_vhdl_name_t
|
465
|
|
466
|
and __1 () = pp_vhdl_cst_val_t
|
467
|
|
468
|
and __0 () = pp_vhdl_name_t
|
469
|
in
|
470
|
((let open! Ppx_deriving_runtime in
|
471
|
fun fmt ->
|
472
|
function
|
473
|
| Call a0 ->
|
474
|
((__0 ()) fmt) a0;
|
475
|
| Cst { value = avalue; unit_name = aunit_name } ->
|
476
|
((__1 ()) fmt) avalue;
|
477
|
(function
|
478
|
| None -> Format.pp_print_string fmt ""
|
479
|
| Some x ->
|
480
|
Format.fprintf fmt " ";
|
481
|
((__2 ()) fmt) x) aunit_name;
|
482
|
| Op { id = aid; args = aargs } ->
|
483
|
(match aargs with
|
484
|
| [] -> (Format.fprintf fmt "%s") aid;
|
485
|
| hd::[] ->
|
486
|
(Format.fprintf fmt "%s") aid;
|
487
|
((__3 ()) fmt) hd
|
488
|
| hd::(hd2::[]) ->
|
489
|
((__3 ()) fmt) hd;
|
490
|
(Format.fprintf fmt " %s ") aid;
|
491
|
((__3 ()) fmt) hd2
|
492
|
| _ ->
|
493
|
(Format.fprintf fmt "@[<2>Op {@,";
|
494
|
((Format.fprintf fmt "@[%s =@ " "id";
|
495
|
(Format.fprintf fmt "%S") aid;
|
496
|
Format.fprintf fmt "@]");
|
497
|
Format.fprintf fmt ";@ ";
|
498
|
Format.fprintf fmt "@[%s =@ " "args";
|
499
|
((fun x ->
|
500
|
Format.fprintf fmt "@[<2>[";
|
501
|
ignore
|
502
|
(List.fold_left
|
503
|
(fun sep ->
|
504
|
fun x ->
|
505
|
if sep then Format.fprintf fmt ";@ ";
|
506
|
((__3 ()) fmt) x;
|
507
|
true) false x);
|
508
|
Format.fprintf fmt "@,]@]")) aargs;
|
509
|
Format.fprintf fmt "@]");
|
510
|
Format.fprintf fmt "@]}"))
|
511
|
| IsNull -> Format.pp_print_string fmt ""
|
512
|
| Time { value = avalue; phy_unit = aphy_unit } ->
|
513
|
(Format.fprintf fmt "@[<2>Time {@,";
|
514
|
((Format.fprintf fmt "@[%s =@ " "value";
|
515
|
(Format.fprintf fmt "%d") avalue;
|
516
|
Format.fprintf fmt "@]");
|
517
|
Format.fprintf fmt ";@ ";
|
518
|
Format.fprintf fmt "@[%s =@ " "phy_unit";
|
519
|
(Format.fprintf fmt "%S") aphy_unit;
|
520
|
Format.fprintf fmt "@]");
|
521
|
Format.fprintf fmt "@]}")
|
522
|
| Sig { name = aname; att = aatt } ->
|
523
|
(Format.fprintf fmt "--@[<2>Sig {@,";
|
524
|
((Format.fprintf fmt "@[%s =@ " "name";
|
525
|
((__4 ()) fmt) aname;
|
526
|
Format.fprintf fmt "@]");
|
527
|
Format.fprintf fmt ";@ ";
|
528
|
Format.fprintf fmt "@[%s =@ " "att";
|
529
|
((function
|
530
|
| None -> Format.pp_print_string fmt "None"
|
531
|
| Some x ->
|
532
|
(Format.pp_print_string fmt "(Some ";
|
533
|
((__5 ()) fmt) x;
|
534
|
Format.pp_print_string fmt ")"))) aatt;
|
535
|
Format.fprintf fmt "@]");
|
536
|
Format.fprintf fmt "@]}")
|
537
|
| SuffixMod { expr = aexpr; selection = aselection } ->
|
538
|
(Format.fprintf fmt "--@[<2>SuffixMod {@,";
|
539
|
((Format.fprintf fmt "@[%s =@ " "expr";
|
540
|
((__6 ()) fmt) aexpr;
|
541
|
Format.fprintf fmt "@]");
|
542
|
Format.fprintf fmt ";@ ";
|
543
|
Format.fprintf fmt "@[%s =@ " "selection";
|
544
|
((__7 ()) fmt) aselection;
|
545
|
Format.fprintf fmt "@]");
|
546
|
Format.fprintf fmt "@]}")
|
547
|
| Aggregate { elems = aelems } ->
|
548
|
(match aelems with
|
549
|
| [] -> Format.fprintf fmt "";
|
550
|
| _ ->
|
551
|
(Format.fprintf fmt "(@[";
|
552
|
((fun x ->
|
553
|
ignore
|
554
|
(List.fold_left
|
555
|
(fun sep ->
|
556
|
fun x ->
|
557
|
if sep then Format.fprintf fmt ", ";
|
558
|
((__8 ()) fmt) x;
|
559
|
true) false x))) aelems;
|
560
|
Format.fprintf fmt ")@]");)
|
561
|
| QualifiedExpression
|
562
|
{ type_mark = atype_mark; aggregate = aaggregate;
|
563
|
expression = aexpression }
|
564
|
->
|
565
|
((__9 ()) fmt) atype_mark;
|
566
|
Format.fprintf fmt "'";
|
567
|
(match aaggregate with
|
568
|
| [] -> Format.fprintf fmt "";
|
569
|
| _ ->
|
570
|
Format.fprintf fmt "(@[<v>";
|
571
|
((fun x ->
|
572
|
ignore
|
573
|
(List.fold_left
|
574
|
(fun sep ->
|
575
|
fun x ->
|
576
|
if sep then Format.fprintf fmt ",@ ";
|
577
|
((__10 ()) fmt) x;
|
578
|
true) false x))) aaggregate;
|
579
|
Format.fprintf fmt ")@]");
|
580
|
(match aexpression with
|
581
|
| None -> Format.pp_print_string fmt ""
|
582
|
| Some x ->
|
583
|
((__11 ()) fmt) x;);
|
584
|
| Others -> Format.pp_print_string fmt "others")
|
585
|
[@ocaml.warning "-A"])
|
586
|
|
587
|
and show_vhdl_expr_t : vhdl_expr_t -> Ppx_deriving_runtime.string =
|
588
|
fun x -> Format.asprintf "%a" pp_vhdl_expr_t x
|
589
|
|
590
|
and pp_vhdl_name_t :
|
591
|
Format.formatter -> vhdl_name_t -> Ppx_deriving_runtime.unit =
|
592
|
let __9 () = pp_vhdl_assoc_element_t
|
593
|
|
594
|
and __8 () = pp_vhdl_name_t
|
595
|
|
596
|
and __7 () = pp_vhdl_expr_t
|
597
|
|
598
|
and __6 () = pp_vhdl_name_t
|
599
|
|
600
|
and __5 () = pp_vhdl_name_t
|
601
|
|
602
|
and __4 () = pp_vhdl_discrete_range_t
|
603
|
|
604
|
and __3 () = pp_vhdl_name_t
|
605
|
|
606
|
and __2 () = pp_vhdl_expr_t
|
607
|
|
608
|
and __1 () = pp_vhdl_name_t
|
609
|
|
610
|
and __0 () = pp_vhdl_name_t
|
611
|
in
|
612
|
((let open! Ppx_deriving_runtime in
|
613
|
fun fmt ->
|
614
|
function
|
615
|
| Simple a0 ->
|
616
|
(Format.fprintf fmt "%s") a0;
|
617
|
| Identifier a0 ->
|
618
|
(Format.fprintf fmt "%s") a0;
|
619
|
| Selected a0 ->
|
620
|
((fun x ->
|
621
|
ignore
|
622
|
(List.fold_left
|
623
|
(fun sep ->
|
624
|
fun x ->
|
625
|
if sep then Format.fprintf fmt ".";
|
626
|
((__0 ()) fmt) x;
|
627
|
true) false x);) a0;)
|
628
|
| Index { id = aid; exprs = aexprs } ->
|
629
|
((__1 ()) fmt) aid;
|
630
|
Format.fprintf fmt "(";
|
631
|
(fun x ->
|
632
|
ignore
|
633
|
(List.fold_left
|
634
|
(fun sep ->
|
635
|
fun x ->
|
636
|
if sep then Format.fprintf fmt ",@ ";
|
637
|
((__2 ()) fmt) x;
|
638
|
true
|
639
|
) false x);
|
640
|
) aexprs;
|
641
|
Format.fprintf fmt ")";
|
642
|
| Slice { id = aid; range = arange } ->
|
643
|
((__3 ()) fmt) aid;
|
644
|
Format.fprintf fmt "(";
|
645
|
((__4 ()) fmt) arange;
|
646
|
Format.fprintf fmt ")";
|
647
|
| Attribute { id = aid; designator = adesignator; expr = aexpr } ->
|
648
|
((__5 ()) fmt) aid;
|
649
|
Format.fprintf fmt "\'";
|
650
|
((__6 ()) fmt) adesignator;
|
651
|
(match aexpr with
|
652
|
| IsNull -> Format.fprintf fmt "";
|
653
|
| _ ->
|
654
|
Format.fprintf fmt "(";
|
655
|
((__7 ()) fmt) aexpr;
|
656
|
Format.fprintf fmt ")")
|
657
|
| Function { id = aid; assoc_list = aassoc_list } ->
|
658
|
(((__8 ()) fmt) aid;
|
659
|
Format.fprintf fmt "(";
|
660
|
((fun x ->
|
661
|
Format.fprintf fmt "@[";
|
662
|
ignore
|
663
|
(List.fold_left
|
664
|
(fun sep ->
|
665
|
fun x ->
|
666
|
if sep then Format.fprintf fmt ";@ ";
|
667
|
((__9 ()) fmt) x;
|
668
|
true) false x);
|
669
|
Format.fprintf fmt "@]")) aassoc_list;
|
670
|
Format.fprintf fmt ")";)
|
671
|
| NoName -> Format.pp_print_string fmt "")
|
672
|
[@ocaml.warning "-A"])
|
673
|
|
674
|
and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string =
|
675
|
fun x -> Format.asprintf "%a" pp_vhdl_name_t x
|
676
|
|
677
|
and pp_vhdl_assoc_element_t :
|
678
|
Format.formatter -> vhdl_assoc_element_t -> Ppx_deriving_runtime.unit =
|
679
|
let __4 () = pp_vhdl_expr_t
|
680
|
|
681
|
and __3 () = pp_vhdl_name_t
|
682
|
|
683
|
and __2 () = pp_vhdl_name_t
|
684
|
|
685
|
and __1 () = pp_vhdl_name_t
|
686
|
|
687
|
and __0 () = pp_vhdl_name_t
|
688
|
in
|
689
|
((let open! Ppx_deriving_runtime in
|
690
|
fun fmt ->
|
691
|
fun x ->
|
692
|
(match x.formal_name with
|
693
|
| None -> Format.pp_print_string fmt ""
|
694
|
| Some NoName -> Format.pp_print_string fmt ""
|
695
|
| Some a ->
|
696
|
(((__0 ()) fmt) a;
|
697
|
(match x.formal_arg with
|
698
|
| None -> Format.pp_print_string fmt ""
|
699
|
| Some b -> ((__1 ()) fmt) b);
|
700
|
Format.fprintf fmt " => "));
|
701
|
(match x.actual_name with
|
702
|
| None ->
|
703
|
((match x.actual_designator with
|
704
|
| None -> Format.pp_print_string fmt ""
|
705
|
| Some NoName -> Format.pp_print_string fmt ""
|
706
|
| Some b -> ((__3 ()) fmt) b);
|
707
|
(match x.actual_expr with
|
708
|
| None -> Format.pp_print_string fmt ""
|
709
|
| Some IsNull -> Format.pp_print_string fmt ""
|
710
|
| Some c -> ((__4 ()) fmt) c);)
|
711
|
| Some a ->
|
712
|
(((__2 ()) fmt) a;
|
713
|
(match a with
|
714
|
| NoName -> ()
|
715
|
| _ -> Format.fprintf fmt "(");
|
716
|
(match x.actual_designator with
|
717
|
| None -> Format.pp_print_string fmt ""
|
718
|
| Some b -> ((__3 ()) fmt) b);
|
719
|
(match x.actual_expr with
|
720
|
| None -> Format.pp_print_string fmt ""
|
721
|
| Some IsNull -> Format.pp_print_string fmt ""
|
722
|
| Some c -> ((__4 ()) fmt) c);
|
723
|
(match a with
|
724
|
| NoName -> ()
|
725
|
| _ -> Format.fprintf fmt ")")));)
|
726
|
[@ocaml.warning "-A"])
|
727
|
|
728
|
and show_vhdl_assoc_element_t :
|
729
|
vhdl_assoc_element_t -> Ppx_deriving_runtime.string =
|
730
|
fun x -> Format.asprintf "%a" pp_vhdl_assoc_element_t x
|
731
|
|
732
|
and pp_vhdl_element_assoc_t :
|
733
|
Format.formatter -> vhdl_element_assoc_t -> Ppx_deriving_runtime.unit =
|
734
|
let __1 () = pp_vhdl_expr_t
|
735
|
|
736
|
and __0 () = pp_vhdl_expr_t
|
737
|
in
|
738
|
((let open! Ppx_deriving_runtime in
|
739
|
fun fmt ->
|
740
|
fun x ->
|
741
|
(match x.choices with
|
742
|
| [] -> Format.fprintf fmt "";
|
743
|
| _ ->
|
744
|
(((fun x ->
|
745
|
ignore
|
746
|
(List.fold_left
|
747
|
(fun sep ->
|
748
|
fun x ->
|
749
|
if sep then Format.fprintf fmt "|@ ";
|
750
|
((__0 ()) fmt) x;
|
751
|
true) false x))) x.choices;
|
752
|
Format.fprintf fmt " => ";));
|
753
|
((__1 ()) fmt) x.expr)
|
754
|
[@ocaml.warning "-A"])
|
755
|
|
756
|
and show_vhdl_element_assoc_t :
|
757
|
vhdl_element_assoc_t -> Ppx_deriving_runtime.string =
|
758
|
fun x -> Format.asprintf "%a" pp_vhdl_element_assoc_t x
|
759
|
|
760
|
(* TODO *)
|
761
|
and (pp_vhdl_array_attributes_t :
|
762
|
Format.formatter ->
|
763
|
vhdl_array_attributes_t -> Ppx_deriving_runtime.unit)
|
764
|
=
|
765
|
((let open! Ppx_deriving_runtime in
|
766
|
fun fmt ->
|
767
|
function
|
768
|
| AAttInt { id = aid; arg = aarg } ->
|
769
|
(Format.fprintf fmt "@[<2>AAttInt {@,";
|
770
|
((Format.fprintf fmt "@[%s =@ " "id";
|
771
|
(Format.fprintf fmt "%S") aid;
|
772
|
Format.fprintf fmt "@]");
|
773
|
Format.fprintf fmt ";@ ";
|
774
|
Format.fprintf fmt "@[%s =@ " "arg";
|
775
|
(Format.fprintf fmt "%d") aarg;
|
776
|
Format.fprintf fmt "@]");
|
777
|
Format.fprintf fmt "@]}")
|
778
|
| AAttAscending -> Format.pp_print_string fmt "AAttAscending")
|
779
|
[@ocaml.warning "-A"])
|
780
|
|
781
|
and show_vhdl_array_attributes_t :
|
782
|
vhdl_array_attributes_t -> Ppx_deriving_runtime.string =
|
783
|
fun x -> Format.asprintf "%a" pp_vhdl_array_attributes_t x
|
784
|
|
785
|
(* TODO *)
|
786
|
and (pp_vhdl_signal_attributes_t :
|
787
|
Format.formatter ->
|
788
|
vhdl_signal_attributes_t -> Ppx_deriving_runtime.unit)
|
789
|
=
|
790
|
((let open! Ppx_deriving_runtime in
|
791
|
fun fmt ->
|
792
|
function
|
793
|
| SigAtt a0 ->
|
794
|
(Format.fprintf fmt "(@[<2>SigAtt@ ";
|
795
|
(Format.fprintf fmt "%S") a0;
|
796
|
Format.fprintf fmt "@])"))
|
797
|
[@ocaml.warning "-A"])
|
798
|
|
799
|
and show_vhdl_signal_attributes_t :
|
800
|
vhdl_signal_attributes_t -> Ppx_deriving_runtime.string =
|
801
|
fun x -> Format.asprintf "%a" pp_vhdl_signal_attributes_t x
|
802
|
|
803
|
(* TODO *)
|
804
|
and (pp_vhdl_string_attributes_t :
|
805
|
Format.formatter ->
|
806
|
vhdl_string_attributes_t -> Ppx_deriving_runtime.unit)
|
807
|
=
|
808
|
((let open! Ppx_deriving_runtime in
|
809
|
fun fmt ->
|
810
|
function
|
811
|
| StringAtt a0 ->
|
812
|
(Format.fprintf fmt "(@[<2>StringAtt@ ";
|
813
|
(Format.fprintf fmt "%S") a0;
|
814
|
Format.fprintf fmt "@])"))
|
815
|
[@ocaml.warning "-A"])
|
816
|
|
817
|
and show_vhdl_string_attributes_t :
|
818
|
vhdl_string_attributes_t -> Ppx_deriving_runtime.string =
|
819
|
fun x -> Format.asprintf "%a" pp_vhdl_string_attributes_t x
|
820
|
|
821
|
(* TODO *)
|
822
|
and (pp_vhdl_suffix_selection_t :
|
823
|
Format.formatter ->
|
824
|
vhdl_suffix_selection_t -> Ppx_deriving_runtime.unit)
|
825
|
=
|
826
|
((let open! Ppx_deriving_runtime in
|
827
|
fun fmt ->
|
828
|
function
|
829
|
| Idx a0 ->
|
830
|
(Format.fprintf fmt "(@[<2>Idx@ ";
|
831
|
(Format.fprintf fmt "%d") a0;
|
832
|
Format.fprintf fmt "@])")
|
833
|
| SuffixRange (a0,a1) ->
|
834
|
(Format.fprintf fmt "(@[<2>SuffixRange (@,";
|
835
|
((Format.fprintf fmt "%d") a0;
|
836
|
Format.fprintf fmt ",@ ";
|
837
|
(Format.fprintf fmt "%d") a1);
|
838
|
Format.fprintf fmt "@,))@]"))
|
839
|
[@ocaml.warning "-A"])
|
840
|
|
841
|
and show_vhdl_suffix_selection_t :
|
842
|
vhdl_suffix_selection_t -> Ppx_deriving_runtime.string =
|
843
|
fun x -> Format.asprintf "%a" pp_vhdl_suffix_selection_t x
|
844
|
|
845
|
let rec (vhdl_type_t_to_yojson : vhdl_type_t -> Yojson.Safe.json) =
|
846
|
((let open! Ppx_deriving_yojson_runtime in
|
847
|
function
|
848
|
| Base arg0 ->
|
849
|
`List
|
850
|
[`String "Base";
|
851
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0]
|
852
|
| Range (arg0,arg1,arg2) ->
|
853
|
`List
|
854
|
[`String "Range";
|
855
|
((function
|
856
|
| None -> `Null
|
857
|
| Some x ->
|
858
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)) x))
|
859
|
arg0;
|
860
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg1;
|
861
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg2]
|
862
|
| Bit_vector (arg0,arg1) ->
|
863
|
`List
|
864
|
[`String "Bit_vector";
|
865
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg0;
|
866
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg1]
|
867
|
| Array arg0 ->
|
868
|
`List
|
869
|
[`String "ARRAY_TYPE_DEFINITION";
|
870
|
(let fields = [] in
|
871
|
let fields =
|
872
|
("definition",
|
873
|
((fun x -> vhdl_subtype_indication_t_to_yojson x)
|
874
|
arg0.definition))
|
875
|
:: fields in
|
876
|
let fields =
|
877
|
if arg0.const = None
|
878
|
then fields
|
879
|
else
|
880
|
("const",
|
881
|
(((function
|
882
|
| None -> `Null
|
883
|
| Some x ->
|
884
|
((fun x -> vhdl_constraint_t_to_yojson x)) x))
|
885
|
arg0.const))
|
886
|
:: fields
|
887
|
in
|
888
|
let fields =
|
889
|
if arg0.indexes = []
|
890
|
then fields
|
891
|
else
|
892
|
("indexes",
|
893
|
(((fun x ->
|
894
|
`List
|
895
|
(List.map (fun x -> vhdl_name_t_to_yojson x) x)))
|
896
|
arg0.indexes))
|
897
|
:: fields
|
898
|
in
|
899
|
`Assoc fields)]
|
900
|
| Record arg0 ->
|
901
|
`List
|
902
|
[`String "RECORD_TYPE_DEFINITION";
|
903
|
((fun x ->
|
904
|
`List
|
905
|
(List.map
|
906
|
(fun x -> vhdl_element_declaration_t_to_yojson x) x)))
|
907
|
arg0]
|
908
|
| Enumerated arg0 ->
|
909
|
`List
|
910
|
[`String "ENUMERATION_TYPE_DEFINITION";
|
911
|
((fun x ->
|
912
|
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x))) arg0]
|
913
|
| Void -> `List [`String "Void"])
|
914
|
[@ocaml.warning "-A"])
|
915
|
|
916
|
and (vhdl_type_t_of_yojson :
|
917
|
Yojson.Safe.json -> vhdl_type_t Ppx_deriving_yojson_runtime.error_or)
|
918
|
=
|
919
|
((let open! Ppx_deriving_yojson_runtime in
|
920
|
function
|
921
|
| `List ((`String "Base")::arg0::[]) ->
|
922
|
((function
|
923
|
| `String x -> Result.Ok x
|
924
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
|
925
|
((fun arg0 -> Result.Ok (Base arg0)))
|
926
|
| `List ((`String "Range")::arg0::arg1::arg2::[]) ->
|
927
|
((function
|
928
|
| `Int x -> Result.Ok x
|
929
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg2) >>=
|
930
|
((fun arg2 ->
|
931
|
((function
|
932
|
| `Int x -> Result.Ok x
|
933
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
|
934
|
(fun arg1 ->
|
935
|
((function
|
936
|
| `Null -> Result.Ok None
|
937
|
| x ->
|
938
|
((function
|
939
|
| `String x -> Result.Ok x
|
940
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") x)
|
941
|
>>= ((fun x -> Result.Ok (Some x)))) arg0)
|
942
|
>>=
|
943
|
(fun arg0 -> Result.Ok (Range (arg0, arg1, arg2))))))
|
944
|
| `List ((`String "Bit_vector")::arg0::arg1::[]) ->
|
945
|
((function
|
946
|
| `Int x -> Result.Ok x
|
947
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
|
948
|
((fun arg1 ->
|
949
|
((function
|
950
|
| `Int x -> Result.Ok x
|
951
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
|
952
|
(fun arg0 -> Result.Ok (Bit_vector (arg0, arg1)))))
|
953
|
| `List ((`String "ARRAY_TYPE_DEFINITION")::arg0::[]) ->
|
954
|
((function
|
955
|
| `Assoc xs ->
|
956
|
let rec loop xs ((arg0,arg1,arg2) as _state) =
|
957
|
match xs with
|
958
|
| ("indexes",x)::xs ->
|
959
|
loop xs
|
960
|
(((function
|
961
|
| `List xs ->
|
962
|
map_bind (fun x -> vhdl_name_t_of_yojson x)
|
963
|
[] xs
|
964
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t.indexes")
|
965
|
x), arg1, arg2)
|
966
|
| ("const",x)::xs ->
|
967
|
loop xs
|
968
|
(arg0,
|
969
|
((function
|
970
|
| `Null -> Result.Ok None
|
971
|
| x ->
|
972
|
((fun x -> vhdl_constraint_t_of_yojson x) x)
|
973
|
>>= ((fun x -> Result.Ok (Some x)))) x),
|
974
|
arg2)
|
975
|
| ("definition",x)::xs ->
|
976
|
loop xs
|
977
|
(arg0, arg1,
|
978
|
((fun x -> vhdl_subtype_indication_t_of_yojson x)
|
979
|
x))
|
980
|
| [] ->
|
981
|
arg2 >>=
|
982
|
((fun arg2 ->
|
983
|
arg1 >>=
|
984
|
(fun arg1 ->
|
985
|
arg0 >>=
|
986
|
(fun arg0 ->
|
987
|
Result.Ok
|
988
|
(Array
|
989
|
{
|
990
|
indexes = arg0;
|
991
|
const = arg1;
|
992
|
definition = arg2
|
993
|
})))))
|
994
|
| _::xs -> loop xs _state in
|
995
|
loop xs
|
996
|
((Result.Ok []), (Result.Ok None),
|
997
|
(Result.Error "Vhdl_ast.vhdl_type_t.definition"))
|
998
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t")) arg0
|
999
|
| `List ((`String "RECORD_TYPE_DEFINITION")::arg0::[]) ->
|
1000
|
((function
|
1001
|
| `List xs ->
|
1002
|
map_bind (fun x -> vhdl_element_declaration_t_of_yojson x)
|
1003
|
[] xs
|
1004
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
|
1005
|
((fun arg0 -> Result.Ok (Record arg0)))
|
1006
|
| `List ((`String "ENUMERATION_TYPE_DEFINITION")::arg0::[]) ->
|
1007
|
((function
|
1008
|
| `List xs -> map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs
|
1009
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
|
1010
|
((fun arg0 -> Result.Ok (Enumerated arg0)))
|
1011
|
| `List ((`String "Void")::[]) -> Result.Ok Void
|
1012
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t")
|
1013
|
[@ocaml.warning "-A"])
|
1014
|
|
1015
|
and (vhdl_element_declaration_t_to_yojson :
|
1016
|
vhdl_element_declaration_t -> Yojson.Safe.json)
|
1017
|
=
|
1018
|
((let open! Ppx_deriving_yojson_runtime in
|
1019
|
fun x ->
|
1020
|
let fields = [] in
|
1021
|
let fields =
|
1022
|
("definition",
|
1023
|
((fun x -> vhdl_subtype_indication_t_to_yojson x) x.definition))
|
1024
|
:: fields in
|
1025
|
let fields =
|
1026
|
("names",
|
1027
|
((fun x ->
|
1028
|
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x))
|
1029
|
x.names))
|
1030
|
:: fields in
|
1031
|
`Assoc fields)
|
1032
|
[@ocaml.warning "-A"])
|
1033
|
|
1034
|
and (vhdl_element_declaration_t_of_yojson :
|
1035
|
Yojson.Safe.json ->
|
1036
|
vhdl_element_declaration_t Ppx_deriving_yojson_runtime.error_or)
|
1037
|
=
|
1038
|
((let open! Ppx_deriving_yojson_runtime in
|
1039
|
function
|
1040
|
| `Assoc xs ->
|
1041
|
let rec loop xs ((arg0,arg1) as _state) =
|
1042
|
match xs with
|
1043
|
| ("names",x)::xs ->
|
1044
|
loop xs
|
1045
|
(((function
|
1046
|
| `List xs ->
|
1047
|
map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs
|
1048
|
| _ ->
|
1049
|
Result.Error
|
1050
|
"Vhdl_ast.vhdl_element_declaration_t.names") x),
|
1051
|
arg1)
|
1052
|
| ("definition",x)::xs ->
|
1053
|
loop xs
|
1054
|
(arg0,
|
1055
|
((fun x -> vhdl_subtype_indication_t_of_yojson x) x))
|
1056
|
| [] ->
|
1057
|
arg1 >>=
|
1058
|
((fun arg1 ->
|
1059
|
arg0 >>=
|
1060
|
(fun arg0 ->
|
1061
|
Result.Ok { names = arg0; definition = arg1 })))
|
1062
|
| _::xs -> loop xs _state in
|
1063
|
loop xs
|
1064
|
((Result.Error "Vhdl_ast.vhdl_element_declaration_t.names"),
|
1065
|
(Result.Error "Vhdl_ast.vhdl_element_declaration_t.definition"))
|
1066
|
| _ -> Result.Error "Vhdl_ast.vhdl_element_declaration_t")
|
1067
|
[@ocaml.warning "-A"])
|
1068
|
|
1069
|
and (vhdl_subtype_indication_t_to_yojson :
|
1070
|
vhdl_subtype_indication_t -> Yojson.Safe.json)
|
1071
|
=
|
1072
|
((let open! Ppx_deriving_yojson_runtime in
|
1073
|
fun x ->
|
1074
|
let fields = [] in
|
1075
|
let fields =
|
1076
|
if x.const = NoConstraint
|
1077
|
then fields
|
1078
|
else
|
1079
|
("const", (((fun x -> vhdl_constraint_t_to_yojson x)) x.const))
|
1080
|
:: fields
|
1081
|
in
|
1082
|
let fields =
|
1083
|
if x.functionName = NoName
|
1084
|
then fields
|
1085
|
else
|
1086
|
("functionName",
|
1087
|
(((fun x -> vhdl_name_t_to_yojson x)) x.functionName))
|
1088
|
:: fields
|
1089
|
in
|
1090
|
let fields =
|
1091
|
if x.name = NoName
|
1092
|
then fields
|
1093
|
else ("name", (((fun x -> vhdl_name_t_to_yojson x)) x.name)) ::
|
1094
|
fields
|
1095
|
in
|
1096
|
`Assoc fields)
|
1097
|
[@ocaml.warning "-A"])
|
1098
|
|
1099
|
and (vhdl_subtype_indication_t_of_yojson :
|
1100
|
Yojson.Safe.json ->
|
1101
|
vhdl_subtype_indication_t Ppx_deriving_yojson_runtime.error_or)
|
1102
|
=
|
1103
|
((let open! Ppx_deriving_yojson_runtime in
|
1104
|
function
|
1105
|
| `Assoc xs ->
|
1106
|
let rec loop xs ((arg0,arg1,arg2) as _state) =
|
1107
|
match xs with
|
1108
|
| ("name",x)::xs ->
|
1109
|
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2)
|
1110
|
| ("functionName",x)::xs ->
|
1111
|
loop xs (arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2)
|
1112
|
| ("const",x)::xs ->
|
1113
|
loop xs
|
1114
|
(arg0, arg1, ((fun x -> vhdl_constraint_t_of_yojson x) x))
|
1115
|
| [] ->
|
1116
|
arg2 >>=
|
1117
|
((fun arg2 ->
|
1118
|
arg1 >>=
|
1119
|
(fun arg1 ->
|
1120
|
arg0 >>=
|
1121
|
(fun arg0 ->
|
1122
|
Result.Ok
|
1123
|
{
|
1124
|
name = arg0;
|
1125
|
functionName = arg1;
|
1126
|
const = arg2
|
1127
|
}))))
|
1128
|
| _::xs -> loop xs _state in
|
1129
|
loop xs
|
1130
|
((Result.Ok NoName), (Result.Ok NoName),
|
1131
|
(Result.Ok NoConstraint))
|
1132
|
| _ -> Result.Error "Vhdl_ast.vhdl_subtype_indication_t")
|
1133
|
[@ocaml.warning "-A"])
|
1134
|
|
1135
|
and (vhdl_discrete_range_t_to_yojson :
|
1136
|
vhdl_discrete_range_t -> Yojson.Safe.json)
|
1137
|
=
|
1138
|
((let open! Ppx_deriving_yojson_runtime in
|
1139
|
function
|
1140
|
| SubDiscreteRange arg0 ->
|
1141
|
`List
|
1142
|
[`String "SUB_DISCRETE_RANGE";
|
1143
|
((fun x -> vhdl_subtype_indication_t_to_yojson x)) arg0]
|
1144
|
| NamedRange arg0 ->
|
1145
|
`List
|
1146
|
[`String "NAMED_RANGE";
|
1147
|
((fun x -> vhdl_name_t_to_yojson x)) arg0]
|
1148
|
| DirectedRange arg0 ->
|
1149
|
`List
|
1150
|
[`String "RANGE_WITH_DIRECTION";
|
1151
|
(let fields = [] in
|
1152
|
let fields =
|
1153
|
("_to", ((fun x -> vhdl_expr_t_to_yojson x) arg0._to)) ::
|
1154
|
fields in
|
1155
|
let fields =
|
1156
|
("from", ((fun x -> vhdl_expr_t_to_yojson x) arg0.from)) ::
|
1157
|
fields in
|
1158
|
let fields =
|
1159
|
("direction",
|
1160
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)
|
1161
|
arg0.direction))
|
1162
|
:: fields in
|
1163
|
`Assoc fields)])
|
1164
|
[@ocaml.warning "-A"])
|
1165
|
|
1166
|
and (vhdl_discrete_range_t_of_yojson :
|
1167
|
Yojson.Safe.json ->
|
1168
|
vhdl_discrete_range_t Ppx_deriving_yojson_runtime.error_or)
|
1169
|
=
|
1170
|
((let open! Ppx_deriving_yojson_runtime in
|
1171
|
function
|
1172
|
| `List ((`String "SUB_DISCRETE_RANGE")::arg0::[]) ->
|
1173
|
((fun x -> vhdl_subtype_indication_t_of_yojson x) arg0) >>=
|
1174
|
((fun arg0 -> Result.Ok (SubDiscreteRange arg0)))
|
1175
|
| `List ((`String "NAMED_RANGE")::arg0::[]) ->
|
1176
|
((fun x -> vhdl_name_t_of_yojson x) arg0) >>=
|
1177
|
((fun arg0 -> Result.Ok (NamedRange arg0)))
|
1178
|
| `List ((`String "RANGE_WITH_DIRECTION")::arg0::[]) ->
|
1179
|
((function
|
1180
|
| `Assoc xs ->
|
1181
|
let rec loop xs ((arg0,arg1,arg2) as _state) =
|
1182
|
match xs with
|
1183
|
| ("direction",x)::xs ->
|
1184
|
loop xs
|
1185
|
(((function
|
1186
|
| `String x -> Result.Ok x
|
1187
|
| _ ->
|
1188
|
Result.Error
|
1189
|
"Vhdl_ast.vhdl_discrete_range_t.direction")
|
1190
|
x), arg1, arg2)
|
1191
|
| ("from",x)::xs ->
|
1192
|
loop xs
|
1193
|
(arg0, ((fun x -> vhdl_expr_t_of_yojson x) x), arg2)
|
1194
|
| ("_to",x)::xs ->
|
1195
|
loop xs
|
1196
|
(arg0, arg1, ((fun x -> vhdl_expr_t_of_yojson x) x))
|
1197
|
| [] ->
|
1198
|
arg2 >>=
|
1199
|
((fun arg2 ->
|
1200
|
arg1 >>=
|
1201
|
(fun arg1 ->
|
1202
|
arg0 >>=
|
1203
|
(fun arg0 ->
|
1204
|
Result.Ok
|
1205
|
(DirectedRange
|
1206
|
{
|
1207
|
direction = arg0;
|
1208
|
from = arg1;
|
1209
|
_to = arg2
|
1210
|
})))))
|
1211
|
| _::xs -> loop xs _state in
|
1212
|
loop xs
|
1213
|
((Result.Error "Vhdl_ast.vhdl_discrete_range_t.direction"),
|
1214
|
(Result.Error "Vhdl_ast.vhdl_discrete_range_t.from"),
|
1215
|
(Result.Error "Vhdl_ast.vhdl_discrete_range_t._to"))
|
1216
|
| _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")) arg0
|
1217
|
| _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")
|
1218
|
[@ocaml.warning "-A"])
|
1219
|
|
1220
|
and (vhdl_constraint_t_to_yojson : vhdl_constraint_t -> Yojson.Safe.json) =
|
1221
|
((let open! Ppx_deriving_yojson_runtime in
|
1222
|
function
|
1223
|
| RefConstraint arg0 ->
|
1224
|
`List
|
1225
|
[`String "RefConstraint";
|
1226
|
(let fields = [] in
|
1227
|
let fields =
|
1228
|
("ref_name",
|
1229
|
((fun x -> vhdl_name_t_to_yojson x) arg0.ref_name))
|
1230
|
:: fields in
|
1231
|
`Assoc fields)]
|
1232
|
| RangeConstraint arg0 ->
|
1233
|
`List
|
1234
|
[`String "RANGE_CONSTRAINT";
|
1235
|
(let fields = [] in
|
1236
|
let fields =
|
1237
|
("range",
|
1238
|
((fun x -> vhdl_discrete_range_t_to_yojson x) arg0.range))
|
1239
|
:: fields in
|
1240
|
`Assoc fields)]
|
1241
|
| IndexConstraint arg0 ->
|
1242
|
`List
|
1243
|
[`String "INDEX_CONSTRAINT";
|
1244
|
(let fields = [] in
|
1245
|
let fields =
|
1246
|
("ranges",
|
1247
|
((fun x ->
|
1248
|
`List
|
1249
|
(List.map
|
1250
|
(fun x -> vhdl_discrete_range_t_to_yojson x) x))
|
1251
|
arg0.ranges))
|
1252
|
:: fields in
|
1253
|
`Assoc fields)]
|
1254
|
| ArrayConstraint arg0 ->
|
1255
|
`List
|
1256
|
[`String "ARRAY_CONSTRAINT";
|
1257
|
(let fields = [] in
|
1258
|
let fields =
|
1259
|
("sub", ((fun x -> vhdl_constraint_t_to_yojson x) arg0.sub))
|
1260
|
:: fields in
|
1261
|
let fields =
|
1262
|
("ranges",
|
1263
|
((fun x ->
|
1264
|
`List
|
1265
|
(List.map
|
1266
|
(fun x -> vhdl_discrete_range_t_to_yojson x) x))
|
1267
|
arg0.ranges))
|
1268
|
:: fields in
|
1269
|
`Assoc fields)]
|
1270
|
| RecordConstraint -> `List [`String "RecordConstraint"]
|
1271
|
| NoConstraint -> `List [`String "NoConstraint"])
|
1272
|
[@ocaml.warning "-A"])
|
1273
|
|
1274
|
and (vhdl_constraint_t_of_yojson :
|
1275
|
Yojson.Safe.json ->
|
1276
|
vhdl_constraint_t Ppx_deriving_yojson_runtime.error_or)
|
1277
|
=
|
1278
|
((let open! Ppx_deriving_yojson_runtime in
|
1279
|
function
|
1280
|
| `List ((`String "RefConstraint")::arg0::[]) ->
|
1281
|
((function
|
1282
|
| `Assoc xs ->
|
1283
|
let rec loop xs (arg0 as _state) =
|
1284
|
match xs with
|
1285
|
| ("ref_name",x)::xs ->
|
1286
|
loop xs ((fun x -> vhdl_name_t_of_yojson x) x)
|
1287
|
| [] ->
|
1288
|
arg0 >>=
|
1289
|
((fun arg0 ->
|
1290
|
Result.Ok (RefConstraint { ref_name = arg0 })))
|
1291
|
| _::xs -> loop xs _state in
|
1292
|
loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ref_name")
|
1293
|
| _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
|
1294
|
| `List ((`String "RANGE_CONSTRAINT")::arg0::[]) ->
|
1295
|
((function
|
1296
|
| `Assoc xs ->
|
1297
|
let rec loop xs (arg0 as _state) =
|
1298
|
match xs with
|
1299
|
| ("range",x)::xs ->
|
1300
|
loop xs
|
1301
|
((fun x -> vhdl_discrete_range_t_of_yojson x) x)
|
1302
|
| [] ->
|
1303
|
arg0 >>=
|
1304
|
((fun arg0 ->
|
1305
|
Result.Ok (RangeConstraint { range = arg0 })))
|
1306
|
| _::xs -> loop xs _state in
|
1307
|
loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.range")
|
1308
|
| _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
|
1309
|
| `List ((`String "INDEX_CONSTRAINT")::arg0::[]) ->
|
1310
|
((function
|
1311
|
| `Assoc xs ->
|
1312
|
let rec loop xs (arg0 as _state) =
|
1313
|
match xs with
|
1314
|
| ("ranges",x)::xs ->
|
1315
|
loop xs
|
1316
|
((function
|
1317
|
| `List xs ->
|
1318
|
map_bind
|
1319
|
(fun x -> vhdl_discrete_range_t_of_yojson x)
|
1320
|
[] xs
|
1321
|
| _ ->
|
1322
|
Result.Error
|
1323
|
"Vhdl_ast.vhdl_constraint_t.ranges") x)
|
1324
|
| [] ->
|
1325
|
arg0 >>=
|
1326
|
((fun arg0 ->
|
1327
|
Result.Ok (IndexConstraint { ranges = arg0 })))
|
1328
|
| _::xs -> loop xs _state in
|
1329
|
loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ranges")
|
1330
|
| _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
|
1331
|
| `List ((`String "ARRAY_CONSTRAINT")::arg0::[]) ->
|
1332
|
((function
|
1333
|
| `Assoc xs ->
|
1334
|
let rec loop xs ((arg0,arg1) as _state) =
|
1335
|
match xs with
|
1336
|
| ("ranges",x)::xs ->
|
1337
|
loop xs
|
1338
|
(((function
|
1339
|
| `List xs ->
|
1340
|
map_bind
|
1341
|
(fun x -> vhdl_discrete_range_t_of_yojson x)
|
1342
|
[] xs
|
1343
|
| _ ->
|
1344
|
Result.Error
|
1345
|
"Vhdl_ast.vhdl_constraint_t.ranges") x),
|
1346
|
arg1)
|
1347
|
| ("sub",x)::xs ->
|
1348
|
loop xs
|
1349
|
(arg0, ((fun x -> vhdl_constraint_t_of_yojson x) x))
|
1350
|
| [] ->
|
1351
|
arg1 >>=
|
1352
|
((fun arg1 ->
|
1353
|
arg0 >>=
|
1354
|
(fun arg0 ->
|
1355
|
Result.Ok
|
1356
|
(ArrayConstraint
|
1357
|
{ ranges = arg0; sub = arg1 }))))
|
1358
|
| _::xs -> loop xs _state in
|
1359
|
loop xs
|
1360
|
((Result.Error "Vhdl_ast.vhdl_constraint_t.ranges"),
|
1361
|
(Result.Error "Vhdl_ast.vhdl_constraint_t.sub"))
|
1362
|
| _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
|
1363
|
| `List ((`String "RecordConstraint")::[]) ->
|
1364
|
Result.Ok RecordConstraint
|
1365
|
| `List ((`String "NoConstraint")::[]) -> Result.Ok NoConstraint
|
1366
|
| _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")
|
1367
|
[@ocaml.warning "-A"])
|
1368
|
|
1369
|
and (vhdl_definition_t_to_yojson : vhdl_definition_t -> Yojson.Safe.json) =
|
1370
|
((let open! Ppx_deriving_yojson_runtime in
|
1371
|
function
|
1372
|
| Type arg0 ->
|
1373
|
`List
|
1374
|
[`String "TYPE_DECLARATION";
|
1375
|
(let fields = [] in
|
1376
|
let fields =
|
1377
|
("definition",
|
1378
|
((fun x -> vhdl_type_t_to_yojson x) arg0.definition))
|
1379
|
:: fields in
|
1380
|
let fields =
|
1381
|
("name", ((fun x -> vhdl_name_t_to_yojson x) arg0.name)) ::
|
1382
|
fields in
|
1383
|
`Assoc fields)]
|
1384
|
| Subtype arg0 ->
|
1385
|
`List
|
1386
|
[`String "SUBTYPE_DECLARATION";
|
1387
|
(let fields = [] in
|
1388
|
let fields =
|
1389
|
("typ",
|
1390
|
((fun x -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
|
1391
|
:: fields in
|
1392
|
let fields =
|
1393
|
("name", ((fun x -> vhdl_name_t_to_yojson x) arg0.name)) ::
|
1394
|
fields in
|
1395
|
`Assoc fields)])
|
1396
|
[@ocaml.warning "-A"])
|
1397
|
|
1398
|
and (vhdl_definition_t_of_yojson :
|
1399
|
Yojson.Safe.json ->
|
1400
|
vhdl_definition_t Ppx_deriving_yojson_runtime.error_or)
|
1401
|
=
|
1402
|
((let open! Ppx_deriving_yojson_runtime in
|
1403
|
function
|
1404
|
| `List ((`String "TYPE_DECLARATION")::arg0::[]) ->
|
1405
|
((function
|
1406
|
| `Assoc xs ->
|
1407
|
let rec loop xs ((arg0,arg1) as _state) =
|
1408
|
match xs with
|
1409
|
| ("name",x)::xs ->
|
1410
|
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1)
|
1411
|
| ("definition",x)::xs ->
|
1412
|
loop xs (arg0, ((fun x -> vhdl_type_t_of_yojson x) x))
|
1413
|
| [] ->
|
1414
|
arg1 >>=
|
1415
|
((fun arg1 ->
|
1416
|
arg0 >>=
|
1417
|
(fun arg0 ->
|
1418
|
Result.Ok
|
1419
|
(Type { name = arg0; definition = arg1 }))))
|
1420
|
| _::xs -> loop xs _state in
|
1421
|
loop xs
|
1422
|
((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
|
1423
|
(Result.Error "Vhdl_ast.vhdl_definition_t.definition"))
|
1424
|
| _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
|
1425
|
| `List ((`String "SUBTYPE_DECLARATION")::arg0::[]) ->
|
1426
|
((function
|
1427
|
| `Assoc xs ->
|
1428
|
let rec loop xs ((arg0,arg1) as _state) =
|
1429
|
match xs with
|
1430
|
| ("name",x)::xs ->
|
1431
|
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1)
|
1432
|
| ("typ",x)::xs ->
|
1433
|
loop xs
|
1434
|
(arg0,
|
1435
|
((fun x -> vhdl_subtype_indication_t_of_yojson x)
|
1436
|
x))
|
1437
|
| [] ->
|
1438
|
arg1 >>=
|
1439
|
((fun arg1 ->
|
1440
|
arg0 >>=
|
1441
|
(fun arg0 ->
|
1442
|
Result.Ok
|
1443
|
(Subtype { name = arg0; typ = arg1 }))))
|
1444
|
| _::xs -> loop xs _state in
|
1445
|
loop xs
|
1446
|
((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
|
1447
|
(Result.Error "Vhdl_ast.vhdl_definition_t.typ"))
|
1448
|
| _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
|
1449
|
| _ -> Result.Error "Vhdl_ast.vhdl_definition_t")
|
1450
|
[@ocaml.warning "-A"])
|
1451
|
|
1452
|
and (vhdl_expr_t_to_yojson : vhdl_expr_t -> Yojson.Safe.json) =
|
1453
|
((let open! Ppx_deriving_yojson_runtime in
|
1454
|
function
|
1455
|
| Call arg0 ->
|
1456
|
`List [`String "CALL"; ((fun x -> vhdl_name_t_to_yojson x)) arg0]
|
1457
|
| Cst arg0 ->
|
1458
|
`List
|
1459
|
[`String "CONSTANT_VALUE";
|
1460
|
(let fields = [] in
|
1461
|
let fields =
|
1462
|
if arg0.unit_name = None
|
1463
|
then fields
|
1464
|
else
|
1465
|
("unit_name",
|
1466
|
(((function
|
1467
|
| None -> `Null
|
1468
|
| Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x))
|
1469
|
arg0.unit_name))
|
1470
|
:: fields
|
1471
|
in
|
1472
|
let fields =
|
1473
|
("value", ((fun x -> vhdl_cst_val_t_to_yojson x) arg0.value))
|
1474
|
:: fields in
|
1475
|
`Assoc fields)]
|
1476
|
| Op arg0 ->
|
1477
|
`List
|
1478
|
[`String "EXPRESSION";
|
1479
|
(let fields = [] in
|
1480
|
let fields =
|
1481
|
if arg0.args = []
|
1482
|
then fields
|
1483
|
else
|
1484
|
("args",
|
1485
|
(((fun x ->
|
1486
|
`List
|
1487
|
(List.map (fun x -> vhdl_expr_t_to_yojson x) x)))
|
1488
|
arg0.args))
|
1489
|
:: fields
|
1490
|
in
|
1491
|
let fields =
|
1492
|
if arg0.id = ""
|
1493
|
then fields
|
1494
|
else
|
1495
|
("id",
|
1496
|
(((fun (x : Ppx_deriving_runtime.string) -> `String x))
|
1497
|
arg0.id))
|
1498
|
:: fields
|
1499
|
in
|
1500
|
`Assoc fields)]
|
1501
|
| IsNull -> `List [`String "IsNull"]
|
1502
|
| Time arg0 ->
|
1503
|
`List
|
1504
|
[`String "Time";
|
1505
|
(let fields = [] in
|
1506
|
let fields =
|
1507
|
if arg0.phy_unit = ""
|
1508
|
then fields
|
1509
|
else
|
1510
|
("phy_unit",
|
1511
|
(((fun (x : Ppx_deriving_runtime.string) -> `String x))
|
1512
|
arg0.phy_unit))
|
1513
|
:: fields
|
1514
|
in
|
1515
|
let fields =
|
1516
|
("value",
|
1517
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x) arg0.value))
|
1518
|
:: fields in
|
1519
|
`Assoc fields)]
|
1520
|
| Sig arg0 ->
|
1521
|
`List
|
1522
|
[`String "Sig";
|
1523
|
(let fields = [] in
|
1524
|
let fields =
|
1525
|
if arg0.att = None
|
1526
|
then fields
|
1527
|
else
|
1528
|
("att",
|
1529
|
(((function
|
1530
|
| None -> `Null
|
1531
|
| Some x ->
|
1532
|
((fun x -> vhdl_signal_attributes_t_to_yojson x))
|
1533
|
x)) arg0.att))
|
1534
|
:: fields
|
1535
|
in
|
1536
|
let fields =
|
1537
|
("name", ((fun x -> vhdl_name_t_to_yojson x) arg0.name)) ::
|
1538
|
fields in
|
1539
|
`Assoc fields)]
|
1540
|
| SuffixMod arg0 ->
|
1541
|
`List
|
1542
|
[`String "SuffixMod";
|
1543
|
(let fields = [] in
|
1544
|
let fields =
|
1545
|
("selection",
|
1546
|
((fun x -> vhdl_suffix_selection_t_to_yojson x)
|
1547
|
arg0.selection))
|
1548
|
:: fields in
|
1549
|
let fields =
|
1550
|
("expr", ((fun x -> vhdl_expr_t_to_yojson x) arg0.expr)) ::
|
1551
|
fields in
|
1552
|
`Assoc fields)]
|
1553
|
| Aggregate arg0 ->
|
1554
|
`List
|
1555
|
[`String "AGGREGATE";
|
1556
|
(let fields = [] in
|
1557
|
let fields =
|
1558
|
if arg0.elems = []
|
1559
|
then fields
|
1560
|
else
|
1561
|
("elems",
|
1562
|
(((fun x ->
|
1563
|
`List
|
1564
|
(List.map
|
1565
|
(fun x -> vhdl_element_assoc_t_to_yojson x) x)))
|
1566
|
arg0.elems))
|
1567
|
:: fields
|
1568
|
in
|
1569
|
`Assoc fields)]
|
1570
|
| QualifiedExpression arg0 ->
|
1571
|
`List
|
1572
|
[`String "QUALIFIED_EXPRESSION";
|
1573
|
(let fields = [] in
|
1574
|
let fields =
|
1575
|
if arg0.expression = None
|
1576
|
then fields
|
1577
|
else
|
1578
|
("expression",
|
1579
|
(((function
|
1580
|
| None -> `Null
|
1581
|
| Some x -> ((fun x -> vhdl_expr_t_to_yojson x)) x))
|
1582
|
arg0.expression))
|
1583
|
:: fields
|
1584
|
in
|
1585
|
let fields =
|
1586
|
if arg0.aggregate = []
|
1587
|
then fields
|
1588
|
else
|
1589
|
("aggregate",
|
1590
|
(((fun x ->
|
1591
|
`List
|
1592
|
(List.map
|
1593
|
(fun x -> vhdl_element_assoc_t_to_yojson x) x)))
|
1594
|
arg0.aggregate))
|
1595
|
:: fields
|
1596
|
in
|
1597
|
let fields =
|
1598
|
("type_mark",
|
1599
|
((fun x -> vhdl_name_t_to_yojson x) arg0.type_mark))
|
1600
|
:: fields in
|
1601
|
`Assoc fields)]
|
1602
|
| Others -> `List [`String "OTHERS"])
|
1603
|
[@ocaml.warning "-A"])
|
1604
|
|
1605
|
and (vhdl_expr_t_of_yojson :
|
1606
|
Yojson.Safe.json -> vhdl_expr_t Ppx_deriving_yojson_runtime.error_or)
|
1607
|
=
|
1608
|
((let open! Ppx_deriving_yojson_runtime in
|
1609
|
function
|
1610
|
| `List ((`String "CALL")::arg0::[]) ->
|
1611
|
((fun x -> vhdl_name_t_of_yojson x) arg0) >>=
|
1612
|
((fun arg0 -> Result.Ok (Call arg0)))
|
1613
|
| `List ((`String "CONSTANT_VALUE")::arg0::[]) ->
|
1614
|
((function
|
1615
|
| `Assoc xs ->
|
1616
|
let rec loop xs ((arg0,arg1) as _state) =
|
1617
|
match xs with
|
1618
|
| ("value",x)::xs ->
|
1619
|
loop xs
|
1620
|
(((fun x -> vhdl_cst_val_t_of_yojson x) x), arg1)
|
1621
|
| ("unit_name",x)::xs ->
|
1622
|
loop xs
|
1623
|
(arg0,
|
1624
|
((function
|
1625
|
| `Null -> Result.Ok None
|
1626
|
| x ->
|
1627
|
((fun x -> vhdl_name_t_of_yojson x) x) >>=
|
1628
|
((fun x -> Result.Ok (Some x)))) x))
|
1629
|
| [] ->
|
1630
|
arg1 >>=
|
1631
|
((fun arg1 ->
|
1632
|
arg0 >>=
|
1633
|
(fun arg0 ->
|
1634
|
Result.Ok
|
1635
|
(Cst { value = arg0; unit_name = arg1 }))))
|
1636
|
| _::xs -> loop xs _state in
|
1637
|
loop xs
|
1638
|
((Result.Error "Vhdl_ast.vhdl_expr_t.value"),
|
1639
|
(Result.Ok None))
|
1640
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
|
1641
|
| `List ((`String "EXPRESSION")::arg0::[]) ->
|
1642
|
((function
|
1643
|
| `Assoc xs ->
|
1644
|
let rec loop xs ((arg0,arg1) as _state) =
|
1645
|
match xs with
|
1646
|
| ("id",x)::xs ->
|
1647
|
loop xs
|
1648
|
(((function
|
1649
|
| `String x -> Result.Ok x
|
1650
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t.id") x),
|
1651
|
arg1)
|
1652
|
| ("args",x)::xs ->
|
1653
|
loop xs
|
1654
|
(arg0,
|
1655
|
((function
|
1656
|
| `List xs ->
|
1657
|
map_bind (fun x -> vhdl_expr_t_of_yojson x)
|
1658
|
[] xs
|
1659
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t.args")
|
1660
|
x))
|
1661
|
| [] ->
|
1662
|
arg1 >>=
|
1663
|
((fun arg1 ->
|
1664
|
arg0 >>=
|
1665
|
(fun arg0 ->
|
1666
|
Result.Ok (Op { id = arg0; args = arg1 }))))
|
1667
|
| _::xs -> loop xs _state in
|
1668
|
loop xs ((Result.Ok ""), (Result.Ok []))
|
1669
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
|
1670
|
| `List ((`String "IsNull")::[]) -> Result.Ok IsNull
|
1671
|
| `List ((`String "Time")::arg0::[]) ->
|
1672
|
((function
|
1673
|
| `Assoc xs ->
|
1674
|
let rec loop xs ((arg0,arg1) as _state) =
|
1675
|
match xs with
|
1676
|
| ("value",x)::xs ->
|
1677
|
loop xs
|
1678
|
(((function
|
1679
|
| `Int x -> Result.Ok x
|
1680
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t.value")
|
1681
|
x), arg1)
|
1682
|
| ("phy_unit",x)::xs ->
|
1683
|
loop xs
|
1684
|
(arg0,
|
1685
|
((function
|
1686
|
| `String x -> Result.Ok x
|
1687
|
| _ ->
|
1688
|
Result.Error "Vhdl_ast.vhdl_expr_t.phy_unit")
|
1689
|
x))
|
1690
|
| [] ->
|
1691
|
arg1 >>=
|
1692
|
((fun arg1 ->
|
1693
|
arg0 >>=
|
1694
|
(fun arg0 ->
|
1695
|
Result.Ok
|
1696
|
(Time { value = arg0; phy_unit = arg1 }))))
|
1697
|
| _::xs -> loop xs _state in
|
1698
|
loop xs
|
1699
|
((Result.Error "Vhdl_ast.vhdl_expr_t.value"),
|
1700
|
(Result.Ok ""))
|
1701
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
|
1702
|
| `List ((`String "Sig")::arg0::[]) ->
|
1703
|
((function
|
1704
|
| `Assoc xs ->
|
1705
|
let rec loop xs ((arg0,arg1) as _state) =
|
1706
|
match xs with
|
1707
|
| ("name",x)::xs ->
|
1708
|
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1)
|
1709
|
| ("att",x)::xs ->
|
1710
|
loop xs
|
1711
|
(arg0,
|
1712
|
((function
|
1713
|
| `Null -> Result.Ok None
|
1714
|
| x ->
|
1715
|
((fun x ->
|
1716
|
vhdl_signal_attributes_t_of_yojson x) x)
|
1717
|
>>= ((fun x -> Result.Ok (Some x)))) x))
|
1718
|
| [] ->
|
1719
|
arg1 >>=
|
1720
|
((fun arg1 ->
|
1721
|
arg0 >>=
|
1722
|
(fun arg0 ->
|
1723
|
Result.Ok (Sig { name = arg0; att = arg1 }))))
|
1724
|
| _::xs -> loop xs _state in
|
1725
|
loop xs
|
1726
|
((Result.Error "Vhdl_ast.vhdl_expr_t.name"),
|
1727
|
(Result.Ok None))
|
1728
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
|
1729
|
| `List ((`String "SuffixMod")::arg0::[]) ->
|
1730
|
((function
|
1731
|
| `Assoc xs ->
|
1732
|
let rec loop xs ((arg0,arg1) as _state) =
|
1733
|
match xs with
|
1734
|
| ("expr",x)::xs ->
|
1735
|
loop xs (((fun x -> vhdl_expr_t_of_yojson x) x), arg1)
|
1736
|
| ("selection",x)::xs ->
|
1737
|
loop xs
|
1738
|
(arg0,
|
1739
|
((fun x -> vhdl_suffix_selection_t_of_yojson x) x))
|
1740
|
| [] ->
|
1741
|
arg1 >>=
|
1742
|
((fun arg1 ->
|
1743
|
arg0 >>=
|
1744
|
(fun arg0 ->
|
1745
|
Result.Ok
|
1746
|
(SuffixMod
|
1747
|
{ expr = arg0; selection = arg1 }))))
|
1748
|
| _::xs -> loop xs _state in
|
1749
|
loop xs
|
1750
|
((Result.Error "Vhdl_ast.vhdl_expr_t.expr"),
|
1751
|
(Result.Error "Vhdl_ast.vhdl_expr_t.selection"))
|
1752
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
|
1753
|
| `List ((`String "AGGREGATE")::arg0::[]) ->
|
1754
|
((function
|
1755
|
| `Assoc xs ->
|
1756
|
let rec loop xs (arg0 as _state) =
|
1757
|
match xs with
|
1758
|
| ("elems",x)::xs ->
|
1759
|
loop xs
|
1760
|
((function
|
1761
|
| `List xs ->
|
1762
|
map_bind
|
1763
|
(fun x -> vhdl_element_assoc_t_of_yojson x)
|
1764
|
[] xs
|
1765
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t.elems") x)
|
1766
|
| [] ->
|
1767
|
arg0 >>=
|
1768
|
((fun arg0 -> Result.Ok (Aggregate { elems = arg0 })))
|
1769
|
| _::xs -> loop xs _state in
|
1770
|
loop xs (Result.Ok [])
|
1771
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
|
1772
|
| `List ((`String "QUALIFIED_EXPRESSION")::arg0::[]) ->
|
1773
|
((function
|
1774
|
| `Assoc xs ->
|
1775
|
let rec loop xs ((arg0,arg1,arg2) as _state) =
|
1776
|
match xs with
|
1777
|
| ("type_mark",x)::xs ->
|
1778
|
loop xs
|
1779
|
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2)
|
1780
|
| ("aggregate",x)::xs ->
|
1781
|
loop xs
|
1782
|
(arg0,
|
1783
|
((function
|
1784
|
| `List xs ->
|
1785
|
map_bind
|
1786
|
(fun x -> vhdl_element_assoc_t_of_yojson x)
|
1787
|
[] xs
|
1788
|
| _ ->
|
1789
|
Result.Error "Vhdl_ast.vhdl_expr_t.aggregate")
|
1790
|
x), arg2)
|
1791
|
| ("expression",x)::xs ->
|
1792
|
loop xs
|
1793
|
(arg0, arg1,
|
1794
|
((function
|
1795
|
| `Null -> Result.Ok None
|
1796
|
| x ->
|
1797
|
((fun x -> vhdl_expr_t_of_yojson x) x) >>=
|
1798
|
((fun x -> Result.Ok (Some x)))) x))
|
1799
|
| [] ->
|
1800
|
arg2 >>=
|
1801
|
((fun arg2 ->
|
1802
|
arg1 >>=
|
1803
|
(fun arg1 ->
|
1804
|
arg0 >>=
|
1805
|
(fun arg0 ->
|
1806
|
Result.Ok
|
1807
|
(QualifiedExpression
|
1808
|
{
|
1809
|
type_mark = arg0;
|
1810
|
aggregate = arg1;
|
1811
|
expression = arg2
|
1812
|
})))))
|
1813
|
| _::xs -> loop xs _state in
|
1814
|
loop xs
|
1815
|
((Result.Error "Vhdl_ast.vhdl_expr_t.type_mark"),
|
1816
|
(Result.Ok []), (Result.Ok None))
|
1817
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
|
1818
|
| `List ((`String "OTHERS")::[]) -> Result.Ok Others
|
1819
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")
|
1820
|
[@ocaml.warning "-A"])
|
1821
|
|
1822
|
and (vhdl_name_t_to_yojson : vhdl_name_t -> Yojson.Safe.json) =
|
1823
|
((let open! Ppx_deriving_yojson_runtime in
|
1824
|
function
|
1825
|
| Simple arg0 ->
|
1826
|
`List
|
1827
|
[`String "SIMPLE_NAME";
|
1828
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0]
|
1829
|
| Identifier arg0 ->
|
1830
|
`List
|
1831
|
[`String "IDENTIFIER";
|
1832
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0]
|
1833
|
| Selected arg0 ->
|
1834
|
`List
|
1835
|
[`String "SELECTED_NAME";
|
1836
|
((fun x ->
|
1837
|
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x))) arg0]
|
1838
|
| Index arg0 ->
|
1839
|
`List
|
1840
|
[`String "INDEXED_NAME";
|
1841
|
(let fields = [] in
|
1842
|
let fields =
|
1843
|
("exprs",
|
1844
|
((fun x ->
|
1845
|
`List (List.map (fun x -> vhdl_expr_t_to_yojson x) x))
|
1846
|
arg0.exprs))
|
1847
|
:: fields in
|
1848
|
let fields =
|
1849
|
("id", ((fun x -> vhdl_name_t_to_yojson x) arg0.id)) ::
|
1850
|
fields in
|
1851
|
`Assoc fields)]
|
1852
|
| Slice arg0 ->
|
1853
|
`List
|
1854
|
[`String "SLICE_NAME";
|
1855
|
(let fields = [] in
|
1856
|
let fields =
|
1857
|
("range",
|
1858
|
((fun x -> vhdl_discrete_range_t_to_yojson x) arg0.range))
|
1859
|
:: fields in
|
1860
|
let fields =
|
1861
|
("id", ((fun x -> vhdl_name_t_to_yojson x) arg0.id)) ::
|
1862
|
fields in
|
1863
|
`Assoc fields)]
|
1864
|
| Attribute arg0 ->
|
1865
|
`List
|
1866
|
[`String "ATTRIBUTE_NAME";
|
1867
|
(let fields = [] in
|
1868
|
let fields =
|
1869
|
if arg0.expr = IsNull
|
1870
|
then fields
|
1871
|
else
|
1872
|
("expr", (((fun x -> vhdl_expr_t_to_yojson x)) arg0.expr))
|
1873
|
:: fields
|
1874
|
in
|
1875
|
let fields =
|
1876
|
("designator",
|
1877
|
((fun x -> vhdl_name_t_to_yojson x) arg0.designator))
|
1878
|
:: fields in
|
1879
|
let fields =
|
1880
|
("id", ((fun x -> vhdl_name_t_to_yojson x) arg0.id)) ::
|
1881
|
fields in
|
1882
|
`Assoc fields)]
|
1883
|
| Function arg0 ->
|
1884
|
`List
|
1885
|
[`String "FUNCTION_CALL";
|
1886
|
(let fields = [] in
|
1887
|
let fields =
|
1888
|
("assoc_list",
|
1889
|
((fun x ->
|
1890
|
`List
|
1891
|
(List.map (fun x -> vhdl_assoc_element_t_to_yojson x)
|
1892
|
x)) arg0.assoc_list))
|
1893
|
:: fields in
|
1894
|
let fields =
|
1895
|
("id", ((fun x -> vhdl_name_t_to_yojson x) arg0.id)) ::
|
1896
|
fields in
|
1897
|
`Assoc fields)]
|
1898
|
| NoName -> `List [`String "NoName"])
|
1899
|
[@ocaml.warning "-A"])
|
1900
|
|
1901
|
and (vhdl_name_t_of_yojson :
|
1902
|
Yojson.Safe.json -> vhdl_name_t Ppx_deriving_yojson_runtime.error_or)
|
1903
|
=
|
1904
|
((let open! Ppx_deriving_yojson_runtime in
|
1905
|
function
|
1906
|
| `List ((`String "SIMPLE_NAME")::arg0::[]) ->
|
1907
|
((function
|
1908
|
| `String x -> Result.Ok x
|
1909
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
|
1910
|
((fun arg0 -> Result.Ok (Simple arg0)))
|
1911
|
| `List ((`String "IDENTIFIER")::arg0::[]) ->
|
1912
|
((function
|
1913
|
| `String x -> Result.Ok x
|
1914
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
|
1915
|
((fun arg0 -> Result.Ok (Identifier arg0)))
|
1916
|
| `List ((`String "SELECTED_NAME")::arg0::[]) ->
|
1917
|
((function
|
1918
|
| `List xs -> map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs
|
1919
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
|
1920
|
((fun arg0 -> Result.Ok (Selected arg0)))
|
1921
|
| `List ((`String "INDEXED_NAME")::arg0::[]) ->
|
1922
|
((function
|
1923
|
| `Assoc xs ->
|
1924
|
let rec loop xs ((arg0,arg1) as _state) =
|
1925
|
match xs with
|
1926
|
| ("id",x)::xs ->
|
1927
|
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1)
|
1928
|
| ("exprs",x)::xs ->
|
1929
|
loop xs
|
1930
|
(arg0,
|
1931
|
((function
|
1932
|
| `List xs ->
|
1933
|
map_bind (fun x -> vhdl_expr_t_of_yojson x)
|
1934
|
[] xs
|
1935
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t.exprs")
|
1936
|
x))
|
1937
|
| [] ->
|
1938
|
arg1 >>=
|
1939
|
((fun arg1 ->
|
1940
|
arg0 >>=
|
1941
|
(fun arg0 ->
|
1942
|
Result.Ok
|
1943
|
(Index { id = arg0; exprs = arg1 }))))
|
1944
|
| _::xs -> loop xs _state in
|
1945
|
loop xs
|
1946
|
((Result.Error "Vhdl_ast.vhdl_name_t.id"),
|
1947
|
(Result.Error "Vhdl_ast.vhdl_name_t.exprs"))
|
1948
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
|
1949
|
| `List ((`String "SLICE_NAME")::arg0::[]) ->
|
1950
|
((function
|
1951
|
| `Assoc xs ->
|
1952
|
let rec loop xs ((arg0,arg1) as _state) =
|
1953
|
match xs with
|
1954
|
| ("id",x)::xs ->
|
1955
|
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1)
|
1956
|
| ("range",x)::xs ->
|
1957
|
loop xs
|
1958
|
(arg0,
|
1959
|
((fun x -> vhdl_discrete_range_t_of_yojson x) x))
|
1960
|
| [] ->
|
1961
|
arg1 >>=
|
1962
|
((fun arg1 ->
|
1963
|
arg0 >>=
|
1964
|
(fun arg0 ->
|
1965
|
Result.Ok
|
1966
|
(Slice { id = arg0; range = arg1 }))))
|
1967
|
| _::xs -> loop xs _state in
|
1968
|
loop xs
|
1969
|
((Result.Error "Vhdl_ast.vhdl_name_t.id"),
|
1970
|
(Result.Error "Vhdl_ast.vhdl_name_t.range"))
|
1971
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
|
1972
|
| `List ((`String "ATTRIBUTE_NAME")::arg0::[]) ->
|
1973
|
((function
|
1974
|
| `Assoc xs ->
|
1975
|
let rec loop xs ((arg0,arg1,arg2) as _state) =
|
1976
|
match xs with
|
1977
|
| ("id",x)::xs ->
|
1978
|
loop xs
|
1979
|
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2)
|
1980
|
| ("designator",x)::xs ->
|
1981
|
loop xs
|
1982
|
(arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2)
|
1983
|
| ("expr",x)::xs ->
|
1984
|
loop xs
|
1985
|
(arg0, arg1, ((fun x -> vhdl_expr_t_of_yojson x) x))
|
1986
|
| [] ->
|
1987
|
arg2 >>=
|
1988
|
((fun arg2 ->
|
1989
|
arg1 >>=
|
1990
|
(fun arg1 ->
|
1991
|
arg0 >>=
|
1992
|
(fun arg0 ->
|
1993
|
Result.Ok
|
1994
|
(Attribute
|
1995
|
{
|
1996
|
id = arg0;
|
1997
|
designator = arg1;
|
1998
|
expr = arg2
|
1999
|
})))))
|
2000
|
| _::xs -> loop xs _state in
|
2001
|
loop xs
|
2002
|
((Result.Error "Vhdl_ast.vhdl_name_t.id"),
|
2003
|
(Result.Error "Vhdl_ast.vhdl_name_t.designator"),
|
2004
|
(Result.Ok IsNull))
|
2005
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
|
2006
|
| `List ((`String "FUNCTION_CALL")::arg0::[]) ->
|
2007
|
((function
|
2008
|
| `Assoc xs ->
|
2009
|
let rec loop xs ((arg0,arg1) as _state) =
|
2010
|
match xs with
|
2011
|
| ("id",x)::xs ->
|
2012
|
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1)
|
2013
|
| ("assoc_list",x)::xs ->
|
2014
|
loop xs
|
2015
|
(arg0,
|
2016
|
((function
|
2017
|
| `List xs ->
|
2018
|
map_bind
|
2019
|
(fun x -> vhdl_assoc_element_t_of_yojson x)
|
2020
|
[] xs
|
2021
|
| _ ->
|
2022
|
Result.Error
|
2023
|
"Vhdl_ast.vhdl_name_t.assoc_list") x))
|
2024
|
| [] ->
|
2025
|
arg1 >>=
|
2026
|
((fun arg1 ->
|
2027
|
arg0 >>=
|
2028
|
(fun arg0 ->
|
2029
|
Result.Ok
|
2030
|
(Function { id = arg0; assoc_list = arg1 }))))
|
2031
|
| _::xs -> loop xs _state in
|
2032
|
loop xs
|
2033
|
((Result.Error "Vhdl_ast.vhdl_name_t.id"),
|
2034
|
(Result.Error "Vhdl_ast.vhdl_name_t.assoc_list"))
|
2035
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
|
2036
|
| `List ((`String "NoName")::[]) -> Result.Ok NoName
|
2037
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t")
|
2038
|
[@ocaml.warning "-A"])
|
2039
|
|
2040
|
and (vhdl_assoc_element_t_to_yojson :
|
2041
|
vhdl_assoc_element_t -> Yojson.Safe.json)
|
2042
|
=
|
2043
|
((let open! Ppx_deriving_yojson_runtime in
|
2044
|
fun x ->
|
2045
|
let fields = [] in
|
2046
|
let fields =
|
2047
|
if x.actual_expr = None
|
2048
|
then fields
|
2049
|
else
|
2050
|
("actual_expr",
|
2051
|
(((function
|
2052
|
| None -> `Null
|
2053
|
| Some x -> ((fun x -> vhdl_expr_t_to_yojson x)) x))
|
2054
|
x.actual_expr))
|
2055
|
:: fields
|
2056
|
in
|
2057
|
let fields =
|
2058
|
if x.actual_designator = None
|
2059
|
then fields
|
2060
|
else
|
2061
|
("actual_designator",
|
2062
|
(((function
|
2063
|
| None -> `Null
|
2064
|
| Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x))
|
2065
|
x.actual_designator))
|
2066
|
:: fields
|
2067
|
in
|
2068
|
let fields =
|
2069
|
if x.actual_name = None
|
2070
|
then fields
|
2071
|
else
|
2072
|
("actual_name",
|
2073
|
(((function
|
2074
|
| None -> `Null
|
2075
|
| Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x))
|
2076
|
x.actual_name))
|
2077
|
:: fields
|
2078
|
in
|
2079
|
let fields =
|
2080
|
if x.formal_arg = None
|
2081
|
then fields
|
2082
|
else
|
2083
|
("formal_arg",
|
2084
|
(((function
|
2085
|
| None -> `Null
|
2086
|
| Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x))
|
2087
|
x.formal_arg))
|
2088
|
:: fields
|
2089
|
in
|
2090
|
let fields =
|
2091
|
if x.formal_name = None
|
2092
|
then fields
|
2093
|
else
|
2094
|
("formal_name",
|
2095
|
(((function
|
2096
|
| None -> `Null
|
2097
|
| Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x))
|
2098
|
x.formal_name))
|
2099
|
:: fields
|
2100
|
in
|
2101
|
`Assoc fields)
|
2102
|
[@ocaml.warning "-A"])
|
2103
|
|
2104
|
and (vhdl_assoc_element_t_of_yojson :
|
2105
|
Yojson.Safe.json ->
|
2106
|
vhdl_assoc_element_t Ppx_deriving_yojson_runtime.error_or)
|
2107
|
=
|
2108
|
((let open! Ppx_deriving_yojson_runtime in
|
2109
|
function
|
2110
|
| `Assoc xs ->
|
2111
|
let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
|
2112
|
match xs with
|
2113
|
| ("formal_name",x)::xs ->
|
2114
|
loop xs
|
2115
|
(((function
|
2116
|
| `Null -> Result.Ok None
|
2117
|
| x ->
|
2118
|
((fun x -> vhdl_name_t_of_yojson x) x) >>=
|
2119
|
((fun x -> Result.Ok (Some x)))) x), arg1, arg2,
|
2120
|
arg3, arg4)
|
2121
|
| ("formal_arg",x)::xs ->
|
2122
|
loop xs
|
2123
|
(arg0,
|
2124
|
((function
|
2125
|
| `Null -> Result.Ok None
|
2126
|
| x ->
|
2127
|
((fun x -> vhdl_name_t_of_yojson x) x) >>=
|
2128
|
((fun x -> Result.Ok (Some x)))) x), arg2, arg3,
|
2129
|
arg4)
|
2130
|
| ("actual_name",x)::xs ->
|
2131
|
loop xs
|
2132
|
(arg0, arg1,
|
2133
|
((function
|
2134
|
| `Null -> Result.Ok None
|
2135
|
| x ->
|
2136
|
((fun x -> vhdl_name_t_of_yojson x) x) >>=
|
2137
|
((fun x -> Result.Ok (Some x)))) x), arg3, arg4)
|
2138
|
| ("actual_designator",x)::xs ->
|
2139
|
loop xs
|
2140
|
(arg0, arg1, arg2,
|
2141
|
((function
|
2142
|
| `Null -> Result.Ok None
|
2143
|
| x ->
|
2144
|
((fun x -> vhdl_name_t_of_yojson x) x) >>=
|
2145
|
((fun x -> Result.Ok (Some x)))) x), arg4)
|
2146
|
| ("actual_expr",x)::xs ->
|
2147
|
loop xs
|
2148
|
(arg0, arg1, arg2, arg3,
|
2149
|
((function
|
2150
|
| `Null -> Result.Ok None
|
2151
|
| x ->
|
2152
|
((fun x -> vhdl_expr_t_of_yojson x) x) >>=
|
2153
|
((fun x -> Result.Ok (Some x)))) x))
|
2154
|
| [] ->
|
2155
|
arg4 >>=
|
2156
|
((fun arg4 ->
|
2157
|
arg3 >>=
|
2158
|
(fun arg3 ->
|
2159
|
arg2 >>=
|
2160
|
(fun arg2 ->
|
2161
|
arg1 >>=
|
2162
|
(fun arg1 ->
|
2163
|
arg0 >>=
|
2164
|
(fun arg0 ->
|
2165
|
Result.Ok
|
2166
|
{
|
2167
|
formal_name = arg0;
|
2168
|
formal_arg = arg1;
|
2169
|
actual_name = arg2;
|
2170
|
actual_designator = arg3;
|
2171
|
actual_expr = arg4
|
2172
|
}))))))
|
2173
|
| _::xs -> loop xs _state in
|
2174
|
loop xs
|
2175
|
((Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
|
2176
|
(Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
|
2177
|
(Result.Ok (Some IsNull)))
|
2178
|
| _ -> Result.Error "Vhdl_ast.vhdl_assoc_element_t")
|
2179
|
[@ocaml.warning "-A"])
|
2180
|
|
2181
|
and (vhdl_element_assoc_t_to_yojson :
|
2182
|
vhdl_element_assoc_t -> Yojson.Safe.json)
|
2183
|
=
|
2184
|
((let open! Ppx_deriving_yojson_runtime in
|
2185
|
fun x ->
|
2186
|
let fields = [] in
|
2187
|
let fields = ("expr", ((fun x -> vhdl_expr_t_to_yojson x) x.expr))
|
2188
|
:: fields in
|
2189
|
let fields =
|
2190
|
if x.choices = []
|
2191
|
then fields
|
2192
|
else
|
2193
|
("choices",
|
2194
|
(((fun x ->
|
2195
|
`List (List.map (fun x -> vhdl_expr_t_to_yojson x) x)))
|
2196
|
x.choices))
|
2197
|
:: fields
|
2198
|
in
|
2199
|
`Assoc fields)
|
2200
|
[@ocaml.warning "-A"])
|
2201
|
|
2202
|
and (vhdl_element_assoc_t_of_yojson :
|
2203
|
Yojson.Safe.json ->
|
2204
|
vhdl_element_assoc_t Ppx_deriving_yojson_runtime.error_or)
|
2205
|
=
|
2206
|
((let open! Ppx_deriving_yojson_runtime in
|
2207
|
function
|
2208
|
| `Assoc xs ->
|
2209
|
let rec loop xs ((arg0,arg1) as _state) =
|
2210
|
match xs with
|
2211
|
| ("choices",x)::xs ->
|
2212
|
loop xs
|
2213
|
(((function
|
2214
|
| `List xs ->
|
2215
|
map_bind (fun x -> vhdl_expr_t_of_yojson x) [] xs
|
2216
|
| _ ->
|
2217
|
Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices")
|
2218
|
x), arg1)
|
2219
|
| ("expr",x)::xs ->
|
2220
|
loop xs (arg0, ((fun x -> vhdl_expr_t_of_yojson x) x))
|
2221
|
| [] ->
|
2222
|
arg1 >>=
|
2223
|
((fun arg1 ->
|
2224
|
arg0 >>=
|
2225
|
(fun arg0 ->
|
2226
|
Result.Ok { choices = arg0; expr = arg1 })))
|
2227
|
| _::xs -> loop xs _state in
|
2228
|
loop xs
|
2229
|
((Result.Ok []),
|
2230
|
(Result.Error "Vhdl_ast.vhdl_element_assoc_t.expr"))
|
2231
|
| _ -> Result.Error "Vhdl_ast.vhdl_element_assoc_t")
|
2232
|
[@ocaml.warning "-A"])
|
2233
|
|
2234
|
and (vhdl_array_attributes_t_to_yojson :
|
2235
|
vhdl_array_attributes_t -> Yojson.Safe.json)
|
2236
|
=
|
2237
|
((let open! Ppx_deriving_yojson_runtime in
|
2238
|
function
|
2239
|
| AAttInt arg0 ->
|
2240
|
`List
|
2241
|
[`String "AAttInt";
|
2242
|
(let fields = [] in
|
2243
|
let fields =
|
2244
|
("arg",
|
2245
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x) arg0.arg))
|
2246
|
:: fields in
|
2247
|
let fields =
|
2248
|
("id",
|
2249
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)
|
2250
|
arg0.id))
|
2251
|
:: fields in
|
2252
|
`Assoc fields)]
|
2253
|
| AAttAscending -> `List [`String "AAttAscending"])
|
2254
|
[@ocaml.warning "-A"])
|
2255
|
|
2256
|
and (vhdl_array_attributes_t_of_yojson :
|
2257
|
Yojson.Safe.json ->
|
2258
|
vhdl_array_attributes_t Ppx_deriving_yojson_runtime.error_or)
|
2259
|
=
|
2260
|
((let open! Ppx_deriving_yojson_runtime in
|
2261
|
function
|
2262
|
| `List ((`String "AAttInt")::arg0::[]) ->
|
2263
|
((function
|
2264
|
| `Assoc xs ->
|
2265
|
let rec loop xs ((arg0,arg1) as _state) =
|
2266
|
match xs with
|
2267
|
| ("id",x)::xs ->
|
2268
|
loop xs
|
2269
|
(((function
|
2270
|
| `String x -> Result.Ok x
|
2271
|
| _ ->
|
2272
|
Result.Error
|
2273
|
"Vhdl_ast.vhdl_array_attributes_t.id") x),
|
2274
|
arg1)
|
2275
|
| ("arg",x)::xs ->
|
2276
|
loop xs
|
2277
|
(arg0,
|
2278
|
((function
|
2279
|
| `Int x -> Result.Ok x
|
2280
|
| _ ->
|
2281
|
Result.Error
|
2282
|
"Vhdl_ast.vhdl_array_attributes_t.arg") x))
|
2283
|
| [] ->
|
2284
|
arg1 >>=
|
2285
|
((fun arg1 ->
|
2286
|
arg0 >>=
|
2287
|
(fun arg0 ->
|
2288
|
Result.Ok
|
2289
|
(AAttInt { id = arg0; arg = arg1 }))))
|
2290
|
| _::xs -> loop xs _state in
|
2291
|
loop xs
|
2292
|
((Result.Error "Vhdl_ast.vhdl_array_attributes_t.id"),
|
2293
|
(Result.Error "Vhdl_ast.vhdl_array_attributes_t.arg"))
|
2294
|
| _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")) arg0
|
2295
|
| `List ((`String "AAttAscending")::[]) -> Result.Ok AAttAscending
|
2296
|
| _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")
|
2297
|
[@ocaml.warning "-A"])
|
2298
|
|
2299
|
and (vhdl_signal_attributes_t_to_yojson :
|
2300
|
vhdl_signal_attributes_t -> Yojson.Safe.json)
|
2301
|
=
|
2302
|
((let open! Ppx_deriving_yojson_runtime in
|
2303
|
function
|
2304
|
| SigAtt arg0 ->
|
2305
|
`List
|
2306
|
[`String "SigAtt";
|
2307
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0])
|
2308
|
[@ocaml.warning "-A"])
|
2309
|
|
2310
|
and (vhdl_signal_attributes_t_of_yojson :
|
2311
|
Yojson.Safe.json ->
|
2312
|
vhdl_signal_attributes_t Ppx_deriving_yojson_runtime.error_or)
|
2313
|
=
|
2314
|
((let open! Ppx_deriving_yojson_runtime in
|
2315
|
function
|
2316
|
| `List ((`String "SigAtt")::arg0::[]) ->
|
2317
|
((function
|
2318
|
| `String x -> Result.Ok x
|
2319
|
| _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t") arg0)
|
2320
|
>>= ((fun arg0 -> Result.Ok (SigAtt arg0)))
|
2321
|
| _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t")
|
2322
|
[@ocaml.warning "-A"])
|
2323
|
|
2324
|
and (vhdl_string_attributes_t_to_yojson :
|
2325
|
vhdl_string_attributes_t -> Yojson.Safe.json)
|
2326
|
=
|
2327
|
((let open! Ppx_deriving_yojson_runtime in
|
2328
|
function
|
2329
|
| StringAtt arg0 ->
|
2330
|
`List
|
2331
|
[`String "StringAtt";
|
2332
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0])
|
2333
|
[@ocaml.warning "-A"])
|
2334
|
|
2335
|
and (vhdl_string_attributes_t_of_yojson :
|
2336
|
Yojson.Safe.json ->
|
2337
|
vhdl_string_attributes_t Ppx_deriving_yojson_runtime.error_or)
|
2338
|
=
|
2339
|
((let open! Ppx_deriving_yojson_runtime in
|
2340
|
function
|
2341
|
| `List ((`String "StringAtt")::arg0::[]) ->
|
2342
|
((function
|
2343
|
| `String x -> Result.Ok x
|
2344
|
| _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t") arg0)
|
2345
|
>>= ((fun arg0 -> Result.Ok (StringAtt arg0)))
|
2346
|
| _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t")
|
2347
|
[@ocaml.warning "-A"])
|
2348
|
|
2349
|
and (vhdl_suffix_selection_t_to_yojson :
|
2350
|
vhdl_suffix_selection_t -> Yojson.Safe.json)
|
2351
|
=
|
2352
|
((let open! Ppx_deriving_yojson_runtime in
|
2353
|
function
|
2354
|
| Idx arg0 ->
|
2355
|
`List
|
2356
|
[`String "Idx";
|
2357
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg0]
|
2358
|
| SuffixRange (arg0,arg1) ->
|
2359
|
`List
|
2360
|
[`String "SuffixRange";
|
2361
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg0;
|
2362
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg1])
|
2363
|
[@ocaml.warning "-A"])
|
2364
|
|
2365
|
and (vhdl_suffix_selection_t_of_yojson :
|
2366
|
Yojson.Safe.json ->
|
2367
|
vhdl_suffix_selection_t Ppx_deriving_yojson_runtime.error_or)
|
2368
|
=
|
2369
|
((let open! Ppx_deriving_yojson_runtime in
|
2370
|
function
|
2371
|
| `List ((`String "Idx")::arg0::[]) ->
|
2372
|
((function
|
2373
|
| `Int x -> Result.Ok x
|
2374
|
| _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg0) >>=
|
2375
|
((fun arg0 -> Result.Ok (Idx arg0)))
|
2376
|
| `List ((`String "SuffixRange")::arg0::arg1::[]) ->
|
2377
|
((function
|
2378
|
| `Int x -> Result.Ok x
|
2379
|
| _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg1) >>=
|
2380
|
((fun arg1 ->
|
2381
|
((function
|
2382
|
| `Int x -> Result.Ok x
|
2383
|
| _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
|
2384
|
arg0)
|
2385
|
>>= (fun arg0 -> Result.Ok (SuffixRange (arg0, arg1)))))
|
2386
|
| _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
|
2387
|
[@ocaml.warning "-A"])
|
2388
|
|
2389
|
type 'basetype vhdl_type_attributes_t =
|
2390
|
| TAttNoArg of {
|
2391
|
id: string }
|
2392
|
| TAttIntArg of {
|
2393
|
id: string ;
|
2394
|
arg: int }
|
2395
|
| TAttValArg of {
|
2396
|
id: string ;
|
2397
|
arg: 'basetype }
|
2398
|
| TAttStringArg of {
|
2399
|
id: string ;
|
2400
|
arg: string }
|
2401
|
|
2402
|
(* TODO *)
|
2403
|
let rec pp_vhdl_type_attributes_t
|
2404
|
=
|
2405
|
((let open! Ppx_deriving_runtime in
|
2406
|
fun poly_basetype ->
|
2407
|
fun fmt ->
|
2408
|
function
|
2409
|
| TAttNoArg { id = aid } ->
|
2410
|
(Format.fprintf fmt "@[<2>TAttNoArg {@,";
|
2411
|
(Format.fprintf fmt "@[%s =@ " "id";
|
2412
|
(Format.fprintf fmt "%S") aid;
|
2413
|
Format.fprintf fmt "@]");
|
2414
|
Format.fprintf fmt "@]}")
|
2415
|
| TAttIntArg { id = aid; arg = aarg } ->
|
2416
|
(Format.fprintf fmt "@[<2>TAttIntArg {@,";
|
2417
|
((Format.fprintf fmt "@[%s =@ " "id";
|
2418
|
(Format.fprintf fmt "%S") aid;
|
2419
|
Format.fprintf fmt "@]");
|
2420
|
Format.fprintf fmt ";@ ";
|
2421
|
Format.fprintf fmt "@[%s =@ " "arg";
|
2422
|
(Format.fprintf fmt "%d") aarg;
|
2423
|
Format.fprintf fmt "@]");
|
2424
|
Format.fprintf fmt "@]}")
|
2425
|
| TAttValArg { id = aid; arg = aarg } ->
|
2426
|
(Format.fprintf fmt "@[<2>TAttValArg {@,";
|
2427
|
((Format.fprintf fmt "@[%s =@ " "id";
|
2428
|
(Format.fprintf fmt "%S") aid;
|
2429
|
Format.fprintf fmt "@]");
|
2430
|
Format.fprintf fmt ";@ ";
|
2431
|
Format.fprintf fmt "@[%s =@ " "arg";
|
2432
|
(poly_basetype fmt) aarg;
|
2433
|
Format.fprintf fmt "@]");
|
2434
|
Format.fprintf fmt "@]}")
|
2435
|
| TAttStringArg { id = aid; arg = aarg } ->
|
2436
|
(Format.fprintf fmt "@[<2>TAttStringArg {@,";
|
2437
|
((Format.fprintf fmt "@[%s =@ " "id";
|
2438
|
(Format.fprintf fmt "%S") aid;
|
2439
|
Format.fprintf fmt "@]");
|
2440
|
Format.fprintf fmt ";@ ";
|
2441
|
Format.fprintf fmt "@[%s =@ " "arg";
|
2442
|
(Format.fprintf fmt "%S") aarg;
|
2443
|
Format.fprintf fmt "@]");
|
2444
|
Format.fprintf fmt "@]}"))
|
2445
|
[@ocaml.warning "-A"])
|
2446
|
|
2447
|
and show_vhdl_type_attributes_t =
|
2448
|
fun poly_basetype ->
|
2449
|
fun x ->
|
2450
|
Format.asprintf "%a" (pp_vhdl_type_attributes_t poly_basetype) x
|
2451
|
|
2452
|
let rec vhdl_type_attributes_t_to_yojson :
|
2453
|
'basetype .
|
2454
|
('basetype -> Yojson.Safe.json) ->
|
2455
|
'basetype vhdl_type_attributes_t -> Yojson.Safe.json
|
2456
|
=
|
2457
|
fun poly_basetype ->
|
2458
|
((let open! Ppx_deriving_yojson_runtime in
|
2459
|
function
|
2460
|
| TAttNoArg arg0 ->
|
2461
|
`List
|
2462
|
[`String "TAttNoArg";
|
2463
|
(let fields = [] in
|
2464
|
let fields =
|
2465
|
("id",
|
2466
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)
|
2467
|
arg0.id))
|
2468
|
:: fields in
|
2469
|
`Assoc fields)]
|
2470
|
| TAttIntArg arg0 ->
|
2471
|
`List
|
2472
|
[`String "TAttIntArg";
|
2473
|
(let fields = [] in
|
2474
|
let fields =
|
2475
|
("arg",
|
2476
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x) arg0.arg))
|
2477
|
:: fields in
|
2478
|
let fields =
|
2479
|
("id",
|
2480
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)
|
2481
|
arg0.id))
|
2482
|
:: fields in
|
2483
|
`Assoc fields)]
|
2484
|
| TAttValArg arg0 ->
|
2485
|
`List
|
2486
|
[`String "TAttValArg";
|
2487
|
(let fields = [] in
|
2488
|
let fields =
|
2489
|
("arg", ((poly_basetype : _ -> Yojson.Safe.json) arg0.arg))
|
2490
|
:: fields in
|
2491
|
let fields =
|
2492
|
("id",
|
2493
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)
|
2494
|
arg0.id))
|
2495
|
:: fields in
|
2496
|
`Assoc fields)]
|
2497
|
| TAttStringArg arg0 ->
|
2498
|
`List
|
2499
|
[`String "TAttStringArg";
|
2500
|
(let fields = [] in
|
2501
|
let fields =
|
2502
|
("arg",
|
2503
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)
|
2504
|
arg0.arg))
|
2505
|
:: fields in
|
2506
|
let fields =
|
2507
|
("id",
|
2508
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)
|
2509
|
arg0.id))
|
2510
|
:: fields in
|
2511
|
`Assoc fields)])
|
2512
|
[@ocaml.warning "-A"])
|
2513
|
|
2514
|
and vhdl_type_attributes_t_of_yojson :
|
2515
|
'basetype .
|
2516
|
(Yojson.Safe.json -> 'basetype Ppx_deriving_yojson_runtime.error_or) ->
|
2517
|
Yojson.Safe.json ->
|
2518
|
'basetype vhdl_type_attributes_t Ppx_deriving_yojson_runtime.error_or
|
2519
|
=
|
2520
|
fun poly_basetype ->
|
2521
|
((let open! Ppx_deriving_yojson_runtime in
|
2522
|
function
|
2523
|
| `List ((`String "TAttNoArg")::arg0::[]) ->
|
2524
|
((function
|
2525
|
| `Assoc xs ->
|
2526
|
let rec loop xs (arg0 as _state) =
|
2527
|
match xs with
|
2528
|
| ("id",x)::xs ->
|
2529
|
loop xs
|
2530
|
((function
|
2531
|
| `String x -> Result.Ok x
|
2532
|
| _ ->
|
2533
|
Result.Error
|
2534
|
"Vhdl_ast.vhdl_type_attributes_t.id") x)
|
2535
|
| [] ->
|
2536
|
arg0 >>=
|
2537
|
((fun arg0 -> Result.Ok (TAttNoArg { id = arg0 })))
|
2538
|
| _::xs -> loop xs _state in
|
2539
|
loop xs (Result.Error "Vhdl_ast.vhdl_type_attributes_t.id")
|
2540
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
|
2541
|
| `List ((`String "TAttIntArg")::arg0::[]) ->
|
2542
|
((function
|
2543
|
| `Assoc xs ->
|
2544
|
let rec loop xs ((arg0,arg1) as _state) =
|
2545
|
match xs with
|
2546
|
| ("id",x)::xs ->
|
2547
|
loop xs
|
2548
|
(((function
|
2549
|
| `String x -> Result.Ok x
|
2550
|
| _ ->
|
2551
|
Result.Error
|
2552
|
"Vhdl_ast.vhdl_type_attributes_t.id") x),
|
2553
|
arg1)
|
2554
|
| ("arg",x)::xs ->
|
2555
|
loop xs
|
2556
|
(arg0,
|
2557
|
((function
|
2558
|
| `Int x -> Result.Ok x
|
2559
|
| _ ->
|
2560
|
Result.Error
|
2561
|
"Vhdl_ast.vhdl_type_attributes_t.arg") x))
|
2562
|
| [] ->
|
2563
|
arg1 >>=
|
2564
|
((fun arg1 ->
|
2565
|
arg0 >>=
|
2566
|
(fun arg0 ->
|
2567
|
Result.Ok
|
2568
|
(TAttIntArg { id = arg0; arg = arg1 }))))
|
2569
|
| _::xs -> loop xs _state in
|
2570
|
loop xs
|
2571
|
((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
|
2572
|
(Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
|
2573
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
|
2574
|
| `List ((`String "TAttValArg")::arg0::[]) ->
|
2575
|
((function
|
2576
|
| `Assoc xs ->
|
2577
|
let rec loop xs ((arg0,arg1) as _state) =
|
2578
|
match xs with
|
2579
|
| ("id",x)::xs ->
|
2580
|
loop xs
|
2581
|
(((function
|
2582
|
| `String x -> Result.Ok x
|
2583
|
| _ ->
|
2584
|
Result.Error
|
2585
|
"Vhdl_ast.vhdl_type_attributes_t.id") x),
|
2586
|
arg1)
|
2587
|
| ("arg",x)::xs ->
|
2588
|
loop xs
|
2589
|
(arg0,
|
2590
|
((poly_basetype : Yojson.Safe.json -> _ error_or)
|
2591
|
x))
|
2592
|
| [] ->
|
2593
|
arg1 >>=
|
2594
|
((fun arg1 ->
|
2595
|
arg0 >>=
|
2596
|
(fun arg0 ->
|
2597
|
Result.Ok
|
2598
|
(TAttValArg { id = arg0; arg = arg1 }))))
|
2599
|
| _::xs -> loop xs _state in
|
2600
|
loop xs
|
2601
|
((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
|
2602
|
(Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
|
2603
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
|
2604
|
| `List ((`String "TAttStringArg")::arg0::[]) ->
|
2605
|
((function
|
2606
|
| `Assoc xs ->
|
2607
|
let rec loop xs ((arg0,arg1) as _state) =
|
2608
|
match xs with
|
2609
|
| ("id",x)::xs ->
|
2610
|
loop xs
|
2611
|
(((function
|
2612
|
| `String x -> Result.Ok x
|
2613
|
| _ ->
|
2614
|
Result.Error
|
2615
|
"Vhdl_ast.vhdl_type_attributes_t.id") x),
|
2616
|
arg1)
|
2617
|
| ("arg",x)::xs ->
|
2618
|
loop xs
|
2619
|
(arg0,
|
2620
|
((function
|
2621
|
| `String x -> Result.Ok x
|
2622
|
| _ ->
|
2623
|
Result.Error
|
2624
|
"Vhdl_ast.vhdl_type_attributes_t.arg") x))
|
2625
|
| [] ->
|
2626
|
arg1 >>=
|
2627
|
((fun arg1 ->
|
2628
|
arg0 >>=
|
2629
|
(fun arg0 ->
|
2630
|
Result.Ok
|
2631
|
(TAttStringArg { id = arg0; arg = arg1 }))))
|
2632
|
| _::xs -> loop xs _state in
|
2633
|
loop xs
|
2634
|
((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
|
2635
|
(Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
|
2636
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
|
2637
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")
|
2638
|
[@ocaml.warning "-A"])
|
2639
|
|
2640
|
let typ_att_noarg = ["base"; "left"; "right"; "high"; "low"]
|
2641
|
let typ_att_intarg = ["pos"; "val"; "succ"; "pred"; "leftof"; "rightof"]
|
2642
|
let typ_att_valarg = ["image"]
|
2643
|
let typ_att_stringarg = ["value"]
|
2644
|
let array_att_intarg =
|
2645
|
["left"; "right"; "high"; "low"; "range"; "reverse_range"; "length"]
|
2646
|
type vhdl_parameter_t =
|
2647
|
{
|
2648
|
names: vhdl_name_t list ;
|
2649
|
mode: string list [@default []];
|
2650
|
typ: vhdl_subtype_indication_t ;
|
2651
|
init_val: vhdl_cst_val_t option [@default None]}
|
2652
|
|
2653
|
(* TODO *)
|
2654
|
let rec pp_vhdl_parameter_t :
|
2655
|
Format.formatter -> vhdl_parameter_t -> Ppx_deriving_runtime.unit =
|
2656
|
let __2 () = pp_vhdl_cst_val_t
|
2657
|
|
2658
|
and __1 () = pp_vhdl_subtype_indication_t
|
2659
|
|
2660
|
and __0 () = pp_vhdl_name_t
|
2661
|
in
|
2662
|
((let open! Ppx_deriving_runtime in
|
2663
|
fun fmt ->
|
2664
|
fun x ->
|
2665
|
Format.fprintf fmt "@[<2>{ ";
|
2666
|
((((Format.fprintf fmt "@[%s =@ " "names";
|
2667
|
((fun x ->
|
2668
|
Format.fprintf fmt "@[<2>[";
|
2669
|
ignore
|
2670
|
(List.fold_left
|
2671
|
(fun sep ->
|
2672
|
fun x ->
|
2673
|
if sep then Format.fprintf fmt ";@ ";
|
2674
|
((__0 ()) fmt) x;
|
2675
|
true) false x);
|
2676
|
Format.fprintf fmt "@,]@]")) x.names;
|
2677
|
Format.fprintf fmt "@]");
|
2678
|
Format.fprintf fmt ";@ ";
|
2679
|
Format.fprintf fmt "@[%s =@ " "mode";
|
2680
|
((fun x ->
|
2681
|
Format.fprintf fmt "@[<2>[";
|
2682
|
ignore
|
2683
|
(List.fold_left
|
2684
|
(fun sep ->
|
2685
|
fun x ->
|
2686
|
if sep then Format.fprintf fmt ";@ ";
|
2687
|
(Format.fprintf fmt "%S") x;
|
2688
|
true) false x);
|
2689
|
Format.fprintf fmt "@,]@]")) x.mode;
|
2690
|
Format.fprintf fmt "@]");
|
2691
|
Format.fprintf fmt ";@ ";
|
2692
|
Format.fprintf fmt "@[%s =@ " "typ";
|
2693
|
((__1 ()) fmt) x.typ;
|
2694
|
Format.fprintf fmt "@]");
|
2695
|
Format.fprintf fmt ";@ ";
|
2696
|
Format.fprintf fmt "@[%s =@ " "init_val";
|
2697
|
((function
|
2698
|
| None -> Format.pp_print_string fmt "None"
|
2699
|
| Some x ->
|
2700
|
(Format.pp_print_string fmt "(Some ";
|
2701
|
((__2 ()) fmt) x;
|
2702
|
Format.pp_print_string fmt ")"))) x.init_val;
|
2703
|
Format.fprintf fmt "@]");
|
2704
|
Format.fprintf fmt "@ }@]")
|
2705
|
[@ocaml.warning "-A"])
|
2706
|
|
2707
|
and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string =
|
2708
|
fun x -> Format.asprintf "%a" pp_vhdl_parameter_t x
|
2709
|
|
2710
|
let rec (vhdl_parameter_t_to_yojson : vhdl_parameter_t -> Yojson.Safe.json) =
|
2711
|
((let open! Ppx_deriving_yojson_runtime in
|
2712
|
fun x ->
|
2713
|
let fields = [] in
|
2714
|
let fields =
|
2715
|
if x.init_val = None
|
2716
|
then fields
|
2717
|
else
|
2718
|
("init_val",
|
2719
|
(((function
|
2720
|
| None -> `Null
|
2721
|
| Some x -> ((fun x -> vhdl_cst_val_t_to_yojson x)) x))
|
2722
|
x.init_val))
|
2723
|
:: fields
|
2724
|
in
|
2725
|
let fields =
|
2726
|
("typ", ((fun x -> vhdl_subtype_indication_t_to_yojson x) x.typ))
|
2727
|
:: fields in
|
2728
|
let fields =
|
2729
|
if x.mode = []
|
2730
|
then fields
|
2731
|
else
|
2732
|
("mode",
|
2733
|
(((fun x ->
|
2734
|
`List
|
2735
|
(List.map
|
2736
|
(fun (x : Ppx_deriving_runtime.string) -> `String x)
|
2737
|
x))) x.mode))
|
2738
|
:: fields
|
2739
|
in
|
2740
|
let fields =
|
2741
|
("names",
|
2742
|
((fun x ->
|
2743
|
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x))
|
2744
|
x.names))
|
2745
|
:: fields in
|
2746
|
`Assoc fields)
|
2747
|
[@ocaml.warning "-A"])
|
2748
|
|
2749
|
and (vhdl_parameter_t_of_yojson :
|
2750
|
Yojson.Safe.json ->
|
2751
|
vhdl_parameter_t Ppx_deriving_yojson_runtime.error_or)
|
2752
|
=
|
2753
|
((let open! Ppx_deriving_yojson_runtime in
|
2754
|
function
|
2755
|
| `Assoc xs ->
|
2756
|
let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
|
2757
|
match xs with
|
2758
|
| ("names",x)::xs ->
|
2759
|
loop xs
|
2760
|
(((function
|
2761
|
| `List xs ->
|
2762
|
map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs
|
2763
|
| _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.names") x),
|
2764
|
arg1, arg2, arg3)
|
2765
|
| ("mode",x)::xs ->
|
2766
|
loop xs
|
2767
|
(arg0,
|
2768
|
((function
|
2769
|
| `List xs ->
|
2770
|
map_bind
|
2771
|
(function
|
2772
|
| `String x -> Result.Ok x
|
2773
|
| _ ->
|
2774
|
Result.Error
|
2775
|
"Vhdl_ast.vhdl_parameter_t.mode") [] xs
|
2776
|
| _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.mode") x),
|
2777
|
arg2, arg3)
|
2778
|
| ("typ",x)::xs ->
|
2779
|
loop xs
|
2780
|
(arg0, arg1,
|
2781
|
((fun x -> vhdl_subtype_indication_t_of_yojson x) x),
|
2782
|
arg3)
|
2783
|
| ("init_val",x)::xs ->
|
2784
|
loop xs
|
2785
|
(arg0, arg1, arg2,
|
2786
|
((function
|
2787
|
| `Null -> Result.Ok None
|
2788
|
| x ->
|
2789
|
((fun x -> vhdl_cst_val_t_of_yojson x) x) >>=
|
2790
|
((fun x -> Result.Ok (Some x)))) x))
|
2791
|
| [] ->
|
2792
|
arg3 >>=
|
2793
|
((fun arg3 ->
|
2794
|
arg2 >>=
|
2795
|
(fun arg2 ->
|
2796
|
arg1 >>=
|
2797
|
(fun arg1 ->
|
2798
|
arg0 >>=
|
2799
|
(fun arg0 ->
|
2800
|
Result.Ok
|
2801
|
{
|
2802
|
names = arg0;
|
2803
|
mode = arg1;
|
2804
|
typ = arg2;
|
2805
|
init_val = arg3
|
2806
|
})))))
|
2807
|
| _::xs -> loop xs _state in
|
2808
|
loop xs
|
2809
|
((Result.Error "Vhdl_ast.vhdl_parameter_t.names"),
|
2810
|
(Result.Ok []), (Result.Error "Vhdl_ast.vhdl_parameter_t.typ"),
|
2811
|
(Result.Ok (Some (CstInt 0))))
|
2812
|
| _ -> Result.Error "Vhdl_ast.vhdl_parameter_t")
|
2813
|
[@ocaml.warning "-A"])
|
2814
|
|
2815
|
type vhdl_subprogram_spec_t =
|
2816
|
{
|
2817
|
name: string [@default ""];
|
2818
|
subprogram_type: string [@default ""];
|
2819
|
typeMark: vhdl_name_t [@default NoName];
|
2820
|
parameters: vhdl_parameter_t list ;
|
2821
|
isPure: bool [@default false]}
|
2822
|
|
2823
|
(* TODO *)
|
2824
|
let rec pp_vhdl_subprogram_spec_t :
|
2825
|
Format.formatter -> vhdl_subprogram_spec_t -> Ppx_deriving_runtime.unit =
|
2826
|
let __1 () = pp_vhdl_parameter_t
|
2827
|
|
2828
|
and __0 () = pp_vhdl_name_t
|
2829
|
in
|
2830
|
((let open! Ppx_deriving_runtime in
|
2831
|
fun fmt ->
|
2832
|
fun x ->
|
2833
|
(match x.subprogram_type with
|
2834
|
| "function" ->
|
2835
|
if (x.isPure) then
|
2836
|
Format.fprintf fmt "pure %s" x.subprogram_type
|
2837
|
else
|
2838
|
Format.fprintf fmt "impure %s" x.subprogram_type
|
2839
|
| "procedure" ->
|
2840
|
Format.fprintf fmt "%s %s" x.subprogram_type x.name);
|
2841
|
(match x.parameters with
|
2842
|
| [] -> Format.fprintf fmt "";
|
2843
|
| _ ->
|
2844
|
Format.fprintf fmt "(@[";
|
2845
|
((fun x ->
|
2846
|
ignore
|
2847
|
(List.fold_left
|
2848
|
(fun sep ->
|
2849
|
fun x ->
|
2850
|
if sep then Format.fprintf fmt ",@ ";
|
2851
|
((__1 ()) fmt) x;
|
2852
|
true) false x))) x.parameters;
|
2853
|
Format.fprintf fmt "@])");
|
2854
|
(match x.typeMark with
|
2855
|
| NoName -> Format.fprintf fmt "";
|
2856
|
| _ ->
|
2857
|
Format.fprintf fmt "returns ";
|
2858
|
((__0 ()) fmt) x.typeMark))
|
2859
|
[@ocaml.warning "-A"])
|
2860
|
|
2861
|
and show_vhdl_subprogram_spec_t :
|
2862
|
vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string =
|
2863
|
fun x -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x
|
2864
|
|
2865
|
let rec (vhdl_subprogram_spec_t_to_yojson :
|
2866
|
vhdl_subprogram_spec_t -> Yojson.Safe.json)
|
2867
|
=
|
2868
|
((let open! Ppx_deriving_yojson_runtime in
|
2869
|
fun x ->
|
2870
|
let fields = [] in
|
2871
|
let fields =
|
2872
|
if x.isPure = false
|
2873
|
then fields
|
2874
|
else
|
2875
|
("isPure",
|
2876
|
(((fun (x : Ppx_deriving_runtime.bool) -> `Bool x)) x.isPure))
|
2877
|
:: fields
|
2878
|
in
|
2879
|
let fields =
|
2880
|
if x.parameters = []
|
2881
|
then fields
|
2882
|
else
|
2883
|
("parameters",
|
2884
|
(((fun x ->
|
2885
|
`List
|
2886
|
(List.map (fun x -> vhdl_parameter_t_to_yojson x) x)))
|
2887
|
x.parameters))
|
2888
|
:: fields
|
2889
|
in
|
2890
|
let fields =
|
2891
|
if x.typeMark = NoName
|
2892
|
then fields
|
2893
|
else
|
2894
|
("typeMark", (((fun x -> vhdl_name_t_to_yojson x)) x.typeMark))
|
2895
|
:: fields
|
2896
|
in
|
2897
|
let fields =
|
2898
|
if x.subprogram_type = ""
|
2899
|
then fields
|
2900
|
else
|
2901
|
("subprogram_type",
|
2902
|
(((fun (x : Ppx_deriving_runtime.string) -> `String x))
|
2903
|
x.subprogram_type))
|
2904
|
:: fields
|
2905
|
in
|
2906
|
let fields =
|
2907
|
if x.name = ""
|
2908
|
then fields
|
2909
|
else
|
2910
|
("name",
|
2911
|
(((fun (x : Ppx_deriving_runtime.string) -> `String x)) x.name))
|
2912
|
:: fields
|
2913
|
in
|
2914
|
`Assoc fields)
|
2915
|
[@ocaml.warning "-A"])
|
2916
|
|
2917
|
and (vhdl_subprogram_spec_t_of_yojson :
|
2918
|
Yojson.Safe.json ->
|
2919
|
vhdl_subprogram_spec_t Ppx_deriving_yojson_runtime.error_or)
|
2920
|
=
|
2921
|
((let open! Ppx_deriving_yojson_runtime in
|
2922
|
function
|
2923
|
| `Assoc xs ->
|
2924
|
let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
|
2925
|
match xs with
|
2926
|
| ("name",x)::xs ->
|
2927
|
loop xs
|
2928
|
(((function
|
2929
|
| `String x -> Result.Ok x
|
2930
|
| _ ->
|
2931
|
Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.name")
|
2932
|
x), arg1, arg2, arg3, arg4)
|
2933
|
| ("subprogram_type",x)::xs ->
|
2934
|
loop xs
|
2935
|
(arg0,
|
2936
|
((function
|
2937
|
| `String x -> Result.Ok x
|
2938
|
| _ ->
|
2939
|
Result.Error
|
2940
|
"Vhdl_ast.vhdl_subprogram_spec_t.subprogram_type")
|
2941
|
x), arg2, arg3, arg4)
|
2942
|
| ("typeMark",x)::xs ->
|
2943
|
loop xs
|
2944
|
(arg0, arg1, ((fun x -> vhdl_name_t_of_yojson x) x), arg3,
|
2945
|
arg4)
|
2946
|
| ("parameters",x)::xs ->
|
2947
|
loop xs
|
2948
|
(arg0, arg1, arg2,
|
2949
|
((function
|
2950
|
| `List xs ->
|
2951
|
map_bind (fun x -> vhdl_parameter_t_of_yojson x)
|
2952
|
[] xs
|
2953
|
| _ ->
|
2954
|
Result.Error
|
2955
|
"Vhdl_ast.vhdl_subprogram_spec_t.parameters") x),
|
2956
|
arg4)
|
2957
|
| ("isPure",x)::xs ->
|
2958
|
loop xs
|
2959
|
(arg0, arg1, arg2, arg3,
|
2960
|
((function
|
2961
|
| `Bool x -> Result.Ok x
|
2962
|
| _ ->
|
2963
|
Result.Error
|
2964
|
"Vhdl_ast.vhdl_subprogram_spec_t.isPure") x))
|
2965
|
| [] ->
|
2966
|
arg4 >>=
|
2967
|
((fun arg4 ->
|
2968
|
arg3 >>=
|
2969
|
(fun arg3 ->
|
2970
|
arg2 >>=
|
2971
|
(fun arg2 ->
|
2972
|
arg1 >>=
|
2973
|
(fun arg1 ->
|
2974
|
arg0 >>=
|
2975
|
(fun arg0 ->
|
2976
|
Result.Ok
|
2977
|
{
|
2978
|
name = arg0;
|
2979
|
subprogram_type = arg1;
|
2980
|
typeMark = arg2;
|
2981
|
parameters = arg3;
|
2982
|
isPure = arg4
|
2983
|
}))))))
|
2984
|
| _::xs -> loop xs _state in
|
2985
|
loop xs
|
2986
|
((Result.Ok ""), (Result.Ok ""), (Result.Ok NoName),
|
2987
|
(Result.Ok []), (Result.Ok false))
|
2988
|
| _ -> Result.Error "Vhdl_ast.vhdl_subprogram_spec_t")
|
2989
|
[@ocaml.warning "-A"])
|
2990
|
|
2991
|
let arith_funs = ["+"; "-"; "*"; "/"; "mod"; "rem"; "abs"; "**"; "&"]
|
2992
|
let bool_funs = ["and"; "or"; "nand"; "nor"; "xor"; "not"]
|
2993
|
let rel_funs =
|
2994
|
["<";
|
2995
|
">";
|
2996
|
"<=";
|
2997
|
">=";
|
2998
|
"/=";
|
2999
|
"=";
|
3000
|
"?=";
|
3001
|
"?/=";
|
3002
|
"?<";
|
3003
|
"?<=";
|
3004
|
"?>";
|
3005
|
"?>=";
|
3006
|
"??"]
|
3007
|
let shift_funs = ["sll"; "srl"; "sla"; "sra"; "rol"; "ror"]
|
3008
|
|
3009
|
type vhdl_waveform_element_t =
|
3010
|
{
|
3011
|
value: vhdl_expr_t option [@default None];
|
3012
|
delay: vhdl_expr_t option [@default None]}[@@deriving
|
3013
|
((show { with_path = false }),
|
3014
|
(yojson { strict = false }))]
|
3015
|
|
3016
|
let rec pp_vhdl_waveform_element_t :
|
3017
|
Format.formatter -> vhdl_waveform_element_t -> Ppx_deriving_runtime.unit =
|
3018
|
let __1 () = pp_vhdl_expr_t
|
3019
|
|
3020
|
and __0 () = pp_vhdl_expr_t
|
3021
|
in
|
3022
|
((let open! Ppx_deriving_runtime in
|
3023
|
fun fmt ->
|
3024
|
fun x ->
|
3025
|
(match x.value with
|
3026
|
| None -> Format.fprintf fmt "";
|
3027
|
| Some IsNull -> Format.fprintf fmt "null";
|
3028
|
| Some v -> ((__0 ()) fmt) v);
|
3029
|
(match x.delay with
|
3030
|
| None -> Format.fprintf fmt "";
|
3031
|
| Some v ->
|
3032
|
Format.fprintf fmt " after ";
|
3033
|
((__1 ()) fmt) v))
|
3034
|
[@ocaml.warning "-A"])
|
3035
|
|
3036
|
and show_vhdl_waveform_element_t :
|
3037
|
vhdl_waveform_element_t -> Ppx_deriving_runtime.string =
|
3038
|
fun x -> Format.asprintf "%a" pp_vhdl_waveform_element_t x
|
3039
|
|
3040
|
let rec (vhdl_waveform_element_t_to_yojson :
|
3041
|
vhdl_waveform_element_t -> Yojson.Safe.json)
|
3042
|
=
|
3043
|
((let open! Ppx_deriving_yojson_runtime in
|
3044
|
fun x ->
|
3045
|
let fields = [] in
|
3046
|
let fields =
|
3047
|
if x.delay = None
|
3048
|
then fields
|
3049
|
else
|
3050
|
("delay",
|
3051
|
(((function
|
3052
|
| None -> `Null
|
3053
|
| Some x -> ((fun x -> vhdl_expr_t_to_yojson x)) x))
|
3054
|
x.delay))
|
3055
|
:: fields
|
3056
|
in
|
3057
|
let fields =
|
3058
|
if x.value = None
|
3059
|
then fields
|
3060
|
else
|
3061
|
("value",
|
3062
|
(((function
|
3063
|
| None -> `Null
|
3064
|
| Some x -> ((fun x -> vhdl_expr_t_to_yojson x)) x))
|
3065
|
x.value))
|
3066
|
:: fields
|
3067
|
in
|
3068
|
`Assoc fields)
|
3069
|
[@ocaml.warning "-A"])
|
3070
|
|
3071
|
and (vhdl_waveform_element_t_of_yojson :
|
3072
|
Yojson.Safe.json ->
|
3073
|
vhdl_waveform_element_t Ppx_deriving_yojson_runtime.error_or)
|
3074
|
=
|
3075
|
((let open! Ppx_deriving_yojson_runtime in
|
3076
|
function
|
3077
|
| `Assoc xs ->
|
3078
|
let rec loop xs ((arg0,arg1) as _state) =
|
3079
|
match xs with
|
3080
|
| ("value",x)::xs ->
|
3081
|
loop xs
|
3082
|
(((function
|
3083
|
| `Null -> Result.Ok None
|
3084
|
| x ->
|
3085
|
((fun x -> vhdl_expr_t_of_yojson x) x) >>=
|
3086
|
((fun x -> Result.Ok (Some x)))) x), arg1)
|
3087
|
| ("delay",x)::xs ->
|
3088
|
loop xs
|
3089
|
(arg0,
|
3090
|
((function
|
3091
|
| `Null -> Result.Ok None
|
3092
|
| x ->
|
3093
|
((fun x -> vhdl_expr_t_of_yojson x) x) >>=
|
3094
|
((fun x -> Result.Ok (Some x)))) x))
|
3095
|
| [] ->
|
3096
|
arg1 >>=
|
3097
|
((fun arg1 ->
|
3098
|
arg0 >>=
|
3099
|
(fun arg0 ->
|
3100
|
Result.Ok { value = arg0; delay = arg1 })))
|
3101
|
| _::xs -> loop xs _state in
|
3102
|
loop xs ((Result.Ok None), (Result.Ok None))
|
3103
|
| _ -> Result.Error "Vhdl_ast.vhdl_waveform_element_t")
|
3104
|
[@ocaml.warning "-A"])
|
3105
|
|
3106
|
type vhdl_sequential_stmt_t =
|
3107
|
| VarAssign of
|
3108
|
{
|
3109
|
label: vhdl_name_t [@default NoName];
|
3110
|
lhs: vhdl_name_t ;
|
3111
|
rhs: vhdl_expr_t } [@name "VARIABLE_ASSIGNMENT_STATEMENT"]
|
3112
|
| SigSeqAssign of
|
3113
|
{
|
3114
|
label: vhdl_name_t [@default NoName];
|
3115
|
lhs: vhdl_name_t ;
|
3116
|
rhs: vhdl_waveform_element_t list } [@name "SIGNAL_ASSIGNMENT_STATEMENT"]
|
3117
|
| If of
|
3118
|
{
|
3119
|
label: vhdl_name_t [@default NoName];
|
3120
|
if_cases: vhdl_if_case_t list ;
|
3121
|
default: vhdl_sequential_stmt_t list [@default []]} [@name "IF_STATEMENT"]
|
3122
|
| Case of
|
3123
|
{
|
3124
|
label: vhdl_name_t [@default NoName];
|
3125
|
guard: vhdl_expr_t ;
|
3126
|
branches: vhdl_case_item_t list } [@name "CASE_STATEMENT_TREE"]
|
3127
|
| Exit of
|
3128
|
{
|
3129
|
label: vhdl_name_t [@default NoName];
|
3130
|
loop_label: string option [@default Some ""];
|
3131
|
condition: vhdl_expr_t option [@default Some IsNull]}
|
3132
|
[@name "EXIT_STATEMENT"]
|
3133
|
| Assert of
|
3134
|
{
|
3135
|
label: vhdl_name_t [@default NoName];
|
3136
|
cond: vhdl_expr_t ;
|
3137
|
report: vhdl_expr_t [@default IsNull];
|
3138
|
severity: vhdl_expr_t [@default IsNull]} [@name "ASSERTION_STATEMENT"]
|
3139
|
| ProcedureCall of
|
3140
|
{
|
3141
|
label: vhdl_name_t [@default NoName];
|
3142
|
name: vhdl_name_t ;
|
3143
|
assocs: vhdl_assoc_element_t list } [@name "PROCEDURE_CALL_STATEMENT"]
|
3144
|
| Wait [@name "WAIT_STATEMENT"]
|
3145
|
| Null of {
|
3146
|
label: vhdl_name_t [@default NoName]} [@name "NULL_STATEMENT"]
|
3147
|
| Return of {
|
3148
|
label: vhdl_name_t [@default NoName]} [@name "RETURN_STATEMENT"]
|
3149
|
and vhdl_if_case_t =
|
3150
|
{
|
3151
|
if_cond: vhdl_expr_t ;
|
3152
|
if_block: vhdl_sequential_stmt_t list }
|
3153
|
and vhdl_case_item_t =
|
3154
|
{
|
3155
|
when_cond: vhdl_expr_t list ;
|
3156
|
when_stmt: vhdl_sequential_stmt_t list }
|
3157
|
|
3158
|
let rec pp_vhdl_sequential_stmt_t :
|
3159
|
Format.formatter -> vhdl_sequential_stmt_t -> Ppx_deriving_runtime.unit =
|
3160
|
let __22 () = pp_vhdl_name_t
|
3161
|
|
3162
|
and __21 () = pp_vhdl_name_t
|
3163
|
|
3164
|
and __20 () = pp_vhdl_assoc_element_t
|
3165
|
|
3166
|
and __19 () = pp_vhdl_name_t
|
3167
|
|
3168
|
and __18 () = pp_vhdl_name_t
|
3169
|
|
3170
|
and __17 () = pp_vhdl_expr_t
|
3171
|
|
3172
|
and __16 () = pp_vhdl_expr_t
|
3173
|
|
3174
|
and __15 () = pp_vhdl_expr_t
|
3175
|
|
3176
|
and __14 () = pp_vhdl_name_t
|
3177
|
|
3178
|
and __13 () = pp_vhdl_expr_t
|
3179
|
|
3180
|
and __12 () = pp_vhdl_name_t
|
3181
|
|
3182
|
and __11 () = pp_vhdl_case_item_t
|
3183
|
|
3184
|
and __10 () = pp_vhdl_expr_t
|
3185
|
|
3186
|
and __9 () = pp_vhdl_name_t
|
3187
|
|
3188
|
and __8 () = pp_vhdl_sequential_stmt_t
|
3189
|
|
3190
|
and __7 () = pp_vhdl_if_case_t
|
3191
|
|
3192
|
and __6 () = pp_vhdl_name_t
|
3193
|
|
3194
|
and __5 () = pp_vhdl_waveform_element_t
|
3195
|
|
3196
|
and __4 () = pp_vhdl_name_t
|
3197
|
|
3198
|
and __3 () = pp_vhdl_name_t
|
3199
|
|
3200
|
and __2 () = pp_vhdl_expr_t
|
3201
|
|
3202
|
and __1 () = pp_vhdl_name_t
|
3203
|
|
3204
|
and __0 () = pp_vhdl_name_t
|
3205
|
in
|
3206
|
((let open! Ppx_deriving_runtime in
|
3207
|
fun fmt ->
|
3208
|
function
|
3209
|
| VarAssign { label = alabel; lhs = alhs; rhs = arhs } ->
|
3210
|
(match alabel with
|
3211
|
| NoName -> Format.fprintf fmt "";
|
3212
|
| _ -> (((__0 ()) fmt) alabel;
|
3213
|
Format.fprintf fmt ": ")
|
3214
|
);
|
3215
|
((__1 ()) fmt) alhs;
|
3216
|
Format.fprintf fmt " := ";
|
3217
|
((__2 ()) fmt) arhs;
|
3218
|
(* TODO: Check
|
3219
|
(Format.fprintf fmt "@[<2>VarAssign {@,";
|
3220
|
(((Format.fprintf fmt "@[%s =@ " "label";
|
3221
|
((__0 ()) fmt) alabel;
|
3222
|
Format.fprintf fmt "@]");
|
3223
|
Format.fprintf fmt ";@ ";
|
3224
|
Format.fprintf fmt "@[%s =@ " "lhs";
|
3225
|
((__1 ()) fmt) alhs;
|
3226
|
Format.fprintf fmt "@]");
|
3227
|
Format.fprintf fmt ";@ ";
|
3228
|
Format.fprintf fmt "@[%s =@ " "rhs";
|
3229
|
((__2 ()) fmt) arhs;
|
3230
|
Format.fprintf fmt "@]");
|
3231
|
Format.fprintf fmt "@]}") *)
|
3232
|
| SigSeqAssign { label = alabel; lhs = alhs; rhs = arhs } ->
|
3233
|
(match alabel with
|
3234
|
| NoName -> Format.fprintf fmt "";
|
3235
|
| _ -> (((__3 ()) fmt) alabel;
|
3236
|
Format.fprintf fmt ":@ ")
|
3237
|
);
|
3238
|
Format.fprintf fmt "@[<2>";
|
3239
|
((__4 ()) fmt) alhs;
|
3240
|
Format.fprintf fmt "@ <=@ ";
|
3241
|
((fun x ->
|
3242
|
Format.fprintf fmt "@[";
|
3243
|
ignore
|
3244
|
(List.fold_left
|
3245
|
(fun sep ->
|
3246
|
fun x ->
|
3247
|
if sep then Format.fprintf fmt "";
|
3248
|
((__5 ()) fmt) x;
|
3249
|
true) false x);
|
3250
|
Format.fprintf fmt "@]@]")) arhs;
|
3251
|
| If { label = alabel; if_cases = aif_cases; default = adefault } ->
|
3252
|
(match alabel with
|
3253
|
| NoName -> Format.fprintf fmt "";
|
3254
|
| _ -> (((__6 ()) fmt) alabel;
|
3255
|
Format.fprintf fmt ":@ ")
|
3256
|
);
|
3257
|
Format.fprintf fmt "@[<v>if";
|
3258
|
((fun x ->
|
3259
|
ignore
|
3260
|
(List.fold_left
|
3261
|
(fun sep ->
|
3262
|
fun x ->
|
3263
|
if sep then Format.fprintf fmt "@;elseif";
|
3264
|
((__7 ()) fmt) x;
|
3265
|
true
|
3266
|
) false x);
|
3267
|
)) aif_cases;
|
3268
|
(match adefault with
|
3269
|
| [] -> Format.fprintf fmt "";
|
3270
|
| _ -> (Format.fprintf fmt "@;else";
|
3271
|
((fun x ->
|
3272
|
Format.fprintf fmt "@;<0 2>";
|
3273
|
ignore
|
3274
|
(List.fold_left
|
3275
|
(fun sep ->
|
3276
|
fun x ->
|
3277
|
if sep then Format.fprintf fmt "";
|
3278
|
((__8 ()) fmt) x;
|
3279
|
true) false x))) adefault));
|
3280
|
Format.fprintf fmt "@;end if@]"
|
3281
|
| Case { label = alabel; guard = aguard; branches = abranches } ->
|
3282
|
(match alabel with
|
3283
|
| NoName -> Format.fprintf fmt "";
|
3284
|
| _ -> (((__9 ()) fmt) alabel;
|
3285
|
Format.fprintf fmt ":@ ")
|
3286
|
);
|
3287
|
Format.fprintf fmt "@[<v>case ";
|
3288
|
((__10 ()) fmt) aguard;
|
3289
|
Format.fprintf fmt " is";
|
3290
|
((fun x ->
|
3291
|
ignore
|
3292
|
(List.fold_left
|
3293
|
(fun sep ->
|
3294
|
fun x ->
|
3295
|
if sep then Format.fprintf fmt "";
|
3296
|
((__11 ()) fmt) x;
|
3297
|
true) false x);)) abranches;
|
3298
|
Format.fprintf fmt "@;end case@]";
|
3299
|
| Exit
|
3300
|
{ label = alabel; loop_label = aloop_label;
|
3301
|
condition = acondition }
|
3302
|
->
|
3303
|
(match alabel with
|
3304
|
| NoName -> Format.fprintf fmt "";
|
3305
|
| _ -> (((__12 ()) fmt) alabel;
|
3306
|
Format.fprintf fmt ":@ ")
|
3307
|
);
|
3308
|
Format.fprintf fmt "exit";
|
3309
|
(match aloop_label with
|
3310
|
| None -> Format.pp_print_string fmt ""
|
3311
|
| Some x -> (Format.fprintf fmt "@ %s@ ") x);
|
3312
|
((function
|
3313
|
| None -> Format.pp_print_string fmt ""
|
3314
|
| Some x ->
|
3315
|
(Format.pp_print_string fmt "when@ ";
|
3316
|
((__13 ()) fmt) x;))) acondition;
|
3317
|
| Assert
|
3318
|
{ label = alabel; cond = acond; report = areport;
|
3319
|
severity = aseverity }
|
3320
|
->
|
3321
|
Format.fprintf fmt "@[<v 2>";
|
3322
|
(match alabel with
|
3323
|
| NoName -> Format.fprintf fmt "";
|
3324
|
| _ -> (((__14 ()) fmt) alabel;
|
3325
|
Format.fprintf fmt ":@ ")
|
3326
|
);
|
3327
|
Format.fprintf fmt "assert ";
|
3328
|
((__15 ()) fmt) acond;
|
3329
|
(match areport with
|
3330
|
| IsNull -> Format.fprintf fmt "";
|
3331
|
| _ ->
|
3332
|
Format.fprintf fmt "@;report ";
|
3333
|
((__16 ()) fmt) areport);
|
3334
|
(match aseverity with
|
3335
|
| IsNull -> Format.fprintf fmt "";
|
3336
|
| _ ->
|
3337
|
Format.fprintf fmt "@;severity ";
|
3338
|
((__17 ()) fmt) aseverity);
|
3339
|
Format.fprintf fmt "@]";
|
3340
|
| ProcedureCall { label = alabel; name = aname; assocs = aassocs } ->
|
3341
|
(match alabel with
|
3342
|
| NoName -> Format.fprintf fmt "";
|
3343
|
| _ -> (((__18 ()) fmt) alabel;
|
3344
|
Format.fprintf fmt ":@ ")
|
3345
|
);
|
3346
|
((__19 ()) fmt) aname;
|
3347
|
(match aassocs with
|
3348
|
| [] -> Format.fprintf fmt "";
|
3349
|
| _ ->
|
3350
|
((fun x ->
|
3351
|
Format.fprintf fmt "(";
|
3352
|
ignore
|
3353
|
(List.fold_left
|
3354
|
(fun sep ->
|
3355
|
fun x ->
|
3356
|
if sep then Format.fprintf fmt ",@ ";
|
3357
|
((__20 ()) fmt) x;
|
3358
|
true) false x);
|
3359
|
Format.fprintf fmt ")")) aassocs);
|
3360
|
| Wait -> Format.pp_print_string fmt "wait"
|
3361
|
| Null { label = alabel } ->
|
3362
|
(match alabel with
|
3363
|
| NoName -> Format.fprintf fmt "";
|
3364
|
| _ -> (((__18 ()) fmt) alabel;
|
3365
|
Format.fprintf fmt ":@ ")
|
3366
|
);
|
3367
|
Format. |