Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / backends / VHDL / vhdl_ast_deriving.ml @ f779d524

History | View | Annotate | Download (217 KB)

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 Some NoName];
157
  formal_arg: vhdl_name_t option [@default Some NoName];
158
  actual_name: vhdl_name_t option [@default Some NoName];
159
  actual_designator: vhdl_name_t option [@default Some NoName];
160
  actual_expr: vhdl_expr_t option [@default Some IsNull]}
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
(* Missing adaptation for : Function *)
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
            (Format.fprintf fmt "@[<2>Function {@,";
544
             ((Format.fprintf fmt "@[%s =@ " "id";
545
               ((__8 ()) fmt) aid;
546
               Format.fprintf fmt "@]");
547
              Format.fprintf fmt ";@ ";
548
              Format.fprintf fmt "@[%s =@ " "assoc_list";
549
              ((fun x  ->
550
                  Format.fprintf fmt "@[<2>[";
551
                  ignore
552
                    (List.fold_left
553
                       (fun sep  ->
554
                          fun x  ->
555
                            if sep then Format.fprintf fmt ";@ ";
556
                            ((__9 ()) fmt) x;
557
                            true) false x);
558
                  Format.fprintf fmt "@,]@]")) aassoc_list;
559
              Format.fprintf fmt "@]");
560
             Format.fprintf fmt "@]}")
561
        | NoName  -> Format.pp_print_string fmt "")
562
    [@ocaml.warning "-A"])
563

    
564
and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string =
565
  fun x  -> Format.asprintf "%a" pp_vhdl_name_t x
566

    
567
and pp_vhdl_assoc_element_t :
568
  Format.formatter -> vhdl_assoc_element_t -> Ppx_deriving_runtime.unit =
569
  let __4 () = pp_vhdl_expr_t
570
  
571
  and __3 () = pp_vhdl_name_t
572
  
573
  and __2 () = pp_vhdl_name_t
574
  
575
  and __1 () = pp_vhdl_name_t
576
  
577
  and __0 () = pp_vhdl_name_t
578
   in
579
  ((let open! Ppx_deriving_runtime in
580
      fun fmt  ->
581
        fun x  ->
582
          Format.fprintf fmt "@[<2>{ ";
583
          (((((Format.fprintf fmt "@[%s =@ " "formal_name";
584
               ((function
585
                 | None  -> Format.pp_print_string fmt "None"
586
                 | Some x ->
587
                     (Format.pp_print_string fmt "(Some ";
588
                      ((__0 ()) fmt) x;
589
                      Format.pp_print_string fmt ")"))) x.formal_name;
590
               Format.fprintf fmt "@]");
591
              Format.fprintf fmt ";@ ";
592
              Format.fprintf fmt "@[%s =@ " "formal_arg";
593
              ((function
594
                | None  -> Format.pp_print_string fmt "None"
595
                | Some x ->
596
                    (Format.pp_print_string fmt "(Some ";
597
                     ((__1 ()) fmt) x;
598
                     Format.pp_print_string fmt ")"))) x.formal_arg;
599
              Format.fprintf fmt "@]");
600
             Format.fprintf fmt ";@ ";
601
             Format.fprintf fmt "@[%s =@ " "actual_name";
602
             ((function
603
               | None  -> Format.pp_print_string fmt "None"
604
               | Some x ->
605
                   (Format.pp_print_string fmt "(Some ";
606
                    ((__2 ()) fmt) x;
607
                    Format.pp_print_string fmt ")"))) x.actual_name;
608
             Format.fprintf fmt "@]");
609
            Format.fprintf fmt ";@ ";
610
            Format.fprintf fmt "@[%s =@ " "actual_designator";
611
            ((function
612
              | None  -> Format.pp_print_string fmt "None"
613
              | Some x ->
614
                  (Format.pp_print_string fmt "(Some ";
615
                   ((__3 ()) fmt) x;
616
                   Format.pp_print_string fmt ")"))) x.actual_designator;
617
            Format.fprintf fmt "@]");
618
           Format.fprintf fmt ";@ ";
619
           Format.fprintf fmt "@[%s =@ " "actual_expr";
620
           ((function
621
             | None  -> Format.pp_print_string fmt "None"
622
             | Some x ->
623
                 (Format.pp_print_string fmt "(Some ";
624
                  ((__4 ()) fmt) x;
625
                  Format.pp_print_string fmt ")"))) x.actual_expr;
626
           Format.fprintf fmt "@]");
627
          Format.fprintf fmt "@ }@]")
628
    [@ocaml.warning "-A"])
629

    
630
and show_vhdl_assoc_element_t :
631
  vhdl_assoc_element_t -> Ppx_deriving_runtime.string =
632
  fun x  -> Format.asprintf "%a" pp_vhdl_assoc_element_t x
633

    
634
and pp_vhdl_element_assoc_t :
635
  Format.formatter -> vhdl_element_assoc_t -> Ppx_deriving_runtime.unit =
636
  let __1 () = pp_vhdl_expr_t
637
  
638
  and __0 () = pp_vhdl_expr_t
639
   in
640
  ((let open! Ppx_deriving_runtime in
641
      fun fmt  ->
642
        fun x  ->
643
          Format.fprintf fmt "@[<2>{ ";
644
          ((Format.fprintf fmt "@[%s =@ " "choices";
645
            ((fun x  ->
646
                Format.fprintf fmt "@[<2>[";
647
                ignore
648
                  (List.fold_left
649
                     (fun sep  ->
650
                        fun x  ->
651
                          if sep then Format.fprintf fmt ";@ ";
652
                          ((__0 ()) fmt) x;
653
                          true) false x);
654
                Format.fprintf fmt "@,]@]")) x.choices;
655
            Format.fprintf fmt "@]");
656
           Format.fprintf fmt ";@ ";
657
           Format.fprintf fmt "@[%s =@ " "expr";
658
           ((__1 ()) fmt) x.expr;
659
           Format.fprintf fmt "@]");
660
          Format.fprintf fmt "@ }@]")
661
    [@ocaml.warning "-A"])
662

    
663
and show_vhdl_element_assoc_t :
664
  vhdl_element_assoc_t -> Ppx_deriving_runtime.string =
665
  fun x  -> Format.asprintf "%a" pp_vhdl_element_assoc_t x
666

    
667
and (pp_vhdl_array_attributes_t :
668
      Format.formatter ->
669
        vhdl_array_attributes_t -> Ppx_deriving_runtime.unit)
670
  =
671
  ((let open! Ppx_deriving_runtime in
672
      fun fmt  ->
673
        function
674
        | AAttInt { id = aid; arg = aarg } ->
675
            (Format.fprintf fmt "@[<2>AAttInt {@,";
676
             ((Format.fprintf fmt "@[%s =@ " "id";
677
               (Format.fprintf fmt "%S") aid;
678
               Format.fprintf fmt "@]");
679
              Format.fprintf fmt ";@ ";
680
              Format.fprintf fmt "@[%s =@ " "arg";
681
              (Format.fprintf fmt "%d") aarg;
682
              Format.fprintf fmt "@]");
683
             Format.fprintf fmt "@]}")
684
        | AAttAscending  -> Format.pp_print_string fmt "AAttAscending")
685
  [@ocaml.warning "-A"])
686

    
687
and show_vhdl_array_attributes_t :
688
  vhdl_array_attributes_t -> Ppx_deriving_runtime.string =
689
  fun x  -> Format.asprintf "%a" pp_vhdl_array_attributes_t x
690

    
691
and (pp_vhdl_signal_attributes_t :
692
      Format.formatter ->
693
        vhdl_signal_attributes_t -> Ppx_deriving_runtime.unit)
694
  =
695
  ((let open! Ppx_deriving_runtime in
696
      fun fmt  ->
697
        function
698
        | SigAtt a0 ->
699
            (Format.fprintf fmt "(@[<2>SigAtt@ ";
700
             (Format.fprintf fmt "%S") a0;
701
             Format.fprintf fmt "@])"))
702
  [@ocaml.warning "-A"])
703

    
704
and show_vhdl_signal_attributes_t :
705
  vhdl_signal_attributes_t -> Ppx_deriving_runtime.string =
706
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_attributes_t x
707

    
708
and (pp_vhdl_string_attributes_t :
709
      Format.formatter ->
710
        vhdl_string_attributes_t -> Ppx_deriving_runtime.unit)
711
  =
712
  ((let open! Ppx_deriving_runtime in
713
      fun fmt  ->
714
        function
715
        | StringAtt a0 ->
716
            (Format.fprintf fmt "(@[<2>StringAtt@ ";
717
             (Format.fprintf fmt "%S") a0;
718
             Format.fprintf fmt "@])"))
719
  [@ocaml.warning "-A"])
720

    
721
and show_vhdl_string_attributes_t :
722
  vhdl_string_attributes_t -> Ppx_deriving_runtime.string =
723
  fun x  -> Format.asprintf "%a" pp_vhdl_string_attributes_t x
724

    
725
and (pp_vhdl_suffix_selection_t :
726
      Format.formatter ->
727
        vhdl_suffix_selection_t -> Ppx_deriving_runtime.unit)
728
  =
729
  ((let open! Ppx_deriving_runtime in
730
      fun fmt  ->
731
        function
732
        | Idx a0 ->
733
            (Format.fprintf fmt "(@[<2>Idx@ ";
734
             (Format.fprintf fmt "%d") a0;
735
             Format.fprintf fmt "@])")
736
        | SuffixRange (a0,a1) ->
737
            (Format.fprintf fmt "(@[<2>SuffixRange (@,";
738
             ((Format.fprintf fmt "%d") a0;
739
              Format.fprintf fmt ",@ ";
740
              (Format.fprintf fmt "%d") a1);
741
             Format.fprintf fmt "@,))@]"))
742
  [@ocaml.warning "-A"])
743

    
744
and show_vhdl_suffix_selection_t :
745
  vhdl_suffix_selection_t -> Ppx_deriving_runtime.string =
746
  fun x  -> Format.asprintf "%a" pp_vhdl_suffix_selection_t x
747

    
748
let rec (vhdl_type_t_to_yojson : vhdl_type_t -> Yojson.Safe.json) =
749
  ((let open! Ppx_deriving_yojson_runtime in
750
      function
751
      | Base arg0 ->
752
          `List
753
            [`String "Base";
754
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
755
      | Range (arg0,arg1,arg2) ->
756
          `List
757
            [`String "Range";
758
            ((function
759
              | None  -> `Null
760
              | Some x ->
761
                  ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x))
762
              arg0;
763
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1;
764
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg2]
765
      | Bit_vector (arg0,arg1) ->
766
          `List
767
            [`String "Bit_vector";
768
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
769
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1]
770
      | Array (arg0,arg1,arg2) ->
771
          `List
772
            [`String "Array";
773
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
774
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1;
775
            ((fun x  -> vhdl_type_t_to_yojson x)) arg2]
776
      | Enumerated arg0 ->
777
          `List
778
            [`String "Enumerated";
779
            ((fun x  ->
780
                `List
781
                  (List.map
782
                     (fun (x : Ppx_deriving_runtime.string)  -> `String x) x)))
783
              arg0]
784
      | Void  -> `List [`String "Void"])
785
  [@ocaml.warning "-A"])
786

    
787
and (vhdl_type_t_of_yojson :
788
      Yojson.Safe.json -> vhdl_type_t Ppx_deriving_yojson_runtime.error_or)
789
  =
790
  ((let open! Ppx_deriving_yojson_runtime in
791
      function
792
      | `List ((`String "Base")::arg0::[]) ->
793
          ((function
794
            | `String x -> Result.Ok x
795
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
796
            ((fun arg0  -> Result.Ok (Base arg0)))
797
      | `List ((`String "Range")::arg0::arg1::arg2::[]) ->
798
          ((function
799
            | `Int x -> Result.Ok x
800
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg2) >>=
801
            ((fun arg2  ->
802
                ((function
803
                  | `Int x -> Result.Ok x
804
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
805
                  (fun arg1  ->
806
                     ((function
807
                       | `Null -> Result.Ok None
808
                       | x ->
809
                           ((function
810
                             | `String x -> Result.Ok x
811
                             | _ -> Result.Error "Vhdl_ast.vhdl_type_t") x)
812
                             >>= ((fun x  -> Result.Ok (Some x)))) arg0)
813
                       >>=
814
                       (fun arg0  -> Result.Ok (Range (arg0, arg1, arg2))))))
815
      | `List ((`String "Bit_vector")::arg0::arg1::[]) ->
816
          ((function
817
            | `Int x -> Result.Ok x
818
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
819
            ((fun arg1  ->
820
                ((function
821
                  | `Int x -> Result.Ok x
822
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
823
                  (fun arg0  -> Result.Ok (Bit_vector (arg0, arg1)))))
824
      | `List ((`String "Array")::arg0::arg1::arg2::[]) ->
825
          ((fun x  -> vhdl_type_t_of_yojson x) arg2) >>=
826
            ((fun arg2  ->
827
                ((function
828
                  | `Int x -> Result.Ok x
829
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
830
                  (fun arg1  ->
831
                     ((function
832
                       | `Int x -> Result.Ok x
833
                       | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
834
                       (fun arg0  -> Result.Ok (Array (arg0, arg1, arg2))))))
835
      | `List ((`String "Enumerated")::arg0::[]) ->
836
          ((function
837
            | `List xs ->
838
                map_bind
839
                  (function
840
                   | `String x -> Result.Ok x
841
                   | _ -> Result.Error "Vhdl_ast.vhdl_type_t") [] xs
842
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
843
            ((fun arg0  -> Result.Ok (Enumerated arg0)))
844
      | `List ((`String "Void")::[]) -> Result.Ok Void
845
      | _ -> Result.Error "Vhdl_ast.vhdl_type_t")
846
  [@ocaml.warning "-A"])
847

    
848
and (vhdl_subtype_indication_t_to_yojson :
849
      vhdl_subtype_indication_t -> Yojson.Safe.json)
850
  =
851
  ((let open! Ppx_deriving_yojson_runtime in
852
      fun x  ->
853
        let fields = []  in
854
        let fields =
855
          if x.const = NoConstraint
856
          then fields
857
          else
858
            ("const", (((fun x  -> vhdl_constraint_t_to_yojson x)) x.const))
859
            :: fields
860
           in
861
        let fields =
862
          if x.functionName = NoName
863
          then fields
864
          else
865
            ("functionName",
866
              (((fun x  -> vhdl_name_t_to_yojson x)) x.functionName))
867
            :: fields
868
           in
869
        let fields =
870
          if x.name = NoName
871
          then fields
872
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
873
            fields
874
           in
875
        `Assoc fields)
876
  [@ocaml.warning "-A"])
877

    
878
and (vhdl_subtype_indication_t_of_yojson :
879
      Yojson.Safe.json ->
880
        vhdl_subtype_indication_t Ppx_deriving_yojson_runtime.error_or)
881
  =
882
  ((let open! Ppx_deriving_yojson_runtime in
883
      function
884
      | `Assoc xs ->
885
          let rec loop xs ((arg0,arg1,arg2) as _state) =
886
            match xs with
887
            | ("name",x)::xs ->
888
                loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
889
            | ("functionName",x)::xs ->
890
                loop xs (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
891
            | ("const",x)::xs ->
892
                loop xs
893
                  (arg0, arg1, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
894
            | [] ->
895
                arg2 >>=
896
                  ((fun arg2  ->
897
                      arg1 >>=
898
                        (fun arg1  ->
899
                           arg0 >>=
900
                             (fun arg0  ->
901
                                Result.Ok
902
                                  {
903
                                    name = arg0;
904
                                    functionName = arg1;
905
                                    const = arg2
906
                                  }))))
907
            | _::xs -> loop xs _state  in
908
          loop xs
909
            ((Result.Ok NoName), (Result.Ok NoName),
910
              (Result.Ok NoConstraint))
911
      | _ -> Result.Error "Vhdl_ast.vhdl_subtype_indication_t")
912
  [@ocaml.warning "-A"])
913

    
914
and (vhdl_discrete_range_t_to_yojson :
915
      vhdl_discrete_range_t -> Yojson.Safe.json)
916
  =
917
  ((let open! Ppx_deriving_yojson_runtime in
918
      function
919
      | SubDiscreteRange arg0 ->
920
          `List
921
            [`String "SUB_DISCRETE_RANGE";
922
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x)) arg0]
923
      | NamedRange arg0 ->
924
          `List
925
            [`String "NAMED_RANGE";
926
            ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
927
      | DirectedRange arg0 ->
928
          `List
929
            [`String "RANGE_WITH_DIRECTION";
930
            (let fields = []  in
931
             let fields =
932
               ("_to", ((fun x  -> vhdl_expr_t_to_yojson x) arg0._to)) ::
933
               fields  in
934
             let fields =
935
               ("from", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.from)) ::
936
               fields  in
937
             let fields =
938
               ("direction",
939
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
940
                    arg0.direction))
941
               :: fields  in
