Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / backends / VHDL / vhdl_ast_deriving.ml @ 3bc26d43

History | View | Annotate | Download (213 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 None];
157
  formal_arg: vhdl_name_t option [@default None];
158
  actual_name: vhdl_name_t option [@default None];
159
  actual_designator: vhdl_name_t option [@default None];
160
  actual_expr: vhdl_expr_t option [@default None]}
161
and vhdl_element_assoc_t = {
162
  choices: vhdl_expr_t list ;
163
  expr: vhdl_expr_t }
164
and vhdl_array_attributes_t =
165
  | AAttInt of {
166
  id: string ;
167
  arg: int } 
168
  | AAttAscending 
169
and vhdl_signal_attributes_t =
170
  | SigAtt of string 
171
and vhdl_string_attributes_t =
172
  | StringAtt of string 
173
and vhdl_suffix_selection_t =
174
  | Idx of int 
175
  | SuffixRange of int * int
176

    
177
let rec pp_vhdl_type_t :
178
  Format.formatter -> vhdl_type_t -> Ppx_deriving_runtime.unit =
179
  let __0 () = pp_vhdl_type_t  in
180
  ((let open! Ppx_deriving_runtime in
181
      fun fmt  ->
182
        function
183
        | Base a0 ->
184
             (Format.fprintf fmt "%s") a0;
185
        | Range (a0,a1,a2) ->
186
             ((
187
               (Format.fprintf fmt "%d") a1);
188
               ((function
189
                 | None  -> Format.pp_print_string fmt "None"
190
                 | Some x ->
191
                      (Format.fprintf fmt "%S") x;
192
                      )) a0;
193
              (Format.fprintf fmt "%d") a2);
194
        | Bit_vector (a0,a1) ->
195
             (Format.fprintf fmt "%d .. %d") a0 a1;
196
        | Array (a0,a1,a2) ->
197
             (((__0 ()) fmt) a2;
198
              (Format.fprintf fmt "[%d,%d]") a0 a1);
199
        | Enumerated a0 ->
200
             ((fun x  ->
201
                 Format.fprintf fmt "@[<2>[";
202
                 ignore
203
                   (List.fold_left
204
                      (fun sep  ->
205
                         fun x  ->
206
                           if sep then Format.fprintf fmt ";@ ";
207
                           (Format.fprintf fmt "%S") x;
208
                           true) false x);
209
                 Format.fprintf fmt "@,]@]")) a0;
210
        | Void  -> Format.pp_print_string fmt "Void")
211
    [@ocaml.warning "-A"])
212

    
213
and show_vhdl_type_t : vhdl_type_t -> Ppx_deriving_runtime.string =
214
  fun x  -> Format.asprintf "%a" pp_vhdl_type_t x
215

    
216
(* Adapted *)
217
and pp_vhdl_subtype_indication_t :
218
  Format.formatter -> vhdl_subtype_indication_t -> Ppx_deriving_runtime.unit
219
  =
220
  let __2 () = pp_vhdl_constraint_t
221
  
222
  and __1 () = pp_vhdl_name_t
223
  
224
  and __0 () = pp_vhdl_name_t
225
   in
226
  ((let open! Ppx_deriving_runtime in
227
      fun fmt  ->
228
        fun x  ->
229
          ((__0 ()) fmt) x.name;
230
          ((__1 ()) fmt) x.functionName;
231
          Format.fprintf fmt " ";
232
          ((__2 ()) fmt) x.const;
233
    )
234
    [@ocaml.warning "-A"])
235

    
236
and show_vhdl_subtype_indication_t :
237
  vhdl_subtype_indication_t -> Ppx_deriving_runtime.string =
238
  fun x  -> Format.asprintf "%a" pp_vhdl_subtype_indication_t x
239

    
240
(* Adapted *)
241
and pp_vhdl_discrete_range_t :
242
  Format.formatter -> vhdl_discrete_range_t -> Ppx_deriving_runtime.unit =
243
  let __3 () = pp_vhdl_expr_t
244
  
245
  and __2 () = pp_vhdl_expr_t
246
  
247
  and __1 () = pp_vhdl_name_t
248
  
249
  and __0 () = pp_vhdl_subtype_indication_t
250
   in
251
  ((let open! Ppx_deriving_runtime in
252
      fun fmt  ->
253
        function
254
        | SubDiscreteRange a0 ->
255
             ((__0 ()) fmt) a0;
256
        | NamedRange a0 ->
257
             ((__1 ()) fmt) a0;
258
        | DirectedRange { direction = adirection; from = afrom; _to = a_to }
259
            ->
260
               ((__2 ()) fmt) afrom;
261
               (Format.fprintf fmt " %s ") adirection;
262
               ((__3 ()) fmt) a_to;
263
    )
264
    [@ocaml.warning "-A"])
265

    
266
and show_vhdl_discrete_range_t :
267
  vhdl_discrete_range_t -> Ppx_deriving_runtime.string =
268
  fun x  -> Format.asprintf "%a" pp_vhdl_discrete_range_t x
