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
|
(* Adapted *)
|
18
|
let rec (pp_vhdl_cst_val_t :
|
19
|
Format.formatter -> vhdl_cst_val_t -> Ppx_deriving_runtime.unit)
|
20
|
=
|
21
|
((let open! Ppx_deriving_runtime in
|
22
|
fun fmt ->
|
23
|
function
|
24
|
| CstInt a0 ->
|
25
|
(Format.fprintf fmt "%d") a0;
|
26
|
| CstStdLogic a0 ->
|
27
|
(Format.fprintf fmt "%S") a0;
|
28
|
| CstLiteral a0 ->
|
29
|
(Format.fprintf fmt "%s") a0;)
|
30
|
[@ocaml.warning "-A"])
|
31
|
|
32
|
and show_vhdl_cst_val_t : vhdl_cst_val_t -> Ppx_deriving_runtime.string =
|
33
|
fun x -> Format.asprintf "%a" pp_vhdl_cst_val_t x
|
34
|
|
35
|
let rec (vhdl_cst_val_t_to_yojson : vhdl_cst_val_t -> Yojson.Safe.json) =
|
36
|
((let open! Ppx_deriving_yojson_runtime in
|
37
|
function
|
38
|
| CstInt arg0 ->
|
39
|
`List
|
40
|
[`String "CstInt";
|
41
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg0]
|
42
|
| CstStdLogic arg0 ->
|
43
|
`List
|
44
|
[`String "CstStdLogic";
|
45
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0]
|
46
|
| CstLiteral arg0 ->
|
47
|
`List
|
48
|
[`String "CST_LITERAL";
|
49
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0])
|
50
|
[@ocaml.warning "-A"])
|
51
|
|
52
|
and (vhdl_cst_val_t_of_yojson :
|
53
|
Yojson.Safe.json -> vhdl_cst_val_t Ppx_deriving_yojson_runtime.error_or)
|
54
|
=
|
55
|
((let open! Ppx_deriving_yojson_runtime in
|
56
|
function
|
57
|
| `List ((`String "CstInt")::arg0::[]) ->
|
58
|
((function
|
59
|
| `Int x -> Result.Ok x
|
60
|
| _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>=
|
61
|
((fun arg0 -> Result.Ok (CstInt arg0)))
|
62
|
| `List ((`String "CstStdLogic")::arg0::[]) ->
|
63
|
((function
|
64
|
| `String x -> Result.Ok x
|
65
|
| _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>=
|
66
|
((fun arg0 -> Result.Ok (CstStdLogic arg0)))
|
67
|
| `List ((`String "CST_LITERAL")::arg0::[]) ->
|
68
|
((function
|
69
|
| `String x -> Result.Ok x
|
70
|
| _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>=
|
71
|
((fun arg0 -> Result.Ok (CstLiteral arg0)))
|
72
|
| _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t")
|
73
|
[@ocaml.warning "-A"])
|
74
|
|
75
|
type vhdl_type_t =
|
76
|
| Base of string
|
77
|
| Range of string option * int * int
|
78
|
| Bit_vector of int * int
|
79
|
| Array of int * int * vhdl_type_t
|
80
|
| Enumerated of string list
|
81
|
| Void
|
82
|
and vhdl_subtype_indication_t =
|
83
|
{
|
84
|
name: vhdl_name_t [@default NoName];
|
85
|
functionName: vhdl_name_t [@default NoName];
|
86
|
const: vhdl_constraint_t [@default NoConstraint]}
|
87
|
and vhdl_discrete_range_t =
|
88
|
| SubDiscreteRange of vhdl_subtype_indication_t
|
89
|
[@name "SUB_DISCRETE_RANGE"]
|
90
|
| NamedRange of vhdl_name_t [@name "NAMED_RANGE"]
|
91
|
| DirectedRange of
|
92
|
{
|
93
|
direction: string ;
|
94
|
from: vhdl_expr_t ;
|
95
|
_to: vhdl_expr_t } [@name "RANGE_WITH_DIRECTION"]
|
96
|
and vhdl_constraint_t =
|
97
|
| RefConstraint of {
|
98
|
ref_name: vhdl_name_t }
|
99
|
| RangeConstraint of {
|
100
|
range: vhdl_discrete_range_t } [@name "RANGE_CONSTRAINT"]
|
101
|
| IndexConstraint of {
|
102
|
ranges: vhdl_discrete_range_t list } [@name "INDEX_CONSTRAINT"]
|
103
|
| ArrayConstraint of
|
104
|
{
|
105
|
ranges: vhdl_discrete_range_t list ;
|
106
|
sub: vhdl_constraint_t } [@name "ARRAY_CONSTRAINT"]
|
107
|
| RecordConstraint
|
108
|
| NoConstraint
|
109
|
and vhdl_definition_t =
|
110
|
| Type of {
|
111
|
name: vhdl_name_t ;
|
112
|
definition: vhdl_type_t } [@name "TYPE_DECLARATION"]
|
113
|
| Subtype of {
|
114
|
name: vhdl_name_t ;
|
115
|
typ: vhdl_subtype_indication_t } [@name "SUBTYPE_DECLARATION"]
|
116
|
and vhdl_expr_t =
|
117
|
| Call of vhdl_name_t [@name "CALL"]
|
118
|
| Cst of vhdl_cst_val_t [@name "CONSTANT_VALUE"]
|
119
|
| Op of {
|
120
|
id: string [@default ""];
|
121
|
args: vhdl_expr_t list [@default []]} [@name "EXPRESSION"]
|
122
|
| IsNull [@name "IsNull"]
|
123
|
| Time of {
|
124
|
value: int ;
|
125
|
phy_unit: string [@default ""]}
|
126
|
| Sig of {
|
127
|
name: vhdl_name_t ;
|
128
|
att: vhdl_signal_attributes_t option }
|
129
|
| SuffixMod of {
|
130
|
expr: vhdl_expr_t ;
|
131
|
selection: vhdl_suffix_selection_t }
|
132
|
| Aggregate of {
|
133
|
elems: vhdl_element_assoc_t list } [@name "AGGREGATE"]
|
134
|
| Others [@name "OTHERS"]
|
135
|
and vhdl_name_t =
|
136
|
| Simple of string [@name "SIMPLE_NAME"]
|
137
|
| Identifier of string [@name "IDENTIFIER"]
|
138
|
| Selected of vhdl_name_t list [@name "SELECTED_NAME"]
|
139
|
| Index of {
|
140
|
id: vhdl_name_t ;
|
141
|
exprs: vhdl_expr_t list } [@name "INDEXED_NAME"]
|
142
|
| Slice of {
|
143
|
id: vhdl_name_t ;
|
144
|
range: vhdl_discrete_range_t } [@name "SLICE_NAME"]
|
145
|
| Attribute of
|
146
|
{
|
147
|
id: vhdl_name_t ;
|
148
|
designator: vhdl_name_t ;
|
149
|
expr: vhdl_expr_t [@default IsNull]} [@name "ATTRIBUTE_NAME"]
|
150
|
| Function of {
|
151
|
id: vhdl_name_t ;
|
152
|
assoc_list: vhdl_assoc_element_t list } [@name "FUNCTION_CALL"]
|
153
|
| NoName
|
154
|
and vhdl_assoc_element_t =
|
155
|
{
|
156
|
formal_name: vhdl_name_t option [@default None];
|
157
|
formal_arg: vhdl_name_t option [@default None];
|
158
|
actual_name: vhdl_name_t option [@default None];
|
159
|
actual_designator: vhdl_name_t option [@default None];
|
160
|
actual_expr: vhdl_expr_t option [@default None]}
|
161
|
and vhdl_element_assoc_t = {
|
162
|
choices: vhdl_expr_t list ;
|
163
|
expr: vhdl_expr_t }
|
164
|
and vhdl_array_attributes_t =
|
165
|
| AAttInt of {
|
166
|
id: string ;
|
167
|
arg: int }
|
168
|
| AAttAscending
|
169
|
and vhdl_signal_attributes_t =
|
170
|
| SigAtt of string
|
171
|
and vhdl_string_attributes_t =
|
172
|
| StringAtt of string
|
173
|
and vhdl_suffix_selection_t =
|
174
|
| Idx of int
|
175
|
| SuffixRange of int * int
|
176
|
|
177
|
let rec pp_vhdl_type_t :
|
178
|
Format.formatter -> vhdl_type_t -> Ppx_deriving_runtime.unit =
|
179
|
let __0 () = pp_vhdl_type_t in
|
180
|
((let open! Ppx_deriving_runtime in
|
181
|
fun fmt ->
|
182
|
function
|
183
|
| Base a0 ->
|
184
|
(Format.fprintf fmt "%s") a0;
|
185
|
| Range (a0,a1,a2) ->
|
186
|
((
|
187
|
(Format.fprintf fmt "%d") a1);
|
188
|
((function
|
189
|
| None -> Format.pp_print_string fmt "None"
|
190
|
| Some x ->
|
191
|
(Format.fprintf fmt "%S") x;
|
192
|
)) a0;
|
193
|
(Format.fprintf fmt "%d") a2);
|
194
|
| Bit_vector (a0,a1) ->
|
195
|
(Format.fprintf fmt "%d .. %d") a0 a1;
|
196
|
| Array (a0,a1,a2) ->
|
197
|
(((__0 ()) fmt) a2;
|
198
|
(Format.fprintf fmt "[%d,%d]") a0 a1);
|
199
|
| Enumerated a0 ->
|
200
|
((fun x ->
|
201
|
Format.fprintf fmt "@[<2>[";
|
202
|
ignore
|
203
|
(List.fold_left
|
204
|
(fun sep ->
|
205
|
fun x ->
|
206
|
if sep then Format.fprintf fmt ";@ ";
|
207
|
(Format.fprintf fmt "%S") x;
|
208
|
true) false x);
|
209
|
Format.fprintf fmt "@,]@]")) a0;
|
210
|
| Void -> Format.pp_print_string fmt "Void")
|
211
|
[@ocaml.warning "-A"])
|
212
|
|
213
|
and show_vhdl_type_t : vhdl_type_t -> Ppx_deriving_runtime.string =
|
214
|
fun x -> Format.asprintf "%a" pp_vhdl_type_t x
|
215
|
|
216
|
(* Adapted *)
|
217
|
and pp_vhdl_subtype_indication_t :
|
218
|
Format.formatter -> vhdl_subtype_indication_t -> Ppx_deriving_runtime.unit
|
219
|
=
|
220
|
let __2 () = pp_vhdl_constraint_t
|
221
|
|
222
|
and __1 () = pp_vhdl_name_t
|
223
|
|
224
|
and __0 () = pp_vhdl_name_t
|
225
|
in
|
226
|
((let open! Ppx_deriving_runtime in
|
227
|
fun fmt ->
|
228
|
fun x ->
|
229
|
((__0 ()) fmt) x.name;
|
230
|
((__1 ()) fmt) x.functionName;
|
231
|
Format.fprintf fmt " ";
|
232
|
((__2 ()) fmt) x.const;
|
233
|
)
|
234
|
[@ocaml.warning "-A"])
|
235
|
|
236
|
and show_vhdl_subtype_indication_t :
|
237
|
vhdl_subtype_indication_t -> Ppx_deriving_runtime.string =
|
238
|
fun x -> Format.asprintf "%a" pp_vhdl_subtype_indication_t x
|
239
|
|
240
|
(* Adapted *)
|
241
|
and pp_vhdl_discrete_range_t :
|
242
|
Format.formatter -> vhdl_discrete_range_t -> Ppx_deriving_runtime.unit =
|
243
|
let __3 () = pp_vhdl_expr_t
|
244
|
|
245
|
and __2 () = pp_vhdl_expr_t
|
246
|
|
247
|
and __1 () = pp_vhdl_name_t
|
248
|
|
249
|
and __0 () = pp_vhdl_subtype_indication_t
|
250
|
in
|
251
|
((let open! Ppx_deriving_runtime in
|
252
|
fun fmt ->
|
253
|
function
|
254
|
| SubDiscreteRange a0 ->
|
255
|
((__0 ()) fmt) a0;
|
256
|
| NamedRange a0 ->
|
257
|
((__1 ()) fmt) a0;
|
258
|
| DirectedRange { direction = adirection; from = afrom; _to = a_to }
|
259
|
->
|
260
|
((__2 ()) fmt) afrom;
|
261
|
(Format.fprintf fmt " %s ") adirection;
|
262
|
((__3 ()) fmt) a_to;
|
263
|
)
|
264
|
[@ocaml.warning "-A"])
|
265
|
|
266
|
and show_vhdl_discrete_range_t :
|
267
|
vhdl_discrete_range_t -> Ppx_deriving_runtime.string =
|
268
|
fun x -> Format.asprintf "%a" pp_vhdl_discrete_range_t x
|
269
|
|
270
|
(* Requires adaptation for: ArrayConstraint, RecordConstraint *)
|
271
|
and pp_vhdl_constraint_t :
|
272
|
Format.formatter -> vhdl_constraint_t -> Ppx_deriving_runtime.unit =
|
273
|
let __4 () = pp_vhdl_constraint_t
|
274
|
|
275
|
and __3 () = pp_vhdl_discrete_range_t
|
276
|
|
277
|
and __2 () = pp_vhdl_discrete_range_t
|
278
|
|
279
|
and __1 () = pp_vhdl_discrete_range_t
|
280
|
|
281
|
and __0 () = pp_vhdl_name_t
|
282
|
in
|
283
|
((let open! Ppx_deriving_runtime in
|
284
|
fun fmt ->
|
285
|
function
|
286
|
| RefConstraint { ref_name = aref_name } ->
|
287
|
(Format.fprintf fmt "(";
|
288
|
((__0 ()) fmt) aref_name;
|
289
|
Format.fprintf fmt ")");
|
290
|
| RangeConstraint { range = arange } ->
|
291
|
(Format.fprintf fmt "(";
|
292
|
((__1 ()) fmt) arange;
|
293
|
Format.fprintf fmt ")");
|
294
|
| IndexConstraint { ranges = aranges } ->
|
295
|
Format.fprintf fmt "(";
|
296
|
((fun x ->
|
297
|
ignore
|
298
|
(List.fold_left
|
299
|
(fun sep ->
|
300
|
fun x ->
|
301
|
if sep then Format.fprintf fmt ", ";
|
302
|
((__2 ()) fmt) x;
|
303
|
true) false x))) aranges;
|
304
|
Format.fprintf fmt ")";
|
305
|
| ArrayConstraint { ranges = aranges; sub = asub } ->
|
306
|
(Format.fprintf fmt "@[<2>ArrayConstraint {@,";
|
307
|
((Format.fprintf fmt "@[%s =@ " "ranges";
|
308
|
((fun x ->
|
309
|
Format.fprintf fmt "@[<2>[";
|
310
|
ignore
|
311
|
(List.fold_left
|
312
|
(fun sep ->
|
313
|
fun x ->
|
314
|
if sep then Format.fprintf fmt ";@ ";
|
315
|
((__3 ()) fmt) x;
|
316
|
true) false x);
|
317
|
Format.fprintf fmt "@,]@]")) aranges;
|
318
|
Format.fprintf fmt "@]");
|
319
|
Format.fprintf fmt ";@ ";
|
320
|
Format.fprintf fmt "@[%s =@ " "sub";
|
321
|
((__4 ()) fmt) asub;
|
322
|
Format.fprintf fmt "@]");
|
323
|
Format.fprintf fmt "@]}")
|
324
|
| RecordConstraint -> Format.pp_print_string fmt ""
|
325
|
| NoConstraint -> Format.pp_print_string fmt "")
|
326
|
[@ocaml.warning "-A"])
|
327
|
|
328
|
and show_vhdl_constraint_t : vhdl_constraint_t -> Ppx_deriving_runtime.string
|
329
|
= fun x -> Format.asprintf "%a" pp_vhdl_constraint_t x
|
330
|
|
331
|
and pp_vhdl_definition_t :
|
332
|
Format.formatter -> vhdl_definition_t -> Ppx_deriving_runtime.unit =
|
333
|
let __3 () = pp_vhdl_subtype_indication_t
|
334
|
|
335
|
and __2 () = pp_vhdl_name_t
|
336
|
|
337
|
and __1 () = pp_vhdl_type_t
|
338
|
|
339
|
and __0 () = pp_vhdl_name_t
|
340
|
in
|
341
|
((let open! Ppx_deriving_runtime in
|
342
|
fun fmt ->
|
343
|
function
|
344
|
| Type { name = aname; definition = adefinition } ->
|
345
|
Format.fprintf fmt "@[<2>type ";
|
346
|
((__0 ()) fmt) aname;
|
347
|
Format.fprintf fmt " is ";
|
348
|
((__1 ()) fmt) adefinition;
|
349
|
Format.fprintf fmt "@]}";
|
350
|
| Subtype { name = aname; typ = atyp } ->
|
351
|
Format.fprintf fmt "@[<2>subtype ";
|
352
|
((__2 ()) fmt) aname;
|
353
|
Format.fprintf fmt " is ";
|
354
|
((__3 ()) fmt) atyp;
|
355
|
Format.fprintf fmt "@]";
|
356
|
)
|
357
|
[@ocaml.warning "-A"])
|
358
|
|
359
|
and show_vhdl_definition_t : vhdl_definition_t -> Ppx_deriving_runtime.string
|
360
|
= fun x -> Format.asprintf "%a" pp_vhdl_definition_t x
|
361
|
|
362
|
(* adaptation to be provided for Op, Time, Sig, suffixMod, Aggregate, *)
|
363
|
and pp_vhdl_expr_t :
|
364
|
Format.formatter -> vhdl_expr_t -> Ppx_deriving_runtime.unit =
|
365
|
let __7 () = pp_vhdl_element_assoc_t
|
366
|
|
367
|
and __6 () = pp_vhdl_suffix_selection_t
|
368
|
|
369
|
and __5 () = pp_vhdl_expr_t
|
370
|
|
371
|
and __4 () = pp_vhdl_signal_attributes_t
|
372
|
|
373
|
and __3 () = pp_vhdl_name_t
|
374
|
|
375
|
and __2 () = pp_vhdl_expr_t
|
376
|
|
377
|
and __1 () = pp_vhdl_cst_val_t
|
378
|
|
379
|
and __0 () = pp_vhdl_name_t
|
380
|
in
|
381
|
((let open! Ppx_deriving_runtime in
|
382
|
fun fmt ->
|
383
|
function
|
384
|
| Call a0 ->
|
385
|
((__0 ()) fmt) a0;
|
386
|
| Cst a0 ->
|
387
|
((__1 ()) fmt) a0;
|
388
|
| Op { id = aid; args = aargs } ->
|
389
|
(match aargs with
|
390
|
| [] -> (Format.fprintf fmt "%s") aid;
|
391
|
| hd::[] ->
|
392
|
(Format.fprintf fmt "%s") aid;
|
393
|
((__2 ()) fmt) hd
|
394
|
| hd::(hd2::[]) ->
|
395
|
((__2 ()) fmt) hd;
|
396
|
(Format.fprintf fmt " %s ") aid;
|
397
|
((__2 ()) fmt) hd2
|
398
|
| _ ->
|
399
|
(Format.fprintf fmt "@[<2>Op {@,";
|
400
|
((Format.fprintf fmt "@[%s =@ " "id";
|
401
|
(Format.fprintf fmt "%S") aid;
|
402
|
Format.fprintf fmt "@]");
|
403
|
Format.fprintf fmt ";@ ";
|
404
|
Format.fprintf fmt "@[%s =@ " "args";
|
405
|
((fun x ->
|
406
|
Format.fprintf fmt "@[<2>[";
|
407
|
ignore
|
408
|
(List.fold_left
|
409
|
(fun sep ->
|
410
|
fun x ->
|
411
|
if sep then Format.fprintf fmt ";@ ";
|
412
|
((__2 ()) fmt) x;
|
413
|
true) false x);
|
414
|
Format.fprintf fmt "@,]@]")) aargs;
|
415
|
Format.fprintf fmt "@]");
|
416
|
Format.fprintf fmt "@]}"))
|
417
|
| IsNull -> Format.pp_print_string fmt ""
|
418
|
| Time { value = avalue; phy_unit = aphy_unit } ->
|
419
|
(Format.fprintf fmt "@[<2>Time {@,";
|
420
|
((Format.fprintf fmt "@[%s =@ " "value";
|
421
|
(Format.fprintf fmt "%d") avalue;
|
422
|
Format.fprintf fmt "@]");
|
423
|
Format.fprintf fmt ";@ ";
|
424
|
Format.fprintf fmt "@[%s =@ " "phy_unit";
|
425
|
(Format.fprintf fmt "%S") aphy_unit;
|
426
|
Format.fprintf fmt "@]");
|
427
|
Format.fprintf fmt "@]}")
|
428
|
| Sig { name = aname; att = aatt } ->
|
429
|
(Format.fprintf fmt "@[<2>Sig {@,";
|
430
|
((Format.fprintf fmt "@[%s =@ " "name";
|
431
|
((__3 ()) fmt) aname;
|
432
|
Format.fprintf fmt "@]");
|
433
|
Format.fprintf fmt ";@ ";
|
434
|
Format.fprintf fmt "@[%s =@ " "att";
|
435
|
((function
|
436
|
| None -> Format.pp_print_string fmt "None"
|
437
|
| Some x ->
|
438
|
(Format.pp_print_string fmt "(Some ";
|
439
|
((__4 ()) fmt) x;
|
440
|
Format.pp_print_string fmt ")"))) aatt;
|
441
|
Format.fprintf fmt "@]");
|
442
|
Format.fprintf fmt "@]}")
|
443
|
| SuffixMod { expr = aexpr; selection = aselection } ->
|
444
|
(Format.fprintf fmt "@[<2>SuffixMod {@,";
|
445
|
((Format.fprintf fmt "@[%s =@ " "expr";
|
446
|
((__5 ()) fmt) aexpr;
|
447
|
Format.fprintf fmt "@]");
|
448
|
Format.fprintf fmt ";@ ";
|
449
|
Format.fprintf fmt "@[%s =@ " "selection";
|
450
|
((__6 ()) fmt) aselection;
|
451
|
Format.fprintf fmt "@]");
|
452
|
Format.fprintf fmt "@]}")
|
453
|
| Aggregate { elems = aelems } ->
|
454
|
(Format.fprintf fmt "@[<2>Aggregate {@,";
|
455
|
(Format.fprintf fmt "@[%s =@ " "elems";
|
456
|
((fun x ->
|
457
|
Format.fprintf fmt "@[<2>[";
|
458
|
ignore
|
459
|
(List.fold_left
|
460
|
(fun sep ->
|
461
|
fun x ->
|
462
|
if sep then Format.fprintf fmt ";@ ";
|
463
|
((__7 ()) fmt) x;
|
464
|
true) false x);
|
465
|
Format.fprintf fmt "@,]@]")) aelems;
|
466
|
Format.fprintf fmt "@]");
|
467
|
Format.fprintf fmt "@]}")
|
468
|
| Others -> Format.pp_print_string fmt "others")
|
469
|
[@ocaml.warning "-A"])
|
470
|
|
471
|
and show_vhdl_expr_t : vhdl_expr_t -> Ppx_deriving_runtime.string =
|
472
|
fun x -> Format.asprintf "%a" pp_vhdl_expr_t x
|
473
|
|
474
|
(* Adapted *)
|
475
|
and pp_vhdl_name_t :
|
476
|
Format.formatter -> vhdl_name_t -> Ppx_deriving_runtime.unit =
|
477
|
let __9 () = pp_vhdl_assoc_element_t
|
478
|
|
479
|
and __8 () = pp_vhdl_name_t
|
480
|
|
481
|
and __7 () = pp_vhdl_expr_t
|
482
|
|
483
|
and __6 () = pp_vhdl_name_t
|
484
|
|
485
|
and __5 () = pp_vhdl_name_t
|
486
|
|
487
|
and __4 () = pp_vhdl_discrete_range_t
|
488
|
|
489
|
and __3 () = pp_vhdl_name_t
|
490
|
|
491
|
and __2 () = pp_vhdl_expr_t
|
492
|
|
493
|
and __1 () = pp_vhdl_name_t
|
494
|
|
495
|
and __0 () = pp_vhdl_name_t
|
496
|
in
|
497
|
((let open! Ppx_deriving_runtime in
|
498
|
fun fmt ->
|
499
|
function
|
500
|
| Simple a0 ->
|
501
|
(Format.fprintf fmt "%s") a0;
|
502
|
| Identifier a0 ->
|
503
|
(Format.fprintf fmt "%s") a0;
|
504
|
| Selected a0 ->
|
505
|
((fun x ->
|
506
|
ignore
|
507
|
(List.fold_left
|
508
|
(fun sep ->
|
509
|
fun x ->
|
510
|
if sep then Format.fprintf fmt ".";
|
511
|
((__0 ()) fmt) x;
|
512
|
true) false x);) a0;)
|
513
|
| Index { id = aid; exprs = aexprs } ->
|
514
|
((__1 ()) fmt) aid;
|
515
|
Format.fprintf fmt "(";
|
516
|
(fun x ->
|
517
|
ignore
|
518
|
(List.fold_left
|
519
|
(fun sep ->
|
520
|
fun x ->
|
521
|
if sep then Format.fprintf fmt ",@ ";
|
522
|
((__2 ()) fmt) x;
|
523
|
true
|
524
|
) false x);
|
525
|
) aexprs;
|
526
|
Format.fprintf fmt ")";
|
527
|
| Slice { id = aid; range = arange } ->
|
528
|
((__3 ()) fmt) aid;
|
529
|
Format.fprintf fmt "(";
|
530
|
((__4 ()) fmt) arange;
|
531
|
Format.fprintf fmt ")";
|
532
|
| Attribute { id = aid; designator = adesignator; expr = aexpr } ->
|
533
|
((__5 ()) fmt) aid;
|
534
|
Format.fprintf fmt "\'";
|
535
|
((__6 ()) fmt) adesignator;
|
536
|
(match aexpr with
|
537
|
| IsNull -> Format.fprintf fmt "";
|
538
|
| _ ->
|
539
|
Format.fprintf fmt "(";
|
540
|
((__7 ()) fmt) aexpr;
|
541
|
Format.fprintf fmt ")")
|
542
|
| Function { id = aid; assoc_list = aassoc_list } ->
|
543
|
(((__8 ()) fmt) aid;
|
544
|
Format.fprintf fmt "(";
|
545
|
((fun x ->
|
546
|
Format.fprintf fmt "@[";
|
547
|
ignore
|
548
|
(List.fold_left
|
549
|
(fun sep ->
|
550
|
fun x ->
|
551
|
if sep then Format.fprintf fmt ";@ ";
|
552
|
((__9 ()) fmt) x;
|
553
|
true) false x);
|
554
|
Format.fprintf fmt "@]")) aassoc_list;
|
555
|
Format.fprintf fmt ")";)
|
556
|
| NoName -> Format.pp_print_string fmt "")
|
557
|
[@ocaml.warning "-A"])
|
558
|
|
559
|
and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string =
|
560
|
fun x -> Format.asprintf "%a" pp_vhdl_name_t x
|
561
|
|
562
|
(* Adapted *)
|
563
|
and pp_vhdl_assoc_element_t :
|
564
|
Format.formatter -> vhdl_assoc_element_t -> Ppx_deriving_runtime.unit =
|
565
|
let __4 () = pp_vhdl_expr_t
|
566
|
|
567
|
and __3 () = pp_vhdl_name_t
|
568
|
|
569
|
and __2 () = pp_vhdl_name_t
|
570
|
|
571
|
and __1 () = pp_vhdl_name_t
|
572
|
|
573
|
and __0 () = pp_vhdl_name_t
|
574
|
in
|
575
|
((let open! Ppx_deriving_runtime in
|
576
|
fun fmt ->
|
577
|
fun x ->
|
578
|
(match x.formal_name with
|
579
|
| None -> Format.pp_print_string fmt ""
|
580
|
| Some NoName -> Format.pp_print_string fmt ""
|
581
|
| Some a ->
|
582
|
(((__0 ()) fmt) a;
|
583
|
(match x.formal_arg with
|
584
|
| None -> ()
|
585
|
| Some b -> Format.fprintf fmt "(";
|
586
|
((__1 ()) fmt) b;
|
587
|
Format.fprintf fmt ")");
|
588
|
Format.fprintf fmt " => "));
|
589
|
(match x.actual_name with
|
590
|
| None -> Format.pp_print_string fmt ""
|
591
|
| Some a ->
|
592
|
(((__2 ()) fmt) a;
|
593
|
(match x.actual_designator with
|
594
|
| None -> ()
|
595
|
| Some NoName -> Format.pp_print_string fmt ""
|
596
|
| Some b -> (Format.fprintf fmt "(";
|
597
|
((__3 ()) fmt) b;
|
598
|
Format.fprintf fmt ")"));
|
599
|
(match x.actual_expr with
|
600
|
| None -> ()
|
601
|
| Some IsNull -> Format.pp_print_string fmt ""
|
602
|
| Some c -> (Format.fprintf fmt "(";
|
603
|
((__4 ()) fmt) c;
|
604
|
Format.fprintf fmt ")"))));)
|
605
|
[@ocaml.warning "-A"])
|
606
|
|
607
|
and show_vhdl_assoc_element_t :
|
608
|
vhdl_assoc_element_t -> Ppx_deriving_runtime.string =
|
609
|
fun x -> Format.asprintf "%a" pp_vhdl_assoc_element_t x
|
610
|
|
611
|
and pp_vhdl_element_assoc_t :
|
612
|
Format.formatter -> vhdl_element_assoc_t -> Ppx_deriving_runtime.unit =
|
613
|
let __1 () = pp_vhdl_expr_t
|
614
|
|
615
|
and __0 () = pp_vhdl_expr_t
|
616
|
in
|
617
|
((let open! Ppx_deriving_runtime in
|
618
|
fun fmt ->
|
619
|
fun x ->
|
620
|
Format.fprintf fmt "@[<2>{ ";
|
621
|
((Format.fprintf fmt "@[%s =@ " "choices";
|
622
|
((fun x ->
|
623
|
Format.fprintf fmt "@[<2>[";
|
624
|
ignore
|
625
|
(List.fold_left
|
626
|
(fun sep ->
|
627
|
fun x ->
|
628
|
if sep then Format.fprintf fmt ";@ ";
|
629
|
((__0 ()) fmt) x;
|
630
|
true) false x);
|
631
|
Format.fprintf fmt "@,]@]")) x.choices;
|
632
|
Format.fprintf fmt "@]");
|
633
|
Format.fprintf fmt ";@ ";
|
634
|
Format.fprintf fmt "@[%s =@ " "expr";
|
635
|
((__1 ()) fmt) x.expr;
|
636
|
Format.fprintf fmt "@]");
|
637
|
Format.fprintf fmt "@ }@]")
|
638
|
[@ocaml.warning "-A"])
|
639
|
|
640
|
and show_vhdl_element_assoc_t :
|
641
|
vhdl_element_assoc_t -> Ppx_deriving_runtime.string =
|
642
|
fun x -> Format.asprintf "%a" pp_vhdl_element_assoc_t x
|
643
|
|
644
|
and (pp_vhdl_array_attributes_t :
|
645
|
Format.formatter ->
|
646
|
vhdl_array_attributes_t -> Ppx_deriving_runtime.unit)
|
647
|
=
|
648
|
((let open! Ppx_deriving_runtime in
|
649
|
fun fmt ->
|
650
|
function
|
651
|
| AAttInt { id = aid; arg = aarg } ->
|
652
|
(Format.fprintf fmt "@[<2>AAttInt {@,";
|
653
|
((Format.fprintf fmt "@[%s =@ " "id";
|
654
|
(Format.fprintf fmt "%S") aid;
|
655
|
Format.fprintf fmt "@]");
|
656
|
Format.fprintf fmt ";@ ";
|
657
|
Format.fprintf fmt "@[%s =@ " "arg";
|
658
|
(Format.fprintf fmt "%d") aarg;
|
659
|
Format.fprintf fmt "@]");
|
660
|
Format.fprintf fmt "@]}")
|
661
|
| AAttAscending -> Format.pp_print_string fmt "AAttAscending")
|
662
|
[@ocaml.warning "-A"])
|
663
|
|
664
|
and show_vhdl_array_attributes_t :
|
665
|
vhdl_array_attributes_t -> Ppx_deriving_runtime.string =
|
666
|
fun x -> Format.asprintf "%a" pp_vhdl_array_attributes_t x
|
667
|
|
668
|
and (pp_vhdl_signal_attributes_t :
|
669
|
Format.formatter ->
|
670
|
vhdl_signal_attributes_t -> Ppx_deriving_runtime.unit)
|
671
|
=
|
672
|
((let open! Ppx_deriving_runtime in
|
673
|
fun fmt ->
|
674
|
function
|
675
|
| SigAtt a0 ->
|
676
|
(Format.fprintf fmt "(@[<2>SigAtt@ ";
|
677
|
(Format.fprintf fmt "%S") a0;
|
678
|
Format.fprintf fmt "@])"))
|
679
|
[@ocaml.warning "-A"])
|
680
|
|
681
|
and show_vhdl_signal_attributes_t :
|
682
|
vhdl_signal_attributes_t -> Ppx_deriving_runtime.string =
|
683
|
fun x -> Format.asprintf "%a" pp_vhdl_signal_attributes_t x
|
684
|
|
685
|
and (pp_vhdl_string_attributes_t :
|
686
|
Format.formatter ->
|
687
|
vhdl_string_attributes_t -> Ppx_deriving_runtime.unit)
|
688
|
=
|
689
|
((let open! Ppx_deriving_runtime in
|
690
|
fun fmt ->
|
691
|
function
|
692
|
| StringAtt a0 ->
|
693
|
(Format.fprintf fmt "(@[<2>StringAtt@ ";
|
694
|
(Format.fprintf fmt "%S") a0;
|
695
|
Format.fprintf fmt "@])"))
|
696
|
[@ocaml.warning "-A"])
|
697
|
|
698
|
and show_vhdl_string_attributes_t :
|
699
|
vhdl_string_attributes_t -> Ppx_deriving_runtime.string =
|
700
|
fun x -> Format.asprintf "%a" pp_vhdl_string_attributes_t x
|
701
|
|
702
|
and (pp_vhdl_suffix_selection_t :
|
703
|
Format.formatter ->
|
704
|
vhdl_suffix_selection_t -> Ppx_deriving_runtime.unit)
|
705
|
=
|
706
|
((let open! Ppx_deriving_runtime in
|
707
|
fun fmt ->
|
708
|
function
|
709
|
| Idx a0 ->
|
710
|
(Format.fprintf fmt "(@[<2>Idx@ ";
|
711
|
(Format.fprintf fmt "%d") a0;
|
712
|
Format.fprintf fmt "@])")
|
713
|
| SuffixRange (a0,a1) ->
|
714
|
(Format.fprintf fmt "(@[<2>SuffixRange (@,";
|
715
|
((Format.fprintf fmt "%d") a0;
|
716
|
Format.fprintf fmt ",@ ";
|
717
|
(Format.fprintf fmt "%d") a1);
|
718
|
Format.fprintf fmt "@,))@]"))
|
719
|
[@ocaml.warning "-A"])
|
720
|
|
721
|
and show_vhdl_suffix_selection_t :
|
722
|
vhdl_suffix_selection_t -> Ppx_deriving_runtime.string =
|
723
|
fun x -> Format.asprintf "%a" pp_vhdl_suffix_selection_t x
|
724
|
|
725
|
let rec (vhdl_type_t_to_yojson : vhdl_type_t -> Yojson.Safe.json) =
|
726
|
((let open! Ppx_deriving_yojson_runtime in
|
727
|
function
|
728
|
| Base arg0 ->
|
729
|
`List
|
730
|
[`String "Base";
|
731
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0]
|
732
|
| Range (arg0,arg1,arg2) ->
|
733
|
`List
|
734
|
[`String "Range";
|
735
|
((function
|
736
|
| None -> `Null
|
737
|
| Some x ->
|
738
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)) x))
|
739
|
arg0;
|
740
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg1;
|
741
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg2]
|
742
|
| Bit_vector (arg0,arg1) ->
|
743
|
`List
|
744
|
[`String "Bit_vector";
|
745
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg0;
|
746
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg1]
|
747
|
| Array (arg0,arg1,arg2) ->
|
748
|
`List
|
749
|
[`String "Array";
|
750
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg0;
|
751
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg1;
|
752
|
((fun x -> vhdl_type_t_to_yojson x)) arg2]
|
753
|
| Enumerated arg0 ->
|
754
|
`List
|
755
|
[`String "Enumerated";
|
756
|
((fun x ->
|
757
|
`List
|
758
|
(List.map
|
759
|
(fun (x : Ppx_deriving_runtime.string) -> `String x) x)))
|
760
|
arg0]
|
761
|
| Void -> `List [`String "Void"])
|
762
|
[@ocaml.warning "-A"])
|
763
|
|
764
|
and (vhdl_type_t_of_yojson :
|
765
|
Yojson.Safe.json -> vhdl_type_t Ppx_deriving_yojson_runtime.error_or)
|
766
|
=
|
767
|
((let open! Ppx_deriving_yojson_runtime in
|
768
|
function
|
769
|
| `List ((`String "Base")::arg0::[]) ->
|
770
|
((function
|
771
|
| `String x -> Result.Ok x
|
772
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
|
773
|
((fun arg0 -> Result.Ok (Base arg0)))
|
774
|
| `List ((`String "Range")::arg0::arg1::arg2::[]) ->
|
775
|
((function
|
776
|
| `Int x -> Result.Ok x
|
777
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg2) >>=
|
778
|
((fun arg2 ->
|
779
|
((function
|
780
|
| `Int x -> Result.Ok x
|
781
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
|
782
|
(fun arg1 ->
|
783
|
((function
|
784
|
| `Null -> Result.Ok None
|
785
|
| x ->
|
786
|
((function
|
787
|
| `String x -> Result.Ok x
|
788
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") x)
|
789
|
>>= ((fun x -> Result.Ok (Some x)))) arg0)
|
790
|
>>=
|
791
|
(fun arg0 -> Result.Ok (Range (arg0, arg1, arg2))))))
|
792
|
| `List ((`String "Bit_vector")::arg0::arg1::[]) ->
|
793
|
((function
|
794
|
| `Int x -> Result.Ok x
|
795
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
|
796
|
((fun arg1 ->
|
797
|
((function
|
798
|
| `Int x -> Result.Ok x
|
799
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
|
800
|
(fun arg0 -> Result.Ok (Bit_vector (arg0, arg1)))))
|
801
|
| `List ((`String "Array")::arg0::arg1::arg2::[]) ->
|
802
|
((fun x -> vhdl_type_t_of_yojson x) arg2) >>=
|
803
|
((fun arg2 ->
|
804
|
((function
|
805
|
| `Int x -> Result.Ok x
|
806
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
|
807
|
(fun arg1 ->
|
808
|
((function
|
809
|
| `Int x -> Result.Ok x
|
810
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
|
811
|
(fun arg0 -> Result.Ok (Array (arg0, arg1, arg2))))))
|
812
|
| `List ((`String "Enumerated")::arg0::[]) ->
|
813
|
((function
|
814
|
| `List xs ->
|
815
|
map_bind
|
816
|
(function
|
817
|
| `String x -> Result.Ok x
|
818
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") [] xs
|
819
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
|
820
|
((fun arg0 -> Result.Ok (Enumerated arg0)))
|
821
|
| `List ((`String "Void")::[]) -> Result.Ok Void
|
822
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_t")
|
823
|
[@ocaml.warning "-A"])
|
824
|
|
825
|
and (vhdl_subtype_indication_t_to_yojson :
|
826
|
vhdl_subtype_indication_t -> Yojson.Safe.json)
|
827
|
=
|
828
|
((let open! Ppx_deriving_yojson_runtime in
|
829
|
fun x ->
|
830
|
let fields = [] in
|
831
|
let fields =
|
832
|
if x.const = NoConstraint
|
833
|
then fields
|
834
|
else
|
835
|
("const", (((fun x -> vhdl_constraint_t_to_yojson x)) x.const))
|
836
|
:: fields
|
837
|
in
|
838
|
let fields =
|
839
|
if x.functionName = NoName
|
840
|
then fields
|
841
|
else
|
842
|
("functionName",
|
843
|
(((fun x -> vhdl_name_t_to_yojson x)) x.functionName))
|
844
|
:: fields
|
845
|
in
|
846
|
let fields =
|
847
|
if x.name = NoName
|
848
|
then fields
|
849
|
else ("name", (((fun x -> vhdl_name_t_to_yojson x)) x.name)) ::
|
850
|
fields
|
851
|
in
|
852
|
`Assoc fields)
|
853
|
[@ocaml.warning "-A"])
|
854
|
|
855
|
and (vhdl_subtype_indication_t_of_yojson :
|
856
|
Yojson.Safe.json ->
|
857
|
vhdl_subtype_indication_t Ppx_deriving_yojson_runtime.error_or)
|
858
|
=
|
859
|
((let open! Ppx_deriving_yojson_runtime in
|
860
|
function
|
861
|
| `Assoc xs ->
|
862
|
let rec loop xs ((arg0,arg1,arg2) as _state) =
|
863
|
match xs with
|
864
|
| ("name",x)::xs ->
|
865
|
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2)
|
866
|
| ("functionName",x)::xs ->
|
867
|
loop xs (arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2)
|
868
|
| ("const",x)::xs ->
|
869
|
loop xs
|
870
|
(arg0, arg1, ((fun x -> vhdl_constraint_t_of_yojson x) x))
|
871
|
| [] ->
|
872
|
arg2 >>=
|
873
|
((fun arg2 ->
|
874
|
arg1 >>=
|
875
|
(fun arg1 ->
|
876
|
arg0 >>=
|
877
|
(fun arg0 ->
|
878
|
Result.Ok
|
879
|
{
|
880
|
name = arg0;
|
881
|
functionName = arg1;
|
882
|
const = arg2
|
883
|
}))))
|
884
|
| _::xs -> loop xs _state in
|
885
|
loop xs
|
886
|
((Result.Ok NoName), (Result.Ok NoName),
|
887
|
(Result.Ok NoConstraint))
|
888
|
| _ -> Result.Error "Vhdl_ast.vhdl_subtype_indication_t")
|
889
|
[@ocaml.warning "-A"])
|
890
|
|
891
|
and (vhdl_discrete_range_t_to_yojson :
|
892
|
vhdl_discrete_range_t -> Yojson.Safe.json)
|
893
|
=
|
894
|
((let open! Ppx_deriving_yojson_runtime in
|
895
|
function
|
896
|
| SubDiscreteRange arg0 ->
|
897
|
`List
|
898
|
[`String "SUB_DISCRETE_RANGE";
|
899
|
((fun x -> vhdl_subtype_indication_t_to_yojson x)) arg0]
|
900
|
| NamedRange arg0 ->
|
901
|
`List
|
902
|
[`String "NAMED_RANGE";
|
903
|
((fun x -> vhdl_name_t_to_yojson x)) arg0]
|
904
|
| DirectedRange arg0 ->
|
905
|
`List
|
906
|
[`String "RANGE_WITH_DIRECTION";
|
907
|
(let fields = [] in
|
908
|
let fields =
|
909
|
("_to", ((fun x -> vhdl_expr_t_to_yojson x) arg0._to)) ::
|
910
|
fields in
|
911
|
let fields =
|
912
|
("from", ((fun x -> vhdl_expr_t_to_yojson x) arg0.from)) ::
|
913
|
fields in
|
914
|
let fields =
|
915
|
("direction",
|
916
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)
|
917
|
arg0.direction))
|
918
|
:: fields in
|
919
|
`Assoc fields)])
|
920
|
[@ocaml.warning "-A"])
|
921
|
|
922
|
and (vhdl_discrete_range_t_of_yojson :
|
923
|
Yojson.Safe.json ->
|
924
|
vhdl_discrete_range_t Ppx_deriving_yojson_runtime.error_or)
|
925
|
=
|
926
|
((let open! Ppx_deriving_yojson_runtime in
|
927
|
function
|
928
|
| `List ((`String "SUB_DISCRETE_RANGE")::arg0::[]) ->
|
929
|
((fun x -> vhdl_subtype_indication_t_of_yojson x) arg0) >>=
|
930
|
((fun arg0 -> Result.Ok (SubDiscreteRange arg0)))
|
931
|
| `List ((`String "NAMED_RANGE")::arg0::[]) ->
|
932
|
((fun x -> vhdl_name_t_of_yojson x) arg0) >>=
|
933
|
((fun arg0 -> Result.Ok (NamedRange arg0)))
|
934
|
| `List ((`String "RANGE_WITH_DIRECTION")::arg0::[]) ->
|
935
|
((function
|
936
|
| `Assoc xs ->
|
937
|
let rec loop xs ((arg0,arg1,arg2) as _state) =
|
938
|
match xs with
|
939
|
| ("direction",x)::xs ->
|
940
|
loop xs
|
941
|
(((function
|
942
|
| `String x -> Result.Ok x
|
943
|
| _ ->
|
944
|
Result.Error
|
945
|
"Vhdl_ast.vhdl_discrete_range_t.direction")
|
946
|
x), arg1, arg2)
|
947
|
| ("from",x)::xs ->
|
948
|
loop xs
|
949
|
(arg0, ((fun x -> vhdl_expr_t_of_yojson x) x), arg2)
|
950
|
| ("_to",x)::xs ->
|
951
|
loop xs
|
952
|
(arg0, arg1, ((fun x -> vhdl_expr_t_of_yojson x) x))
|
953
|
| [] ->
|
954
|
arg2 >>=
|
955
|
((fun arg2 ->
|
956
|
arg1 >>=
|
957
|
(fun arg1 ->
|
958
|
arg0 >>=
|
959
|
(fun arg0 ->
|
960
|
Result.Ok
|
961
|
(DirectedRange
|
962
|
{
|
963
|
direction = arg0;
|
964
|
from = arg1;
|
965
|
_to = arg2
|
966
|
})))))
|
967
|
| _::xs -> loop xs _state in
|
968
|
loop xs
|
969
|
((Result.Error "Vhdl_ast.vhdl_discrete_range_t.direction"),
|
970
|
(Result.Error "Vhdl_ast.vhdl_discrete_range_t.from"),
|
971
|
(Result.Error "Vhdl_ast.vhdl_discrete_range_t._to"))
|
972
|
| _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")) arg0
|
973
|
| _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")
|
974
|
[@ocaml.warning "-A"])
|
975
|
|
976
|
and (vhdl_constraint_t_to_yojson : vhdl_constraint_t -> Yojson.Safe.json) =
|
977
|
((let open! Ppx_deriving_yojson_runtime in
|
978
|
function
|
979
|
| RefConstraint arg0 ->
|
980
|
`List
|
981
|
[`String "RefConstraint";
|
982
|
(let fields = [] in
|
983
|
let fields =
|
984
|
("ref_name",
|
985
|
((fun x -> vhdl_name_t_to_yojson x) arg0.ref_name))
|
986
|
:: fields in
|
987
|
`Assoc fields)]
|
988
|
| RangeConstraint arg0 ->
|
989
|
`List
|
990
|
[`String "RANGE_CONSTRAINT";
|
991
|
(let fields = [] in
|
992
|
let fields =
|
993
|
("range",
|
994
|
((fun x -> vhdl_discrete_range_t_to_yojson x) arg0.range))
|
995
|
:: fields in
|
996
|
`Assoc fields)]
|
997
|
| IndexConstraint arg0 ->
|
998
|
`List
|
999
|
[`String "INDEX_CONSTRAINT";
|
1000
|
(let fields = [] in
|
1001
|
let fields =
|
1002
|
("ranges",
|
1003
|
((fun x ->
|
1004
|
`List
|
1005
|
(List.map
|
1006
|
(fun x -> vhdl_discrete_range_t_to_yojson x) x))
|
1007
|
arg0.ranges))
|
1008
|
:: fields in
|
1009
|
`Assoc fields)]
|
1010
|
| ArrayConstraint arg0 ->
|
1011
|
`List
|
1012
|
[`String "ARRAY_CONSTRAINT";
|
1013
|
(let fields = [] in
|
1014
|
let fields =
|
1015
|
("sub", ((fun x -> vhdl_constraint_t_to_yojson x) arg0.sub))
|
1016
|
:: fields in
|
1017
|
let fields =
|
1018
|
("ranges",
|
1019
|
((fun x ->
|
1020
|
`List
|
1021
|
(List.map
|
1022
|
(fun x -> vhdl_discrete_range_t_to_yojson x) x))
|
1023
|
arg0.ranges))
|
1024
|
:: fields in
|
1025
|
`Assoc fields)]
|
1026
|
| RecordConstraint -> `List [`String "RecordConstraint"]
|
1027
|
| NoConstraint -> `List [`String "NoConstraint"])
|
1028
|
[@ocaml.warning "-A"])
|
1029
|
|
1030
|
and (vhdl_constraint_t_of_yojson :
|
1031
|
Yojson.Safe.json ->
|
1032
|
vhdl_constraint_t Ppx_deriving_yojson_runtime.error_or)
|
1033
|
=
|
1034
|
((let open! Ppx_deriving_yojson_runtime in
|
1035
|
function
|
1036
|
| `List ((`String "RefConstraint")::arg0::[]) ->
|
1037
|
((function
|
1038
|
| `Assoc xs ->
|
1039
|
let rec loop xs (arg0 as _state) =
|
1040
|
match xs with
|
1041
|
| ("ref_name",x)::xs ->
|
1042
|
loop xs ((fun x -> vhdl_name_t_of_yojson x) x)
|
1043
|
| [] ->
|
1044
|
arg0 >>=
|
1045
|
((fun arg0 ->
|
1046
|
Result.Ok (RefConstraint { ref_name = arg0 })))
|
1047
|
| _::xs -> loop xs _state in
|
1048
|
loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ref_name")
|
1049
|
| _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
|
1050
|
| `List ((`String "RANGE_CONSTRAINT")::arg0::[]) ->
|
1051
|
((function
|
1052
|
| `Assoc xs ->
|
1053
|
let rec loop xs (arg0 as _state) =
|
1054
|
match xs with
|
1055
|
| ("range",x)::xs ->
|
1056
|
loop xs
|
1057
|
((fun x -> vhdl_discrete_range_t_of_yojson x) x)
|
1058
|
| [] ->
|
1059
|
arg0 >>=
|
1060
|
((fun arg0 ->
|
1061
|
Result.Ok (RangeConstraint { range = arg0 })))
|
1062
|
| _::xs -> loop xs _state in
|
1063
|
loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.range")
|
1064
|
| _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
|
1065
|
| `List ((`String "INDEX_CONSTRAINT")::arg0::[]) ->
|
1066
|
((function
|
1067
|
| `Assoc xs ->
|
1068
|
let rec loop xs (arg0 as _state) =
|
1069
|
match xs with
|
1070
|
| ("ranges",x)::xs ->
|
1071
|
loop xs
|
1072
|
((function
|
1073
|
| `List xs ->
|
1074
|
map_bind
|
1075
|
(fun x -> vhdl_discrete_range_t_of_yojson x)
|
1076
|
[] xs
|
1077
|
| _ ->
|
1078
|
Result.Error
|
1079
|
"Vhdl_ast.vhdl_constraint_t.ranges") x)
|
1080
|
| [] ->
|
1081
|
arg0 >>=
|
1082
|
((fun arg0 ->
|
1083
|
Result.Ok (IndexConstraint { ranges = arg0 })))
|
1084
|
| _::xs -> loop xs _state in
|
1085
|
loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ranges")
|
1086
|
| _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
|
1087
|
| `List ((`String "ARRAY_CONSTRAINT")::arg0::[]) ->
|
1088
|
((function
|
1089
|
| `Assoc xs ->
|
1090
|
let rec loop xs ((arg0,arg1) as _state) =
|
1091
|
match xs with
|
1092
|
| ("ranges",x)::xs ->
|
1093
|
loop xs
|
1094
|
(((function
|
1095
|
| `List xs ->
|
1096
|
map_bind
|
1097
|
(fun x -> vhdl_discrete_range_t_of_yojson x)
|
1098
|
[] xs
|
1099
|
| _ ->
|
1100
|
Result.Error
|
1101
|
"Vhdl_ast.vhdl_constraint_t.ranges") x),
|
1102
|
arg1)
|
1103
|
| ("sub",x)::xs ->
|
1104
|
loop xs
|
1105
|
(arg0, ((fun x -> vhdl_constraint_t_of_yojson x) x))
|
1106
|
| [] ->
|
1107
|
arg1 >>=
|
1108
|
((fun arg1 ->
|
1109
|
arg0 >>=
|
1110
|
(fun arg0 ->
|
1111
|
Result.Ok
|
1112
|
(ArrayConstraint
|
1113
|
{ ranges = arg0; sub = arg1 }))))
|
1114
|
| _::xs -> loop xs _state in
|
1115
|
loop xs
|
1116
|
((Result.Error "Vhdl_ast.vhdl_constraint_t.ranges"),
|
1117
|
(Result.Error "Vhdl_ast.vhdl_constraint_t.sub"))
|
1118
|
| _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
|
1119
|
| `List ((`String "RecordConstraint")::[]) ->
|
1120
|
Result.Ok RecordConstraint
|
1121
|
| `List ((`String "NoConstraint")::[]) -> Result.Ok NoConstraint
|
1122
|
| _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")
|
1123
|
[@ocaml.warning "-A"])
|
1124
|
|
1125
|
and (vhdl_definition_t_to_yojson : vhdl_definition_t -> Yojson.Safe.json) =
|
1126
|
((let open! Ppx_deriving_yojson_runtime in
|
1127
|
function
|
1128
|
| Type arg0 ->
|
1129
|
`List
|
1130
|
[`String "TYPE_DECLARATION";
|
1131
|
(let fields = [] in
|
1132
|
let fields =
|
1133
|
("definition",
|
1134
|
((fun x -> vhdl_type_t_to_yojson x) arg0.definition))
|
1135
|
:: fields in
|
1136
|
let fields =
|
1137
|
("name", ((fun x -> vhdl_name_t_to_yojson x) arg0.name)) ::
|
1138
|
fields in
|
1139
|
`Assoc fields)]
|
1140
|
| Subtype arg0 ->
|
1141
|
`List
|
1142
|
[`String "SUBTYPE_DECLARATION";
|
1143
|
(let fields = [] in
|
1144
|
let fields =
|
1145
|
("typ",
|
1146
|
((fun x -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
|
1147
|
:: fields in
|
1148
|
let fields =
|
1149
|
("name", ((fun x -> vhdl_name_t_to_yojson x) arg0.name)) ::
|
1150
|
fields in
|
1151
|
`Assoc fields)])
|
1152
|
[@ocaml.warning "-A"])
|
1153
|
|
1154
|
and (vhdl_definition_t_of_yojson :
|
1155
|
Yojson.Safe.json ->
|
1156
|
vhdl_definition_t Ppx_deriving_yojson_runtime.error_or)
|
1157
|
=
|
1158
|
((let open! Ppx_deriving_yojson_runtime in
|
1159
|
function
|
1160
|
| `List ((`String "TYPE_DECLARATION")::arg0::[]) ->
|
1161
|
((function
|
1162
|
| `Assoc xs ->
|
1163
|
let rec loop xs ((arg0,arg1) as _state) =
|
1164
|
match xs with
|
1165
|
| ("name",x)::xs ->
|
1166
|
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1)
|
1167
|
| ("definition",x)::xs ->
|
1168
|
loop xs (arg0, ((fun x -> vhdl_type_t_of_yojson x) x))
|
1169
|
| [] ->
|
1170
|
arg1 >>=
|
1171
|
((fun arg1 ->
|
1172
|
arg0 >>=
|
1173
|
(fun arg0 ->
|
1174
|
Result.Ok
|
1175
|
(Type { name = arg0; definition = arg1 }))))
|
1176
|
| _::xs -> loop xs _state in
|
1177
|
loop xs
|
1178
|
((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
|
1179
|
(Result.Error "Vhdl_ast.vhdl_definition_t.definition"))
|
1180
|
| _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
|
1181
|
| `List ((`String "SUBTYPE_DECLARATION")::arg0::[]) ->
|
1182
|
((function
|
1183
|
| `Assoc xs ->
|
1184
|
let rec loop xs ((arg0,arg1) as _state) =
|
1185
|
match xs with
|
1186
|
| ("name",x)::xs ->
|
1187
|
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1)
|
1188
|
| ("typ",x)::xs ->
|
1189
|
loop xs
|
1190
|
(arg0,
|
1191
|
((fun x -> vhdl_subtype_indication_t_of_yojson x)
|
1192
|
x))
|
1193
|
| [] ->
|
1194
|
arg1 >>=
|
1195
|
((fun arg1 ->
|
1196
|
arg0 >>=
|
1197
|
(fun arg0 ->
|
1198
|
Result.Ok
|
1199
|
(Subtype { name = arg0; typ = arg1 }))))
|
1200
|
| _::xs -> loop xs _state in
|
1201
|
loop xs
|
1202
|
((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
|
1203
|
(Result.Error "Vhdl_ast.vhdl_definition_t.typ"))
|
1204
|
| _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
|
1205
|
| _ -> Result.Error "Vhdl_ast.vhdl_definition_t")
|
1206
|
[@ocaml.warning "-A"])
|
1207
|
|
1208
|
and (vhdl_expr_t_to_yojson : vhdl_expr_t -> Yojson.Safe.json) =
|
1209
|
((let open! Ppx_deriving_yojson_runtime in
|
1210
|
function
|
1211
|
| Call arg0 ->
|
1212
|
`List [`String "CALL"; ((fun x -> vhdl_name_t_to_yojson x)) arg0]
|
1213
|
| Cst arg0 ->
|
1214
|
`List
|
1215
|
[`String "CONSTANT_VALUE";
|
1216
|
((fun x -> vhdl_cst_val_t_to_yojson x)) arg0]
|
1217
|
| Op arg0 ->
|
1218
|
`List
|
1219
|
[`String "EXPRESSION";
|
1220
|
(let fields = [] in
|
1221
|
let fields =
|
1222
|
if arg0.args = []
|
1223
|
then fields
|
1224
|
else
|
1225
|
("args",
|
1226
|
(((fun x ->
|
1227
|
`List
|
1228
|
(List.map (fun x -> vhdl_expr_t_to_yojson x) x)))
|
1229
|
arg0.args))
|
1230
|
:: fields
|
1231
|
in
|
1232
|
let fields =
|
1233
|
if arg0.id = ""
|
1234
|
then fields
|
1235
|
else
|
1236
|
("id",
|
1237
|
(((fun (x : Ppx_deriving_runtime.string) -> `String x))
|
1238
|
arg0.id))
|
1239
|
:: fields
|
1240
|
in
|
1241
|
`Assoc fields)]
|
1242
|
| IsNull -> `List [`String "IsNull"]
|
1243
|
| Time arg0 ->
|
1244
|
`List
|
1245
|
[`String "Time";
|
1246
|
(let fields = [] in
|
1247
|
let fields =
|
1248
|
if arg0.phy_unit = ""
|
1249
|
then fields
|
1250
|
else
|
1251
|
("phy_unit",
|
1252
|
(((fun (x : Ppx_deriving_runtime.string) -> `String x))
|
1253
|
arg0.phy_unit))
|
1254
|
:: fields
|
1255
|
in
|
1256
|
let fields =
|
1257
|
("value",
|
1258
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x) arg0.value))
|
1259
|
:: fields in
|
1260
|
`Assoc fields)]
|
1261
|
| Sig arg0 ->
|
1262
|
`List
|
1263
|
[`String "Sig";
|
1264
|
(let fields = [] in
|
1265
|
let fields =
|
1266
|
("att",
|
1267
|
((function
|
1268
|
| None -> `Null
|
1269
|
| Some x ->
|
1270
|
((fun x -> vhdl_signal_attributes_t_to_yojson x)) x)
|
1271
|
arg0.att))
|
1272
|
:: fields in
|
1273
|
let fields =
|
1274
|
("name", ((fun x -> vhdl_name_t_to_yojson x) arg0.name)) ::
|
1275
|
fields in
|
1276
|
`Assoc fields)]
|
1277
|
| SuffixMod arg0 ->
|
1278
|
`List
|
1279
|
[`String "SuffixMod";
|
1280
|
(let fields = [] in
|
1281
|
let fields =
|
1282
|
("selection",
|
1283
|
((fun x -> vhdl_suffix_selection_t_to_yojson x)
|
1284
|
arg0.selection))
|
1285
|
:: fields in
|
1286
|
let fields =
|
1287
|
("expr", ((fun x -> vhdl_expr_t_to_yojson x) arg0.expr)) ::
|
1288
|
fields in
|
1289
|
`Assoc fields)]
|
1290
|
| Aggregate arg0 ->
|
1291
|
`List
|
1292
|
[`String "AGGREGATE";
|
1293
|
(let fields = [] in
|
1294
|
let fields =
|
1295
|
("elems",
|
1296
|
((fun x ->
|
1297
|
`List
|
1298
|
(List.map (fun x -> vhdl_element_assoc_t_to_yojson x)
|
1299
|
x)) arg0.elems))
|
1300
|
:: fields in
|
1301
|
`Assoc fields)]
|
1302
|
| Others -> `List [`String "OTHERS"])
|
1303
|
[@ocaml.warning "-A"])
|
1304
|
|
1305
|
and (vhdl_expr_t_of_yojson :
|
1306
|
Yojson.Safe.json -> vhdl_expr_t Ppx_deriving_yojson_runtime.error_or)
|
1307
|
=
|
1308
|
((let open! Ppx_deriving_yojson_runtime in
|
1309
|
function
|
1310
|
| `List ((`String "CALL")::arg0::[]) ->
|
1311
|
((fun x -> vhdl_name_t_of_yojson x) arg0) >>=
|
1312
|
((fun arg0 -> Result.Ok (Call arg0)))
|
1313
|
| `List ((`String "CONSTANT_VALUE")::arg0::[]) ->
|
1314
|
((fun x -> vhdl_cst_val_t_of_yojson x) arg0) >>=
|
1315
|
((fun arg0 -> Result.Ok (Cst arg0)))
|
1316
|
| `List ((`String "EXPRESSION")::arg0::[]) ->
|
1317
|
((function
|
1318
|
| `Assoc xs ->
|
1319
|
let rec loop xs ((arg0,arg1) as _state) =
|
1320
|
match xs with
|
1321
|
| ("id",x)::xs ->
|
1322
|
loop xs
|
1323
|
(((function
|
1324
|
| `String x -> Result.Ok x
|
1325
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t.id") x),
|
1326
|
arg1)
|
1327
|
| ("args",x)::xs ->
|
1328
|
loop xs
|
1329
|
(arg0,
|
1330
|
((function
|
1331
|
| `List xs ->
|
1332
|
map_bind (fun x -> vhdl_expr_t_of_yojson x)
|
1333
|
[] xs
|
1334
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t.args")
|
1335
|
x))
|
1336
|
| [] ->
|
1337
|
arg1 >>=
|
1338
|
((fun arg1 ->
|
1339
|
arg0 >>=
|
1340
|
(fun arg0 ->
|
1341
|
Result.Ok (Op { id = arg0; args = arg1 }))))
|
1342
|
| _::xs -> loop xs _state in
|
1343
|
loop xs ((Result.Ok ""), (Result.Ok []))
|
1344
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
|
1345
|
| `List ((`String "IsNull")::[]) -> Result.Ok IsNull
|
1346
|
| `List ((`String "Time")::arg0::[]) ->
|
1347
|
((function
|
1348
|
| `Assoc xs ->
|
1349
|
let rec loop xs ((arg0,arg1) as _state) =
|
1350
|
match xs with
|
1351
|
| ("value",x)::xs ->
|
1352
|
loop xs
|
1353
|
(((function
|
1354
|
| `Int x -> Result.Ok x
|
1355
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t.value")
|
1356
|
x), arg1)
|
1357
|
| ("phy_unit",x)::xs ->
|
1358
|
loop xs
|
1359
|
(arg0,
|
1360
|
((function
|
1361
|
| `String x -> Result.Ok x
|
1362
|
| _ ->
|
1363
|
Result.Error "Vhdl_ast.vhdl_expr_t.phy_unit")
|
1364
|
x))
|
1365
|
| [] ->
|
1366
|
arg1 >>=
|
1367
|
((fun arg1 ->
|
1368
|
arg0 >>=
|
1369
|
(fun arg0 ->
|
1370
|
Result.Ok
|
1371
|
(Time { value = arg0; phy_unit = arg1 }))))
|
1372
|
| _::xs -> loop xs _state in
|
1373
|
loop xs
|
1374
|
((Result.Error "Vhdl_ast.vhdl_expr_t.value"),
|
1375
|
(Result.Ok ""))
|
1376
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
|
1377
|
| `List ((`String "Sig")::arg0::[]) ->
|
1378
|
((function
|
1379
|
| `Assoc xs ->
|
1380
|
let rec loop xs ((arg0,arg1) as _state) =
|
1381
|
match xs with
|
1382
|
| ("name",x)::xs ->
|
1383
|
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1)
|
1384
|
| ("att",x)::xs ->
|
1385
|
loop xs
|
1386
|
(arg0,
|
1387
|
((function
|
1388
|
| `Null -> Result.Ok None
|
1389
|
| x ->
|
1390
|
((fun x ->
|
1391
|
vhdl_signal_attributes_t_of_yojson x) x)
|
1392
|
>>= ((fun x -> Result.Ok (Some x)))) x))
|
1393
|
| [] ->
|
1394
|
arg1 >>=
|
1395
|
((fun arg1 ->
|
1396
|
arg0 >>=
|
1397
|
(fun arg0 ->
|
1398
|
Result.Ok (Sig { name = arg0; att = arg1 }))))
|
1399
|
| _::xs -> loop xs _state in
|
1400
|
loop xs
|
1401
|
((Result.Error "Vhdl_ast.vhdl_expr_t.name"),
|
1402
|
(Result.Error "Vhdl_ast.vhdl_expr_t.att"))
|
1403
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
|
1404
|
| `List ((`String "SuffixMod")::arg0::[]) ->
|
1405
|
((function
|
1406
|
| `Assoc xs ->
|
1407
|
let rec loop xs ((arg0,arg1) as _state) =
|
1408
|
match xs with
|
1409
|
| ("expr",x)::xs ->
|
1410
|
loop xs (((fun x -> vhdl_expr_t_of_yojson x) x), arg1)
|
1411
|
| ("selection",x)::xs ->
|
1412
|
loop xs
|
1413
|
(arg0,
|
1414
|
((fun x -> vhdl_suffix_selection_t_of_yojson x) x))
|
1415
|
| [] ->
|
1416
|
arg1 >>=
|
1417
|
((fun arg1 ->
|
1418
|
arg0 >>=
|
1419
|
(fun arg0 ->
|
1420
|
Result.Ok
|
1421
|
(SuffixMod
|
1422
|
{ expr = arg0; selection = arg1 }))))
|
1423
|
| _::xs -> loop xs _state in
|
1424
|
loop xs
|
1425
|
((Result.Error "Vhdl_ast.vhdl_expr_t.expr"),
|
1426
|
(Result.Error "Vhdl_ast.vhdl_expr_t.selection"))
|
1427
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
|
1428
|
| `List ((`String "AGGREGATE")::arg0::[]) ->
|
1429
|
((function
|
1430
|
| `Assoc xs ->
|
1431
|
let rec loop xs (arg0 as _state) =
|
1432
|
match xs with
|
1433
|
| ("elems",x)::xs ->
|
1434
|
loop xs
|
1435
|
((function
|
1436
|
| `List xs ->
|
1437
|
map_bind
|
1438
|
(fun x -> vhdl_element_assoc_t_of_yojson x)
|
1439
|
[] xs
|
1440
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t.elems") x)
|
1441
|
| [] ->
|
1442
|
arg0 >>=
|
1443
|
((fun arg0 -> Result.Ok (Aggregate { elems = arg0 })))
|
1444
|
| _::xs -> loop xs _state in
|
1445
|
loop xs (Result.Error "Vhdl_ast.vhdl_expr_t.elems")
|
1446
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
|
1447
|
| `List ((`String "OTHERS")::[]) -> Result.Ok Others
|
1448
|
| _ -> Result.Error "Vhdl_ast.vhdl_expr_t")
|
1449
|
[@ocaml.warning "-A"])
|
1450
|
|
1451
|
and (vhdl_name_t_to_yojson : vhdl_name_t -> Yojson.Safe.json) =
|
1452
|
((let open! Ppx_deriving_yojson_runtime in
|
1453
|
function
|
1454
|
| Simple arg0 ->
|
1455
|
`List
|
1456
|
[`String "SIMPLE_NAME";
|
1457
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0]
|
1458
|
| Identifier arg0 ->
|
1459
|
`List
|
1460
|
[`String "IDENTIFIER";
|
1461
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0]
|
1462
|
| Selected arg0 ->
|
1463
|
`List
|
1464
|
[`String "SELECTED_NAME";
|
1465
|
((fun x ->
|
1466
|
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x))) arg0]
|
1467
|
| Index arg0 ->
|
1468
|
`List
|
1469
|
[`String "INDEXED_NAME";
|
1470
|
(let fields = [] in
|
1471
|
let fields =
|
1472
|
("exprs",
|
1473
|
((fun x ->
|
1474
|
`List (List.map (fun x -> vhdl_expr_t_to_yojson x) x))
|
1475
|
arg0.exprs))
|
1476
|
:: fields in
|
1477
|
let fields =
|
1478
|
("id", ((fun x -> vhdl_name_t_to_yojson x) arg0.id)) ::
|
1479
|
fields in
|
1480
|
`Assoc fields)]
|
1481
|
| Slice arg0 ->
|
1482
|
`List
|
1483
|
[`String "SLICE_NAME";
|
1484
|
(let fields = [] in
|
1485
|
let fields =
|
1486
|
("range",
|
1487
|
((fun x -> vhdl_discrete_range_t_to_yojson x) arg0.range))
|
1488
|
:: fields in
|
1489
|
let fields =
|
1490
|
("id", ((fun x -> vhdl_name_t_to_yojson x) arg0.id)) ::
|
1491
|
fields in
|
1492
|
`Assoc fields)]
|
1493
|
| Attribute arg0 ->
|
1494
|
`List
|
1495
|
[`String "ATTRIBUTE_NAME";
|
1496
|
(let fields = [] in
|
1497
|
let fields =
|
1498
|
if arg0.expr = IsNull
|
1499
|
then fields
|
1500
|
else
|
1501
|
("expr", (((fun x -> vhdl_expr_t_to_yojson x)) arg0.expr))
|
1502
|
:: fields
|
1503
|
in
|
1504
|
let fields =
|
1505
|
("designator",
|
1506
|
((fun x -> vhdl_name_t_to_yojson x) arg0.designator))
|
1507
|
:: fields in
|
1508
|
let fields =
|
1509
|
("id", ((fun x -> vhdl_name_t_to_yojson x) arg0.id)) ::
|
1510
|
fields in
|
1511
|
`Assoc fields)]
|
1512
|
| Function arg0 ->
|
1513
|
`List
|
1514
|
[`String "FUNCTION_CALL";
|
1515
|
(let fields = [] in
|
1516
|
let fields =
|
1517
|
("assoc_list",
|
1518
|
((fun x ->
|
1519
|
`List
|
1520
|
(List.map (fun x -> vhdl_assoc_element_t_to_yojson x)
|
1521
|
x)) arg0.assoc_list))
|
1522
|
:: fields in
|
1523
|
let fields =
|
1524
|
("id", ((fun x -> vhdl_name_t_to_yojson x) arg0.id)) ::
|
1525
|
fields in
|
1526
|
`Assoc fields)]
|
1527
|
| NoName -> `List [`String "NoName"])
|
1528
|
[@ocaml.warning "-A"])
|
1529
|
|
1530
|
and (vhdl_name_t_of_yojson :
|
1531
|
Yojson.Safe.json -> vhdl_name_t Ppx_deriving_yojson_runtime.error_or)
|
1532
|
=
|
1533
|
((let open! Ppx_deriving_yojson_runtime in
|
1534
|
function
|
1535
|
| `List ((`String "SIMPLE_NAME")::arg0::[]) ->
|
1536
|
((function
|
1537
|
| `String x -> Result.Ok x
|
1538
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
|
1539
|
((fun arg0 -> Result.Ok (Simple arg0)))
|
1540
|
| `List ((`String "IDENTIFIER")::arg0::[]) ->
|
1541
|
((function
|
1542
|
| `String x -> Result.Ok x
|
1543
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
|
1544
|
((fun arg0 -> Result.Ok (Identifier arg0)))
|
1545
|
| `List ((`String "SELECTED_NAME")::arg0::[]) ->
|
1546
|
((function
|
1547
|
| `List xs -> map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs
|
1548
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
|
1549
|
((fun arg0 -> Result.Ok (Selected arg0)))
|
1550
|
| `List ((`String "INDEXED_NAME")::arg0::[]) ->
|
1551
|
((function
|
1552
|
| `Assoc xs ->
|
1553
|
let rec loop xs ((arg0,arg1) as _state) =
|
1554
|
match xs with
|
1555
|
| ("id",x)::xs ->
|
1556
|
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1)
|
1557
|
| ("exprs",x)::xs ->
|
1558
|
loop xs
|
1559
|
(arg0,
|
1560
|
((function
|
1561
|
| `List xs ->
|
1562
|
map_bind (fun x -> vhdl_expr_t_of_yojson x)
|
1563
|
[] xs
|
1564
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t.exprs")
|
1565
|
x))
|
1566
|
| [] ->
|
1567
|
arg1 >>=
|
1568
|
((fun arg1 ->
|
1569
|
arg0 >>=
|
1570
|
(fun arg0 ->
|
1571
|
Result.Ok
|
1572
|
(Index { id = arg0; exprs = arg1 }))))
|
1573
|
| _::xs -> loop xs _state in
|
1574
|
loop xs
|
1575
|
((Result.Error "Vhdl_ast.vhdl_name_t.id"),
|
1576
|
(Result.Error "Vhdl_ast.vhdl_name_t.exprs"))
|
1577
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
|
1578
|
| `List ((`String "SLICE_NAME")::arg0::[]) ->
|
1579
|
((function
|
1580
|
| `Assoc xs ->
|
1581
|
let rec loop xs ((arg0,arg1) as _state) =
|
1582
|
match xs with
|
1583
|
| ("id",x)::xs ->
|
1584
|
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1)
|
1585
|
| ("range",x)::xs ->
|
1586
|
loop xs
|
1587
|
(arg0,
|
1588
|
((fun x -> vhdl_discrete_range_t_of_yojson x) x))
|
1589
|
| [] ->
|
1590
|
arg1 >>=
|
1591
|
((fun arg1 ->
|
1592
|
arg0 >>=
|
1593
|
(fun arg0 ->
|
1594
|
Result.Ok
|
1595
|
(Slice { id = arg0; range = arg1 }))))
|
1596
|
| _::xs -> loop xs _state in
|
1597
|
loop xs
|
1598
|
((Result.Error "Vhdl_ast.vhdl_name_t.id"),
|
1599
|
(Result.Error "Vhdl_ast.vhdl_name_t.range"))
|
1600
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
|
1601
|
| `List ((`String "ATTRIBUTE_NAME")::arg0::[]) ->
|
1602
|
((function
|
1603
|
| `Assoc xs ->
|
1604
|
let rec loop xs ((arg0,arg1,arg2) as _state) =
|
1605
|
match xs with
|
1606
|
| ("id",x)::xs ->
|
1607
|
loop xs
|
1608
|
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2)
|
1609
|
| ("designator",x)::xs ->
|
1610
|
loop xs
|
1611
|
(arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2)
|
1612
|
| ("expr",x)::xs ->
|
1613
|
loop xs
|
1614
|
(arg0, arg1, ((fun x -> vhdl_expr_t_of_yojson x) x))
|
1615
|
| [] ->
|
1616
|
arg2 >>=
|
1617
|
((fun arg2 ->
|
1618
|
arg1 >>=
|
1619
|
(fun arg1 ->
|
1620
|
arg0 >>=
|
1621
|
(fun arg0 ->
|
1622
|
Result.Ok
|
1623
|
(Attribute
|
1624
|
{
|
1625
|
id = arg0;
|
1626
|
designator = arg1;
|
1627
|
expr = arg2
|
1628
|
})))))
|
1629
|
| _::xs -> loop xs _state in
|
1630
|
loop xs
|
1631
|
((Result.Error "Vhdl_ast.vhdl_name_t.id"),
|
1632
|
(Result.Error "Vhdl_ast.vhdl_name_t.designator"),
|
1633
|
(Result.Ok IsNull))
|
1634
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
|
1635
|
| `List ((`String "FUNCTION_CALL")::arg0::[]) ->
|
1636
|
((function
|
1637
|
| `Assoc xs ->
|
1638
|
let rec loop xs ((arg0,arg1) as _state) =
|
1639
|
match xs with
|
1640
|
| ("id",x)::xs ->
|
1641
|
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1)
|
1642
|
| ("assoc_list",x)::xs ->
|
1643
|
loop xs
|
1644
|
(arg0,
|
1645
|
((function
|
1646
|
| `List xs ->
|
1647
|
map_bind
|
1648
|
(fun x -> vhdl_assoc_element_t_of_yojson x)
|
1649
|
[] xs
|
1650
|
| _ ->
|
1651
|
Result.Error
|
1652
|
"Vhdl_ast.vhdl_name_t.assoc_list") x))
|
1653
|
| [] ->
|
1654
|
arg1 >>=
|
1655
|
((fun arg1 ->
|
1656
|
arg0 >>=
|
1657
|
(fun arg0 ->
|
1658
|
Result.Ok
|
1659
|
(Function { id = arg0; assoc_list = arg1 }))))
|
1660
|
| _::xs -> loop xs _state in
|
1661
|
loop xs
|
1662
|
((Result.Error "Vhdl_ast.vhdl_name_t.id"),
|
1663
|
(Result.Error "Vhdl_ast.vhdl_name_t.assoc_list"))
|
1664
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
|
1665
|
| `List ((`String "NoName")::[]) -> Result.Ok NoName
|
1666
|
| _ -> Result.Error "Vhdl_ast.vhdl_name_t")
|
1667
|
[@ocaml.warning "-A"])
|
1668
|
|
1669
|
and (vhdl_assoc_element_t_to_yojson :
|
1670
|
vhdl_assoc_element_t -> Yojson.Safe.json)
|
1671
|
=
|
1672
|
((let open! Ppx_deriving_yojson_runtime in
|
1673
|
fun x ->
|
1674
|
let fields = [] in
|
1675
|
let fields =
|
1676
|
if x.actual_expr = None
|
1677
|
then fields
|
1678
|
else
|
1679
|
("actual_expr",
|
1680
|
(((function
|
1681
|
| None -> `Null
|
1682
|
| Some x -> ((fun x -> vhdl_expr_t_to_yojson x)) x))
|
1683
|
x.actual_expr))
|
1684
|
:: fields
|
1685
|
in
|
1686
|
let fields =
|
1687
|
if x.actual_designator = None
|
1688
|
then fields
|
1689
|
else
|
1690
|
("actual_designator",
|
1691
|
(((function
|
1692
|
| None -> `Null
|
1693
|
| Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x))
|
1694
|
x.actual_designator))
|
1695
|
:: fields
|
1696
|
in
|
1697
|
let fields =
|
1698
|
if x.actual_name = None
|
1699
|
then fields
|
1700
|
else
|
1701
|
("actual_name",
|
1702
|
(((function
|
1703
|
| None -> `Null
|
1704
|
| Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x))
|
1705
|
x.actual_name))
|
1706
|
:: fields
|
1707
|
in
|
1708
|
let fields =
|
1709
|
if x.formal_arg = None
|
1710
|
then fields
|
1711
|
else
|
1712
|
("formal_arg",
|
1713
|
(((function
|
1714
|
| None -> `Null
|
1715
|
| Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x))
|
1716
|
x.formal_arg))
|
1717
|
:: fields
|
1718
|
in
|
1719
|
let fields =
|
1720
|
if x.formal_name = None
|
1721
|
then fields
|
1722
|
else
|
1723
|
("formal_name",
|
1724
|
(((function
|
1725
|
| None -> `Null
|
1726
|
| Some x -> ((fun x -> vhdl_name_t_to_yojson x)) x))
|
1727
|
x.formal_name))
|
1728
|
:: fields
|
1729
|
in
|
1730
|
`Assoc fields)
|
1731
|
[@ocaml.warning "-A"])
|
1732
|
|
1733
|
and (vhdl_assoc_element_t_of_yojson :
|
1734
|
Yojson.Safe.json ->
|
1735
|
vhdl_assoc_element_t Ppx_deriving_yojson_runtime.error_or)
|
1736
|
=
|
1737
|
((let open! Ppx_deriving_yojson_runtime in
|
1738
|
function
|
1739
|
| `Assoc xs ->
|
1740
|
let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
|
1741
|
match xs with
|
1742
|
| ("formal_name",x)::xs ->
|
1743
|
loop xs
|
1744
|
(((function
|
1745
|
| `Null -> Result.Ok None
|
1746
|
| x ->
|
1747
|
((fun x -> vhdl_name_t_of_yojson x) x) >>=
|
1748
|
((fun x -> Result.Ok (Some x)))) x), arg1, arg2,
|
1749
|
arg3, arg4)
|
1750
|
| ("formal_arg",x)::xs ->
|
1751
|
loop xs
|
1752
|
(arg0,
|
1753
|
((function
|
1754
|
| `Null -> Result.Ok None
|
1755
|
| x ->
|
1756
|
((fun x -> vhdl_name_t_of_yojson x) x) >>=
|
1757
|
((fun x -> Result.Ok (Some x)))) x), arg2, arg3,
|
1758
|
arg4)
|
1759
|
| ("actual_name",x)::xs ->
|
1760
|
loop xs
|
1761
|
(arg0, arg1,
|
1762
|
((function
|
1763
|
| `Null -> Result.Ok None
|
1764
|
| x ->
|
1765
|
((fun x -> vhdl_name_t_of_yojson x) x) >>=
|
1766
|
((fun x -> Result.Ok (Some x)))) x), arg3, arg4)
|
1767
|
| ("actual_designator",x)::xs ->
|
1768
|
loop xs
|
1769
|
(arg0, arg1, arg2,
|
1770
|
((function
|
1771
|
| `Null -> Result.Ok None
|
1772
|
| x ->
|
1773
|
((fun x -> vhdl_name_t_of_yojson x) x) >>=
|
1774
|
((fun x -> Result.Ok (Some x)))) x), arg4)
|
1775
|
| ("actual_expr",x)::xs ->
|
1776
|
loop xs
|
1777
|
(arg0, arg1, arg2, arg3,
|
1778
|
((function
|
1779
|
| `Null -> Result.Ok None
|
1780
|
| x ->
|
1781
|
((fun x -> vhdl_expr_t_of_yojson x) x) >>=
|
1782
|
((fun x -> Result.Ok (Some x)))) x))
|
1783
|
| [] ->
|
1784
|
arg4 >>=
|
1785
|
((fun arg4 ->
|
1786
|
arg3 >>=
|
1787
|
(fun arg3 ->
|
1788
|
arg2 >>=
|
1789
|
(fun arg2 ->
|
1790
|
arg1 >>=
|
1791
|
(fun arg1 ->
|
1792
|
arg0 >>=
|
1793
|
(fun arg0 ->
|
1794
|
Result.Ok
|
1795
|
{
|
1796
|
formal_name = arg0;
|
1797
|
formal_arg = arg1;
|
1798
|
actual_name = arg2;
|
1799
|
actual_designator = arg3;
|
1800
|
actual_expr = arg4
|
1801
|
}))))))
|
1802
|
| _::xs -> loop xs _state in
|
1803
|
loop xs
|
1804
|
((Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
|
1805
|
(Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
|
1806
|
(Result.Ok (Some IsNull)))
|
1807
|
| _ -> Result.Error "Vhdl_ast.vhdl_assoc_element_t")
|
1808
|
[@ocaml.warning "-A"])
|
1809
|
|
1810
|
and (vhdl_element_assoc_t_to_yojson :
|
1811
|
vhdl_element_assoc_t -> Yojson.Safe.json)
|
1812
|
=
|
1813
|
((let open! Ppx_deriving_yojson_runtime in
|
1814
|
fun x ->
|
1815
|
let fields = [] in
|
1816
|
let fields = ("expr", ((fun x -> vhdl_expr_t_to_yojson x) x.expr))
|
1817
|
:: fields in
|
1818
|
let fields =
|
1819
|
("choices",
|
1820
|
((fun x ->
|
1821
|
`List (List.map (fun x -> vhdl_expr_t_to_yojson x) x))
|
1822
|
x.choices))
|
1823
|
:: fields in
|
1824
|
`Assoc fields)
|
1825
|
[@ocaml.warning "-A"])
|
1826
|
|
1827
|
and (vhdl_element_assoc_t_of_yojson :
|
1828
|
Yojson.Safe.json ->
|
1829
|
vhdl_element_assoc_t Ppx_deriving_yojson_runtime.error_or)
|
1830
|
=
|
1831
|
((let open! Ppx_deriving_yojson_runtime in
|
1832
|
function
|
1833
|
| `Assoc xs ->
|
1834
|
let rec loop xs ((arg0,arg1) as _state) =
|
1835
|
match xs with
|
1836
|
| ("choices",x)::xs ->
|
1837
|
loop xs
|
1838
|
(((function
|
1839
|
| `List xs ->
|
1840
|
map_bind (fun x -> vhdl_expr_t_of_yojson x) [] xs
|
1841
|
| _ ->
|
1842
|
Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices")
|
1843
|
x), arg1)
|
1844
|
| ("expr",x)::xs ->
|
1845
|
loop xs (arg0, ((fun x -> vhdl_expr_t_of_yojson x) x))
|
1846
|
| [] ->
|
1847
|
arg1 >>=
|
1848
|
((fun arg1 ->
|
1849
|
arg0 >>=
|
1850
|
(fun arg0 ->
|
1851
|
Result.Ok { choices = arg0; expr = arg1 })))
|
1852
|
| _::xs -> loop xs _state in
|
1853
|
loop xs
|
1854
|
((Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices"),
|
1855
|
(Result.Error "Vhdl_ast.vhdl_element_assoc_t.expr"))
|
1856
|
| _ -> Result.Error "Vhdl_ast.vhdl_element_assoc_t")
|
1857
|
[@ocaml.warning "-A"])
|
1858
|
|
1859
|
and (vhdl_array_attributes_t_to_yojson :
|
1860
|
vhdl_array_attributes_t -> Yojson.Safe.json)
|
1861
|
=
|
1862
|
((let open! Ppx_deriving_yojson_runtime in
|
1863
|
function
|
1864
|
| AAttInt arg0 ->
|
1865
|
`List
|
1866
|
[`String "AAttInt";
|
1867
|
(let fields = [] in
|
1868
|
let fields =
|
1869
|
("arg",
|
1870
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x) arg0.arg))
|
1871
|
:: fields in
|
1872
|
let fields =
|
1873
|
("id",
|
1874
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)
|
1875
|
arg0.id))
|
1876
|
:: fields in
|
1877
|
`Assoc fields)]
|
1878
|
| AAttAscending -> `List [`String "AAttAscending"])
|
1879
|
[@ocaml.warning "-A"])
|
1880
|
|
1881
|
and (vhdl_array_attributes_t_of_yojson :
|
1882
|
Yojson.Safe.json ->
|
1883
|
vhdl_array_attributes_t Ppx_deriving_yojson_runtime.error_or)
|
1884
|
=
|
1885
|
((let open! Ppx_deriving_yojson_runtime in
|
1886
|
function
|
1887
|
| `List ((`String "AAttInt")::arg0::[]) ->
|
1888
|
((function
|
1889
|
| `Assoc xs ->
|
1890
|
let rec loop xs ((arg0,arg1) as _state) =
|
1891
|
match xs with
|
1892
|
| ("id",x)::xs ->
|
1893
|
loop xs
|
1894
|
(((function
|
1895
|
| `String x -> Result.Ok x
|
1896
|
| _ ->
|
1897
|
Result.Error
|
1898
|
"Vhdl_ast.vhdl_array_attributes_t.id") x),
|
1899
|
arg1)
|
1900
|
| ("arg",x)::xs ->
|
1901
|
loop xs
|
1902
|
(arg0,
|
1903
|
((function
|
1904
|
| `Int x -> Result.Ok x
|
1905
|
| _ ->
|
1906
|
Result.Error
|
1907
|
"Vhdl_ast.vhdl_array_attributes_t.arg") x))
|
1908
|
| [] ->
|
1909
|
arg1 >>=
|
1910
|
((fun arg1 ->
|
1911
|
arg0 >>=
|
1912
|
(fun arg0 ->
|
1913
|
Result.Ok
|
1914
|
(AAttInt { id = arg0; arg = arg1 }))))
|
1915
|
| _::xs -> loop xs _state in
|
1916
|
loop xs
|
1917
|
((Result.Error "Vhdl_ast.vhdl_array_attributes_t.id"),
|
1918
|
(Result.Error "Vhdl_ast.vhdl_array_attributes_t.arg"))
|
1919
|
| _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")) arg0
|
1920
|
| `List ((`String "AAttAscending")::[]) -> Result.Ok AAttAscending
|
1921
|
| _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")
|
1922
|
[@ocaml.warning "-A"])
|
1923
|
|
1924
|
and (vhdl_signal_attributes_t_to_yojson :
|
1925
|
vhdl_signal_attributes_t -> Yojson.Safe.json)
|
1926
|
=
|
1927
|
((let open! Ppx_deriving_yojson_runtime in
|
1928
|
function
|
1929
|
| SigAtt arg0 ->
|
1930
|
`List
|
1931
|
[`String "SigAtt";
|
1932
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0])
|
1933
|
[@ocaml.warning "-A"])
|
1934
|
|
1935
|
and (vhdl_signal_attributes_t_of_yojson :
|
1936
|
Yojson.Safe.json ->
|
1937
|
vhdl_signal_attributes_t Ppx_deriving_yojson_runtime.error_or)
|
1938
|
=
|
1939
|
((let open! Ppx_deriving_yojson_runtime in
|
1940
|
function
|
1941
|
| `List ((`String "SigAtt")::arg0::[]) ->
|
1942
|
((function
|
1943
|
| `String x -> Result.Ok x
|
1944
|
| _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t") arg0)
|
1945
|
>>= ((fun arg0 -> Result.Ok (SigAtt arg0)))
|
1946
|
| _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t")
|
1947
|
[@ocaml.warning "-A"])
|
1948
|
|
1949
|
and (vhdl_string_attributes_t_to_yojson :
|
1950
|
vhdl_string_attributes_t -> Yojson.Safe.json)
|
1951
|
=
|
1952
|
((let open! Ppx_deriving_yojson_runtime in
|
1953
|
function
|
1954
|
| StringAtt arg0 ->
|
1955
|
`List
|
1956
|
[`String "StringAtt";
|
1957
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)) arg0])
|
1958
|
[@ocaml.warning "-A"])
|
1959
|
|
1960
|
and (vhdl_string_attributes_t_of_yojson :
|
1961
|
Yojson.Safe.json ->
|
1962
|
vhdl_string_attributes_t Ppx_deriving_yojson_runtime.error_or)
|
1963
|
=
|
1964
|
((let open! Ppx_deriving_yojson_runtime in
|
1965
|
function
|
1966
|
| `List ((`String "StringAtt")::arg0::[]) ->
|
1967
|
((function
|
1968
|
| `String x -> Result.Ok x
|
1969
|
| _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t") arg0)
|
1970
|
>>= ((fun arg0 -> Result.Ok (StringAtt arg0)))
|
1971
|
| _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t")
|
1972
|
[@ocaml.warning "-A"])
|
1973
|
|
1974
|
and (vhdl_suffix_selection_t_to_yojson :
|
1975
|
vhdl_suffix_selection_t -> Yojson.Safe.json)
|
1976
|
=
|
1977
|
((let open! Ppx_deriving_yojson_runtime in
|
1978
|
function
|
1979
|
| Idx arg0 ->
|
1980
|
`List
|
1981
|
[`String "Idx";
|
1982
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg0]
|
1983
|
| SuffixRange (arg0,arg1) ->
|
1984
|
`List
|
1985
|
[`String "SuffixRange";
|
1986
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg0;
|
1987
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x)) arg1])
|
1988
|
[@ocaml.warning "-A"])
|
1989
|
|
1990
|
and (vhdl_suffix_selection_t_of_yojson :
|
1991
|
Yojson.Safe.json ->
|
1992
|
vhdl_suffix_selection_t Ppx_deriving_yojson_runtime.error_or)
|
1993
|
=
|
1994
|
((let open! Ppx_deriving_yojson_runtime in
|
1995
|
function
|
1996
|
| `List ((`String "Idx")::arg0::[]) ->
|
1997
|
((function
|
1998
|
| `Int x -> Result.Ok x
|
1999
|
| _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg0) >>=
|
2000
|
((fun arg0 -> Result.Ok (Idx arg0)))
|
2001
|
| `List ((`String "SuffixRange")::arg0::arg1::[]) ->
|
2002
|
((function
|
2003
|
| `Int x -> Result.Ok x
|
2004
|
| _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg1) >>=
|
2005
|
((fun arg1 ->
|
2006
|
((function
|
2007
|
| `Int x -> Result.Ok x
|
2008
|
| _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
|
2009
|
arg0)
|
2010
|
>>= (fun arg0 -> Result.Ok (SuffixRange (arg0, arg1)))))
|
2011
|
| _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
|
2012
|
[@ocaml.warning "-A"])
|
2013
|
|
2014
|
type 'basetype vhdl_type_attributes_t =
|
2015
|
| TAttNoArg of {
|
2016
|
id: string }
|
2017
|
| TAttIntArg of {
|
2018
|
id: string ;
|
2019
|
arg: int }
|
2020
|
| TAttValArg of {
|
2021
|
id: string ;
|
2022
|
arg: 'basetype }
|
2023
|
| TAttStringArg of {
|
2024
|
id: string ;
|
2025
|
arg: string }
|
2026
|
|
2027
|
let rec pp_vhdl_type_attributes_t
|
2028
|
=
|
2029
|
((let open! Ppx_deriving_runtime in
|
2030
|
fun poly_basetype ->
|
2031
|
fun fmt ->
|
2032
|
function
|
2033
|
| TAttNoArg { id = aid } ->
|
2034
|
(Format.fprintf fmt "@[<2>TAttNoArg {@,";
|
2035
|
(Format.fprintf fmt "@[%s =@ " "id";
|
2036
|
(Format.fprintf fmt "%S") aid;
|
2037
|
Format.fprintf fmt "@]");
|
2038
|
Format.fprintf fmt "@]}")
|
2039
|
| TAttIntArg { id = aid; arg = aarg } ->
|
2040
|
(Format.fprintf fmt "@[<2>TAttIntArg {@,";
|
2041
|
((Format.fprintf fmt "@[%s =@ " "id";
|
2042
|
(Format.fprintf fmt "%S") aid;
|
2043
|
Format.fprintf fmt "@]");
|
2044
|
Format.fprintf fmt ";@ ";
|
2045
|
Format.fprintf fmt "@[%s =@ " "arg";
|
2046
|
(Format.fprintf fmt "%d") aarg;
|
2047
|
Format.fprintf fmt "@]");
|
2048
|
Format.fprintf fmt "@]}")
|
2049
|
| TAttValArg { id = aid; arg = aarg } ->
|
2050
|
(Format.fprintf fmt "@[<2>TAttValArg {@,";
|
2051
|
((Format.fprintf fmt "@[%s =@ " "id";
|
2052
|
(Format.fprintf fmt "%S") aid;
|
2053
|
Format.fprintf fmt "@]");
|
2054
|
Format.fprintf fmt ";@ ";
|
2055
|
Format.fprintf fmt "@[%s =@ " "arg";
|
2056
|
(poly_basetype fmt) aarg;
|
2057
|
Format.fprintf fmt "@]");
|
2058
|
Format.fprintf fmt "@]}")
|
2059
|
| TAttStringArg { id = aid; arg = aarg } ->
|
2060
|
(Format.fprintf fmt "@[<2>TAttStringArg {@,";
|
2061
|
((Format.fprintf fmt "@[%s =@ " "id";
|
2062
|
(Format.fprintf fmt "%S") aid;
|
2063
|
Format.fprintf fmt "@]");
|
2064
|
Format.fprintf fmt ";@ ";
|
2065
|
Format.fprintf fmt "@[%s =@ " "arg";
|
2066
|
(Format.fprintf fmt "%S") aarg;
|
2067
|
Format.fprintf fmt "@]");
|
2068
|
Format.fprintf fmt "@]}"))
|
2069
|
[@ocaml.warning "-A"])
|
2070
|
|
2071
|
and show_vhdl_type_attributes_t =
|
2072
|
fun poly_basetype ->
|
2073
|
fun x ->
|
2074
|
Format.asprintf "%a" (pp_vhdl_type_attributes_t poly_basetype) x
|
2075
|
|
2076
|
let rec vhdl_type_attributes_t_to_yojson :
|
2077
|
'basetype .
|
2078
|
('basetype -> Yojson.Safe.json) ->
|
2079
|
'basetype vhdl_type_attributes_t -> Yojson.Safe.json
|
2080
|
=
|
2081
|
fun poly_basetype ->
|
2082
|
((let open! Ppx_deriving_yojson_runtime in
|
2083
|
function
|
2084
|
| TAttNoArg arg0 ->
|
2085
|
`List
|
2086
|
[`String "TAttNoArg";
|
2087
|
(let fields = [] in
|
2088
|
let fields =
|
2089
|
("id",
|
2090
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)
|
2091
|
arg0.id))
|
2092
|
:: fields in
|
2093
|
`Assoc fields)]
|
2094
|
| TAttIntArg arg0 ->
|
2095
|
`List
|
2096
|
[`String "TAttIntArg";
|
2097
|
(let fields = [] in
|
2098
|
let fields =
|
2099
|
("arg",
|
2100
|
((fun (x : Ppx_deriving_runtime.int) -> `Int x) arg0.arg))
|
2101
|
:: fields in
|
2102
|
let fields =
|
2103
|
("id",
|
2104
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)
|
2105
|
arg0.id))
|
2106
|
:: fields in
|
2107
|
`Assoc fields)]
|
2108
|
| TAttValArg arg0 ->
|
2109
|
`List
|
2110
|
[`String "TAttValArg";
|
2111
|
(let fields = [] in
|
2112
|
let fields =
|
2113
|
("arg", ((poly_basetype : _ -> Yojson.Safe.json) arg0.arg))
|
2114
|
:: fields in
|
2115
|
let fields =
|
2116
|
("id",
|
2117
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)
|
2118
|
arg0.id))
|
2119
|
:: fields in
|
2120
|
`Assoc fields)]
|
2121
|
| TAttStringArg arg0 ->
|
2122
|
`List
|
2123
|
[`String "TAttStringArg";
|
2124
|
(let fields = [] in
|
2125
|
let fields =
|
2126
|
("arg",
|
2127
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)
|
2128
|
arg0.arg))
|
2129
|
:: fields in
|
2130
|
let fields =
|
2131
|
("id",
|
2132
|
((fun (x : Ppx_deriving_runtime.string) -> `String x)
|
2133
|
arg0.id))
|
2134
|
:: fields in
|
2135
|
`Assoc fields)])
|
2136
|
[@ocaml.warning "-A"])
|
2137
|
|
2138
|
and vhdl_type_attributes_t_of_yojson :
|
2139
|
'basetype .
|
2140
|
(Yojson.Safe.json -> 'basetype Ppx_deriving_yojson_runtime.error_or) ->
|
2141
|
Yojson.Safe.json ->
|
2142
|
'basetype vhdl_type_attributes_t Ppx_deriving_yojson_runtime.error_or
|
2143
|
=
|
2144
|
fun poly_basetype ->
|
2145
|
((let open! Ppx_deriving_yojson_runtime in
|
2146
|
function
|
2147
|
| `List ((`String "TAttNoArg")::arg0::[]) ->
|
2148
|
((function
|
2149
|
| `Assoc xs ->
|
2150
|
let rec loop xs (arg0 as _state) =
|
2151
|
match xs with
|
2152
|
| ("id",x)::xs ->
|
2153
|
loop xs
|
2154
|
((function
|
2155
|
| `String x -> Result.Ok x
|
2156
|
| _ ->
|
2157
|
Result.Error
|
2158
|
"Vhdl_ast.vhdl_type_attributes_t.id") x)
|
2159
|
| [] ->
|
2160
|
arg0 >>=
|
2161
|
((fun arg0 -> Result.Ok (TAttNoArg { id = arg0 })))
|
2162
|
| _::xs -> loop xs _state in
|
2163
|
loop xs (Result.Error "Vhdl_ast.vhdl_type_attributes_t.id")
|
2164
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
|
2165
|
| `List ((`String "TAttIntArg")::arg0::[]) ->
|
2166
|
((function
|
2167
|
| `Assoc xs ->
|
2168
|
let rec loop xs ((arg0,arg1) as _state) =
|
2169
|
match xs with
|
2170
|
| ("id",x)::xs ->
|
2171
|
loop xs
|
2172
|
(((function
|
2173
|
| `String x -> Result.Ok x
|
2174
|
| _ ->
|
2175
|
Result.Error
|
2176
|
"Vhdl_ast.vhdl_type_attributes_t.id") x),
|
2177
|
arg1)
|
2178
|
| ("arg",x)::xs ->
|
2179
|
loop xs
|
2180
|
(arg0,
|
2181
|
((function
|
2182
|
| `Int x -> Result.Ok x
|
2183
|
| _ ->
|
2184
|
Result.Error
|
2185
|
"Vhdl_ast.vhdl_type_attributes_t.arg") x))
|
2186
|
| [] ->
|
2187
|
arg1 >>=
|
2188
|
((fun arg1 ->
|
2189
|
arg0 >>=
|
2190
|
(fun arg0 ->
|
2191
|
Result.Ok
|
2192
|
(TAttIntArg { id = arg0; arg = arg1 }))))
|
2193
|
| _::xs -> loop xs _state in
|
2194
|
loop xs
|
2195
|
((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
|
2196
|
(Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
|
2197
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
|
2198
|
| `List ((`String "TAttValArg")::arg0::[]) ->
|
2199
|
((function
|
2200
|
| `Assoc xs ->
|
2201
|
let rec loop xs ((arg0,arg1) as _state) =
|
2202
|
match xs with
|
2203
|
| ("id",x)::xs ->
|
2204
|
loop xs
|
2205
|
(((function
|
2206
|
| `String x -> Result.Ok x
|
2207
|
| _ ->
|
2208
|
Result.Error
|
2209
|
"Vhdl_ast.vhdl_type_attributes_t.id") x),
|
2210
|
arg1)
|
2211
|
| ("arg",x)::xs ->
|
2212
|
loop xs
|
2213
|
(arg0,
|
2214
|
((poly_basetype : Yojson.Safe.json -> _ error_or)
|
2215
|
x))
|
2216
|
| [] ->
|
2217
|
arg1 >>=
|
2218
|
((fun arg1 ->
|
2219
|
arg0 >>=
|
2220
|
(fun arg0 ->
|
2221
|
Result.Ok
|
2222
|
(TAttValArg { id = arg0; arg = arg1 }))))
|
2223
|
| _::xs -> loop xs _state in
|
2224
|
loop xs
|
2225
|
((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
|
2226
|
(Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
|
2227
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
|
2228
|
| `List ((`String "TAttStringArg")::arg0::[]) ->
|
2229
|
((function
|
2230
|
| `Assoc xs ->
|
2231
|
let rec loop xs ((arg0,arg1) as _state) =
|
2232
|
match xs with
|
2233
|
| ("id",x)::xs ->
|
2234
|
loop xs
|
2235
|
(((function
|
2236
|
| `String x -> Result.Ok x
|
2237
|
| _ ->
|
2238
|
Result.Error
|
2239
|
"Vhdl_ast.vhdl_type_attributes_t.id") x),
|
2240
|
arg1)
|
2241
|
| ("arg",x)::xs ->
|
2242
|
loop xs
|
2243
|
(arg0,
|
2244
|
((function
|
2245
|
| `String x -> Result.Ok x
|
2246
|
| _ ->
|
2247
|
Result.Error
|
2248
|
"Vhdl_ast.vhdl_type_attributes_t.arg") x))
|
2249
|
| [] ->
|
2250
|
arg1 >>=
|
2251
|
((fun arg1 ->
|
2252
|
arg0 >>=
|
2253
|
(fun arg0 ->
|
2254
|
Result.Ok
|
2255
|
(TAttStringArg { id = arg0; arg = arg1 }))))
|
2256
|
| _::xs -> loop xs _state in
|
2257
|
loop xs
|
2258
|
((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
|
2259
|
(Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
|
2260
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
|
2261
|
| _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")
|
2262
|
[@ocaml.warning "-A"])
|
2263
|
|
2264
|
let typ_att_noarg = ["base"; "left"; "right"; "high"; "low"]
|
2265
|
let typ_att_intarg = ["pos"; "val"; "succ"; "pred"; "leftof"; "rightof"]
|
2266
|
let typ_att_valarg = ["image"]
|
2267
|
let typ_att_stringarg = ["value"]
|
2268
|
let array_att_intarg =
|
2269
|
["left"; "right"; "high"; "low"; "range"; "reverse_range"; "length"]
|
2270
|
type vhdl_parameter_t =
|
2271
|
{
|
2272
|
names: vhdl_name_t list ;
|
2273
|
mode: string list [@default []];
|
2274
|
typ: vhdl_subtype_indication_t ;
|
2275
|
init_val: vhdl_cst_val_t option [@default None]}
|
2276
|
|
2277
|
let rec pp_vhdl_parameter_t :
|
2278
|
Format.formatter -> vhdl_parameter_t -> Ppx_deriving_runtime.unit =
|
2279
|
let __2 () = pp_vhdl_cst_val_t
|
2280
|
|
2281
|
and __1 () = pp_vhdl_subtype_indication_t
|
2282
|
|
2283
|
and __0 () = pp_vhdl_name_t
|
2284
|
in
|
2285
|
((let open! Ppx_deriving_runtime in
|
2286
|
fun fmt ->
|
2287
|
fun x ->
|
2288
|
Format.fprintf fmt "@[<2>{ ";
|
2289
|
((((Format.fprintf fmt "@[%s =@ " "names";
|
2290
|
((fun x ->
|
2291
|
Format.fprintf fmt "@[<2>[";
|
2292
|
ignore
|
2293
|
(List.fold_left
|
2294
|
(fun sep ->
|
2295
|
fun x ->
|
2296
|
if sep then Format.fprintf fmt ";@ ";
|
2297
|
((__0 ()) fmt) x;
|
2298
|
true) false x);
|
2299
|
Format.fprintf fmt "@,]@]")) x.names;
|
2300
|
Format.fprintf fmt "@]");
|
2301
|
Format.fprintf fmt ";@ ";
|
2302
|
Format.fprintf fmt "@[%s =@ " "mode";
|
2303
|
((fun x ->
|
2304
|
Format.fprintf fmt "@[<2>[";
|
2305
|
ignore
|
2306
|
(List.fold_left
|
2307
|
(fun sep ->
|
2308
|
fun x ->
|
2309
|
if sep then Format.fprintf fmt ";@ ";
|
2310
|
(Format.fprintf fmt "%S") x;
|
2311
|
true) false x);
|
2312
|
Format.fprintf fmt "@,]@]")) x.mode;
|
2313
|
Format.fprintf fmt "@]");
|
2314
|
Format.fprintf fmt ";@ ";
|
2315
|
Format.fprintf fmt "@[%s =@ " "typ";
|
2316
|
((__1 ()) fmt) x.typ;
|
2317
|
Format.fprintf fmt "@]");
|
2318
|
Format.fprintf fmt ";@ ";
|
2319
|
Format.fprintf fmt "@[%s =@ " "init_val";
|
2320
|
((function
|
2321
|
| None -> Format.pp_print_string fmt "None"
|
2322
|
| Some x ->
|
2323
|
(Format.pp_print_string fmt "(Some ";
|
2324
|
((__2 ()) fmt) x;
|
2325
|
Format.pp_print_string fmt ")"))) x.init_val;
|
2326
|
Format.fprintf fmt "@]");
|
2327
|
Format.fprintf fmt "@ }@]")
|
2328
|
[@ocaml.warning "-A"])
|
2329
|
|
2330
|
and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string =
|
2331
|
fun x -> Format.asprintf "%a" pp_vhdl_parameter_t x
|
2332
|
|
2333
|
let rec (vhdl_parameter_t_to_yojson : vhdl_parameter_t -> Yojson.Safe.json) =
|
2334
|
((let open! Ppx_deriving_yojson_runtime in
|
2335
|
fun x ->
|
2336
|
let fields = [] in
|
2337
|
let fields =
|
2338
|
if x.init_val = None
|
2339
|
then fields
|
2340
|
else
|
2341
|
("init_val",
|
2342
|
(((function
|
2343
|
| None -> `Null
|
2344
|
| Some x -> ((fun x -> vhdl_cst_val_t_to_yojson x)) x))
|
2345
|
x.init_val))
|
2346
|
:: fields
|
2347
|
in
|
2348
|
let fields =
|
2349
|
("typ", ((fun x -> vhdl_subtype_indication_t_to_yojson x) x.typ))
|
2350
|
:: fields in
|
2351
|
let fields =
|
2352
|
if x.mode = []
|
2353
|
then fields
|
2354
|
else
|
2355
|
("mode",
|
2356
|
(((fun x ->
|
2357
|
`List
|
2358
|
(List.map
|
2359
|
(fun (x : Ppx_deriving_runtime.string) -> `String x)
|
2360
|
x))) x.mode))
|
2361
|
:: fields
|
2362
|
in
|
2363
|
let fields =
|
2364
|
("names",
|
2365
|
((fun x ->
|
2366
|
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x))
|
2367
|
x.names))
|
2368
|
:: fields in
|
2369
|
`Assoc fields)
|
2370
|
[@ocaml.warning "-A"])
|
2371
|
|
2372
|
and (vhdl_parameter_t_of_yojson :
|
2373
|
Yojson.Safe.json ->
|
2374
|
vhdl_parameter_t Ppx_deriving_yojson_runtime.error_or)
|
2375
|
=
|
2376
|
((let open! Ppx_deriving_yojson_runtime in
|
2377
|
function
|
2378
|
| `Assoc xs ->
|
2379
|
let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
|
2380
|
match xs with
|
2381
|
| ("names",x)::xs ->
|
2382
|
loop xs
|
2383
|
(((function
|
2384
|
| `List xs ->
|
2385
|
map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs
|
2386
|
| _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.names") x),
|
2387
|
arg1, arg2, arg3)
|
2388
|
| ("mode",x)::xs ->
|
2389
|
loop xs
|
2390
|
(arg0,
|
2391
|
((function
|
2392
|
| `List xs ->
|
2393
|
map_bind
|
2394
|
(function
|
2395
|
| `String x -> Result.Ok x
|
2396
|
| _ ->
|
2397
|
Result.Error
|
2398
|
"Vhdl_ast.vhdl_parameter_t.mode") [] xs
|
2399
|
| _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.mode") x),
|
2400
|
arg2, arg3)
|
2401
|
| ("typ",x)::xs ->
|
2402
|
loop xs
|
2403
|
(arg0, arg1,
|
2404
|
((fun x -> vhdl_subtype_indication_t_of_yojson x) x),
|
2405
|
arg3)
|
2406
|
| ("init_val",x)::xs ->
|
2407
|
loop xs
|
2408
|
(arg0, arg1, arg2,
|
2409
|
((function
|
2410
|
| `Null -> Result.Ok None
|
2411
|
| x ->
|
2412
|
((fun x -> vhdl_cst_val_t_of_yojson x) x) >>=
|
2413
|
((fun x -> Result.Ok (Some x)))) x))
|
2414
|
| [] ->
|
2415
|
arg3 >>=
|
2416
|
((fun arg3 ->
|
2417
|
arg2 >>=
|
2418
|
(fun arg2 ->
|
2419
|
arg1 >>=
|
2420
|
(fun arg1 ->
|
2421
|
arg0 >>=
|
2422
|
(fun arg0 ->
|
2423
|
Result.Ok
|
2424
|
{
|
2425
|
names = arg0;
|
2426
|
mode = arg1;
|
2427
|
typ = arg2;
|
2428
|
init_val = arg3
|
2429
|
})))))
|
2430
|
| _::xs -> loop xs _state in
|
2431
|
loop xs
|
2432
|
((Result.Error "Vhdl_ast.vhdl_parameter_t.names"),
|
2433
|
(Result.Ok []), (Result.Error "Vhdl_ast.vhdl_parameter_t.typ"),
|
2434
|
(Result.Ok (Some (CstInt 0))))
|
2435
|
| _ -> Result.Error "Vhdl_ast.vhdl_parameter_t")
|
2436
|
[@ocaml.warning "-A"])
|
2437
|
|
2438
|
type vhdl_subprogram_spec_t =
|
2439
|
{
|
2440
|
name: string [@default ""];
|
2441
|
typeMark: vhdl_name_t [@default NoName];
|
2442
|
parameters: vhdl_parameter_t list ;
|
2443
|
isPure: bool [@default false]}
|
2444
|
|
2445
|
let rec pp_vhdl_subprogram_spec_t :
|
2446
|
Format.formatter -> vhdl_subprogram_spec_t -> Ppx_deriving_runtime.unit =
|
2447
|
let __1 () = pp_vhdl_parameter_t
|
2448
|
|
2449
|
and __0 () = pp_vhdl_name_t
|
2450
|
in
|
2451
|
((let open! Ppx_deriving_runtime in
|
2452
|
fun fmt ->
|
2453
|
fun x ->
|
2454
|
Format.fprintf fmt "@[<2>{ ";
|
2455
|
((((Format.fprintf fmt "@[%s =@ " "name";
|
2456
|
(Format.fprintf fmt "%S") x.name;
|
2457
|
Format.fprintf fmt "@]");
|
2458
|
Format.fprintf fmt ";@ ";
|
2459
|
Format.fprintf fmt "@[%s =@ " "typeMark";
|
2460
|
((__0 ()) fmt) x.typeMark;
|
2461
|
Format.fprintf fmt "@]");
|
2462
|
Format.fprintf fmt ";@ ";
|
2463
|
Format.fprintf fmt "@[%s =@ " "parameters";
|
2464
|
((fun x ->
|
2465
|
Format.fprintf fmt "@[<2>[";
|
2466
|
ignore
|
2467
|
(List.fold_left
|
2468
|
(fun sep ->
|
2469
|
fun x ->
|
2470
|
if sep then Format.fprintf fmt ";@ ";
|
2471
|
((__1 ()) fmt) x;
|
2472
|
true) false x);
|
2473
|
Format.fprintf fmt "@,]@]")) x.parameters;
|
2474
|
Format.fprintf fmt "@]");
|
2475
|
Format.fprintf fmt ";@ ";
|
2476
|
Format.fprintf fmt "@[%s =@ " "isPure";
|
2477
|
(Format.fprintf fmt "%B") x.isPure;
|
2478
|
Format.fprintf fmt "@]");
|
2479
|
Format.fprintf fmt "@ }@]")
|
2480
|
[@ocaml.warning "-A"])
|
2481
|
|
2482
|
and show_vhdl_subprogram_spec_t :
|
2483
|
vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string =
|
2484
|
fun x -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x
|
2485
|
|
2486
|
let rec (vhdl_subprogram_spec_t_to_yojson :
|
2487
|
vhdl_subprogram_spec_t -> Yojson.Safe.json)
|
2488
|
=
|
2489
|
((let open! Ppx_deriving_yojson_runtime in
|
2490
|
fun x ->
|
2491
|
let fields = [] in
|
2492
|
let fields =
|
2493
|
if x.isPure = false
|
2494
|
then fields
|
2495
|
else
|
2496
|
("isPure",
|
2497
|
(((fun (x : Ppx_deriving_runtime.bool) -> `Bool x)) x.isPure))
|
2498
|
:: fields
|
2499
|
in
|
2500
|
let fields =
|
2501
|
("parameters",
|
2502
|
((fun x ->
|
2503
|
`List (List.map (fun x -> vhdl_parameter_t_to_yojson x) x))
|
2504
|
x.parameters))
|
2505
|
:: fields in
|
2506
|
let fields =
|
2507
|
if x.typeMark = NoName
|
2508
|
then fields
|
2509
|
else
|
2510
|
("typeMark", (((fun x -> vhdl_name_t_to_yojson x)) x.typeMark))
|
2511
|
:: fields
|
2512
|
in
|
2513
|
let fields =
|
2514
|
if x.name = ""
|
2515
|
then fields
|
2516
|
else
|
2517
|
("name",
|
2518
|
(((fun (x : Ppx_deriving_runtime.string) -> `String x)) x.name))
|
2519
|
:: fields
|
2520
|
in
|
2521
|
`Assoc fields)
|
2522
|
[@ocaml.warning "-A"])
|
2523
|
|
2524
|
and (vhdl_subprogram_spec_t_of_yojson :
|
2525
|
Yojson.Safe.json ->
|
2526
|
vhdl_subprogram_spec_t Ppx_deriving_yojson_runtime.error_or)
|
2527
|
=
|
2528
|
((let open! Ppx_deriving_yojson_runtime in
|
2529
|
function
|
2530
|
| `Assoc xs ->
|
2531
|
let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
|
2532
|
match xs with
|
2533
|
| ("name",x)::xs ->
|
2534
|
loop xs
|
2535
|
(((function
|
2536
|
| `String x -> Result.Ok x
|
2537
|
| _ ->
|
2538
|
Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.name")
|
2539
|
x), arg1, arg2, arg3)
|
2540
|
| ("typeMark",x)::xs ->
|
2541
|
loop xs
|
2542
|
(arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2, arg3)
|
2543
|
| ("parameters",x)::xs ->
|
2544
|
loop xs
|
2545
|
(arg0, arg1,
|
2546
|
((function
|
2547
|
| `List xs ->
|
2548
|
map_bind (fun x -> vhdl_parameter_t_of_yojson x)
|
2549
|
[] xs
|
2550
|
| _ ->
|
2551
|
Result.Error
|
2552
|
"Vhdl_ast.vhdl_subprogram_spec_t.parameters") x),
|
2553
|
arg3)
|
2554
|
| ("isPure",x)::xs ->
|
2555
|
loop xs
|
2556
|
(arg0, arg1, arg2,
|
2557
|
((function
|
2558
|
| `Bool x -> Result.Ok x
|
2559
|
| _ ->
|
2560
|
Result.Error
|
2561
|
"Vhdl_ast.vhdl_subprogram_spec_t.isPure") x))
|
2562
|
| [] ->
|
2563
|
arg3 >>=
|
2564
|
((fun arg3 ->
|
2565
|
arg2 >>=
|
2566
|
(fun arg2 ->
|
2567
|
arg1 >>=
|
2568
|
(fun arg1 ->
|
2569
|
arg0 >>=
|
2570
|
(fun arg0 ->
|
2571
|
Result.Ok
|
2572
|
{
|
2573
|
name = arg0;
|
2574
|
typeMark = arg1;
|
2575
|
parameters = arg2;
|
2576
|
isPure = arg3
|
2577
|
})))))
|
2578
|
| _::xs -> loop xs _state in
|
2579
|
loop xs
|
2580
|
((Result.Ok ""), (Result.Ok NoName),
|
2581
|
(Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.parameters"),
|
2582
|
(Result.Ok false))
|
2583
|
| _ -> Result.Error "Vhdl_ast.vhdl_subprogram_spec_t")
|
2584
|
[@ocaml.warning "-A"])
|
2585
|
|
2586
|
let arith_funs = ["+"; "-"; "*"; "/"; "mod"; "rem"; "abs"; "**"; "&"]
|
2587
|
let bool_funs = ["and"; "or"; "nand"; "nor"; "xor"; "not"]
|
2588
|
let rel_funs =
|
2589
|
["<";
|
2590
|
">";
|
2591
|
"<=";
|
2592
|
">=";
|
2593
|
"/=";
|
2594
|
"=";
|
2595
|
"?=";
|
2596
|
"?/=";
|
2597
|
"?<";
|
2598
|
"?<=";
|
2599
|
"?>";
|
2600
|
"?>=";
|
2601
|
"??"]
|
2602
|
let shift_funs = ["sll"; "srl"; "sla"; "sra"; "rol"; "ror"]
|
2603
|
type vhdl_sequential_stmt_t =
|
2604
|
| VarAssign of
|
2605
|
{
|
2606
|
label: vhdl_name_t [@default NoName];
|
2607
|
lhs: vhdl_name_t ;
|
2608
|
rhs: vhdl_expr_t } [@name "VARIABLE_ASSIGNMENT_STATEMENT"]
|
2609
|
| SigSeqAssign of
|
2610
|
{
|
2611
|
label: vhdl_name_t [@default NoName];
|
2612
|
lhs: vhdl_name_t ;
|
2613
|
rhs: vhdl_expr_t list } [@name "SIGNAL_ASSIGNMENT_STATEMENT"]
|
2614
|
| If of
|
2615
|
{
|
2616
|
label: vhdl_name_t [@default NoName];
|
2617
|
if_cases: vhdl_if_case_t list ;
|
2618
|
default: vhdl_sequential_stmt_t list [@default []]} [@name "IF_STATEMENT"]
|
2619
|
| Case of
|
2620
|
{
|
2621
|
label: vhdl_name_t [@default NoName];
|
2622
|
guard: vhdl_expr_t ;
|
2623
|
branches: vhdl_case_item_t list } [@name "CASE_STATEMENT_TREE"]
|
2624
|
| Exit of
|
2625
|
{
|
2626
|
label: vhdl_name_t [@default NoName];
|
2627
|
loop_label: string option [@default Some ""];
|
2628
|
condition: vhdl_expr_t option [@default Some IsNull]}
|
2629
|
[@name "EXIT_STATEMENT"]
|
2630
|
| Assert of
|
2631
|
{
|
2632
|
label: vhdl_name_t [@default NoName];
|
2633
|
cond: vhdl_expr_t ;
|
2634
|
report: vhdl_expr_t [@default IsNull];
|
2635
|
severity: vhdl_expr_t [@default IsNull]} [@name "ASSERTION_STATEMENT"]
|
2636
|
| Wait [@name "WAIT_STATEMENT"]
|
2637
|
| Null of {
|
2638
|
label: vhdl_name_t [@default NoName]} [@name "NULL_STATEMENT"]
|
2639
|
| Return of {
|
2640
|
label: vhdl_name_t [@default NoName]} [@name "RETURN_STATEMENT"]
|
2641
|
and vhdl_if_case_t =
|
2642
|
{
|
2643
|
if_cond: vhdl_expr_t ;
|
2644
|
if_block: vhdl_sequential_stmt_t list }
|
2645
|
and vhdl_case_item_t =
|
2646
|
{
|
2647
|
when_cond: vhdl_expr_t list ;
|
2648
|
when_stmt: vhdl_sequential_stmt_t list }
|
2649
|
|
2650
|
let rec pp_vhdl_sequential_stmt_t :
|
2651
|
Format.formatter -> vhdl_sequential_stmt_t -> Ppx_deriving_runtime.unit =
|
2652
|
let __19 () = pp_vhdl_name_t
|
2653
|
|
2654
|
and __18 () = pp_vhdl_name_t
|
2655
|
|
2656
|
and __17 () = pp_vhdl_expr_t
|
2657
|
|
2658
|
and __16 () = pp_vhdl_expr_t
|
2659
|
|
2660
|
and __15 () = pp_vhdl_expr_t
|
2661
|
|
2662
|
and __14 () = pp_vhdl_name_t
|
2663
|
|
2664
|
and __13 () = pp_vhdl_expr_t
|
2665
|
|
2666
|
and __12 () = pp_vhdl_name_t
|
2667
|
|
2668
|
and __11 () = pp_vhdl_case_item_t
|
2669
|
|
2670
|
and __10 () = pp_vhdl_expr_t
|
2671
|
|
2672
|
and __9 () = pp_vhdl_name_t
|
2673
|
|
2674
|
and __8 () = pp_vhdl_sequential_stmt_t
|
2675
|
|
2676
|
and __7 () = pp_vhdl_if_case_t
|
2677
|
|
2678
|
and __6 () = pp_vhdl_name_t
|
2679
|
|
2680
|
and __5 () = pp_vhdl_expr_t
|
2681
|
|
2682
|
and __4 () = pp_vhdl_name_t
|
2683
|
|
2684
|
and __3 () = pp_vhdl_name_t
|
2685
|
|
2686
|
and __2 () = pp_vhdl_expr_t
|
2687
|
|
2688
|
and __1 () = pp_vhdl_name_t
|
2689
|
|
2690
|
and __0 () = pp_vhdl_name_t
|
2691
|
in
|
2692
|
((let open! Ppx_deriving_runtime in
|
2693
|
fun fmt ->
|
2694
|
function
|
2695
|
| VarAssign { label = alabel; lhs = alhs; rhs = arhs } ->
|
2696
|
(match alabel with
|
2697
|
| NoName -> Format.fprintf fmt "";
|
2698
|
| _ -> (((__0 ()) fmt) alabel;
|
2699
|
Format.fprintf fmt ":@ ")
|
2700
|
);
|
2701
|
Format.fprintf fmt "@[<2>";
|
2702
|
((__1 ()) fmt) alhs;
|
2703
|
Format.fprintf fmt "@ :=@ ";
|
2704
|
((__2 ()) fmt) arhs;
|
2705
|
Format.fprintf fmt "@]";
|
2706
|
(* TODO: Check
|
2707
|
(Format.fprintf fmt "@[<2>VarAssign {@,";
|
2708
|
(((Format.fprintf fmt "@[%s =@ " "label";
|
2709
|
((__0 ()) fmt) alabel;
|
2710
|
Format.fprintf fmt "@]");
|
2711
|
Format.fprintf fmt ";@ ";
|
2712
|
Format.fprintf fmt "@[%s =@ " "lhs";
|
2713
|
((__1 ()) fmt) alhs;
|
2714
|
Format.fprintf fmt "@]");
|
2715
|
Format.fprintf fmt ";@ ";
|
2716
|
Format.fprintf fmt "@[%s =@ " "rhs";
|
2717
|
((__2 ()) fmt) arhs;
|
2718
|
Format.fprintf fmt "@]");
|
2719
|
Format.fprintf fmt "@]}") *)
|
2720
|
| SigSeqAssign { label = alabel; lhs = alhs; rhs = arhs } ->
|
2721
|
(match alabel with
|
2722
|
| NoName -> Format.fprintf fmt "";
|
2723
|
| _ -> (((__3 ()) fmt) alabel;
|
2724
|
Format.fprintf fmt ":@ ")
|
2725
|
);
|
2726
|
Format.fprintf fmt "@[<2>";
|
2727
|
((__4 ()) fmt) alhs;
|
2728
|
Format.fprintf fmt "@ <=@ ";
|
2729
|
((fun x ->
|
2730
|
Format.fprintf fmt "@[";
|
2731
|
ignore
|
2732
|
(List.fold_left
|
2733
|
(fun sep ->
|
2734
|
fun x ->
|
2735
|
if sep then Format.fprintf fmt "";
|
2736
|
((__5 ()) fmt) x;
|
2737
|
Format.fprintf fmt ";";
|
2738
|
true) false x);
|
2739
|
Format.fprintf fmt "@]@]")) arhs;
|
2740
|
| If { label = alabel; if_cases = aif_cases; default = adefault } ->
|
2741
|
(match alabel with
|
2742
|
| NoName -> Format.fprintf fmt "";
|
2743
|
| _ -> (((__6 ()) fmt) alabel;
|
2744
|
Format.fprintf fmt ":@ ")
|
2745
|
);
|
2746
|
Format.fprintf fmt "@[<v>if";
|
2747
|
((fun x ->
|
2748
|
ignore
|
2749
|
(List.fold_left
|
2750
|
(fun sep ->
|
2751
|
fun x ->
|
2752
|
if sep then Format.fprintf fmt "@;elseif";
|
2753
|
((__7 ()) fmt) x;
|
2754
|
true
|
2755
|
) false x);
|
2756
|
)) aif_cases;
|
2757
|
(match adefault with
|
2758
|
| [] -> Format.fprintf fmt "";
|
2759
|
| _ -> (Format.fprintf fmt "@;else";
|
2760
|
((fun x ->
|
2761
|
Format.fprintf fmt "@;<0 2>";
|
2762
|
ignore
|
2763
|
(List.fold_left
|
2764
|
(fun sep ->
|
2765
|
fun x ->
|
2766
|
if sep then Format.fprintf fmt "";
|
2767
|
((__8 ()) fmt) x;
|
2768
|
true) false x))) adefault));
|
2769
|
Format.fprintf fmt "@;end if;@]"
|
2770
|
| Case { label = alabel; guard = aguard; branches = abranches } ->
|
2771
|
(match alabel with
|
2772
|
| NoName -> Format.fprintf fmt "";
|
2773
|
| _ -> (((__9 ()) fmt) alabel;
|
2774
|
Format.fprintf fmt ":@ ")
|
2775
|
);
|
2776
|
Format.fprintf fmt "@[<v>case ";
|
2777
|
((__10 ()) fmt) aguard;
|
2778
|
Format.fprintf fmt " is";
|
2779
|
((fun x ->
|
2780
|
ignore
|
2781
|
(List.fold_left
|
2782
|
(fun sep ->
|
2783
|
fun x ->
|
2784
|
if sep then Format.fprintf fmt "";
|
2785
|
((__11 ()) fmt) x;
|
2786
|
true) false x);)) abranches;
|
2787
|
Format.fprintf fmt "@;end case;@]";
|
2788
|
| Exit
|
2789
|
{ label = alabel; loop_label = aloop_label;
|
2790
|
condition = acondition }
|
2791
|
->
|
2792
|
(match alabel with
|
2793
|
| NoName -> Format.fprintf fmt "";
|
2794
|
| _ -> (((__12 ()) fmt) alabel;
|
2795
|
Format.fprintf fmt ":@ ")
|
2796
|
);
|
2797
|
Format.fprintf fmt "exit";
|
2798
|
(match aloop_label with
|
2799
|
| None -> Format.pp_print_string fmt ""
|
2800
|
| Some x -> (Format.fprintf fmt "@ %s@ ") x);
|
2801
|
((function
|
2802
|
| None -> Format.pp_print_string fmt ""
|
2803
|
| Some x ->
|
2804
|
(Format.pp_print_string fmt "when@ ";
|
2805
|
((__13 ()) fmt) x;))) acondition;
|
2806
|
| Assert
|
2807
|
{ label = alabel; cond = acond; report = areport;
|
2808
|
severity = aseverity }
|
2809
|
->
|
2810
|
(Format.fprintf fmt "@[<2>Assert {@,";
|
2811
|
((((Format.fprintf fmt "@[%s =@ " "label";
|
2812
|
((__14 ()) fmt) alabel;
|
2813
|
Format.fprintf fmt "@]");
|
2814
|
Format.fprintf fmt ";@ ";
|
2815
|
Format.fprintf fmt "@[%s =@ " "cond";
|
2816
|
((__15 ()) fmt) acond;
|
2817
|
Format.fprintf fmt "@]");
|
2818
|
Format.fprintf fmt ";@ ";
|
2819
|
Format.fprintf fmt "@[%s =@ " "report";
|
2820
|
((__16 ()) fmt) areport;
|
2821
|
Format.fprintf fmt "@]");
|
2822
|
Format.fprintf fmt ";@ ";
|
2823
|
Format.fprintf fmt "@[%s =@ " "severity";
|
2824
|
((__17 ()) fmt) aseverity;
|
2825
|
Format.fprintf fmt "@]");
|
2826
|
Format.fprintf fmt "@]}")
|
2827
|
| Wait -> Format.pp_print_string fmt "wait"
|
2828
|
| Null { label = alabel } ->
|
2829
|
(match alabel with
|
2830
|
| NoName -> Format.fprintf fmt "";
|
2831
|
| _ -> (((__18 ()) fmt) alabel;
|
2832
|
Format.fprintf fmt ":@ ")
|
2833
|
);
|
2834
|
Format.fprintf fmt "null";
|
2835
|
| Return { label = alabel } ->
|
2836
|
(match alabel with
|
2837
|
| NoName -> Format.fprintf fmt "";
|
2838
|
| _ -> (((__19 ()) fmt) alabel;
|
2839
|
Format.fprintf fmt ":@ ")
|
2840
|
);
|
2841
|
Format.fprintf fmt "return";)
|
2842
|
[@ocaml.warning "-A"])
|
2843
|
|
2844
|
and show_vhdl_sequential_stmt_t :
|
2845
|
vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string =
|
2846
|
fun x -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x
|
2847
|
|
2848
|
(* Adapted *)
|
2849
|
and pp_vhdl_if_case_t :
|
2850
|
Format.formatter -> vhdl_if_case_t -> Ppx_deriving_runtime.unit =
|
2851
|
let __1 () = pp_vhdl_sequential_stmt_t
|
2852
|
|
2853
|
and __0 () = pp_vhdl_expr_t
|
2854
|
in
|
2855
|
((let open! Ppx_deriving_runtime in
|
2856
|
fun fmt ->
|
2857
|
fun x ->
|
2858
|
Format.fprintf fmt " (";
|
2859
|
((__0 ()) fmt) x.if_cond;
|
2860
|
Format.fprintf fmt ") then@;<0 2>";
|
2861
|
((fun x ->
|
2862
|
ignore
|
2863
|
(List.fold_left
|
2864
|
(fun sep ->
|
2865
|
fun x ->
|
2866
|
if sep then Format.fprintf fmt "@;<0 2>";
|
2867
|
((__1 ()) fmt) x;
|
2868
|
true) false x);
|
2869
|
)) x.if_block;)
|
2870
|
[@ocaml.warning "-A"])
|
2871
|
|
2872
|
and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string =
|
2873
|
fun x -> Format.asprintf "%a" pp_vhdl_if_case_t x
|
2874
|
|
2875
|
and pp_vhdl_case_item_t :
|
2876
|
Format.formatter -> vhdl_case_item_t -> Ppx_deriving_runtime.unit =
|
2877
|
let __1 () = pp_vhdl_sequential_stmt_t
|
2878
|
|
2879
|
and __0 () = pp_vhdl_expr_t
|
2880
|
in
|
2881
|
((let open! Ppx_deriving_runtime in
|
2882
|
fun fmt ->
|
2883
|
fun x ->
|
2884
|
Format.fprintf fmt "@;<0 2>when ";
|
2885
|
((fun x ->
|
2886
|
ignore
|
2887
|
(List.fold_left
|
2888
|
(fun sep ->
|
2889
|
fun x ->
|
2890
|
if sep then Format.fprintf fmt "@ |@ ";
|
2891
|
((__0 ()) fmt) x;
|
2892
|
true) false x);)) x.when_cond;
|
2893
|
Format.fprintf fmt " => ";
|
2894
|
((fun x ->
|
2895
|
ignore
|
2896
|
(List.fold_left
|
2897
|
(fun sep ->
|
2898
|
fun x ->
|
2899
|
if sep then Format.fprintf fmt "";
|
2900
|
((__1 ()) fmt) x;
|
2901
|
true) false x);)) x.when_stmt)
|
2902
|
[@ocaml.warning "-A"])
|
2903
|
|
2904
|
and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string =
|
2905
|
fun x -> Format.asprintf "%a" pp_vhdl_case_item_t x
|
2906
|
|
2907
|
let rec (vhdl_sequential_stmt_t_to_yojson :
|
2908
|
vhdl_sequential_stmt_t -> Yojson.Safe.json)
|
2909
|
=
|
2910
|
((let open! Ppx_deriving_yojson_runtime in
|
2911
|
function
|
2912
|
| VarAssign arg0 ->
|
2913
|
`List
|
2914
|
[`String "VARIABLE_ASSIGNMENT_STATEMENT";
|
2915
|
(let fields = [] in
|
2916
|
let fields =
|
2917
|
("rhs", ((fun x -> vhdl_expr_t_to_yojson x) arg0.rhs)) ::
|
2918
|
fields in
|
2919
|
let fields =
|
2920
|
("lhs", ((fun x -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
|
2921
|
fields in
|
2922
|
let fields =
|
2923
|
if arg0.label = NoName
|
2924
|
then fields
|
2925
|
else
|
2926
|
("label",
|
2927
|
(((fun x -> vhdl_name_t_to_yojson x)) arg0.label))
|
2928
|
:: fields
|
2929
|
in
|
2930
|
`Assoc fields)]
|
2931
|
| SigSeqAssign arg0 ->
|
2932
|
`List
|
2933
|
[`String "SIGNAL_ASSIGNMENT_STATEMENT";
|
2934
|
(let fields = [] in
|
2935
|
let fields =
|
2936
|
("rhs",
|
2937
|
((fun x ->
|
2938
|
`List (List.map (fun x -> vhdl_expr_t_to_yojson x) x))
|
2939
|
arg0.rhs))
|
2940
|
:: fields in
|
2941
|
let fields =
|
2942
|
("lhs", ((fun x -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
|
2943
|
fields in
|
2944
|
let fields =
|
2945
|
if arg0.label = NoName
|
2946
|
then fields
|
2947
|
else
|
2948
|
("label",
|
2949
|
(((fun x -> vhdl_name_t_to_yojson x)) arg0.label))
|
2950
|
:: fields
|
2951
|
in
|
2952
|
`Assoc fields)]
|
2953
|
| If arg0 ->
|
2954
|
`List
|
2955
|
[`String "IF_STATEMENT";
|
2956
|
(let fields = [] in
|
2957
|
let fields =
|
2958
|
if arg0.default = []
|
2959
|
then fields
|
2960
|
else
|
2961
|
("default",
|
2962
|
(((fun x ->
|
2963
|
`List
|
2964
|
(List.map
|
2965
|
(fun x -> vhdl_sequential_stmt_t_to_yojson x) x)))
|
2966
|
arg0.default))
|
2967
|
:: fields
|
2968
|
in
|
2969
|
let fields =
|
2970
|
("if_cases",
|
2971
|
((fun x ->
|
2972
|
`List
|
2973
|
(List.map (fun x -> vhdl_if_case_t_to_yojson x) x))
|
2974
|
arg0.if_cases))
|
2975
|
:: fields in
|
2976
|
let fields =
|
2977
|
if arg0.label = NoName
|
2978
|
then fields
|
2979
|
else
|
2980
|
("label",
|
2981
|
(((fun x -> vhdl_name_t_to_yojson x)) arg0.label))
|
2982
|
:: fields
|
2983
|
in
|
2984
|
`Assoc fields)]
|
2985
|
| Case arg0 ->
|
2986
|
`List
|
2987
|
[`String "CASE_STATEMENT_TREE";
|
2988
|
(let fields = [] in
|
2989
|
let fields =
|
2990
|
("branches",
|
2991
|
((fun x ->
|
2992
|
`List
|
2993
|
(List.map (fun x -> vhdl_case_item_t_to_yojson x) x))
|
2994
|
arg0.branches))
|
2995
|
:: fields in
|
2996
|
let fields =
|
2997
|
("guard", ((fun x -> vhdl_expr_t_to_yojson x) arg0.guard)) ::
|
2998
|
fields in
|
2999
|
let fields =
|
3000
|
if arg0.label = NoName
|
3001
|
then fields
|
3002
|
else
|
3003
|
("label",
|
3004
|
(((fun x -> vhdl_name_t_to_yojson x)) arg0.label))
|
3005
|
:: fields
|
3006
|
in
|
3007
|
`Assoc fields)]
|
3008
|
| Exit arg0 ->
|
3009
|
`List
|
3010
|
[`String "EXIT_STATEMENT";
|
3011
|
(let fields = [] in
|
3012
|
let fields =
|
3013
|
if arg0.condition = (Some IsNull)
|
3014
|
then fields
|
3015
|
else
|
3016
|
("condition",
|
3017
|
(((function
|
3018
|
| None -> `Null
|
3019
|
| Some x -> ((fun x -> vhdl_expr_t_to_yojson x)) x))
|
3020
|
arg0.condition))
|
3021
|
:: fields
|
3022
|
in
|
3023
|
let fields =
|
3024
|
if arg0.loop_label = (Some "")
|
3025
|
then fields
|
3026
|
else
|
3027
|
("loop_label",
|
3028
|
(((function
|
3029
|
| None -> `Null
|
3030
|
| Some x ->
|
3031
|
((fun (x : Ppx_deriving_runtime.string) ->
|
3032
|
`String x)) x)) arg0.loop_label))
|
3033
|
:: fields
|
3034
|
in
|
3035
|
let fields =
|
3036
|
if arg0.label = NoName
|
3037
|
then fields
|
3038
|
else
|
3039
|
("label",
|
3040
|
(((fun x -> vhdl_name_t_to_yojson x)) arg0.label))
|
3041
|
:: fields
|
3042
|
in
|
3043
|
`Assoc fields)]
|
3044
|
| Assert arg0 ->
|
3045
|
`List
|
3046
|
[`String "ASSERTION_STATEMENT";
|
3047
|
(let fields = [] in
|
3048
|
let fields =
|
3049
|
if arg0.severity = IsNull
|
3050
|
then fields
|
3051
|
else
|
3052
|
("severity",
|
3053
|
(((fun x -> vhdl_expr_t_to_yojson x)) arg0.severity))
|
3054
|
:: fields
|
3055
|
in
|
3056
|
let fields =
|
3057
|
if arg0.report = IsNull
|
3058
|
then fields
|
3059
|
else
|
3060
|
("report",
|
3061
|
(((fun x -> vhdl_expr_t_to_yojson x)) arg0.report))
|
3062
|
:: fields
|
3063
|
in
|
3064
|
let fields =
|
3065
|
("cond", ((fun x -> vhdl_expr_t_to_yojson x) arg0.cond)) ::
|
3066
|
fields in
|
3067
|
let fields =
|
3068
|
if arg0.label = NoName
|
3069
|
then fields
|
3070
|
else
|
3071
|
("label",
|
3072
|
(((fun x -> vhdl_name_t_to_yojson x)) arg0.label))
|
3073
|
:: fields
|
3074
|
in
|
3075
|
`Assoc fields)]
|
3076
|
| Wait -> `List [`String "WAIT_STATEMENT"]
|
3077
|
| Null arg0 ->
|
3078
|
`List
|
3079
|
[`String "NULL_STATEMENT";
|
3080
|
(let fields = [] in
|
3081
|
let fields =
|
3082
|
if arg0.label = NoName
|
3083
|
then fields
|
3084
|
else
|
3085
|
("label",
|
3086
|
(((fun x -> vhdl_name_t_to_yojson x)) arg0.label))
|
3087
|
:: fields
|
3088
|
in
|
3089
|
`Assoc fields)]
|
3090
|
| Return arg0 ->
|
3091
|
`List
|
3092
|
[`String "RETURN_STATEMENT";
|
3093
|
(let fields = [] in
|
3094
|
let fields =
|
3095
|
if arg0.label = NoName
|
3096
|
then fields
|
3097
|
else
|
3098
|
("label",
|
3099
|
(((fun x -> vhdl_name_t_to_yojson x)) arg0.label))
|
3100
|
:: fields
|
3101
|
in
|
3102
|
`Assoc fields)])
|
3103
|
[@ocaml.warning "-A"])
|
3104
|
|
3105
|
and (vhdl_sequential_stmt_t_of_yojson :
|
3106
|
Yojson.Safe.json ->
|
3107
|
vhdl_sequential_stmt_t Ppx_deriving_yojson_runtime.error_or)
|
3108
|
=
|
3109
|
((let open! Ppx_deriving_yojson_runtime in
|
3110
|
function
|
3111
|
| `List ((`String "VARIABLE_ASSIGNMENT_STATEMENT")::arg0::[]) ->
|
3112
|
((function
|
3113
|
| `Assoc xs ->
|
3114
|
let rec loop xs ((arg0,arg1,arg2) as _state) =
|
3115
|
match xs with
|
3116
|
| ("label",x)::xs ->
|
3117
|
loop xs
|
3118
|
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2)
|
3119
|
| ("lhs",x)::xs ->
|
3120
|
loop xs
|
3121
|
(arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2)
|
3122
|
| ("rhs",x)::xs ->
|
3123
|
loop xs
|
3124
|
(arg0, arg1, ((fun x -> vhdl_expr_t_of_yojson x) x))
|
3125
|
| [] ->
|
3126
|
arg2 >>=
|
3127
|
((fun arg2 ->
|
3128
|
arg1 >>=
|
3129
|
(fun arg1 ->
|
3130
|
arg0 >>=
|
3131
|
(fun arg0 ->
|
3132
|
Result.Ok
|
3133
|
(VarAssign
|
3134
|
{
|
3135
|
label = arg0;
|
3136
|
lhs = arg1;
|
3137
|
rhs = arg2
|
3138
|
})))))
|
3139
|
| _::xs -> loop xs _state in
|
3140
|
loop xs
|
3141
|
((Result.Ok NoName),
|
3142
|
(Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
|
3143
|
(Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
|
3144
|
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
|
3145
|
| `List ((`String "SIGNAL_ASSIGNMENT_STATEMENT")::arg0::[]) ->
|
3146
|
((function
|
3147
|
| `Assoc xs ->
|
3148
|
let rec loop xs ((arg0,arg1,arg2) as _state) =
|
3149
|
match xs with
|
3150
|
| ("label",x)::xs ->
|
3151
|
loop xs
|
3152
|
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2)
|
3153
|
| ("lhs",x)::xs ->
|
3154
|
loop xs
|
3155
|
(arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2)
|
3156
|
| ("rhs",x)::xs ->
|
3157
|
loop xs
|
3158
|
(arg0, arg1,
|
3159
|
((function
|
3160
|
| `List xs ->
|
3161
|
map_bind (fun x -> vhdl_expr_t_of_yojson x)
|
3162
|
[] xs
|
3163
|
| _ ->
|
3164
|
Result.Error
|
3165
|
"Vhdl_ast.vhdl_sequential_stmt_t.rhs") x))
|
3166
|
| [] ->
|
3167
|
arg2 >>=
|
3168
|
((fun arg2 ->
|
3169
|
arg1 >>=
|
3170
|
(fun arg1 ->
|
3171
|
arg0 >>=
|
3172
|
(fun arg0 ->
|
3173
|
Result.Ok
|
3174
|
(SigSeqAssign
|
3175
|
{
|
3176
|
label = arg0;
|
3177
|
lhs = arg1;
|
3178
|
rhs = arg2
|
3179
|
})))))
|
3180
|
| _::xs -> loop xs _state in
|
3181
|
loop xs
|
3182
|
((Result.Ok NoName),
|
3183
|
(Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
|
3184
|
(Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
|
3185
|
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
|
3186
|
| `List ((`String "IF_STATEMENT")::arg0::[]) ->
|
3187
|
((function
|
3188
|
| `Assoc xs ->
|
3189
|
let rec loop xs ((arg0,arg1,arg2) as _state) =
|
3190
|
match xs with
|
3191
|
| ("label",x)::xs ->
|
3192
|
loop xs
|
3193
|
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2)
|
3194
|
| ("if_cases",x)::xs ->
|
3195
|
loop xs
|
3196
|
(arg0,
|
3197
|
((function
|
3198
|
| `List xs ->
|
3199
|
map_bind
|
3200
|
(fun x -> vhdl_if_case_t_of_yojson x) []
|
3201
|
xs
|
3202
|
| _ ->
|
3203
|
Result.Error
|
3204
|
"Vhdl_ast.vhdl_sequential_stmt_t.if_cases")
|
3205
|
x), arg2)
|
3206
|
| ("default",x)::xs ->
|
3207
|
loop xs
|
3208
|
(arg0, arg1,
|
3209
|
((function
|
3210
|
| `List xs ->
|
3211
|
map_bind
|
3212
|
(fun x ->
|
3213
|
vhdl_sequential_stmt_t_of_yojson x) []
|
3214
|
xs
|
3215
|
| _ ->
|
3216
|
Result.Error
|
3217
|
"Vhdl_ast.vhdl_sequential_stmt_t.default")
|
3218
|
x))
|
3219
|
| [] ->
|
3220
|
arg2 >>=
|
3221
|
((fun arg2 ->
|
3222
|
arg1 >>=
|
3223
|
(fun arg1 ->
|
3224
|
arg0 >>=
|
3225
|
(fun arg0 ->
|
3226
|
Result.Ok
|
3227
|
(If
|
3228
|
{
|
3229
|
label = arg0;
|
3230
|
if_cases = arg1;
|
3231
|
default = arg2
|
3232
|
})))))
|
3233
|
| _::xs -> loop xs _state in
|
3234
|
loop xs
|
3235
|
((Result.Ok NoName),
|
3236
|
(Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.if_cases"),
|
3237
|
(Result.Ok []))
|
3238
|
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
|
3239
|
| `List ((`String "CASE_STATEMENT_TREE")::arg0::[]) ->
|
3240
|
((function
|
3241
|
| `Assoc xs ->
|
3242
|
let rec loop xs ((arg0,arg1,arg2) as _state) =
|
3243
|
match xs with
|
3244
|
| ("label",x)::xs ->
|
3245
|
loop xs
|
3246
|
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2)
|
3247
|
| ("guard",x)::xs ->
|
3248
|
loop xs
|
3249
|
(arg0, ((fun x -> vhdl_expr_t_of_yojson x) x), arg2)
|
3250
|
| ("branches",x)::xs ->
|
3251
|
loop xs
|
3252
|
(arg0, arg1,
|
3253
|
((function
|
3254
|
| `List xs ->
|
3255
|
map_bind
|
3256
|
(fun x -> vhdl_case_item_t_of_yojson x) []
|
3257
|
xs
|
3258
|
| _ ->
|
3259
|
Result.Error
|
3260
|
"Vhdl_ast.vhdl_sequential_stmt_t.branches")
|
3261
|
x))
|
3262
|
| [] ->
|
3263
|
arg2 >>=
|
3264
|
((fun arg2 ->
|
3265
|
arg1 >>=
|
3266
|
(fun arg1 ->
|
3267
|
arg0 >>=
|
3268
|
(fun arg0 ->
|
3269
|
Result.Ok
|
3270
|
(Case
|
3271
|
{
|
3272
|
label = arg0;
|
3273
|
guard = arg1;
|
3274
|
branches = arg2
|
3275
|
})))))
|
3276
|
| _::xs -> loop xs _state in
|
3277
|
loop xs
|
3278
|
((Result.Ok NoName),
|
3279
|
(Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.guard"),
|
3280
|
(Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.branches"))
|
3281
|
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
|
3282
|
| `List ((`String "EXIT_STATEMENT")::arg0::[]) ->
|
3283
|
((function
|
3284
|
| `Assoc xs ->
|
3285
|
let rec loop xs ((arg0,arg1,arg2) as _state) =
|
3286
|
match xs with
|
3287
|
| ("label",x)::xs ->
|
3288
|
loop xs
|
3289
|
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2)
|
3290
|
| ("loop_label",x)::xs ->
|
3291
|
loop xs
|
3292
|
(arg0,
|
3293
|
((function
|
3294
|
| `Null -> Result.Ok None
|
3295
|
| x ->
|
3296
|
((function
|
3297
|
| `String x -> Result.Ok x
|
3298
|
| _ ->
|
3299
|
Result.Error
|
3300
|
"Vhdl_ast.vhdl_sequential_stmt_t.loop_label")
|
3301
|
x)
|
3302
|
>>= ((fun x -> Result.Ok (Some x)))) x),
|
3303
|
arg2)
|
3304
|
| ("condition",x)::xs ->
|
3305
|
loop xs
|
3306
|
(arg0, arg1,
|
3307
|
((function
|
3308
|
| `Null -> Result.Ok None
|
3309
|
| x ->
|
3310
|
((fun x -> vhdl_expr_t_of_yojson x) x) >>=
|
3311
|
((fun x -> Result.Ok (Some x)))) x))
|
3312
|
| [] ->
|
3313
|
arg2 >>=
|
3314
|
((fun arg2 ->
|
3315
|
arg1 >>=
|
3316
|
(fun arg1 ->
|
3317
|
arg0 >>=
|
3318
|
(fun arg0 ->
|
3319
|
Result.Ok
|
3320
|
(Exit
|
3321
|
{
|
3322
|
label = arg0;
|
3323
|
loop_label = arg1;
|
3324
|
condition = arg2
|
3325
|
})))))
|
3326
|
| _::xs -> loop xs _state in
|
3327
|
loop xs
|
3328
|
((Result.Ok NoName), (Result.Ok (Some "")),
|
3329
|
(Result.Ok (Some IsNull)))
|
3330
|
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
|
3331
|
| `List ((`String "ASSERTION_STATEMENT")::arg0::[]) ->
|
3332
|
((function
|
3333
|
| `Assoc xs ->
|
3334
|
let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
|
3335
|
match xs with
|
3336
|
| ("label",x)::xs ->
|
3337
|
loop xs
|
3338
|
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2,
|
3339
|
arg3)
|
3340
|
| ("cond",x)::xs ->
|
3341
|
loop xs
|
3342
|
(arg0, ((fun x -> vhdl_expr_t_of_yojson x) x), arg2,
|
3343
|
arg3)
|
3344
|
| ("report",x)::xs ->
|
3345
|
loop xs
|
3346
|
(arg0, arg1, ((fun x -> vhdl_expr_t_of_yojson x) x),
|
3347
|
arg3)
|
3348
|
| ("severity",x)::xs ->
|
3349
|
loop xs
|
3350
|
(arg0, arg1, arg2,
|
3351
|
((fun x -> vhdl_expr_t_of_yojson x) x))
|
3352
|
| [] ->
|
3353
|
arg3 >>=
|
3354
|
((fun arg3 ->
|
3355
|
arg2 >>=
|
3356
|
(fun arg2 ->
|
3357
|
arg1 >>=
|
3358
|
(fun arg1 ->
|
3359
|
arg0 >>=
|
3360
|
(fun arg0 ->
|
3361
|
Result.Ok
|
3362
|
(Assert
|
3363
|
{
|
3364
|
label = arg0;
|
3365
|
cond = arg1;
|
3366
|
report = arg2;
|
3367
|
severity = arg3
|
3368
|
}))))))
|
3369
|
| _::xs -> loop xs _state in
|
3370
|
loop xs
|
3371
|
((Result.Ok NoName),
|
3372
|
(Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.cond"),
|
3373
|
(Result.Ok IsNull), (Result.Ok IsNull))
|
3374
|
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
|
3375
|
| `List ((`String "WAIT_STATEMENT")::[]) -> Result.Ok Wait
|
3376
|
| `List ((`String "NULL_STATEMENT")::arg0::[]) ->
|
3377
|
((function
|
3378
|
| `Assoc xs ->
|
3379
|
let rec loop xs (arg0 as _state) =
|
3380
|
match xs with
|
3381
|
| ("label",x)::xs ->
|
3382
|
loop xs ((fun x -> vhdl_name_t_of_yojson x) x)
|
3383
|
| [] ->
|
3384
|
arg0 >>=
|
3385
|
((fun arg0 -> Result.Ok (Null { label = arg0 })))
|
3386
|
| _::xs -> loop xs _state in
|
3387
|
loop xs (Result.Ok NoName)
|
3388
|
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
|
3389
|
| `List ((`String "RETURN_STATEMENT")::arg0::[]) ->
|
3390
|
((function
|
3391
|
| `Assoc xs ->
|
3392
|
let rec loop xs (arg0 as _state) =
|
3393
|
match xs with
|
3394
|
| ("label",x)::xs ->
|
3395
|
loop xs ((fun x -> vhdl_name_t_of_yojson x) x)
|
3396
|
| [] ->
|
3397
|
arg0 >>=
|
3398
|
((fun arg0 -> Result.Ok (Return { label = arg0 })))
|
3399
|
| _::xs -> loop xs _state in
|
3400
|
loop xs (Result.Ok NoName)
|
3401
|
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
|
3402
|
| _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")
|
3403
|
[@ocaml.warning "-A"])
|
3404
|
|
3405
|
and (vhdl_if_case_t_to_yojson : vhdl_if_case_t -> Yojson.Safe.json) =
|
3406
|
((let open! Ppx_deriving_yojson_runtime in
|
3407
|
fun x ->
|
3408
|
let fields = [] in
|
3409
|
let fields =
|
3410
|
("if_block",
|
3411
|
((fun x ->
|
3412
|
`List
|
3413
|
(List.map (fun x -> vhdl_sequential_stmt_t_to_yojson x) x))
|
3414
|
x.if_block))
|
3415
|
:: fields in
|
3416
|
let fields =
|
3417
|
("if_cond", ((fun x -> vhdl_expr_t_to_yojson x) x.if_cond)) ::
|
3418
|
fields in
|
3419
|
`Assoc fields)
|
3420
|
[@ocaml.warning "-A"])
|
3421
|
|
3422
|
and (vhdl_if_case_t_of_yojson :
|
3423
|
Yojson.Safe.json -> vhdl_if_case_t Ppx_deriving_yojson_runtime.error_or)
|
3424
|
=
|
3425
|
((let open! Ppx_deriving_yojson_runtime in
|
3426
|
function
|
3427
|
| `Assoc xs ->
|
3428
|
let rec loop xs ((arg0,arg1) as _state) =
|
3429
|
match xs with
|
3430
|
| ("if_cond",x)::xs ->
|
3431
|
loop xs (((fun x -> vhdl_expr_t_of_yojson x) x), arg1)
|
3432
|
| ("if_block",x)::xs ->
|
3433
|
loop xs
|
3434
|
(arg0,
|
3435
|
((function
|
3436
|
| `List xs ->
|
3437
|
map_bind
|
3438
|
(fun x -> vhdl_sequential_stmt_t_of_yojson x) []
|
3439
|
xs
|
3440
|
| _ -> Result.Error "Vhdl_ast.vhdl_if_case_t.if_block")
|
3441
|
x))
|
3442
|
| [] ->
|
3443
|
arg1 >>=
|
3444
|
((fun arg1 ->
|
3445
|
arg0 >>=
|
3446
|
(fun arg0 ->
|
3447
|
Result.Ok { if_cond = arg0; if_block = arg1 })))
|
3448
|
| _::xs -> loop xs _state in
|
3449
|
loop xs
|
3450
|
((Result.Error "Vhdl_ast.vhdl_if_case_t.if_cond"),
|
3451
|
(Result.Error "Vhdl_ast.vhdl_if_case_t.if_block"))
|
3452
|
| _ -> Result.Error "Vhdl_ast.vhdl_if_case_t")
|
3453
|
[@ocaml.warning "-A"])
|
3454
|
|
3455
|
and (vhdl_case_item_t_to_yojson : vhdl_case_item_t -> Yojson.Safe.json) =
|
3456
|
((let open! Ppx_deriving_yojson_runtime in
|
3457
|
fun x ->
|
3458
|
let fields = [] in
|
3459
|
let fields =
|
3460
|
("when_stmt",
|
3461
|
((fun x ->
|
3462
|
`List
|
3463
|
(List.map (fun x -> vhdl_sequential_stmt_t_to_yojson x) x))
|
3464
|
x.when_stmt))
|
3465
|
:: fields in
|
3466
|
let fields =
|
3467
|
("when_cond",
|
3468
|
((fun x ->
|
3469
|
`List (List.map (fun x -> vhdl_expr_t_to_yojson x) x))
|
3470
|
x.when_cond))
|
3471
|
:: fields in
|
3472
|
`Assoc fields)
|
3473
|
[@ocaml.warning "-A"])
|
3474
|
|
3475
|
and (vhdl_case_item_t_of_yojson :
|
3476
|
Yojson.Safe.json ->
|
3477
|
vhdl_case_item_t Ppx_deriving_yojson_runtime.error_or)
|
3478
|
=
|
3479
|
((let open! Ppx_deriving_yojson_runtime in
|
3480
|
function
|
3481
|
| `Assoc xs ->
|
3482
|
let rec loop xs ((arg0,arg1) as _state) =
|
3483
|
match xs with
|
3484
|
| ("when_cond",x)::xs ->
|
3485
|
loop xs
|
3486
|
(((function
|
3487
|
| `List xs ->
|
3488
|
map_bind (fun x -> vhdl_expr_t_of_yojson x) [] xs
|
3489
|
| _ ->
|
3490
|
Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond")
|
3491
|
x), arg1)
|
3492
|
| ("when_stmt",x)::xs ->
|
3493
|
loop xs
|
3494
|
(arg0,
|
3495
|
((function
|
3496
|
| `List xs ->
|
3497
|
map_bind
|
3498
|
(fun x -> vhdl_sequential_stmt_t_of_yojson x) []
|
3499
|
xs
|
3500
|
| _ ->
|
3501
|
Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt")
|
3502
|
x))
|
3503
|
| [] ->
|
3504
|
arg1 >>=
|
3505
|
((fun arg1 ->
|
3506
|
arg0 >>=
|
3507
|
(fun arg0 ->
|
3508
|
Result.Ok { when_cond = arg0; when_stmt = arg1 })))
|
3509
|
| _::xs -> loop xs _state in
|
3510
|
loop xs
|
3511
|
((Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond"),
|
3512
|
(Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt"))
|
3513
|
| _ -> Result.Error "Vhdl_ast.vhdl_case_item_t")
|
3514
|
[@ocaml.warning "-A"])
|
3515
|
|
3516
|
type vhdl_declaration_t =
|
3517
|
| VarDecl of
|
3518
|
{
|
3519
|
names: vhdl_name_t list ;
|
3520
|
typ: vhdl_subtype_indication_t ;
|
3521
|
init_val: vhdl_cst_val_t option [@default None]}
|
3522
|
[@name "VARIABLE_DECLARATION"]
|
3523
|
| CstDecl of
|
3524
|
{
|
3525
|
names: vhdl_name_t list ;
|
3526
|
typ: vhdl_subtype_indication_t ;
|
3527
|
init_val: vhdl_cst_val_t } [@name "CONSTANT_DECLARATION"]
|
3528
|
| SigDecl of
|
3529
|
{
|
3530
|
names: vhdl_name_t list ;
|
3531
|
typ: vhdl_subtype_indication_t ;
|
3532
|
init_val: vhdl_cst_val_t option [@default None]}
|
3533
|
[@name "SIGNAL_DECLARATION"]
|
3534
|
| Subprogram of
|
3535
|
{
|
3536
|
name: vhdl_name_t [@default NoName];
|
3537
|
kind: string [@default ""];
|
3538
|
spec: vhdl_subprogram_spec_t
|
3539
|
[@default
|
3540
|
{ name = ""; typeMark = NoName; parameters = []; isPure = false }];
|
3541
|
decl_part: vhdl_declaration_t list [@default []];
|
3542
|
stmts: vhdl_sequential_stmt_t list [@default []]} [@name "SUBPROGRAM_BODY"]
|
3543
|
|
3544
|
(* Needs adaptation for: SubProgram *)
|
3545
|
let rec pp_vhdl_declaration_t :
|
3546
|
Format.formatter -> vhdl_declaration_t -> Ppx_deriving_runtime.unit =
|
3547
|
let __12 () = pp_vhdl_sequential_stmt_t
|
3548
|
|
3549
|
and __11 () = pp_vhdl_declaration_t
|
3550
|
|
3551
|
and __10 () = pp_vhdl_subprogram_spec_t
|
3552
|
|
3553
|
and __9 () = pp_vhdl_name_t
|
3554
|
|
3555
|
and __8 () = pp_vhdl_cst_val_t
|
3556
|
|
3557
|
and __7 () = pp_vhdl_subtype_indication_t
|
3558
|
|
3559
|
and __6 () = pp_vhdl_name_t
|
3560
|
|
3561
|
and __5 () = pp_vhdl_cst_val_t
|
3562
|
|
3563
|
and __4 () = pp_vhdl_subtype_indication_t
|
3564
|
|
3565
|
and __3 () = pp_vhdl_name_t
|
3566
|
|
3567
|
and __2 () = pp_vhdl_cst_val_t
|
3568
|
|
3569
|
and __1 () = pp_vhdl_subtype_indication_t
|
3570
|
|
3571
|
and __0 () = pp_vhdl_name_t
|
3572
|
in
|
3573
|
((let open! Ppx_deriving_runtime in
|
3574
|
fun fmt ->
|
3575
|
function
|
3576
|
| VarDecl { names = anames; typ = atyp; init_val = ainit_val } ->
|
3577
|
(Format.fprintf fmt "@[<2>variable@ ";
|
3578
|
((((fun x ->
|
3579
|
ignore
|
3580
|
(List.fold_left
|
3581
|
(fun sep ->
|
3582
|
fun x ->
|
3583
|
if sep then Format.fprintf fmt ",";
|
3584
|
((__0 ()) fmt) x;
|
3585
|
true) false x);)) anames;
|
3586
|
Format.fprintf fmt "@ :@ ";
|
3587
|
((__1 ()) fmt) atyp;
|
3588
|
((function
|
3589
|
| None -> Format.pp_print_string fmt ""
|
3590
|
| Some x ->
|
3591
|
(Format.fprintf fmt ":=";
|
3592
|
((__2 ()) fmt) x;))) ainit_val;
|
3593
|
Format.fprintf fmt "@]");
|
3594
|
))
|
3595
|
| CstDecl { names = anames; typ = atyp; init_val = ainit_val } ->
|
3596
|
(Format.fprintf fmt "@[<2>constant@ ";
|
3597
|
((((fun x ->
|
3598
|
ignore
|
3599
|
(List.fold_left
|
3600
|
(fun sep ->
|
3601
|
fun x ->
|
3602
|
if sep then Format.fprintf fmt ",";
|
3603
|
((__3 ()) fmt) x;
|
3604
|
true) false x);)) anames;
|
3605
|
Format.fprintf fmt "@ :@ ";
|
3606
|
((__4 ()) fmt) atyp;
|
3607
|
Format.fprintf fmt ":=";
|
3608
|
((__5 ()) fmt) ainit_val;
|
3609
|
Format.fprintf fmt "@]");
|
3610
|
))
|
3611
|
| SigDecl { names = anames; typ = atyp; init_val = ainit_val } ->
|
3612
|
(Format.fprintf fmt "@[<2>signal@ ";
|
3613
|
((fun x ->
|
3614
|
ignore
|
3615
|
(List.fold_left
|
3616
|
(fun sep ->
|
3617
|
fun x ->
|
3618
|
if sep then Format.fprintf fmt ",";
|
3619
|
((__6 ()) fmt) x;
|
3620
|
true) false x);
|
3621
|
)) anames;
|
3622
|
Format.fprintf fmt "@ :@ ";
|
3623
|
((__7 ()) fmt) atyp;
|
3624
|
(function
|
3625
|
| None -> Format.pp_print_string fmt ""
|
3626
|
| Some x ->
|
3627
|
(Format.fprintf fmt ":=";
|
3628
|
((__8 ()) fmt) x;)
|
3629
|
) ainit_val;
|
3630
|
Format.fprintf fmt "@]";
|
3631
|
)
|
3632
|
| Subprogram
|
3633
|
{ name = aname; kind = akind; spec = aspec;
|
3634
|
decl_part = adecl_part; stmts = astmts }
|
3635
|
->
|
3636
|
(Format.fprintf fmt "@[<2>Subprogram {@,";
|
3637
|
(((((Format.fprintf fmt "@[%s =@ " "name";
|
3638
|
((__9 ()) fmt) aname;
|
3639
|
Format.fprintf fmt "@]");
|
3640
|
Format.fprintf fmt ";@ ";
|
3641
|
Format.fprintf fmt "@[%s =@ " "kind";
|
3642
|
(Format.fprintf fmt "%S") akind;
|
3643
|
Format.fprintf fmt "@]");
|
3644
|
Format.fprintf fmt ";@ ";
|
3645
|
Format.fprintf fmt "@[%s =@ " "spec";
|
3646
|
((__10 ()) fmt) aspec;
|
3647
|
Format.fprintf fmt "@]");
|
3648
|
Format.fprintf fmt ";@ ";
|
3649
|
Format.fprintf fmt "@[%s =@ " "decl_part";
|
3650
|
((fun x ->
|
3651
|
Format.fprintf fmt "@[<2>[";
|
3652
|
ignore
|
3653
|
(List.fold_left
|
3654
|
(fun sep ->
|
3655
|
fun x ->
|
3656
|
if sep then Format.fprintf fmt ";@ ";
|
3657
|
((__11 ()) fmt) x;
|
3658
|
true) false x);
|
3659
|
Format.fprintf fmt "@,]@]")) adecl_part;
|
3660
|
Format.fprintf fmt "@]");
|
3661
|
Format.fprintf fmt ";@ ";
|
3662
|
Format.fprintf fmt "@[%s =@ " "stmts";
|
3663
|
((fun x ->
|
3664
|
Format.fprintf fmt "@[<2>[";
|
3665
|
ignore
|
3666
|
(List.fold_left
|
3667
|
(fun sep ->
|
3668
|
fun x ->
|
3669
|
if sep then Format.fprintf fmt ";@ ";
|
3670
|
((__12 ()) fmt) x;
|
3671
|
true) false x);
|
3672
|
Format.fprintf fmt "@,]@]")) astmts;
|
3673
|
Format.fprintf fmt "@]");
|
3674
|
Format.fprintf fmt "@]}"))
|
3675
|
[@ocaml.warning "-A"])
|
3676
|
|
3677
|
and show_vhdl_declaration_t :
|
3678
|
vhdl_declaration_t -> Ppx_deriving_runtime.string =
|
3679
|
fun x -> Format.asprintf "%a" pp_vhdl_declaration_t x
|
3680
|
|
3681
|
let rec (vhdl_declaration_t_to_yojson :
|
3682
|
vhdl_declaration_t -> Yojson.Safe.json)
|
3683
|
=
|
3684
|
((let open! Ppx_deriving_yojson_runtime in
|
3685
|
function
|
3686
|
| VarDecl arg0 ->
|
3687
|
`List
|
3688
|
[`String "VARIABLE_DECLARATION";
|
3689
|
(let fields = [] in
|
3690
|
let fields =
|
3691
|
if arg0.init_val = None
|
3692
|
then fields
|
3693
|
else
|
3694
|
("init_val",
|
3695
|
(((function
|
3696
|
| None -> `Null
|
3697
|
| Some x -> ((fun x -> vhdl_cst_val_t_to_yojson x)) x))
|
3698
|
arg0.init_val))
|
3699
|
:: fields
|
3700
|
in
|
3701
|
let fields =
|
3702
|
("typ",
|
3703
|
((fun x -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
|
3704
|
:: fields in
|
3705
|
let fields =
|
3706
|
("names",
|
3707
|
((fun x ->
|
3708
|
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x))
|
3709
|
arg0.names))
|
3710
|
:: fields in
|
3711
|
`Assoc fields)]
|
3712
|
| CstDecl arg0 ->
|
3713
|
`List
|
3714
|
[`String "CONSTANT_DECLARATION";
|
3715
|
(let fields = [] in
|
3716
|
let fields =
|
3717
|
("init_val",
|
3718
|
((fun x -> vhdl_cst_val_t_to_yojson x) arg0.init_val))
|
3719
|
:: fields in
|
3720
|
let fields =
|
3721
|
("typ",
|
3722
|
((fun x -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
|
3723
|
:: fields in
|
3724
|
let fields =
|
3725
|
("names",
|
3726
|
((fun x ->
|
3727
|
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x))
|
3728
|
arg0.names))
|
3729
|
:: fields in
|
3730
|
`Assoc fields)]
|
3731
|
| SigDecl arg0 ->
|
3732
|
`List
|
3733
|
[`String "SIGNAL_DECLARATION";
|
3734
|
(let fields = [] in
|
3735
|
let fields =
|
3736
|
if arg0.init_val = None
|
3737
|
then fields
|
3738
|
else
|
3739
|
("init_val",
|
3740
|
(((function
|
3741
|
| None -> `Null
|
3742
|
| Some x -> ((fun x -> vhdl_cst_val_t_to_yojson x)) x))
|
3743
|
arg0.init_val))
|
3744
|
:: fields
|
3745
|
in
|
3746
|
let fields =
|
3747
|
("typ",
|
3748
|
((fun x -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
|
3749
|
:: fields in
|
3750
|
let fields =
|
3751
|
("names",
|
3752
|
((fun x ->
|
3753
|
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x))
|
3754
|
arg0.names))
|
3755
|
:: fields in
|
3756
|
`Assoc fields)]
|
3757
|
| Subprogram arg0 ->
|
3758
|
`List
|
3759
|
[`String "SUBPROGRAM_BODY";
|
3760
|
(let fields = [] in
|
3761
|
let fields =
|
3762
|
if arg0.stmts = []
|
3763
|
then fields
|
3764
|
else
|
3765
|
("stmts",
|
3766
|
(((fun x ->
|
3767
|
`List
|
3768
|
(List.map
|
3769
|
(fun x -> vhdl_sequential_stmt_t_to_yojson x) x)))
|
3770
|
arg0.stmts))
|
3771
|
:: fields
|
3772
|
in
|
3773
|
let fields =
|
3774
|
if arg0.decl_part = []
|
3775
|
then fields
|
3776
|
else
|
3777
|
("decl_part",
|
3778
|
(((fun x ->
|
3779
|
`List
|
3780
|
(List.map
|
3781
|
(fun x -> vhdl_declaration_t_to_yojson x) x)))
|
3782
|
arg0.decl_part))
|
3783
|
:: fields
|
3784
|
in
|
3785
|
let fields =
|
3786
|
if
|
3787
|
arg0.spec =
|
3788
|
{
|
3789
|
name = "";
|
3790
|
typeMark = NoName;
|
3791
|
parameters = [];
|
3792
|
isPure = false
|
3793
|
}
|
3794
|
then fields
|
3795
|
else
|
3796
|
("spec",
|
3797
|
(((fun x -> vhdl_subprogram_spec_t_to_yojson x))
|
3798
|
arg0.spec))
|
3799
|
:: fields
|
3800
|
in
|
3801
|
let fields =
|
3802
|
if arg0.kind = ""
|
3803
|
then fields
|
3804
|
else
|
3805
|
("kind",
|
3806
|
(((fun (x : Ppx_deriving_runtime.string) -> `String x))
|
3807
|
arg0.kind))
|
3808
|
:: fields
|
3809
|
in
|
3810
|
let fields =
|
3811
|
if arg0.name = NoName
|
3812
|
then fields
|
3813
|
else
|
3814
|
("name", (((fun x -> vhdl_name_t_to_yojson x)) arg0.name))
|
3815
|
:: fields
|
3816
|
in
|
3817
|
`Assoc fields)])
|
3818
|
[@ocaml.warning "-A"])
|
3819
|
|
3820
|
and (vhdl_declaration_t_of_yojson :
|
3821
|
Yojson.Safe.json ->
|
3822
|
vhdl_declaration_t Ppx_deriving_yojson_runtime.error_or)
|
3823
|
=
|
3824
|
((let open! Ppx_deriving_yojson_runtime in
|
3825
|
function
|
3826
|
| `List ((`String "VARIABLE_DECLARATION")::arg0::[]) ->
|
3827
|
((function
|
3828
|
| `Assoc xs ->
|
3829
|
let rec loop xs ((arg0,arg1,arg2) as _state) =
|
3830
|
match xs with
|
3831
|
| ("names",x)::xs ->
|
3832
|
loop xs
|
3833
|
(((function
|
3834
|
| `List xs ->
|
3835
|
map_bind (fun x -> vhdl_name_t_of_yojson x)
|
3836
|
[] xs
|
3837
|
| _ ->
|
3838
|
Result.Error
|
3839
|
"Vhdl_ast.vhdl_declaration_t.names") x),
|
3840
|
arg1, arg2)
|
3841
|
| ("typ",x)::xs ->
|
3842
|
loop xs
|
3843
|
(arg0,
|
3844
|
((fun x -> vhdl_subtype_indication_t_of_yojson x)
|
3845
|
x), arg2)
|
3846
|
| ("init_val",x)::xs ->
|
3847
|
loop xs
|
3848
|
(arg0, arg1,
|
3849
|
((function
|
3850
|
| `Null -> Result.Ok None
|
3851
|
| x ->
|
3852
|
((fun x -> vhdl_cst_val_t_of_yojson x) x)
|
3853
|
>>= ((fun x -> Result.Ok (Some x)))) x))
|
3854
|
| [] ->
|
3855
|
arg2 >>=
|
3856
|
((fun arg2 ->
|
3857
|
arg1 >>=
|
3858
|
(fun arg1 ->
|
3859
|
arg0 >>=
|
3860
|
(fun arg0 ->
|
3861
|
Result.Ok
|
3862
|
(VarDecl
|
3863
|
{
|
3864
|
names = arg0;
|
3865
|
typ = arg1;
|
3866
|
init_val = arg2
|
3867
|
})))))
|
3868
|
| _::xs -> loop xs _state in
|
3869
|
loop xs
|
3870
|
((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
|
3871
|
(Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
|
3872
|
(Result.Ok (Some (CstInt 0))))
|
3873
|
| _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
|
3874
|
| `List ((`String "CONSTANT_DECLARATION")::arg0::[]) ->
|
3875
|
((function
|
3876
|
| `Assoc xs ->
|
3877
|
let rec loop xs ((arg0,arg1,arg2) as _state) =
|
3878
|
match xs with
|
3879
|
| ("names",x)::xs ->
|
3880
|
loop xs
|
3881
|
(((function
|
3882
|
| `List xs ->
|
3883
|
map_bind (fun x -> vhdl_name_t_of_yojson x)
|
3884
|
[] xs
|
3885
|
| _ ->
|
3886
|
Result.Error
|
3887
|
"Vhdl_ast.vhdl_declaration_t.names") x),
|
3888
|
arg1, arg2)
|
3889
|
| ("typ",x)::xs ->
|
3890
|
loop xs
|
3891
|
(arg0,
|
3892
|
((fun x -> vhdl_subtype_indication_t_of_yojson x)
|
3893
|
x), arg2)
|
3894
|
| ("init_val",x)::xs ->
|
3895
|
loop xs
|
3896
|
(arg0, arg1,
|
3897
|
((fun x -> vhdl_cst_val_t_of_yojson x) x))
|
3898
|
| [] ->
|
3899
|
arg2 >>=
|
3900
|
((fun arg2 ->
|
3901
|
arg1 >>=
|
3902
|
(fun arg1 ->
|
3903
|
arg0 >>=
|
3904
|
(fun arg0 ->
|
3905
|
Result.Ok
|
3906
|
(CstDecl
|
3907
|
{
|
3908
|
names = arg0;
|
3909
|
typ = arg1;
|
3910
|
init_val = arg2
|
3911
|
})))))
|
3912
|
| _::xs -> loop xs _state in
|
3913
|
loop xs
|
3914
|
((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
|
3915
|
(Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
|
3916
|
(Result.Error "Vhdl_ast.vhdl_declaration_t.init_val"))
|
3917
|
| _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
|
3918
|
| `List ((`String "SIGNAL_DECLARATION")::arg0::[]) ->
|
3919
|
((function
|
3920
|
| `Assoc xs ->
|
3921
|
let rec loop xs ((arg0,arg1,arg2) as _state) =
|
3922
|
match xs with
|
3923
|
| ("names",x)::xs ->
|
3924
|
loop xs
|
3925
|
(((function
|
3926
|
| `List xs ->
|
3927
|
map_bind (fun x -> vhdl_name_t_of_yojson x)
|
3928
|
[] xs
|
3929
|
| _ ->
|
3930
|
Result.Error
|
3931
|
"Vhdl_ast.vhdl_declaration_t.names") x),
|
3932
|
arg1, arg2)
|
3933
|
| ("typ",x)::xs ->
|
3934
|
loop xs
|
3935
|
(arg0,
|
3936
|
((fun x -> vhdl_subtype_indication_t_of_yojson x)
|
3937
|
x), arg2)
|
3938
|
| ("init_val",x)::xs ->
|
3939
|
loop xs
|
3940
|
(arg0, arg1,
|
3941
|
((function
|
3942
|
| `Null -> Result.Ok None
|
3943
|
| x ->
|
3944
|
((fun x -> vhdl_cst_val_t_of_yojson x) x)
|
3945
|
>>= ((fun x -> Result.Ok (Some x)))) x))
|
3946
|
| [] ->
|
3947
|
arg2 >>=
|
3948
|
((fun arg2 ->
|
3949
|
arg1 >>=
|
3950
|
(fun arg1 ->
|
3951
|
arg0 >>=
|
3952
|
(fun arg0 ->
|
3953
|
Result.Ok
|
3954
|
(SigDecl
|
3955
|
{
|
3956
|
names = arg0;
|
3957
|
typ = arg1;
|
3958
|
init_val = arg2
|
3959
|
})))))
|
3960
|
| _::xs -> loop xs _state in
|
3961
|
loop xs
|
3962
|
((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
|
3963
|
(Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
|
3964
|
(Result.Ok (Some (CstInt 0))))
|
3965
|
| _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
|
3966
|
| `List ((`String "SUBPROGRAM_BODY")::arg0::[]) ->
|
3967
|
((function
|
3968
|
| `Assoc xs ->
|
3969
|
let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
|
3970
|
match xs with
|
3971
|
| ("name",x)::xs ->
|
3972
|
loop xs
|
3973
|
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2,
|
3974
|
arg3, arg4)
|
3975
|
| ("kind",x)::xs ->
|
3976
|
loop xs
|
3977
|
(arg0,
|
3978
|
((function
|
3979
|
| `String x -> Result.Ok x
|
3980
|
| _ ->
|
3981
|
Result.Error
|
3982
|
"Vhdl_ast.vhdl_declaration_t.kind") x),
|
3983
|
arg2, arg3, arg4)
|
3984
|
| ("spec",x)::xs ->
|
3985
|
loop xs
|
3986
|
(arg0, arg1,
|
3987
|
((fun x -> vhdl_subprogram_spec_t_of_yojson x) x),
|
3988
|
arg3, arg4)
|
3989
|
| ("decl_part",x)::xs ->
|
3990
|
loop xs
|
3991
|
(arg0, arg1, arg2,
|
3992
|
((function
|
3993
|
| `List xs ->
|
3994
|
map_bind
|
3995
|
(fun x -> vhdl_declaration_t_of_yojson x)
|
3996
|
[] xs
|
3997
|
| _ ->
|
3998
|
Result.Error
|
3999
|
"Vhdl_ast.vhdl_declaration_t.decl_part") x),
|
4000
|
arg4)
|
4001
|
| ("stmts",x)::xs ->
|
4002
|
loop xs
|
4003
|
(arg0, arg1, arg2, arg3,
|
4004
|
((function
|
4005
|
| `List xs ->
|
4006
|
map_bind
|
4007
|
(fun x ->
|
4008
|
vhdl_sequential_stmt_t_of_yojson x) []
|
4009
|
xs
|
4010
|
| _ ->
|
4011
|
Result.Error
|
4012
|
"Vhdl_ast.vhdl_declaration_t.stmts") x))
|
4013
|
| [] ->
|
4014
|
arg4 >>=
|
4015
|
((fun arg4 ->
|
4016
|
arg3 >>=
|
4017
|
(fun arg3 ->
|
4018
|
arg2 >>=
|
4019
|
(fun arg2 ->
|
4020
|
arg1 >>=
|
4021
|
(fun arg1 ->
|
4022
|
arg0 >>=
|
4023
|
(fun arg0 ->
|
4024
|
Result.Ok
|
4025
|
(Subprogram
|
4026
|
{
|
4027
|
name = arg0;
|
4028
|
kind = arg1;
|
4029
|
spec = arg2;
|
4030
|
decl_part = arg3;
|
4031
|
stmts = arg4
|
4032
|
})))))))
|
4033
|
| _::xs -> loop xs _state in
|
4034
|
loop xs
|
4035
|
((Result.Ok NoName), (Result.Ok ""),
|
4036
|
(Result.Ok
|
4037
|
{
|
4038
|
name = "";
|
4039
|
typeMark = NoName;
|
4040
|
parameters = [];
|
4041
|
isPure = false
|
4042
|
}), (Result.Ok []), (Result.Ok []))
|
4043
|
| _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
|
4044
|
| _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")
|
4045
|
[@ocaml.warning "-A"])
|
4046
|
|
4047
|
type vhdl_signal_condition_t =
|
4048
|
{
|
4049
|
expr: vhdl_expr_t list ;
|
4050
|
cond: vhdl_expr_t [@default IsNull]}
|
4051
|
|
4052
|
let rec pp_vhdl_signal_condition_t :
|
4053
|
Format.formatter -> vhdl_signal_condition_t -> Ppx_deriving_runtime.unit =
|
4054
|
let __1 () = pp_vhdl_expr_t
|
4055
|
|
4056
|
and __0 () = pp_vhdl_expr_t
|
4057
|
in
|
4058
|
((let open! Ppx_deriving_runtime in
|
4059
|
fun fmt ->
|
4060
|
fun x ->
|
4061
|
Format.fprintf fmt "@[<2>{ ";
|
4062
|
((Format.fprintf fmt "@[%s =@ " "expr";
|
4063
|
((fun x ->
|
4064
|
Format.fprintf fmt "@[<2>[";
|
4065
|
ignore
|
4066
|
(List.fold_left
|
4067
|
(fun sep ->
|
4068
|
fun x ->
|
4069
|
if sep then Format.fprintf fmt ";@ ";
|
4070
|
((__0 ()) fmt) x;
|
4071
|
true) false x);
|
4072
|
Format.fprintf fmt "@,]@]")) x.expr;
|
4073
|
Format.fprintf fmt "@]");
|
4074
|
Format.fprintf fmt ";@ ";
|
4075
|
Format.fprintf fmt "@[%s =@ " "cond";
|
4076
|
((__1 ()) fmt) x.cond;
|
4077
|
Format.fprintf fmt "@]");
|
4078
|
Format.fprintf fmt "@ }@]")
|
4079
|
[@ocaml.warning "-A"])
|
4080
|
|
4081
|
and show_vhdl_signal_condition_t :
|
4082
|
vhdl_signal_condition_t -> Ppx_deriving_runtime.string =
|
4083
|
fun x -> Format.asprintf "%a" pp_vhdl_signal_condition_t x
|
4084
|
|
4085
|
let rec (vhdl_signal_condition_t_to_yojson :
|
4086
|
vhdl_signal_condition_t -> Yojson.Safe.json)
|
4087
|
=
|
4088
|
((let open! Ppx_deriving_yojson_runtime in
|
4089
|
fun x ->
|
4090
|
let fields = [] in
|
4091
|
let fields =
|
4092
|
if x.cond = IsNull
|
4093
|
then fields
|
4094
|
else ("cond", (((fun x -> vhdl_expr_t_to_yojson x)) x.cond)) ::
|
4095
|
fields
|
4096
|
in
|
4097
|
let fields =
|
4098
|
("expr",
|
4099
|
((fun x ->
|
4100
|
`List (List.map (fun x -> vhdl_expr_t_to_yojson x) x))
|
4101
|
x.expr))
|
4102
|
:: fields in
|
4103
|
`Assoc fields)
|
4104
|
[@ocaml.warning "-A"])
|
4105
|
|
4106
|
and (vhdl_signal_condition_t_of_yojson :
|
4107
|
Yojson.Safe.json ->
|
4108
|
vhdl_signal_condition_t Ppx_deriving_yojson_runtime.error_or)
|
4109
|
=
|
4110
|
((let open! Ppx_deriving_yojson_runtime in
|
4111
|
function
|
4112
|
| `Assoc xs ->
|
4113
|
let rec loop xs ((arg0,arg1) as _state) =
|
4114
|
match xs with
|
4115
|
| ("expr",x)::xs ->
|
4116
|
loop xs
|
4117
|
(((function
|
4118
|
| `List xs ->
|
4119
|
map_bind (fun x -> vhdl_expr_t_of_yojson x) [] xs
|
4120
|
| _ ->
|
4121
|
Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr")
|
4122
|
x), arg1)
|
4123
|
| ("cond",x)::xs ->
|
4124
|
loop xs (arg0, ((fun x -> vhdl_expr_t_of_yojson x) x))
|
4125
|
| [] ->
|
4126
|
arg1 >>=
|
4127
|
((fun arg1 ->
|
4128
|
arg0 >>=
|
4129
|
(fun arg0 -> Result.Ok { expr = arg0; cond = arg1 })))
|
4130
|
| _::xs -> loop xs _state in
|
4131
|
loop xs
|
4132
|
((Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr"),
|
4133
|
(Result.Ok IsNull))
|
4134
|
| _ -> Result.Error "Vhdl_ast.vhdl_signal_condition_t")
|
4135
|
[@ocaml.warning "-A"])
|
4136
|
|
4137
|
type vhdl_signal_selection_t =
|
4138
|
{
|
4139
|
expr: vhdl_expr_t ;
|
4140
|
when_sel: vhdl_expr_t list [@default []]}
|
4141
|
|
4142
|
let rec pp_vhdl_signal_selection_t :
|
4143
|
Format.formatter -> vhdl_signal_selection_t -> Ppx_deriving_runtime.unit =
|
4144
|
let __1 () = pp_vhdl_expr_t
|
4145
|
|
4146
|
and __0 () = pp_vhdl_expr_t
|
4147
|
in
|
4148
|
((let open! Ppx_deriving_runtime in
|
4149
|
fun fmt ->
|
4150
|
fun x ->
|
4151
|
Format.fprintf fmt "@[<2>{ ";
|
4152
|
((Format.fprintf fmt "@[%s =@ " "expr";
|
4153
|
((__0 ()) fmt) x.expr;
|
4154
|
Format.fprintf fmt "@]");
|
4155
|
Format.fprintf fmt ";@ ";
|
4156
|
Format.fprintf fmt "@[%s =@ " "when_sel";
|
4157
|
((fun x ->
|
4158
|
Format.fprintf fmt "@[<2>[";
|
4159
|
ignore
|
4160
|
(List.fold_left
|
4161
|
(fun sep ->
|
4162
|
fun x ->
|
4163
|
if sep then Format.fprintf fmt ";@ ";
|
4164
|
((__1 ()) fmt) x;
|
4165
|
true) false x);
|
4166
|
Format.fprintf fmt "@,]@]")) x.when_sel;
|
4167
|
Format.fprintf fmt "@]");
|
4168
|
Format.fprintf fmt "@ }@]")
|
4169
|
[@ocaml.warning "-A"])
|
4170
|
|
4171
|
and show_vhdl_signal_selection_t :
|
4172
|
vhdl_signal_selection_t -> Ppx_deriving_runtime.string =
|
4173
|
fun x -> Format.asprintf "%a" pp_vhdl_signal_selection_t x
|
4174
|
|
4175
|
let rec (vhdl_signal_selection_t_to_yojson :
|
4176
|
vhdl_signal_selection_t -> Yojson.Safe.json)
|
4177
|
=
|
4178
|
((let open! Ppx_deriving_yojson_runtime in
|
4179
|
fun x ->
|
4180
|
let fields = [] in
|
4181
|
let fields =
|
4182
|
if x.when_sel = []
|
4183
|
then fields
|
4184
|
else
|
4185
|
("when_sel",
|
4186
|
(((fun x ->
|
4187
|
`List (List.map (fun x -> vhdl_expr_t_to_yojson x) x)))
|
4188
|
x.when_sel))
|
4189
|
:: fields
|
4190
|
in
|
4191
|
let fields = ("expr", ((fun x -> vhdl_expr_t_to_yojson x) x.expr))
|
4192
|
:: fields in
|
4193
|
`Assoc fields)
|
4194
|
[@ocaml.warning "-A"])
|
4195
|
|
4196
|
and (vhdl_signal_selection_t_of_yojson :
|
4197
|
Yojson.Safe.json ->
|
4198
|
vhdl_signal_selection_t Ppx_deriving_yojson_runtime.error_or)
|
4199
|
=
|
4200
|
((let open! Ppx_deriving_yojson_runtime in
|
4201
|
function
|
4202
|
| `Assoc xs ->
|
4203
|
let rec loop xs ((arg0,arg1) as _state) =
|
4204
|
match xs with
|
4205
|
| ("expr",x)::xs ->
|
4206
|
loop xs (((fun x -> vhdl_expr_t_of_yojson x) x), arg1)
|
4207
|
| ("when_sel",x)::xs ->
|
4208
|
loop xs
|
4209
|
(arg0,
|
4210
|
((function
|
4211
|
| `List xs ->
|
4212
|
map_bind (fun x -> vhdl_expr_t_of_yojson x) [] xs
|
4213
|
| _ ->
|
4214
|
Result.Error
|
4215
|
"Vhdl_ast.vhdl_signal_selection_t.when_sel") x))
|
4216
|
| [] ->
|
4217
|
arg1 >>=
|
4218
|
((fun arg1 ->
|
4219
|
arg0 >>=
|
4220
|
(fun arg0 ->
|
4221
|
Result.Ok { expr = arg0; when_sel = arg1 })))
|
4222
|
| _::xs -> loop xs _state in
|
4223
|
loop xs
|
4224
|
((Result.Error "Vhdl_ast.vhdl_signal_selection_t.expr"),
|
4225
|
(Result.Ok []))
|
4226
|
| _ -> Result.Error "Vhdl_ast.vhdl_signal_selection_t")
|
4227
|
[@ocaml.warning "-A"])
|
4228
|
|
4229
|
type vhdl_conditional_signal_t =
|
4230
|
{
|
4231
|
postponed: bool [@default false];
|
4232
|
label: vhdl_name_t [@default NoName];
|
4233
|
lhs: vhdl_name_t ;
|
4234
|
rhs: vhdl_signal_condition_t list ;
|
4235
|
cond: vhdl_expr_t [@default IsNull];
|
4236
|
delay: vhdl_expr_t [@default IsNull]}
|
4237
|
|
4238
|
let rec pp_vhdl_conditional_signal_t :
|
4239
|
Format.formatter -> vhdl_conditional_signal_t -> Ppx_deriving_runtime.unit
|
4240
|
=
|
4241
|
let __4 () = pp_vhdl_expr_t
|
4242
|
|
4243
|
and __3 () = pp_vhdl_expr_t
|
4244
|
|
4245
|
and __2 () = pp_vhdl_signal_condition_t
|
4246
|
|
4247
|
and __1 () = pp_vhdl_name_t
|
4248
|
|
4249
|
and __0 () = pp_vhdl_name_t
|
4250
|
in
|
4251
|
((let open! Ppx_deriving_runtime in
|
4252
|
fun fmt ->
|
4253
|
fun x ->
|
4254
|
Format.fprintf fmt "@[<2>{ ";
|
4255
|
((((((Format.fprintf fmt "@[%s =@ " "postponed";
|
4256
|
(Format.fprintf fmt "%B") x.postponed;
|
4257
|
Format.fprintf fmt "@]");
|
4258
|
Format.fprintf fmt ";@ ";
|
4259
|
Format.fprintf fmt "@[%s =@ " "label";
|
4260
|
((__0 ()) fmt) x.label;
|
4261
|
Format.fprintf fmt "@]");
|
4262
|
Format.fprintf fmt ";@ ";
|
4263
|
Format.fprintf fmt "@[%s =@ " "lhs";
|
4264
|
((__1 ()) fmt) x.lhs;
|
4265
|
Format.fprintf fmt "@]");
|
4266
|
Format.fprintf fmt ";@ ";
|
4267
|
Format.fprintf fmt "@[%s =@ " "rhs";
|
4268
|
((fun x ->
|
4269
|
Format.fprintf fmt "@[<2>[";
|
4270
|
ignore
|
4271
|
(List.fold_left
|
4272
|
(fun sep ->
|
4273
|
fun x ->
|
4274
|
if sep then Format.fprintf fmt ";@ ";
|
4275
|
((__2 ()) fmt) x;
|
4276
|
true) false x);
|
4277
|
Format.fprintf fmt "@,]@]")) x.rhs;
|
4278
|
Format.fprintf fmt "@]");
|
4279
|
Format.fprintf fmt ";@ ";
|
4280
|
Format.fprintf fmt "@[%s =@ " "cond";
|
4281
|
((__3 ()) fmt) x.cond;
|
4282
|
Format.fprintf fmt "@]");
|
4283
|
Format.fprintf fmt ";@ ";
|
4284
|
Format.fprintf fmt "@[%s =@ " "delay";
|
4285
|
((__4 ()) fmt) x.delay;
|
4286
|
Format.fprintf fmt "@]");
|
4287
|
Format.fprintf fmt "@ }@]")
|
4288
|
[@ocaml.warning "-A"])
|
4289
|
|
4290
|
and show_vhdl_conditional_signal_t :
|
4291
|
vhdl_conditional_signal_t -> Ppx_deriving_runtime.string =
|
4292
|
fun x -> Format.asprintf "%a" pp_vhdl_conditional_signal_t x
|
4293
|
|
4294
|
let rec (vhdl_conditional_signal_t_to_yojson :
|
4295
|
vhdl_conditional_signal_t -> Yojson.Safe.json)
|
4296
|
=
|
4297
|
((let open! Ppx_deriving_yojson_runtime in
|
4298
|
fun x ->
|
4299
|
let fields = [] in
|
4300
|
let fields =
|
4301
|
if x.delay = IsNull
|
4302
|
then fields
|
4303
|
else ("delay", (((fun x -> vhdl_expr_t_to_yojson x)) x.delay)) ::
|
4304
|
fields
|
4305
|
in
|
4306
|
let fields =
|
4307
|
if x.cond = IsNull
|
4308
|
then fields
|
4309
|
else ("cond", (((fun x -> vhdl_expr_t_to_yojson x)) x.cond)) ::
|
4310
|
fields
|
4311
|
in
|
4312
|
let fields =
|
4313
|
("rhs",
|
4314
|
((fun x ->
|
4315
|
`List
|
4316
|
(List.map (fun x -> vhdl_signal_condition_t_to_yojson x) x))
|
4317
|
x.rhs))
|
4318
|
:: fields in
|
4319
|
let fields = ("lhs", ((fun x -> vhdl_name_t_to_yojson x) x.lhs)) ::
|
4320
|
fields in
|
4321
|
let fields =
|
4322
|
if x.label = NoName
|
4323
|
then fields
|
4324
|
else ("label", (((fun x -> vhdl_name_t_to_yojson x)) x.label)) ::
|
4325
|
fields
|
4326
|
in
|
4327
|
let fields =
|
4328
|
if x.postponed = false
|
4329
|
then fields
|
4330
|
else
|
4331
|
("postponed",
|
4332
|
(((fun (x : Ppx_deriving_runtime.bool) -> `Bool x))
|
4333
|
x.postponed))
|
4334
|
:: fields
|
4335
|
in
|
4336
|
`Assoc fields)
|
4337
|
[@ocaml.warning "-A"])
|
4338
|
|
4339
|
and (vhdl_conditional_signal_t_of_yojson :
|
4340
|
Yojson.Safe.json ->
|
4341
|
vhdl_conditional_signal_t Ppx_deriving_yojson_runtime.error_or)
|
4342
|
=
|
4343
|
((let open! Ppx_deriving_yojson_runtime in
|
4344
|
function
|
4345
|
| `Assoc xs ->
|
4346
|
let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
|
4347
|
match xs with
|
4348
|
| ("postponed",x)::xs ->
|
4349
|
loop xs
|
4350
|
(((function
|
4351
|
| `Bool x -> Result.Ok x
|
4352
|
| _ ->
|
4353
|
Result.Error
|
4354
|
"Vhdl_ast.vhdl_conditional_signal_t.postponed") x),
|
4355
|
arg1, arg2, arg3, arg4, arg5)
|
4356
|
| ("label",x)::xs ->
|
4357
|
loop xs
|
4358
|
(arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2, arg3,
|
4359
|
arg4, arg5)
|
4360
|
| ("lhs",x)::xs ->
|
4361
|
loop xs
|
4362
|
(arg0, arg1, ((fun x -> vhdl_name_t_of_yojson x) x), arg3,
|
4363
|
arg4, arg5)
|
4364
|
| ("rhs",x)::xs ->
|
4365
|
loop xs
|
4366
|
(arg0, arg1, arg2,
|
4367
|
((function
|
4368
|
| `List xs ->
|
4369
|
map_bind
|
4370
|
(fun x -> vhdl_signal_condition_t_of_yojson x)
|
4371
|
[] xs
|
4372
|
| _ ->
|
4373
|
Result.Error
|
4374
|
"Vhdl_ast.vhdl_conditional_signal_t.rhs") x),
|
4375
|
arg4, arg5)
|
4376
|
| ("cond",x)::xs ->
|
4377
|
loop xs
|
4378
|
(arg0, arg1, arg2, arg3,
|
4379
|
((fun x -> vhdl_expr_t_of_yojson x) x), arg5)
|
4380
|
| ("delay",x)::xs ->
|
4381
|
loop xs
|
4382
|
(arg0, arg1, arg2, arg3, arg4,
|
4383
|
((fun x -> vhdl_expr_t_of_yojson x) x))
|
4384
|
| [] ->
|
4385
|
arg5 >>=
|
4386
|
((fun arg5 ->
|
4387
|
arg4 >>=
|
4388
|
(fun arg4 ->
|
4389
|
arg3 >>=
|
4390
|
(fun arg3 ->
|
4391
|
arg2 >>=
|
4392
|
(fun arg2 ->
|
4393
|
arg1 >>=
|
4394
|
(fun arg1 ->
|
4395
|
arg0 >>=
|
4396
|
(fun arg0 ->
|
4397
|
Result.Ok
|
4398
|
{
|
4399
|
postponed = arg0;
|
4400
|
label = arg1;
|
4401
|
lhs = arg2;
|
4402
|
rhs = arg3;
|
4403
|
cond = arg4;
|
4404
|
delay = arg5
|
4405
|
})))))))
|
4406
|
| _::xs -> loop xs _state in
|
4407
|
loop xs
|
4408
|
((Result.Ok false), (Result.Ok NoName),
|
4409
|
(Result.Error "Vhdl_ast.vhdl_conditional_signal_t.lhs"),
|
4410
|
(Result.Error "Vhdl_ast.vhdl_conditional_signal_t.rhs"),
|
4411
|
(Result.Ok IsNull), (Result.Ok IsNull))
|
4412
|
| _ -> Result.Error "Vhdl_ast.vhdl_conditional_signal_t")
|
4413
|
[@ocaml.warning "-A"])
|
4414
|
|
4415
|
type vhdl_process_t =
|
4416
|
{
|
4417
|
id: vhdl_name_t [@default NoName];
|
4418
|
declarations: vhdl_declaration_t list option
|
4419
|
[@key "PROCESS_DECLARATIVE_PART"][@default Some []];
|
4420
|
active_sigs: vhdl_name_t list [@default []];
|
4421
|
body: vhdl_sequential_stmt_t list
|
4422
|
[@key "PROCESS_STATEMENT_PART"][@default []]}
|
4423
|
|
4424
|
let rec pp_vhdl_process_t :
|
4425
|
Format.formatter -> vhdl_process_t -> Ppx_deriving_runtime.unit =
|
4426
|
let __3 () = pp_vhdl_sequential_stmt_t
|
4427
|
|
4428
|
and __2 () = pp_vhdl_name_t
|
4429
|
|
4430
|
and __1 () = pp_vhdl_declaration_t
|
4431
|
|
4432
|
and __0 () = pp_vhdl_name_t
|
4433
|
in
|
4434
|
((let open! Ppx_deriving_runtime in
|
4435
|
fun fmt ->
|
4436
|
fun x ->
|
4437
|
Format.fprintf fmt "@[<2>{ ";
|
4438
|
((((Format.fprintf fmt "@[%s =@ " "id";
|
4439
|
((__0 ()) fmt) x.id;
|
4440
|
Format.fprintf fmt "@]");
|
4441
|
Format.fprintf fmt ";@ ";
|
4442
|
Format.fprintf fmt "@[%s =@ " "declarations";
|
4443
|
((function
|
4444
|
| None -> Format.pp_print_string fmt "None"
|
4445
|
| Some x ->
|
4446
|
(Format.pp_print_string fmt "(Some ";
|
4447
|
((fun x ->
|
4448
|
Format.fprintf fmt "@[<2>[";
|
4449
|
ignore
|
4450
|
(List.fold_left
|
4451
|
(fun sep ->
|
4452
|
fun x ->
|
4453
|
if sep then Format.fprintf fmt ";@ ";
|
4454
|
((__1 ()) fmt) x;
|
4455
|
true) false x);
|
4456
|
Format.fprintf fmt "@,]@]")) x;
|
4457
|
Format.pp_print_string fmt ")"))) x.declarations;
|
4458
|
Format.fprintf fmt "@]");
|
4459
|
Format.fprintf fmt ";@ ";
|
4460
|
Format.fprintf fmt "@[%s =@ " "active_sigs";
|
4461
|
((fun x ->
|
4462
|
Format.fprintf fmt "@[<2>[";
|
4463
|
ignore
|
4464
|
(List.fold_left
|
4465
|
(fun sep ->
|
4466
|
fun x ->
|
4467
|
if sep then Format.fprintf fmt ";@ ";
|
4468
|
((__2 ()) fmt) x;
|
4469
|
true) false x);
|
4470
|
Format.fprintf fmt "@,]@]")) x.active_sigs;
|
4471
|
Format.fprintf fmt "@]");
|
4472
|
Format.fprintf fmt ";@ ";
|
4473
|
Format.fprintf fmt "@[%s =@ " "body";
|
4474
|
((fun x ->
|
4475
|
Format.fprintf fmt "@[<2>[";
|
4476
|
ignore
|
4477
|
(List.fold_left
|
4478
|
(fun sep ->
|
4479
|
fun x ->
|
4480
|
if sep then Format.fprintf fmt ";@ ";
|
4481
|
((__3 ()) fmt) x;
|
4482
|
true) false x);
|
4483
|
Format.fprintf fmt "@,]@]")) x.body;
|
4484
|
Format.fprintf fmt "@]");
|
4485
|
Format.fprintf fmt "@ }@]")
|
4486
|
[@ocaml.warning "-A"])
|
4487
|
|
4488
|
and show_vhdl_process_t : vhdl_process_t -> Ppx_deriving_runtime.string =
|
4489
|
fun x -> Format.asprintf "%a" pp_vhdl_process_t x
|
4490
|
|
4491
|
let rec (vhdl_process_t_to_yojson : vhdl_process_t -> Yojson.Safe.json) =
|
4492
|
((let open! Ppx_deriving_yojson_runtime in
|
4493
|
fun x ->
|
4494
|
let fields = [] in
|
4495
|
let fields =
|
4496
|
if x.body = []
|
4497
|
then fields
|
4498
|
else
|
4499
|
("PROCESS_STATEMENT_PART",
|
4500
|
(((fun x ->
|
4501
|
`List
|
4502
|
(List.map (fun x -> vhdl_sequential_stmt_t_to_yojson x)
|
4503
|
x))) x.body))
|
4504
|
:: fields
|
4505
|
in
|
4506
|
let fields =
|
4507
|
if x.active_sigs = []
|
4508
|
then fields
|
4509
|
else
|
4510
|
("active_sigs",
|
4511
|
(((fun x ->
|
4512
|
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x)))
|
4513
|
x.active_sigs))
|
4514
|
:: fields
|
4515
|
in
|
4516
|
let fields =
|
4517
|
if x.declarations = (Some [])
|
4518
|
then fields
|
4519
|
else
|
4520
|
("PROCESS_DECLARATIVE_PART",
|
4521
|
(((function
|
4522
|
| None -> `Null
|
4523
|
| Some x ->
|
4524
|
((fun x ->
|
4525
|
`List
|
4526
|
(List.map
|
4527
|
(fun x -> vhdl_declaration_t_to_yojson x) x)))
|
4528
|
x)) x.declarations))
|
4529
|
:: fields
|
4530
|
in
|
4531
|
let fields =
|
4532
|
if x.id = NoName
|
4533
|
then fields
|
4534
|
else ("id", (((fun x -> vhdl_name_t_to_yojson x)) x.id)) :: fields
|
4535
|
in
|
4536
|
`Assoc fields)
|
4537
|
[@ocaml.warning "-A"])
|
4538
|
|
4539
|
and (vhdl_process_t_of_yojson :
|
4540
|
Yojson.Safe.json -> vhdl_process_t Ppx_deriving_yojson_runtime.error_or)
|
4541
|
=
|
4542
|
((let open! Ppx_deriving_yojson_runtime in
|
4543
|
function
|
4544
|
| `Assoc xs ->
|
4545
|
let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
|
4546
|
match xs with
|
4547
|
| ("id",x)::xs ->
|
4548
|
loop xs
|
4549
|
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3)
|
4550
|
| ("PROCESS_DECLARATIVE_PART",x)::xs ->
|
4551
|
loop xs
|
4552
|
(arg0,
|
4553
|
((function
|
4554
|
| `Null -> Result.Ok None
|
4555
|
| x ->
|
4556
|
((function
|
4557
|
| `List xs ->
|
4558
|
map_bind
|
4559
|
(fun x -> vhdl_declaration_t_of_yojson x)
|
4560
|
[] xs
|
4561
|
| _ ->
|
4562
|
Result.Error
|
4563
|
"Vhdl_ast.vhdl_process_t.declarations") x)
|
4564
|
>>= ((fun x -> Result.Ok (Some x)))) x), arg2,
|
4565
|
arg3)
|
4566
|
| ("active_sigs",x)::xs ->
|
4567
|
loop xs
|
4568
|
(arg0, arg1,
|
4569
|
((function
|
4570
|
| `List xs ->
|
4571
|
map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs
|
4572
|
| _ ->
|
4573
|
Result.Error "Vhdl_ast.vhdl_process_t.active_sigs")
|
4574
|
x), arg3)
|
4575
|
| ("PROCESS_STATEMENT_PART",x)::xs ->
|
4576
|
loop xs
|
4577
|
(arg0, arg1, arg2,
|
4578
|
((function
|
4579
|
| `List xs ->
|
4580
|
map_bind
|
4581
|
(fun x -> vhdl_sequential_stmt_t_of_yojson x) []
|
4582
|
xs
|
4583
|
| _ -> Result.Error "Vhdl_ast.vhdl_process_t.body") x))
|
4584
|
| [] ->
|
4585
|
arg3 >>=
|
4586
|
((fun arg3 ->
|
4587
|
arg2 >>=
|
4588
|
(fun arg2 ->
|
4589
|
arg1 >>=
|
4590
|
(fun arg1 ->
|
4591
|
arg0 >>=
|
4592
|
(fun arg0 ->
|
4593
|
Result.Ok
|
4594
|
{
|
4595
|
id = arg0;
|
4596
|
declarations = arg1;
|
4597
|
active_sigs = arg2;
|
4598
|
body = arg3
|
4599
|
})))))
|
4600
|
| _::xs -> loop xs _state in
|
4601
|
loop xs
|
4602
|
((Result.Ok NoName), (Result.Ok (Some [])), (Result.Ok []),
|
4603
|
(Result.Ok []))
|
4604
|
| _ -> Result.Error "Vhdl_ast.vhdl_process_t")
|
4605
|
[@ocaml.warning "-A"])
|
4606
|
|
4607
|
type vhdl_selected_signal_t =
|
4608
|
{
|
4609
|
postponed: bool [@default false];
|
4610
|
label: vhdl_name_t [@default NoName];
|
4611
|
lhs: vhdl_name_t ;
|
4612
|
sel: vhdl_expr_t ;
|
4613
|
branches: vhdl_signal_selection_t list [@default []];
|
4614
|
delay: vhdl_expr_t option }
|
4615
|
|
4616
|
let rec pp_vhdl_selected_signal_t :
|
4617
|
Format.formatter -> vhdl_selected_signal_t -> Ppx_deriving_runtime.unit =
|
4618
|
let __4 () = pp_vhdl_expr_t
|
4619
|
|
4620
|
and __3 () = pp_vhdl_signal_selection_t
|
4621
|
|
4622
|
and __2 () = pp_vhdl_expr_t
|
4623
|
|
4624
|
and __1 () = pp_vhdl_name_t
|
4625
|
|
4626
|
and __0 () = pp_vhdl_name_t
|
4627
|
in
|
4628
|
((let open! Ppx_deriving_runtime in
|
4629
|
fun fmt ->
|
4630
|
fun x ->
|
4631
|
Format.fprintf fmt "@[<2>{ ";
|
4632
|
((((((Format.fprintf fmt "@[%s =@ " "postponed";
|
4633
|
(Format.fprintf fmt "%B") x.postponed;
|
4634
|
Format.fprintf fmt "@]");
|
4635
|
Format.fprintf fmt ";@ ";
|
4636
|
Format.fprintf fmt "@[%s =@ " "label";
|
4637
|
((__0 ()) fmt) x.label;
|
4638
|
Format.fprintf fmt "@]");
|
4639
|
Format.fprintf fmt ";@ ";
|
4640
|
Format.fprintf fmt "@[%s =@ " "lhs";
|
4641
|
((__1 ()) fmt) x.lhs;
|
4642
|
Format.fprintf fmt "@]");
|
4643
|
Format.fprintf fmt ";@ ";
|
4644
|
Format.fprintf fmt "@[%s =@ " "sel";
|
4645
|
((__2 ()) fmt) x.sel;
|
4646
|
Format.fprintf fmt "@]");
|
4647
|
Format.fprintf fmt ";@ ";
|
4648
|
Format.fprintf fmt "@[%s =@ " "branches";
|
4649
|
((fun x ->
|
4650
|
Format.fprintf fmt "@[<2>[";
|
4651
|
ignore
|
4652
|
(List.fold_left
|
4653
|
(fun sep ->
|
4654
|
fun x ->
|
4655
|
if sep then Format.fprintf fmt ";@ ";
|
4656
|
((__3 ()) fmt) x;
|
4657
|
true) false x);
|
4658
|
Format.fprintf fmt "@,]@]")) x.branches;
|
4659
|
Format.fprintf fmt "@]");
|
4660
|
Format.fprintf fmt ";@ ";
|
4661
|
Format.fprintf fmt "@[%s =@ " "delay";
|
4662
|
((function
|
4663
|
| None -> Format.pp_print_string fmt "None"
|
4664
|
| Some x ->
|
4665
|
(Format.pp_print_string fmt "(Some ";
|
4666
|
((__4 ()) fmt) x;
|
4667
|
Format.pp_print_string fmt ")"))) x.delay;
|
4668
|
Format.fprintf fmt "@]");
|
4669
|
Format.fprintf fmt "@ }@]")
|
4670
|
[@ocaml.warning "-A"])
|
4671
|
|
4672
|
and show_vhdl_selected_signal_t :
|
4673
|
vhdl_selected_signal_t -> Ppx_deriving_runtime.string =
|
4674
|
fun x -> Format.asprintf "%a" pp_vhdl_selected_signal_t x
|
4675
|
|
4676
|
let rec (vhdl_selected_signal_t_to_yojson :
|
4677
|
vhdl_selected_signal_t -> Yojson.Safe.json)
|
4678
|
=
|
4679
|
((let open! Ppx_deriving_yojson_runtime in
|
4680
|
fun x ->
|
4681
|
let fields = [] in
|
4682
|
let fields =
|
4683
|
("delay",
|
4684
|
((function
|
4685
|
| None -> `Null
|
4686
|
| Some x -> ((fun x -> vhdl_expr_t_to_yojson x)) x) x.delay))
|
4687
|
:: fields in
|
4688
|
let fields =
|
4689
|
if x.branches = []
|
4690
|
then fields
|
4691
|
else
|
4692
|
("branches",
|
4693
|
(((fun x ->
|
4694
|
`List
|
4695
|
(List.map
|
4696
|
(fun x -> vhdl_signal_selection_t_to_yojson x) x)))
|
4697
|
x.branches))
|
4698
|
:: fields
|
4699
|
in
|
4700
|
let fields = ("sel", ((fun x -> vhdl_expr_t_to_yojson x) x.sel)) ::
|
4701
|
fields in
|
4702
|
let fields = ("lhs", ((fun x -> vhdl_name_t_to_yojson x) x.lhs)) ::
|
4703
|
fields in
|
4704
|
let fields =
|
4705
|
if x.label = NoName
|
4706
|
then fields
|
4707
|
else ("label", (((fun x -> vhdl_name_t_to_yojson x)) x.label)) ::
|
4708
|
fields
|
4709
|
in
|
4710
|
let fields =
|
4711
|
if x.postponed = false
|
4712
|
then fields
|
4713
|
else
|
4714
|
("postponed",
|
4715
|
(((fun (x : Ppx_deriving_runtime.bool) -> `Bool x))
|
4716
|
x.postponed))
|
4717
|
:: fields
|
4718
|
in
|
4719
|
`Assoc fields)
|
4720
|
[@ocaml.warning "-A"])
|
4721
|
|
4722
|
and (vhdl_selected_signal_t_of_yojson :
|
4723
|
Yojson.Safe.json ->
|
4724
|
vhdl_selected_signal_t Ppx_deriving_yojson_runtime.error_or)
|
4725
|
=
|
4726
|
((let open! Ppx_deriving_yojson_runtime in
|
4727
|
function
|
4728
|
| `Assoc xs ->
|
4729
|
let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
|
4730
|
match xs with
|
4731
|
| ("postponed",x)::xs ->
|
4732
|
loop xs
|
4733
|
(((function
|
4734
|
| `Bool x -> Result.Ok x
|
4735
|
| _ ->
|
4736
|
Result.Error
|
4737
|
"Vhdl_ast.vhdl_selected_signal_t.postponed") x),
|
4738
|
arg1, arg2, arg3, arg4, arg5)
|
4739
|
| ("label",x)::xs ->
|
4740
|
loop xs
|
4741
|
(arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2, arg3,
|
4742
|
arg4, arg5)
|
4743
|
| ("lhs",x)::xs ->
|
4744
|
loop xs
|
4745
|
(arg0, arg1, ((fun x -> vhdl_name_t_of_yojson x) x), arg3,
|
4746
|
arg4, arg5)
|
4747
|
| ("sel",x)::xs ->
|
4748
|
loop xs
|
4749
|
(arg0, arg1, arg2, ((fun x -> vhdl_expr_t_of_yojson x) x),
|
4750
|
arg4, arg5)
|
4751
|
| ("branches",x)::xs ->
|
4752
|
loop xs
|
4753
|
(arg0, arg1, arg2, arg3,
|
4754
|
((function
|
4755
|
| `List xs ->
|
4756
|
map_bind
|
4757
|
(fun x -> vhdl_signal_selection_t_of_yojson x)
|
4758
|
[] xs
|
4759
|
| _ ->
|
4760
|
Result.Error
|
4761
|
"Vhdl_ast.vhdl_selected_signal_t.branches") x),
|
4762
|
arg5)
|
4763
|
| ("delay",x)::xs ->
|
4764
|
loop xs
|
4765
|
(arg0, arg1, arg2, arg3, arg4,
|
4766
|
((function
|
4767
|
| `Null -> Result.Ok None
|
4768
|
| x ->
|
4769
|
((fun x -> vhdl_expr_t_of_yojson x) x) >>=
|
4770
|
((fun x -> Result.Ok (Some x)))) x))
|
4771
|
| [] ->
|
4772
|
arg5 >>=
|
4773
|
((fun arg5 ->
|
4774
|
arg4 >>=
|
4775
|
(fun arg4 ->
|
4776
|
arg3 >>=
|
4777
|
(fun arg3 ->
|
4778
|
arg2 >>=
|
4779
|
(fun arg2 ->
|
4780
|
arg1 >>=
|
4781
|
(fun arg1 ->
|
4782
|
arg0 >>=
|
4783
|
(fun arg0 ->
|
4784
|
Result.Ok
|
4785
|
{
|
4786
|
postponed = arg0;
|
4787
|
label = arg1;
|
4788
|
lhs = arg2;
|
4789
|
sel = arg3;
|
4790
|
branches = arg4;
|
4791
|
delay = arg5
|
4792
|
})))))))
|
4793
|
| _::xs -> loop xs _state in
|
4794
|
loop xs
|
4795
|
((Result.Ok false), (Result.Ok NoName),
|
4796
|
(Result.Error "Vhdl_ast.vhdl_selected_signal_t.lhs"),
|
4797
|
(Result.Error "Vhdl_ast.vhdl_selected_signal_t.sel"),
|
4798
|
(Result.Ok []),
|
4799
|
(Result.Error "Vhdl_ast.vhdl_selected_signal_t.delay"))
|
4800
|
| _ -> Result.Error "Vhdl_ast.vhdl_selected_signal_t")
|
4801
|
[@ocaml.warning "-A"])
|
4802
|
|
4803
|
type vhdl_concurrent_stmt_t =
|
4804
|
| SigAssign of vhdl_conditional_signal_t
|
4805
|
[@name "CONDITIONAL_SIGNAL_ASSIGNMENT"]
|
4806
|
| Process of vhdl_process_t [@name "PROCESS_STATEMENT"]
|
4807
|
| SelectedSig of vhdl_selected_signal_t
|
4808
|
[@name "SELECTED_SIGNAL_ASSIGNMENT"]
|
4809
|
|
4810
|
(* Adapted *)
|
4811
|
let rec pp_vhdl_concurrent_stmt_t :
|
4812
|
Format.formatter -> vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.unit =
|
4813
|
let __2 () = pp_vhdl_selected_signal_t
|
4814
|
|
4815
|
and __1 () = pp_vhdl_process_t
|
4816
|
|
4817
|
and __0 () = pp_vhdl_conditional_signal_t
|
4818
|
in
|
4819
|
((let open! Ppx_deriving_runtime in
|
4820
|
fun fmt ->
|
4821
|
function
|
4822
|
| SigAssign a0 ->
|
4823
|
((__0 ()) fmt) a0;
|
4824
|
| Process a0 ->
|
4825
|
((__1 ()) fmt) a0;
|
4826
|
| SelectedSig a0 ->
|
4827
|
((__2 ()) fmt) a0;
|
4828
|
)
|
4829
|
[@ocaml.warning "-A"])
|
4830
|
|
4831
|
and show_vhdl_concurrent_stmt_t :
|
4832
|
vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.string =
|
4833
|
fun x -> Format.asprintf "%a" pp_vhdl_concurrent_stmt_t x
|
4834
|
|
4835
|
let rec (vhdl_concurrent_stmt_t_to_yojson :
|
4836
|
vhdl_concurrent_stmt_t -> Yojson.Safe.json)
|
4837
|
=
|
4838
|
((let open! Ppx_deriving_yojson_runtime in
|
4839
|
function
|
4840
|
| SigAssign arg0 ->
|
4841
|
`List
|
4842
|
[`String "CONDITIONAL_SIGNAL_ASSIGNMENT";
|
4843
|
((fun x -> vhdl_conditional_signal_t_to_yojson x)) arg0]
|
4844
|
| Process arg0 ->
|
4845
|
`List
|
4846
|
[`String "PROCESS_STATEMENT";
|
4847
|
((fun x -> vhdl_process_t_to_yojson x)) arg0]
|
4848
|
| SelectedSig arg0 ->
|
4849
|
`List
|
4850
|
[`String "SELECTED_SIGNAL_ASSIGNMENT";
|
4851
|
((fun x -> vhdl_selected_signal_t_to_yojson x)) arg0])
|
4852
|
[@ocaml.warning "-A"])
|
4853
|
|
4854
|
and (vhdl_concurrent_stmt_t_of_yojson :
|
4855
|
Yojson.Safe.json ->
|
4856
|
vhdl_concurrent_stmt_t Ppx_deriving_yojson_runtime.error_or)
|
4857
|
=
|
4858
|
((let open! Ppx_deriving_yojson_runtime in
|
4859
|
function
|
4860
|
| `List ((`String "CONDITIONAL_SIGNAL_ASSIGNMENT")::arg0::[]) ->
|
4861
|
((fun x -> vhdl_conditional_signal_t_of_yojson x) arg0) >>=
|
4862
|
((fun arg0 -> Result.Ok (SigAssign arg0)))
|
4863
|
| `List ((`String "PROCESS_STATEMENT")::arg0::[]) ->
|
4864
|
((fun x -> vhdl_process_t_of_yojson x) arg0) >>=
|
4865
|
((fun arg0 -> Result.Ok (Process arg0)))
|
4866
|
| `List ((`String "SELECTED_SIGNAL_ASSIGNMENT")::arg0::[]) ->
|
4867
|
((fun x -> vhdl_selected_signal_t_of_yojson x) arg0) >>=
|
4868
|
((fun arg0 -> Result.Ok (SelectedSig arg0)))
|
4869
|
| _ -> Result.Error "Vhdl_ast.vhdl_concurrent_stmt_t")
|
4870
|
[@ocaml.warning "-A"])
|
4871
|
|
4872
|
type vhdl_port_mode_t =
|
4873
|
| InPort [@name "in"]
|
4874
|
| OutPort [@name "out"]
|
4875
|
| InoutPort [@name "inout"]
|
4876
|
| BufferPort [@name "buffer"]
|
4877
|
|
4878
|
let rec (pp_vhdl_port_mode_t :
|
4879
|
Format.formatter -> vhdl_port_mode_t -> Ppx_deriving_runtime.unit)
|
4880
|
=
|
4881
|
((let open! Ppx_deriving_runtime in
|
4882
|
fun fmt ->
|
4883
|
function
|
4884
|
| InPort -> Format.pp_print_string fmt "in"
|
4885
|
| OutPort -> Format.pp_print_string fmt "out"
|
4886
|
| InoutPort -> Format.pp_print_string fmt "inout"
|
4887
|
| BufferPort -> Format.pp_print_string fmt "buffer")
|
4888
|
[@ocaml.warning "-A"])
|
4889
|
|
4890
|
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string =
|
4891
|
fun x -> Format.asprintf "%a" pp_vhdl_port_mode_t x
|
4892
|
|
4893
|
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) =
|
4894
|
((let open! Ppx_deriving_yojson_runtime in
|
4895
|
function
|
4896
|
| InPort -> `List [`String "in"]
|
4897
|
| OutPort -> `List [`String "out"]
|
4898
|
| InoutPort -> `List [`String "inout"]
|
4899
|
| BufferPort -> `List [`String "buffer"])
|
4900
|
[@ocaml.warning "-A"])
|
4901
|
|
4902
|
and (vhdl_port_mode_t_of_yojson :
|
4903
|
Yojson.Safe.json ->
|
4904
|
vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or)
|
4905
|
=
|
4906
|
((let open! Ppx_deriving_yojson_runtime in
|
4907
|
function
|
4908
|
| `List ((`String "in")::[]) -> Result.Ok InPort
|
4909
|
| `List ((`String "out")::[]) -> Result.Ok OutPort
|
4910
|
| `List ((`String "inout")::[]) -> Result.Ok InoutPort
|
4911
|
| `List ((`String "buffer")::[]) -> Result.Ok BufferPort
|
4912
|
| _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t")
|
4913
|
[@ocaml.warning "-A"])
|
4914
|
|
4915
|
type vhdl_port_t =
|
4916
|
{
|
4917
|
names: vhdl_name_t list [@default []];
|
4918
|
mode: vhdl_port_mode_t [@default InPort];
|
4919
|
typ: vhdl_subtype_indication_t ;
|
4920
|
expr: vhdl_expr_t [@default IsNull]}
|
4921
|
|
4922
|
(* Adapted *)
|
4923
|
let rec pp_vhdl_port_t :
|
4924
|
Format.formatter -> vhdl_port_t -> Ppx_deriving_runtime.unit =
|
4925
|
let __3 () = pp_vhdl_expr_t
|
4926
|
|
4927
|
and __2 () = pp_vhdl_subtype_indication_t
|
4928
|
|
4929
|
and __1 () = pp_vhdl_port_mode_t
|
4930
|
|
4931
|
and __0 () = pp_vhdl_name_t
|
4932
|
in
|
4933
|
((let open! Ppx_deriving_runtime in
|
4934
|
fun fmt ->
|
4935
|
fun x ->
|
4936
|
Format.fprintf fmt "@[";
|
4937
|
((((
|
4938
|
((fun x ->
|
4939
|
Format.fprintf fmt "@[";
|
4940
|
ignore
|
4941
|
(List.fold_left
|
4942
|
(fun sep ->
|
4943
|
fun x ->
|
4944
|
if sep then Format.fprintf fmt ",@ ";
|
4945
|
((__0 ()) fmt) x;
|
4946
|
true) false x);
|
4947
|
Format.fprintf fmt "@,@]")) x.names;
|
4948
|
);
|
4949
|
Format.fprintf fmt ":@ ";
|
4950
|
((__1 ()) fmt) x.mode;
|
4951
|
);
|
4952
|
Format.fprintf fmt "@ ";
|
4953
|
((__2 ()) fmt) x.typ;
|
4954
|
);
|
4955
|
(match x.expr with
|
4956
|
| IsNull -> Format.fprintf fmt "";
|
4957
|
| _ -> (Format.fprintf fmt "@[:=@ ";
|
4958
|
((__3 ()) fmt) x.expr;
|
4959
|
Format.fprintf fmt "@]"));
|
4960
|
Format.fprintf fmt "@]"))
|
4961
|
[@ocaml.warning "-A"])
|
4962
|
|
4963
|
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string =
|
4964
|
fun x -> Format.asprintf "%a" pp_vhdl_port_t x
|
4965
|
|
4966
|
let rec (vhdl_port_t_to_yojson : vhdl_port_t -> Yojson.Safe.json) =
|
4967
|
((let open! Ppx_deriving_yojson_runtime in
|
4968
|
fun x ->
|
4969
|
let fields = [] in
|
4970
|
let fields =
|
4971
|
if x.expr = IsNull
|
4972
|
then fields
|
4973
|
else ("expr", (((fun x -> vhdl_expr_t_to_yojson x)) x.expr)) ::
|
4974
|
fields
|
4975
|
in
|
4976
|
let fields =
|
4977
|
("typ", ((fun x -> vhdl_subtype_indication_t_to_yojson x) x.typ))
|
4978
|
:: fields in
|
4979
|
let fields =
|
4980
|
if x.mode = InPort
|
4981
|
then fields
|
4982
|
else ("mode", (((fun x -> vhdl_port_mode_t_to_yojson x)) x.mode))
|
4983
|
:: fields
|
4984
|
in
|
4985
|
let fields =
|
4986
|
if x.names = []
|
4987
|
then fields
|
4988
|
else
|
4989
|
("names",
|
4990
|
(((fun x ->
|
4991
|
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x)))
|
4992
|
x.names))
|
4993
|
:: fields
|
4994
|
in
|
4995
|
`Assoc fields)
|
4996
|
[@ocaml.warning "-A"])
|
4997
|
|
4998
|
and (vhdl_port_t_of_yojson :
|
4999
|
Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
|
5000
|
=
|
5001
|
((let open! Ppx_deriving_yojson_runtime in
|
5002
|
function
|
5003
|
| `Assoc xs ->
|
5004
|
let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
|
5005
|
match xs with
|
5006
|
| ("names",x)::xs ->
|
5007
|
loop xs
|
5008
|
(((function
|
5009
|
| `List xs ->
|
5010
|
map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs
|
5011
|
| _ -> Result.Error "Vhdl_ast.vhdl_port_t.names") x),
|
5012
|
arg1, arg2, arg3)
|
5013
|
| ("mode",x)::xs ->
|
5014
|
loop xs
|
5015
|
(arg0, ((fun x -> vhdl_port_mode_t_of_yojson x) x), arg2,
|
5016
|
arg3)
|
5017
|
| ("typ",x)::xs ->
|
5018
|
loop xs
|
5019
|
(arg0, arg1,
|
5020
|
((fun x -> vhdl_subtype_indication_t_of_yojson x) x),
|
5021
|
arg3)
|
5022
|
| ("expr",x)::xs ->
|
5023
|
loop xs
|
5024
|
(arg0, arg1, arg2, ((fun x -> vhdl_expr_t_of_yojson x) x))
|
5025
|
| [] ->
|
5026
|
arg3 >>=
|
5027
|
((fun arg3 ->
|
5028
|
arg2 >>=
|
5029
|
(fun arg2 ->
|
5030
|
arg1 >>=
|
5031
|
(fun arg1 ->
|
5032
|
arg0 >>=
|
5033
|
(fun arg0 ->
|
5034
|
Result.Ok
|
5035
|
{
|
5036
|
names = arg0;
|
5037
|
mode = arg1;
|
5038
|
typ = arg2;
|
5039
|
expr = arg3
|
5040
|
})))))
|
5041
|
| _::xs -> loop xs _state in
|
5042
|
loop xs
|
5043
|
((Result.Ok []), (Result.Ok InPort),
|
5044
|
(Result.Error "Vhdl_ast.vhdl_port_t.typ"), (Result.Ok IsNull))
|
5045
|
| _ -> Result.Error "Vhdl_ast.vhdl_port_t")
|
5046
|
[@ocaml.warning "-A"])
|
5047
|
|
5048
|
type vhdl_entity_t =
|
5049
|
{
|
5050
|
name: vhdl_name_t [@default NoName];
|
5051
|
generics: vhdl_port_t list [@default []];
|
5052
|
ports: vhdl_port_t list [@default []];
|
5053
|
declaration: vhdl_declaration_t list
|
5054
|
[@key "ENTITY_DECLARATIVE_PART"][@default []];
|
5055
|
stmts: vhdl_concurrent_stmt_t list
|
5056
|
[@key "ENTITY_STATEMENT_PART"][@default []]}
|
5057
|
|
5058
|
(* Adapted *)
|
5059
|
let rec pp_vhdl_entity_t :
|
5060
|
Format.formatter -> vhdl_entity_t -> Ppx_deriving_runtime.unit =
|
5061
|
let __4 () = pp_vhdl_concurrent_stmt_t
|
5062
|
|
5063
|
and __3 () = pp_vhdl_declaration_t
|
5064
|
|
5065
|
and __2 () = pp_vhdl_port_t
|
5066
|
|
5067
|
and __1 () = pp_vhdl_port_t
|
5068
|
|
5069
|
and __0 () = pp_vhdl_name_t
|
5070
|
in
|
5071
|
((let open! Ppx_deriving_runtime in
|
5072
|
fun fmt ->
|
5073
|
fun x ->
|
5074
|
(((((
|
5075
|
((__0 ()) fmt) x.name;
|
5076
|
Format.fprintf fmt " is@ ");
|
5077
|
Format.fprintf fmt "@[<v>";
|
5078
|
((fun x ->
|
5079
|
Format.fprintf fmt "@[";
|
5080
|
ignore
|
5081
|
(List.fold_left
|
5082
|
(fun sep ->
|
5083
|
fun x ->
|
5084
|
if sep then Format.fprintf fmt ";@ ";
|
5085
|
((__1 ()) fmt) x;
|
5086
|
true) false x);
|
5087
|
Format.fprintf fmt "@]")) x.generics;
|
5088
|
Format.fprintf fmt "@]");
|
5089
|
Format.fprintf fmt "port (@[<v>";
|
5090
|
((fun x ->
|
5091
|
Format.fprintf fmt "@[";
|
5092
|
ignore
|
5093
|
(List.fold_left
|
5094
|
(fun sep ->
|
5095
|
fun x ->
|
5096
|
if sep then Format.fprintf fmt ";@ ";
|
5097
|
((__2 ()) fmt) x;
|
5098
|
true) false x);
|
5099
|
Format.fprintf fmt "@]")) x.ports;
|
5100
|
Format.fprintf fmt "@]);");
|
5101
|
Format.fprintf fmt "@[<v>";
|
5102
|
((fun x ->
|
5103
|
Format.fprintf fmt "@[";
|
5104
|
ignore
|
5105
|
(List.fold_left
|
5106
|
(fun sep ->
|
5107
|
fun x ->
|
5108
|
if sep then Format.fprintf fmt ";@ ";
|
5109
|
((__3 ()) fmt) x;
|
5110
|
true) false x);
|
5111
|
Format.fprintf fmt "@]")) x.declaration;
|
5112
|
Format.fprintf fmt "@]");
|
5113
|
Format.fprintf fmt "@[<v>";
|
5114
|
((fun x ->
|
5115
|
Format.fprintf fmt "@[";
|
5116
|
ignore
|
5117
|
(List.fold_left
|
5118
|
(fun sep ->
|
5119
|
fun x ->
|
5120
|
if sep then Format.fprintf fmt ";@ ";
|
5121
|
((__4 ()) fmt) x;
|
5122
|
true) false x);
|
5123
|
Format.fprintf fmt "@]")) x.stmts;
|
5124
|
Format.fprintf fmt "@]");
|
5125
|
Format.fprintf fmt "@]")
|
5126
|
[@ocaml.warning "-A"])
|
5127
|
|
5128
|
and show_vhdl_entity_t : vhdl_entity_t -> Ppx_deriving_runtime.string =
|
5129
|
fun x -> Format.asprintf "%a" pp_vhdl_entity_t x
|
5130
|
|
5131
|
let rec (vhdl_entity_t_to_yojson : vhdl_entity_t -> Yojson.Safe.json) =
|
5132
|
((let open! Ppx_deriving_yojson_runtime in
|
5133
|
fun x ->
|
5134
|
let fields = [] in
|
5135
|
let fields =
|
5136
|
if x.stmts = []
|
5137
|
then fields
|
5138
|
else
|
5139
|
("ENTITY_STATEMENT_PART",
|
5140
|
(((fun x ->
|
5141
|
`List
|
5142
|
(List.map (fun x -> vhdl_concurrent_stmt_t_to_yojson x)
|
5143
|
x))) x.stmts))
|
5144
|
:: fields
|
5145
|
in
|
5146
|
let fields =
|
5147
|
if x.declaration = []
|
5148
|
then fields
|
5149
|
else
|
5150
|
("ENTITY_DECLARATIVE_PART",
|
5151
|
(((fun x ->
|
5152
|
`List
|
5153
|
(List.map (fun x -> vhdl_declaration_t_to_yojson x) x)))
|
5154
|
x.declaration))
|
5155
|
:: fields
|
5156
|
in
|
5157
|
let fields =
|
5158
|
if x.ports = []
|
5159
|
then fields
|
5160
|
else
|
5161
|
("ports",
|
5162
|
(((fun x ->
|
5163
|
`List (List.map (fun x -> vhdl_port_t_to_yojson x) x)))
|
5164
|
x.ports))
|
5165
|
:: fields
|
5166
|
in
|
5167
|
let fields =
|
5168
|
if x.generics = []
|
5169
|
then fields
|
5170
|
else
|
5171
|
("generics",
|
5172
|
(((fun x ->
|
5173
|
`List (List.map (fun x -> vhdl_port_t_to_yojson x) x)))
|
5174
|
x.generics))
|
5175
|
:: fields
|
5176
|
in
|
5177
|
let fields =
|
5178
|
if x.name = NoName
|
5179
|
then fields
|
5180
|
else ("name", (((fun x -> vhdl_name_t_to_yojson x)) x.name)) ::
|
5181
|
fields
|
5182
|
in
|
5183
|
`Assoc fields)
|
5184
|
[@ocaml.warning "-A"])
|
5185
|
|
5186
|
and (vhdl_entity_t_of_yojson :
|
5187
|
Yojson.Safe.json -> vhdl_entity_t Ppx_deriving_yojson_runtime.error_or)
|
5188
|
=
|
5189
|
((let open! Ppx_deriving_yojson_runtime in
|
5190
|
function
|
5191
|
| `Assoc xs ->
|
5192
|
let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
|
5193
|
match xs with
|
5194
|
| ("name",x)::xs ->
|
5195
|
loop xs
|
5196
|
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3,
|
5197
|
arg4)
|
5198
|
| ("generics",x)::xs ->
|
5199
|
loop xs
|
5200
|
(arg0,
|
5201
|
((function
|
5202
|
| `List xs ->
|
5203
|
map_bind (fun x -> vhdl_port_t_of_yojson x) [] xs
|
5204
|
| _ -> Result.Error "Vhdl_ast.vhdl_entity_t.generics")
|
5205
|
x), arg2, arg3, arg4)
|
5206
|
| ("ports",x)::xs ->
|
5207
|
loop xs
|
5208
|
(arg0, arg1,
|
5209
|
((function
|
5210
|
| `List xs ->
|
5211
|
map_bind (fun x -> vhdl_port_t_of_yojson x) [] xs
|
5212
|
| _ -> Result.Error "Vhdl_ast.vhdl_entity_t.ports") x),
|
5213
|
arg3, arg4)
|
5214
|
| ("ENTITY_DECLARATIVE_PART",x)::xs ->
|
5215
|
loop xs
|
5216
|
(arg0, arg1, arg2,
|
5217
|
((function
|
5218
|
| `List xs ->
|
5219
|
map_bind (fun x -> vhdl_declaration_t_of_yojson x)
|
5220
|
[] xs
|
5221
|
| _ ->
|
5222
|
Result.Error "Vhdl_ast.vhdl_entity_t.declaration")
|
5223
|
x), arg4)
|
5224
|
| ("ENTITY_STATEMENT_PART",x)::xs ->
|
5225
|
loop xs
|
5226
|
(arg0, arg1, arg2, arg3,
|
5227
|
((function
|
5228
|
| `List xs ->
|
5229
|
map_bind
|
5230
|
(fun x -> vhdl_concurrent_stmt_t_of_yojson x) []
|
5231
|
xs
|
5232
|
| _ -> Result.Error "Vhdl_ast.vhdl_entity_t.stmts") x))
|
5233
|
| [] ->
|
5234
|
arg4 >>=
|
5235
|
((fun arg4 ->
|
5236
|
arg3 >>=
|
5237
|
(fun arg3 ->
|
5238
|
arg2 >>=
|
5239
|
(fun arg2 ->
|
5240
|
arg1 >>=
|
5241
|
(fun arg1 ->
|
5242
|
arg0 >>=
|
5243
|
(fun arg0 ->
|
5244
|
Result.Ok
|
5245
|
{
|
5246
|
name = arg0;
|
5247
|
generics = arg1;
|
5248
|
ports = arg2;
|
5249
|
declaration = arg3;
|
5250
|
stmts = arg4
|
5251
|
}))))))
|
5252
|
| _::xs -> loop xs _state in
|
5253
|
loop xs
|
5254
|
((Result.Ok NoName), (Result.Ok []), (Result.Ok []),
|
5255
|
(Result.Ok []), (Result.Ok []))
|
5256
|
| _ -> Result.Error "Vhdl_ast.vhdl_entity_t")
|
5257
|
[@ocaml.warning "-A"])
|
5258
|
|
5259
|
type vhdl_package_t =
|
5260
|
{
|
5261
|
name: vhdl_name_t [@default NoName];
|
5262
|
shared_defs: vhdl_definition_t list [@default []]}
|
5263
|
|
5264
|
(* Adapted -- TODO: indentation of package content is not correct *)
|
5265
|
let rec pp_vhdl_package_t :
|
5266
|
Format.formatter -> vhdl_package_t -> Ppx_deriving_runtime.unit =
|
5267
|
let __1 () = pp_vhdl_definition_t
|
5268
|
|
5269
|
and __0 () = pp_vhdl_name_t
|
5270
|
in
|
5271
|
((let open! Ppx_deriving_runtime in
|
5272
|
fun fmt ->
|
5273
|
fun x ->
|
5274
|
((Format.fprintf fmt "@[";
|
5275
|
((__0 ()) fmt) x.name;
|
5276
|
Format.fprintf fmt " is@.");
|
5277
|
Format.fprintf fmt "@[<v 2>";
|
5278
|
((fun x ->
|
5279
|
Format.fprintf fmt "@[";
|
5280
|
ignore
|
5281
|
(List.fold_left
|
5282
|
(fun sep ->
|
5283
|
fun x ->
|
5284
|
if sep then Format.fprintf fmt ";@ ";
|
5285
|
((__1 ()) fmt) x;
|
5286
|
true) false x);
|
5287
|
Format.fprintf fmt "@,@]")) x.shared_defs;
|
5288
|
Format.fprintf fmt "@]");
|
5289
|
Format.fprintf fmt "@]")
|
5290
|
[@ocaml.warning "-A"])
|
5291
|
|
5292
|
and show_vhdl_package_t : vhdl_package_t -> Ppx_deriving_runtime.string =
|
5293
|
fun x -> Format.asprintf "%a" pp_vhdl_package_t x
|
5294
|
|
5295
|
let rec (vhdl_package_t_to_yojson : vhdl_package_t -> Yojson.Safe.json) =
|
5296
|
((let open! Ppx_deriving_yojson_runtime in
|
5297
|
fun x ->
|
5298
|
let fields = [] in
|
5299
|
let fields =
|
5300
|
if x.shared_defs = []
|
5301
|
then fields
|
5302
|
else
|
5303
|
("shared_defs",
|
5304
|
(((fun x ->
|
5305
|
`List
|
5306
|
(List.map (fun x -> vhdl_definition_t_to_yojson x) x)))
|
5307
|
x.shared_defs))
|
5308
|
:: fields
|
5309
|
in
|
5310
|
let fields =
|
5311
|
if x.name = NoName
|
5312
|
then fields
|
5313
|
else ("name", (((fun x -> vhdl_name_t_to_yojson x)) x.name)) ::
|
5314
|
fields
|
5315
|
in
|
5316
|
`Assoc fields)
|
5317
|
[@ocaml.warning "-A"])
|
5318
|
|
5319
|
and (vhdl_package_t_of_yojson :
|
5320
|
Yojson.Safe.json -> vhdl_package_t Ppx_deriving_yojson_runtime.error_or)
|
5321
|
=
|
5322
|
((let open! Ppx_deriving_yojson_runtime in
|
5323
|
function
|
5324
|
| `Assoc xs ->
|
5325
|
let rec loop xs ((arg0,arg1) as _state) =
|
5326
|
match xs with
|
5327
|
| ("name",x)::xs ->
|
5328
|
loop xs (((fun x -> vhdl_name_t_of_yojson x) x), arg1)
|
5329
|
| ("shared_defs",x)::xs ->
|
5330
|
loop xs
|
5331
|
(arg0,
|
5332
|
((function
|
5333
|
| `List xs ->
|
5334
|
map_bind (fun x -> vhdl_definition_t_of_yojson x)
|
5335
|
[] xs
|
5336
|
| _ ->
|
5337
|
Result.Error "Vhdl_ast.vhdl_package_t.shared_defs")
|
5338
|
x))
|
5339
|
| [] ->
|
5340
|
arg1 >>=
|
5341
|
((fun arg1 ->
|
5342
|
arg0 >>=
|
5343
|
(fun arg0 ->
|
5344
|
Result.Ok { name = arg0; shared_defs = arg1 })))
|
5345
|
| _::xs -> loop xs _state in
|
5346
|
loop xs ((Result.Ok NoName), (Result.Ok []))
|
5347
|
| _ -> Result.Error "Vhdl_ast.vhdl_package_t")
|
5348
|
[@ocaml.warning "-A"])
|
5349
|
|
5350
|
type vhdl_load_t =
|
5351
|
| Library of vhdl_name_t list [@name "LIBRARY_CLAUSE"][@default []]
|
5352
|
| Use of vhdl_name_t list [@name "USE_CLAUSE"][@default []]
|
5353
|
|
5354
|
(* Adapted *)
|
5355
|
let rec pp_vhdl_load_t :
|
5356
|
Format.formatter -> vhdl_load_t -> Ppx_deriving_runtime.unit =
|
5357
|
let __1 () = pp_vhdl_name_t
|
5358
|
|
5359
|
and __0 () = pp_vhdl_name_t
|
5360
|
in
|
5361
|
((let open! Ppx_deriving_runtime in
|
5362
|
fun fmt ->
|
5363
|
function
|
5364
|
| Library a0 ->
|
5365
|
(Format.fprintf fmt "@[<2>library@ ";
|
5366
|
((fun x ->
|
5367
|
Format.fprintf fmt "@[<2>";
|
5368
|
ignore
|
5369
|
(List.fold_left
|
5370
|
(fun sep ->
|
5371
|
fun x ->
|
5372
|
if sep then Format.fprintf fmt ".";
|
5373
|
((__0 ()) fmt) x;
|
5374
|
true) false x);
|
5375
|
Format.fprintf fmt "@,@]")) a0;
|
5376
|
Format.fprintf fmt "@]:")
|
5377
|
| Use a0 ->
|
5378
|
(Format.fprintf fmt "@[<2>use@ ";
|
5379
|
((fun x ->
|
5380
|
Format.fprintf fmt "@[<2>";
|
5381
|
ignore
|
5382
|
(List.fold_left
|
5383
|
(fun sep ->
|
5384
|
fun x ->
|
5385
|
if sep then Format.fprintf fmt ".";
|
5386
|
((__1 ()) fmt) x;
|
5387
|
true) false x);
|
5388
|
Format.fprintf fmt "@,@]")) a0;
|
5389
|
Format.fprintf fmt "@];"))
|
5390
|
[@ocaml.warning "-A"])
|
5391
|
|
5392
|
and show_vhdl_load_t : vhdl_load_t -> Ppx_deriving_runtime.string =
|
5393
|
fun x -> Format.asprintf "%a" pp_vhdl_load_t x
|
5394
|
|
5395
|
let rec (vhdl_load_t_to_yojson : vhdl_load_t -> Yojson.Safe.json) =
|
5396
|
((let open! Ppx_deriving_yojson_runtime in
|
5397
|
function
|
5398
|
| Library arg0 ->
|
5399
|
`List
|
5400
|
[`String "LIBRARY_CLAUSE";
|
5401
|
((fun x ->
|
5402
|
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x))) arg0]
|
5403
|
| Use arg0 ->
|
5404
|
`List
|
5405
|
[`String "USE_CLAUSE";
|
5406
|
((fun x ->
|
5407
|
`List (List.map (fun x -> vhdl_name_t_to_yojson x) x))) arg0])
|
5408
|
[@ocaml.warning "-A"])
|
5409
|
|
5410
|
and (vhdl_load_t_of_yojson :
|
5411
|
Yojson.Safe.json -> vhdl_load_t Ppx_deriving_yojson_runtime.error_or)
|
5412
|
=
|
5413
|
((let open! Ppx_deriving_yojson_runtime in
|
5414
|
function
|
5415
|
| `List ((`String "LIBRARY_CLAUSE")::arg0::[]) ->
|
5416
|
((function
|
5417
|
| `List xs -> map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs
|
5418
|
| _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
|
5419
|
((fun arg0 -> Result.Ok (Library arg0)))
|
5420
|
| `List ((`String "USE_CLAUSE")::arg0::[]) ->
|
5421
|
((function
|
5422
|
| `List xs -> map_bind (fun x -> vhdl_name_t_of_yojson x) [] xs
|
5423
|
| _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
|
5424
|
((fun arg0 -> Result.Ok (Use arg0)))
|
5425
|
| _ -> Result.Error "Vhdl_ast.vhdl_load_t")
|
5426
|
[@ocaml.warning "-A"])
|
5427
|
|
5428
|
type vhdl_architecture_t =
|
5429
|
{
|
5430
|
name: vhdl_name_t [@default NoName];
|
5431
|
entity: vhdl_name_t [@default NoName];
|
5432
|
declarations: vhdl_declaration_t list
|
5433
|
[@key "ARCHITECTURE_DECLARATIVE_PART"][@default []];
|
5434
|
body: vhdl_concurrent_stmt_t list
|
5435
|
[@key "ARCHITECTURE_STATEMENT_PART"][@default []]}
|
5436
|
|
5437
|
(* Adapted *)
|
5438
|
let rec pp_vhdl_architecture_t :
|
5439
|
Format.formatter -> vhdl_architecture_t -> Ppx_deriving_runtime.unit =
|
5440
|
let __3 () = pp_vhdl_concurrent_stmt_t
|
5441
|
|
5442
|
and __2 () = pp_vhdl_declaration_t
|
5443
|
|
5444
|
and __1 () = pp_vhdl_name_t
|
5445
|
|
5446
|
and __0 () = pp_vhdl_name_t
|
5447
|
in
|
5448
|
((let open! Ppx_deriving_runtime in
|
5449
|
fun fmt ->
|
5450
|
fun x ->
|
5451
|
((((
|
5452
|
((__0 ()) fmt) x.name;
|
5453
|
);
|
5454
|
Format.fprintf fmt " of ";
|
5455
|
((__1 ()) fmt) x.entity;
|
5456
|
);
|
5457
|
Format.fprintf fmt " is @ ";
|
5458
|
Format.fprintf fmt "@[<v>";
|
5459
|
((fun x ->
|
5460
|
Format.fprintf fmt "@[";
|
5461
|
ignore
|
5462
|
(List.fold_left
|
5463
|
(fun sep ->
|
5464
|
fun x ->
|
5465
|
if sep then Format.fprintf fmt "@ ";
|
5466
|
((__2 ()) fmt) x;
|
5467
|
Format.fprintf fmt ";";
|
5468
|
true) false x);
|
5469
|
Format.fprintf fmt "@]")) x.declarations;
|
5470
|
Format.fprintf fmt "@]");
|
5471
|
Format.fprintf fmt "@ ";
|
5472
|
Format.fprintf fmt "@[<v>";
|
5473
|
(match x.body with
|
5474
|
| [] -> Format.fprintf fmt "";
|
5475
|
| _ -> Format.fprintf fmt "begin@ @[<2>";
|
5476
|
((fun x ->
|
5477
|
Format.fprintf fmt "@[";
|
5478
|
ignore
|
5479
|
(List.fold_left
|
5480
|
(fun sep ->
|
5481
|
fun x ->
|
5482
|
if sep then Format.fprintf fmt "@ ";
|
5483
|
((__3 ()) fmt) x;
|
5484
|
true) false x);
|
5485
|
Format.fprintf fmt "@]")) x.body;
|
5486
|
Format.fprintf fmt "@]");
|
5487
|
Format.fprintf fmt "@]");
|
5488
|
Format.fprintf fmt "@ ")
|
5489
|
[@ocaml.warning "-A"])
|
5490
|
|
5491
|
and show_vhdl_architecture_t :
|
5492
|
vhdl_architecture_t -> Ppx_deriving_runtime.string =
|
5493
|
fun x -> Format.asprintf "%a" pp_vhdl_architecture_t x
|
5494
|
|
5495
|
let rec (vhdl_architecture_t_to_yojson :
|
5496
|
vhdl_architecture_t -> Yojson.Safe.json)
|
5497
|
=
|
5498
|
((let open! Ppx_deriving_yojson_runtime in
|
5499
|
fun x ->
|
5500
|
let fields = [] in
|
5501
|
let fields =
|
5502
|
if x.body = []
|
5503
|
then fields
|
5504
|
else
|
5505
|
("ARCHITECTURE_STATEMENT_PART",
|
5506
|
(((fun x ->
|
5507
|
`List
|
5508
|
(List.map (fun x -> vhdl_concurrent_stmt_t_to_yojson x)
|
5509
|
x))) x.body))
|
5510
|
:: fields
|
5511
|
in
|
5512
|
let fields =
|
5513
|
if x.declarations = []
|
5514
|
then fields
|
5515
|
else
|
5516
|
("ARCHITECTURE_DECLARATIVE_PART",
|
5517
|
(((fun x ->
|
5518
|
`List
|
5519
|
(List.map (fun x -> vhdl_declaration_t_to_yojson x) x)))
|
5520
|
x.declarations))
|
5521
|
:: fields
|
5522
|
in
|
5523
|
let fields =
|
5524
|
if x.entity = NoName
|
5525
|
then fields
|
5526
|
else ("entity", (((fun x -> vhdl_name_t_to_yojson x)) x.entity))
|
5527
|
:: fields
|
5528
|
in
|
5529
|
let fields =
|
5530
|
if x.name = NoName
|
5531
|
then fields
|
5532
|
else ("name", (((fun x -> vhdl_name_t_to_yojson x)) x.name)) ::
|
5533
|
fields
|
5534
|
in
|
5535
|
`Assoc fields)
|
5536
|
[@ocaml.warning "-A"])
|
5537
|
|
5538
|
and (vhdl_architecture_t_of_yojson :
|
5539
|
Yojson.Safe.json ->
|
5540
|
vhdl_architecture_t Ppx_deriving_yojson_runtime.error_or)
|
5541
|
=
|
5542
|
((let open! Ppx_deriving_yojson_runtime in
|
5543
|
function
|
5544
|
| `Assoc xs ->
|
5545
|
let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
|
5546
|
match xs with
|
5547
|
| ("name",x)::xs ->
|
5548
|
loop xs
|
5549
|
(((fun x -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3)
|
5550
|
| ("entity",x)::xs ->
|
5551
|
loop xs
|
5552
|
(arg0, ((fun x -> vhdl_name_t_of_yojson x) x), arg2, arg3)
|
5553
|
| ("ARCHITECTURE_DECLARATIVE_PART",x)::xs ->
|
5554
|
loop xs
|
5555
|
(arg0, arg1,
|
5556
|
((function
|
5557
|
| `List xs ->
|
5558
|
map_bind (fun x -> vhdl_declaration_t_of_yojson x)
|
5559
|
[] xs
|
5560
|
| _ ->
|
5561
|
Result.Error
|
5562
|
"Vhdl_ast.vhdl_architecture_t.declarations") x),
|
5563
|
arg3)
|
5564
|
| ("ARCHITECTURE_STATEMENT_PART",x)::xs ->
|
5565
|
loop xs
|
5566
|
(arg0, arg1, arg2,
|
5567
|
((function
|
5568
|
| `List xs ->
|
5569
|
map_bind
|
5570
|
(fun x -> vhdl_concurrent_stmt_t_of_yojson x) []
|
5571
|
xs
|
5572
|
| _ -> Result.Error "Vhdl_ast.vhdl_architecture_t.body")
|
5573
|
x))
|
5574
|
| [] ->
|
5575
|
arg3 >>=
|
5576
|
((fun arg3 ->
|
5577
|
arg2 >>=
|
5578
|
(fun arg2 ->
|
5579
|
arg1 >>=
|
5580
|
(fun arg1 ->
|
5581
|
arg0 >>=
|
5582
|
(fun arg0 ->
|
5583
|
Result.Ok
|
5584
|
{
|
5585
|
name = arg0;
|
5586
|
entity = arg1;
|
5587
|
declarations = arg2;
|
5588
|
body = arg3
|
5589
|
})))))
|
5590
|
| _::xs -> loop xs _state in
|
5591
|
loop xs
|
5592
|
((Result.Ok NoName), (Result.Ok NoName), (Result.Ok []),
|
5593
|
(Result.Ok []))
|
5594
|
| _ -> Result.Error "Vhdl_ast.vhdl_architecture_t")
|
5595
|
[@ocaml.warning "-A"])
|
5596
|
|
5597
|
type vhdl_configuration_t = unit
|
5598
|
|
5599
|
let rec (pp_vhdl_configuration_t :
|
5600
|
Format.formatter ->
|
5601
|
vhdl_configuration_t -> Ppx_deriving_runtime.unit)
|
5602
|
=
|
5603
|
((let open! Ppx_deriving_runtime in
|
5604
|
fun fmt -> fun () -> Format.pp_print_string fmt "()")
|
5605
|
[@ocaml.warning "-A"])
|
5606
|
|
5607
|
and show_vhdl_configuration_t :
|
5608
|
vhdl_configuration_t -> Ppx_deriving_runtime.string =
|
5609
|
fun x -> Format.asprintf "%a" pp_vhdl_configuration_t x
|
5610
|
|
5611
|
let rec (vhdl_configuration_t_to_yojson :
|
5612
|
vhdl_configuration_t -> Yojson.Safe.json)
|
5613
|
=
|
5614
|
((let open! Ppx_deriving_yojson_runtime in
|
5615
|
fun (x : Ppx_deriving_runtime.unit) -> `Null)
|
5616
|
[@ocaml.warning "-A"])
|
5617
|
|
5618
|
and (vhdl_configuration_t_of_yojson :
|
5619
|
Yojson.Safe.json ->
|
5620
|
vhdl_configuration_t Ppx_deriving_yojson_runtime.error_or)
|
5621
|
=
|
5622
|
((let open! Ppx_deriving_yojson_runtime in
|
5623
|
function
|
5624
|
| `Null -> Result.Ok ()
|
5625
|
| _ -> Result.Error "Vhdl_ast.vhdl_configuration_t")
|
5626
|
[@ocaml.warning "-A"])
|
5627
|
|
5628
|
type vhdl_library_unit_t =
|
5629
|
| Package of vhdl_package_t [@name "PACKAGE_DECLARATION"]
|
5630
|
| Entities of vhdl_entity_t [@name "ENTITY_DECLARATION"]
|
5631
|
| Architecture of vhdl_architecture_t [@name "ARCHITECTURE_BODY"]
|
5632
|
| Configuration of vhdl_configuration_t [@name "CONFIGURATION_DECLARATION"]
|
5633
|
|
5634
|
(* Adapted *)
|
5635
|
let rec pp_vhdl_library_unit_t :
|
5636
|
Format.formatter -> vhdl_library_unit_t -> Ppx_deriving_runtime.unit =
|
5637
|
let __3 () = pp_vhdl_configuration_t
|
5638
|
|
5639
|
and __2 () = pp_vhdl_architecture_t
|
5640
|
|
5641
|
and __1 () = pp_vhdl_entity_t
|
5642
|
|
5643
|
and __0 () = pp_vhdl_package_t
|
5644
|
in
|
5645
|
((let open! Ppx_deriving_runtime in
|
5646
|
fun fmt ->
|
5647
|
function
|
5648
|
| Package a0 ->
|
5649
|
(Format.fprintf fmt "@[<2>package ";
|
5650
|
((__0 ()) fmt) a0;
|
5651
|
Format.fprintf fmt "@.end;")
|
5652
|
| Entities a0 ->
|
5653
|
(Format.fprintf fmt "@[<2>entity ";
|
5654
|
((__1 ()) fmt) a0;
|
5655
|
Format.fprintf fmt "@.end;")
|
5656
|
| Architecture a0 ->
|
5657
|
(Format.fprintf fmt "@[<2>architecture ";
|
5658
|
((__2 ()) fmt) a0;
|
5659
|
Format.fprintf fmt "@.end;")
|
5660
|
| Configuration a0 ->
|
5661
|
(Format.fprintf fmt "@[<2>configuration ";
|
5662
|
((__3 ()) fmt) a0;
|
5663
|
Format.fprintf fmt "@.end;"))
|
5664
|
[@ocaml.warning "-A"])
|
5665
|
|
5666
|
and show_vhdl_library_unit_t :
|
5667
|
vhdl_library_unit_t -> Ppx_deriving_runtime.string =
|
5668
|
fun x -> Format.asprintf "%a" pp_vhdl_library_unit_t x
|
5669
|
|
5670
|
let rec (vhdl_library_unit_t_to_yojson :
|
5671
|
vhdl_library_unit_t -> Yojson.Safe.json)
|
5672
|
=
|
5673
|
((let open! Ppx_deriving_yojson_runtime in
|
5674
|
function
|
5675
|
| Package arg0 ->
|
5676
|
`List
|
5677
|
[`String "PACKAGE_DECLARATION";
|
5678
|
((fun x -> vhdl_package_t_to_yojson x)) arg0]
|
5679
|
| Entities arg0 ->
|
5680
|
`List
|
5681
|
[`String "ENTITY_DECLARATION";
|
5682
|
((fun x -> vhdl_entity_t_to_yojson x)) arg0]
|
5683
|
| Architecture arg0 ->
|
5684
|
`List
|
5685
|
[`String "ARCHITECTURE_BODY";
|
5686
|
((fun x -> vhdl_architecture_t_to_yojson x)) arg0]
|
5687
|
| Configuration arg0 ->
|
5688
|
`List
|
5689
|
[`String "CONFIGURATION_DECLARATION";
|
5690
|
((fun x -> vhdl_configuration_t_to_yojson x)) arg0])
|
5691
|
[@ocaml.warning "-A"])
|
5692
|
|
5693
|
and (vhdl_library_unit_t_of_yojson :
|
5694
|
Yojson.Safe.json ->
|
5695
|
vhdl_library_unit_t Ppx_deriving_yojson_runtime.error_or)
|
5696
|
=
|
5697
|
((let open! Ppx_deriving_yojson_runtime in
|
5698
|
function
|
5699
|
| `List ((`String "PACKAGE_DECLARATION")::arg0::[]) ->
|
5700
|
((fun x -> vhdl_package_t_of_yojson x) arg0) >>=
|
5701
|
((fun arg0 -> Result.Ok (Package arg0)))
|
5702
|
| `List ((`String "ENTITY_DECLARATION")::arg0::[]) ->
|
5703
|
((fun x -> vhdl_entity_t_of_yojson x) arg0) >>=
|
5704
|
((fun arg0 -> Result.Ok (Entities arg0)))
|
5705
|
| `List ((`String "ARCHITECTURE_BODY")::arg0::[]) ->
|
5706
|
((fun x -> vhdl_architecture_t_of_yojson x) arg0) >>=
|
5707
|
((fun arg0 -> Result.Ok (Architecture arg0)))
|
5708
|
| `List ((`String "CONFIGURATION_DECLARATION")::arg0::[]) ->
|
5709
|
((fun x -> vhdl_configuration_t_of_yojson x) arg0) >>=
|
5710
|
((fun arg0 -> Result.Ok (Configuration arg0)))
|
5711
|
| _ -> Result.Error "Vhdl_ast.vhdl_library_unit_t")
|
5712
|
[@ocaml.warning "-A"])
|
5713
|
|
5714
|
type vhdl_design_unit_t =
|
5715
|
{
|
5716
|
contexts: vhdl_load_t list [@default []];
|
5717
|
library: vhdl_library_unit_t }
|
5718
|
|
5719
|
(* Adapted *)
|
5720
|
let rec pp_vhdl_design_unit_t :
|
5721
|
Format.formatter -> vhdl_design_unit_t -> Ppx_deriving_runtime.unit =
|
5722
|
let __1 () = pp_vhdl_library_unit_t
|
5723
|
|
5724
|
and __0 () = pp_vhdl_load_t
|
5725
|
in
|
5726
|
((let open! Ppx_deriving_runtime in
|
5727
|
fun fmt ->
|
5728
|
fun x ->
|
5729
|
((
|
5730
|
Format.fprintf fmt "@[<v>";
|
5731
|
((fun x ->
|
5732
|
ignore
|
5733
|
(List.fold_left
|
5734
|
(fun sep ->
|
5735
|
fun x ->
|
5736
|
if sep then Format.fprintf fmt "@ ";
|
5737
|
((__0 ()) fmt) x;
|
5738
|
true) false x);
|
5739
|
)) x.contexts;
|
5740
|
Format.fprintf fmt "@ ";
|
5741
|
Format.fprintf fmt "@[";
|
5742
|
((__1 ()) fmt) x.library;
|
5743
|
Format.fprintf fmt "@]";
|
5744
|
Format.fprintf fmt "@]";
|
5745
|
))
|
5746
|
)
|
5747
|
[@ocaml.warning "-A"])
|
5748
|
|
5749
|
and show_vhdl_design_unit_t :
|
5750
|
vhdl_design_unit_t -> Ppx_deriving_runtime.string =
|
5751
|
fun x -> Format.asprintf "%a" pp_vhdl_design_unit_t x
|
5752
|
|
5753
|
let rec (vhdl_design_unit_t_to_yojson :
|
5754
|
vhdl_design_unit_t -> Yojson.Safe.json)
|
5755
|
=
|
5756
|
((let open! Ppx_deriving_yojson_runtime in
|
5757
|
fun x ->
|
5758
|
let fields = [] in
|
5759
|
let fields =
|
5760
|
("library",
|
5761
|
((fun x -> vhdl_library_unit_t_to_yojson x) x.library))
|
5762
|
:: fields in
|
5763
|
let fields =
|
5764
|
if x.contexts = []
|
5765
|
then fields
|
5766
|
else
|
5767
|
("contexts",
|
5768
|
(((fun x ->
|
5769
|
`List (List.map (fun x -> vhdl_load_t_to_yojson x) x)))
|
5770
|
x.contexts))
|
5771
|
:: fields
|
5772
|
in
|
5773
|
`Assoc fields)
|
5774
|
[@ocaml.warning "-A"])
|
5775
|
|
5776
|
and (vhdl_design_unit_t_of_yojson :
|
5777
|
Yojson.Safe.json ->
|
5778
|
vhdl_design_unit_t Ppx_deriving_yojson_runtime.error_or)
|
5779
|
=
|
5780
|
((let open! Ppx_deriving_yojson_runtime in
|
5781
|
function
|
5782
|
| `Assoc xs ->
|
5783
|
let rec loop xs ((arg0,arg1) as _state) =
|
5784
|
match xs with
|
5785
|
| ("contexts",x)::xs ->
|
5786
|
loop xs
|
5787
|
(((function
|
5788
|
| `List xs ->
|
5789
|
map_bind (fun x -> vhdl_load_t_of_yojson x) [] xs
|
5790
|
| _ ->
|
5791
|
Result.Error "Vhdl_ast.vhdl_design_unit_t.contexts")
|
5792
|
x), arg1)
|
5793
|
| ("library",x)::xs ->
|
5794
|
loop xs
|
5795
|
(arg0, ((fun x -> vhdl_library_unit_t_of_yojson x) x))
|
5796
|
| [] ->
|
5797
|
arg1 >>=
|
5798
|
((fun arg1 ->
|
5799
|
arg0 >>=
|
5800
|
(fun arg0 ->
|
5801
|
Result.Ok { contexts = arg0; library = arg1 })))
|
5802
|
| _::xs -> loop xs _state in
|
5803
|
loop xs
|
5804
|
((Result.Ok []),
|
5805
|
(Result.Error "Vhdl_ast.vhdl_design_unit_t.library"))
|
5806
|
| _ -> Result.Error "Vhdl_ast.vhdl_design_unit_t")
|
5807
|
[@ocaml.warning "-A"])
|
5808
|
|
5809
|
type vhdl_design_file_t =
|
5810
|
{
|
5811
|
design_units: vhdl_design_unit_t list [@default []]}
|
5812
|
|
5813
|
(* Adapted *)
|
5814
|
let rec pp_vhdl_design_file_t :
|
5815
|
Format.formatter -> vhdl_design_file_t -> Ppx_deriving_runtime.unit =
|
5816
|
let __0 () = pp_vhdl_design_unit_t in
|
5817
|
((let open! Ppx_deriving_runtime in
|
5818
|
fun fmt ->
|
5819
|
fun x ->
|
5820
|
((fun x ->
|
5821
|
ignore
|
5822
|
(List.fold_left
|
5823
|
(fun sep ->
|
5824
|
fun x ->
|
5825
|
if sep then Format.fprintf fmt "@ ";
|
5826
|
((__0 ()) fmt) x;
|
5827
|
true) false x);
|
5828
|
)) x.design_units;
|
5829
|
)
|
5830
|
[@ocaml.warning "-A"])
|
5831
|
|
5832
|
and show_vhdl_design_file_t :
|
5833
|
vhdl_design_file_t -> Ppx_deriving_runtime.string =
|
5834
|
fun x -> Format.asprintf "%a" pp_vhdl_design_file_t x
|
5835
|
|
5836
|
let rec (vhdl_design_file_t_to_yojson :
|
5837
|
vhdl_design_file_t -> Yojson.Safe.json)
|
5838
|
=
|
5839
|
((let open! Ppx_deriving_yojson_runtime in
|
5840
|
fun x ->
|
5841
|
let fields = [] in
|
5842
|
let fields =
|
5843
|
if x.design_units = []
|
5844
|
then fields
|
5845
|
else
|
5846
|
("design_units",
|
5847
|
(((fun x ->
|
5848
|
`List
|
5849
|
(List.map (fun x -> vhdl_design_unit_t_to_yojson x) x)))
|
5850
|
x.design_units))
|
5851
|
:: fields
|
5852
|
in
|
5853
|
`Assoc fields)
|
5854
|
[@ocaml.warning "-A"])
|
5855
|
|
5856
|
and (vhdl_design_file_t_of_yojson :
|
5857
|
Yojson.Safe.json ->
|
5858
|
vhdl_design_file_t Ppx_deriving_yojson_runtime.error_or)
|
5859
|
=
|
5860
|
((let open! Ppx_deriving_yojson_runtime in
|
5861
|
function
|
5862
|
| `Assoc xs ->
|
5863
|
let rec loop xs (arg0 as _state) =
|
5864
|
match xs with
|
5865
|
| ("design_units",x)::xs ->
|
5866
|
loop xs
|
5867
|
((function
|
5868
|
| `List xs ->
|
5869
|
map_bind (fun x -> vhdl_design_unit_t_of_yojson x)
|
5870
|
[] xs
|
5871
|
| _ ->
|
5872
|
Result.Error
|
5873
|
"Vhdl_ast.vhdl_design_file_t.design_units") x)
|
5874
|
| [] ->
|
5875
|
arg0 >>= ((fun arg0 -> Result.Ok { design_units = arg0 }))
|
5876
|
| _::xs -> loop xs _state in
|
5877
|
loop xs (Result.Ok [])
|
5878
|
| _ -> Result.Error "Vhdl_ast.vhdl_design_file_t")
|
5879
|
[@ocaml.warning "-A"])
|
5880
|
|
5881
|
type vhdl_file_t =
|
5882
|
{
|
5883
|
design_file: vhdl_design_file_t
|
5884
|
[@default { design_units = [] }][@key "DESIGN_FILE"]}
|
5885
|
|
5886
|
(* Adapted *)
|
5887
|
let rec pp_vhdl_file_t :
|
5888
|
Format.formatter -> vhdl_file_t -> Ppx_deriving_runtime.unit =
|
5889
|
let __0 () = pp_vhdl_design_file_t in
|
5890
|
((let open! Ppx_deriving_runtime in
|
5891
|
fun fmt ->
|
5892
|
fun x ->
|
5893
|
((__0 ()) fmt) x.design_file;
|
5894
|
)
|
5895
|
[@ocaml.warning "-A"])
|
5896
|
|
5897
|
and show_vhdl_file_t : vhdl_file_t -> Ppx_deriving_runtime.string =
|
5898
|
fun x -> Format.asprintf "%a" pp_vhdl_file_t x
|
5899
|
|
5900
|
let rec (vhdl_file_t_to_yojson : vhdl_file_t -> Yojson.Safe.json) =
|
5901
|
((let open! Ppx_deriving_yojson_runtime in
|
5902
|
fun x ->
|
5903
|
let fields = [] in
|
5904
|
let fields =
|
5905
|
if x.design_file = { design_units = [] }
|
5906
|
then fields
|
5907
|
else
|
5908
|
("DESIGN_FILE",
|
5909
|
(((fun x -> vhdl_design_file_t_to_yojson x)) x.design_file))
|
5910
|
:: fields
|
5911
|
in
|
5912
|
`Assoc fields)
|
5913
|
[@ocaml.warning "-A"])
|
5914
|
|
5915
|
and (vhdl_file_t_of_yojson :
|
5916
|
Yojson.Safe.json -> vhdl_file_t Ppx_deriving_yojson_runtime.error_or)
|
5917
|
=
|
5918
|
((let open! Ppx_deriving_yojson_runtime in
|
5919
|
function
|
5920
|
| `Assoc xs ->
|
5921
|
let rec loop xs (arg0 as _state) =
|
5922
|
match xs with
|
5923
|
| ("DESIGN_FILE",x)::xs ->
|
5924
|
loop xs ((fun x -> vhdl_design_file_t_of_yojson x) x)
|
5925
|
| [] ->
|
5926
|
arg0 >>= ((fun arg0 -> Result.Ok { design_file = arg0 }))
|
5927
|
| _::xs -> Result.Error "Vhdl_ast.vhdl_file_t" in
|
5928
|
loop xs (Result.Ok { design_units = [] })
|
5929
|
| _ -> Result.Error "Vhdl_ast.vhdl_file_t")
|
5930
|
[@ocaml.warning "-A"])
|