942
             `Assoc fields)])
943
  [@ocaml.warning "-A"])
944

    
945
and (vhdl_discrete_range_t_of_yojson :
946
      Yojson.Safe.json ->
947
        vhdl_discrete_range_t Ppx_deriving_yojson_runtime.error_or)
948
  =
949
  ((let open! Ppx_deriving_yojson_runtime in
950
      function
951
      | `List ((`String "SUB_DISCRETE_RANGE")::arg0::[]) ->
952
          ((fun x  -> vhdl_subtype_indication_t_of_yojson x) arg0) >>=
953
            ((fun arg0  -> Result.Ok (SubDiscreteRange arg0)))
954
      | `List ((`String "NAMED_RANGE")::arg0::[]) ->
955
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
956
            ((fun arg0  -> Result.Ok (NamedRange arg0)))
957
      | `List ((`String "RANGE_WITH_DIRECTION")::arg0::[]) ->
958
          ((function
959
            | `Assoc xs ->
960
                let rec loop xs ((arg0,arg1,arg2) as _state) =
961
                  match xs with
962
                  | ("direction",x)::xs ->
963
                      loop xs
964
                        (((function
965
                           | `String x -> Result.Ok x
966
                           | _ ->
967
                               Result.Error
968
                                 "Vhdl_ast.vhdl_discrete_range_t.direction")
969
                            x), arg1, arg2)
970
                  | ("from",x)::xs ->
971
                      loop xs
972
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
973
                  | ("_to",x)::xs ->
974
                      loop xs
975
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
976
                  | [] ->
977
                      arg2 >>=
978
                        ((fun arg2  ->
979
                            arg1 >>=
980
                              (fun arg1  ->
981
                                 arg0 >>=
982
                                   (fun arg0  ->
983
                                      Result.Ok
984
                                        (DirectedRange
985
                                           {
986
                                             direction = arg0;
987
                                             from = arg1;
988
                                             _to = arg2
989
                                           })))))
990
                  | _::xs -> loop xs _state  in
991
                loop xs
992
                  ((Result.Error "Vhdl_ast.vhdl_discrete_range_t.direction"),
993
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t.from"),
994
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t._to"))
995
            | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")) arg0
996
      | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")
997
  [@ocaml.warning "-A"])
998

    
999
and (vhdl_constraint_t_to_yojson : vhdl_constraint_t -> Yojson.Safe.json) =
1000
  ((let open! Ppx_deriving_yojson_runtime in
1001
      function
1002
      | RefConstraint arg0 ->
1003
          `List
1004
            [`String "RefConstraint";
1005
            (let fields = []  in
1006
             let fields =
1007
               ("ref_name",
1008
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.ref_name))
1009
               :: fields  in
1010
             `Assoc fields)]
1011
      | RangeConstraint arg0 ->
1012
          `List
1013
            [`String "RANGE_CONSTRAINT";
1014
            (let fields = []  in
1015
             let fields =
1016
               ("range",
1017
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
1018
               :: fields  in
1019
             `Assoc fields)]
1020
      | IndexConstraint arg0 ->
1021
          `List
1022
            [`String "INDEX_CONSTRAINT";
1023
            (let fields = []  in
1024
             let fields =
1025
               ("ranges",
1026
                 ((fun x  ->
1027
                     `List
1028
                       (List.map
1029
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1030
                    arg0.ranges))
1031
               :: fields  in
1032
             `Assoc fields)]
1033
      | ArrayConstraint arg0 ->
1034
          `List
1035
            [`String "ARRAY_CONSTRAINT";
1036
            (let fields = []  in
1037
             let fields =
1038
               ("sub", ((fun x  -> vhdl_constraint_t_to_yojson x) arg0.sub))
1039
               :: fields  in
1040
             let fields =
1041
               ("ranges",
1042
                 ((fun x  ->
1043
                     `List
1044
                       (List.map
1045
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1046
                    arg0.ranges))
1047
               :: fields  in
1048
             `Assoc fields)]
1049
      | RecordConstraint  -> `List [`String "RecordConstraint"]
1050
      | NoConstraint  -> `List [`String "NoConstraint"])
1051
  [@ocaml.warning "-A"])
1052

    
1053
and (vhdl_constraint_t_of_yojson :
1054
      Yojson.Safe.json ->
1055
        vhdl_constraint_t Ppx_deriving_yojson_runtime.error_or)
1056
  =
1057
  ((let open! Ppx_deriving_yojson_runtime in
1058
      function
1059
      | `List ((`String "RefConstraint")::arg0::[]) ->
1060
          ((function
1061
            | `Assoc xs ->
1062
                let rec loop xs (arg0 as _state) =
1063
                  match xs with
1064
                  | ("ref_name",x)::xs ->
1065
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
1066
                  | [] ->
1067
                      arg0 >>=
1068
                        ((fun arg0  ->
1069
                            Result.Ok (RefConstraint { ref_name = arg0 })))
1070
                  | _::xs -> loop xs _state  in
1071
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ref_name")
1072
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1073
      | `List ((`String "RANGE_CONSTRAINT")::arg0::[]) ->
1074
          ((function
1075
            | `Assoc xs ->
1076
                let rec loop xs (arg0 as _state) =
1077
                  match xs with
1078
                  | ("range",x)::xs ->
1079
                      loop xs
1080
                        ((fun x  -> vhdl_discrete_range_t_of_yojson x) x)
1081
                  | [] ->
1082
                      arg0 >>=
1083
                        ((fun arg0  ->
1084
                            Result.Ok (RangeConstraint { range = arg0 })))
1085
                  | _::xs -> loop xs _state  in
1086
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.range")
1087
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1088
      | `List ((`String "INDEX_CONSTRAINT")::arg0::[]) ->
1089
          ((function
1090
            | `Assoc xs ->
1091
                let rec loop xs (arg0 as _state) =
1092
                  match xs with
1093
                  | ("ranges",x)::xs ->
1094
                      loop xs
1095
                        ((function
1096
                          | `List xs ->
1097
                              map_bind
1098
                                (fun x  -> vhdl_discrete_range_t_of_yojson x)
1099
                                [] xs
1100
                          | _ ->
1101
                              Result.Error
1102
                                "Vhdl_ast.vhdl_constraint_t.ranges") x)
1103
                  | [] ->
1104
                      arg0 >>=
1105
                        ((fun arg0  ->
1106
                            Result.Ok (IndexConstraint { ranges = arg0 })))
1107
                  | _::xs -> loop xs _state  in
1108
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ranges")
1109
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1110
      | `List ((`String "ARRAY_CONSTRAINT")::arg0::[]) ->
1111
          ((function
1112
            | `Assoc xs ->
1113
                let rec loop xs ((arg0,arg1) as _state) =
1114
                  match xs with
1115
                  | ("ranges",x)::xs ->
1116
                      loop xs
1117
                        (((function
1118
                           | `List xs ->
1119
                               map_bind
1120
                                 (fun x  -> vhdl_discrete_range_t_of_yojson x)
1121
                                 [] xs
1122
                           | _ ->
1123
                               Result.Error
1124
                                 "Vhdl_ast.vhdl_constraint_t.ranges") x),
1125
                          arg1)
1126
                  | ("sub",x)::xs ->
1127
                      loop xs
1128
                        (arg0, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
1129
                  | [] ->
1130
                      arg1 >>=
1131
                        ((fun arg1  ->
1132
                            arg0 >>=
1133
                              (fun arg0  ->
1134
                                 Result.Ok
1135
                                   (ArrayConstraint
1136
                                      { ranges = arg0; sub = arg1 }))))
1137
                  | _::xs -> loop xs _state  in
1138
                loop xs
1139
                  ((Result.Error "Vhdl_ast.vhdl_constraint_t.ranges"),
1140
                    (Result.Error "Vhdl_ast.vhdl_constraint_t.sub"))
1141
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1142
      | `List ((`String "RecordConstraint")::[]) ->
1143
          Result.Ok RecordConstraint
1144
      | `List ((`String "NoConstraint")::[]) -> Result.Ok NoConstraint
1145
      | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")
1146
  [@ocaml.warning "-A"])
1147

    
1148
and (vhdl_definition_t_to_yojson : vhdl_definition_t -> Yojson.Safe.json) =
1149
  ((let open! Ppx_deriving_yojson_runtime in
1150
      function
1151
      | Type arg0 ->
1152
          `List
1153
            [`String "TYPE_DECLARATION";
1154
            (let fields = []  in
1155
             let fields =
1156
               ("definition",
1157
                 ((fun x  -> vhdl_type_t_to_yojson x) arg0.definition))
1158
               :: fields  in
1159
             let fields =
1160
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1161
               fields  in
1162
             `Assoc fields)]
1163
      | Subtype arg0 ->
1164
          `List
1165
            [`String "SUBTYPE_DECLARATION";
1166
            (let fields = []  in
1167
             let fields =
1168
               ("typ",
1169
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
1170
               :: fields  in
1171
             let fields =
1172
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1173
               fields  in
1174
             `Assoc fields)])
1175
  [@ocaml.warning "-A"])
1176

    
1177
and (vhdl_definition_t_of_yojson :
1178
      Yojson.Safe.json ->
1179
        vhdl_definition_t Ppx_deriving_yojson_runtime.error_or)
1180
  =
1181
  ((let open! Ppx_deriving_yojson_runtime in
1182
      function
1183
      | `List ((`String "TYPE_DECLARATION")::arg0::[]) ->
1184
          ((function
1185
            | `Assoc xs ->
1186
                let rec loop xs ((arg0,arg1) as _state) =
1187
                  match xs with
1188
                  | ("name",x)::xs ->
1189
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1190
                  | ("definition",x)::xs ->
1191
                      loop xs (arg0, ((fun x  -> vhdl_type_t_of_yojson x) x))
1192
                  | [] ->
1193
                      arg1 >>=
1194
                        ((fun arg1  ->
1195
                            arg0 >>=
1196
                              (fun arg0  ->
1197
                                 Result.Ok
1198
                                   (Type { name = arg0; definition = arg1 }))))
1199
                  | _::xs -> loop xs _state  in
1200
                loop xs
1201
                  ((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
1202
                    (Result.Error "Vhdl_ast.vhdl_definition_t.definition"))
1203
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
1204
      | `List ((`String "SUBTYPE_DECLARATION")::arg0::[]) ->
1205
          ((function
1206
            | `Assoc xs ->
1207
                let rec loop xs ((arg0,arg1) as _state) =
1208
                  match xs with
1209
                  | ("name",x)::xs ->
1210
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1211
                  | ("typ",x)::xs ->
1212
                      loop xs
1213
                        (arg0,
1214
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
1215
                             x))
1216
                  | [] ->
1217
                      arg1 >>=
1218
                        ((fun arg1  ->
1219
                            arg0 >>=
1220
                              (fun arg0  ->
1221
                                 Result.Ok
1222
                                   (Subtype { name = arg0; typ = arg1 }))))
1223
                  | _::xs -> loop xs _state  in
1224
                loop xs
1225
                  ((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
1226
                    (Result.Error "Vhdl_ast.vhdl_definition_t.typ"))
1227
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
1228
      | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")
1229
  [@ocaml.warning "-A"])
1230

    
1231
and (vhdl_expr_t_to_yojson : vhdl_expr_t -> Yojson.Safe.json) =
1232
  ((let open! Ppx_deriving_yojson_runtime in
1233
      function
1234
      | Call arg0 ->
1235
          `List [`String "CALL"; ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
1236
      | Cst arg0 ->
1237
          `List
1238
            [`String "CONSTANT_VALUE";
1239
            ((fun x  -> vhdl_cst_val_t_to_yojson x)) arg0]
1240
      | Op arg0 ->
1241
          `List
1242
            [`String "EXPRESSION";
1243
            (let fields = []  in
1244
             let fields =
1245
               if arg0.args = []
1246
               then fields
1247
               else
1248
                 ("args",
1249
                   (((fun x  ->
1250
                        `List
1251
                          (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
1252
                      arg0.args))
1253
                 :: fields
1254
                in
1255
             let fields =
1256
               if arg0.id = ""
1257
               then fields
1258
               else
1259
                 ("id",
1260
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
1261
                      arg0.id))
1262
                 :: fields
1263
                in
1264
             `Assoc fields)]
1265
      | IsNull  -> `List [`String "IsNull"]
1266
      | Time arg0 ->
1267
          `List
1268
            [`String "Time";
1269
            (let fields = []  in
1270
             let fields =
1271
               if arg0.phy_unit = ""
1272
               then fields
1273
               else
1274
                 ("phy_unit",
1275
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
1276
                      arg0.phy_unit))
1277
                 :: fields
1278
                in
1279
             let fields =
1280
               ("value",
1281
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.value))
1282
               :: fields  in
1283
             `Assoc fields)]
1284
      | Sig arg0 ->
1285
          `List
1286
            [`String "Sig";
1287
            (let fields = []  in
1288
             let fields =
1289
               ("att",
1290
                 ((function
1291
                   | None  -> `Null
1292
                   | Some x ->
1293
                       ((fun x  -> vhdl_signal_attributes_t_to_yojson x)) x)
1294
                    arg0.att))
1295
               :: fields  in
1296
             let fields =
1297
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1298
               fields  in
1299
             `Assoc fields)]
1300
      | SuffixMod arg0 ->
1301
          `List
1302
            [`String "SuffixMod";
1303
            (let fields = []  in
1304
             let fields =
1305
               ("selection",
1306
                 ((fun x  -> vhdl_suffix_selection_t_to_yojson x)
1307
                    arg0.selection))
1308
               :: fields  in
1309
             let fields =
1310
               ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.expr)) ::
1311
               fields  in
1312
             `Assoc fields)]
1313
      | Aggregate arg0 ->
1314
          `List
1315
            [`String "AGGREGATE";
1316
            (let fields = []  in
1317
             let fields =
1318
               ("elems",
1319
                 ((fun x  ->
1320
                     `List
1321
                       (List.map (fun x  -> vhdl_element_assoc_t_to_yojson x)
1322
                          x)) arg0.elems))
1323
               :: fields  in
1324
             `Assoc fields)]
1325
      | Others  -> `List [`String "OTHERS"])
1326
  [@ocaml.warning "-A"])
1327

    
1328
and (vhdl_expr_t_of_yojson :
1329
      Yojson.Safe.json -> vhdl_expr_t Ppx_deriving_yojson_runtime.error_or)
1330
  =
1331
  ((let open! Ppx_deriving_yojson_runtime in
1332
      function
1333
      | `List ((`String "CALL")::arg0::[]) ->
1334
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
1335
            ((fun arg0  -> Result.Ok (Call arg0)))
1336
      | `List ((`String "CONSTANT_VALUE")::arg0::[]) ->
1337
          ((fun x  -> vhdl_cst_val_t_of_yojson x) arg0) >>=
1338
            ((fun arg0  -> Result.Ok (Cst arg0)))
1339
      | `List ((`String "EXPRESSION")::arg0::[]) ->
1340
          ((function
1341
            | `Assoc xs ->
1342
                let rec loop xs ((arg0,arg1) as _state) =
1343
                  match xs with
1344
                  | ("id",x)::xs ->
1345
                      loop xs
1346
                        (((function
1347
                           | `String x -> Result.Ok x
1348
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.id") x),
1349
                          arg1)
1350
                  | ("args",x)::xs ->
1351
                      loop xs
1352
                        (arg0,
1353
                          ((function
1354
                            | `List xs ->
1355
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1356
                                  [] xs
1357
                            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.args")
1358
                             x))
1359
                  | [] ->
1360
                      arg1 >>=
1361
                        ((fun arg1  ->
1362
                            arg0 >>=
1363
                              (fun arg0  ->
1364
                                 Result.Ok (Op { id = arg0; args = arg1 }))))
1365
                  | _::xs -> loop xs _state  in
1366
                loop xs ((Result.Ok ""), (Result.Ok []))
1367
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1368
      | `List ((`String "IsNull")::[]) -> Result.Ok IsNull
1369
      | `List ((`String "Time")::arg0::[]) ->
1370
          ((function
1371
            | `Assoc xs ->
1372
                let rec loop xs ((arg0,arg1) as _state) =
1373
                  match xs with
1374
                  | ("value",x)::xs ->
1375
                      loop xs
1376
                        (((function
1377
                           | `Int x -> Result.Ok x
1378
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.value")
1379
                            x), arg1)
1380
                  | ("phy_unit",x)::xs ->
1381
                      loop xs
1382
                        (arg0,
1383
                          ((function
1384
                            | `String x -> Result.Ok x
1385
                            | _ ->
1386
                                Result.Error "Vhdl_ast.vhdl_expr_t.phy_unit")
1387
                             x))
1388
                  | [] ->
1389
                      arg1 >>=
1390
                        ((fun arg1  ->
1391
                            arg0 >>=
1392
                              (fun arg0  ->
1393
                                 Result.Ok
1394
                                   (Time { value = arg0; phy_unit = arg1 }))))
1395
                  | _::xs -> loop xs _state  in
1396
                loop xs
1397
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.value"),
1398
                    (Result.Ok ""))
1399
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1400
      | `List ((`String "Sig")::arg0::[]) ->
1401
          ((function
1402
            | `Assoc xs ->
1403
                let rec loop xs ((arg0,arg1) as _state) =
1404
                  match xs with
1405
                  | ("name",x)::xs ->
1406
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1407
                  | ("att",x)::xs ->
1408
                      loop xs
1409
                        (arg0,
1410
                          ((function
1411
                            | `Null -> Result.Ok None
1412
                            | x ->
1413
                                ((fun x  ->
1414
                                    vhdl_signal_attributes_t_of_yojson x) x)
1415
                                  >>= ((fun x  -> Result.Ok (Some x)))) x))
1416
                  | [] ->
1417
                      arg1 >>=
1418
                        ((fun arg1  ->
1419
                            arg0 >>=
1420
                              (fun arg0  ->
1421
                                 Result.Ok (Sig { name = arg0; att = arg1 }))))
1422
                  | _::xs -> loop xs _state  in
1423
                loop xs
1424
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.name"),
1425
                    (Result.Error "Vhdl_ast.vhdl_expr_t.att"))
1426
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1427
      | `List ((`String "SuffixMod")::arg0::[]) ->
1428
          ((function
1429
            | `Assoc xs ->
1430
                let rec loop xs ((arg0,arg1) as _state) =
1431
                  match xs with
1432
                  | ("expr",x)::xs ->
1433
                      loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
1434
                  | ("selection",x)::xs ->
1435
                      loop xs
1436
                        (arg0,
1437
                          ((fun x  -> vhdl_suffix_selection_t_of_yojson x) x))
1438
                  | [] ->
1439
                      arg1 >>=
1440
                        ((fun arg1  ->
1441
                            arg0 >>=
1442
                              (fun arg0  ->
1443
                                 Result.Ok
1444
                                   (SuffixMod
1445
                                      { expr = arg0; selection = arg1 }))))
1446
                  | _::xs -> loop xs _state  in
1447
                loop xs
1448
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.expr"),
1449
                    (Result.Error "Vhdl_ast.vhdl_expr_t.selection"))
1450
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1451
      | `List ((`String "AGGREGATE")::arg0::[]) ->
1452
          ((function
1453
            | `Assoc xs ->
1454
                let rec loop xs (arg0 as _state) =
1455
                  match xs with
1456
                  | ("elems",x)::xs ->
1457
                      loop xs
1458
                        ((function
1459
                          | `List xs ->
1460
                              map_bind
1461
                                (fun x  -> vhdl_element_assoc_t_of_yojson x)
1462
                                [] xs
1463
                          | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.elems") x)
1464
                  | [] ->
1465
                      arg0 >>=
1466
                        ((fun arg0  -> Result.Ok (Aggregate { elems = arg0 })))
1467
                  | _::xs -> loop xs _state  in
1468
                loop xs (Result.Error "Vhdl_ast.vhdl_expr_t.elems")
1469
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1470
      | `List ((`String "OTHERS")::[]) -> Result.Ok Others
1471
      | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")
1472
  [@ocaml.warning "-A"])
1473

    
1474
and (vhdl_name_t_to_yojson : vhdl_name_t -> Yojson.Safe.json) =
1475
  ((let open! Ppx_deriving_yojson_runtime in
1476
      function
1477
      | Simple arg0 ->
1478
          `List
1479
            [`String "SIMPLE_NAME";
1480
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1481
      | Identifier arg0 ->
1482
          `List
1483
            [`String "IDENTIFIER";
1484
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1485
      | Selected arg0 ->
1486
          `List
1487
            [`String "SELECTED_NAME";
1488
            ((fun x  ->
1489
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
1490
      | Index arg0 ->
1491
          `List
1492
            [`String "INDEXED_NAME";
1493
            (let fields = []  in
1494
             let fields =
1495
               ("exprs",
1496
                 ((fun x  ->
1497
                     `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
1498
                    arg0.exprs))
1499
               :: fields  in
1500
             let fields =
1501
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1502
               fields  in
1503
             `Assoc fields)]
1504
      | Slice arg0 ->
1505
          `List
1506
            [`String "SLICE_NAME";
1507
            (let fields = []  in
1508
             let fields =
1509
               ("range",
1510
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
1511
               :: fields  in
1512
             let fields =
1513
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1514
               fields  in
1515
             `Assoc fields)]
1516
      | Attribute arg0 ->
1517
          `List
1518
            [`String "ATTRIBUTE_NAME";
1519
            (let fields = []  in
1520
             let fields =
1521
               if arg0.expr = IsNull
1522
               then fields
1523
               else
1524
                 ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.expr))
1525
                 :: fields
1526
                in
1527
             let fields =
1528
               ("designator",
1529
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.designator))
1530
               :: fields  in
1531
             let fields =
1532
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1533
               fields  in
1534
             `Assoc fields)]
1535
      | Function arg0 ->
1536
          `List
1537
            [`String "FUNCTION_CALL";
1538
            (let fields = []  in
1539
             let fields =
1540
               ("assoc_list",
1541
                 ((fun x  ->
1542
                     `List
1543
                       (List.map (fun x  -> vhdl_assoc_element_t_to_yojson x)
1544
                          x)) arg0.assoc_list))
1545
               :: fields  in
1546
             let fields =
1547
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1548
               fields  in
1549
             `Assoc fields)]
1550
      | NoName  -> `List [`String "NoName"])
1551
  [@ocaml.warning "-A"])
1552

    
1553
and (vhdl_name_t_of_yojson :
1554
      Yojson.Safe.json -> vhdl_name_t Ppx_deriving_yojson_runtime.error_or)
1555
  =
1556
  ((let open! Ppx_deriving_yojson_runtime in
1557
      function
1558
      | `List ((`String "SIMPLE_NAME")::arg0::[]) ->
1559
          ((function
1560
            | `String x -> Result.Ok x
1561
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1562
            ((fun arg0  -> Result.Ok (Simple arg0)))
1563
      | `List ((`String "IDENTIFIER")::arg0::[]) ->
1564
          ((function
1565
            | `String x -> Result.Ok x
1566
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1567
            ((fun arg0  -> Result.Ok (Identifier arg0)))
1568
      | `List ((`String "SELECTED_NAME")::arg0::[]) ->
1569
          ((function
1570
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1571
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1572
            ((fun arg0  -> Result.Ok (Selected arg0)))
1573
      | `List ((`String "INDEXED_NAME")::arg0::[]) ->
1574
          ((function
1575
            | `Assoc xs ->
1576
                let rec loop xs ((arg0,arg1) as _state) =
1577
                  match xs with
1578
                  | ("id",x)::xs ->
1579
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1580
                  | ("exprs",x)::xs ->
1581
                      loop xs
1582
                        (arg0,
1583
                          ((function
1584
                            | `List xs ->
1585
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1586
                                  [] xs
1587
                            | _ -> Result.Error "Vhdl_ast.vhdl_name_t.exprs")
1588
                             x))
1589
                  | [] ->
1590
                      arg1 >>=
1591
                        ((fun arg1  ->
1592
                            arg0 >>=
1593
                              (fun arg0  ->
1594
                                 Result.Ok
1595
                                   (Index { id = arg0; exprs = 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.exprs"))
1600
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1601
      | `List ((`String "SLICE_NAME")::arg0::[]) ->
1602
          ((function
1603
            | `Assoc xs ->
1604
                let rec loop xs ((arg0,arg1) as _state) =
1605
                  match xs with
1606
                  | ("id",x)::xs ->
1607
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1608
                  | ("range",x)::xs ->
1609
                      loop xs
1610
                        (arg0,
1611
                          ((fun x  -> vhdl_discrete_range_t_of_yojson x) x))
1612
                  | [] ->
1613
                      arg1 >>=
1614
                        ((fun arg1  ->
1615
                            arg0 >>=
1616
                              (fun arg0  ->
1617
                                 Result.Ok
1618
                                   (Slice { id = arg0; range = arg1 }))))
1619
                  | _::xs -> loop xs _state  in
1620
                loop xs
1621
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1622
                    (Result.Error "Vhdl_ast.vhdl_name_t.range"))
1623
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1624
      | `List ((`String "ATTRIBUTE_NAME")::arg0::[]) ->
1625
          ((function
1626
            | `Assoc xs ->
1627
                let rec loop xs ((arg0,arg1,arg2) as _state) =
1628
                  match xs with
1629
                  | ("id",x)::xs ->
1630
                      loop xs
1631
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
1632
                  | ("designator",x)::xs ->
1633
                      loop xs
1634
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
1635
                  | ("expr",x)::xs ->
1636
                      loop xs
1637
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1638
                  | [] ->
1639
                      arg2 >>=
1640
                        ((fun arg2  ->
1641
                            arg1 >>=
1642
                              (fun arg1  ->
1643
                                 arg0 >>=
1644
                                   (fun arg0  ->
1645
                                      Result.Ok
1646
                                        (Attribute
1647
                                           {
1648
                                             id = arg0;
1649
                                             designator = arg1;
1650
                                             expr = arg2
1651
                                           })))))
1652
                  | _::xs -> loop xs _state  in
1653
                loop xs
1654
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1655
                    (Result.Error "Vhdl_ast.vhdl_name_t.designator"),
1656
                    (Result.Ok IsNull))
1657
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1658
      | `List ((`String "FUNCTION_CALL")::arg0::[]) ->
1659
          ((function
1660
            | `Assoc xs ->
1661
                let rec loop xs ((arg0,arg1) as _state) =
1662
                  match xs with
1663
                  | ("id",x)::xs ->
1664
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1665
                  | ("assoc_list",x)::xs ->
1666
                      loop xs
1667
                        (arg0,
1668
                          ((function
1669
                            | `List xs ->
1670
                                map_bind
1671
                                  (fun x  -> vhdl_assoc_element_t_of_yojson x)
1672
                                  [] xs
1673
                            | _ ->
1674
                                Result.Error
1675
                                  "Vhdl_ast.vhdl_name_t.assoc_list") x))
1676
                  | [] ->
1677
                      arg1 >>=
1678
                        ((fun arg1  ->
1679
                            arg0 >>=
1680
                              (fun arg0  ->
1681
                                 Result.Ok
1682
                                   (Function { id = arg0; assoc_list = arg1 }))))
1683
                  | _::xs -> loop xs _state  in
1684
                loop xs
1685
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1686
                    (Result.Error "Vhdl_ast.vhdl_name_t.assoc_list"))
1687
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1688
      | `List ((`String "NoName")::[]) -> Result.Ok NoName
1689
      | _ -> Result.Error "Vhdl_ast.vhdl_name_t")
1690
  [@ocaml.warning "-A"])
1691

    
1692
and (vhdl_assoc_element_t_to_yojson :
1693
      vhdl_assoc_element_t -> Yojson.Safe.json)
1694
  =
1695
  ((let open! Ppx_deriving_yojson_runtime in
1696
      fun x  ->
1697
        let fields = []  in
1698
        let fields =
1699
          if x.actual_expr = (Some IsNull)
1700
          then fields
1701
          else
1702
            ("actual_expr",
1703
              (((function
1704
                 | None  -> `Null
1705
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
1706
                 x.actual_expr))
1707
            :: fields
1708
           in
1709
        let fields =
1710
          if x.actual_designator = (Some NoName)
1711
          then fields
1712
          else
1713
            ("actual_designator",
1714
              (((function
1715
                 | None  -> `Null
1716
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1717
                 x.actual_designator))
1718
            :: fields
1719
           in
1720
        let fields =
1721
          if x.actual_name = (Some NoName)
1722
          then fields
1723
          else
1724
            ("actual_name",
1725
              (((function
1726
                 | None  -> `Null
1727
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1728
                 x.actual_name))
1729
            :: fields
1730
           in
1731
        let fields =
1732
          if x.formal_arg = (Some NoName)
1733
          then fields
1734
          else
1735
            ("formal_arg",
1736
              (((function
1737
                 | None  -> `Null
1738
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1739
                 x.formal_arg))
1740
            :: fields
1741
           in
1742
        let fields =
1743
          if x.formal_name = (Some NoName)
1744
          then fields
1745
          else
1746
            ("formal_name",
1747
              (((function
1748
                 | None  -> `Null
1749
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1750
                 x.formal_name))
1751
            :: fields
1752
           in
1753
        `Assoc fields)
1754
  [@ocaml.warning "-A"])
1755

    
1756
and (vhdl_assoc_element_t_of_yojson :
1757
      Yojson.Safe.json ->
1758
        vhdl_assoc_element_t Ppx_deriving_yojson_runtime.error_or)
1759
  =
1760
  ((let open! Ppx_deriving_yojson_runtime in
1761
      function
1762
      | `Assoc xs ->
1763
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
1764
            match xs with
1765
            | ("formal_name",x)::xs ->
1766
                loop xs
1767
                  (((function
1768
                     | `Null -> Result.Ok None
1769
                     | x ->
1770
                         ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1771
                           ((fun x  -> Result.Ok (Some x)))) x), arg1, arg2,
1772
                    arg3, arg4)
1773
            | ("formal_arg",x)::xs ->
1774
                loop xs
1775
                  (arg0,
1776
                    ((function
1777
                      | `Null -> Result.Ok None
1778
                      | x ->
1779
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1780
                            ((fun x  -> Result.Ok (Some x)))) x), arg2, arg3,
1781
                    arg4)
1782
            | ("actual_name",x)::xs ->
1783
                loop xs
1784
                  (arg0, arg1,
1785
                    ((function
1786
                      | `Null -> Result.Ok None
1787
                      | x ->
1788
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1789
                            ((fun x  -> Result.Ok (Some x)))) x), arg3, arg4)
1790
            | ("actual_designator",x)::xs ->
1791
                loop xs
1792
                  (arg0, arg1, arg2,
1793
                    ((function
1794
                      | `Null -> Result.Ok None
1795
                      | x ->
1796
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1797
                            ((fun x  -> Result.Ok (Some x)))) x), arg4)
1798
            | ("actual_expr",x)::xs ->
1799
                loop xs
1800
                  (arg0, arg1, arg2, arg3,
1801
                    ((function
1802
                      | `Null -> Result.Ok None
1803
                      | x ->
1804
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
1805
                            ((fun x  -> Result.Ok (Some x)))) x))
1806
            | [] ->
1807
                arg4 >>=
1808
                  ((fun arg4  ->
1809
                      arg3 >>=
1810
                        (fun arg3  ->
1811
                           arg2 >>=
1812
                             (fun arg2  ->
1813
                                arg1 >>=
1814
                                  (fun arg1  ->
1815
                                     arg0 >>=
1816
                                       (fun arg0  ->
1817
                                          Result.Ok
1818
                                            {
1819
                                              formal_name = arg0;
1820
                                              formal_arg = arg1;
1821
                                              actual_name = arg2;
1822
                                              actual_designator = arg3;
1823
                                              actual_expr = arg4
1824
                                            }))))))
1825
            | _::xs -> loop xs _state  in
1826
          loop xs
1827
            ((Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
1828
              (Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
1829
              (Result.Ok (Some IsNull)))
1830
      | _ -> Result.Error "Vhdl_ast.vhdl_assoc_element_t")
1831
  [@ocaml.warning "-A"])
1832

    
1833
and (vhdl_element_assoc_t_to_yojson :
1834
      vhdl_element_assoc_t -> Yojson.Safe.json)
1835
  =
1836
  ((let open! Ppx_deriving_yojson_runtime in
1837
      fun x  ->
1838
        let fields = []  in
1839
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
1840
          :: fields  in
1841
        let fields =
1842
          ("choices",
1843
            ((fun x  ->
1844
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
1845
               x.choices))
1846
          :: fields  in
1847
        `Assoc fields)
1848
  [@ocaml.warning "-A"])
1849

    
1850
and (vhdl_element_assoc_t_of_yojson :
1851
      Yojson.Safe.json ->
1852
        vhdl_element_assoc_t Ppx_deriving_yojson_runtime.error_or)
1853
  =
1854
  ((let open! Ppx_deriving_yojson_runtime in
1855
      function
1856
      | `Assoc xs ->
1857
          let rec loop xs ((arg0,arg1) as _state) =
1858
            match xs with
1859
            | ("choices",x)::xs ->
1860
                loop xs
1861
                  (((function
1862
                     | `List xs ->
1863
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
1864
                     | _ ->
1865
                         Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices")
1866
                      x), arg1)
1867
            | ("expr",x)::xs ->
1868
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1869
            | [] ->
1870
                arg1 >>=
1871
                  ((fun arg1  ->
1872
                      arg0 >>=
1873
                        (fun arg0  ->
1874
                           Result.Ok { choices = arg0; expr = arg1 })))
1875
            | _::xs -> loop xs _state  in
1876
          loop xs
1877
            ((Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices"),
1878
              (Result.Error "Vhdl_ast.vhdl_element_assoc_t.expr"))
1879
      | _ -> Result.Error "Vhdl_ast.vhdl_element_assoc_t")
1880
  [@ocaml.warning "-A"])
1881

    
1882
and (vhdl_array_attributes_t_to_yojson :
1883
      vhdl_array_attributes_t -> Yojson.Safe.json)
1884
  =
1885
  ((let open! Ppx_deriving_yojson_runtime in
1886
      function
1887
      | AAttInt arg0 ->
1888
          `List
1889
            [`String "AAttInt";
1890
            (let fields = []  in
1891
             let fields =
1892
               ("arg",
1893
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
1894
               :: fields  in
1895
             let fields =
1896
               ("id",
1897
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
1898
                    arg0.id))
1899
               :: fields  in
1900
             `Assoc fields)]
1901
      | AAttAscending  -> `List [`String "AAttAscending"])
1902
  [@ocaml.warning "-A"])
1903

    
1904
and (vhdl_array_attributes_t_of_yojson :
1905
      Yojson.Safe.json ->
1906
        vhdl_array_attributes_t Ppx_deriving_yojson_runtime.error_or)
1907
  =
1908
  ((let open! Ppx_deriving_yojson_runtime in
1909
      function
1910
      | `List ((`String "AAttInt")::arg0::[]) ->
1911
          ((function
1912
            | `Assoc xs ->
1913
                let rec loop xs ((arg0,arg1) as _state) =
1914
                  match xs with
1915
                  | ("id",x)::xs ->
1916
                      loop xs
1917
                        (((function
1918
                           | `String x -> Result.Ok x
1919
                           | _ ->
1920
                               Result.Error
1921
                                 "Vhdl_ast.vhdl_array_attributes_t.id") x),
1922
                          arg1)
1923
                  | ("arg",x)::xs ->
1924
                      loop xs
1925
                        (arg0,
1926
                          ((function
1927
                            | `Int x -> Result.Ok x
1928
                            | _ ->
1929
                                Result.Error
1930
                                  "Vhdl_ast.vhdl_array_attributes_t.arg") x))
1931
                  | [] ->
1932
                      arg1 >>=
1933
                        ((fun arg1  ->
1934
                            arg0 >>=
1935
                              (fun arg0  ->
1936
                                 Result.Ok
1937
                                   (AAttInt { id = arg0; arg = arg1 }))))
1938
                  | _::xs -> loop xs _state  in
1939
                loop xs
1940
                  ((Result.Error "Vhdl_ast.vhdl_array_attributes_t.id"),
1941
                    (Result.Error "Vhdl_ast.vhdl_array_attributes_t.arg"))
1942
            | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")) arg0
1943
      | `List ((`String "AAttAscending")::[]) -> Result.Ok AAttAscending
1944
      | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")
1945
  [@ocaml.warning "-A"])
1946

    
1947
and (vhdl_signal_attributes_t_to_yojson :
1948
      vhdl_signal_attributes_t -> Yojson.Safe.json)
1949
  =
1950
  ((let open! Ppx_deriving_yojson_runtime in
1951
      function
1952
      | SigAtt arg0 ->
1953
          `List
1954
            [`String "SigAtt";
1955
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
1956
  [@ocaml.warning "-A"])
1957

    
1958
and (vhdl_signal_attributes_t_of_yojson :
1959
      Yojson.Safe.json ->
1960
        vhdl_signal_attributes_t Ppx_deriving_yojson_runtime.error_or)
1961
  =
1962
  ((let open! Ppx_deriving_yojson_runtime in
1963
      function
1964
      | `List ((`String "SigAtt")::arg0::[]) ->
1965
          ((function
1966
            | `String x -> Result.Ok x
1967
            | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t") arg0)
1968
            >>= ((fun arg0  -> Result.Ok (SigAtt arg0)))
1969
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t")
1970
  [@ocaml.warning "-A"])
1971

    
1972
and (vhdl_string_attributes_t_to_yojson :
1973
      vhdl_string_attributes_t -> Yojson.Safe.json)
1974
  =
1975
  ((let open! Ppx_deriving_yojson_runtime in
1976
      function
1977
      | StringAtt arg0 ->
1978
          `List
1979
            [`String "StringAtt";
1980
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
1981
  [@ocaml.warning "-A"])
1982

    
1983
and (vhdl_string_attributes_t_of_yojson :
1984
      Yojson.Safe.json ->
1985
        vhdl_string_attributes_t Ppx_deriving_yojson_runtime.error_or)
1986
  =
1987
  ((let open! Ppx_deriving_yojson_runtime in
1988
      function
1989
      | `List ((`String "StringAtt")::arg0::[]) ->
1990
          ((function
1991
            | `String x -> Result.Ok x
1992
            | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t") arg0)
1993
            >>= ((fun arg0  -> Result.Ok (StringAtt arg0)))
1994
      | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t")
1995
  [@ocaml.warning "-A"])
1996

    
1997
and (vhdl_suffix_selection_t_to_yojson :
1998
      vhdl_suffix_selection_t -> Yojson.Safe.json)
1999
  =
2000
  ((let open! Ppx_deriving_yojson_runtime in
2001
      function
2002
      | Idx arg0 ->
2003
          `List
2004
            [`String "Idx";
2005
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0]
2006
      | SuffixRange (arg0,arg1) ->
2007
          `List
2008
            [`String "SuffixRange";
2009
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
2010
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1])
2011
  [@ocaml.warning "-A"])
2012

    
2013
and (vhdl_suffix_selection_t_of_yojson :
2014
      Yojson.Safe.json ->
2015
        vhdl_suffix_selection_t Ppx_deriving_yojson_runtime.error_or)
2016
  =
2017
  ((let open! Ppx_deriving_yojson_runtime in
2018
      function
2019
      | `List ((`String "Idx")::arg0::[]) ->
2020
          ((function
2021
            | `Int x -> Result.Ok x
2022
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg0) >>=
2023
            ((fun arg0  -> Result.Ok (Idx arg0)))
2024
      | `List ((`String "SuffixRange")::arg0::arg1::[]) ->
2025
          ((function
2026
            | `Int x -> Result.Ok x
2027
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg1) >>=
2028
            ((fun arg1  ->
2029
                ((function
2030
                  | `Int x -> Result.Ok x
2031
                  | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2032
                   arg0)
2033
                  >>= (fun arg0  -> Result.Ok (SuffixRange (arg0, arg1)))))
2034
      | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2035
  [@ocaml.warning "-A"])
2036

    
2037
type 'basetype vhdl_type_attributes_t =
2038
  | TAttNoArg of {
2039
  id: string } 
2040
  | TAttIntArg of {
2041
  id: string ;
2042
  arg: int } 
2043
  | TAttValArg of {
2044
  id: string ;
2045
  arg: 'basetype } 
2046
  | TAttStringArg of {
2047
  id: string ;
2048
  arg: string } 
2049

    
2050
let rec pp_vhdl_type_attributes_t
2051
  =
2052
  ((let open! Ppx_deriving_runtime in
2053
      fun poly_basetype  ->
2054
        fun fmt  ->
2055
          function
2056
          | TAttNoArg { id = aid } ->
2057
              (Format.fprintf fmt "@[<2>TAttNoArg {@,";
2058
               (Format.fprintf fmt "@[%s =@ " "id";
2059
                (Format.fprintf fmt "%S") aid;
2060
                Format.fprintf fmt "@]");
2061
               Format.fprintf fmt "@]}")
2062
          | TAttIntArg { id = aid; arg = aarg } ->
2063
              (Format.fprintf fmt "@[<2>TAttIntArg {@,";
2064
               ((Format.fprintf fmt "@[%s =@ " "id";
2065
                 (Format.fprintf fmt "%S") aid;
2066
                 Format.fprintf fmt "@]");
2067
                Format.fprintf fmt ";@ ";
2068
                Format.fprintf fmt "@[%s =@ " "arg";
2069
                (Format.fprintf fmt "%d") aarg;
2070
                Format.fprintf fmt "@]");
2071
               Format.fprintf fmt "@]}")
2072
          | TAttValArg { id = aid; arg = aarg } ->
2073
              (Format.fprintf fmt "@[<2>TAttValArg {@,";
2074
               ((Format.fprintf fmt "@[%s =@ " "id";
2075
                 (Format.fprintf fmt "%S") aid;
2076
                 Format.fprintf fmt "@]");
2077
                Format.fprintf fmt ";@ ";
2078
                Format.fprintf fmt "@[%s =@ " "arg";
2079
                (poly_basetype fmt) aarg;
2080
                Format.fprintf fmt "@]");
2081
               Format.fprintf fmt "@]}")
2082
          | TAttStringArg { id = aid; arg = aarg } ->
2083
              (Format.fprintf fmt "@[<2>TAttStringArg {@,";
2084
               ((Format.fprintf fmt "@[%s =@ " "id";
2085
                 (Format.fprintf fmt "%S") aid;
2086
                 Format.fprintf fmt "@]");
2087
                Format.fprintf fmt ";@ ";
2088
                Format.fprintf fmt "@[%s =@ " "arg";
2089
                (Format.fprintf fmt "%S") aarg;
2090
                Format.fprintf fmt "@]");
2091
               Format.fprintf fmt "@]}"))
2092
  [@ocaml.warning "-A"])
2093

    
2094
and show_vhdl_type_attributes_t  =
2095
  fun poly_basetype  ->
2096
    fun x  ->
2097
      Format.asprintf "%a" (pp_vhdl_type_attributes_t poly_basetype) x
2098

    
2099
let rec vhdl_type_attributes_t_to_yojson :
2100
  'basetype .
2101
    ('basetype -> Yojson.Safe.json) ->
2102
      'basetype vhdl_type_attributes_t -> Yojson.Safe.json
2103
  =
2104
  fun poly_basetype  ->
2105
    ((let open! Ppx_deriving_yojson_runtime in
2106
        function
2107
        | TAttNoArg arg0 ->
2108
            `List
2109
              [`String "TAttNoArg";
2110
              (let fields = []  in
2111
               let fields =
2112
                 ("id",
2113
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2114
                      arg0.id))
2115
                 :: fields  in
2116
               `Assoc fields)]
2117
        | TAttIntArg arg0 ->
2118
            `List
2119
              [`String "TAttIntArg";
2120
              (let fields = []  in
2121
               let fields =
2122
                 ("arg",
2123
                   ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
2124
                 :: fields  in
2125
               let fields =
2126
                 ("id",
2127
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2128
                      arg0.id))
2129
                 :: fields  in
2130
               `Assoc fields)]
2131
        | TAttValArg arg0 ->
2132
            `List
2133
              [`String "TAttValArg";
2134
              (let fields = []  in
2135
               let fields =
2136
                 ("arg", ((poly_basetype : _ -> Yojson.Safe.json) arg0.arg))
2137
                 :: fields  in
2138
               let fields =
2139
                 ("id",
2140
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2141
                      arg0.id))
2142
                 :: fields  in
2143
               `Assoc fields)]
2144
        | TAttStringArg arg0 ->
2145
            `List
2146
              [`String "TAttStringArg";
2147
              (let fields = []  in
2148
               let fields =
2149
                 ("arg",
2150
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2151
                      arg0.arg))
2152
                 :: fields  in
2153
               let fields =
2154
                 ("id",
2155
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2156
                      arg0.id))
2157
                 :: fields  in
2158
               `Assoc fields)])
2159
    [@ocaml.warning "-A"])
2160

    
2161
and vhdl_type_attributes_t_of_yojson :
2162
  'basetype .
2163
    (Yojson.Safe.json -> 'basetype Ppx_deriving_yojson_runtime.error_or) ->
2164
      Yojson.Safe.json ->
2165
        'basetype vhdl_type_attributes_t Ppx_deriving_yojson_runtime.error_or
2166
  =
2167
  fun poly_basetype  ->
2168
    ((let open! Ppx_deriving_yojson_runtime in
2169
        function
2170
        | `List ((`String "TAttNoArg")::arg0::[]) ->
2171
            ((function
2172
              | `Assoc xs ->
2173
                  let rec loop xs (arg0 as _state) =
2174
                    match xs with
2175
                    | ("id",x)::xs ->
2176
                        loop xs
2177
                          ((function
2178
                            | `String x -> Result.Ok x
2179
                            | _ ->
2180
                                Result.Error
2181
                                  "Vhdl_ast.vhdl_type_attributes_t.id") x)
2182
                    | [] ->
2183
                        arg0 >>=
2184
                          ((fun arg0  -> Result.Ok (TAttNoArg { id = arg0 })))
2185
                    | _::xs -> loop xs _state  in
2186
                  loop xs (Result.Error "Vhdl_ast.vhdl_type_attributes_t.id")
2187
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2188
        | `List ((`String "TAttIntArg")::arg0::[]) ->
2189
            ((function
2190
              | `Assoc xs ->
2191
                  let rec loop xs ((arg0,arg1) as _state) =
2192
                    match xs with
2193
                    | ("id",x)::xs ->
2194
                        loop xs
2195
                          (((function
2196
                             | `String x -> Result.Ok x
2197
                             | _ ->
2198
                                 Result.Error
2199
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2200
                            arg1)
2201
                    | ("arg",x)::xs ->
2202
                        loop xs
2203
                          (arg0,
2204
                            ((function
2205
                              | `Int x -> Result.Ok x
2206
                              | _ ->
2207
                                  Result.Error
2208
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2209
                    | [] ->
2210
                        arg1 >>=
2211
                          ((fun arg1  ->
2212
                              arg0 >>=
2213
                                (fun arg0  ->
2214
                                   Result.Ok
2215
                                     (TAttIntArg { id = arg0; arg = arg1 }))))
2216
                    | _::xs -> loop xs _state  in
2217
                  loop xs
2218
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2219
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2220
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2221
        | `List ((`String "TAttValArg")::arg0::[]) ->
2222
            ((function
2223
              | `Assoc xs ->
2224
                  let rec loop xs ((arg0,arg1) as _state) =
2225
                    match xs with
2226
                    | ("id",x)::xs ->
2227
                        loop xs
2228
                          (((function
2229
                             | `String x -> Result.Ok x
2230
                             | _ ->
2231
                                 Result.Error
2232
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2233
                            arg1)
2234
                    | ("arg",x)::xs ->
2235
                        loop xs
2236
                          (arg0,
2237
                            ((poly_basetype : Yojson.Safe.json -> _ error_or)
2238
                               x))
2239
                    | [] ->
2240
                        arg1 >>=
2241
                          ((fun arg1  ->
2242
                              arg0 >>=
2243
                                (fun arg0  ->
2244
                                   Result.Ok
2245
                                     (TAttValArg { id = arg0; arg = arg1 }))))
2246
                    | _::xs -> loop xs _state  in
2247
                  loop xs
2248
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2249
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2250
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2251
        | `List ((`String "TAttStringArg")::arg0::[]) ->
2252
            ((function
2253
              | `Assoc xs ->
2254
                  let rec loop xs ((arg0,arg1) as _state) =
2255
                    match xs with
2256
                    | ("id",x)::xs ->
2257
                        loop xs
2258
                          (((function
2259
                             | `String x -> Result.Ok x
2260
                             | _ ->
2261
                                 Result.Error
2262
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2263
                            arg1)
2264
                    | ("arg",x)::xs ->
2265
                        loop xs
2266
                          (arg0,
2267
                            ((function
2268
                              | `String x -> Result.Ok x
2269
                              | _ ->
2270
                                  Result.Error
2271
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2272
                    | [] ->
2273
                        arg1 >>=
2274
                          ((fun arg1  ->
2275
                              arg0 >>=
2276
                                (fun arg0  ->
2277
                                   Result.Ok
2278
                                     (TAttStringArg { id = arg0; arg = arg1 }))))
2279
                    | _::xs -> loop xs _state  in
2280
                  loop xs
2281
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2282
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2283
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2284
        | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")
2285
    [@ocaml.warning "-A"])
2286

    
2287
let typ_att_noarg = ["base"; "left"; "right"; "high"; "low"] 
2288
let typ_att_intarg = ["pos"; "val"; "succ"; "pred"; "leftof"; "rightof"] 
2289
let typ_att_valarg = ["image"] 
2290
let typ_att_stringarg = ["value"] 
2291
let array_att_intarg =
2292
  ["left"; "right"; "high"; "low"; "range"; "reverse_range"; "length"] 
2293
type vhdl_parameter_t =
2294
  {
2295
  names: vhdl_name_t list ;
2296
  mode: string list [@default []];
2297
  typ: vhdl_subtype_indication_t ;
2298
  init_val: vhdl_cst_val_t option [@default Some (CstInt 0)]}
2299

    
2300
let rec pp_vhdl_parameter_t :
2301
  Format.formatter -> vhdl_parameter_t -> Ppx_deriving_runtime.unit =
2302
  let __2 () = pp_vhdl_cst_val_t
2303
  
2304
  and __1 () = pp_vhdl_subtype_indication_t
2305
  
2306
  and __0 () = pp_vhdl_name_t
2307
   in
2308
  ((let open! Ppx_deriving_runtime in
2309
      fun fmt  ->
2310
        fun x  ->
2311
          Format.fprintf fmt "@[<2>{ ";
2312
          ((((Format.fprintf fmt "@[%s =@ " "names";
2313
              ((fun x  ->
2314
                  Format.fprintf fmt "@[<2>[";
2315
                  ignore
2316
                    (List.fold_left
2317
                       (fun sep  ->
2318
                          fun x  ->
2319
                            if sep then Format.fprintf fmt ";@ ";
2320
                            ((__0 ()) fmt) x;
2321
                            true) false x);
2322
                  Format.fprintf fmt "@,]@]")) x.names;
2323
              Format.fprintf fmt "@]");
2324
             Format.fprintf fmt ";@ ";
2325
             Format.fprintf fmt "@[%s =@ " "mode";
2326
             ((fun x  ->
2327
                 Format.fprintf fmt "@[<2>[";
2328
                 ignore
2329
                   (List.fold_left
2330
                      (fun sep  ->
2331
                         fun x  ->
2332
                           if sep then Format.fprintf fmt ";@ ";
2333
                           (Format.fprintf fmt "%S") x;
2334
                           true) false x);
2335
                 Format.fprintf fmt "@,]@]")) x.mode;
2336
             Format.fprintf fmt "@]");
2337
            Format.fprintf fmt ";@ ";
2338
            Format.fprintf fmt "@[%s =@ " "typ";
2339
            ((__1 ()) fmt) x.typ;
2340
            Format.fprintf fmt "@]");
2341
           Format.fprintf fmt ";@ ";
2342
           Format.fprintf fmt "@[%s =@ " "init_val";
2343
           ((function
2344
             | None  -> Format.pp_print_string fmt "None"
2345
             | Some x ->
2346
                 (Format.pp_print_string fmt "(Some ";
2347
                  ((__2 ()) fmt) x;
2348
                  Format.pp_print_string fmt ")"))) x.init_val;
2349
           Format.fprintf fmt "@]");
2350
          Format.fprintf fmt "@ }@]")
2351
    [@ocaml.warning "-A"])
2352

    
2353
and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string =
2354
  fun x  -> Format.asprintf "%a" pp_vhdl_parameter_t x
2355

    
2356
let rec (vhdl_parameter_t_to_yojson : vhdl_parameter_t -> Yojson.Safe.json) =
2357
  ((let open! Ppx_deriving_yojson_runtime in
2358
      fun x  ->
2359
        let fields = []  in
2360
        let fields =
2361
          if x.init_val = (Some (CstInt 0))
2362
          then fields
2363
          else
2364
            ("init_val",
2365
              (((function
2366
                 | None  -> `Null
2367
                 | Some x -> ((fun x  -> vhdl_cst_val_t_to_yojson x)) x))
2368
                 x.init_val))
2369
            :: fields
2370
           in
2371
        let fields =
2372
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
2373
          :: fields  in
2374
        let fields =
2375
          if x.mode = []
2376
          then fields
2377
          else
2378
            ("mode",
2379
              (((fun x  ->
2380
                   `List
2381
                     (List.map
2382
                        (fun (x : Ppx_deriving_runtime.string)  -> `String x)
2383
                        x))) x.mode))
2384
            :: fields
2385
           in
2386
        let fields =
2387
          ("names",
2388
            ((fun x  ->
2389
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
2390
               x.names))
2391
          :: fields  in
2392
        `Assoc fields)
2393
  [@ocaml.warning "-A"])
2394

    
2395
and (vhdl_parameter_t_of_yojson :
2396
      Yojson.Safe.json ->
2397
        vhdl_parameter_t Ppx_deriving_yojson_runtime.error_or)
2398
  =
2399
  ((let open! Ppx_deriving_yojson_runtime in
2400
      function
2401
      | `Assoc xs ->
2402
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2403
            match xs with
2404
            | ("names",x)::xs ->
2405
                loop xs
2406
                  (((function
2407
                     | `List xs ->
2408
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
2409
                     | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.names") x),
2410
                    arg1, arg2, arg3)
2411
            | ("mode",x)::xs ->
2412
                loop xs
2413
                  (arg0,
2414
                    ((function
2415
                      | `List xs ->
2416
                          map_bind
2417
                            (function
2418
                             | `String x -> Result.Ok x
2419
                             | _ ->
2420
                                 Result.Error
2421
                                   "Vhdl_ast.vhdl_parameter_t.mode") [] xs
2422
                      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.mode") x),
2423
                    arg2, arg3)
2424
            | ("typ",x)::xs ->
2425
                loop xs
2426
                  (arg0, arg1,
2427
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
2428
                    arg3)
2429
            | ("init_val",x)::xs ->
2430
                loop xs
2431
                  (arg0, arg1, arg2,
2432
                    ((function
2433
                      | `Null -> Result.Ok None
2434
                      | x ->
2435
                          ((fun x  -> vhdl_cst_val_t_of_yojson x) x) >>=
2436
                            ((fun x  -> Result.Ok (Some x)))) x))
2437
            | [] ->
2438
                arg3 >>=
2439
                  ((fun arg3  ->
2440
                      arg2 >>=
2441
                        (fun arg2  ->
2442
                           arg1 >>=
2443
                             (fun arg1  ->
2444
                                arg0 >>=
2445
                                  (fun arg0  ->
2446
                                     Result.Ok
2447
                                       {
2448
                                         names = arg0;
2449
                                         mode = arg1;
2450
                                         typ = arg2;
2451
                                         init_val = arg3
2452
                                       })))))
2453
            | _::xs -> loop xs _state  in
2454
          loop xs
2455
            ((Result.Error "Vhdl_ast.vhdl_parameter_t.names"),
2456
              (Result.Ok []), (Result.Error "Vhdl_ast.vhdl_parameter_t.typ"),
2457
              (Result.Ok (Some (CstInt 0))))
2458
      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t")
2459
  [@ocaml.warning "-A"])
2460

    
2461
type vhdl_subprogram_spec_t =
2462
  {
2463
  name: string [@default ""];
2464
  typeMark: vhdl_name_t [@default NoName];
2465
  parameters: vhdl_parameter_t list ;
2466
  isPure: bool [@default false]}
2467

    
2468
let rec pp_vhdl_subprogram_spec_t :
2469
  Format.formatter -> vhdl_subprogram_spec_t -> Ppx_deriving_runtime.unit =
2470
  let __1 () = pp_vhdl_parameter_t
2471
  
2472
  and __0 () = pp_vhdl_name_t
2473
   in
2474
  ((let open! Ppx_deriving_runtime in
2475
      fun fmt  ->
2476
        fun x  ->
2477
          Format.fprintf fmt "@[<2>{ ";
2478
          ((((Format.fprintf fmt "@[%s =@ " "name";
2479
              (Format.fprintf fmt "%S") x.name;
2480
              Format.fprintf fmt "@]");
2481
             Format.fprintf fmt ";@ ";
2482
             Format.fprintf fmt "@[%s =@ " "typeMark";
2483
             ((__0 ()) fmt) x.typeMark;
2484
             Format.fprintf fmt "@]");
2485
            Format.fprintf fmt ";@ ";
2486
            Format.fprintf fmt "@[%s =@ " "parameters";
2487
            ((fun x  ->
2488
                Format.fprintf fmt "@[<2>[";
2489
                ignore
2490
                  (List.fold_left
2491
                     (fun sep  ->
2492
                        fun x  ->
2493
                          if sep then Format.fprintf fmt ";@ ";
2494
                          ((__1 ()) fmt) x;
2495
                          true) false x);
2496
                Format.fprintf fmt "@,]@]")) x.parameters;
2497
            Format.fprintf fmt "@]");
2498
           Format.fprintf fmt ";@ ";
2499
           Format.fprintf fmt "@[%s =@ " "isPure";
2500
           (Format.fprintf fmt "%B") x.isPure;
2501
           Format.fprintf fmt "@]");
2502
          Format.fprintf fmt "@ }@]")
2503
    [@ocaml.warning "-A"])
2504

    
2505
and show_vhdl_subprogram_spec_t :
2506
  vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string =
2507
  fun x  -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x
2508

    
2509
let rec (vhdl_subprogram_spec_t_to_yojson :
2510
          vhdl_subprogram_spec_t -> Yojson.Safe.json)
2511
  =
2512
  ((let open! Ppx_deriving_yojson_runtime in
2513
      fun x  ->
2514
        let fields = []  in
2515
        let fields =
2516
          if x.isPure = false
2517
          then fields
2518
          else
2519
            ("isPure",
2520
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x)) x.isPure))
2521
            :: fields
2522
           in
2523
        let fields =
2524
          ("parameters",
2525
            ((fun x  ->
2526
                `List (List.map (fun x  -> vhdl_parameter_t_to_yojson x) x))
2527
               x.parameters))
2528
          :: fields  in
2529
        let fields =
2530
          if x.typeMark = NoName
2531
          then fields
2532
          else
2533
            ("typeMark", (((fun x  -> vhdl_name_t_to_yojson x)) x.typeMark))
2534
            :: fields
2535
           in
2536
        let fields =
2537
          if x.name = ""
2538
          then fields
2539
          else
2540
            ("name",
2541
              (((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x.name))
2542
            :: fields
2543
           in
2544
        `Assoc fields)
2545
  [@ocaml.warning "-A"])
2546

    
2547
and (vhdl_subprogram_spec_t_of_yojson :
2548
      Yojson.Safe.json ->
2549
        vhdl_subprogram_spec_t Ppx_deriving_yojson_runtime.error_or)
2550
  =
2551
  ((let open! Ppx_deriving_yojson_runtime in
2552
      function
2553
      | `Assoc xs ->
2554
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2555
            match xs with
2556
            | ("name",x)::xs ->
2557
                loop xs
2558
                  (((function
2559
                     | `String x -> Result.Ok x
2560
                     | _ ->
2561
                         Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.name")
2562
                      x), arg1, arg2, arg3)
2563
            | ("typeMark",x)::xs ->
2564
                loop xs
2565
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3)
2566
            | ("parameters",x)::xs ->
2567
                loop xs
2568
                  (arg0, arg1,
2569
                    ((function
2570
                      | `List xs ->
2571
                          map_bind (fun x  -> vhdl_parameter_t_of_yojson x)
2572
                            [] xs
2573
                      | _ ->
2574
                          Result.Error
2575
                            "Vhdl_ast.vhdl_subprogram_spec_t.parameters") x),
2576
                    arg3)
2577
            | ("isPure",x)::xs ->
2578
                loop xs
2579
                  (arg0, arg1, arg2,
2580
                    ((function
2581
                      | `Bool x -> Result.Ok x
2582
                      | _ ->
2583
                          Result.Error
2584
                            "Vhdl_ast.vhdl_subprogram_spec_t.isPure") x))
2585
            | [] ->
2586
                arg3 >>=
2587
                  ((fun arg3  ->
2588
                      arg2 >>=
2589
                        (fun arg2  ->
2590
                           arg1 >>=
2591
                             (fun arg1  ->
2592
                                arg0 >>=
2593
                                  (fun arg0  ->
2594
                                     Result.Ok
2595
                                       {
2596
                                         name = arg0;
2597
                                         typeMark = arg1;
2598
                                         parameters = arg2;
2599
                                         isPure = arg3
2600
                                       })))))
2601
            | _::xs -> loop xs _state  in
2602
          loop xs
2603
            ((Result.Ok ""), (Result.Ok NoName),
2604
              (Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.parameters"),
2605
              (Result.Ok false))
2606
      | _ -> Result.Error "Vhdl_ast.vhdl_subprogram_spec_t")
2607
  [@ocaml.warning "-A"])
2608

    
2609
let arith_funs = ["+"; "-"; "*"; "/"; "mod"; "rem"; "abs"; "**"; "&"] 
2610
let bool_funs = ["and"; "or"; "nand"; "nor"; "xor"; "not"] 
2611
let rel_funs =
2612
  ["<";
2613
  ">";
2614
  "<=";
2615
  ">=";
2616
  "/=";
2617
  "=";
2618
  "?=";
2619
  "?/=";
2620
  "?<";
2621
  "?<=";
2622
  "?>";
2623
  "?>=";
2624
  "??"] 
2625
let shift_funs = ["sll"; "srl"; "sla"; "sra"; "rol"; "ror"] 
2626
type vhdl_sequential_stmt_t =
2627
  | VarAssign of
2628
  {
2629
  label: vhdl_name_t [@default NoName];
2630
  lhs: vhdl_name_t ;
2631
  rhs: vhdl_expr_t } [@name "VARIABLE_ASSIGNMENT_STATEMENT"]
2632
  | SigSeqAssign of
2633
  {
2634
  label: vhdl_name_t [@default NoName];
2635
  lhs: vhdl_name_t ;
2636
  rhs: vhdl_expr_t list } [@name "SIGNAL_ASSIGNMENT_STATEMENT"]
2637
  | If of
2638
  {
2639
  label: vhdl_name_t [@default NoName];
2640
  if_cases: vhdl_if_case_t list ;
2641
  default: vhdl_sequential_stmt_t list [@default []]} [@name "IF_STATEMENT"]
2642
  | Case of
2643
  {
2644
  label: vhdl_name_t [@default NoName];
2645
  guard: vhdl_expr_t ;
2646
  branches: vhdl_case_item_t list } [@name "CASE_STATEMENT_TREE"]
2647
  | Exit of
2648
  {
2649
  label: vhdl_name_t [@default NoName];
2650
  loop_label: string option [@default Some ""];
2651
  condition: vhdl_expr_t option [@default Some IsNull]}
2652
  [@name "EXIT_STATEMENT"]
2653
  | Assert of
2654
  {
2655
  label: vhdl_name_t [@default NoName];
2656
  cond: vhdl_expr_t ;
2657
  report: vhdl_expr_t [@default IsNull];
2658
  severity: vhdl_expr_t [@default IsNull]} [@name "ASSERTION_STATEMENT"]
2659
  | Wait [@name "WAIT_STATEMENT"]
2660
  | Null of {
2661
  label: vhdl_name_t [@default NoName]} [@name "NULL_STATEMENT"]
2662
  | Return of {
2663
  label: vhdl_name_t [@default NoName]} [@name "RETURN_STATEMENT"]
2664
and vhdl_if_case_t =
2665
  {
2666
  if_cond: vhdl_expr_t ;
2667
  if_block: vhdl_sequential_stmt_t list }
2668
and vhdl_case_item_t =
2669
  {
2670
  when_cond: vhdl_expr_t list ;
2671
  when_stmt: vhdl_sequential_stmt_t list }
2672

    
2673
let rec pp_vhdl_sequential_stmt_t :
2674
  Format.formatter -> vhdl_sequential_stmt_t -> Ppx_deriving_runtime.unit =
2675
  let __19 () = pp_vhdl_name_t
2676
  
2677
  and __18 () = pp_vhdl_name_t
2678
  
2679
  and __17 () = pp_vhdl_expr_t
2680
  
2681
  and __16 () = pp_vhdl_expr_t
2682
  
2683
  and __15 () = pp_vhdl_expr_t
2684
  
2685
  and __14 () = pp_vhdl_name_t
2686
  
2687
  and __13 () = pp_vhdl_expr_t
2688
  
2689
  and __12 () = pp_vhdl_name_t
2690
  
2691
  and __11 () = pp_vhdl_case_item_t
2692
  
2693
  and __10 () = pp_vhdl_expr_t
2694
  
2695
  and __9 () = pp_vhdl_name_t
2696
  
2697
  and __8 () = pp_vhdl_sequential_stmt_t
2698
  
2699
  and __7 () = pp_vhdl_if_case_t
2700
  
2701
  and __6 () = pp_vhdl_name_t
2702
  
2703
  and __5 () = pp_vhdl_expr_t
2704
  
2705
  and __4 () = pp_vhdl_name_t
2706
  
2707
  and __3 () = pp_vhdl_name_t
2708
  
2709
  and __2 () = pp_vhdl_expr_t
2710
  
2711
  and __1 () = pp_vhdl_name_t
2712
  
2713
  and __0 () = pp_vhdl_name_t
2714
   in
2715
  ((let open! Ppx_deriving_runtime in
2716
      fun fmt  ->
2717
        function
2718
        | VarAssign { label = alabel; lhs = alhs; rhs = arhs } ->
2719
            (match alabel with
2720
              | NoName -> Format.fprintf fmt "";
2721
              | _ -> (((__0 ()) fmt) alabel;
2722
                     Format.fprintf fmt ":@ ")
2723
            );
2724
            Format.fprintf fmt "@[<2>";
2725
            ((__1 ()) fmt) alhs;
2726
            Format.fprintf fmt "@ :=@ ";
2727
            ((__2 ()) fmt) arhs;
2728
            Format.fprintf fmt "@]";
2729
(* TODO: Check
2730
            (Format.fprintf fmt "@[<2>VarAssign {@,";
2731
             (((Format.fprintf fmt "@[%s =@ " "label";
2732
                ((__0 ()) fmt) alabel;
2733
                Format.fprintf fmt "@]");
2734
               Format.fprintf fmt ";@ ";
2735
               Format.fprintf fmt "@[%s =@ " "lhs";
2736
               ((__1 ()) fmt) alhs;
2737
               Format.fprintf fmt "@]");
2738
              Format.fprintf fmt ";@ ";
2739
              Format.fprintf fmt "@[%s =@ " "rhs";
2740
              ((__2 ()) fmt) arhs;
2741
              Format.fprintf fmt "@]");
2742
             Format.fprintf fmt "@]}") *)
2743
        | SigSeqAssign { label = alabel; lhs = alhs; rhs = arhs } ->
2744
            (match alabel with
2745
              | NoName -> Format.fprintf fmt "";
2746
              | _ -> (((__3 ()) fmt) alabel;
2747
                     Format.fprintf fmt ":@ ")
2748
            );
2749
            Format.fprintf fmt "@[<2>";
2750
            ((__4 ()) fmt) alhs;
2751
            Format.fprintf fmt "@ <=@ ";
2752
            ((fun x  ->
2753
               Format.fprintf fmt "@[";
2754
               ignore
2755
                 (List.fold_left
2756
                   (fun sep  ->
2757
                     fun x  ->
2758
                       if sep then Format.fprintf fmt "";
2759
                        ((__5 ()) fmt) x;
2760
                        Format.fprintf fmt ";";
2761
                        true) false x);
2762
             Format.fprintf fmt "@]@]")) arhs;
2763
        | If { label = alabel; if_cases = aif_cases; default = adefault } ->
2764
            (match alabel with
2765
              | NoName -> Format.fprintf fmt "";
2766
              | _ -> (((__6 ()) fmt) alabel;
2767
                     Format.fprintf fmt ":@ ")
2768
            );
2769
            Format.fprintf fmt "@[<v>if";
2770
            ((fun x ->
2771
               ignore
2772
               (List.fold_left
2773
                 (fun sep  ->
2774
                   fun x  ->
2775
                           if sep then Format.fprintf fmt "@;elseif";
2776
                                ((__7 ()) fmt) x;
2777
                                true
2778
                 ) false x);
2779
             )) aif_cases;
2780
            Format.fprintf fmt "@]";
2781
            (match adefault with
2782
              | [] -> Format.fprintf fmt "";
2783
              | _  -> (Format.fprintf fmt "@;else";
2784
                      ((fun x  ->
2785
                          Format.fprintf fmt "@;<0 2>";
2786
                          ignore
2787
                            (List.fold_left
2788
                              (fun sep  ->
2789
                                fun x  ->
2790
                                        if sep then Format.fprintf fmt "";
2791
                          ((__8 ()) fmt) x;
2792
                          true) false x);
2793
             )) adefault;))
2794
        | Case { label = alabel; guard = aguard; branches = abranches } ->
2795
            (match alabel with
2796
              | NoName -> Format.fprintf fmt "";
2797
              | _ -> (((__9 ()) fmt) alabel;
2798
                     Format.fprintf fmt ":@ ")
2799
            );
2800
            Format.fprintf fmt "@[<v>case ";
2801
            ((__10 ()) fmt) aguard;
2802
            Format.fprintf fmt " is";
2803
            ((fun x  ->
2804
                ignore
2805
                  (List.fold_left
2806
                     (fun sep  ->
2807
                        fun x  ->
2808
                          if sep then Format.fprintf fmt "";
2809
                          ((__11 ()) fmt) x;
2810
                          true) false x);)) abranches;
2811
            Format.fprintf fmt "@]";
2812
        | Exit
2813
            { label = alabel; loop_label = aloop_label;
2814
              condition = acondition }
2815
            ->
2816
            (Format.fprintf fmt "@[<2>Exit {@,";
2817
             (((Format.fprintf fmt "@[%s =@ " "label";
2818
                ((__12 ()) fmt) alabel;
2819
                Format.fprintf fmt "@]");
2820
               Format.fprintf fmt ";@ ";
2821
               Format.fprintf fmt "@[%s =@ " "loop_label";
2822
               ((function
2823
                 | None  -> Format.pp_print_string fmt "None"
2824
                 | Some x ->
2825
                     (Format.pp_print_string fmt "(Some ";
2826
                      (Format.fprintf fmt "%S") x;
2827
                      Format.pp_print_string fmt ")"))) aloop_label;
2828
               Format.fprintf fmt "@]");
2829
              Format.fprintf fmt ";@ ";
2830
              Format.fprintf fmt "@[%s =@ " "condition";
2831
              ((function
2832
                | None  -> Format.pp_print_string fmt "None"
2833
                | Some x ->
2834
                    (Format.pp_print_string fmt "(Some ";
2835
                     ((__13 ()) fmt) x;
2836
                     Format.pp_print_string fmt ")"))) acondition;
2837
              Format.fprintf fmt "@]");
2838
             Format.fprintf fmt "@]}")
2839
        | Assert
2840
            { label = alabel; cond = acond; report = areport;
2841
              severity = aseverity }
2842
            ->
2843
            (Format.fprintf fmt "@[<2>Assert {@,";
2844
             ((((Format.fprintf fmt "@[%s =@ " "label";
2845
                 ((__14 ()) fmt) alabel;
2846
                 Format.fprintf fmt "@]");
2847
                Format.fprintf fmt ";@ ";
2848
                Format.fprintf fmt "@[%s =@ " "cond";
2849
                ((__15 ()) fmt) acond;
2850
                Format.fprintf fmt "@]");
2851
               Format.fprintf fmt ";@ ";
2852
               Format.fprintf fmt "@[%s =@ " "report";
2853
               ((__16 ()) fmt) areport;
2854
               Format.fprintf fmt "@]");
2855
              Format.fprintf fmt ";@ ";
2856
              Format.fprintf fmt "@[%s =@ " "severity";
2857
              ((__17 ()) fmt) aseverity;
2858
              Format.fprintf fmt "@]");
2859
             Format.fprintf fmt "@]}")
2860
        | Wait  -> Format.pp_print_string fmt "Wait"
2861
        | Null { label = alabel } ->
2862
            (Format.fprintf fmt "@[<2>Null {@,";
2863
             (Format.fprintf fmt "@[%s =@ " "label";
2864
              ((__18 ()) fmt) alabel;
2865
              Format.fprintf fmt "@]");
2866
             Format.fprintf fmt "@]}")
2867
        | Return { label = alabel } ->
2868
            (Format.fprintf fmt "@[<2>Return {@,";
2869
             (Format.fprintf fmt "@[%s =@ " "label";
2870
              ((__19 ()) fmt) alabel;
2871
              Format.fprintf fmt "@]");
2872
             Format.fprintf fmt "@]}"))
2873
    [@ocaml.warning "-A"])
2874

    
2875
and show_vhdl_sequential_stmt_t :
2876
  vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string =
2877
  fun x  -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x
2878

    
2879
(* Adapted *)
2880
and pp_vhdl_if_case_t :
2881
  Format.formatter -> vhdl_if_case_t -> Ppx_deriving_runtime.unit =
2882
  let __1 () = pp_vhdl_sequential_stmt_t
2883
  
2884
  and __0 () = pp_vhdl_expr_t
2885
   in
2886
  ((let open! Ppx_deriving_runtime in
2887
      fun fmt  ->
2888
        fun x  ->
2889
          Format.fprintf fmt " (";
2890
          ((__0 ()) fmt) x.if_cond;
2891
          Format.fprintf fmt ") then@;<0 2>";
2892
          ((fun x  ->
2893
             ignore
2894
               (List.fold_left
2895
                  (fun sep  ->
2896
                     fun x  ->
2897
                             if sep then Format.fprintf fmt "@;<0 2>";
2898
                       ((__1 ()) fmt) x;
2899
                       true) false x);
2900
          )) x.if_block;)
2901
    [@ocaml.warning "-A"])
2902

    
2903
and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string =
2904
  fun x  -> Format.asprintf "%a" pp_vhdl_if_case_t x
2905

    
2906
and pp_vhdl_case_item_t :
2907
  Format.formatter -> vhdl_case_item_t -> Ppx_deriving_runtime.unit =
2908
  let __1 () = pp_vhdl_sequential_stmt_t
2909
  
2910
  and __0 () = pp_vhdl_expr_t
2911
   in
2912
  ((let open! Ppx_deriving_runtime in
2913
      fun fmt  ->
2914
        fun x  ->
2915
                Format.fprintf fmt "@;<0 2>when ";
2916
            ((fun x  ->
2917
                ignore
2918
                  (List.fold_left
2919
                     (fun sep  ->
2920
                        fun x  ->
2921
                          if sep then Format.fprintf fmt "@ |@ ";
2922
                          ((__0 ()) fmt) x;
2923
                          true) false x);)) x.when_cond;
2924
           Format.fprintf fmt " => ";
2925
           ((fun x  ->
2926
               ignore
2927
                 (List.fold_left
2928
                    (fun sep  ->
2929
                       fun x  ->
2930
                         if sep then Format.fprintf fmt "";
2931
                         ((__1 ()) fmt) x;
2932
                         true) false x);)) x.when_stmt)
2933
    [@ocaml.warning "-A"])
2934

    
2935
and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string =
2936
  fun x  -> Format.asprintf "%a" pp_vhdl_case_item_t x
2937

    
2938
let rec (vhdl_sequential_stmt_t_to_yojson :
2939
          vhdl_sequential_stmt_t -> Yojson.Safe.json)
2940
  =
2941
  ((let open! Ppx_deriving_yojson_runtime in
2942
      function
2943
      | VarAssign arg0 ->
2944
          `List
2945
            [`String "VARIABLE_ASSIGNMENT_STATEMENT";
2946
            (let fields = []  in
2947
             let fields =
2948
               ("rhs", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.rhs)) ::
2949
               fields  in
2950
             let fields =
2951
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
2952
               fields  in
2953
             let fields =
2954
               if arg0.label = NoName
2955
               then fields
2956
               else
2957
                 ("label",
2958
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
2959
                 :: fields
2960
                in
2961
             `Assoc fields)]
2962
      | SigSeqAssign arg0 ->
2963
          `List
2964
            [`String "SIGNAL_ASSIGNMENT_STATEMENT";
2965
            (let fields = []  in
2966
             let fields =
2967
               ("rhs",
2968
                 ((fun x  ->
2969
                     `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
2970
                    arg0.rhs))
2971
               :: fields  in
2972
             let fields =
2973
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
2974
               fields  in
2975
             let fields =
2976
               if arg0.label = NoName
2977
               then fields
2978
               else
2979
                 ("label",
2980
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
2981
                 :: fields
2982
                in
2983
             `Assoc fields)]
2984
      | If arg0 ->
2985
          `List
2986
            [`String "IF_STATEMENT";
2987
            (let fields = []  in
2988
             let fields =
2989
               if arg0.default = []
2990
               then fields
2991
               else
2992
                 ("default",
2993
                   (((fun x  ->
2994
                        `List
2995
                          (List.map
2996
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
2997
                      arg0.default))
2998
                 :: fields
2999
                in
3000
             let fields =
3001
               ("if_cases",
3002
                 ((fun x  ->
3003
                     `List
3004
                       (List.map (fun x  -> vhdl_if_case_t_to_yojson x) x))
3005
                    arg0.if_cases))
3006
               :: fields  in
3007
             let fields =
3008
               if arg0.label = NoName
3009
               then fields
3010
               else
3011
                 ("label",
3012
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3013
                 :: fields
3014
                in
3015
             `Assoc fields)]
3016
      | Case arg0 ->
3017
          `List
3018
            [`String "CASE_STATEMENT_TREE";
3019
            (let fields = []  in
3020
             let fields =
3021
               ("branches",
3022
                 ((fun x  ->
3023
                     `List
3024
                       (List.map (fun x  -> vhdl_case_item_t_to_yojson x) x))
3025
                    arg0.branches))
3026
               :: fields  in
3027
             let fields =
3028
               ("guard", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.guard)) ::
3029
               fields  in
3030
             let fields =
3031
               if arg0.label = NoName
3032
               then fields
3033
               else
3034
                 ("label",
3035
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3036
                 :: fields
3037
                in
3038
             `Assoc fields)]
3039
      | Exit arg0 ->
3040
          `List
3041
            [`String "EXIT_STATEMENT";
3042
            (let fields = []  in
3043
             let fields =
3044
               if arg0.condition = (Some IsNull)
3045
               then fields
3046
               else
3047
                 ("condition",
3048
                   (((function
3049
                      | None  -> `Null
3050
                      | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
3051
                      arg0.condition))
3052
                 :: fields
3053
                in
3054
             let fields =
3055
               if arg0.loop_label = (Some "")
3056
               then fields
3057
               else
3058
                 ("loop_label",
3059
                   (((function
3060
                      | None  -> `Null
3061
                      | Some x ->
3062
                          ((fun (x : Ppx_deriving_runtime.string)  ->
3063
                              `String x)) x)) arg0.loop_label))
3064
                 :: fields
3065
                in
3066
             let fields =
3067
               if arg0.label = NoName
3068
               then fields
3069
               else
3070
                 ("label",
3071
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3072
                 :: fields
3073
                in
3074
             `Assoc fields)]
3075
      | Assert arg0 ->
3076
          `List
3077
            [`String "ASSERTION_STATEMENT";
3078
            (let fields = []  in
3079
             let fields =
3080
               if arg0.severity = IsNull
3081
               then fields
3082
               else
3083
                 ("severity",
3084
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.severity))
3085
                 :: fields
3086
                in
3087
             let fields =
3088
               if arg0.report = IsNull
3089
               then fields
3090
               else
3091
                 ("report",
3092
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.report))
3093
                 :: fields
3094
                in
3095
             let fields =
3096
               ("cond", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.cond)) ::
3097
               fields  in
3098
             let fields =
3099
               if arg0.label = NoName
3100
               then fields
3101
               else
3102
                 ("label",
3103
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3104
                 :: fields
3105
                in
3106
             `Assoc fields)]
3107
      | Wait  -> `List [`String "WAIT_STATEMENT"]
3108
      | Null arg0 ->
3109
          `List
3110
            [`String "NULL_STATEMENT";
3111
            (let fields = []  in
3112
             let fields =
3113
               if arg0.label = NoName
3114
               then fields
3115
               else
3116
                 ("label",
3117
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3118
                 :: fields
3119
                in
3120
             `Assoc fields)]
3121
      | Return arg0 ->
3122
          `List
3123
            [`String "RETURN_STATEMENT";
3124
            (let fields = []  in
3125
             let fields =
3126
               if arg0.label = NoName
3127
               then fields
3128
               else
3129
                 ("label",
3130
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3131
                 :: fields
3132
                in
3133
             `Assoc fields)])
3134
  [@ocaml.warning "-A"])
3135

    
3136
and (vhdl_sequential_stmt_t_of_yojson :
3137
      Yojson.Safe.json ->
3138
        vhdl_sequential_stmt_t Ppx_deriving_yojson_runtime.error_or)
3139
  =
3140
  ((let open! Ppx_deriving_yojson_runtime in
3141
      function
3142
      | `List ((`String "VARIABLE_ASSIGNMENT_STATEMENT")::arg0::[]) ->
3143
          ((function
3144
            | `Assoc xs ->
3145
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3146
                  match xs with
3147
                  | ("label",x)::xs ->
3148
                      loop xs
3149
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3150
                  | ("lhs",x)::xs ->
3151
                      loop xs
3152
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3153
                  | ("rhs",x)::xs ->
3154
                      loop xs
3155
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
3156
                  | [] ->
3157
                      arg2 >>=
3158
                        ((fun arg2  ->
3159
                            arg1 >>=
3160
                              (fun arg1  ->
3161
                                 arg0 >>=
3162
                                   (fun arg0  ->
3163
                                      Result.Ok
3164
                                        (VarAssign
3165
                                           {
3166
                                             label = arg0;
3167
                                             lhs = arg1;
3168
                                             rhs = arg2
3169
                                           })))))
3170
                  | _::xs -> loop xs _state  in
3171
                loop xs
3172
                  ((Result.Ok NoName),
3173
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
3174
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
3175
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3176
      | `List ((`String "SIGNAL_ASSIGNMENT_STATEMENT")::arg0::[]) ->
3177
          ((function
3178
            | `Assoc xs ->
3179
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3180
                  match xs with
3181
                  | ("label",x)::xs ->
3182
                      loop xs
3183
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3184
                  | ("lhs",x)::xs ->
3185
                      loop xs
3186
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3187
                  | ("rhs",x)::xs ->
3188
                      loop xs
3189
                        (arg0, arg1,
3190
                          ((function
3191
                            | `List xs ->
3192
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
3193
                                  [] xs
3194
                            | _ ->
3195
                                Result.Error
3196
                                  "Vhdl_ast.vhdl_sequential_stmt_t.rhs") x))
3197
                  | [] ->
3198
                      arg2 >>=
3199
                        ((fun arg2  ->
3200
                            arg1 >>=
3201
                              (fun arg1  ->
3202
                                 arg0 >>=
3203
                                   (fun arg0  ->
3204
                                      Result.Ok
3205
                                        (SigSeqAssign
3206
                                           {
3207
                                             label = arg0;
3208
                                             lhs = arg1;
3209
                                             rhs = arg2
3210
                                           })))))
3211
                  | _::xs -> loop xs _state  in
3212
                loop xs
3213
                  ((Result.Ok NoName),
3214
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
3215
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
3216
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3217
      | `List ((`String "IF_STATEMENT")::arg0::[]) ->
3218
          ((function
3219
            | `Assoc xs ->
3220
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3221
                  match xs with
3222
                  | ("label",x)::xs ->
3223
                      loop xs
3224
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3225
                  | ("if_cases",x)::xs ->
3226
                      loop xs
3227
                        (arg0,
3228
                          ((function
3229
                            | `List xs ->
3230
                                map_bind
3231
                                  (fun x  -> vhdl_if_case_t_of_yojson x) []
3232
                                  xs
3233
                            | _ ->
3234
                                Result.Error
3235
                                  "Vhdl_ast.vhdl_sequential_stmt_t.if_cases")
3236
                             x), arg2)
3237
                  | ("default",x)::xs ->
3238
                      loop xs
3239
                        (arg0, arg1,
3240
                          ((function
3241
                            | `List xs ->
3242
                                map_bind
3243
                                  (fun x  ->
3244
                                     vhdl_sequential_stmt_t_of_yojson x) []
3245
                                  xs
3246
                            | _ ->
3247
                                Result.Error
3248
                                  "Vhdl_ast.vhdl_sequential_stmt_t.default")
3249
                             x))
3250
                  | [] ->
3251
                      arg2 >>=
3252
                        ((fun arg2  ->
3253
                            arg1 >>=
3254
                              (fun arg1  ->
3255
                                 arg0 >>=
3256
                                   (fun arg0  ->
3257
                                      Result.Ok
3258
                                        (If
3259
                                           {
3260
                                             label = arg0;
3261
                                             if_cases = arg1;
3262
                                             default = arg2
3263
                                           })))))
3264
                  | _::xs -> loop xs _state  in
3265
                loop xs
3266
                  ((Result.Ok NoName),
3267
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.if_cases"),
3268
                    (Result.Ok []))
3269
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3270
      | `List ((`String "CASE_STATEMENT_TREE")::arg0::[]) ->
3271
          ((function
3272
            | `Assoc xs ->
3273
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3274
                  match xs with
3275
                  | ("label",x)::xs ->
3276
                      loop xs
3277
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3278
                  | ("guard",x)::xs ->
3279
                      loop xs
3280
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
3281
                  | ("branches",x)::xs ->
3282
                      loop xs
3283
                        (arg0, arg1,
3284
                          ((function
3285
                            | `List xs ->
3286
                                map_bind
3287
                                  (fun x  -> vhdl_case_item_t_of_yojson x) []
3288
                                  xs
3289
                            | _ ->
3290
                                Result.Error
3291
                                  "Vhdl_ast.vhdl_sequential_stmt_t.branches")
3292
                             x))
3293
                  | [] ->
3294
                      arg2 >>=
3295
                        ((fun arg2  ->
3296
                            arg1 >>=
3297
                              (fun arg1  ->
3298
                                 arg0 >>=
3299
                                   (fun arg0  ->
3300
                                      Result.Ok
3301
                                        (Case
3302
                                           {
3303
                                             label = arg0;
3304
                                             guard = arg1;
3305
                                             branches = arg2
3306
                                           })))))
3307
                  | _::xs -> loop xs _state  in
3308
                loop xs
3309
                  ((Result.Ok NoName),
3310
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.guard"),
3311
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.branches"))
3312
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3313
      | `List ((`String "EXIT_STATEMENT")::arg0::[]) ->
3314
          ((function
3315
            | `Assoc xs ->
3316
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3317
                  match xs with
3318
                  | ("label",x)::xs ->
3319
                      loop xs
3320
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3321
                  | ("loop_label",x)::xs ->
3322
                      loop xs
3323
                        (arg0,
3324
                          ((function
3325
                            | `Null -> Result.Ok None
3326
                            | x ->
3327
                                ((function
3328
                                  | `String x -> Result.Ok x
3329
                                  | _ ->
3330
                                      Result.Error
3331
                                        "Vhdl_ast.vhdl_sequential_stmt_t.loop_label")
3332
                                   x)
3333
                                  >>= ((fun x  -> Result.Ok (Some x)))) x),
3334
                          arg2)
3335
                  | ("condition",x)::xs ->
3336
                      loop xs
3337
                        (arg0, arg1,
3338
                          ((function
3339
                            | `Null -> Result.Ok None
3340
                            | x ->
3341
                                ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
3342
                                  ((fun x  -> Result.Ok (Some x)))) x))
3343
                  | [] ->
3344
                      arg2 >>=
3345
                        ((fun arg2  ->
3346
                            arg1 >>=
3347
                              (fun arg1  ->
3348
                                 arg0 >>=
3349
                                   (fun arg0  ->
3350
                                      Result.Ok
3351
                                        (Exit
3352
                                           {
3353
                                             label = arg0;
3354
                                             loop_label = arg1;
3355
                                             condition = arg2
3356
                                           })))))
3357
                  | _::xs -> loop xs _state  in
3358
                loop xs
3359
                  ((Result.Ok NoName), (Result.Ok (Some "")),
3360
                    (Result.Ok (Some IsNull)))
3361
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3362
      | `List ((`String "ASSERTION_STATEMENT")::arg0::[]) ->
3363
          ((function
3364
            | `Assoc xs ->
3365
                let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
3366
                  match xs with
3367
                  | ("label",x)::xs ->
3368
                      loop xs
3369
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2,
3370
                          arg3)
3371
                  | ("cond",x)::xs ->
3372
                      loop xs
3373
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2,
3374
                          arg3)
3375
                  | ("report",x)::xs ->
3376
                      loop xs
3377
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x),
3378
                          arg3)
3379
                  | ("severity",x)::xs ->
3380
                      loop xs
3381
                        (arg0, arg1, arg2,
3382
                          ((fun x  -> vhdl_expr_t_of_yojson x) x))
3383
                  | [] ->
3384
                      arg3 >>=
3385
                        ((fun arg3  ->
3386
                            arg2 >>=
3387
                              (fun arg2  ->
3388
                                 arg1 >>=
3389
                                   (fun arg1  ->
3390
                                      arg0 >>=
3391
                                        (fun arg0  ->
3392
                                           Result.Ok
3393
                                             (Assert
3394
                                                {
3395
                                                  label = arg0;
3396
                                                  cond = arg1;
3397
                                                  report = arg2;
3398
                                                  severity = arg3
3399
                                                }))))))
3400
                  | _::xs -> loop xs _state  in
3401
                loop xs
3402
                  ((Result.Ok NoName),
3403
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.cond"),
3404
                    (Result.Ok IsNull), (Result.Ok IsNull))
3405
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3406
      | `List ((`String "WAIT_STATEMENT")::[]) -> Result.Ok Wait
3407
      | `List ((`String "NULL_STATEMENT")::arg0::[]) ->
3408
          ((function
3409
            | `Assoc xs ->
3410
                let rec loop xs (arg0 as _state) =
3411
                  match xs with
3412
                  | ("label",x)::xs ->
3413
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
3414
                  | [] ->
3415
                      arg0 >>=
3416
                        ((fun arg0  -> Result.Ok (Null { label = arg0 })))
3417
                  | _::xs -> loop xs _state  in
3418
                loop xs (Result.Ok NoName)
3419
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3420
      | `List ((`String "RETURN_STATEMENT")::arg0::[]) ->
3421
          ((function
3422
            | `Assoc xs ->
3423
                let rec loop xs (arg0 as _state) =
3424
                  match xs with
3425
                  | ("label",x)::xs ->
3426
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
3427
                  | [] ->
3428
                      arg0 >>=
3429
                        ((fun arg0  -> Result.Ok (Return { label = arg0 })))
3430
                  | _::xs -> loop xs _state  in
3431
                loop xs (Result.Ok NoName)
3432
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3433
      | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")
3434
  [@ocaml.warning "-A"])
3435

    
3436
and (vhdl_if_case_t_to_yojson : vhdl_if_case_t -> Yojson.Safe.json) =
3437
  ((let open! Ppx_deriving_yojson_runtime in
3438
      fun x  ->
3439
        let fields = []  in
3440
        let fields =
3441
          ("if_block",
3442
            ((fun x  ->
3443
                `List
3444
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3445
               x.if_block))
3446
          :: fields  in
3447
        let fields =
3448
          ("if_cond", ((fun x  -> vhdl_expr_t_to_yojson x) x.if_cond)) ::
3449
          fields  in
3450
        `Assoc fields)
3451
  [@ocaml.warning "-A"])
3452

    
3453
and (vhdl_if_case_t_of_yojson :
3454
      Yojson.Safe.json -> vhdl_if_case_t Ppx_deriving_yojson_runtime.error_or)
3455
  =
3456
  ((let open! Ppx_deriving_yojson_runtime in
3457
      function
3458
      | `Assoc xs ->
3459
          let rec loop xs ((arg0,arg1) as _state) =
3460
            match xs with
3461
            | ("if_cond",x)::xs ->
3462
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
3463
            | ("if_block",x)::xs ->
3464
                loop xs
3465
                  (arg0,
3466
                    ((function
3467
                      | `List xs ->
3468
                          map_bind
3469
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3470
                            xs
3471
                      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t.if_block")
3472
                       x))
3473
            | [] ->
3474
                arg1 >>=
3475
                  ((fun arg1  ->
3476
                      arg0 >>=
3477
                        (fun arg0  ->
3478
                           Result.Ok { if_cond = arg0; if_block = arg1 })))
3479
            | _::xs -> loop xs _state  in
3480
          loop xs
3481
            ((Result.Error "Vhdl_ast.vhdl_if_case_t.if_cond"),
3482
              (Result.Error "Vhdl_ast.vhdl_if_case_t.if_block"))
3483
      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t")
3484
  [@ocaml.warning "-A"])
3485

    
3486
and (vhdl_case_item_t_to_yojson : vhdl_case_item_t -> Yojson.Safe.json) =
3487
  ((let open! Ppx_deriving_yojson_runtime in
3488
      fun x  ->
3489
        let fields = []  in
3490
        let fields =
3491
          ("when_stmt",
3492
            ((fun x  ->
3493
                `List
3494
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3495
               x.when_stmt))
3496
          :: fields  in
3497
        let fields =
3498
          ("when_cond",
3499
            ((fun x  ->
3500
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
3501
               x.when_cond))
3502
          :: fields  in
3503
        `Assoc fields)
3504
  [@ocaml.warning "-A"])
3505

    
3506
and (vhdl_case_item_t_of_yojson :
3507
      Yojson.Safe.json ->
3508
        vhdl_case_item_t Ppx_deriving_yojson_runtime.error_or)
3509
  =
3510
  ((let open! Ppx_deriving_yojson_runtime in
3511
      function
3512
      | `Assoc xs ->
3513
          let rec loop xs ((arg0,arg1) as _state) =
3514
            match xs with
3515
            | ("when_cond",x)::xs ->
3516
                loop xs
3517
                  (((function
3518
                     | `List xs ->
3519
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
3520
                     | _ ->
3521
                         Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond")
3522
                      x), arg1)
3523
            | ("when_stmt",x)::xs ->
3524
                loop xs
3525
                  (arg0,
3526
                    ((function
3527
                      | `List xs ->
3528
                          map_bind
3529
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3530
                            xs
3531
                      | _ ->
3532
                          Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt")
3533
                       x))
3534
            | [] ->
3535
                arg1 >>=
3536
                  ((fun arg1  ->
3537
                      arg0 >>=
3538
                        (fun arg0  ->
3539
                           Result.Ok { when_cond = arg0; when_stmt = arg1 })))
3540
            | _::xs -> loop xs _state  in
3541
          loop xs
3542
            ((Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond"),
3543
              (Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt"))
3544
      | _ -> Result.Error "Vhdl_ast.vhdl_case_item_t")
3545
  [@ocaml.warning "-A"])
3546

    
3547
type vhdl_declaration_t =
3548
  | VarDecl of
3549
  {
3550
  names: vhdl_name_t list ;
3551
  typ: vhdl_subtype_indication_t ;
3552
  init_val: vhdl_cst_val_t option [@default Some (CstInt 0)]}
3553
  [@name "VARIABLE_DECLARATION"]
3554
  | CstDecl of
3555
  {
3556
  names: vhdl_name_t list ;
3557
  typ: vhdl_subtype_indication_t ;
3558
  init_val: vhdl_cst_val_t } [@name "CONSTANT_DECLARATION"]
3559
  | SigDecl of
3560
  {
3561
  names: vhdl_name_t list ;
3562
  typ: vhdl_subtype_indication_t ;
3563
  init_val: vhdl_cst_val_t option [@default Some (CstInt 0)]}
3564
  [@name "SIGNAL_DECLARATION"]
3565
  | Subprogram of
3566
  {
3567
  name: vhdl_name_t [@default NoName];
3568
  kind: string [@default ""];
3569
  spec: vhdl_subprogram_spec_t
3570
    [@default
3571
      { name = ""; typeMark = NoName; parameters = []; isPure = false }];
3572
  decl_part: vhdl_declaration_t list [@default []];
3573
  stmts: vhdl_sequential_stmt_t list [@default []]} [@name "SUBPROGRAM_BODY"]
3574

    
3575
(* Needs adaptation for: SubProgram *)
3576
let rec pp_vhdl_declaration_t :
3577
  Format.formatter -> vhdl_declaration_t -> Ppx_deriving_runtime.unit =
3578
  let __12 () = pp_vhdl_sequential_stmt_t
3579
  
3580
  and __11 () = pp_vhdl_declaration_t
3581
  
3582
  and __10 () = pp_vhdl_subprogram_spec_t
3583
  
3584
  and __9 () = pp_vhdl_name_t
3585
  
3586
  and __8 () = pp_vhdl_cst_val_t
3587
  
3588
  and __7 () = pp_vhdl_subtype_indication_t
3589
  
3590
  and __6 () = pp_vhdl_name_t
3591
  
3592
  and __5 () = pp_vhdl_cst_val_t
3593
  
3594
  and __4 () = pp_vhdl_subtype_indication_t
3595
  
3596
  and __3 () = pp_vhdl_name_t
3597
  
3598
  and __2 () = pp_vhdl_cst_val_t
3599
  
3600
  and __1 () = pp_vhdl_subtype_indication_t
3601
  
3602
  and __0 () = pp_vhdl_name_t
3603
   in
3604
  ((let open! Ppx_deriving_runtime in
3605
      fun fmt  ->
3606
        function
3607
        | VarDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3608
            (Format.fprintf fmt "@[<2>variable@ ";
3609
             ((((fun x  ->
3610
                    ignore
3611
                      (List.fold_left
3612
                         (fun sep  ->
3613
                            fun x  ->
3614
                              if sep then Format.fprintf fmt ",";
3615
                              ((__0 ()) fmt) x;
3616
                              true) false x);)) anames;
3617
               Format.fprintf fmt "@ :@ ";
3618
               ((__1 ()) fmt) atyp;
3619
              ((function
3620
                | None  -> Format.pp_print_string fmt ""
3621
                | Some x ->
3622
                    (Format.fprintf fmt ":=";
3623
                     ((__2 ()) fmt) x;))) ainit_val;
3624
              Format.fprintf fmt "@]");
3625
            ))
3626
        | CstDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3627
            (Format.fprintf fmt "@[<2>constant@ ";
3628
             ((((fun x  ->
3629
                    ignore
3630
                      (List.fold_left
3631
                         (fun sep  ->
3632
                            fun x  ->
3633
                              if sep then Format.fprintf fmt ",";
3634
                              ((__3 ()) fmt) x;
3635
                              true) false x);)) anames;
3636
               Format.fprintf fmt "@ :@ ";
3637
               ((__4 ()) fmt) atyp;
3638
              Format.fprintf fmt ":=";
3639
              ((__5 ()) fmt) ainit_val;
3640
              Format.fprintf fmt "@]");
3641
             ))
3642
        | SigDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3643
            (Format.fprintf fmt "@[<2>signal@ ";
3644
            ((fun x  ->
3645
              ignore
3646
              (List.fold_left
3647
                (fun sep  ->
3648
                  fun x  ->
3649
                    if sep then Format.fprintf fmt ",";
3650
                                ((__6 ()) fmt) x;
3651
                                true) false x);
3652
              )) anames;
3653
            Format.fprintf fmt "@ :@ ";
3654
            ((__7 ()) fmt) atyp;
3655
            (function
3656
              | None  -> Format.pp_print_string fmt ""
3657
              | Some x ->
3658
                  (Format.fprintf fmt ":=";
3659
                  ((__8 ()) fmt) x;)
3660
            ) ainit_val;
3661
            Format.fprintf fmt "@]";
3662
            )
3663
        | Subprogram
3664
            { name = aname; kind = akind; spec = aspec;
3665
              decl_part = adecl_part; stmts = astmts }
3666
            ->
3667
            (Format.fprintf fmt "@[<2>Subprogram {@,";
3668
             (((((Format.fprintf fmt "@[%s =@ " "name";
3669
                  ((__9 ()) fmt) aname;
3670
                  Format.fprintf fmt "@]");
3671
                 Format.fprintf fmt ";@ ";
3672
                 Format.fprintf fmt "@[%s =@ " "kind";
3673
                 (Format.fprintf fmt "%S") akind;
3674
                 Format.fprintf fmt "@]");
3675
                Format.fprintf fmt ";@ ";
3676
                Format.fprintf fmt "@[%s =@ " "spec";
3677
                ((__10 ()) fmt) aspec;
3678
                Format.fprintf fmt "@]");
3679
               Format.fprintf fmt ";@ ";
3680
               Format.fprintf fmt "@[%s =@ " "decl_part";
3681
               ((fun x  ->
3682
                   Format.fprintf fmt "@[<2>[";
3683
                   ignore
3684
                     (List.fold_left
3685
                        (fun sep  ->
3686
                           fun x  ->
3687
                             if sep then Format.fprintf fmt ";@ ";
3688
                             ((__11 ()) fmt) x;
3689
                             true) false x);
3690
                   Format.fprintf fmt "@,]@]")) adecl_part;
3691
               Format.fprintf fmt "@]");
3692
              Format.fprintf fmt ";@ ";
3693
              Format.fprintf fmt "@[%s =@ " "stmts";
3694
              ((fun x  ->
3695
                  Format.fprintf fmt "@[<2>[";
3696
                  ignore
3697
                    (List.fold_left
3698
                       (fun sep  ->
3699
                          fun x  ->
3700
                            if sep then Format.fprintf fmt ";@ ";
3701
                            ((__12 ()) fmt) x;
3702
                            true) false x);
3703
                  Format.fprintf fmt "@,]@]")) astmts;
3704
              Format.fprintf fmt "@]");
3705
             Format.fprintf fmt "@]}"))
3706
    [@ocaml.warning "-A"])
3707

    
3708
and show_vhdl_declaration_t :
3709
  vhdl_declaration_t -> Ppx_deriving_runtime.string =
3710
  fun x  -> Format.asprintf "%a" pp_vhdl_declaration_t x
3711

    
3712
let rec (vhdl_declaration_t_to_yojson :
3713
          vhdl_declaration_t -> Yojson.Safe.json)
3714
  =
3715
  ((let open! Ppx_deriving_yojson_runtime in
3716
      function
3717
      | VarDecl arg0 ->
3718
          `List
3719
            [`String "VARIABLE_DECLARATION";
3720
            (let fields = []  in
3721
             let fields =
3722
               if arg0.init_val = (Some (CstInt 0))
3723
               then fields
3724
               else
3725
                 ("init_val",
3726
                   (((function
3727
                      | None  -> `Null
3728
                      | Some x -> ((fun x  -> vhdl_cst_val_t_to_yojson x)) x))
3729
                      arg0.init_val))
3730
                 :: fields
3731
                in
3732
             let fields =
3733
               ("typ",
3734
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
3735
               :: fields  in
3736
             let fields =
3737
               ("names",
3738
                 ((fun x  ->
3739
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
3740
                    arg0.names))
3741
               :: fields  in
3742
             `Assoc fields)]
3743
      | CstDecl arg0 ->
3744
          `List
3745
            [`String "CONSTANT_DECLARATION";
3746
            (let fields = []  in
3747
             let fields =
3748
               ("init_val",
3749
                 ((fun x  -> vhdl_cst_val_t_to_yojson x) arg0.init_val))
3750
               :: fields  in
3751
             let fields =
3752
               ("typ",
3753
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
3754
               :: fields  in
3755
             let fields =
3756
               ("names",
3757
                 ((fun x  ->
3758
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
3759
                    arg0.names))
3760
               :: fields  in
3761
             `Assoc fields)]
3762
      | SigDecl arg0 ->
3763
          `List
3764
            [`String "SIGNAL_DECLARATION";
3765
            (let fields = []  in
3766
             let fields =
3767
               if arg0.init_val = (Some (CstInt 0))
3768
               then fields
3769
               else
3770
                 ("init_val",
3771
                   (((function
3772
                      | None  -> `Null
3773
                      | Some x -> ((fun x  -> vhdl_cst_val_t_to_yojson x)) x))
3774
                      arg0.init_val))
3775
                 :: fields
3776
                in
3777
             let fields =
3778
               ("typ",
3779
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
3780
               :: fields  in
3781
             let fields =
3782
               ("names",
3783
                 ((fun x  ->
3784
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
3785
                    arg0.names))
3786
               :: fields  in
3787
             `Assoc fields)]
3788
      | Subprogram arg0 ->
3789
          `List
3790
            [`String "SUBPROGRAM_BODY";
3791
            (let fields = []  in
3792
             let fields =
3793
               if arg0.stmts = []
3794
               then fields
3795
               else
3796
                 ("stmts",
3797
                   (((fun x  ->
3798
                        `List
3799
                          (List.map
3800
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
3801
                      arg0.stmts))
3802
                 :: fields
3803
                in
3804
             let fields =
3805
               if arg0.decl_part = []
3806
               then fields
3807
               else
3808
                 ("decl_part",
3809
                   (((fun x  ->
3810
                        `List
3811
                          (List.map
3812
                             (fun x  -> vhdl_declaration_t_to_yojson x) x)))
3813
                      arg0.decl_part))
3814
                 :: fields
3815
                in
3816
             let fields =
3817
               if
3818
                 arg0.spec =
3819
                   {
3820
                     name = "";
3821
                     typeMark = NoName;
3822
                     parameters = [];
3823
                     isPure = false
3824
                   }
3825
               then fields
3826
               else
3827
                 ("spec",
3828
                   (((fun x  -> vhdl_subprogram_spec_t_to_yojson x))
3829
                      arg0.spec))
3830
                 :: fields
3831
                in
3832
             let fields =
3833
               if arg0.kind = ""
3834
               then fields
3835
               else
3836
                 ("kind",
3837
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
3838
                      arg0.kind))
3839
                 :: fields
3840
                in
3841
             let fields =
3842
               if arg0.name = NoName
3843
               then fields
3844
               else
3845
                 ("name", (((fun x  -> vhdl_name_t_to_yojson x)) arg0.name))
3846
                 :: fields
3847
                in
3848
             `Assoc fields)])
3849
  [@ocaml.warning "-A"])
3850

    
3851
and (vhdl_declaration_t_of_yojson :
3852
      Yojson.Safe.json ->
3853
        vhdl_declaration_t Ppx_deriving_yojson_runtime.error_or)
3854
  =
3855
  ((let open! Ppx_deriving_yojson_runtime in
3856
      function
3857
      | `List ((`String "VARIABLE_DECLARATION")::arg0::[]) ->
3858
          ((function
3859
            | `Assoc xs ->
3860
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3861
                  match xs with
3862
                  | ("names",x)::xs ->
3863
                      loop xs
3864
                        (((function
3865
                           | `List xs ->
3866
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
3867
                                 [] xs
3868
                           | _ ->
3869
                               Result.Error
3870
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
3871
                          arg1, arg2)
3872
                  | ("typ",x)::xs ->
3873
                      loop xs
3874
                        (arg0,
3875
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
3876
                             x), arg2)
3877
                  | ("init_val",x)::xs ->
3878
                      loop xs
3879
                        (arg0, arg1,
3880
                          ((function
3881
                            | `Null -> Result.Ok None
3882
                            | x ->
3883
                                ((fun x  -> vhdl_cst_val_t_of_yojson x) x)
3884
                                  >>= ((fun x  -> Result.Ok (Some x)))) x))
3885
                  | [] ->
3886
                      arg2 >>=
3887
                        ((fun arg2  ->
3888
                            arg1 >>=
3889
                              (fun arg1  ->
3890
                                 arg0 >>=
3891
                                   (fun arg0  ->
3892
                                      Result.Ok
3893
                                        (VarDecl
3894
                                           {
3895
                                             names = arg0;
3896
                                             typ = arg1;
3897
                                             init_val = arg2
3898
                                           })))))
3899
                  | _::xs -> loop xs _state  in
3900
                loop xs
3901
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
3902
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
3903
                    (Result.Ok (Some (CstInt 0))))
3904
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
3905
      | `List ((`String "CONSTANT_DECLARATION")::arg0::[]) ->
3906
          ((function
3907
            | `Assoc xs ->
3908
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3909
                  match xs with
3910
                  | ("names",x)::xs ->
3911
                      loop xs
3912
                        (((function
3913
                           | `List xs ->
3914
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
3915
                                 [] xs
3916
                           | _ ->
3917
                               Result.Error
3918
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
3919
                          arg1, arg2)
3920
                  | ("typ",x)::xs ->
3921
                      loop xs
3922
                        (arg0,
3923
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
3924
                             x), arg2)
3925
                  | ("init_val",x)::xs ->
3926
                      loop xs
3927
                        (arg0, arg1,
3928
                          ((fun x  -> vhdl_cst_val_t_of_yojson x) x))
3929
                  | [] ->
3930
                      arg2 >>=
3931
                        ((fun arg2  ->
3932
                            arg1 >>=
3933
                              (fun arg1  ->
3934
                                 arg0 >>=
3935
                                   (fun arg0  ->
3936
                                      Result.Ok
3937
                                        (CstDecl
3938
                                           {
3939
                                             names = arg0;
3940
                                             typ = arg1;
3941
                                             init_val = arg2
3942
                                           })))))
3943
                  | _::xs -> loop xs _state  in
3944
                loop xs
3945
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
3946
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
3947
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.init_val"))
3948
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
3949
      | `List ((`String "SIGNAL_DECLARATION")::arg0::[]) ->
3950
          ((function
3951
            | `Assoc xs ->
3952
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3953
                  match xs with
3954
                  | ("names",x)::xs ->
3955
                      loop xs
3956
                        (((function
3957
                           | `List xs ->
3958
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
3959
                                 [] xs
3960
                           | _ ->
3961
                               Result.Error
3962
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
3963
                          arg1, arg2)
3964
                  | ("typ",x)::xs ->
3965
                      loop xs
3966
                        (arg0,
3967
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
3968
                             x), arg2)
3969
                  | ("init_val",x)::xs ->
3970
                      loop xs
3971
                        (arg0, arg1,
3972
                          ((function
3973
                            | `Null -> Result.Ok None
3974
                            | x ->
3975
                                ((fun x  -> vhdl_cst_val_t_of_yojson x) x)
3976
                                  >>= ((fun x  -> Result.Ok (Some x)))) x))
3977
                  | [] ->
3978
                      arg2 >>=
3979
                        ((fun arg2  ->
3980
                            arg1 >>=
3981
                              (fun arg1  ->
3982
                                 arg0 >>=
3983
                                   (fun arg0  ->
3984
                                      Result.Ok
3985
                                        (SigDecl
3986
                                           {
3987
                                             names = arg0;
3988
                                             typ = arg1;
3989
                                             init_val = arg2
3990
                                           })))))
3991
                  | _::xs -> loop xs _state  in
3992
                loop xs
3993
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
3994
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
3995
                    (Result.Ok (Some (CstInt 0))))
3996
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
3997
      | `List ((`String "SUBPROGRAM_BODY")::arg0::[]) ->
3998
          ((function
3999
            | `Assoc xs ->
4000
                let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
4001
                  match xs with
4002
                  | ("name",x)::xs ->
4003
                      loop xs
4004
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2,
4005
                          arg3, arg4)
4006
                  | ("kind",x)::xs ->
4007
                      loop xs
4008
                        (arg0,
4009
                          ((function
4010
                            | `String x -> Result.Ok x
4011
                            | _ ->
4012
                                Result.Error
4013
                                  "Vhdl_ast.vhdl_declaration_t.kind") x),
4014
                          arg2, arg3, arg4)
4015
                  | ("spec",x)::xs ->
4016
                      loop xs
4017
                        (arg0, arg1,
4018
                          ((fun x  -> vhdl_subprogram_spec_t_of_yojson x) x),
4019
                          arg3, arg4)
4020
                  | ("decl_part",x)::xs ->
4021
                      loop xs
4022
                        (arg0, arg1, arg2,
4023
                          ((function
4024
                            | `List xs ->
4025
                                map_bind
4026
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4027
                                  [] xs
4028
                            | _ ->
4029
                                Result.Error
4030
                                  "Vhdl_ast.vhdl_declaration_t.decl_part") x),
4031
                          arg4)
4032
                  | ("stmts",x)::xs ->
4033
                      loop xs
4034
                        (arg0, arg1, arg2, arg3,
4035
                          ((function
4036
                            | `List xs ->
4037
                                map_bind
4038
                                  (fun x  ->
4039
                                     vhdl_sequential_stmt_t_of_yojson x) []
4040
                                  xs
4041
                            | _ ->
4042
                                Result.Error
4043
                                  "Vhdl_ast.vhdl_declaration_t.stmts") x))
4044
                  | [] ->
4045
                      arg4 >>=
4046
                        ((fun arg4  ->
4047
                            arg3 >>=
4048
                              (fun arg3  ->
4049
                                 arg2 >>=
4050
                                   (fun arg2  ->
4051
                                      arg1 >>=
4052
                                        (fun arg1  ->
4053
                                           arg0 >>=
4054
                                             (fun arg0  ->
4055
                                                Result.Ok
4056
                                                  (Subprogram
4057
                                                     {
4058
                                                       name = arg0;
4059
                                                       kind = arg1;
4060
                                                       spec = arg2;
4061
                                                       decl_part = arg3;
4062
                                                       stmts = arg4
4063
                                                     })))))))
4064
                  | _::xs -> loop xs _state  in
4065
                loop xs
4066
                  ((Result.Ok NoName), (Result.Ok ""),
4067
                    (Result.Ok
4068
                       {
4069
                         name = "";
4070
                         typeMark = NoName;
4071
                         parameters = [];
4072
                         isPure = false
4073
                       }), (Result.Ok []), (Result.Ok []))
4074
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4075
      | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")
4076
  [@ocaml.warning "-A"])
4077

    
4078
type vhdl_signal_condition_t =
4079
  {
4080
  expr: vhdl_expr_t list ;
4081
  cond: vhdl_expr_t [@default IsNull]}
4082

    
4083
let rec pp_vhdl_signal_condition_t :
4084
  Format.formatter -> vhdl_signal_condition_t -> Ppx_deriving_runtime.unit =
4085
  let __1 () = pp_vhdl_expr_t
4086
  
4087
  and __0 () = pp_vhdl_expr_t
4088
   in
4089
  ((let open! Ppx_deriving_runtime in
4090
      fun fmt  ->
4091
        fun x  ->
4092
          Format.fprintf fmt "@[<2>{ ";
4093
          ((Format.fprintf fmt "@[%s =@ " "expr";
4094
            ((fun x  ->
4095
                Format.fprintf fmt "@[<2>[";
4096
                ignore
4097
                  (List.fold_left
4098
                     (fun sep  ->
4099
                        fun x  ->
4100
                          if sep then Format.fprintf fmt ";@ ";
4101
                          ((__0 ()) fmt) x;
4102
                          true) false x);
4103
                Format.fprintf fmt "@,]@]")) x.expr;
4104
            Format.fprintf fmt "@]");
4105
           Format.fprintf fmt ";@ ";
4106
           Format.fprintf fmt "@[%s =@ " "cond";
4107
           ((__1 ()) fmt) x.cond;
4108
           Format.fprintf fmt "@]");
4109
          Format.fprintf fmt "@ }@]")
4110
    [@ocaml.warning "-A"])
4111

    
4112
and show_vhdl_signal_condition_t :
4113
  vhdl_signal_condition_t -> Ppx_deriving_runtime.string =
4114
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_condition_t x
4115

    
4116
let rec (vhdl_signal_condition_t_to_yojson :
4117
          vhdl_signal_condition_t -> Yojson.Safe.json)
4118
  =
4119
  ((let open! Ppx_deriving_yojson_runtime in
4120
      fun x  ->
4121
        let fields = []  in
4122
        let fields =
4123
          if x.cond = IsNull
4124
          then fields
4125
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4126
            fields
4127
           in
4128
        let fields =
4129
          ("expr",
4130
            ((fun x  ->
4131
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
4132
               x.expr))
4133
          :: fields  in
4134
        `Assoc fields)
4135
  [@ocaml.warning "-A"])
4136

    
4137
and (vhdl_signal_condition_t_of_yojson :
4138
      Yojson.Safe.json ->
4139
        vhdl_signal_condition_t Ppx_deriving_yojson_runtime.error_or)
4140
  =
4141
  ((let open! Ppx_deriving_yojson_runtime in
4142
      function
4143
      | `Assoc xs ->
4144
          let rec loop xs ((arg0,arg1) as _state) =
4145
            match xs with
4146
            | ("expr",x)::xs ->
4147
                loop xs
4148
                  (((function
4149
                     | `List xs ->
4150
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4151
                     | _ ->
4152
                         Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr")
4153
                      x), arg1)
4154
            | ("cond",x)::xs ->
4155
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4156
            | [] ->
4157
                arg1 >>=
4158
                  ((fun arg1  ->
4159
                      arg0 >>=
4160
                        (fun arg0  -> Result.Ok { expr = arg0; cond = arg1 })))
4161
            | _::xs -> loop xs _state  in
4162
          loop xs
4163
            ((Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr"),
4164
              (Result.Ok IsNull))
4165
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_condition_t")
4166
  [@ocaml.warning "-A"])
4167

    
4168
type vhdl_signal_selection_t =
4169
  {
4170
  expr: vhdl_expr_t ;
4171
  when_sel: vhdl_expr_t list [@default []]}
4172

    
4173
let rec pp_vhdl_signal_selection_t :
4174
  Format.formatter -> vhdl_signal_selection_t -> Ppx_deriving_runtime.unit =
4175
  let __1 () = pp_vhdl_expr_t
4176
  
4177
  and __0 () = pp_vhdl_expr_t
4178
   in
4179
  ((let open! Ppx_deriving_runtime in
4180
      fun fmt  ->
4181
        fun x  ->
4182
          Format.fprintf fmt "@[<2>{ ";
4183
          ((Format.fprintf fmt "@[%s =@ " "expr";
4184
            ((__0 ()) fmt) x.expr;
4185
            Format.fprintf fmt "@]");
4186
           Format.fprintf fmt ";@ ";
4187
           Format.fprintf fmt "@[%s =@ " "when_sel";
4188
           ((fun x  ->
4189
               Format.fprintf fmt "@[<2>[";
4190
               ignore
4191
                 (List.fold_left
4192
                    (fun sep  ->
4193
                       fun x  ->
4194
                         if sep then Format.fprintf fmt ";@ ";
4195
                         ((__1 ()) fmt) x;
4196
                         true) false x);
4197
               Format.fprintf fmt "@,]@]")) x.when_sel;
4198
           Format.fprintf fmt "@]");
4199
          Format.fprintf fmt "@ }@]")
4200
    [@ocaml.warning "-A"])
4201

    
4202
and show_vhdl_signal_selection_t :
4203
  vhdl_signal_selection_t -> Ppx_deriving_runtime.string =
4204
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_selection_t x
4205

    
4206
let rec (vhdl_signal_selection_t_to_yojson :
4207
          vhdl_signal_selection_t -> Yojson.Safe.json)
4208
  =
4209
  ((let open! Ppx_deriving_yojson_runtime in
4210
      fun x  ->
4211
        let fields = []  in
4212
        let fields =
4213
          if x.when_sel = []
4214
          then fields
4215
          else
4216
            ("when_sel",
4217
              (((fun x  ->
4218
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
4219
                 x.when_sel))
4220
            :: fields
4221
           in
4222
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
4223
          :: fields  in
4224
        `Assoc fields)
4225
  [@ocaml.warning "-A"])
4226

    
4227
and (vhdl_signal_selection_t_of_yojson :
4228
      Yojson.Safe.json ->
4229
        vhdl_signal_selection_t Ppx_deriving_yojson_runtime.error_or)
4230
  =
4231
  ((let open! Ppx_deriving_yojson_runtime in
4232
      function
4233
      | `Assoc xs ->
4234
          let rec loop xs ((arg0,arg1) as _state) =
4235
            match xs with
4236
            | ("expr",x)::xs ->
4237
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
4238
            | ("when_sel",x)::xs ->
4239
                loop xs
4240
                  (arg0,
4241
                    ((function
4242
                      | `List xs ->
4243
                          map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4244
                      | _ ->
4245
                          Result.Error
4246
                            "Vhdl_ast.vhdl_signal_selection_t.when_sel") x))
4247
            | [] ->
4248
                arg1 >>=
4249
                  ((fun arg1  ->
4250
                      arg0 >>=
4251
                        (fun arg0  ->
4252
                           Result.Ok { expr = arg0; when_sel = arg1 })))
4253
            | _::xs -> loop xs _state  in
4254
          loop xs
4255
            ((Result.Error "Vhdl_ast.vhdl_signal_selection_t.expr"),
4256
              (Result.Ok []))
4257
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_selection_t")
4258
  [@ocaml.warning "-A"])
4259

    
4260
type vhdl_conditional_signal_t =
4261
  {
4262
  postponed: bool [@default false];
4263
  label: vhdl_name_t [@default NoName];
4264
  lhs: vhdl_name_t ;
4265
  rhs: vhdl_signal_condition_t list ;
4266
  cond: vhdl_expr_t [@default IsNull];
4267
  delay: vhdl_expr_t [@default IsNull]}
4268

    
4269
let rec pp_vhdl_conditional_signal_t :
4270
  Format.formatter -> vhdl_conditional_signal_t -> Ppx_deriving_runtime.unit
4271
  =
4272
  let __4 () = pp_vhdl_expr_t
4273
  
4274
  and __3 () = pp_vhdl_expr_t
4275
  
4276
  and __2 () = pp_vhdl_signal_condition_t
4277
  
4278
  and __1 () = pp_vhdl_name_t
4279
  
4280
  and __0 () = pp_vhdl_name_t
4281
   in
4282
  ((let open! Ppx_deriving_runtime in
4283
      fun fmt  ->
4284
        fun x  ->
4285
          Format.fprintf fmt "@[<2>{ ";
4286
          ((((((Format.fprintf fmt "@[%s =@ " "postponed";
4287
                (Format.fprintf fmt "%B") x.postponed;
4288
                Format.fprintf fmt "@]");
4289
               Format.fprintf fmt ";@ ";
4290
               Format.fprintf fmt "@[%s =@ " "label";
4291
               ((__0 ()) fmt) x.label;
4292
               Format.fprintf fmt "@]");
4293
              Format.fprintf fmt ";@ ";
4294
              Format.fprintf fmt "@[%s =@ " "lhs";
4295
              ((__1 ()) fmt) x.lhs;
4296
              Format.fprintf fmt "@]");
4297
             Format.fprintf fmt ";@ ";
4298
             Format.fprintf fmt "@[%s =@ " "rhs";
4299
             ((fun x  ->
4300
                 Format.fprintf fmt "@[<2>[";
4301
                 ignore
4302
                   (List.fold_left
4303
                      (fun sep  ->
4304
                         fun x  ->
4305
                           if sep then Format.fprintf fmt ";@ ";
4306
                           ((__2 ()) fmt) x;
4307
                           true) false x);
4308
                 Format.fprintf fmt "@,]@]")) x.rhs;
4309
             Format.fprintf fmt "@]");
4310
            Format.fprintf fmt ";@ ";
4311
            Format.fprintf fmt "@[%s =@ " "cond";
4312
            ((__3 ()) fmt) x.cond;
4313
            Format.fprintf fmt "@]");
4314
           Format.fprintf fmt ";@ ";
4315
           Format.fprintf fmt "@[%s =@ " "delay";
4316
           ((__4 ()) fmt) x.delay;
4317
           Format.fprintf fmt "@]");
4318
          Format.fprintf fmt "@ }@]")
4319
    [@ocaml.warning "-A"])
4320

    
4321
and show_vhdl_conditional_signal_t :
4322
  vhdl_conditional_signal_t -> Ppx_deriving_runtime.string =
4323
  fun x  -> Format.asprintf "%a" pp_vhdl_conditional_signal_t x
4324

    
4325
let rec (vhdl_conditional_signal_t_to_yojson :
4326
          vhdl_conditional_signal_t -> Yojson.Safe.json)
4327
  =
4328
  ((let open! Ppx_deriving_yojson_runtime in
4329
      fun x  ->
4330
        let fields = []  in
4331
        let fields =
4332
          if x.delay = IsNull
4333
          then fields
4334
          else ("delay", (((fun x  -> vhdl_expr_t_to_yojson x)) x.delay)) ::
4335
            fields
4336
           in
4337
        let fields =
4338
          if x.cond = IsNull
4339
          then fields
4340
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4341
            fields
4342
           in
4343
        let fields =
4344
          ("rhs",
4345
            ((fun x  ->
4346
                `List
4347
                  (List.map (fun x  -> vhdl_signal_condition_t_to_yojson x) x))
4348
               x.rhs))
4349
          :: fields  in
4350
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4351
          fields  in
4352
        let fields =
4353
          if x.label = NoName
4354
          then fields
4355
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4356
            fields
4357
           in
4358
        let fields =
4359
          if x.postponed = false
4360
          then fields
4361
          else
4362
            ("postponed",
4363
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4364
                 x.postponed))
4365
            :: fields
4366
           in
4367
        `Assoc fields)
4368
  [@ocaml.warning "-A"])
4369

    
4370
and (vhdl_conditional_signal_t_of_yojson :
4371
      Yojson.Safe.json ->
4372
        vhdl_conditional_signal_t Ppx_deriving_yojson_runtime.error_or)
4373
  =
4374
  ((let open! Ppx_deriving_yojson_runtime in
4375
      function
4376
      | `Assoc xs ->
4377
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4378
            match xs with
4379
            | ("postponed",x)::xs ->
4380
                loop xs
4381
                  (((function
4382
                     | `Bool x -> Result.Ok x
4383
                     | _ ->
4384
                         Result.Error
4385
                           "Vhdl_ast.vhdl_conditional_signal_t.postponed") x),
4386
                    arg1, arg2, arg3, arg4, arg5)
4387
            | ("label",x)::xs ->
4388
                loop xs
4389
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4390
                    arg4, arg5)
4391
            | ("lhs",x)::xs ->
4392
                loop xs
4393
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4394
                    arg4, arg5)
4395
            | ("rhs",x)::xs ->
4396
                loop xs
4397
                  (arg0, arg1, arg2,
4398
                    ((function
4399
                      | `List xs ->
4400
                          map_bind
4401
                            (fun x  -> vhdl_signal_condition_t_of_yojson x)
4402
                            [] xs
4403
                      | _ ->
4404
                          Result.Error
4405
                            "Vhdl_ast.vhdl_conditional_signal_t.rhs") x),
4406
                    arg4, arg5)
4407
            | ("cond",x)::xs ->
4408
                loop xs
4409
                  (arg0, arg1, arg2, arg3,
4410
                    ((fun x  -> vhdl_expr_t_of_yojson x) x), arg5)
4411
            | ("delay",x)::xs ->
4412
                loop xs
4413
                  (arg0, arg1, arg2, arg3, arg4,
4414
                    ((fun x  -> vhdl_expr_t_of_yojson x) x))
4415
            | [] ->
4416
                arg5 >>=
4417
                  ((fun arg5  ->
4418
                      arg4 >>=
4419
                        (fun arg4  ->
4420
                           arg3 >>=
4421
                             (fun arg3  ->
4422
                                arg2 >>=
4423
                                  (fun arg2  ->
4424
                                     arg1 >>=
4425
                                       (fun arg1  ->
4426
                                          arg0 >>=
4427
                                            (fun arg0  ->
4428
                                               Result.Ok
4429
                                                 {
4430
                                                   postponed = arg0;
4431
                                                   label = arg1;
4432
                                                   lhs = arg2;
4433
                                                   rhs = arg3;
4434
                                                   cond = arg4;
4435
                                                   delay = arg5
4436
                                                 })))))))
4437
            | _::xs -> loop xs _state  in
4438
          loop xs
4439
            ((Result.Ok false), (Result.Ok NoName),
4440
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.lhs"),
4441
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.rhs"),
4442
              (Result.Ok IsNull), (Result.Ok IsNull))
4443
      | _ -> Result.Error "Vhdl_ast.vhdl_conditional_signal_t")
4444
  [@ocaml.warning "-A"])
4445

    
4446
type vhdl_process_t =
4447
  {
4448
  id: vhdl_name_t [@default NoName];
4449
  declarations: vhdl_declaration_t list option
4450
    [@key "PROCESS_DECLARATIVE_PART"][@default Some []];
4451
  active_sigs: vhdl_name_t list [@default []];
4452
  body: vhdl_sequential_stmt_t list
4453
    [@key "PROCESS_STATEMENT_PART"][@default []]}
4454

    
4455
let rec pp_vhdl_process_t :
4456
  Format.formatter -> vhdl_process_t -> Ppx_deriving_runtime.unit =
4457
  let __3 () = pp_vhdl_sequential_stmt_t
4458
  
4459
  and __2 () = pp_vhdl_name_t
4460
  
4461
  and __1 () = pp_vhdl_declaration_t
4462
  
4463
  and __0 () = pp_vhdl_name_t
4464
   in
4465
  ((let open! Ppx_deriving_runtime in
4466
      fun fmt  ->
4467
        fun x  ->
4468
          Format.fprintf fmt "@[<2>{ ";
4469
          ((((Format.fprintf fmt "@[%s =@ " "id";
4470
              ((__0 ()) fmt) x.id;
4471
              Format.fprintf fmt "@]");
4472
             Format.fprintf fmt ";@ ";
4473
             Format.fprintf fmt "@[%s =@ " "declarations";
4474
             ((function
4475
               | None  -> Format.pp_print_string fmt "None"
4476
               | Some x ->
4477
                   (Format.pp_print_string fmt "(Some ";
4478
                    ((fun x  ->
4479
                        Format.fprintf fmt "@[<2>[";
4480
                        ignore
4481
                          (List.fold_left
4482
                             (fun sep  ->
4483
                                fun x  ->
4484
                                  if sep then Format.fprintf fmt ";@ ";
4485
                                  ((__1 ()) fmt) x;
4486
                                  true) false x);
4487
                        Format.fprintf fmt "@,]@]")) x;
4488
                    Format.pp_print_string fmt ")"))) x.declarations;
4489
             Format.fprintf fmt "@]");
4490
            Format.fprintf fmt ";@ ";
4491
            Format.fprintf fmt "@[%s =@ " "active_sigs";
4492
            ((fun x  ->
4493
                Format.fprintf fmt "@[<2>[";
4494
                ignore
4495
                  (List.fold_left
4496
                     (fun sep  ->
4497
                        fun x  ->
4498
                          if sep then Format.fprintf fmt ";@ ";
4499
                          ((__2 ()) fmt) x;
4500
                          true) false x);
4501
                Format.fprintf fmt "@,]@]")) x.active_sigs;
4502
            Format.fprintf fmt "@]");
4503
           Format.fprintf fmt ";@ ";
4504
           Format.fprintf fmt "@[%s =@ " "body";
4505
           ((fun x  ->
4506
               Format.fprintf fmt "@[<2>[";
4507
               ignore
4508
                 (List.fold_left
4509
                    (fun sep  ->
4510
                       fun x  ->
4511
                         if sep then Format.fprintf fmt ";@ ";
4512
                         ((__3 ()) fmt) x;
4513
                         true) false x);
4514
               Format.fprintf fmt "@,]@]")) x.body;
4515
           Format.fprintf fmt "@]");
4516
          Format.fprintf fmt "@ }@]")
4517
    [@ocaml.warning "-A"])
4518

    
4519
and show_vhdl_process_t : vhdl_process_t -> Ppx_deriving_runtime.string =
4520
  fun x  -> Format.asprintf "%a" pp_vhdl_process_t x
4521

    
4522
let rec (vhdl_process_t_to_yojson : vhdl_process_t -> Yojson.Safe.json) =
4523
  ((let open! Ppx_deriving_yojson_runtime in
4524
      fun x  ->
4525
        let fields = []  in
4526
        let fields =
4527
          if x.body = []
4528
          then fields
4529
          else
4530
            ("PROCESS_STATEMENT_PART",
4531
              (((fun x  ->
4532
                   `List
4533
                     (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x)
4534
                        x))) x.body))
4535
            :: fields
4536
           in
4537
        let fields =
4538
          if x.active_sigs = []
4539
          then fields
4540
          else
4541
            ("active_sigs",
4542
              (((fun x  ->
4543
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
4544
                 x.active_sigs))
4545
            :: fields
4546
           in
4547
        let fields =
4548
          if x.declarations = (Some [])
4549
          then fields
4550
          else
4551
            ("PROCESS_DECLARATIVE_PART",
4552
              (((function
4553
                 | None  -> `Null
4554
                 | Some x ->
4555
                     ((fun x  ->
4556
                         `List
4557
                           (List.map
4558
                              (fun x  -> vhdl_declaration_t_to_yojson x) x)))
4559
                       x)) x.declarations))
4560
            :: fields
4561
           in
4562
        let fields =
4563
          if x.id = NoName
4564
          then fields
4565
          else ("id", (((fun x  -> vhdl_name_t_to_yojson x)) x.id)) :: fields
4566
           in
4567
        `Assoc fields)
4568
  [@ocaml.warning "-A"])
4569

    
4570
and (vhdl_process_t_of_yojson :
4571
      Yojson.Safe.json -> vhdl_process_t Ppx_deriving_yojson_runtime.error_or)
4572
  =
4573
  ((let open! Ppx_deriving_yojson_runtime in
4574
      function
4575
      | `Assoc xs ->
4576
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
4577
            match xs with
4578
            | ("id",x)::xs ->
4579
                loop xs
4580
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3)
4581
            | ("PROCESS_DECLARATIVE_PART",x)::xs ->
4582
                loop xs
4583
                  (arg0,
4584
                    ((function
4585
                      | `Null -> Result.Ok None
4586
                      | x ->
4587
                          ((function
4588
                            | `List xs ->
4589
                                map_bind
4590
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4591
                                  [] xs
4592
                            | _ ->
4593
                                Result.Error
4594
                                  "Vhdl_ast.vhdl_process_t.declarations") x)
4595
                            >>= ((fun x  -> Result.Ok (Some x)))) x), arg2,
4596
                    arg3)
4597
            | ("active_sigs",x)::xs ->
4598
                loop xs
4599
                  (arg0, arg1,
4600
                    ((function
4601
                      | `List xs ->
4602
                          map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4603
                      | _ ->
4604
                          Result.Error "Vhdl_ast.vhdl_process_t.active_sigs")
4605
                       x), arg3)
4606
            | ("PROCESS_STATEMENT_PART",x)::xs ->
4607
                loop xs
4608
                  (arg0, arg1, arg2,
4609
                    ((function
4610
                      | `List xs ->
4611
                          map_bind
4612
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
4613
                            xs
4614
                      | _ -> Result.Error "Vhdl_ast.vhdl_process_t.body") x))
4615
            | [] ->
4616
                arg3 >>=
4617
                  ((fun arg3  ->
4618
                      arg2 >>=
4619
                        (fun arg2  ->
4620
                           arg1 >>=
4621
                             (fun arg1  ->
4622
                                arg0 >>=
4623
                                  (fun arg0  ->
4624
                                     Result.Ok
4625
                                       {
4626
                                         id = arg0;
4627
                                         declarations = arg1;
4628
                                         active_sigs = arg2;
4629
                                         body = arg3
4630
                                       })))))
4631
            | _::xs -> loop xs _state  in
4632
          loop xs
4633
            ((Result.Ok NoName), (Result.Ok (Some [])), (Result.Ok []),
4634
              (Result.Ok []))
4635
      | _ -> Result.Error "Vhdl_ast.vhdl_process_t")
4636
  [@ocaml.warning "-A"])
4637

    
4638
type vhdl_selected_signal_t =
4639
  {
4640
  postponed: bool [@default false];
4641
  label: vhdl_name_t [@default NoName];
4642
  lhs: vhdl_name_t ;
4643
  sel: vhdl_expr_t ;
4644
  branches: vhdl_signal_selection_t list [@default []];
4645
  delay: vhdl_expr_t option }
4646

    
4647
let rec pp_vhdl_selected_signal_t :
4648
  Format.formatter -> vhdl_selected_signal_t -> Ppx_deriving_runtime.unit =
4649
  let __4 () = pp_vhdl_expr_t
4650
  
4651
  and __3 () = pp_vhdl_signal_selection_t
4652
  
4653
  and __2 () = pp_vhdl_expr_t
4654
  
4655
  and __1 () = pp_vhdl_name_t
4656
  
4657
  and __0 () = pp_vhdl_name_t
4658
   in
4659
  ((let open! Ppx_deriving_runtime in
4660
      fun fmt  ->
4661
        fun x  ->
4662
          Format.fprintf fmt "@[<2>{ ";
4663
          ((((((Format.fprintf fmt "@[%s =@ " "postponed";
4664
                (Format.fprintf fmt "%B") x.postponed;
4665
                Format.fprintf fmt "@]");
4666
               Format.fprintf fmt ";@ ";
4667
               Format.fprintf fmt "@[%s =@ " "label";
4668
               ((__0 ()) fmt) x.label;
4669
               Format.fprintf fmt "@]");
4670
              Format.fprintf fmt ";@ ";
4671
              Format.fprintf fmt "@[%s =@ " "lhs";
4672
              ((__1 ()) fmt) x.lhs;
4673
              Format.fprintf fmt "@]");
4674
             Format.fprintf fmt ";@ ";
4675
             Format.fprintf fmt "@[%s =@ " "sel";
4676
             ((__2 ()) fmt) x.sel;
4677
             Format.fprintf fmt "@]");
4678
            Format.fprintf fmt ";@ ";
4679
            Format.fprintf fmt "@[%s =@ " "branches";
4680
            ((fun x  ->
4681
                Format.fprintf fmt "@[<2>[";
4682
                ignore
4683
                  (List.fold_left
4684
                     (fun sep  ->
4685
                        fun x  ->
4686
                          if sep then Format.fprintf fmt ";@ ";
4687
                          ((__3 ()) fmt) x;
4688
                          true) false x);
4689
                Format.fprintf fmt "@,]@]")) x.branches;
4690
            Format.fprintf fmt "@]");
4691
           Format.fprintf fmt ";@ ";
4692
           Format.fprintf fmt "@[%s =@ " "delay";
4693
           ((function
4694
             | None  -> Format.pp_print_string fmt "None"
4695
             | Some x ->
4696
                 (Format.pp_print_string fmt "(Some ";
4697
                  ((__4 ()) fmt) x;
4698
                  Format.pp_print_string fmt ")"))) x.delay;
4699
           Format.fprintf fmt "@]");
4700
          Format.fprintf fmt "@ }@]")
4701
    [@ocaml.warning "-A"])
4702

    
4703
and show_vhdl_selected_signal_t :
4704
  vhdl_selected_signal_t -> Ppx_deriving_runtime.string =
4705
  fun x  -> Format.asprintf "%a" pp_vhdl_selected_signal_t x
4706

    
4707
let rec (vhdl_selected_signal_t_to_yojson :
4708
          vhdl_selected_signal_t -> Yojson.Safe.json)
4709
  =
4710
  ((let open! Ppx_deriving_yojson_runtime in
4711
      fun x  ->
4712
        let fields = []  in
4713
        let fields =
4714
          ("delay",
4715
            ((function
4716
              | None  -> `Null
4717
              | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x) x.delay))
4718
          :: fields  in
4719
        let fields =
4720
          if x.branches = []
4721
          then fields
4722
          else
4723
            ("branches",
4724
              (((fun x  ->
4725
                   `List
4726
                     (List.map
4727
                        (fun x  -> vhdl_signal_selection_t_to_yojson x) x)))
4728
                 x.branches))
4729
            :: fields
4730
           in
4731
        let fields = ("sel", ((fun x  -> vhdl_expr_t_to_yojson x) x.sel)) ::
4732
          fields  in
4733
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4734
          fields  in
4735
        let fields =
4736
          if x.label = NoName
4737
          then fields
4738
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4739
            fields
4740
           in
4741
        let fields =
4742
          if x.postponed = false
4743
          then fields
4744
          else
4745
            ("postponed",
4746
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4747
                 x.postponed))
4748
            :: fields
4749
           in
4750
        `Assoc fields)
4751
  [@ocaml.warning "-A"])
4752

    
4753
and (vhdl_selected_signal_t_of_yojson :
4754
      Yojson.Safe.json ->
4755
        vhdl_selected_signal_t Ppx_deriving_yojson_runtime.error_or)
4756
  =
4757
  ((let open! Ppx_deriving_yojson_runtime in
4758
      function
4759
      | `Assoc xs ->
4760
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4761
            match xs with
4762
            | ("postponed",x)::xs ->
4763
                loop xs
4764
                  (((function
4765
                     | `Bool x -> Result.Ok x
4766
                     | _ ->
4767
                         Result.Error
4768
                           "Vhdl_ast.vhdl_selected_signal_t.postponed") x),
4769
                    arg1, arg2, arg3, arg4, arg5)
4770
            | ("label",x)::xs ->
4771
                loop xs
4772
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4773
                    arg4, arg5)
4774
            | ("lhs",x)::xs ->
4775
                loop xs
4776
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4777
                    arg4, arg5)
4778
            | ("sel",x)::xs ->
4779
                loop xs
4780
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x),
4781
                    arg4, arg5)
4782
            | ("branches",x)::xs ->
4783
                loop xs
4784
                  (arg0, arg1, arg2, arg3,
4785
                    ((function
4786
                      | `List xs ->
4787
                          map_bind
4788
                            (fun x  -> vhdl_signal_selection_t_of_yojson x)
4789
                            [] xs
4790
                      | _ ->
4791
                          Result.Error
4792
                            "Vhdl_ast.vhdl_selected_signal_t.branches") x),
4793
                    arg5)
4794
            | ("delay",x)::xs ->
4795
                loop xs
4796
                  (arg0, arg1, arg2, arg3, arg4,
4797
                    ((function
4798
                      | `Null -> Result.Ok None
4799
                      | x ->
4800
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
4801
                            ((fun x  -> Result.Ok (Some x)))) x))
4802
            | [] ->
4803
                arg5 >>=
4804
                  ((fun arg5  ->
4805
                      arg4 >>=
4806
                        (fun arg4  ->
4807
                           arg3 >>=
4808
                             (fun arg3  ->
4809
                                arg2 >>=
4810
                                  (fun arg2  ->
4811
                                     arg1 >>=
4812
                                       (fun arg1  ->
4813
                                          arg0 >>=
4814
                                            (fun arg0  ->
4815
                                               Result.Ok
4816
                                                 {
4817
                                                   postponed = arg0;
4818
                                                   label = arg1;
4819
                                                   lhs = arg2;
4820
                                                   sel = arg3;
4821
                                                   branches = arg4;
4822
                                                   delay = arg5
4823
                                                 })))))))
4824
            | _::xs -> loop xs _state  in
4825
          loop xs
4826
            ((Result.Ok false), (Result.Ok NoName),
4827
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.lhs"),
4828
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.sel"),
4829
              (Result.Ok []),
4830
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.delay"))
4831
      | _ -> Result.Error "Vhdl_ast.vhdl_selected_signal_t")
4832
  [@ocaml.warning "-A"])
4833

    
4834
type vhdl_concurrent_stmt_t =
4835
  | SigAssign of vhdl_conditional_signal_t
4836
  [@name "CONDITIONAL_SIGNAL_ASSIGNMENT"]
4837
  | Process of vhdl_process_t [@name "PROCESS_STATEMENT"]
4838
  | SelectedSig of vhdl_selected_signal_t
4839
  [@name "SELECTED_SIGNAL_ASSIGNMENT"]
4840

    
4841
(* Adapted *)
4842
let rec pp_vhdl_concurrent_stmt_t :
4843
  Format.formatter -> vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.unit =
4844
  let __2 () = pp_vhdl_selected_signal_t
4845
  
4846
  and __1 () = pp_vhdl_process_t
4847
  
4848
  and __0 () = pp_vhdl_conditional_signal_t
4849
   in
4850
  ((let open! Ppx_deriving_runtime in
4851
      fun fmt  ->
4852
        function
4853
        | SigAssign a0 ->
4854
             ((__0 ()) fmt) a0;
4855
        | Process a0 ->
4856
             ((__1 ()) fmt) a0;
4857
        | SelectedSig a0 ->
4858
             ((__2 ()) fmt) a0;
4859
    )
4860
    [@ocaml.warning "-A"])
4861

    
4862
and show_vhdl_concurrent_stmt_t :
4863
  vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.string =
4864
  fun x  -> Format.asprintf "%a" pp_vhdl_concurrent_stmt_t x
4865

    
4866
let rec (vhdl_concurrent_stmt_t_to_yojson :
4867
          vhdl_concurrent_stmt_t -> Yojson.Safe.json)
4868
  =
4869
  ((let open! Ppx_deriving_yojson_runtime in
4870
      function
4871
      | SigAssign arg0 ->
4872
          `List
4873
            [`String "CONDITIONAL_SIGNAL_ASSIGNMENT";
4874
            ((fun x  -> vhdl_conditional_signal_t_to_yojson x)) arg0]
4875
      | Process arg0 ->
4876
          `List
4877
            [`String "PROCESS_STATEMENT";
4878
            ((fun x  -> vhdl_process_t_to_yojson x)) arg0]
4879
      | SelectedSig arg0 ->
4880
          `List
4881
            [`String "SELECTED_SIGNAL_ASSIGNMENT";
4882
            ((fun x  -> vhdl_selected_signal_t_to_yojson x)) arg0])
4883
  [@ocaml.warning "-A"])
4884

    
4885
and (vhdl_concurrent_stmt_t_of_yojson :
4886
      Yojson.Safe.json ->
4887
        vhdl_concurrent_stmt_t Ppx_deriving_yojson_runtime.error_or)
4888
  =
4889
  ((let open! Ppx_deriving_yojson_runtime in
4890
      function
4891
      | `List ((`String "CONDITIONAL_SIGNAL_ASSIGNMENT")::arg0::[]) ->
4892
          ((fun x  -> vhdl_conditional_signal_t_of_yojson x) arg0) >>=
4893
            ((fun arg0  -> Result.Ok (SigAssign arg0)))
4894
      | `List ((`String "PROCESS_STATEMENT")::arg0::[]) ->
4895
          ((fun x  -> vhdl_process_t_of_yojson x) arg0) >>=
4896
            ((fun arg0  -> Result.Ok (Process arg0)))
4897
      | `List ((`String "SELECTED_SIGNAL_ASSIGNMENT")::arg0::[]) ->
4898
          ((fun x  -> vhdl_selected_signal_t_of_yojson x) arg0) >>=
4899
            ((fun arg0  -> Result.Ok (SelectedSig arg0)))
4900
      | _ -> Result.Error "Vhdl_ast.vhdl_concurrent_stmt_t")
4901
  [@ocaml.warning "-A"])
4902

    
4903
type vhdl_port_mode_t =
4904
  | InPort [@name "in"]
4905
  | OutPort [@name "out"]
4906
  | InoutPort [@name "inout"]
4907
  | BufferPort [@name "buffer"]
4908

    
4909
let rec (pp_vhdl_port_mode_t :
4910
          Format.formatter -> vhdl_port_mode_t -> Ppx_deriving_runtime.unit)
4911
  =
4912
  ((let open! Ppx_deriving_runtime in
4913
      fun fmt  ->
4914
        function
4915
        | InPort  -> Format.pp_print_string fmt "in"
4916
        | OutPort  -> Format.pp_print_string fmt "out"
4917
        | InoutPort  -> Format.pp_print_string fmt "inout"
4918
        | BufferPort  -> Format.pp_print_string fmt "buffer")
4919
  [@ocaml.warning "-A"])
4920

    
4921
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string =
4922
  fun x  -> Format.asprintf "%a" pp_vhdl_port_mode_t x
4923

    
4924
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) =
4925
  ((let open! Ppx_deriving_yojson_runtime in
4926
      function
4927
      | InPort  -> `List [`String "in"]
4928
      | OutPort  -> `List [`String "out"]
4929
      | InoutPort  -> `List [`String "inout"]
4930
      | BufferPort  -> `List [`String "buffer"])
4931
  [@ocaml.warning "-A"])
4932

    
4933
and (vhdl_port_mode_t_of_yojson :
4934
      Yojson.Safe.json ->
4935
        vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or)
4936
  =
4937
  ((let open! Ppx_deriving_yojson_runtime in
4938
      function
4939
      | `List ((`String "in")::[]) -> Result.Ok InPort
4940
      | `List ((`String "out")::[]) -> Result.Ok OutPort
4941
      | `List ((`String "inout")::[]) -> Result.Ok InoutPort
4942
      | `List ((`String "buffer")::[]) -> Result.Ok BufferPort
4943
      | _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t")
4944
  [@ocaml.warning "-A"])
4945

    
4946
type vhdl_port_t =
4947
  {
4948
  names: vhdl_name_t list [@default []];
4949
  mode: vhdl_port_mode_t [@default InPort];
4950
  typ: vhdl_subtype_indication_t ;
4951
  expr: vhdl_expr_t [@default IsNull]}
4952

    
4953
(* Adapted *)
4954
let rec pp_vhdl_port_t :
4955
  Format.formatter -> vhdl_port_t -> Ppx_deriving_runtime.unit =
4956
  let __3 () = pp_vhdl_expr_t
4957
  
4958
  and __2 () = pp_vhdl_subtype_indication_t
4959
  
4960
  and __1 () = pp_vhdl_port_mode_t
4961
  
4962
  and __0 () = pp_vhdl_name_t
4963
   in
4964
  ((let open! Ppx_deriving_runtime in
4965
      fun fmt  ->
4966
        fun x  ->
4967
          Format.fprintf fmt "@[";
4968
          ((((
4969
              ((fun x  ->
4970
                  Format.fprintf fmt "@[";
4971
                  ignore
4972
                    (List.fold_left
4973
                       (fun sep  ->
4974
                          fun x  ->
4975
                            if sep then Format.fprintf fmt ",@ ";
4976
                            ((__0 ()) fmt) x;
4977
                            true) false x);
4978
                  Format.fprintf fmt "@,@]")) x.names;
4979
              );
4980
             Format.fprintf fmt ":@ ";
4981
             ((__1 ()) fmt) x.mode;
4982
             );
4983
             Format.fprintf fmt "@ ";
4984
            ((__2 ()) fmt) x.typ;
4985
            );
4986
          (match x.expr with
4987
           | IsNull -> Format.fprintf fmt "";
4988
           | _ -> (Format.fprintf fmt "@[:=@ ";
4989
                   ((__3 ()) fmt) x.expr;
4990
                   Format.fprintf fmt "@]"));
4991
          Format.fprintf fmt "@]"))
4992
    [@ocaml.warning "-A"])
4993

    
4994
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string =
4995
  fun x  -> Format.asprintf "%a" pp_vhdl_port_t x
4996

    
4997
let rec (vhdl_port_t_to_yojson : vhdl_port_t -> Yojson.Safe.json) =
4998
  ((let open! Ppx_deriving_yojson_runtime in
4999
      fun x  ->
5000
        let fields = []  in
5001
        let fields =
5002
          if x.expr = IsNull
5003
          then fields
5004
          else ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) x.expr)) ::
5005
            fields
5006
           in
5007
        let fields =
5008
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
5009
          :: fields  in
5010
        let fields =
5011
          if x.mode = InPort
5012
          then fields
5013
          else ("mode", (((fun x  -> vhdl_port_mode_t_to_yojson x)) x.mode))
5014
            :: fields
5015
           in
5016
        let fields =
5017
          if x.names = []
5018
          then fields
5019
          else
5020
            ("names",
5021
              (((fun x  ->
5022
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
5023
                 x.names))
5024
            :: fields
5025
           in
5026
        `Assoc fields)
5027
  [@ocaml.warning "-A"])
5028

    
5029
and (vhdl_port_t_of_yojson :
5030
      Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
5031
  =
5032
  ((let open! Ppx_deriving_yojson_runtime in
5033
      function
5034
      | `Assoc xs ->
5035
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
5036
            match xs with
5037
            | ("names",x)::xs ->
5038
                loop xs
5039
                  (((function
5040
                     | `List xs ->
5041
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5042
                     | _ -> Result.Error "Vhdl_ast.vhdl_port_t.names") x),
5043
                    arg1, arg2, arg3)
5044
            | ("mode",x)::xs ->
5045
                loop xs
5046
                  (arg0, ((fun x  -> vhdl_port_mode_t_of_yojson x) x), arg2,
5047
                    arg3)
5048
            | ("typ",x)::xs ->
5049
                loop xs
5050
                  (arg0, arg1,
5051
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
5052
                    arg3)
5053
            | ("expr",x)::xs ->
5054
                loop xs
5055
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x))
5056
            | [] ->
5057
                arg3 >>=
5058
                  ((fun arg3  ->
5059
                      arg2 >>=
5060
                        (fun arg2  ->
5061
                           arg1 >>=
5062
                             (fun arg1  ->
5063
                                arg0 >>=
5064
                                  (fun arg0  ->
5065
                                     Result.Ok
5066
                                       {
5067
                                         names = arg0;
5068
                                         mode = arg1;
5069
                                         typ = arg2;
5070
                                         expr = arg3
5071
                                       })))))
5072
            | _::xs -> loop xs _state  in
5073
          loop xs
5074
            ((Result.Ok []), (Result.Ok InPort),
5075
              (Result.Error "Vhdl_ast.vhdl_port_t.typ"), (Result.Ok IsNull))
5076
      | _ -> Result.Error "Vhdl_ast.vhdl_port_t")
5077
  [@ocaml.warning "-A"])
5078

    
5079
type vhdl_entity_t =
5080
  {
5081
  name: vhdl_name_t [@default NoName];
5082
  generics: vhdl_port_t list [@default []];
5083
  ports: vhdl_port_t list [@default []];
5084
  declaration: vhdl_declaration_t list
5085
    [@key "ENTITY_DECLARATIVE_PART"][@default []];
5086
  stmts: vhdl_concurrent_stmt_t list
5087
    [@key "ENTITY_STATEMENT_PART"][@default []]}
5088

    
5089
(* Adapted *)
5090
let rec pp_vhdl_entity_t :
5091
  Format.formatter -> vhdl_entity_t -> Ppx_deriving_runtime.unit =
5092
  let __4 () = pp_vhdl_concurrent_stmt_t
5093
  
5094
  and __3 () = pp_vhdl_declaration_t
5095
  
5096
  and __2 () = pp_vhdl_port_t
5097
  
5098
  and __1 () = pp_vhdl_port_t
5099
  
5100
  and __0 () = pp_vhdl_name_t
5101
   in
5102
  ((let open! Ppx_deriving_runtime in
5103
      fun fmt  ->
5104
        fun x  ->
5105
          (((((
5106
               ((__0 ()) fmt) x.name;
5107
               Format.fprintf fmt " is@ ");
5108
              Format.fprintf fmt "@[<v>";
5109
              ((fun x  ->
5110
                  Format.fprintf fmt "@[";
5111
                  ignore
5112
                    (List.fold_left
5113
                       (fun sep  ->
5114
                          fun x  ->
5115
                            if sep then Format.fprintf fmt ";@ ";
5116
                            ((__1 ()) fmt) x;
5117
                            true) false x);
5118
                  Format.fprintf fmt "@]")) x.generics;
5119
              Format.fprintf fmt "@]");
5120
             Format.fprintf fmt "port (@[<v>";
5121
             ((fun x  ->
5122
                 Format.fprintf fmt "@[";
5123
                 ignore
5124
                   (List.fold_left
5125
                      (fun sep  ->
5126
                         fun x  ->
5127
                           if sep then Format.fprintf fmt ";@ ";
5128
                           ((__2 ()) fmt) x;
5129
                           true) false x);
5130
                 Format.fprintf fmt "@]")) x.ports;
5131
             Format.fprintf fmt "@]);");
5132
            Format.fprintf fmt "@[<v>";
5133
            ((fun x  ->
5134
                Format.fprintf fmt "@[";
5135
                ignore
5136
                  (List.fold_left
5137
                     (fun sep  ->
5138
                        fun x  ->
5139
                          if sep then Format.fprintf fmt ";@ ";
5140
                          ((__3 ()) fmt) x;
5141
                          true) false x);
5142
                Format.fprintf fmt "@]")) x.declaration;
5143
            Format.fprintf fmt "@]");
5144
           Format.fprintf fmt "@[<v>";
5145
           ((fun x  ->
5146
               Format.fprintf fmt "@[";
5147
               ignore
5148
                 (List.fold_left
5149
                    (fun sep  ->
5150
                       fun x  ->
5151
                         if sep then Format.fprintf fmt ";@ ";
5152
                         ((__4 ()) fmt) x;
5153
                         true) false x);
5154
               Format.fprintf fmt "@]")) x.stmts;
5155
           Format.fprintf fmt "@]");
5156
          Format.fprintf fmt "@]")
5157
    [@ocaml.warning "-A"])
5158

    
5159
and show_vhdl_entity_t : vhdl_entity_t -> Ppx_deriving_runtime.string =
5160
  fun x  -> Format.asprintf "%a" pp_vhdl_entity_t x
5161

    
5162
let rec (vhdl_entity_t_to_yojson : vhdl_entity_t -> Yojson.Safe.json) =
5163
  ((let open! Ppx_deriving_yojson_runtime in
5164
      fun x  ->
5165
        let fields = []  in
5166
        let fields =
5167
          if x.stmts = []
5168
          then fields
5169
          else
5170
            ("ENTITY_STATEMENT_PART",
5171
              (((fun x  ->
5172
                   `List
5173
                     (List.map (fun x  -> vhdl_concurrent_stmt_t_to_yojson x)
5174
                        x))) x.stmts))
5175
            :: fields
5176
           in
5177
        let fields =
5178
          if x.declaration = []
5179
          then fields
5180
          else
5181
            ("ENTITY_DECLARATIVE_PART",
5182
              (((fun x  ->
5183
                   `List
5184
                     (List.map (fun x  -> vhdl_declaration_t_to_yojson x) x)))
5185
                 x.declaration))
5186
            :: fields
5187
           in
5188
        let fields =
5189
          if x.ports = []
5190
          then fields
5191
          else
5192
            ("ports",
5193
              (((fun x  ->
5194
                   `List (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
5195
                 x.ports))
5196
            :: fields
5197
           in
5198
        let fields =
5199
          if x.generics = []
5200
          then fields
5201
          else
5202
            ("generics",
5203
              (((fun x  ->
5204
                   `List (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
5205
                 x.generics))
5206
            :: fields
5207
           in
5208
        let fields =
5209
          if x.name = NoName
5210
          then fields
5211
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
5212
            fields
5213
           in
5214
        `Assoc fields)
5215
  [@ocaml.warning "-A"])
5216

    
5217
and (vhdl_entity_t_of_yojson :
5218
      Yojson.Safe.json -> vhdl_entity_t Ppx_deriving_yojson_runtime.error_or)
5219
  =
5220
  ((let open! Ppx_deriving_yojson_runtime in
5221
      function
5222
      | `Assoc xs ->
5223
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
5224
            match xs with
5225
            | ("name",x)::xs ->
5226
                loop xs
5227
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3,
5228
                    arg4)
5229
            | ("generics",x)::xs ->
5230
                loop xs
5231
                  (arg0,
5232
                    ((function
5233
                      | `List xs ->
5234
                          map_bind (fun x  -> vhdl_port_t_of_yojson x) [] xs
5235
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.generics")
5236
                       x), arg2, arg3, arg4)
5237
            | ("ports",x)::xs ->
5238
                loop xs
5239
                  (arg0, arg1,
5240
                    ((function
5241
                      | `List xs ->
5242
                          map_bind (fun x  -> vhdl_port_t_of_yojson x) [] xs
5243
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.ports") x),
5244
                    arg3, arg4)
5245
            | ("ENTITY_DECLARATIVE_PART",x)::xs ->
5246
                loop xs
5247
                  (arg0, arg1, arg2,
5248
                    ((function
5249
                      | `List xs ->
5250
                          map_bind (fun x  -> vhdl_declaration_t_of_yojson x)
5251
                            [] xs
5252
                      | _ ->
5253
                          Result.Error "Vhdl_ast.vhdl_entity_t.declaration")
5254
                       x), arg4)
5255
            | ("ENTITY_STATEMENT_PART",x)::xs ->
5256
                loop xs
5257
                  (arg0, arg1, arg2, arg3,
5258
                    ((function
5259
                      | `List xs ->
5260
                          map_bind
5261
                            (fun x  -> vhdl_concurrent_stmt_t_of_yojson x) []
5262
                            xs
5263
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.stmts") x))
5264
            | [] ->
5265
                arg4 >>=
5266
                  ((fun arg4  ->
5267
                      arg3 >>=
5268
                        (fun arg3  ->
5269
                           arg2 >>=
5270
                             (fun arg2  ->
5271
                                arg1 >>=
5272
                                  (fun arg1  ->
5273
                                     arg0 >>=
5274
                                       (fun arg0  ->
5275
                                          Result.Ok
5276
                                            {
5277
                                              name = arg0;
5278
                                              generics = arg1;
5279
                                              ports = arg2;
5280
                                              declaration = arg3;
5281
                                              stmts = arg4
5282
                                            }))))))
5283
            | _::xs -> loop xs _state  in
5284
          loop xs
5285
            ((Result.Ok NoName), (Result.Ok []), (Result.Ok []),
5286
              (Result.Ok []), (Result.Ok []))
5287
      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t")
5288
  [@ocaml.warning "-A"])
5289

    
5290
type vhdl_package_t =
5291
  {
5292
  name: vhdl_name_t [@default NoName];
5293
  shared_defs: vhdl_definition_t list [@default []]}
5294

    
5295
(* Adapted -- TODO: indentation of package content is not correct *)
5296
let rec pp_vhdl_package_t :
5297
  Format.formatter -> vhdl_package_t -> Ppx_deriving_runtime.unit =
5298
  let __1 () = pp_vhdl_definition_t
5299
  
5300
  and __0 () = pp_vhdl_name_t
5301
   in
5302
  ((let open! Ppx_deriving_runtime in
5303
      fun fmt  ->
5304
        fun x  ->
5305
          ((Format.fprintf fmt "@[";
5306
            ((__0 ()) fmt) x.name;
5307
            Format.fprintf fmt " is@.");
5308
           Format.fprintf fmt "@[<v 2>";
5309
           ((fun x  ->
5310
               Format.fprintf fmt "@[";
5311
               ignore
5312
                 (List.fold_left
5313
                    (fun sep  ->
5314
                       fun x  ->
5315
                         if sep then Format.fprintf fmt ";@ ";
5316
                         ((__1 ()) fmt) x;
5317
                         true) false x);
5318
               Format.fprintf fmt "@,@]")) x.shared_defs;
5319
           Format.fprintf fmt "@]");
5320
          Format.fprintf fmt "@]")
5321
    [@ocaml.warning "-A"])
5322

    
5323
and show_vhdl_package_t : vhdl_package_t -> Ppx_deriving_runtime.string =
5324
  fun x  -> Format.asprintf "%a" pp_vhdl_package_t x
5325

    
5326
let rec (vhdl_package_t_to_yojson : vhdl_package_t -> Yojson.Safe.json) =
5327
  ((let open! Ppx_deriving_yojson_runtime in
5328
      fun x  ->
5329
        let fields = []  in
5330
        let fields =
5331
          if x.shared_defs = []
5332
          then fields
5333
          else
5334
            ("shared_defs",
5335
              (((fun x  ->
5336
                   `List
5337
                     (List.map (fun x  -> vhdl_definition_t_to_yojson x) x)))
5338
                 x.shared_defs))
5339
            :: fields
5340
           in
5341
        let fields =
5342
          if x.name = NoName
5343
          then fields
5344
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
5345
            fields
5346
           in
5347
        `Assoc fields)
5348
  [@ocaml.warning "-A"])
5349

    
5350
and (vhdl_package_t_of_yojson :
5351
      Yojson.Safe.json -> vhdl_package_t Ppx_deriving_yojson_runtime.error_or)
5352
  =
5353
  ((let open! Ppx_deriving_yojson_runtime in
5354
      function
5355
      | `Assoc xs ->
5356
          let rec loop xs ((arg0,arg1) as _state) =
5357
            match xs with
5358
            | ("name",x)::xs ->
5359
                loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
5360
            | ("shared_defs",x)::xs ->
5361
                loop xs
5362
                  (arg0,
5363
                    ((function
5364
                      | `List xs ->
5365
                          map_bind (fun x  -> vhdl_definition_t_of_yojson x)
5366
                            [] xs
5367
                      | _ ->
5368
                          Result.Error "Vhdl_ast.vhdl_package_t.shared_defs")
5369
                       x))
5370
            | [] ->
5371
                arg1 >>=
5372
                  ((fun arg1  ->
5373
                      arg0 >>=
5374
                        (fun arg0  ->
5375
                           Result.Ok { name = arg0; shared_defs = arg1 })))
5376
            | _::xs -> loop xs _state  in
5377
          loop xs ((Result.Ok NoName), (Result.Ok []))
5378
      | _ -> Result.Error "Vhdl_ast.vhdl_package_t")
5379
  [@ocaml.warning "-A"])
5380

    
5381
type vhdl_load_t =
5382
  | Library of vhdl_name_t list [@name "LIBRARY_CLAUSE"][@default []]
5383
  | Use of vhdl_name_t list [@name "USE_CLAUSE"][@default []]
5384

    
5385
(* Adapted *)
5386
let rec pp_vhdl_load_t :
5387
  Format.formatter -> vhdl_load_t -> Ppx_deriving_runtime.unit =
5388
  let __1 () = pp_vhdl_name_t
5389
  
5390
  and __0 () = pp_vhdl_name_t
5391
   in
5392
  ((let open! Ppx_deriving_runtime in
5393
      fun fmt  ->
5394
        function
5395
        | Library a0 ->
5396
            (Format.fprintf fmt "@[<2>library@ ";
5397
             ((fun x  ->
5398
                 Format.fprintf fmt "@[<2>";
5399
                 ignore
5400
                   (List.fold_left
5401
                      (fun sep  ->
5402
                         fun x  ->
5403
                           if sep then Format.fprintf fmt ".";
5404
                           ((__0 ()) fmt) x;
5405
                           true) false x);
5406
                 Format.fprintf fmt "@,@]")) a0;
5407
             Format.fprintf fmt "@]:")
5408
        | Use a0 ->
5409
            (Format.fprintf fmt "@[<2>use@ ";
5410
             ((fun x  ->
5411
                 Format.fprintf fmt "@[<2>";
5412
                 ignore
5413
                   (List.fold_left
5414
                      (fun sep  ->
5415
                         fun x  ->
5416
                           if sep then Format.fprintf fmt ".";
5417
                           ((__1 ()) fmt) x;
5418
                           true) false x);
5419
                 Format.fprintf fmt "@,@]")) a0;
5420
             Format.fprintf fmt "@];"))
5421
    [@ocaml.warning "-A"])
5422

    
5423
and show_vhdl_load_t : vhdl_load_t -> Ppx_deriving_runtime.string =
5424
  fun x  -> Format.asprintf "%a" pp_vhdl_load_t x
5425

    
5426
let rec (vhdl_load_t_to_yojson : vhdl_load_t -> Yojson.Safe.json) =
5427
  ((let open! Ppx_deriving_yojson_runtime in
5428
      function
5429
      | Library arg0 ->
5430
          `List
5431
            [`String "LIBRARY_CLAUSE";
5432
            ((fun x  ->
5433
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
5434
      | Use arg0 ->
5435
          `List
5436
            [`String "USE_CLAUSE";
5437
            ((fun x  ->
5438
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0])
5439
  [@ocaml.warning "-A"])
5440

    
5441
and (vhdl_load_t_of_yojson :
5442
      Yojson.Safe.json -> vhdl_load_t Ppx_deriving_yojson_runtime.error_or)
5443
  =
5444
  ((let open! Ppx_deriving_yojson_runtime in
5445
      function
5446
      | `List ((`String "LIBRARY_CLAUSE")::arg0::[]) ->
5447
          ((function
5448
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5449
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
5450
            ((fun arg0  -> Result.Ok (Library arg0)))
5451
      | `List ((`String "USE_CLAUSE")::arg0::[]) ->
5452
          ((function
5453
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5454
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
5455
            ((fun arg0  -> Result.Ok (Use arg0)))
5456
      | _ -> Result.Error "Vhdl_ast.vhdl_load_t")
5457
  [@ocaml.warning "-A"])
5458

    
5459
type vhdl_architecture_t =
5460
  {
5461
  name: vhdl_name_t [@default NoName];
5462
  entity: vhdl_name_t [@default NoName];
5463
  declarations: vhdl_declaration_t list
5464
    [@key "ARCHITECTURE_DECLARATIVE_PART"][@default []];
5465
  body: vhdl_concurrent_stmt_t list
5466
    [@key "ARCHITECTURE_STATEMENT_PART"][@default []]}
5467

    
5468
(* Adapted *)
5469
let rec pp_vhdl_architecture_t :
5470
  Format.formatter -> vhdl_architecture_t -> Ppx_deriving_runtime.unit =
5471
  let __3 () = pp_vhdl_concurrent_stmt_t
5472
  
5473
  and __2 () = pp_vhdl_declaration_t
5474
  
5475
  and __1 () = pp_vhdl_name_t
5476