269

    
270
(* TODO Adapt 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
(* TODO Adapt for Type *)
332
and pp_vhdl_definition_t :
333
  Format.formatter -> vhdl_definition_t -> Ppx_deriving_runtime.unit =
334
  let __3 () = pp_vhdl_subtype_indication_t
335
  
336
  and __2 () = pp_vhdl_name_t
337
  
338
  and __1 () = pp_vhdl_type_t
339
  
340
  and __0 () = pp_vhdl_name_t
341
   in
342
  ((let open! Ppx_deriving_runtime in
343
      fun fmt  ->
344
        function
345
        | Type { name = aname; definition = adefinition } ->
346
            Format.fprintf fmt "type ";
347
            ((__0 ()) fmt) aname;
348
            Format.fprintf fmt " is ";
349
            ((__1 ()) fmt) adefinition;
350
        | Subtype { name = aname; typ = atyp } ->
351
            Format.fprintf fmt "subtype ";
352
            ((__2 ()) fmt) aname;
353
            Format.fprintf fmt " is ";
354
            ((__3 ()) fmt) atyp;
355
   )
356
    [@ocaml.warning "-A"])
357

    
358
and show_vhdl_definition_t : vhdl_definition_t -> Ppx_deriving_runtime.string
359
  = fun x  -> Format.asprintf "%a" pp_vhdl_definition_t x
360

    
361
(* adaptation to be provided for Op, Time, Sig, suffixMod, Aggregate,  *)
362
and pp_vhdl_expr_t :
363
  Format.formatter -> vhdl_expr_t -> Ppx_deriving_runtime.unit =
364
  let __7 () = pp_vhdl_element_assoc_t
365
  
366
  and __6 () = pp_vhdl_suffix_selection_t
367
  
368
  and __5 () = pp_vhdl_expr_t
369
  
370
  and __4 () = pp_vhdl_signal_attributes_t
371
  
372
  and __3 () = pp_vhdl_name_t
373
  
374
  and __2 () = pp_vhdl_expr_t
375
  
376
  and __1 () = pp_vhdl_cst_val_t
377
  
378
  and __0 () = pp_vhdl_name_t
379
   in
380
  ((let open! Ppx_deriving_runtime in
381
      fun fmt  ->
382
        function
383
        | Call a0 ->
384
             ((__0 ()) fmt) a0;
385
        | Cst a0 ->
386
             ((__1 ()) fmt) a0;
387
        | Op { id = aid; args = aargs } ->
388
            (match aargs with
389
            | [] -> (Format.fprintf fmt "%s") aid;
390
            | hd::[] ->
391
               (Format.fprintf fmt "%s") aid;
392
               ((__2 ()) fmt) hd
393
            | hd::(hd2::[]) -> 
394
               ((__2 ()) fmt) hd;
395
               (Format.fprintf fmt " %s ") aid;
396
               ((__2 ()) fmt) hd2
397
            | _ ->
398
            (Format.fprintf fmt "@[<2>Op {@,";
399
             ((Format.fprintf fmt "@[%s =@ " "id";
400
               (Format.fprintf fmt "%S") aid;
401
               Format.fprintf fmt "@]");
402
              Format.fprintf fmt ";@ ";
403
              Format.fprintf fmt "@[%s =@ " "args";
404
              ((fun x  ->
405
                  Format.fprintf fmt "@[<2>[";
406
                  ignore
407
                    (List.fold_left
408
                       (fun sep  ->
409
                          fun x  ->
410
                            if sep then Format.fprintf fmt ";@ ";
411
                            ((__2 ()) fmt) x;
412
                            true) false x);
413
                  Format.fprintf fmt "@,]@]")) aargs;
414
              Format.fprintf fmt "@]");
415
             Format.fprintf fmt "@]}"))
416
        | IsNull  -> Format.pp_print_string fmt ""
417
        | Time { value = avalue; phy_unit = aphy_unit } ->
418
            (Format.fprintf fmt "@[<2>Time {@,";
419
             ((Format.fprintf fmt "@[%s =@ " "value";
420
               (Format.fprintf fmt "%d") avalue;
421
               Format.fprintf fmt "@]");
422
              Format.fprintf fmt ";@ ";
423
              Format.fprintf fmt "@[%s =@ " "phy_unit";
424
              (Format.fprintf fmt "%S") aphy_unit;
425
              Format.fprintf fmt "@]");
426
             Format.fprintf fmt "@]}")
427
        | Sig { name = aname; att = aatt } ->
428
            (Format.fprintf fmt "@[<2>Sig {@,";
429
             ((Format.fprintf fmt "@[%s =@ " "name";
430
               ((__3 ()) fmt) aname;
431
               Format.fprintf fmt "@]");
432
              Format.fprintf fmt ";@ ";
433
              Format.fprintf fmt "@[%s =@ " "att";
434
              ((function
435
                | None  -> Format.pp_print_string fmt "None"
436
                | Some x ->
437
                    (Format.pp_print_string fmt "(Some ";
438
                     ((__4 ()) fmt) x;
439
                     Format.pp_print_string fmt ")"))) aatt;
440
              Format.fprintf fmt "@]");
441
             Format.fprintf fmt "@]}")
442
        | SuffixMod { expr = aexpr; selection = aselection } ->
443
            (Format.fprintf fmt "@[<2>SuffixMod {@,";
444
             ((Format.fprintf fmt "@[%s =@ " "expr";
445
               ((__5 ()) fmt) aexpr;
446
               Format.fprintf fmt "@]");
447
              Format.fprintf fmt ";@ ";
448
              Format.fprintf fmt "@[%s =@ " "selection";
449
              ((__6 ()) fmt) aselection;
450
              Format.fprintf fmt "@]");
451
             Format.fprintf fmt "@]}")
452
        | Aggregate { elems = aelems } ->
453
            (Format.fprintf fmt "@[<2>Aggregate {@,";
454
             (Format.fprintf fmt "@[%s =@ " "elems";
455
              ((fun x  ->
456
                  Format.fprintf fmt "@[<2>[";
457
                  ignore
458
                    (List.fold_left
459
                       (fun sep  ->
460
                          fun x  ->
461
                            if sep then Format.fprintf fmt ";@ ";
462
                            ((__7 ()) fmt) x;
463
                            true) false x);
464
                  Format.fprintf fmt "@,]@]")) aelems;
465
              Format.fprintf fmt "@]");
466
             Format.fprintf fmt "@]}")
467
        | Others  -> Format.pp_print_string fmt "others")
468
    [@ocaml.warning "-A"])
469

    
470
and show_vhdl_expr_t : vhdl_expr_t -> Ppx_deriving_runtime.string =
471
  fun x  -> Format.asprintf "%a" pp_vhdl_expr_t x
472

    
473
(* Adapted *)
474
and pp_vhdl_name_t :
475
  Format.formatter -> vhdl_name_t -> Ppx_deriving_runtime.unit =
476
  let __9 () = pp_vhdl_assoc_element_t
477
  
478
  and __8 () = pp_vhdl_name_t
479
  
480
  and __7 () = pp_vhdl_expr_t
481
  
482
  and __6 () = pp_vhdl_name_t
483
  
484
  and __5 () = pp_vhdl_name_t
485
  
486
  and __4 () = pp_vhdl_discrete_range_t
487
  
488
  and __3 () = pp_vhdl_name_t
489
  
490
  and __2 () = pp_vhdl_expr_t
491
  
492
  and __1 () = pp_vhdl_name_t
493
  
494
  and __0 () = pp_vhdl_name_t
495
   in
496
  ((let open! Ppx_deriving_runtime in
497
      fun fmt  ->
498
        function
499
        | Simple a0 ->
500
             (Format.fprintf fmt "%s") a0;
501
        | Identifier a0 ->
502
             (Format.fprintf fmt "%s") a0;
503
        | Selected a0 ->
504
             ((fun x  ->
505
                 ignore
506
                   (List.fold_left
507
                      (fun sep  ->
508
                         fun x  ->
509
                           if sep then Format.fprintf fmt ".";
510
                           ((__0 ()) fmt) x;
511
                           true) false x);) a0;)
512
        | Index { id = aid; exprs = aexprs } ->
513
            ((__1 ()) fmt) aid;
514
            Format.fprintf fmt "(";
515
            (fun x  ->
516
                ignore
517
                (List.fold_left
518
                  (fun sep  ->
519
                    fun x  ->
520
                      if sep then Format.fprintf fmt ",@ ";
521
                                  ((__2 ()) fmt) x;
522
                                  true
523
                  ) false x);
524
            ) aexprs;
525
            Format.fprintf fmt ")";
526
        | Slice { id = aid; range = arange } ->
527
              ((__3 ()) fmt) aid;
528
              Format.fprintf fmt "(";
529
              ((__4 ()) fmt) arange;
530
              Format.fprintf fmt ")";
531
        | Attribute { id = aid; designator = adesignator; expr = aexpr } ->
532
              ((__5 ()) fmt) aid;
533
              Format.fprintf fmt "\'";
534
              ((__6 ()) fmt) adesignator;
535
              (match aexpr with
536
              | IsNull -> Format.fprintf fmt "";
537
              | _ ->
538
                Format.fprintf fmt "(";
539
                ((__7 ()) fmt) aexpr;
540
                Format.fprintf fmt ")")
541
        | Function { id = aid; assoc_list = aassoc_list } ->
542
            (((__8 ()) fmt) aid;
543
            Format.fprintf fmt "(";
544
            ((fun x  ->
545
              Format.fprintf fmt "@[";
546
              ignore
547
                (List.fold_left
548
                   (fun sep  ->
549
                      fun x  ->
550
                        if sep then Format.fprintf fmt ";@ ";
551
                        ((__9 ()) fmt) x;
552
                        true) false x);
553
            Format.fprintf fmt "@]")) aassoc_list;
554
            Format.fprintf fmt ")";)
555
        | NoName  -> Format.pp_print_string fmt "")
556
    [@ocaml.warning "-A"])
557

    
558
and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string =
559
  fun x  -> Format.asprintf "%a" pp_vhdl_name_t x
560

    
561
(* Adapted *)
562
and pp_vhdl_assoc_element_t :
563
  Format.formatter -> vhdl_assoc_element_t -> Ppx_deriving_runtime.unit =
564
  let __4 () = pp_vhdl_expr_t
565
  
566
  and __3 () = pp_vhdl_name_t
567
  
568
  and __2 () = pp_vhdl_name_t
569
  
570
  and __1 () = pp_vhdl_name_t
571
  
572
  and __0 () = pp_vhdl_name_t
573
   in
574
  ((let open! Ppx_deriving_runtime in
575
      fun fmt  ->
576
        fun x  ->
577
          (match x.formal_name with
578
          | None -> Format.pp_print_string fmt ""
579
          | Some NoName -> Format.pp_print_string fmt ""
580
          | Some a -> 
581
              (((__0 ()) fmt) a;
582
              (match x.formal_arg with
583
              | None -> ()
584
              | Some b -> Format.fprintf fmt "(";
585
                          ((__1 ()) fmt) b;
586
                          Format.fprintf fmt ")");
587
              Format.fprintf fmt " => "));
588
          (match x.actual_name with
589
          | None -> Format.pp_print_string fmt ""
590
          | Some a -> 
591
              (((__2 ()) fmt) a;
592
              (match x.actual_designator with
593
              | None -> ()
594
              | Some NoName -> Format.pp_print_string fmt ""
595
              | Some b -> (Format.fprintf fmt "(";
596
                          ((__3 ()) fmt) b;
597
                          Format.fprintf fmt ")"));
598
              (match x.actual_expr with
599
              | None -> ()
600
              | Some IsNull -> Format.pp_print_string fmt ""
601
              | Some c -> (Format.fprintf fmt "(";
602
                          ((__4 ()) fmt) c;
603
                          Format.fprintf fmt ")"))));)
604
    [@ocaml.warning "-A"])
605

    
606
and show_vhdl_assoc_element_t :
607
  vhdl_assoc_element_t -> Ppx_deriving_runtime.string =
608
  fun x  -> Format.asprintf "%a" pp_vhdl_assoc_element_t x
609

    
610
and pp_vhdl_element_assoc_t :
611
  Format.formatter -> vhdl_element_assoc_t -> Ppx_deriving_runtime.unit =
612
  let __1 () = pp_vhdl_expr_t
613
  
614
  and __0 () = pp_vhdl_expr_t
615
   in
616
  ((let open! Ppx_deriving_runtime in
617
      fun fmt  ->
618
        fun x  ->
619
          Format.fprintf fmt "@[<2>{ ";
620
          ((Format.fprintf fmt "@[%s =@ " "choices";
621
            ((fun x  ->
622
                Format.fprintf fmt "@[<2>[";
623
                ignore
624
                  (List.fold_left
625
                     (fun sep  ->
626
                        fun x  ->
627
                          if sep then Format.fprintf fmt ";@ ";
628
                          ((__0 ()) fmt) x;
629
                          true) false x);
630
                Format.fprintf fmt "@,]@]")) x.choices;
631
            Format.fprintf fmt "@]");
632
           Format.fprintf fmt ";@ ";
633
           Format.fprintf fmt "@[%s =@ " "expr";
634
           ((__1 ()) fmt) x.expr;
635
           Format.fprintf fmt "@]");
636
          Format.fprintf fmt "@ }@]")
637
    [@ocaml.warning "-A"])
638

    
639
and show_vhdl_element_assoc_t :
640
  vhdl_element_assoc_t -> Ppx_deriving_runtime.string =
641
  fun x  -> Format.asprintf "%a" pp_vhdl_element_assoc_t x
642

    
643
and (pp_vhdl_array_attributes_t :
644
      Format.formatter ->
645
        vhdl_array_attributes_t -> Ppx_deriving_runtime.unit)
646
  =
647
  ((let open! Ppx_deriving_runtime in
648
      fun fmt  ->
649
        function
650
        | AAttInt { id = aid; arg = aarg } ->
651
            (Format.fprintf fmt "@[<2>AAttInt {@,";
652
             ((Format.fprintf fmt "@[%s =@ " "id";
653
               (Format.fprintf fmt "%S") aid;
654
               Format.fprintf fmt "@]");
655
              Format.fprintf fmt ";@ ";
656
              Format.fprintf fmt "@[%s =@ " "arg";
657
              (Format.fprintf fmt "%d") aarg;
658
              Format.fprintf fmt "@]");
659
             Format.fprintf fmt "@]}")
660
        | AAttAscending  -> Format.pp_print_string fmt "AAttAscending")
661
  [@ocaml.warning "-A"])
662

    
663
and show_vhdl_array_attributes_t :
664
  vhdl_array_attributes_t -> Ppx_deriving_runtime.string =
665
  fun x  -> Format.asprintf "%a" pp_vhdl_array_attributes_t x
666

    
667
and (pp_vhdl_signal_attributes_t :
668
      Format.formatter ->
669
        vhdl_signal_attributes_t -> Ppx_deriving_runtime.unit)
670
  =
671
  ((let open! Ppx_deriving_runtime in
672
      fun fmt  ->
673
        function
674
        | SigAtt a0 ->
675
            (Format.fprintf fmt "(@[<2>SigAtt@ ";
676
             (Format.fprintf fmt "%S") a0;
677
             Format.fprintf fmt "@])"))
678
  [@ocaml.warning "-A"])
679

    
680
and show_vhdl_signal_attributes_t :
681
  vhdl_signal_attributes_t -> Ppx_deriving_runtime.string =
682
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_attributes_t x
683

    
684
and (pp_vhdl_string_attributes_t :
685
      Format.formatter ->
686
        vhdl_string_attributes_t -> Ppx_deriving_runtime.unit)
687
  =
688
  ((let open! Ppx_deriving_runtime in
689
      fun fmt  ->
690
        function
691
        | StringAtt a0 ->
692
            (Format.fprintf fmt "(@[<2>StringAtt@ ";
693
             (Format.fprintf fmt "%S") a0;
694
             Format.fprintf fmt "@])"))
695
  [@ocaml.warning "-A"])
696

    
697
and show_vhdl_string_attributes_t :
698
  vhdl_string_attributes_t -> Ppx_deriving_runtime.string =
699
  fun x  -> Format.asprintf "%a" pp_vhdl_string_attributes_t x
700

    
701
and (pp_vhdl_suffix_selection_t :
702
      Format.formatter ->
703
        vhdl_suffix_selection_t -> Ppx_deriving_runtime.unit)
704
  =
705
  ((let open! Ppx_deriving_runtime in
706
      fun fmt  ->
707
        function
708
        | Idx a0 ->
709
            (Format.fprintf fmt "(@[<2>Idx@ ";
710
             (Format.fprintf fmt "%d") a0;
711
             Format.fprintf fmt "@])")
712
        | SuffixRange (a0,a1) ->
713
            (Format.fprintf fmt "(@[<2>SuffixRange (@,";
714
             ((Format.fprintf fmt "%d") a0;
715
              Format.fprintf fmt ",@ ";
716
              (Format.fprintf fmt "%d") a1);
717
             Format.fprintf fmt "@,))@]"))
718
  [@ocaml.warning "-A"])
719

    
720
and show_vhdl_suffix_selection_t :
721
  vhdl_suffix_selection_t -> Ppx_deriving_runtime.string =
722
  fun x  -> Format.asprintf "%a" pp_vhdl_suffix_selection_t x
723

    
724
let rec (vhdl_type_t_to_yojson : vhdl_type_t -> Yojson.Safe.json) =
725
  ((let open! Ppx_deriving_yojson_runtime in
726
      function
727
      | Base arg0 ->
728
          `List
729
            [`String "Base";
730
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
731
      | Range (arg0,arg1,arg2) ->
732
          `List
733
            [`String "Range";
734
            ((function
735
              | None  -> `Null
736
              | Some x ->
737
                  ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x))
738
              arg0;
739
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1;
740
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg2]
741
      | Bit_vector (arg0,arg1) ->
742
          `List
743
            [`String "Bit_vector";
744
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
745
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1]
746
      | Array (arg0,arg1,arg2) ->
747
          `List
748
            [`String "Array";
749
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
750
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1;
751
            ((fun x  -> vhdl_type_t_to_yojson x)) arg2]
752
      | Enumerated arg0 ->
753
          `List
754
            [`String "Enumerated";
755
            ((fun x  ->
756
                `List
757
                  (List.map
758
                     (fun (x : Ppx_deriving_runtime.string)  -> `String x) x)))
759
              arg0]
760
      | Void  -> `List [`String "Void"])
761
  [@ocaml.warning "-A"])
762

    
763
and (vhdl_type_t_of_yojson :
764
      Yojson.Safe.json -> vhdl_type_t Ppx_deriving_yojson_runtime.error_or)
765
  =
766
  ((let open! Ppx_deriving_yojson_runtime in
767
      function
768
      | `List ((`String "Base")::arg0::[]) ->
769
          ((function
770
            | `String x -> Result.Ok x
771
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
772
            ((fun arg0  -> Result.Ok (Base arg0)))
773
      | `List ((`String "Range")::arg0::arg1::arg2::[]) ->
774
          ((function
775
            | `Int x -> Result.Ok x
776
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg2) >>=
777
            ((fun arg2  ->
778
                ((function
779
                  | `Int x -> Result.Ok x
780
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
781
                  (fun arg1  ->
782
                     ((function
783
                       | `Null -> Result.Ok None
784
                       | x ->
785
                           ((function
786
                             | `String x -> Result.Ok x
787
                             | _ -> Result.Error "Vhdl_ast.vhdl_type_t") x)
788
                             >>= ((fun x  -> Result.Ok (Some x)))) arg0)
789
                       >>=
790
                       (fun arg0  -> Result.Ok (Range (arg0, arg1, arg2))))))
791
      | `List ((`String "Bit_vector")::arg0::arg1::[]) ->
792
          ((function
793
            | `Int x -> Result.Ok x
794
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
795
            ((fun arg1  ->
796
                ((function
797
                  | `Int x -> Result.Ok x
798
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
799
                  (fun arg0  -> Result.Ok (Bit_vector (arg0, arg1)))))
800
      | `List ((`String "Array")::arg0::arg1::arg2::[]) ->
801
          ((fun x  -> vhdl_type_t_of_yojson x) arg2) >>=
802
            ((fun arg2  ->
803
                ((function
804
                  | `Int x -> Result.Ok x
805
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
806
                  (fun arg1  ->
807
                     ((function
808
                       | `Int x -> Result.Ok x
809
                       | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
810
                       (fun arg0  -> Result.Ok (Array (arg0, arg1, arg2))))))
811
      | `List ((`String "Enumerated")::arg0::[]) ->
812
          ((function
813
            | `List xs ->
814
                map_bind
815
                  (function
816
                   | `String x -> Result.Ok x
817
                   | _ -> Result.Error "Vhdl_ast.vhdl_type_t") [] xs
818
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
819
            ((fun arg0  -> Result.Ok (Enumerated arg0)))
820
      | `List ((`String "Void")::[]) -> Result.Ok Void
821
      | _ -> Result.Error "Vhdl_ast.vhdl_type_t")
822
  [@ocaml.warning "-A"])
823

    
824
and (vhdl_subtype_indication_t_to_yojson :
825
      vhdl_subtype_indication_t -> Yojson.Safe.json)
826
  =
827
  ((let open! Ppx_deriving_yojson_runtime in
828
      fun x  ->
829
        let fields = []  in
830
        let fields =
831
          if x.const = NoConstraint
832
          then fields
833
          else
834
            ("const", (((fun x  -> vhdl_constraint_t_to_yojson x)) x.const))
835
            :: fields
836
           in
837
        let fields =
838
          if x.functionName = NoName
839
          then fields
840
          else
841
            ("functionName",
842
              (((fun x  -> vhdl_name_t_to_yojson x)) x.functionName))
843
            :: fields
844
           in
845
        let fields =
846
          if x.name = NoName
847
          then fields
848
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
849
            fields
850
           in
851
        `Assoc fields)
852
  [@ocaml.warning "-A"])
853

    
854
and (vhdl_subtype_indication_t_of_yojson :
855
      Yojson.Safe.json ->
856
        vhdl_subtype_indication_t Ppx_deriving_yojson_runtime.error_or)
857
  =
858
  ((let open! Ppx_deriving_yojson_runtime in
859
      function
860
      | `Assoc xs ->
861
          let rec loop xs ((arg0,arg1,arg2) as _state) =
862
            match xs with
863
            | ("name",x)::xs ->
864
                loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
865
            | ("functionName",x)::xs ->
866
                loop xs (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
867
            | ("const",x)::xs ->
868
                loop xs
869
                  (arg0, arg1, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
870
            | [] ->
871
                arg2 >>=
872
                  ((fun arg2  ->
873
                      arg1 >>=
874
                        (fun arg1  ->
875
                           arg0 >>=
876
                             (fun arg0  ->
877
                                Result.Ok
878
                                  {
879
                                    name = arg0;
880
                                    functionName = arg1;
881
                                    const = arg2
882
                                  }))))
883
            | _::xs -> loop xs _state  in
884
          loop xs
885
            ((Result.Ok NoName), (Result.Ok NoName),
886
              (Result.Ok NoConstraint))
887
      | _ -> Result.Error "Vhdl_ast.vhdl_subtype_indication_t")
888
  [@ocaml.warning "-A"])
889

    
890
and (vhdl_discrete_range_t_to_yojson :
891
      vhdl_discrete_range_t -> Yojson.Safe.json)
892
  =
893
  ((let open! Ppx_deriving_yojson_runtime in
894
      function
895
      | SubDiscreteRange arg0 ->
896
          `List
897
            [`String "SUB_DISCRETE_RANGE";
898
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x)) arg0]
899
      | NamedRange arg0 ->
900
          `List
901
            [`String "NAMED_RANGE";
902
            ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
903
      | DirectedRange arg0 ->
904
          `List
905
            [`String "RANGE_WITH_DIRECTION";
906
            (let fields = []  in
907
             let fields =
908
               ("_to", ((fun x  -> vhdl_expr_t_to_yojson x) arg0._to)) ::
909
               fields  in
910
             let fields =
911
               ("from", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.from)) ::
912
               fields  in
913
             let fields =
914
               ("direction",
915
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
916
                    arg0.direction))
917
               :: fields  in
918
             `Assoc fields)])
919
  [@ocaml.warning "-A"])
920

    
921
and (vhdl_discrete_range_t_of_yojson :
922
      Yojson.Safe.json ->
923
        vhdl_discrete_range_t Ppx_deriving_yojson_runtime.error_or)
924
  =
925
  ((let open! Ppx_deriving_yojson_runtime in
926
      function
927
      | `List ((`String "SUB_DISCRETE_RANGE")::arg0::[]) ->
928
          ((fun x  -> vhdl_subtype_indication_t_of_yojson x) arg0) >>=
929
            ((fun arg0  -> Result.Ok (SubDiscreteRange arg0)))
930
      | `List ((`String "NAMED_RANGE")::arg0::[]) ->
931
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
932
            ((fun arg0  -> Result.Ok (NamedRange arg0)))
933
      | `List ((`String "RANGE_WITH_DIRECTION")::arg0::[]) ->
934
          ((function
935
            | `Assoc xs ->
936
                let rec loop xs ((arg0,arg1,arg2) as _state) =
937
                  match xs with
938
                  | ("direction",x)::xs ->
939
                      loop xs
940
                        (((function
941
                           | `String x -> Result.Ok x
942
                           | _ ->
943
                               Result.Error
944
                                 "Vhdl_ast.vhdl_discrete_range_t.direction")
945
                            x), arg1, arg2)
946
                  | ("from",x)::xs ->
947
                      loop xs
948
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
949
                  | ("_to",x)::xs ->
950
                      loop xs
951
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
952
                  | [] ->
953
                      arg2 >>=
954
                        ((fun arg2  ->
955
                            arg1 >>=
956
                              (fun arg1  ->
957
                                 arg0 >>=
958
                                   (fun arg0  ->
959
                                      Result.Ok
960
                                        (DirectedRange
961
                                           {
962
                                             direction = arg0;
963
                                             from = arg1;
964
                                             _to = arg2
965
                                           })))))
966
                  | _::xs -> loop xs _state  in
967
                loop xs
968
                  ((Result.Error "Vhdl_ast.vhdl_discrete_range_t.direction"),
969
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t.from"),
970
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t._to"))
971
            | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")) arg0
972
      | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")
973
  [@ocaml.warning "-A"])
974

    
975
and (vhdl_constraint_t_to_yojson : vhdl_constraint_t -> Yojson.Safe.json) =
976
  ((let open! Ppx_deriving_yojson_runtime in
977
      function
978
      | RefConstraint arg0 ->
979
          `List
980
            [`String "RefConstraint";
981
            (let fields = []  in
982
             let fields =
983
               ("ref_name",
984
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.ref_name))
985
               :: fields  in
986
             `Assoc fields)]
987
      | RangeConstraint arg0 ->
988
          `List
989
            [`String "RANGE_CONSTRAINT";
990
            (let fields = []  in
991
             let fields =
992
               ("range",
993
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
994
               :: fields  in
995
             `Assoc fields)]
996
      | IndexConstraint arg0 ->
997
          `List
998
            [`String "INDEX_CONSTRAINT";
999
            (let fields = []  in
1000
             let fields =
1001
               ("ranges",
1002
                 ((fun x  ->
1003
                     `List
1004
                       (List.map
1005
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1006
                    arg0.ranges))
1007
               :: fields  in
1008
             `Assoc fields)]
1009
      | ArrayConstraint arg0 ->
1010
          `List
1011
            [`String "ARRAY_CONSTRAINT";
1012
            (let fields = []  in
1013
             let fields =
1014
               ("sub", ((fun x  -> vhdl_constraint_t_to_yojson x) arg0.sub))
1015
               :: fields  in
1016
             let fields =
1017
               ("ranges",
1018
                 ((fun x  ->
1019
                     `List
1020
                       (List.map
1021
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1022
                    arg0.ranges))
1023
               :: fields  in
1024
             `Assoc fields)]
1025
      | RecordConstraint  -> `List [`String "RecordConstraint"]
1026
      | NoConstraint  -> `List [`String "NoConstraint"])
1027
  [@ocaml.warning "-A"])
1028

    
1029
and (vhdl_constraint_t_of_yojson :
1030
      Yojson.Safe.json ->
1031
        vhdl_constraint_t Ppx_deriving_yojson_runtime.error_or)
1032
  =
1033
  ((let open! Ppx_deriving_yojson_runtime in
1034
      function
1035
      | `List ((`String "RefConstraint")::arg0::[]) ->
1036
          ((function
1037
            | `Assoc xs ->
1038
                let rec loop xs (arg0 as _state) =
1039
                  match xs with
1040
                  | ("ref_name",x)::xs ->
1041
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
1042
                  | [] ->
1043
                      arg0 >>=
1044
                        ((fun arg0  ->
1045
                            Result.Ok (RefConstraint { ref_name = arg0 })))
1046
                  | _::xs -> loop xs _state  in
1047
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ref_name")
1048
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1049
      | `List ((`String "RANGE_CONSTRAINT")::arg0::[]) ->
1050
          ((function
1051
            | `Assoc xs ->
1052
                let rec loop xs (arg0 as _state) =
1053
                  match xs with
1054
                  | ("range",x)::xs ->
1055
                      loop xs
1056
                        ((fun x  -> vhdl_discrete_range_t_of_yojson x) x)
1057
                  | [] ->
1058
                      arg0 >>=
1059
                        ((fun arg0  ->
1060
                            Result.Ok (RangeConstraint { range = arg0 })))
1061
                  | _::xs -> loop xs _state  in
1062
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.range")
1063
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1064
      | `List ((`String "INDEX_CONSTRAINT")::arg0::[]) ->
1065
          ((function
1066
            | `Assoc xs ->
1067
                let rec loop xs (arg0 as _state) =
1068
                  match xs with
1069
                  | ("ranges",x)::xs ->
1070
                      loop xs
1071
                        ((function
1072
                          | `List xs ->
1073
                              map_bind
1074
                                (fun x  -> vhdl_discrete_range_t_of_yojson x)
1075
                                [] xs
1076
                          | _ ->
1077
                              Result.Error
1078
                                "Vhdl_ast.vhdl_constraint_t.ranges") x)
1079
                  | [] ->
1080
                      arg0 >>=
1081
                        ((fun arg0  ->
1082
                            Result.Ok (IndexConstraint { ranges = arg0 })))
1083
                  | _::xs -> loop xs _state  in
1084
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ranges")
1085
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1086
      | `List ((`String "ARRAY_CONSTRAINT")::arg0::[]) ->
1087
          ((function
1088
            | `Assoc xs ->
1089
                let rec loop xs ((arg0,arg1) as _state) =
1090
                  match xs with
1091
                  | ("ranges",x)::xs ->
1092
                      loop xs
1093
                        (((function
1094
                           | `List xs ->
1095
                               map_bind
1096
                                 (fun x  -> vhdl_discrete_range_t_of_yojson x)
1097
                                 [] xs
1098
                           | _ ->
1099
                               Result.Error
1100
                                 "Vhdl_ast.vhdl_constraint_t.ranges") x),
1101
                          arg1)
1102
                  | ("sub",x)::xs ->
1103
                      loop xs
1104
                        (arg0, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
1105
                  | [] ->
1106
                      arg1 >>=
1107
                        ((fun arg1  ->
1108
                            arg0 >>=
1109
                              (fun arg0  ->
1110
                                 Result.Ok
1111
                                   (ArrayConstraint
1112
                                      { ranges = arg0; sub = arg1 }))))
1113
                  | _::xs -> loop xs _state  in
1114
                loop xs
1115
                  ((Result.Error "Vhdl_ast.vhdl_constraint_t.ranges"),
1116
                    (Result.Error "Vhdl_ast.vhdl_constraint_t.sub"))
1117
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1118
      | `List ((`String "RecordConstraint")::[]) ->
1119
          Result.Ok RecordConstraint
1120
      | `List ((`String "NoConstraint")::[]) -> Result.Ok NoConstraint
1121
      | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")
1122
  [@ocaml.warning "-A"])
1123

    
1124
and (vhdl_definition_t_to_yojson : vhdl_definition_t -> Yojson.Safe.json) =
1125
  ((let open! Ppx_deriving_yojson_runtime in
1126
      function
1127
      | Type arg0 ->
1128
          `List
1129
            [`String "TYPE_DECLARATION";
1130
            (let fields = []  in
1131
             let fields =
1132
               ("definition",
1133
                 ((fun x  -> vhdl_type_t_to_yojson x) arg0.definition))
1134
               :: fields  in
1135
             let fields =
1136
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1137
               fields  in
1138
             `Assoc fields)]
1139
      | Subtype arg0 ->
1140
          `List
1141
            [`String "SUBTYPE_DECLARATION";
1142
            (let fields = []  in
1143
             let fields =
1144
               ("typ",
1145
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
1146
               :: fields  in
1147
             let fields =
1148
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1149
               fields  in
1150
             `Assoc fields)])
1151
  [@ocaml.warning "-A"])
1152

    
1153
and (vhdl_definition_t_of_yojson :
1154
      Yojson.Safe.json ->
1155
        vhdl_definition_t Ppx_deriving_yojson_runtime.error_or)
1156
  =
1157
  ((let open! Ppx_deriving_yojson_runtime in
1158
      function
1159
      | `List ((`String "TYPE_DECLARATION")::arg0::[]) ->
1160
          ((function
1161
            | `Assoc xs ->
1162
                let rec loop xs ((arg0,arg1) as _state) =
1163
                  match xs with
1164
                  | ("name",x)::xs ->
1165
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1166
                  | ("definition",x)::xs ->
1167
                      loop xs (arg0, ((fun x  -> vhdl_type_t_of_yojson x) x))
1168
                  | [] ->
1169
                      arg1 >>=
1170
                        ((fun arg1  ->
1171
                            arg0 >>=
1172
                              (fun arg0  ->
1173
                                 Result.Ok
1174
                                   (Type { name = arg0; definition = arg1 }))))
1175
                  | _::xs -> loop xs _state  in
1176
                loop xs
1177
                  ((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
1178
                    (Result.Error "Vhdl_ast.vhdl_definition_t.definition"))
1179
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
1180
      | `List ((`String "SUBTYPE_DECLARATION")::arg0::[]) ->
1181
          ((function
1182
            | `Assoc xs ->
1183
                let rec loop xs ((arg0,arg1) as _state) =
1184
                  match xs with
1185
                  | ("name",x)::xs ->
1186
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1187
                  | ("typ",x)::xs ->
1188
                      loop xs
1189
                        (arg0,
1190
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
1191
                             x))
1192
                  | [] ->
1193
                      arg1 >>=
1194
                        ((fun arg1  ->
1195
                            arg0 >>=
1196
                              (fun arg0  ->
1197
                                 Result.Ok
1198
                                   (Subtype { name = arg0; typ = 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.typ"))
1203
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
1204
      | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")
1205
  [@ocaml.warning "-A"])
1206

    
1207
and (vhdl_expr_t_to_yojson : vhdl_expr_t -> Yojson.Safe.json) =
1208
  ((let open! Ppx_deriving_yojson_runtime in
1209
      function
1210
      | Call arg0 ->
1211
          `List [`String "CALL"; ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
1212
      | Cst arg0 ->
1213
          `List
1214
            [`String "CONSTANT_VALUE";
1215
            ((fun x  -> vhdl_cst_val_t_to_yojson x)) arg0]
1216
      | Op arg0 ->
1217
          `List
1218
            [`String "EXPRESSION";
1219
            (let fields = []  in
1220
             let fields =
1221
               if arg0.args = []
1222
               then fields
1223
               else
1224
                 ("args",
1225
                   (((fun x  ->
1226
                        `List
1227
                          (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
1228
                      arg0.args))
1229
                 :: fields
1230
                in
1231
             let fields =
1232
               if arg0.id = ""
1233
               then fields
1234
               else
1235
                 ("id",
1236
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
1237
                      arg0.id))
1238
                 :: fields
1239
                in
1240
             `Assoc fields)]
1241
      | IsNull  -> `List [`String "IsNull"]
1242
      | Time arg0 ->
1243
          `List
1244
            [`String "Time";
1245
            (let fields = []  in
1246
             let fields =
1247
               if arg0.phy_unit = ""
1248
               then fields
1249
               else
1250
                 ("phy_unit",
1251
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
1252
                      arg0.phy_unit))
1253
                 :: fields
1254
                in
1255
             let fields =
1256
               ("value",
1257
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.value))
1258
               :: fields  in
1259
             `Assoc fields)]
1260
      | Sig arg0 ->
1261
          `List
1262
            [`String "Sig";
1263
            (let fields = []  in
1264
             let fields =
1265
               ("att",
1266
                 ((function
1267
                   | None  -> `Null
1268
                   | Some x ->
1269
                       ((fun x  -> vhdl_signal_attributes_t_to_yojson x)) x)
1270
                    arg0.att))
1271
               :: fields  in
1272
             let fields =
1273
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1274
               fields  in
1275
             `Assoc fields)]
1276
      | SuffixMod arg0 ->
1277
          `List
1278
            [`String "SuffixMod";
1279
            (let fields = []  in
1280
             let fields =
1281
               ("selection",
1282
                 ((fun x  -> vhdl_suffix_selection_t_to_yojson x)
1283
                    arg0.selection))
1284
               :: fields  in
1285
             let fields =
1286
               ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.expr)) ::
1287
               fields  in
1288
             `Assoc fields)]
1289
      | Aggregate arg0 ->
1290
          `List
1291
            [`String "AGGREGATE";
1292
            (let fields = []  in
1293
             let fields =
1294
               ("elems",
1295
                 ((fun x  ->
1296
                     `List
1297
                       (List.map (fun x  -> vhdl_element_assoc_t_to_yojson x)
1298
                          x)) arg0.elems))
1299
               :: fields  in
1300
             `Assoc fields)]
1301
      | Others  -> `List [`String "OTHERS"])
1302
  [@ocaml.warning "-A"])
1303

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

    
1450
and (vhdl_name_t_to_yojson : vhdl_name_t -> Yojson.Safe.json) =
1451
  ((let open! Ppx_deriving_yojson_runtime in
1452
      function
1453
      | Simple arg0 ->
1454
          `List
1455
            [`String "SIMPLE_NAME";
1456
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1457
      | Identifier arg0 ->
1458
          `List
1459
            [`String "IDENTIFIER";
1460
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1461
      | Selected arg0 ->
1462
          `List
1463
            [`String "SELECTED_NAME";
1464
            ((fun x  ->
1465
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
1466
      | Index arg0 ->
1467
          `List
1468
            [`String "INDEXED_NAME";
1469
            (let fields = []  in
1470
             let fields =
1471
               ("exprs",
1472
                 ((fun x  ->
1473
                     `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
1474
                    arg0.exprs))
1475
               :: fields  in
1476
             let fields =
1477
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1478
               fields  in
1479
             `Assoc fields)]
1480
      | Slice arg0 ->
1481
          `List
1482
            [`String "SLICE_NAME";
1483
            (let fields = []  in
1484
             let fields =
1485
               ("range",
1486
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
1487
               :: fields  in
1488
             let fields =
1489
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1490
               fields  in
1491
             `Assoc fields)]
1492
      | Attribute arg0 ->
1493
          `List
1494
            [`String "ATTRIBUTE_NAME";
1495
            (let fields = []  in
1496
             let fields =
1497
               if arg0.expr = IsNull
1498
               then fields
1499
               else
1500
                 ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.expr))
1501
                 :: fields
1502
                in
1503
             let fields =
1504
               ("designator",
1505
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.designator))
1506
               :: fields  in
1507
             let fields =
1508
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1509
               fields  in
1510
             `Assoc fields)]
1511
      | Function arg0 ->
1512
          `List
1513
            [`String "FUNCTION_CALL";
1514
            (let fields = []  in
1515
             let fields =
1516
               ("assoc_list",
1517
                 ((fun x  ->
1518
                     `List
1519
                       (List.map (fun x  -> vhdl_assoc_element_t_to_yojson x)
1520
                          x)) arg0.assoc_list))
1521
               :: fields  in
1522
             let fields =
1523
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1524
               fields  in
1525
             `Assoc fields)]
1526
      | NoName  -> `List [`String "NoName"])
1527
  [@ocaml.warning "-A"])
1528

    
1529
and (vhdl_name_t_of_yojson :
1530
      Yojson.Safe.json -> vhdl_name_t Ppx_deriving_yojson_runtime.error_or)
1531
  =
1532
  ((let open! Ppx_deriving_yojson_runtime in
1533
      function
1534
      | `List ((`String "SIMPLE_NAME")::arg0::[]) ->
1535
          ((function
1536
            | `String x -> Result.Ok x
1537
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1538
            ((fun arg0  -> Result.Ok (Simple arg0)))
1539
      | `List ((`String "IDENTIFIER")::arg0::[]) ->
1540
          ((function
1541
            | `String x -> Result.Ok x
1542
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1543
            ((fun arg0  -> Result.Ok (Identifier arg0)))
1544
      | `List ((`String "SELECTED_NAME")::arg0::[]) ->
1545
          ((function
1546
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1547
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1548
            ((fun arg0  -> Result.Ok (Selected arg0)))
1549
      | `List ((`String "INDEXED_NAME")::arg0::[]) ->
1550
          ((function
1551
            | `Assoc xs ->
1552
                let rec loop xs ((arg0,arg1) as _state) =
1553
                  match xs with
1554
                  | ("id",x)::xs ->
1555
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1556
                  | ("exprs",x)::xs ->
1557
                      loop xs
1558
                        (arg0,
1559
                          ((function
1560
                            | `List xs ->
1561
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1562
                                  [] xs
1563
                            | _ -> Result.Error "Vhdl_ast.vhdl_name_t.exprs")
1564
                             x))
1565
                  | [] ->
1566
                      arg1 >>=
1567
                        ((fun arg1  ->
1568
                            arg0 >>=
1569
                              (fun arg0  ->
1570
                                 Result.Ok
1571
                                   (Index { id = arg0; exprs = arg1 }))))
1572
                  | _::xs -> loop xs _state  in
1573
                loop xs
1574
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1575
                    (Result.Error "Vhdl_ast.vhdl_name_t.exprs"))
1576
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1577
      | `List ((`String "SLICE_NAME")::arg0::[]) ->
1578
          ((function
1579
            | `Assoc xs ->
1580
                let rec loop xs ((arg0,arg1) as _state) =
1581
                  match xs with
1582
                  | ("id",x)::xs ->
1583
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1584
                  | ("range",x)::xs ->
1585
                      loop xs
1586
                        (arg0,
1587
                          ((fun x  -> vhdl_discrete_range_t_of_yojson x) x))
1588
                  | [] ->
1589
                      arg1 >>=
1590
                        ((fun arg1  ->
1591
                            arg0 >>=
1592
                              (fun arg0  ->
1593
                                 Result.Ok
1594
                                   (Slice { id = arg0; range = arg1 }))))
1595
                  | _::xs -> loop xs _state  in
1596
                loop xs
1597
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1598
                    (Result.Error "Vhdl_ast.vhdl_name_t.range"))
1599
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1600
      | `List ((`String "ATTRIBUTE_NAME")::arg0::[]) ->
1601
          ((function
1602
            | `Assoc xs ->
1603
                let rec loop xs ((arg0,arg1,arg2) as _state) =
1604
                  match xs with
1605
                  | ("id",x)::xs ->
1606
                      loop xs
1607
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
1608
                  | ("designator",x)::xs ->
1609
                      loop xs
1610
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
1611
                  | ("expr",x)::xs ->
1612
                      loop xs
1613
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1614
                  | [] ->
1615
                      arg2 >>=
1616
                        ((fun arg2  ->
1617
                            arg1 >>=
1618
                              (fun arg1  ->
1619
                                 arg0 >>=
1620
                                   (fun arg0  ->
1621
                                      Result.Ok
1622
                                        (Attribute
1623
                                           {
1624
                                             id = arg0;
1625
                                             designator = arg1;
1626
                                             expr = arg2
1627
                                           })))))
1628
                  | _::xs -> loop xs _state  in
1629
                loop xs
1630
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1631
                    (Result.Error "Vhdl_ast.vhdl_name_t.designator"),
1632
                    (Result.Ok IsNull))
1633
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1634
      | `List ((`String "FUNCTION_CALL")::arg0::[]) ->
1635
          ((function
1636
            | `Assoc xs ->
1637
                let rec loop xs ((arg0,arg1) as _state) =
1638
                  match xs with
1639
                  | ("id",x)::xs ->
1640
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1641
                  | ("assoc_list",x)::xs ->
1642
                      loop xs
1643
                        (arg0,
1644
                          ((function
1645
                            | `List xs ->
1646
                                map_bind
1647
                                  (fun x  -> vhdl_assoc_element_t_of_yojson x)
1648
                                  [] xs
1649
                            | _ ->
1650
                                Result.Error
1651
                                  "Vhdl_ast.vhdl_name_t.assoc_list") x))
1652
                  | [] ->
1653
                      arg1 >>=
1654
                        ((fun arg1  ->
1655
                            arg0 >>=
1656
                              (fun arg0  ->
1657
                                 Result.Ok
1658
                                   (Function { id = arg0; assoc_list = arg1 }))))
1659
                  | _::xs -> loop xs _state  in
1660
                loop xs
1661
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1662
                    (Result.Error "Vhdl_ast.vhdl_name_t.assoc_list"))
1663
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1664
      | `List ((`String "NoName")::[]) -> Result.Ok NoName
1665
      | _ -> Result.Error "Vhdl_ast.vhdl_name_t")
1666
  [@ocaml.warning "-A"])
1667

    
1668
and (vhdl_assoc_element_t_to_yojson :
1669
      vhdl_assoc_element_t -> Yojson.Safe.json)
1670
  =
1671
  ((let open! Ppx_deriving_yojson_runtime in
1672
      fun x  ->
1673
        let fields = []  in
1674
        let fields =
1675
          if x.actual_expr = None
1676
          then fields
1677
          else
1678
            ("actual_expr",
1679
              (((function
1680
                 | None  -> `Null
1681
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
1682
                 x.actual_expr))
1683
            :: fields
1684
           in
1685
        let fields =
1686
          if x.actual_designator = None
1687
          then fields
1688
          else
1689
            ("actual_designator",
1690
              (((function
1691
                 | None  -> `Null
1692
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1693
                 x.actual_designator))
1694
            :: fields
1695
           in
1696
        let fields =
1697
          if x.actual_name = None
1698
          then fields
1699
          else
1700
            ("actual_name",
1701
              (((function
1702
                 | None  -> `Null
1703
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1704
                 x.actual_name))
1705
            :: fields
1706
           in
1707
        let fields =
1708
          if x.formal_arg = None
1709
          then fields
1710
          else
1711
            ("formal_arg",
1712
              (((function
1713
                 | None  -> `Null
1714
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1715
                 x.formal_arg))
1716
            :: fields
1717
           in
1718
        let fields =
1719
          if x.formal_name = None
1720
          then fields
1721
          else
1722
            ("formal_name",
1723
              (((function
1724
                 | None  -> `Null
1725
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1726
                 x.formal_name))
1727
            :: fields
1728
           in
1729
        `Assoc fields)
1730
  [@ocaml.warning "-A"])
1731

    
1732
and (vhdl_assoc_element_t_of_yojson :
1733
      Yojson.Safe.json ->
1734
        vhdl_assoc_element_t Ppx_deriving_yojson_runtime.error_or)
1735
  =
1736
  ((let open! Ppx_deriving_yojson_runtime in
1737
      function
1738
      | `Assoc xs ->
1739
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
1740
            match xs with
1741
            | ("formal_name",x)::xs ->
1742
                loop xs
1743
                  (((function
1744
                     | `Null -> Result.Ok None
1745
                     | x ->
1746
                         ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1747
                           ((fun x  -> Result.Ok (Some x)))) x), arg1, arg2,
1748
                    arg3, arg4)
1749
            | ("formal_arg",x)::xs ->
1750
                loop xs
1751
                  (arg0,
1752
                    ((function
1753
                      | `Null -> Result.Ok None
1754
                      | x ->
1755
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1756
                            ((fun x  -> Result.Ok (Some x)))) x), arg2, arg3,
1757
                    arg4)
1758
            | ("actual_name",x)::xs ->
1759
                loop xs
1760
                  (arg0, arg1,
1761
                    ((function
1762
                      | `Null -> Result.Ok None
1763
                      | x ->
1764
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1765
                            ((fun x  -> Result.Ok (Some x)))) x), arg3, arg4)
1766
            | ("actual_designator",x)::xs ->
1767
                loop xs
1768
                  (arg0, arg1, arg2,
1769
                    ((function
1770
                      | `Null -> Result.Ok None
1771
                      | x ->
1772
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1773
                            ((fun x  -> Result.Ok (Some x)))) x), arg4)
1774
            | ("actual_expr",x)::xs ->
1775
                loop xs
1776
                  (arg0, arg1, arg2, arg3,
1777
                    ((function
1778
                      | `Null -> Result.Ok None
1779
                      | x ->
1780
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
1781
                            ((fun x  -> Result.Ok (Some x)))) x))
1782
            | [] ->
1783
                arg4 >>=
1784
                  ((fun arg4  ->
1785
                      arg3 >>=
1786
                        (fun arg3  ->
1787
                           arg2 >>=
1788
                             (fun arg2  ->
1789
                                arg1 >>=
1790
                                  (fun arg1  ->
1791
                                     arg0 >>=
1792
                                       (fun arg0  ->
1793
                                          Result.Ok
1794
                                            {
1795
                                              formal_name = arg0;
1796
                                              formal_arg = arg1;
1797
                                              actual_name = arg2;
1798
                                              actual_designator = arg3;
1799
                                              actual_expr = arg4
1800
                                            }))))))
1801
            | _::xs -> loop xs _state  in
1802
          loop xs
1803
            ((Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
1804
              (Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
1805
              (Result.Ok (Some IsNull)))
1806
      | _ -> Result.Error "Vhdl_ast.vhdl_assoc_element_t")
1807
  [@ocaml.warning "-A"])
1808

    
1809
and (vhdl_element_assoc_t_to_yojson :
1810
      vhdl_element_assoc_t -> Yojson.Safe.json)
1811
  =
1812
  ((let open! Ppx_deriving_yojson_runtime in
1813
      fun x  ->
1814
        let fields = []  in
1815
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
1816
          :: fields  in
1817
        let fields =
1818
          ("choices",
1819
            ((fun x  ->
1820
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
1821
               x.choices))
1822
          :: fields  in
1823
        `Assoc fields)
1824
  [@ocaml.warning "-A"])
1825

    
1826
and (vhdl_element_assoc_t_of_yojson :
1827
      Yojson.Safe.json ->
1828
        vhdl_element_assoc_t Ppx_deriving_yojson_runtime.error_or)
1829
  =
1830
  ((let open! Ppx_deriving_yojson_runtime in
1831
      function
1832
      | `Assoc xs ->
1833
          let rec loop xs ((arg0,arg1) as _state) =
1834
            match xs with
1835
            | ("choices",x)::xs ->
1836
                loop xs
1837
                  (((function
1838
                     | `List xs ->
1839
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
1840
                     | _ ->
1841
                         Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices")
1842
                      x), arg1)
1843
            | ("expr",x)::xs ->
1844
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1845
            | [] ->
1846
                arg1 >>=
1847
                  ((fun arg1  ->
1848
                      arg0 >>=
1849
                        (fun arg0  ->
1850
                           Result.Ok { choices = arg0; expr = arg1 })))
1851
            | _::xs -> loop xs _state  in
1852
          loop xs
1853
            ((Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices"),
1854
              (Result.Error "Vhdl_ast.vhdl_element_assoc_t.expr"))
1855
      | _ -> Result.Error "Vhdl_ast.vhdl_element_assoc_t")
1856
  [@ocaml.warning "-A"])
1857

    
1858
and (vhdl_array_attributes_t_to_yojson :
1859
      vhdl_array_attributes_t -> Yojson.Safe.json)
1860
  =
1861
  ((let open! Ppx_deriving_yojson_runtime in
1862
      function
1863
      | AAttInt arg0 ->
1864
          `List
1865
            [`String "AAttInt";
1866
            (let fields = []  in
1867
             let fields =
1868
               ("arg",
1869
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
1870
               :: fields  in
1871
             let fields =
1872
               ("id",
1873
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
1874
                    arg0.id))
1875
               :: fields  in
1876
             `Assoc fields)]
1877
      | AAttAscending  -> `List [`String "AAttAscending"])
1878
  [@ocaml.warning "-A"])
1879

    
1880
and (vhdl_array_attributes_t_of_yojson :
1881
      Yojson.Safe.json ->
1882
        vhdl_array_attributes_t Ppx_deriving_yojson_runtime.error_or)
1883
  =
1884
  ((let open! Ppx_deriving_yojson_runtime in
1885
      function
1886
      | `List ((`String "AAttInt")::arg0::[]) ->
1887
          ((function
1888
            | `Assoc xs ->
1889
                let rec loop xs ((arg0,arg1) as _state) =
1890
                  match xs with
1891
                  | ("id",x)::xs ->
1892
                      loop xs
1893
                        (((function
1894
                           | `String x -> Result.Ok x
1895
                           | _ ->
1896
                               Result.Error
1897
                                 "Vhdl_ast.vhdl_array_attributes_t.id") x),
1898
                          arg1)
1899
                  | ("arg",x)::xs ->
1900
                      loop xs
1901
                        (arg0,
1902
                          ((function
1903
                            | `Int x -> Result.Ok x
1904
                            | _ ->
1905
                                Result.Error
1906
                                  "Vhdl_ast.vhdl_array_attributes_t.arg") x))
1907
                  | [] ->
1908
                      arg1 >>=
1909
                        ((fun arg1  ->
1910
                            arg0 >>=
1911
                              (fun arg0  ->
1912
                                 Result.Ok
1913
                                   (AAttInt { id = arg0; arg = arg1 }))))
1914
                  | _::xs -> loop xs _state  in
1915
                loop xs
1916
                  ((Result.Error "Vhdl_ast.vhdl_array_attributes_t.id"),
1917
                    (Result.Error "Vhdl_ast.vhdl_array_attributes_t.arg"))
1918
            | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")) arg0
1919
      | `List ((`String "AAttAscending")::[]) -> Result.Ok AAttAscending
1920
      | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")
1921
  [@ocaml.warning "-A"])
1922

    
1923
and (vhdl_signal_attributes_t_to_yojson :
1924
      vhdl_signal_attributes_t -> Yojson.Safe.json)
1925
  =
1926
  ((let open! Ppx_deriving_yojson_runtime in
1927
      function
1928
      | SigAtt arg0 ->
1929
          `List
1930
            [`String "SigAtt";
1931
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
1932
  [@ocaml.warning "-A"])
1933

    
1934
and (vhdl_signal_attributes_t_of_yojson :
1935
      Yojson.Safe.json ->
1936
        vhdl_signal_attributes_t Ppx_deriving_yojson_runtime.error_or)
1937
  =
1938
  ((let open! Ppx_deriving_yojson_runtime in
1939
      function
1940
      | `List ((`String "SigAtt")::arg0::[]) ->
1941
          ((function
1942
            | `String x -> Result.Ok x
1943
            | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t") arg0)
1944
            >>= ((fun arg0  -> Result.Ok (SigAtt arg0)))
1945
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t")
1946
  [@ocaml.warning "-A"])
1947

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

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

    
1973
and (vhdl_suffix_selection_t_to_yojson :
1974
      vhdl_suffix_selection_t -> Yojson.Safe.json)
1975
  =
1976
  ((let open! Ppx_deriving_yojson_runtime in
1977
      function
1978
      | Idx arg0 ->
1979
          `List
1980
            [`String "Idx";
1981
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0]
1982
      | SuffixRange (arg0,arg1) ->
1983
          `List
1984
            [`String "SuffixRange";
1985
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
1986
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1])
1987
  [@ocaml.warning "-A"])
1988

    
1989
and (vhdl_suffix_selection_t_of_yojson :
1990
      Yojson.Safe.json ->
1991
        vhdl_suffix_selection_t Ppx_deriving_yojson_runtime.error_or)
1992
  =
1993
  ((let open! Ppx_deriving_yojson_runtime in
1994
      function
1995
      | `List ((`String "Idx")::arg0::[]) ->
1996
          ((function
1997
            | `Int x -> Result.Ok x
1998
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg0) >>=
1999
            ((fun arg0  -> Result.Ok (Idx arg0)))
2000
      | `List ((`String "SuffixRange")::arg0::arg1::[]) ->
2001
          ((function
2002
            | `Int x -> Result.Ok x
2003
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg1) >>=
2004
            ((fun arg1  ->
2005
                ((function
2006
                  | `Int x -> Result.Ok x
2007
                  | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2008
                   arg0)
2009
                  >>= (fun arg0  -> Result.Ok (SuffixRange (arg0, arg1)))))
2010
      | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2011
  [@ocaml.warning "-A"])
2012

    
2013
type 'basetype vhdl_type_attributes_t =
2014
  | TAttNoArg of {
2015
  id: string } 
2016
  | TAttIntArg of {
2017
  id: string ;
2018
  arg: int } 
2019
  | TAttValArg of {
2020
  id: string ;
2021
  arg: 'basetype } 
2022
  | TAttStringArg of {
2023
  id: string ;
2024
  arg: string } 
2025

    
2026
let rec pp_vhdl_type_attributes_t
2027
  =
2028
  ((let open! Ppx_deriving_runtime in
2029
      fun poly_basetype  ->
2030
        fun fmt  ->
2031
          function
2032
          | TAttNoArg { id = aid } ->
2033
              (Format.fprintf fmt "@[<2>TAttNoArg {@,";
2034
               (Format.fprintf fmt "@[%s =@ " "id";
2035
                (Format.fprintf fmt "%S") aid;
2036
                Format.fprintf fmt "@]");
2037
               Format.fprintf fmt "@]}")
2038
          | TAttIntArg { id = aid; arg = aarg } ->
2039
              (Format.fprintf fmt "@[<2>TAttIntArg {@,";
2040
               ((Format.fprintf fmt "@[%s =@ " "id";
2041
                 (Format.fprintf fmt "%S") aid;
2042
                 Format.fprintf fmt "@]");
2043
                Format.fprintf fmt ";@ ";
2044
                Format.fprintf fmt "@[%s =@ " "arg";
2045
                (Format.fprintf fmt "%d") aarg;
2046
                Format.fprintf fmt "@]");
2047
               Format.fprintf fmt "@]}")
2048
          | TAttValArg { id = aid; arg = aarg } ->
2049
              (Format.fprintf fmt "@[<2>TAttValArg {@,";
2050
               ((Format.fprintf fmt "@[%s =@ " "id";
2051
                 (Format.fprintf fmt "%S") aid;
2052
                 Format.fprintf fmt "@]");
2053
                Format.fprintf fmt ";@ ";
2054
                Format.fprintf fmt "@[%s =@ " "arg";
2055
                (poly_basetype fmt) aarg;
2056
                Format.fprintf fmt "@]");
2057
               Format.fprintf fmt "@]}")
2058
          | TAttStringArg { id = aid; arg = aarg } ->
2059
              (Format.fprintf fmt "@[<2>TAttStringArg {@,";
2060
               ((Format.fprintf fmt "@[%s =@ " "id";
2061
                 (Format.fprintf fmt "%S") aid;
2062
                 Format.fprintf fmt "@]");
2063
                Format.fprintf fmt ";@ ";
2064
                Format.fprintf fmt "@[%s =@ " "arg";
2065
                (Format.fprintf fmt "%S") aarg;
2066
                Format.fprintf fmt "@]");
2067
               Format.fprintf fmt "@]}"))
2068
  [@ocaml.warning "-A"])
2069

    
2070
and show_vhdl_type_attributes_t  =
2071
  fun poly_basetype  ->
2072
    fun x  ->
2073
      Format.asprintf "%a" (pp_vhdl_type_attributes_t poly_basetype) x
2074

    
2075
let rec vhdl_type_attributes_t_to_yojson :
2076
  'basetype .
2077
    ('basetype -> Yojson.Safe.json) ->
2078
      'basetype vhdl_type_attributes_t -> Yojson.Safe.json
2079
  =
2080
  fun poly_basetype  ->
2081
    ((let open! Ppx_deriving_yojson_runtime in
2082
        function
2083
        | TAttNoArg arg0 ->
2084
            `List
2085
              [`String "TAttNoArg";
2086
              (let fields = []  in
2087
               let fields =
2088
                 ("id",
2089
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2090
                      arg0.id))
2091
                 :: fields  in
2092
               `Assoc fields)]
2093
        | TAttIntArg arg0 ->
2094
            `List
2095
              [`String "TAttIntArg";
2096
              (let fields = []  in
2097
               let fields =
2098
                 ("arg",
2099
                   ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
2100
                 :: fields  in
2101
               let fields =
2102
                 ("id",
2103
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2104
                      arg0.id))
2105
                 :: fields  in
2106
               `Assoc fields)]
2107
        | TAttValArg arg0 ->
2108
            `List
2109
              [`String "TAttValArg";
2110
              (let fields = []  in
2111
               let fields =
2112
                 ("arg", ((poly_basetype : _ -> Yojson.Safe.json) arg0.arg))
2113
                 :: fields  in
2114
               let fields =
2115
                 ("id",
2116
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2117
                      arg0.id))
2118
                 :: fields  in
2119
               `Assoc fields)]
2120
        | TAttStringArg arg0 ->
2121
            `List
2122
              [`String "TAttStringArg";
2123
              (let fields = []  in
2124
               let fields =
2125
                 ("arg",
2126
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2127
                      arg0.arg))
2128
                 :: fields  in
2129
               let fields =
2130
                 ("id",
2131
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2132
                      arg0.id))
2133
                 :: fields  in
2134
               `Assoc fields)])
2135
    [@ocaml.warning "-A"])
2136

    
2137
and vhdl_type_attributes_t_of_yojson :
2138
  'basetype .
2139
    (Yojson.Safe.json -> 'basetype Ppx_deriving_yojson_runtime.error_or) ->
2140
      Yojson.Safe.json ->
2141
        'basetype vhdl_type_attributes_t Ppx_deriving_yojson_runtime.error_or
2142
  =
2143
  fun poly_basetype  ->
2144
    ((let open! Ppx_deriving_yojson_runtime in
2145
        function
2146
        | `List ((`String "TAttNoArg")::arg0::[]) ->
2147
            ((function
2148
              | `Assoc xs ->
2149
                  let rec loop xs (arg0 as _state) =
2150
                    match xs with
2151
                    | ("id",x)::xs ->
2152
                        loop xs
2153
                          ((function
2154
                            | `String x -> Result.Ok x
2155
                            | _ ->
2156
                                Result.Error
2157
                                  "Vhdl_ast.vhdl_type_attributes_t.id") x)
2158
                    | [] ->
2159
                        arg0 >>=
2160
                          ((fun arg0  -> Result.Ok (TAttNoArg { id = arg0 })))
2161
                    | _::xs -> loop xs _state  in
2162
                  loop xs (Result.Error "Vhdl_ast.vhdl_type_attributes_t.id")
2163
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2164
        | `List ((`String "TAttIntArg")::arg0::[]) ->
2165
            ((function
2166
              | `Assoc xs ->
2167
                  let rec loop xs ((arg0,arg1) as _state) =
2168
                    match xs with
2169
                    | ("id",x)::xs ->
2170
                        loop xs
2171
                          (((function
2172
                             | `String x -> Result.Ok x
2173
                             | _ ->
2174
                                 Result.Error
2175
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2176
                            arg1)
2177
                    | ("arg",x)::xs ->
2178
                        loop xs
2179
                          (arg0,
2180
                            ((function
2181
                              | `Int x -> Result.Ok x
2182
                              | _ ->
2183
                                  Result.Error
2184
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2185
                    | [] ->
2186
                        arg1 >>=
2187
                          ((fun arg1  ->
2188
                              arg0 >>=
2189
                                (fun arg0  ->
2190
                                   Result.Ok
2191
                                     (TAttIntArg { id = arg0; arg = arg1 }))))
2192
                    | _::xs -> loop xs _state  in
2193
                  loop xs
2194
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2195
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2196
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2197
        | `List ((`String "TAttValArg")::arg0::[]) ->
2198
            ((function
2199
              | `Assoc xs ->
2200
                  let rec loop xs ((arg0,arg1) as _state) =
2201
                    match xs with
2202
                    | ("id",x)::xs ->
2203
                        loop xs
2204
                          (((function
2205
                             | `String x -> Result.Ok x
2206
                             | _ ->
2207
                                 Result.Error
2208
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2209
                            arg1)
2210
                    | ("arg",x)::xs ->
2211
                        loop xs
2212
                          (arg0,
2213
                            ((poly_basetype : Yojson.Safe.json -> _ error_or)
2214
                               x))
2215
                    | [] ->
2216
                        arg1 >>=
2217
                          ((fun arg1  ->
2218
                              arg0 >>=
2219
                                (fun arg0  ->
2220
                                   Result.Ok
2221
                                     (TAttValArg { id = arg0; arg = arg1 }))))
2222
                    | _::xs -> loop xs _state  in
2223
                  loop xs
2224
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2225
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2226
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2227
        | `List ((`String "TAttStringArg")::arg0::[]) ->
2228
            ((function
2229
              | `Assoc xs ->
2230
                  let rec loop xs ((arg0,arg1) as _state) =
2231
                    match xs with
2232
                    | ("id",x)::xs ->
2233
                        loop xs
2234
                          (((function
2235
                             | `String x -> Result.Ok x
2236
                             | _ ->
2237
                                 Result.Error
2238
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2239
                            arg1)
2240
                    | ("arg",x)::xs ->
2241
                        loop xs
2242
                          (arg0,
2243
                            ((function
2244
                              | `String x -> Result.Ok x
2245
                              | _ ->
2246
                                  Result.Error
2247
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2248
                    | [] ->
2249
                        arg1 >>=
2250
                          ((fun arg1  ->
2251
                              arg0 >>=
2252
                                (fun arg0  ->
2253
                                   Result.Ok
2254
                                     (TAttStringArg { id = arg0; arg = arg1 }))))
2255
                    | _::xs -> loop xs _state  in
2256
                  loop xs
2257
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2258
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2259
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2260
        | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")
2261
    [@ocaml.warning "-A"])
2262

    
2263
let typ_att_noarg = ["base"; "left"; "right"; "high"; "low"] 
2264
let typ_att_intarg = ["pos"; "val"; "succ"; "pred"; "leftof"; "rightof"] 
2265
let typ_att_valarg = ["image"] 
2266
let typ_att_stringarg = ["value"] 
2267
let array_att_intarg =
2268
  ["left"; "right"; "high"; "low"; "range"; "reverse_range"; "length"] 
2269
type vhdl_parameter_t =
2270
  {
2271
  names: vhdl_name_t list ;
2272
  mode: string list [@default []];
2273
  typ: vhdl_subtype_indication_t ;
2274
  init_val: vhdl_cst_val_t option [@default None]}
2275

    
2276
let rec pp_vhdl_parameter_t :
2277
  Format.formatter -> vhdl_parameter_t -> Ppx_deriving_runtime.unit =
2278
  let __2 () = pp_vhdl_cst_val_t
2279
  
2280
  and __1 () = pp_vhdl_subtype_indication_t
2281
  
2282
  and __0 () = pp_vhdl_name_t
2283
   in
2284
  ((let open! Ppx_deriving_runtime in
2285
      fun fmt  ->
2286
        fun x  ->
2287
          Format.fprintf fmt "@[<2>{ ";
2288
          ((((Format.fprintf fmt "@[%s =@ " "names";
2289
              ((fun x  ->
2290
                  Format.fprintf fmt "@[<2>[";
2291
                  ignore
2292
                    (List.fold_left
2293
                       (fun sep  ->
2294
                          fun x  ->
2295
                            if sep then Format.fprintf fmt ";@ ";
2296
                            ((__0 ()) fmt) x;
2297
                            true) false x);
2298
                  Format.fprintf fmt "@,]@]")) x.names;
2299
              Format.fprintf fmt "@]");
2300
             Format.fprintf fmt ";@ ";
2301
             Format.fprintf fmt "@[%s =@ " "mode";
2302
             ((fun x  ->
2303
                 Format.fprintf fmt "@[<2>[";
2304
                 ignore
2305
                   (List.fold_left
2306
                      (fun sep  ->
2307
                         fun x  ->
2308
                           if sep then Format.fprintf fmt ";@ ";
2309
                           (Format.fprintf fmt "%S") x;
2310
                           true) false x);
2311
                 Format.fprintf fmt "@,]@]")) x.mode;
2312
             Format.fprintf fmt "@]");
2313
            Format.fprintf fmt ";@ ";
2314
            Format.fprintf fmt "@[%s =@ " "typ";
2315
            ((__1 ()) fmt) x.typ;
2316
            Format.fprintf fmt "@]");
2317
           Format.fprintf fmt ";@ ";
2318
           Format.fprintf fmt "@[%s =@ " "init_val";
2319
           ((function
2320
             | None  -> Format.pp_print_string fmt "None"
2321
             | Some x ->
2322
                 (Format.pp_print_string fmt "(Some ";
2323
                  ((__2 ()) fmt) x;
2324
                  Format.pp_print_string fmt ")"))) x.init_val;
2325
           Format.fprintf fmt "@]");
2326
          Format.fprintf fmt "@ }@]")
2327
    [@ocaml.warning "-A"])
2328

    
2329
and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string =
2330
  fun x  -> Format.asprintf "%a" pp_vhdl_parameter_t x
2331

    
2332
let rec (vhdl_parameter_t_to_yojson : vhdl_parameter_t -> Yojson.Safe.json) =
2333
  ((let open! Ppx_deriving_yojson_runtime in
2334
      fun x  ->
2335
        let fields = []  in
2336
        let fields =
2337
          if x.init_val = None
2338
          then fields
2339
          else
2340
            ("init_val",
2341
              (((function
2342
                 | None  -> `Null
2343
                 | Some x -> ((fun x  -> vhdl_cst_val_t_to_yojson x)) x))
2344
                 x.init_val))
2345
            :: fields
2346
           in
2347
        let fields =
2348
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
2349
          :: fields  in
2350
        let fields =
2351
          if x.mode = []
2352
          then fields
2353
          else
2354
            ("mode",
2355
              (((fun x  ->
2356
                   `List
2357
                     (List.map
2358
                        (fun (x : Ppx_deriving_runtime.string)  -> `String x)
2359
                        x))) x.mode))
2360
            :: fields
2361
           in
2362
        let fields =
2363
          ("names",
2364
            ((fun x  ->
2365
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
2366
               x.names))
2367
          :: fields  in
2368
        `Assoc fields)
2369
  [@ocaml.warning "-A"])
2370

    
2371
and (vhdl_parameter_t_of_yojson :
2372
      Yojson.Safe.json ->
2373
        vhdl_parameter_t Ppx_deriving_yojson_runtime.error_or)
2374
  =
2375
  ((let open! Ppx_deriving_yojson_runtime in
2376
      function
2377
      | `Assoc xs ->
2378
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2379
            match xs with
2380
            | ("names",x)::xs ->
2381
                loop xs
2382
                  (((function
2383
                     | `List xs ->
2384
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
2385
                     | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.names") x),
2386
                    arg1, arg2, arg3)
2387
            | ("mode",x)::xs ->
2388
                loop xs
2389
                  (arg0,
2390
                    ((function
2391
                      | `List xs ->
2392
                          map_bind
2393
                            (function
2394
                             | `String x -> Result.Ok x
2395
                             | _ ->
2396
                                 Result.Error
2397
                                   "Vhdl_ast.vhdl_parameter_t.mode") [] xs
2398
                      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.mode") x),
2399
                    arg2, arg3)
2400
            | ("typ",x)::xs ->
2401
                loop xs
2402
                  (arg0, arg1,
2403
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
2404
                    arg3)
2405
            | ("init_val",x)::xs ->
2406
                loop xs
2407
                  (arg0, arg1, arg2,
2408
                    ((function
2409
                      | `Null -> Result.Ok None
2410
                      | x ->
2411
                          ((fun x  -> vhdl_cst_val_t_of_yojson x) x) >>=
2412
                            ((fun x  -> Result.Ok (Some x)))) x))
2413
            | [] ->
2414
                arg3 >>=
2415
                  ((fun arg3  ->
2416
                      arg2 >>=
2417
                        (fun arg2  ->
2418
                           arg1 >>=
2419
                             (fun arg1  ->
2420
                                arg0 >>=
2421
                                  (fun arg0  ->
2422
                                     Result.Ok
2423
                                       {
2424
                                         names = arg0;
2425
                                         mode = arg1;
2426
                                         typ = arg2;
2427
                                         init_val = arg3
2428
                                       })))))
2429
            | _::xs -> loop xs _state  in
2430
          loop xs
2431
            ((Result.Error "Vhdl_ast.vhdl_parameter_t.names"),
2432
              (Result.Ok []), (Result.Error "Vhdl_ast.vhdl_parameter_t.typ"),
2433
              (Result.Ok (Some (CstInt 0))))
2434
      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t")
2435
  [@ocaml.warning "-A"])
2436

    
2437
type vhdl_subprogram_spec_t =
2438
  {
2439
  name: string [@default ""];
2440
  typeMark: vhdl_name_t [@default NoName];
2441
  parameters: vhdl_parameter_t list ;
2442
  isPure: bool [@default false]}
2443

    
2444
let rec pp_vhdl_subprogram_spec_t :
2445
  Format.formatter -> vhdl_subprogram_spec_t -> Ppx_deriving_runtime.unit =
2446
  let __1 () = pp_vhdl_parameter_t
2447
  
2448
  and __0 () = pp_vhdl_name_t
2449
   in
2450
  ((let open! Ppx_deriving_runtime in
2451
      fun fmt  ->
2452
        fun x  ->
2453
          Format.fprintf fmt "@[<2>{ ";
2454
          ((((Format.fprintf fmt "@[%s =@ " "name";
2455
              (Format.fprintf fmt "%S") x.name;
2456
              Format.fprintf fmt "@]");
2457
             Format.fprintf fmt ";@ ";
2458
             Format.fprintf fmt "@[%s =@ " "typeMark";
2459
             ((__0 ()) fmt) x.typeMark;
2460
             Format.fprintf fmt "@]");
2461
            Format.fprintf fmt ";@ ";
2462
            Format.fprintf fmt "@[%s =@ " "parameters";
2463
            ((fun x  ->
2464
                Format.fprintf fmt "@[<2>[";
2465
                ignore
2466
                  (List.fold_left
2467
                     (fun sep  ->
2468
                        fun x  ->
2469
                          if sep then Format.fprintf fmt ";@ ";
2470
                          ((__1 ()) fmt) x;
2471
                          true) false x);
2472
                Format.fprintf fmt "@,]@]")) x.parameters;
2473
            Format.fprintf fmt "@]");
2474
           Format.fprintf fmt ";@ ";
2475
           Format.fprintf fmt "@[%s =@ " "isPure";
2476
           (Format.fprintf fmt "%B") x.isPure;
2477
           Format.fprintf fmt "@]");
2478
          Format.fprintf fmt "@ }@]")
2479
    [@ocaml.warning "-A"])
2480

    
2481
and show_vhdl_subprogram_spec_t :
2482
  vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string =
2483
  fun x  -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x
2484

    
2485
let rec (vhdl_subprogram_spec_t_to_yojson :
2486
          vhdl_subprogram_spec_t -> Yojson.Safe.json)
2487
  =
2488
  ((let open! Ppx_deriving_yojson_runtime in
2489
      fun x  ->
2490
        let fields = []  in
2491
        let fields =
2492
          if x.isPure = false
2493
          then fields
2494
          else
2495
            ("isPure",
2496
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x)) x.isPure))
2497
            :: fields
2498
           in
2499
        let fields =
2500
          ("parameters",
2501
            ((fun x  ->
2502
                `List (List.map (fun x  -> vhdl_parameter_t_to_yojson x) x))
2503
               x.parameters))
2504
          :: fields  in
2505
        let fields =
2506
          if x.typeMark = NoName
2507
          then fields
2508
          else
2509
            ("typeMark", (((fun x  -> vhdl_name_t_to_yojson x)) x.typeMark))
2510
            :: fields
2511
           in
2512
        let fields =
2513
          if x.name = ""
2514
          then fields
2515
          else
2516
            ("name",
2517
              (((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x.name))
2518
            :: fields
2519
           in
2520
        `Assoc fields)
2521
  [@ocaml.warning "-A"])
2522

    
2523
and (vhdl_subprogram_spec_t_of_yojson :
2524
      Yojson.Safe.json ->
2525
        vhdl_subprogram_spec_t Ppx_deriving_yojson_runtime.error_or)
2526
  =
2527
  ((let open! Ppx_deriving_yojson_runtime in
2528
      function
2529
      | `Assoc xs ->
2530
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2531
            match xs with
2532
            | ("name",x)::xs ->
2533
                loop xs
2534
                  (((function
2535
                     | `String x -> Result.Ok x
2536
                     | _ ->
2537
                         Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.name")
2538
                      x), arg1, arg2, arg3)
2539
            | ("typeMark",x)::xs ->
2540
                loop xs
2541
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3)
2542
            | ("parameters",x)::xs ->
2543
                loop xs
2544
                  (arg0, arg1,
2545
                    ((function
2546
                      | `List xs ->
2547
                          map_bind (fun x  -> vhdl_parameter_t_of_yojson x)
2548
                            [] xs
2549
                      | _ ->
2550
                          Result.Error
2551
                            "Vhdl_ast.vhdl_subprogram_spec_t.parameters") x),
2552
                    arg3)
2553
            | ("isPure",x)::xs ->
2554
                loop xs
2555
                  (arg0, arg1, arg2,
2556
                    ((function
2557
                      | `Bool x -> Result.Ok x
2558
                      | _ ->
2559
                          Result.Error
2560
                            "Vhdl_ast.vhdl_subprogram_spec_t.isPure") x))
2561
            | [] ->
2562
                arg3 >>=
2563
                  ((fun arg3  ->
2564
                      arg2 >>=
2565
                        (fun arg2  ->
2566
                           arg1 >>=
2567
                             (fun arg1  ->
2568
                                arg0 >>=
2569
                                  (fun arg0  ->
2570
                                     Result.Ok
2571
                                       {
2572
                                         name = arg0;
2573
                                         typeMark = arg1;
2574
                                         parameters = arg2;
2575
                                         isPure = arg3
2576
                                       })))))
2577
            | _::xs -> loop xs _state  in
2578
          loop xs
2579
            ((Result.Ok ""), (Result.Ok NoName),
2580
              (Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.parameters"),
2581
              (Result.Ok false))
2582
      | _ -> Result.Error "Vhdl_ast.vhdl_subprogram_spec_t")
2583
  [@ocaml.warning "-A"])
2584

    
2585
let arith_funs = ["+"; "-"; "*"; "/"; "mod"; "rem"; "abs"; "**"; "&"] 
2586
let bool_funs = ["and"; "or"; "nand"; "nor"; "xor"; "not"] 
2587
let rel_funs =
2588
  ["<";
2589
  ">";
2590
  "<=";
2591
  ">=";
2592
  "/=";
2593
  "=";
2594
  "?=";
2595
  "?/=";
2596
  "?<";
2597
  "?<=";
2598
  "?>";
2599
  "?>=";
2600
  "??"] 
2601
let shift_funs = ["sll"; "srl"; "sla"; "sra"; "rol"; "ror"] 
2602
type vhdl_sequential_stmt_t =
2603
  | VarAssign of
2604
  {
2605
  label: vhdl_name_t [@default NoName];
2606
  lhs: vhdl_name_t ;
2607
  rhs: vhdl_expr_t } [@name "VARIABLE_ASSIGNMENT_STATEMENT"]
2608
  | SigSeqAssign of
2609
  {
2610
  label: vhdl_name_t [@default NoName];
2611
  lhs: vhdl_name_t ;
2612
  rhs: vhdl_expr_t list } [@name "SIGNAL_ASSIGNMENT_STATEMENT"]
2613
  | If of
2614
  {
2615
  label: vhdl_name_t [@default NoName];
2616
  if_cases: vhdl_if_case_t list ;
2617
  default: vhdl_sequential_stmt_t list [@default []]} [@name "IF_STATEMENT"]
2618
  | Case of
2619
  {
2620
  label: vhdl_name_t [@default NoName];
2621
  guard: vhdl_expr_t ;
2622
  branches: vhdl_case_item_t list } [@name "CASE_STATEMENT_TREE"]
2623
  | Exit of
2624
  {
2625
  label: vhdl_name_t [@default NoName];
2626
  loop_label: string option [@default Some ""];
2627
  condition: vhdl_expr_t option [@default Some IsNull]}
2628
  [@name "EXIT_STATEMENT"]
2629
  | Assert of
2630
  {
2631
  label: vhdl_name_t [@default NoName];
2632
  cond: vhdl_expr_t ;
2633
  report: vhdl_expr_t [@default IsNull];
2634
  severity: vhdl_expr_t [@default IsNull]} [@name "ASSERTION_STATEMENT"]
2635
  | Wait [@name "WAIT_STATEMENT"]
2636
  | Null of {
2637
  label: vhdl_name_t [@default NoName]} [@name "NULL_STATEMENT"]
2638
  | Return of {
2639
  label: vhdl_name_t [@default NoName]} [@name "RETURN_STATEMENT"]
2640
and vhdl_if_case_t =
2641
  {
2642
  if_cond: vhdl_expr_t ;
2643
  if_block: vhdl_sequential_stmt_t list }
2644
and vhdl_case_item_t =
2645
  {
2646
  when_cond: vhdl_expr_t list ;
2647
  when_stmt: vhdl_sequential_stmt_t list }
2648

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

    
2844
and show_vhdl_sequential_stmt_t :
2845
  vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string =
2846
  fun x  -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x
2847

    
2848
(* Adapted *)
2849
and pp_vhdl_if_case_t :
2850
  Format.formatter -> vhdl_if_case_t -> Ppx_deriving_runtime.unit =
2851
  let __1 () = pp_vhdl_sequential_stmt_t
2852
  
2853
  and __0 () = pp_vhdl_expr_t
2854
   in
2855
  ((let open! Ppx_deriving_runtime in
2856
      fun fmt  ->
2857
        fun x  ->
2858
          Format.fprintf fmt " (";
2859
          ((__0 ()) fmt) x.if_cond;
2860
          Format.fprintf fmt ") then@;<0 2>";
2861
          ((fun x  ->
2862
             ignore
2863
               (List.fold_left
2864
                  (fun sep  ->
2865
                     fun x  ->
2866
                             if sep then Format.fprintf fmt "@;<0 2>";
2867
                       ((__1 ()) fmt) x;
2868
                       true) false x);
2869
          )) x.if_block;)
2870
    [@ocaml.warning "-A"])
2871

    
2872
and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string =
2873
  fun x  -> Format.asprintf "%a" pp_vhdl_if_case_t x
2874

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

    
2905
and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string =
2906
  fun x  -> Format.asprintf "%a" pp_vhdl_case_item_t x
2907

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

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

    
3406
and (vhdl_if_case_t_to_yojson : vhdl_if_case_t -> Yojson.Safe.json) =
3407
  ((let open! Ppx_deriving_yojson_runtime in
3408
      fun x  ->
3409
        let fields = []  in
3410
        let fields =
3411
          ("if_block",
3412
            ((fun x  ->
3413
                `List
3414
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3415
               x.if_block))
3416
          :: fields  in
3417
        let fields =
3418
          ("if_cond", ((fun x  -> vhdl_expr_t_to_yojson x) x.if_cond)) ::
3419
          fields  in
3420
        `Assoc fields)
3421
  [@ocaml.warning "-A"])
3422

    
3423
and (vhdl_if_case_t_of_yojson :
3424
      Yojson.Safe.json -> vhdl_if_case_t Ppx_deriving_yojson_runtime.error_or)
3425
  =
3426
  ((let open! Ppx_deriving_yojson_runtime in
3427
      function
3428
      | `Assoc xs ->
3429
          let rec loop xs ((arg0,arg1) as _state) =
3430
            match xs with
3431
            | ("if_cond",x)::xs ->
3432
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
3433
            | ("if_block",x)::xs ->
3434
                loop xs
3435
                  (arg0,
3436
                    ((function
3437
                      | `List xs ->
3438
                          map_bind
3439
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3440
                            xs
3441
                      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t.if_block")
3442
                       x))
3443
            | [] ->
3444
                arg1 >>=
3445
                  ((fun arg1  ->
3446
                      arg0 >>=
3447
                        (fun arg0  ->
3448
                           Result.Ok { if_cond = arg0; if_block = arg1 })))
3449
            | _::xs -> loop xs _state  in
3450
          loop xs
3451
            ((Result.Error "Vhdl_ast.vhdl_if_case_t.if_cond"),
3452
              (Result.Error "Vhdl_ast.vhdl_if_case_t.if_block"))
3453
      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t")
3454
  [@ocaml.warning "-A"])
3455

    
3456
and (vhdl_case_item_t_to_yojson : vhdl_case_item_t -> Yojson.Safe.json) =
3457
  ((let open! Ppx_deriving_yojson_runtime in
3458
      fun x  ->
3459
        let fields = []  in
3460
        let fields =
3461
          ("when_stmt",
3462
            ((fun x  ->
3463
                `List
3464
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3465
               x.when_stmt))
3466
          :: fields  in
3467
        let fields =
3468
          ("when_cond",
3469
            ((fun x  ->
3470
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
3471
               x.when_cond))
3472
          :: fields  in
3473
        `Assoc fields)
3474
  [@ocaml.warning "-A"])
3475

    
3476
and (vhdl_case_item_t_of_yojson :
3477
      Yojson.Safe.json ->
3478
        vhdl_case_item_t Ppx_deriving_yojson_runtime.error_or)
3479
  =
3480
  ((let open! Ppx_deriving_yojson_runtime in
3481
      function
3482
      | `Assoc xs ->
3483
          let rec loop xs ((arg0,arg1) as _state) =
3484
            match xs with
3485
            | ("when_cond",x)::xs ->
3486
                loop xs
3487
                  (((function
3488
                     | `List xs ->
3489
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
3490
                     | _ ->
3491
                         Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond")
3492
                      x), arg1)
3493
            | ("when_stmt",x)::xs ->
3494
                loop xs
3495
                  (arg0,
3496
                    ((function
3497
                      | `List xs ->
3498
                          map_bind
3499
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3500
                            xs
3501
                      | _ ->
3502
                          Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt")
3503
                       x))
3504
            | [] ->
3505
                arg1 >>=
3506
                  ((fun arg1  ->
3507
                      arg0 >>=
3508
                        (fun arg0  ->
3509
                           Result.Ok { when_cond = arg0; when_stmt = arg1 })))
3510
            | _::xs -> loop xs _state  in
3511
          loop xs
3512
            ((Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond"),
3513
              (Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt"))
3514
      | _ -> Result.Error "Vhdl_ast.vhdl_case_item_t")
3515
  [@ocaml.warning "-A"])
3516

    
3517
type vhdl_declaration_t =
3518
  | VarDecl of
3519
  {
3520
  names: vhdl_name_t list ;
3521
  typ: vhdl_subtype_indication_t ;
3522
  init_val: vhdl_cst_val_t option [@default None]}
3523
  [@name "VARIABLE_DECLARATION"]
3524
  | CstDecl of
3525
  {
3526
  names: vhdl_name_t list ;
3527
  typ: vhdl_subtype_indication_t ;
3528
  init_val: vhdl_cst_val_t } [@name "CONSTANT_DECLARATION"]
3529
  | SigDecl of
3530
  {
3531
  names: vhdl_name_t list ;
3532
  typ: vhdl_subtype_indication_t ;
3533
  init_val: vhdl_cst_val_t option [@default None]}
3534
  [@name "SIGNAL_DECLARATION"]
3535
  | Subprogram of
3536
  {
3537
  name: vhdl_name_t [@default NoName];
3538
  kind: string [@default ""];
3539
  spec: vhdl_subprogram_spec_t
3540
    [@default
3541
      { name = ""; typeMark = NoName; parameters = []; isPure = false }];
3542
  decl_part: vhdl_declaration_t list [@default []];
3543
  stmts: vhdl_sequential_stmt_t list [@default []]} [@name "SUBPROGRAM_BODY"]
3544

    
3545
(* Needs adaptation for: SubProgram *)
3546
let rec pp_vhdl_declaration_t :
3547
  Format.formatter -> vhdl_declaration_t -> Ppx_deriving_runtime.unit =
3548
  let __12 () = pp_vhdl_sequential_stmt_t
3549
  
3550
  and __11 () = pp_vhdl_declaration_t
3551
  
3552
  and __10 () = pp_vhdl_subprogram_spec_t
3553
  
3554
  and __9 () = pp_vhdl_name_t
3555
  
3556
  and __8 () = pp_vhdl_cst_val_t
3557
  
3558
  and __7 () = pp_vhdl_subtype_indication_t
3559
  
3560
  and __6 () = pp_vhdl_name_t
3561
  
3562
  and __5 () = pp_vhdl_cst_val_t
3563
  
3564
  and __4 () = pp_vhdl_subtype_indication_t
3565
  
3566
  and __3 () = pp_vhdl_name_t
3567
  
3568
  and __2 () = pp_vhdl_cst_val_t
3569
  
3570
  and __1 () = pp_vhdl_subtype_indication_t
3571
  
3572
  and __0 () = pp_vhdl_name_t
3573
   in
3574
  ((let open! Ppx_deriving_runtime in
3575
      fun fmt  ->
3576
        function
3577
        | VarDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3578
            (Format.fprintf fmt "variable ";
3579
             ((((fun x  ->
3580
                    ignore
3581
                      (List.fold_left
3582
                         (fun sep  ->
3583
                            fun x  ->
3584
                              if sep then Format.fprintf fmt ",";
3585
                              ((__0 ()) fmt) x;
3586
                              true) false x);)) anames;
3587
               Format.fprintf fmt " : ";
3588
               ((__1 ()) fmt) atyp;
3589
              ((function
3590
                | None  -> Format.pp_print_string fmt ""
3591
                | Some x ->
3592
                    (Format.fprintf fmt ":=";
3593
                     ((__2 ()) fmt) x;))) ainit_val);
3594
            ))
3595
        | CstDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3596
            (Format.fprintf fmt "constant ";
3597
             ((((fun x  ->
3598
                    ignore
3599
                      (List.fold_left
3600
                         (fun sep  ->
3601
                            fun x  ->
3602
                              if sep then Format.fprintf fmt ",";
3603
                              ((__3 ()) fmt) x;
3604
                              true) false x);)) anames;
3605
               Format.fprintf fmt " : ";
3606
               ((__4 ()) fmt) atyp;
3607
              Format.fprintf fmt ":=";
3608
              ((__5 ()) fmt) ainit_val)))
3609
        | SigDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3610
            (Format.fprintf fmt "signal ";
3611
            ((fun x  ->
3612
              ignore
3613
              (List.fold_left
3614
                (fun sep  ->
3615
                  fun x  ->
3616
                    if sep then Format.fprintf fmt ",";
3617
                                ((__6 ()) fmt) x;
3618
                                true) false x);
3619
              )) anames;
3620
            Format.fprintf fmt " : ";
3621
            ((__7 ()) fmt) atyp;
3622
            (function
3623
              | None  -> Format.pp_print_string fmt ""
3624
              | Some x ->
3625
                  (Format.fprintf fmt ":=";
3626
                  ((__8 ()) fmt) x;)
3627
            ) ainit_val)
3628
        | Subprogram
3629
            { name = aname; kind = akind; spec = aspec;
3630
              decl_part = adecl_part; stmts = astmts }
3631
            ->
3632
            (Format.fprintf fmt "@[<2>Subprogram {@,";
3633
             (((((Format.fprintf fmt "@[%s =@ " "name";
3634
                  ((__9 ()) fmt) aname;
3635
                  Format.fprintf fmt "@]");
3636
                 Format.fprintf fmt ";@ ";
3637
                 Format.fprintf fmt "@[%s =@ " "kind";
3638
                 (Format.fprintf fmt "%S") akind;
3639
                 Format.fprintf fmt "@]");
3640
                Format.fprintf fmt ";@ ";
3641
                Format.fprintf fmt "@[%s =@ " "spec";
3642
                ((__10 ()) fmt) aspec;
3643
                Format.fprintf fmt "@]");
3644
               Format.fprintf fmt ";@ ";
3645
               Format.fprintf fmt "@[%s =@ " "decl_part";
3646
               ((fun x  ->
3647
                   Format.fprintf fmt "@[<2>[";
3648
                   ignore
3649
                     (List.fold_left
3650
                        (fun sep  ->
3651
                           fun x  ->
3652
                             if sep then Format.fprintf fmt ";@ ";
3653
                             ((__11 ()) fmt) x;
3654
                             true) false x);
3655
                   Format.fprintf fmt "@,]@]")) adecl_part;
3656
               Format.fprintf fmt "@]");
3657
              Format.fprintf fmt ";@ ";
3658
              Format.fprintf fmt "@[%s =@ " "stmts";
3659
              ((fun x  ->
3660
                  Format.fprintf fmt "@[<2>[";
3661
                  ignore
3662
                    (List.fold_left
3663
                       (fun sep  ->
3664
                          fun x  ->
3665
                            if sep then Format.fprintf fmt ";@ ";
3666
                            ((__12 ()) fmt) x;
3667
                            true) false x);
3668
                  Format.fprintf fmt "@,]@]")) astmts;
3669
              Format.fprintf fmt "@]");
3670
             Format.fprintf fmt "@]}"))
3671
    [@ocaml.warning "-A"])
3672

    
3673
and show_vhdl_declaration_t :
3674
  vhdl_declaration_t -> Ppx_deriving_runtime.string =
3675
  fun x  -> Format.asprintf "%a" pp_vhdl_declaration_t x
3676

    
3677
let rec (vhdl_declaration_t_to_yojson :
3678
          vhdl_declaration_t -> Yojson.Safe.json)
3679
  =
3680
  ((let open! Ppx_deriving_yojson_runtime in
3681
      function
3682
      | VarDecl arg0 ->
3683
          `List
3684
            [`String "VARIABLE_DECLARATION";
3685
            (let fields = []  in
3686
             let fields =
3687
               if arg0.init_val = None
3688
               then fields
3689
               else
3690
                 ("init_val",
3691
                   (((function
3692
                      | None  -> `Null
3693
                      | Some x -> ((fun x  -> vhdl_cst_val_t_to_yojson x)) x))
3694
                      arg0.init_val))
3695
                 :: fields
3696
                in
3697
             let fields =
3698
               ("typ",
3699
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
3700
               :: fields  in
3701
             let fields =
3702
               ("names",
3703
                 ((fun x  ->
3704
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
3705
                    arg0.names))
3706
               :: fields  in
3707
             `Assoc fields)]
3708
      | CstDecl arg0 ->
3709
          `List
3710
            [`String "CONSTANT_DECLARATION";
3711
            (let fields = []  in
3712
             let fields =
3713
               ("init_val",
3714
                 ((fun x  -> vhdl_cst_val_t_to_yojson x) arg0.init_val))
3715
               :: fields  in
3716
             let fields =
3717
               ("typ",
3718
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
3719
               :: fields  in
3720
             let fields =
3721
               ("names",
3722
                 ((fun x  ->
3723
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
3724
                    arg0.names))
3725
               :: fields  in
3726
             `Assoc fields)]
3727
      | SigDecl arg0 ->
3728
          `List
3729
            [`String "SIGNAL_DECLARATION";
3730
            (let fields = []  in
3731
             let fields =
3732
               if arg0.init_val = None
3733
               then fields
3734
               else
3735
                 ("init_val",
3736
                   (((function
3737
                      | None  -> `Null
3738
                      | Some x -> ((fun x  -> vhdl_cst_val_t_to_yojson x)) x))
3739
                      arg0.init_val))
3740
                 :: fields
3741
                in
3742
             let fields =
3743
               ("typ",
3744
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
3745
               :: fields  in
3746
             let fields =
3747
               ("names",
3748
                 ((fun x  ->
3749
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
3750
                    arg0.names))
3751
               :: fields  in
3752
             `Assoc fields)]
3753
      | Subprogram arg0 ->
3754
          `List
3755
            [`String "SUBPROGRAM_BODY";
3756
            (let fields = []  in
3757
             let fields =
3758
               if arg0.stmts = []
3759
               then fields
3760
               else
3761
                 ("stmts",
3762
                   (((fun x  ->
3763
                        `List
3764
                          (List.map
3765
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
3766
                      arg0.stmts))
3767
                 :: fields
3768
                in
3769
             let fields =
3770
               if arg0.decl_part = []
3771
               then fields
3772
               else
3773
                 ("decl_part",
3774
                   (((fun x  ->
3775
                        `List
3776
                          (List.map
3777
                             (fun x  -> vhdl_declaration_t_to_yojson x) x)))
3778
                      arg0.decl_part))
3779
                 :: fields
3780
                in
3781
             let fields =
3782
               if
3783
                 arg0.spec =
3784
                   {
3785
                     name = "";
3786
                     typeMark = NoName;
3787
                     parameters = [];
3788
                     isPure = false
3789
                   }
3790
               then fields
3791
               else
3792
                 ("spec",
3793
                   (((fun x  -> vhdl_subprogram_spec_t_to_yojson x))
3794
                      arg0.spec))
3795
                 :: fields
3796
                in
3797
             let fields =
3798
               if arg0.kind = ""
3799
               then fields
3800
               else
3801
                 ("kind",
3802
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
3803
                      arg0.kind))
3804
                 :: fields
3805
                in
3806
             let fields =
3807
               if arg0.name = NoName
3808
               then fields
3809
               else
3810
                 ("name", (((fun x  -> vhdl_name_t_to_yojson x)) arg0.name))
3811
                 :: fields
3812
                in
3813
             `Assoc fields)])
3814
  [@ocaml.warning "-A"])
3815

    
3816
and (vhdl_declaration_t_of_yojson :
3817
      Yojson.Safe.json ->
3818
        vhdl_declaration_t Ppx_deriving_yojson_runtime.error_or)
3819
  =
3820
  ((let open! Ppx_deriving_yojson_runtime in
3821
      function
3822
      | `List ((`String "VARIABLE_DECLARATION")::arg0::[]) ->
3823
          ((function
3824
            | `Assoc xs ->
3825
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3826
                  match xs with
3827
                  | ("names",x)::xs ->
3828
                      loop xs
3829
                        (((function
3830
                           | `List xs ->
3831
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
3832
                                 [] xs
3833
                           | _ ->
3834
                               Result.Error
3835
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
3836
                          arg1, arg2)
3837
                  | ("typ",x)::xs ->
3838
                      loop xs
3839
                        (arg0,
3840
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
3841
                             x), arg2)
3842
                  | ("init_val",x)::xs ->
3843
                      loop xs
3844
                        (arg0, arg1,
3845
                          ((function
3846
                            | `Null -> Result.Ok None
3847
                            | x ->
3848
                                ((fun x  -> vhdl_cst_val_t_of_yojson x) x)
3849
                                  >>= ((fun x  -> Result.Ok (Some x)))) x))
3850
                  | [] ->
3851
                      arg2 >>=
3852
                        ((fun arg2  ->
3853
                            arg1 >>=
3854
                              (fun arg1  ->
3855
                                 arg0 >>=
3856
                                   (fun arg0  ->
3857
                                      Result.Ok
3858
                                        (VarDecl
3859
                                           {
3860
                                             names = arg0;
3861
                                             typ = arg1;
3862
                                             init_val = arg2
3863
                                           })))))
3864
                  | _::xs -> loop xs _state  in
3865
                loop xs
3866
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
3867
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
3868
                    (Result.Ok (Some (CstInt 0))))
3869
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
3870
      | `List ((`String "CONSTANT_DECLARATION")::arg0::[]) ->
3871
          ((function
3872
            | `Assoc xs ->
3873
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3874
                  match xs with
3875
                  | ("names",x)::xs ->
3876
                      loop xs
3877
                        (((function
3878
                           | `List xs ->
3879
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
3880
                                 [] xs
3881
                           | _ ->
3882
                               Result.Error
3883
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
3884
                          arg1, arg2)
3885
                  | ("typ",x)::xs ->
3886
                      loop xs
3887
                        (arg0,
3888
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
3889
                             x), arg2)
3890
                  | ("init_val",x)::xs ->
3891
                      loop xs
3892
                        (arg0, arg1,
3893
                          ((fun x  -> vhdl_cst_val_t_of_yojson x) x))
3894
                  | [] ->
3895
                      arg2 >>=
3896
                        ((fun arg2  ->
3897
                            arg1 >>=
3898
                              (fun arg1  ->
3899
                                 arg0 >>=
3900
                                   (fun arg0  ->
3901
                                      Result.Ok
3902
                                        (CstDecl
3903
                                           {
3904
                                             names = arg0;
3905
                                             typ = arg1;
3906
                                             init_val = arg2
3907
                                           })))))
3908
                  | _::xs -> loop xs _state  in
3909
                loop xs
3910
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
3911
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
3912
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.init_val"))
3913
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
3914
      | `List ((`String "SIGNAL_DECLARATION")::arg0::[]) ->
3915
          ((function
3916
            | `Assoc xs ->
3917
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3918
                  match xs with
3919
                  | ("names",x)::xs ->
3920
                      loop xs
3921
                        (((function
3922
                           | `List xs ->
3923
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
3924
                                 [] xs
3925
                           | _ ->
3926
                               Result.Error
3927
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
3928
                          arg1, arg2)
3929
                  | ("typ",x)::xs ->
3930
                      loop xs
3931
                        (arg0,
3932
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
3933
                             x), arg2)
3934
                  | ("init_val",x)::xs ->
3935
                      loop xs
3936
                        (arg0, arg1,
3937
                          ((function
3938
                            | `Null -> Result.Ok None
3939
                            | x ->
3940
                                ((fun x  -> vhdl_cst_val_t_of_yojson x) x)
3941
                                  >>= ((fun x  -> Result.Ok (Some x)))) x))
3942
                  | [] ->
3943
                      arg2 >>=
3944
                        ((fun arg2  ->
3945
                            arg1 >>=
3946
                              (fun arg1  ->
3947
                                 arg0 >>=
3948
                                   (fun arg0  ->
3949
                                      Result.Ok
3950
                                        (SigDecl
3951
                                           {
3952
                                             names = arg0;
3953
                                             typ = arg1;
3954
                                             init_val = arg2
3955
                                           })))))
3956
                  | _::xs -> loop xs _state  in
3957
                loop xs
3958
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
3959
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
3960
                    (Result.Ok (Some (CstInt 0))))
3961
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
3962
      | `List ((`String "SUBPROGRAM_BODY")::arg0::[]) ->
3963
          ((function
3964
            | `Assoc xs ->
3965
                let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
3966
                  match xs with
3967
                  | ("name",x)::xs ->
3968
                      loop xs
3969
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2,
3970
                          arg3, arg4)
3971
                  | ("kind",x)::xs ->
3972
                      loop xs
3973
                        (arg0,
3974
                          ((function
3975
                            | `String x -> Result.Ok x
3976
                            | _ ->
3977
                                Result.Error
3978
                                  "Vhdl_ast.vhdl_declaration_t.kind") x),
3979
                          arg2, arg3, arg4)
3980
                  | ("spec",x)::xs ->
3981
                      loop xs
3982
                        (arg0, arg1,
3983
                          ((fun x  -> vhdl_subprogram_spec_t_of_yojson x) x),
3984
                          arg3, arg4)
3985
                  | ("decl_part",x)::xs ->
3986
                      loop xs
3987
                        (arg0, arg1, arg2,
3988
                          ((function
3989
                            | `List xs ->
3990
                                map_bind
3991
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
3992
                                  [] xs
3993
                            | _ ->
3994
                                Result.Error
3995
                                  "Vhdl_ast.vhdl_declaration_t.decl_part") x),
3996
                          arg4)
3997
                  | ("stmts",x)::xs ->
3998
                      loop xs
3999
                        (arg0, arg1, arg2, arg3,
4000
                          ((function
4001
                            | `List xs ->
4002
                                map_bind
4003
                                  (fun x  ->
4004
                                     vhdl_sequential_stmt_t_of_yojson x) []
4005
                                  xs
4006
                            | _ ->
4007
                                Result.Error
4008
                                  "Vhdl_ast.vhdl_declaration_t.stmts") x))
4009
                  | [] ->
4010
                      arg4 >>=
4011
                        ((fun arg4  ->
4012
                            arg3 >>=
4013
                              (fun arg3  ->
4014
                                 arg2 >>=
4015
                                   (fun arg2  ->
4016
                                      arg1 >>=
4017
                                        (fun arg1  ->
4018
                                           arg0 >>=
4019
                                             (fun arg0  ->
4020
                                                Result.Ok
4021
                                                  (Subprogram
4022
                                                     {
4023
                                                       name = arg0;
4024
                                                       kind = arg1;
4025
                                                       spec = arg2;
4026
                                                       decl_part = arg3;
4027
                                                       stmts = arg4
4028
                                                     })))))))
4029
                  | _::xs -> loop xs _state  in
4030
                loop xs
4031
                  ((Result.Ok NoName), (Result.Ok ""),
4032
                    (Result.Ok
4033
                       {
4034
                         name = "";
4035
                         typeMark = NoName;
4036
                         parameters = [];
4037
                         isPure = false
4038
                       }), (Result.Ok []), (Result.Ok []))
4039
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4040
      | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")
4041
  [@ocaml.warning "-A"])
4042

    
4043
type vhdl_signal_condition_t =
4044
  {
4045
  expr: vhdl_expr_t list ;
4046
  cond: vhdl_expr_t [@default IsNull]}
4047

    
4048
(* Adapted *)
4049
let rec pp_vhdl_signal_condition_t :
4050
  Format.formatter -> vhdl_signal_condition_t -> Ppx_deriving_runtime.unit =
4051
  let __1 () = pp_vhdl_expr_t
4052
  
4053
  and __0 () = pp_vhdl_expr_t
4054
   in
4055
  ((let open! Ppx_deriving_runtime in
4056
      fun fmt  ->
4057
        fun x  ->
4058
          ((fun x  ->
4059
              ignore
4060
                (List.fold_left
4061
                   (fun sep  ->
4062
                      fun x  ->
4063
                        if sep then Format.fprintf fmt ";@ ";
4064
                        ((__0 ()) fmt) x;
4065
                        true) false x))) x.expr;
4066
          (match x.cond with
4067
          | IsNull -> Format.fprintf fmt "";
4068
          | _ -> Format.fprintf fmt "when ";
4069
                 ((__1 ()) fmt) x.cond);)
4070
    [@ocaml.warning "-A"])
4071

    
4072
and show_vhdl_signal_condition_t :
4073
  vhdl_signal_condition_t -> Ppx_deriving_runtime.string =
4074
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_condition_t x
4075

    
4076
let rec (vhdl_signal_condition_t_to_yojson :
4077
          vhdl_signal_condition_t -> Yojson.Safe.json)
4078
  =
4079
  ((let open! Ppx_deriving_yojson_runtime in
4080
      fun x  ->
4081
        let fields = []  in
4082
        let fields =
4083
          if x.cond = IsNull
4084
          then fields
4085
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4086
            fields
4087
           in
4088
        let fields =
4089
          ("expr",
4090
            ((fun x  ->
4091
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
4092
               x.expr))
4093
          :: fields  in
4094
        `Assoc fields)
4095
  [@ocaml.warning "-A"])
4096

    
4097
and (vhdl_signal_condition_t_of_yojson :
4098
      Yojson.Safe.json ->
4099
        vhdl_signal_condition_t Ppx_deriving_yojson_runtime.error_or)
4100
  =
4101
  ((let open! Ppx_deriving_yojson_runtime in
4102
      function
4103
      | `Assoc xs ->
4104
          let rec loop xs ((arg0,arg1) as _state) =
4105
            match xs with
4106
            | ("expr",x)::xs ->
4107
                loop xs
4108
                  (((function
4109
                     | `List xs ->
4110
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4111
                     | _ ->
4112
                         Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr")
4113
                      x), arg1)
4114
            | ("cond",x)::xs ->
4115
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4116
            | [] ->
4117
                arg1 >>=
4118
                  ((fun arg1  ->
4119
                      arg0 >>=
4120
                        (fun arg0  -> Result.Ok { expr = arg0; cond = arg1 })))
4121
            | _::xs -> loop xs _state  in
4122
          loop xs
4123
            ((Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr"),
4124
              (Result.Ok IsNull))
4125
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_condition_t")
4126
  [@ocaml.warning "-A"])
4127

    
4128
type vhdl_signal_selection_t =
4129
  {
4130
  expr: vhdl_expr_t ;
4131
  when_sel: vhdl_expr_t list [@default []]}
4132

    
4133
let rec pp_vhdl_signal_selection_t :
4134
  Format.formatter -> vhdl_signal_selection_t -> Ppx_deriving_runtime.unit =
4135
  let __1 () = pp_vhdl_expr_t
4136
  
4137
  and __0 () = pp_vhdl_expr_t
4138
   in
4139
  ((let open! Ppx_deriving_runtime in
4140
      fun fmt  ->
4141
        fun x  ->
4142
          Format.fprintf fmt "@[<2>{ ";
4143
          ((Format.fprintf fmt "@[%s =@ " "expr";
4144
            ((__0 ()) fmt) x.expr;
4145
            Format.fprintf fmt "@]");
4146
           Format.fprintf fmt ";@ ";
4147
           Format.fprintf fmt "@[%s =@ " "when_sel";
4148
           ((fun x  ->
4149
               Format.fprintf fmt "@[<2>[";
4150
               ignore
4151
                 (List.fold_left
4152
                    (fun sep  ->
4153
                       fun x  ->
4154
                         if sep then Format.fprintf fmt ";@ ";
4155
                         ((__1 ()) fmt) x;
4156
                         true) false x);
4157
               Format.fprintf fmt "@,]@]")) x.when_sel;
4158
           Format.fprintf fmt "@]");
4159
          Format.fprintf fmt "@ }@]")
4160
    [@ocaml.warning "-A"])
4161

    
4162
and show_vhdl_signal_selection_t :
4163
  vhdl_signal_selection_t -> Ppx_deriving_runtime.string =
4164
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_selection_t x
4165

    
4166
let rec (vhdl_signal_selection_t_to_yojson :
4167
          vhdl_signal_selection_t -> Yojson.Safe.json)
4168
  =
4169
  ((let open! Ppx_deriving_yojson_runtime in
4170
      fun x  ->
4171
        let fields = []  in
4172
        let fields =
4173
          if x.when_sel = []
4174
          then fields
4175
          else
4176
            ("when_sel",
4177
              (((fun x  ->
4178
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
4179
                 x.when_sel))
4180
            :: fields
4181
           in
4182
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
4183
          :: fields  in
4184
        `Assoc fields)
4185
  [@ocaml.warning "-A"])
4186

    
4187
and (vhdl_signal_selection_t_of_yojson :
4188
      Yojson.Safe.json ->
4189
        vhdl_signal_selection_t Ppx_deriving_yojson_runtime.error_or)
4190
  =
4191
  ((let open! Ppx_deriving_yojson_runtime in
4192
      function
4193
      | `Assoc xs ->
4194
          let rec loop xs ((arg0,arg1) as _state) =
4195
            match xs with
4196
            | ("expr",x)::xs ->
4197
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
4198
            | ("when_sel",x)::xs ->
4199
                loop xs
4200
                  (arg0,
4201
                    ((function
4202
                      | `List xs ->
4203
                          map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4204
                      | _ ->
4205
                          Result.Error
4206
                            "Vhdl_ast.vhdl_signal_selection_t.when_sel") x))
4207
            | [] ->
4208
                arg1 >>=
4209
                  ((fun arg1  ->
4210
                      arg0 >>=
4211
                        (fun arg0  ->
4212
                           Result.Ok { expr = arg0; when_sel = arg1 })))
4213
            | _::xs -> loop xs _state  in
4214
          loop xs
4215
            ((Result.Error "Vhdl_ast.vhdl_signal_selection_t.expr"),
4216
              (Result.Ok []))
4217
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_selection_t")
4218
  [@ocaml.warning "-A"])
4219

    
4220
type vhdl_conditional_signal_t =
4221
  {
4222
  postponed: bool [@default false];
4223
  label: vhdl_name_t [@default NoName];
4224
  lhs: vhdl_name_t ;
4225
  rhs: vhdl_signal_condition_t list ;
4226
  cond: vhdl_expr_t [@default IsNull];
4227
  delay: vhdl_expr_t [@default IsNull]}
4228

    
4229
(* Adapted *)
4230
let rec pp_vhdl_conditional_signal_t :
4231
  Format.formatter -> vhdl_conditional_signal_t -> Ppx_deriving_runtime.unit
4232
  =
4233
  let __4 () = pp_vhdl_expr_t
4234
  
4235
  and __3 () = pp_vhdl_expr_t
4236
  
4237
  and __2 () = pp_vhdl_signal_condition_t
4238
  
4239
  and __1 () = pp_vhdl_name_t
4240
  
4241
  and __0 () = pp_vhdl_name_t
4242
   in
4243
  ((let open! Ppx_deriving_runtime in
4244
      fun fmt  ->
4245
        fun x  ->
4246
          (match x.label with
4247
            | NoName -> Format.fprintf fmt "";
4248
            | _ -> (((__0 ()) fmt) x.label;
4249
                   Format.fprintf fmt ":@ ")
4250
          );
4251
          if (x.postponed) then Format.fprintf fmt "postponed@ ";
4252
          ((__1 ()) fmt) x.lhs;
4253
          Format.fprintf fmt " <= ";
4254
          (match x.delay with
4255
            | IsNull -> Format.fprintf fmt "";
4256
            | _ -> ((__4 ()) fmt) x.delay;
4257
                   Format.fprintf fmt " ");
4258
          ((fun x  ->
4259
             Format.fprintf fmt "@[";
4260
             ignore
4261
               (List.fold_left
4262
                 (fun sep  ->
4263
                   fun x  ->
4264
                     if sep then Format.fprintf fmt "";
4265
                      ((__2 ()) fmt) x;
4266
                      Format.fprintf fmt ";";
4267
                      true) false x);
4268
          Format.fprintf fmt "@]")) x.rhs;
4269
          (match x.cond with
4270
            | IsNull -> Format.fprintf fmt "";
4271
            | _ -> Format.fprintf fmt "when (";
4272
                   ((__3 ()) fmt) x.cond;
4273
                   Format.fprintf fmt ")"))
4274
   [@ocaml.warning "-A"])
4275

    
4276
and show_vhdl_conditional_signal_t :
4277
  vhdl_conditional_signal_t -> Ppx_deriving_runtime.string =
4278
  fun x  -> Format.asprintf "%a" pp_vhdl_conditional_signal_t x
4279

    
4280
let rec (vhdl_conditional_signal_t_to_yojson :
4281
          vhdl_conditional_signal_t -> Yojson.Safe.json)
4282
  =
4283
  ((let open! Ppx_deriving_yojson_runtime in
4284
      fun x  ->
4285
        let fields = []  in
4286
        let fields =
4287
          if x.delay = IsNull
4288
          then fields
4289
          else ("delay", (((fun x  -> vhdl_expr_t_to_yojson x)) x.delay)) ::
4290
            fields
4291
           in
4292
        let fields =
4293
          if x.cond = IsNull
4294
          then fields
4295
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4296
            fields
4297
           in
4298
        let fields =
4299
          ("rhs",
4300
            ((fun x  ->
4301
                `List
4302
                  (List.map (fun x  -> vhdl_signal_condition_t_to_yojson x) x))
4303
               x.rhs))
4304
          :: fields  in
4305
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4306
          fields  in
4307
        let fields =
4308
          if x.label = NoName
4309
          then fields
4310
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4311
            fields
4312
           in
4313
        let fields =
4314
          if x.postponed = false
4315
          then fields
4316
          else
4317
            ("postponed",
4318
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4319
                 x.postponed))
4320
            :: fields
4321
           in
4322
        `Assoc fields)
4323
  [@ocaml.warning "-A"])
4324

    
4325
and (vhdl_conditional_signal_t_of_yojson :
4326
      Yojson.Safe.json ->
4327
        vhdl_conditional_signal_t Ppx_deriving_yojson_runtime.error_or)
4328
  =
4329
  ((let open! Ppx_deriving_yojson_runtime in
4330
      function
4331
      | `Assoc xs ->
4332
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4333
            match xs with
4334
            | ("postponed",x)::xs ->
4335
                loop xs
4336
                  (((function
4337
                     | `Bool x -> Result.Ok x
4338
                     | _ ->
4339
                         Result.Error
4340
                           "Vhdl_ast.vhdl_conditional_signal_t.postponed") x),
4341
                    arg1, arg2, arg3, arg4, arg5)
4342
            | ("label",x)::xs ->
4343
                loop xs
4344
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4345
                    arg4, arg5)
4346
            | ("lhs",x)::xs ->
4347
                loop xs
4348
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4349
                    arg4, arg5)
4350
            | ("rhs",x)::xs ->
4351
                loop xs
4352
                  (arg0, arg1, arg2,
4353
                    ((function
4354
                      | `List xs ->
4355
                          map_bind
4356
                            (fun x  -> vhdl_signal_condition_t_of_yojson x)
4357
                            [] xs
4358
                      | _ ->
4359
                          Result.Error
4360
                            "Vhdl_ast.vhdl_conditional_signal_t.rhs") x),
4361
                    arg4, arg5)
4362
            | ("cond",x)::xs ->
4363
                loop xs
4364
                  (arg0, arg1, arg2, arg3,
4365
                    ((fun x  -> vhdl_expr_t_of_yojson x) x), arg5)
4366
            | ("delay",x)::xs ->
4367
                loop xs
4368
                  (arg0, arg1, arg2, arg3, arg4,
4369
                    ((fun x  -> vhdl_expr_t_of_yojson x) x))
4370
            | [] ->
4371
                arg5 >>=
4372
                  ((fun arg5  ->
4373
                      arg4 >>=
4374
                        (fun arg4  ->
4375
                           arg3 >>=
4376
                             (fun arg3  ->
4377
                                arg2 >>=
4378
                                  (fun arg2  ->
4379
                                     arg1 >>=
4380
                                       (fun arg1  ->
4381
                                          arg0 >>=
4382
                                            (fun arg0  ->
4383
                                               Result.Ok
4384
                                                 {
4385
                                                   postponed = arg0;
4386
                                                   label = arg1;
4387
                                                   lhs = arg2;
4388
                                                   rhs = arg3;
4389
                                                   cond = arg4;
4390
                                                   delay = arg5
4391
                                                 })))))))
4392
            | _::xs -> loop xs _state  in
4393
          loop xs
4394
            ((Result.Ok false), (Result.Ok NoName),
4395
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.lhs"),
4396
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.rhs"),
4397
              (Result.Ok IsNull), (Result.Ok IsNull))
4398
      | _ -> Result.Error "Vhdl_ast.vhdl_conditional_signal_t")
4399
  [@ocaml.warning "-A"])
4400

    
4401
type vhdl_process_t =
4402
  {
4403
  id: vhdl_name_t [@default NoName];
4404
  declarations: vhdl_declaration_t list option
4405
    [@key "PROCESS_DECLARATIVE_PART"][@default Some []];
4406
  active_sigs: vhdl_name_t list [@default []];
4407
  body: vhdl_sequential_stmt_t list
4408
    [@key "PROCESS_STATEMENT_PART"][@default []]}
4409

    
4410
(* Adapted *)
4411
let rec pp_vhdl_process_t :
4412
  Format.formatter -> vhdl_process_t -> Ppx_deriving_runtime.unit =
4413
  let __3 () = pp_vhdl_sequential_stmt_t
4414
  
4415
  and __2 () = pp_vhdl_name_t
4416
  
4417
  and __1 () = pp_vhdl_declaration_t
4418
  
4419
  and __0 () = pp_vhdl_name_t
4420
   in
4421
  ((let open! Ppx_deriving_runtime in
4422
      fun fmt  ->
4423
        fun x  ->
4424
          Format.fprintf fmt "@[<v>process ";
4425
          (match x.active_sigs with
4426
          | [] -> Format.fprintf fmt "";
4427
          | _ -> Format.fprintf fmt "(";
4428
                 ((fun x  ->
4429
                    ignore
4430
                      (List.fold_left
4431
                         (fun sep  ->
4432
                            fun x  ->
4433
                              if sep then Format.fprintf fmt ",";
4434
                              ((__2 ()) fmt) x;
4435
                              true) false x))) x.active_sigs;
4436
                 Format.fprintf fmt ")");
4437
          ((function
4438
             | None  -> Format.pp_print_string fmt ""
4439
             | Some x ->
4440
                  ((fun x  ->
4441
                      Format.fprintf fmt "@[<2>";
4442
                      ignore
4443
                        (List.fold_left
4444
                           (fun sep  ->
4445
                              fun x  ->
4446
                                if sep then Format.fprintf fmt "@;";
4447
                                ((__1 ()) fmt) x;
4448
                                true) false x);
4449
                      Format.fprintf fmt "@]")) x;)) x.declarations;
4450
          Format.fprintf fmt "@;@[<v 2>begin@;";
4451
          ((fun x  ->
4452
               ignore
4453
                 (List.fold_left
4454
                    (fun sep  ->
4455
                       fun x  ->
4456
                         if sep then Format.fprintf fmt "@;";
4457
                         ((__3 ()) fmt) x;
4458
                         true) false x);)) x.body;
4459
          Format.fprintf fmt "@]@;end process;@;";
4460
          Format.fprintf fmt "@]";)
4461
    [@ocaml.warning "-A"])
4462

    
4463
and show_vhdl_process_t : vhdl_process_t -> Ppx_deriving_runtime.string =
4464
  fun x  -> Format.asprintf "%a" pp_vhdl_process_t x
4465

    
4466
let rec (vhdl_process_t_to_yojson : vhdl_process_t -> Yojson.Safe.json) =
4467
  ((let open! Ppx_deriving_yojson_runtime in
4468
      fun x  ->
4469
        let fields = []  in
4470
        let fields =
4471
          if x.body = []
4472
          then fields
4473
          else
4474
            ("PROCESS_STATEMENT_PART",
4475
              (((fun x  ->
4476
                   `List
4477
                     (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x)
4478
                        x))) x.body))
4479
            :: fields
4480
           in
4481
        let fields =
4482
          if x.active_sigs = []
4483
          then fields
4484
          else
4485
            ("active_sigs",
4486
              (((fun x  ->
4487
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
4488
                 x.active_sigs))
4489
            :: fields
4490
           in
4491
        let fields =
4492
          if x.declarations = (Some [])
4493
          then fields
4494
          else
4495
            ("PROCESS_DECLARATIVE_PART",
4496
              (((function
4497
                 | None  -> `Null
4498
                 | Some x ->
4499
                     ((fun x  ->
4500
                         `List
4501
                           (List.map
4502
                              (fun x  -> vhdl_declaration_t_to_yojson x) x)))
4503
                       x)) x.declarations))
4504
            :: fields
4505
           in
4506
        let fields =
4507
          if x.id = NoName
4508
          then fields
4509
          else ("id", (((fun x  -> vhdl_name_t_to_yojson x)) x.id)) :: fields
4510
           in
4511
        `Assoc fields)
4512
  [@ocaml.warning "-A"])
4513

    
4514
and (vhdl_process_t_of_yojson :
4515
      Yojson.Safe.json -> vhdl_process_t Ppx_deriving_yojson_runtime.error_or)
4516
  =
4517
  ((let open! Ppx_deriving_yojson_runtime in
4518
      function
4519
      | `Assoc xs ->
4520
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
4521
            match xs with
4522
            | ("id",x)::xs ->
4523
                loop xs
4524
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3)
4525
            | ("PROCESS_DECLARATIVE_PART",x)::xs ->
4526
                loop xs
4527
                  (arg0,
4528
                    ((function
4529
                      | `Null -> Result.Ok None
4530
                      | x ->
4531
                          ((function
4532
                            | `List xs ->
4533
                                map_bind
4534
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4535
                                  [] xs
4536
                            | _ ->
4537
                                Result.Error
4538
                                  "Vhdl_ast.vhdl_process_t.declarations") x)
4539
                            >>= ((fun x  -> Result.Ok (Some x)))) x), arg2,
4540
                    arg3)
4541
            | ("active_sigs",x)::xs ->
4542
                loop xs
4543
                  (arg0, arg1,
4544
                    ((function
4545
                      | `List xs ->
4546
                          map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4547
                      | _ ->
4548
                          Result.Error "Vhdl_ast.vhdl_process_t.active_sigs")
4549
                       x), arg3)
4550
            | ("PROCESS_STATEMENT_PART",x)::xs ->
4551
                loop xs
4552
                  (arg0, arg1, arg2,
4553
                    ((function
4554
                      | `List xs ->
4555
                          map_bind
4556
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
4557
                            xs
4558
                      | _ -> Result.Error "Vhdl_ast.vhdl_process_t.body") x))
4559
            | [] ->
4560
                arg3 >>=
4561
                  ((fun arg3  ->
4562
                      arg2 >>=
4563
                        (fun arg2  ->
4564
                           arg1 >>=
4565
                             (fun arg1  ->
4566
                                arg0 >>=
4567
                                  (fun arg0  ->
4568
                                     Result.Ok
4569
                                       {
4570
                                         id = arg0;
4571
                                         declarations = arg1;
4572
                                         active_sigs = arg2;
4573
                                         body = arg3
4574
                                       })))))
4575
            | _::xs -> loop xs _state  in
4576
          loop xs
4577
            ((Result.Ok NoName), (Result.Ok (Some [])), (Result.Ok []),
4578
              (Result.Ok []))
4579
      | _ -> Result.Error "Vhdl_ast.vhdl_process_t")
4580
  [@ocaml.warning "-A"])
4581

    
4582
type vhdl_selected_signal_t =
4583
  {
4584
  postponed: bool [@default false];
4585
  label: vhdl_name_t [@default NoName];
4586
  lhs: vhdl_name_t ;
4587
  sel: vhdl_expr_t ;
4588
  branches: vhdl_signal_selection_t list [@default []];
4589
  delay: vhdl_expr_t option }
4590

    
4591
let rec pp_vhdl_selected_signal_t :
4592
  Format.formatter -> vhdl_selected_signal_t -> Ppx_deriving_runtime.unit =
4593
  let __4 () = pp_vhdl_expr_t
4594
  
4595
  and __3 () = pp_vhdl_signal_selection_t
4596
  
4597
  and __2 () = pp_vhdl_expr_t
4598
  
4599
  and __1 () = pp_vhdl_name_t
4600
  
4601
  and __0 () = pp_vhdl_name_t
4602
   in
4603
  ((let open! Ppx_deriving_runtime in
4604
      fun fmt  ->
4605
        fun x  ->
4606
          Format.fprintf fmt "@[<2>{ ";
4607
          ((((((Format.fprintf fmt "@[%s =@ " "postponed";
4608
                (Format.fprintf fmt "%B") x.postponed;
4609
                Format.fprintf fmt "@]");
4610
               Format.fprintf fmt ";@ ";
4611
               Format.fprintf fmt "@[%s =@ " "label";
4612
               ((__0 ()) fmt) x.label;
4613
               Format.fprintf fmt "@]");
4614
              Format.fprintf fmt ";@ ";
4615
              Format.fprintf fmt "@[%s =@ " "lhs";
4616
              ((__1 ()) fmt) x.lhs;
4617
              Format.fprintf fmt "@]");
4618
             Format.fprintf fmt ";@ ";
4619
             Format.fprintf fmt "@[%s =@ " "sel";
4620
             ((__2 ()) fmt) x.sel;
4621
             Format.fprintf fmt "@]");
4622
            Format.fprintf fmt ";@ ";
4623
            Format.fprintf fmt "@[%s =@ " "branches";
4624
            ((fun x  ->
4625
                Format.fprintf fmt "@[<2>[";
4626
                ignore
4627
                  (List.fold_left
4628
                     (fun sep  ->
4629
                        fun x  ->
4630
                          if sep then Format.fprintf fmt ";@ ";
4631
                          ((__3 ()) fmt) x;
4632
                          true) false x);
4633
                Format.fprintf fmt "@,]@]")) x.branches;
4634
            Format.fprintf fmt "@]");
4635
           Format.fprintf fmt ";@ ";
4636
           Format.fprintf fmt "@[%s =@ " "delay";
4637
           ((function
4638
             | None  -> Format.pp_print_string fmt "None"
4639
             | Some x ->
4640
                 (Format.pp_print_string fmt "(Some ";
4641
                  ((__4 ()) fmt) x;
4642
                  Format.pp_print_string fmt ")"))) x.delay;
4643
           Format.fprintf fmt "@]");
4644
          Format.fprintf fmt "@ }@]")
4645
    [@ocaml.warning "-A"])
4646

    
4647
and show_vhdl_selected_signal_t :
4648
  vhdl_selected_signal_t -> Ppx_deriving_runtime.string =
4649
  fun x  -> Format.asprintf "%a" pp_vhdl_selected_signal_t x
4650

    
4651
let rec (vhdl_selected_signal_t_to_yojson :
4652
          vhdl_selected_signal_t -> Yojson.Safe.json)
4653
  =
4654
  ((let open! Ppx_deriving_yojson_runtime in
4655
      fun x  ->
4656
        let fields = []  in
4657
        let fields =
4658
          ("delay",
4659
            ((function
4660
              | None  -> `Null
4661
              | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x) x.delay))
4662
          :: fields  in
4663
        let fields =
4664
          if x.branches = []
4665
          then fields
4666
          else
4667
            ("branches",
4668
              (((fun x  ->
4669
                   `List
4670
                     (List.map
4671
                        (fun x  -> vhdl_signal_selection_t_to_yojson x) x)))
4672
                 x.branches))
4673
            :: fields
4674
           in
4675
        let fields = ("sel", ((fun x  -> vhdl_expr_t_to_yojson x) x.sel)) ::
4676
          fields  in
4677
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4678
          fields  in
4679
        let fields =
4680
          if x.label = NoName
4681
          then fields
4682
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4683
            fields
4684
           in
4685
        let fields =
4686
          if x.postponed = false
4687
          then fields
4688
          else
4689
            ("postponed",
4690
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4691
                 x.postponed))
4692
            :: fields
4693
           in
4694
        `Assoc fields)
4695
  [@ocaml.warning "-A"])
4696

    
4697
and (vhdl_selected_signal_t_of_yojson :
4698
      Yojson.Safe.json ->
4699
        vhdl_selected_signal_t Ppx_deriving_yojson_runtime.error_or)
4700
  =
4701
  ((let open! Ppx_deriving_yojson_runtime in
4702
      function
4703
      | `Assoc xs ->
4704
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4705
            match xs with
4706
            | ("postponed",x)::xs ->
4707
                loop xs
4708
                  (((function
4709
                     | `Bool x -> Result.Ok x
4710
                     | _ ->
4711
                         Result.Error
4712
                           "Vhdl_ast.vhdl_selected_signal_t.postponed") x),
4713
                    arg1, arg2, arg3, arg4, arg5)
4714
            | ("label",x)::xs ->
4715
                loop xs
4716
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4717
                    arg4, arg5)
4718
            | ("lhs",x)::xs ->
4719
                loop xs
4720
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4721
                    arg4, arg5)
4722
            | ("sel",x)::xs ->
4723
                loop xs
4724
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x),
4725
                    arg4, arg5)
4726
            | ("branches",x)::xs ->
4727
                loop xs
4728
                  (arg0, arg1, arg2, arg3,
4729
                    ((function
4730
                      | `List xs ->
4731
                          map_bind
4732
                            (fun x  -> vhdl_signal_selection_t_of_yojson x)
4733
                            [] xs
4734
                      | _ ->
4735
                          Result.Error
4736
                            "Vhdl_ast.vhdl_selected_signal_t.branches") x),
4737
                    arg5)
4738
            | ("delay",x)::xs ->
4739
                loop xs
4740
                  (arg0, arg1, arg2, arg3, arg4,
4741
                    ((function
4742
                      | `Null -> Result.Ok None
4743
                      | x ->
4744
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
4745
                            ((fun x  -> Result.Ok (Some x)))) x))
4746
            | [] ->
4747
                arg5 >>=
4748
                  ((fun arg5  ->
4749
                      arg4 >>=
4750
                        (fun arg4  ->
4751
                           arg3 >>=
4752
                             (fun arg3  ->
4753
                                arg2 >>=
4754
                                  (fun arg2  ->
4755
                                     arg1 >>=
4756
                                       (fun arg1  ->
4757
                                          arg0 >>=
4758
                                            (fun arg0  ->
4759
                                               Result.Ok
4760
                                                 {
4761
                                                   postponed = arg0;
4762
                                                   label = arg1;
4763
                                                   lhs = arg2;
4764
                                                   sel = arg3;
4765
                                                   branches = arg4;
4766
                                                   delay = arg5
4767
                                                 })))))))
4768
            | _::xs -> loop xs _state  in
4769
          loop xs
4770
            ((Result.Ok false), (Result.Ok NoName),
4771
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.lhs"),
4772
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.sel"),
4773
              (Result.Ok []),
4774
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.delay"))
4775
      | _ -> Result.Error "Vhdl_ast.vhdl_selected_signal_t")
4776
  [@ocaml.warning "-A"])
4777

    
4778
type vhdl_concurrent_stmt_t =
4779
  | SigAssign of vhdl_conditional_signal_t
4780
  [@name "CONDITIONAL_SIGNAL_ASSIGNMENT"]
4781
  | Process of vhdl_process_t [@name "PROCESS_STATEMENT"]
4782
  | SelectedSig of vhdl_selected_signal_t
4783
  [@name "SELECTED_SIGNAL_ASSIGNMENT"]
4784

    
4785
(* Adapted *)
4786
let rec pp_vhdl_concurrent_stmt_t :
4787
  Format.formatter -> vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.unit =
4788
  let __2 () = pp_vhdl_selected_signal_t
4789
  
4790
  and __1 () = pp_vhdl_process_t
4791
  
4792
  and __0 () = pp_vhdl_conditional_signal_t
4793
   in
4794
  ((let open! Ppx_deriving_runtime in
4795
      fun fmt  ->
4796
        function
4797
        | SigAssign a0 ->
4798
             ((__0 ()) fmt) a0;
4799
        | Process a0 ->
4800
             ((__1 ()) fmt) a0;
4801
        | SelectedSig a0 ->
4802
             ((__2 ()) fmt) a0;
4803
    )
4804
    [@ocaml.warning "-A"])
4805

    
4806
and show_vhdl_concurrent_stmt_t :
4807
  vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.string =
4808
  fun x  -> Format.asprintf "%a" pp_vhdl_concurrent_stmt_t x
4809

    
4810
let rec (vhdl_concurrent_stmt_t_to_yojson :
4811
          vhdl_concurrent_stmt_t -> Yojson.Safe.json)
4812
  =
4813
  ((let open! Ppx_deriving_yojson_runtime in
4814
      function
4815
      | SigAssign arg0 ->
4816
          `List
4817
            [`String "CONDITIONAL_SIGNAL_ASSIGNMENT";
4818
            ((fun x  -> vhdl_conditional_signal_t_to_yojson x)) arg0]
4819
      | Process arg0 ->
4820
          `List
4821
            [`String "PROCESS_STATEMENT";
4822
            ((fun x  -> vhdl_process_t_to_yojson x)) arg0]
4823
      | SelectedSig arg0 ->
4824
          `List
4825
            [`String "SELECTED_SIGNAL_ASSIGNMENT";
4826
            ((fun x  -> vhdl_selected_signal_t_to_yojson x)) arg0])
4827
  [@ocaml.warning "-A"])
4828

    
4829
and (vhdl_concurrent_stmt_t_of_yojson :
4830
      Yojson.Safe.json ->
4831
        vhdl_concurrent_stmt_t Ppx_deriving_yojson_runtime.error_or)
4832
  =
4833
  ((let open! Ppx_deriving_yojson_runtime in
4834
      function
4835
      | `List ((`String "CONDITIONAL_SIGNAL_ASSIGNMENT")::arg0::[]) ->
4836
          ((fun x  -> vhdl_conditional_signal_t_of_yojson x) arg0) >>=
4837
            ((fun arg0  -> Result.Ok (SigAssign arg0)))
4838
      | `List ((`String "PROCESS_STATEMENT")::arg0::[]) ->
4839
          ((fun x  -> vhdl_process_t_of_yojson x) arg0) >>=
4840
            ((fun arg0  -> Result.Ok (Process arg0)))
4841
      | `List ((`String "SELECTED_SIGNAL_ASSIGNMENT")::arg0::[]) ->
4842
          ((fun x  -> vhdl_selected_signal_t_of_yojson x) arg0) >>=
4843
            ((fun arg0  -> Result.Ok (SelectedSig arg0)))
4844
      | _ -> Result.Error "Vhdl_ast.vhdl_concurrent_stmt_t")
4845
  [@ocaml.warning "-A"])
4846

    
4847
type vhdl_port_mode_t =
4848
  | InPort [@name "in"]
4849
  | OutPort [@name "out"]
4850
  | InoutPort [@name "inout"]
4851
  | BufferPort [@name "buffer"]
4852

    
4853
let rec (pp_vhdl_port_mode_t :
4854
          Format.formatter -> vhdl_port_mode_t -> Ppx_deriving_runtime.unit)
4855
  =
4856
  ((let open! Ppx_deriving_runtime in
4857
      fun fmt  ->
4858
        function
4859
        | InPort  -> Format.pp_print_string fmt "in"
4860
        | OutPort  -> Format.pp_print_string fmt "out"
4861
        | InoutPort  -> Format.pp_print_string fmt "inout"
4862
        | BufferPort  -> Format.pp_print_string fmt "buffer")
4863
  [@ocaml.warning "-A"])
4864

    
4865
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string =
4866
  fun x  -> Format.asprintf "%a" pp_vhdl_port_mode_t x
4867

    
4868
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) =
4869
  ((let open! Ppx_deriving_yojson_runtime in
4870
      function
4871
      | InPort  -> `List [`String "in"]
4872
      | OutPort  -> `List [`String "out"]
4873
      | InoutPort  -> `List [`String "inout"]
4874
      | BufferPort  -> `List [`String "buffer"])
4875
  [@ocaml.warning "-A"])
4876

    
4877
and (vhdl_port_mode_t_of_yojson :
4878
      Yojson.Safe.json ->
4879
        vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or)
4880
  =
4881
  ((let open! Ppx_deriving_yojson_runtime in
4882
      function
4883
      | `List ((`String "in")::[]) -> Result.Ok InPort
4884
      | `List ((`String "out")::[]) -> Result.Ok OutPort
4885
      | `List ((`String "inout")::[]) -> Result.Ok InoutPort
4886
      | `List ((`String "buffer")::[]) -> Result.Ok BufferPort
4887
      | _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t")
4888
  [@ocaml.warning "-A"])
4889

    
4890
type vhdl_port_t =
4891
  {
4892
  names: vhdl_name_t list [@default []];
4893
  mode: vhdl_port_mode_t [@default InPort];
4894
  typ: vhdl_subtype_indication_t ;
4895
  expr: vhdl_expr_t [@default IsNull]}
4896

    
4897
(* Adapted *)
4898
let rec pp_vhdl_port_t :
4899
  Format.formatter -> vhdl_port_t -> Ppx_deriving_runtime.unit =
4900
  let __3 () = pp_vhdl_expr_t
4901
  
4902
  and __2 () = pp_vhdl_subtype_indication_t
4903
  
4904
  and __1 () = pp_vhdl_port_mode_t
4905
  
4906
  and __0 () = pp_vhdl_name_t
4907
   in
4908
  ((let open! Ppx_deriving_runtime in
4909
      fun fmt  ->
4910
        fun x  ->
4911
          Format.fprintf fmt "@[";
4912
          ((((
4913
              ((fun x  ->
4914
                  Format.fprintf fmt "@[";
4915
                  ignore
4916
                    (List.fold_left
4917
                       (fun sep  ->
4918
                          fun x  ->
4919
                            if sep then Format.fprintf fmt ",@ ";
4920
                            ((__0 ()) fmt) x;
4921
                            true) false x);
4922
                  Format.fprintf fmt "@,@]")) x.names;
4923
              );
4924
             Format.fprintf fmt ":@ ";
4925
             ((__1 ()) fmt) x.mode;
4926
             );
4927
             Format.fprintf fmt "@ ";
4928
            ((__2 ()) fmt) x.typ;
4929
            );
4930
          (match x.expr with
4931
           | IsNull -> Format.fprintf fmt "";
4932
           | _ -> (Format.fprintf fmt "@[:=@ ";
4933
                   ((__3 ()) fmt) x.expr;
4934
                   Format.fprintf fmt "@]"));
4935
          Format.fprintf fmt "@]"))
4936
    [@ocaml.warning "-A"])
4937

    
4938
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string =
4939
  fun x  -> Format.asprintf "%a" pp_vhdl_port_t x
4940

    
4941
let rec (vhdl_port_t_to_yojson : vhdl_port_t -> Yojson.Safe.json) =
4942
  ((let open! Ppx_deriving_yojson_runtime in
4943
      fun x  ->
4944
        let fields = []  in
4945
        let fields =
4946
          if x.expr = IsNull
4947
          then fields
4948
          else ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) x.expr)) ::
4949
            fields
4950
           in
4951
        let fields =
4952
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
4953
          :: fields  in
4954
        let fields =
4955
          if x.mode = InPort
4956
          then fields
4957
          else ("mode", (((fun x  -> vhdl_port_mode_t_to_yojson x)) x.mode))
4958
            :: fields
4959
           in
4960
        let fields =
4961
          if x.names = []
4962
          then fields
4963
          else
4964
            ("names",
4965
              (((fun x  ->
4966
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
4967
                 x.names))
4968
            :: fields
4969
           in
4970
        `Assoc fields)
4971
  [@ocaml.warning "-A"])
4972

    
4973
and (vhdl_port_t_of_yojson :
4974
      Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
4975
  =
4976
  ((let open! Ppx_deriving_yojson_runtime in
4977
      function
4978
      | `Assoc xs ->
4979
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
4980
            match xs with
4981
            | ("names",x)::xs ->
4982
                loop xs
4983
                  (((function
4984
                     | `List xs ->
4985
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4986
                     | _ -> Result.Error "Vhdl_ast.vhdl_port_t.names") x),
4987
                    arg1, arg2, arg3)
4988
            | ("mode",x)::xs ->
4989
                loop xs
4990
                  (arg0, ((fun x  -> vhdl_port_mode_t_of_yojson x) x), arg2,
4991
                    arg3)
4992
            | ("typ",x)::xs ->
4993
                loop xs
4994
                  (arg0, arg1,
4995
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
4996
                    arg3)
4997
            | ("expr",x)::xs ->
4998
                loop xs
4999
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x))
5000
            | [] ->
5001
                arg3 >>=
5002
                  ((fun arg3  ->
5003
                      arg2 >>=
5004
                        (fun arg2  ->
5005
                           arg1 >>=
5006
                             (fun arg1  ->
5007
                                arg0 >>=
5008
                                  (fun arg0  ->
5009
                                     Result.Ok
5010
                                       {
5011
                                         names = arg0;
5012
                                         mode = arg1;
5013
                                         typ = arg2;
5014
                                         expr = arg3
5015
                                       })))))
5016
            | _::xs -> loop xs _state  in
5017
          loop xs
5018
            ((Result.Ok []), (Result.Ok InPort),
5019
              (Result.Error "Vhdl_ast.vhdl_port_t.typ"), (Result.Ok IsNull))
5020
      | _ -> Result.Error "Vhdl_ast.vhdl_port_t")
5021
  [@ocaml.warning "-A"])
5022

    
5023
type vhdl_entity_t =
5024
  {
5025
  name: vhdl_name_t [@default NoName];
5026
  generics: vhdl_port_t list [@default []];
5027
  ports: vhdl_port_t list [@default []];
5028
  declaration: vhdl_declaration_t list
5029
    [@key "ENTITY_DECLARATIVE_PART"][@default []];
5030
  stmts: vhdl_concurrent_stmt_t list
5031
    [@key "ENTITY_STATEMENT_PART"][@default []]}
5032

    
5033
(* Adapted *)
5034
let rec pp_vhdl_entity_t :
5035
  Format.formatter -> vhdl_entity_t -> Ppx_deriving_runtime.unit =
5036
  let __4 () = pp_vhdl_concurrent_stmt_t
5037
  
5038
  and __3 () = pp_vhdl_declaration_t
5039
  
5040
  and __2 () = pp_vhdl_port_t
5041
  
5042
  and __1 () = pp_vhdl_port_t
5043
  
5044
  and __0 () = pp_vhdl_name_t
5045
   in
5046
  ((let open! Ppx_deriving_runtime in
5047
      fun fmt  ->
5048
        fun x  ->
5049
          (((((
5050
               ((__0 ()) fmt) x.name;
5051
               Format.fprintf fmt " is@ ");
5052
              Format.fprintf fmt "@[<v>";
5053
              ((fun x  ->
5054
                  Format.fprintf fmt "@[";
5055
                  ignore
5056
                    (List.fold_left
5057
                       (fun sep  ->
5058
                          fun x  ->
5059
                            if sep then Format.fprintf fmt ";@ ";
5060
                            ((__1 ()) fmt) x;
5061
                            true) false x);
5062
                  Format.fprintf fmt "@]")) x.generics;
5063
              Format.fprintf fmt "@]");
5064
             Format.fprintf fmt "port (@[<v>";
5065
             ((fun x  ->
5066
                 Format.fprintf fmt "@[";
5067
                 ignore
5068
                   (List.fold_left
5069
                      (fun sep  ->
5070
                         fun x  ->
5071
                           if sep then Format.fprintf fmt ";@ ";
5072
                           ((__2 ()) fmt) x;
5073
                           true) false x);
5074
                 Format.fprintf fmt "@]")) x.ports;
5075
             Format.fprintf fmt "@]);");
5076
            Format.fprintf fmt "@[<v>";
5077
            ((fun x  ->
5078
                Format.fprintf fmt "@[";
5079
                ignore
5080
                  (List.fold_left
5081
                     (fun sep  ->
5082
                        fun x  ->
5083
                          if sep then Format.fprintf fmt ";@ ";
5084
                          ((__3 ()) fmt) x;
5085
                          true) false x);
5086
                Format.fprintf fmt "@]")) x.declaration;
5087
            Format.fprintf fmt "@]");
5088
           Format.fprintf fmt "@[<v>";
5089
           ((fun x  ->
5090
               Format.fprintf fmt "@[";
5091
               ignore
5092
                 (List.fold_left
5093
                    (fun sep  ->
5094
                       fun x  ->
5095
                         if sep then Format.fprintf fmt ";@ ";
5096
                         ((__4 ()) fmt) x;
5097
                         true) false x);
5098
               Format.fprintf fmt "@]")) x.stmts;
5099
           Format.fprintf fmt "@]");
5100
          Format.fprintf fmt "@]")
5101
    [@ocaml.warning "-A"])
5102

    
5103
and show_vhdl_entity_t : vhdl_entity_t -> Ppx_deriving_runtime.string =
5104
  fun x  -> Format.asprintf "%a" pp_vhdl_entity_t x
5105

    
5106
let rec (vhdl_entity_t_to_yojson : vhdl_entity_t -> Yojson.Safe.json) =
5107
  ((let open! Ppx_deriving_yojson_runtime in
5108
      fun x  ->
5109
        let fields = []  in
5110
        let fields =
5111
          if x.stmts = []
5112
          then fields
5113
          else
5114
            ("ENTITY_STATEMENT_PART",
5115
              (((fun x  ->
5116
                   `List
5117
                     (List.map (fun x  -> vhdl_concurrent_stmt_t_to_yojson x)
5118
                        x))) x.stmts))
5119
            :: fields
5120
           in
5121
        let fields =
5122
          if x.declaration = []
5123
          then fields
5124
          else
5125
            ("ENTITY_DECLARATIVE_PART",
5126
              (((fun x  ->
5127
                   `List
5128
                     (List.map (fun x  -> vhdl_declaration_t_to_yojson x) x)))
5129
                 x.declaration))
5130
            :: fields
5131
           in
5132
        let fields =
5133
          if x.ports = []
5134
          then fields
5135
          else
5136
            ("ports",
5137
              (((fun x  ->
5138
                   `List (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
5139
                 x.ports))
5140
            :: fields
5141
           in
5142
        let fields =
5143
          if x.generics = []
5144
          then fields
5145
          else
5146
            ("generics",
5147
              (((fun x  ->
5148
                   `List (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
5149
                 x.generics))
5150
            :: fields
5151
           in
5152
        let fields =
5153
          if x.name = NoName
5154
          then fields
5155
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
5156
            fields
5157
           in
5158
        `Assoc fields)
5159
  [@ocaml.warning "-A"])
5160

    
5161
and (vhdl_entity_t_of_yojson :
5162
      Yojson.Safe.json -> vhdl_entity_t Ppx_deriving_yojson_runtime.error_or)
5163
  =
5164
  ((let open! Ppx_deriving_yojson_runtime in
5165
      function
5166
      | `Assoc xs ->
5167
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
5168
            match xs with
5169
            | ("name",x)::xs ->
5170
                loop xs
5171
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3,
5172
                    arg4)
5173
            | ("generics",x)::xs ->
5174
                loop xs
5175
                  (arg0,
5176
                    ((function
5177
                      | `List xs ->
5178
                          map_bind (fun x  -> vhdl_port_t_of_yojson x) [] xs
5179
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.generics")
5180
                       x), arg2, arg3, arg4)
5181
            | ("ports",x)::xs ->
5182
                loop xs
5183
                  (arg0, arg1,
5184
                    ((function
5185
                      | `List xs ->
5186
                          map_bind (fun x  -> vhdl_port_t_of_yojson x) [] xs
5187
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.ports") x),
5188
                    arg3, arg4)
5189
            | ("ENTITY_DECLARATIVE_PART",x)::xs ->
5190
                loop xs
5191
                  (arg0, arg1, arg2,
5192
                    ((function
5193
                      | `List xs ->
5194
                          map_bind (fun x  -> vhdl_declaration_t_of_yojson x)
5195
                            [] xs
5196
                      | _ ->
5197
                          Result.Error "Vhdl_ast.vhdl_entity_t.declaration")
5198
                       x), arg4)
5199
            | ("ENTITY_STATEMENT_PART",x)::xs ->
5200
                loop xs
5201
                  (arg0, arg1, arg2, arg3,
5202
                    ((function
5203
                      | `List xs ->
5204
                          map_bind
5205
                            (fun x  -> vhdl_concurrent_stmt_t_of_yojson x) []
5206
                            xs
5207
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.stmts") x))
5208
            | [] ->
5209
                arg4 >>=
5210
                  ((fun arg4  ->
5211
                      arg3 >>=
5212
                        (fun arg3  ->
5213
                           arg2 >>=
5214
                             (fun arg2  ->
5215
                                arg1 >>=
5216
                                  (fun arg1  ->
5217
                                     arg0 >>=
5218
                                       (fun arg0  ->
5219
                                          Result.Ok
5220
                                            {
5221
                                              name = arg0;
5222
                                              generics = arg1;
5223
                                              ports = arg2;
5224
                                              declaration = arg3;
5225
                                              stmts = arg4
5226
                                            }))))))
5227
            | _::xs -> loop xs _state  in
5228
          loop xs
5229
            ((Result.Ok NoName), (Result.Ok []), (Result.Ok []),
5230
              (Result.Ok []), (Result.Ok []))
5231
      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t")
5232
  [@ocaml.warning "-A"])
5233

    
5234
type vhdl_package_t =
5235
  {
5236
  name: vhdl_name_t [@default NoName];
5237
  shared_defs: vhdl_definition_t list [@default []]}
5238

    
5239
(* Adapted *)
5240
let rec pp_vhdl_package_t :
5241
  Format.formatter -> vhdl_package_t -> Ppx_deriving_runtime.unit =
5242
  let __1 () = pp_vhdl_definition_t
5243
  
5244
  and __0 () = pp_vhdl_name_t
5245
   in
5246
  ((let open! Ppx_deriving_runtime in
5247
      fun fmt  ->
5248
        fun x  ->
5249
          ((__0 ()) fmt) x.name;
5250
          Format.fprintf fmt " is@;";
5251
          ((fun x  ->
5252
             ignore
5253
               (List.fold_left
5254
                  (fun sep  ->
5255
                     fun x  ->
5256
                       if sep then Format.fprintf fmt "";
5257
                       ((__1 ()) fmt) x;
5258
                       Format.fprintf fmt ";";
5259
                       true) false x))) x.shared_defs;)
5260
    [@ocaml.warning "-A"])
5261

    
5262
and show_vhdl_package_t : vhdl_package_t -> Ppx_deriving_runtime.string =
5263
  fun x  -> Format.asprintf "%a" pp_vhdl_package_t x
5264

    
5265
let rec (vhdl_package_t_to_yojson : vhdl_package_t -> Yojson.Safe.json) =
5266
  ((let open! Ppx_deriving_yojson_runtime in
5267
      fun x  ->
5268
        let fields = []  in
5269
        let fields =
5270
          if x.shared_defs = []
5271
          then fields
5272
          else
5273
            ("shared_defs",
5274
              (((fun x  ->
5275
                   `List
5276
                     (List.map (fun x  -> vhdl_definition_t_to_yojson x) x)))
5277
                 x.shared_defs))
5278
            :: fields
5279
           in
5280
        let fields =
5281
          if x.name = NoName
5282
          then fields
5283
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
5284
            fields
5285
           in
5286
        `Assoc fields)
5287
  [@ocaml.warning "-A"])
5288

    
5289
and (vhdl_package_t_of_yojson :
5290
      Yojson.Safe.json -> vhdl_package_t Ppx_deriving_yojson_runtime.error_or)
5291
  =
5292
  ((let open! Ppx_deriving_yojson_runtime in
5293
      function
5294
      | `Assoc xs ->
5295
          let rec loop xs ((arg0,arg1) as _state) =
5296
            match xs with
5297
            | ("name",x)::xs ->
5298
                loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
5299
            | ("shared_defs",x)::xs ->
5300
                loop xs
5301
                  (arg0,
5302
                    ((function
5303
                      | `List xs ->
5304
                          map_bind (fun x  -> vhdl_definition_t_of_yojson x)
5305
                            [] xs
5306
                      | _ ->
5307
                          Result.Error "Vhdl_ast.vhdl_package_t.shared_defs")
5308
                       x))
5309
            | [] ->
5310
                arg1 >>=
5311
                  ((fun arg1  ->
5312
                      arg0 >>=
5313
                        (fun arg0  ->
5314
                           Result.Ok { name = arg0; shared_defs = arg1 })))
5315
            | _::xs -> loop xs _state  in
5316
          loop xs ((Result.Ok NoName), (Result.Ok []))
5317
      | _ -> Result.Error "Vhdl_ast.vhdl_package_t")
5318
  [@ocaml.warning "-A"])
5319

    
5320
type vhdl_load_t =
5321
  | Library of vhdl_name_t list [@name "LIBRARY_CLAUSE"][@default []]
5322
  | Use of vhdl_name_t list [@name "USE_CLAUSE"][@default []]
5323

    
5324
(* Adapted. TODO: check indentation *)
5325
let rec pp_vhdl_load_t :
5326
  Format.formatter -> vhdl_load_t -> Ppx_deriving_runtime.unit =
5327
  let __1 () = pp_vhdl_name_t
5328
  
5329
  and __0 () = pp_vhdl_name_t
5330
   in
5331
  ((let open! Ppx_deriving_runtime in
5332
      fun fmt  ->
5333
        function
5334
        | Library a0 ->
5335
            (Format.fprintf fmt "@[<2>library@ ";
5336
             ((fun x  ->
5337
                 Format.fprintf fmt "@[<2>";
5338
                 ignore
5339
                   (List.fold_left
5340
                      (fun sep  ->
5341
                         fun x  ->
5342
                           if sep then Format.fprintf fmt ".";
5343
                           ((__0 ()) fmt) x;
5344
                           true) false x);
5345
                 Format.fprintf fmt "@,@]")) a0;
5346
             Format.fprintf fmt "@]:")
5347
        | Use a0 ->
5348
            (Format.fprintf fmt "@[<2>use@ ";
5349
             ((fun x  ->
5350
                 Format.fprintf fmt "@[<2>";
5351
                 ignore
5352
                   (List.fold_left
5353
                      (fun sep  ->
5354
                         fun x  ->
5355
                           if sep then Format.fprintf fmt ".";
5356
                           ((__1 ()) fmt) x;
5357
                           true) false x);
5358
                 Format.fprintf fmt "@,@]")) a0;
5359
             Format.fprintf fmt "@];"))
5360
    [@ocaml.warning "-A"])
5361

    
5362
and show_vhdl_load_t : vhdl_load_t -> Ppx_deriving_runtime.string =
5363
  fun x  -> Format.asprintf "%a" pp_vhdl_load_t x
5364

    
5365
let rec (vhdl_load_t_to_yojson : vhdl_load_t -> Yojson.Safe.json) =
5366
  ((let open! Ppx_deriving_yojson_runtime in
5367
      function
5368
      | Library arg0 ->
5369
          `List
5370
            [`String "LIBRARY_CLAUSE";
5371
            ((fun x  ->
5372
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
5373
      | Use arg0 ->
5374
          `List
5375
            [`String "USE_CLAUSE";
5376
            ((fun x  ->
5377
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0])
5378
  [@ocaml.warning "-A"])
5379

    
5380
and (vhdl_load_t_of_yojson :
5381
      Yojson.Safe.json -> vhdl_load_t Ppx_deriving_yojson_runtime.error_or)
5382
  =
5383
  ((let open! Ppx_deriving_yojson_runtime in
5384
      function
5385
      | `List ((`String "LIBRARY_CLAUSE")::arg0::[]) ->
5386
          ((function
5387
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5388
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
5389
            ((fun arg0  -> Result.Ok (Library arg0)))
5390
      | `List ((`String "USE_CLAUSE")::arg0::[]) ->
5391
          ((function
5392
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5393
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
5394
            ((fun arg0  -> Result.Ok (Use arg0)))
5395
      | _ -> Result.Error "Vhdl_ast.vhdl_load_t")
5396
  [@ocaml.warning "-A"])
5397

    
5398
type vhdl_architecture_t =
5399
  {
5400
  name: vhdl_name_t [@default NoName];
5401
  entity: vhdl_name_t [@default NoName];
5402
  declarations: vhdl_declaration_t list
5403
    [@key "ARCHITECTURE_DECLARATIVE_PART"][@default []];
5404
  body: vhdl_concurrent_stmt_t list
5405
    [@key "ARCHITECTURE_STATEMENT_PART"][@default []]}
5406

    
5407
(* Adapted *)
5408
let rec pp_vhdl_architecture_t :
5409
  Format.formatter -> vhdl_architecture_t -> Ppx_deriving_runtime.unit =
5410
  let __3 () = pp_vhdl_concurrent_stmt_t
5411
  
5412
  and __2 () = pp_vhdl_declaration_t
5413
  
5414
  and __1 () = pp_vhdl_name_t
5415
  
5416
  and __0 () = pp_vhdl_name_t
5417
   in
5418
  ((let open! Ppx_deriving_runtime in
5419
      fun fmt  ->
5420
        fun x  ->
5421
          ((__0 ()) fmt) x.name;
5422
          Format.fprintf fmt " of ";
5423
          ((__1 ()) fmt) x.entity;
5424
          Format.fprintf fmt " is@;";
5425
          ((fun x  ->
5426
             ignore
5427
               (List.fold_left
5428
                  (fun sep  ->
5429
                     fun x  ->
5430
                       if sep then Format.fprintf fmt "@;";
5431
                       ((__2 ()) fmt) x;
5432
                       Format.fprintf fmt ";";
5433
                       true) false x))) x.declarations;
5434
          Format.fprintf fmt "@;";
5435
          (match x.body with
5436
            | [] -> Format.fprintf fmt "";
5437
            | _ -> Format.fprintf fmt "@[<v 2>begin@;";
5438
          ((fun x  ->
5439
               ignore
5440
                 (List.fold_left
5441
                    (fun sep  ->
5442
                       fun x  ->
5443
                         if sep then Format.fprintf fmt "";
5444
                         ((__3 ()) fmt) x;
5445
                         true) false x))) x.body;
5446
          Format.fprintf fmt "@]@;end;"))
5447
    [@ocaml.warning "-A"])
5448

    
5449
and show_vhdl_architecture_t :
5450
  vhdl_architecture_t -> Ppx_deriving_runtime.string =
5451
  fun x  -> Format.asprintf "%a" pp_vhdl_architecture_t x
5452

    
5453
let rec (vhdl_architecture_t_to_yojson :
5454
          vhdl_architecture_t -> Yojson.Safe.json)
5455
  =
5456
  ((let open! Ppx_deriving_yojson_runtime in
5457
      fun x  ->
5458
        let fields = []  in
5459
        let fields =
5460
          if x.body = []
5461
          then fields
5462
          else
5463
            ("ARCHITECTURE_STATEMENT_PART",
5464
              (((fun x  ->
5465
                   `List
5466
                     (List.map (fun x  -> vhdl_concurrent_stmt_t_to_yojson x)
5467
                        x))) x.body))
5468
            :: fields
5469
           in
5470
        let fields =
5471
          if x.declarations = []
5472
          then fields
5473
          else
5474
            ("ARCHITECTURE_DECLARATIVE_PART",
5475
              (((fun x  ->
5476
                   `List
5477
                     (List.map (fun x  -> vhdl_declaration_t_to_yojson x) x)))
5478
                 x.declarations))
5479
            :: fields
5480
           in
5481
        let fields =
5482
          if x.entity = NoName
5483
          then fields
5484
          else ("entity", (((fun x  -> vhdl_name_t_to_yojson x)) x.entity))
5485
            :: fields
5486
           in
5487
        let fields =
5488
          if x.name = NoName
5489
          then fields
5490<