Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / backends / VHDL / vhdl_ast_deriving.ml @ 00970bbf

History | View | Annotate | Download (215 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
(* Requires adaptation for: ArrayConstraint, RecordConstraint *)
271
and pp_vhdl_constraint_t :
272
  Format.formatter -> vhdl_constraint_t -> Ppx_deriving_runtime.unit =
273
  let __4 () = pp_vhdl_constraint_t
274
  
275
  and __3 () = pp_vhdl_discrete_range_t
276
  
277
  and __2 () = pp_vhdl_discrete_range_t
278
  
279
  and __1 () = pp_vhdl_discrete_range_t
280
  
281
  and __0 () = pp_vhdl_name_t
282
   in
283
  ((let open! Ppx_deriving_runtime in
284
      fun fmt  ->
285
        function
286
        | RefConstraint { ref_name = aref_name } ->
287
             (Format.fprintf fmt "(";
288
              ((__0 ()) fmt) aref_name;
289
              Format.fprintf fmt ")");
290
        | RangeConstraint { range = arange } ->
291
             (Format.fprintf fmt "(";
292
              ((__1 ()) fmt) arange;
293
              Format.fprintf fmt ")");
294
        | IndexConstraint { ranges = aranges } ->
295
            Format.fprintf fmt "(";
296
            ((fun x  ->
297
                ignore
298
                  (List.fold_left
299
                     (fun sep  ->
300
                        fun x  ->
301
                          if sep then Format.fprintf fmt ", ";
302
                          ((__2 ()) fmt) x;
303
                          true) false x))) aranges;
304
            Format.fprintf fmt ")";
305
        | ArrayConstraint { ranges = aranges; sub = asub } ->
306
            (Format.fprintf fmt "@[<2>ArrayConstraint {@,";
307
             ((Format.fprintf fmt "@[%s =@ " "ranges";
308
               ((fun x  ->
309
                   Format.fprintf fmt "@[<2>[";
310
                   ignore
311
                     (List.fold_left
312
                        (fun sep  ->
313
                           fun x  ->
314
                             if sep then Format.fprintf fmt ";@ ";
315
                             ((__3 ()) fmt) x;
316
                             true) false x);
317
                   Format.fprintf fmt "@,]@]")) aranges;
318
               Format.fprintf fmt "@]");
319
              Format.fprintf fmt ";@ ";
320
              Format.fprintf fmt "@[%s =@ " "sub";
321
              ((__4 ()) fmt) asub;
322
              Format.fprintf fmt "@]");
323
             Format.fprintf fmt "@]}")
324
        | RecordConstraint  -> Format.pp_print_string fmt ""
325
        | NoConstraint  -> Format.pp_print_string fmt "")
326
    [@ocaml.warning "-A"])
327

    
328
and show_vhdl_constraint_t : vhdl_constraint_t -> Ppx_deriving_runtime.string
329
  = fun x  -> Format.asprintf "%a" pp_vhdl_constraint_t x
330

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2851
and show_vhdl_sequential_stmt_t :
2852
  vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string =
2853
  fun x  -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x
2854

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

    
2879
and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string =
2880
  fun x  -> Format.asprintf "%a" pp_vhdl_if_case_t x
2881

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

    
2911
and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string =
2912
  fun x  -> Format.asprintf "%a" pp_vhdl_case_item_t x
2913

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

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

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

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

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

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

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

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

    
3684
and show_vhdl_declaration_t :
3685
  vhdl_declaration_t -> Ppx_deriving_runtime.string =
3686
  fun x  -> Format.asprintf "%a" pp_vhdl_declaration_t x
3687

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

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

    
4054
type vhdl_signal_condition_t =
4055
  {
4056
  expr: vhdl_expr_t list ;
4057
  cond: vhdl_expr_t [@default IsNull]}
4058

    
4059
let rec pp_vhdl_signal_condition_t :
4060
  Format.formatter -> vhdl_signal_condition_t -> Ppx_deriving_runtime.unit =
4061
  let __1 () = pp_vhdl_expr_t
4062
  
4063
  and __0 () = pp_vhdl_expr_t
4064
   in
4065
  ((let open! Ppx_deriving_runtime in
4066
      fun fmt  ->
4067
        fun x  ->
4068
          Format.fprintf fmt "@[<2>{ ";
4069
          ((Format.fprintf fmt "@[%s =@ " "expr";
4070
            ((fun x  ->
4071
                Format.fprintf fmt "@[<2>[";
4072
                ignore
4073
                  (List.fold_left
4074
                     (fun sep  ->
4075
                        fun x  ->
4076
                          if sep then Format.fprintf fmt ";@ ";
4077
                          ((__0 ()) fmt) x;
4078
                          true) false x);
4079
                Format.fprintf fmt "@,]@]")) x.expr;
4080
            Format.fprintf fmt "@]");
4081
           Format.fprintf fmt ";@ ";
4082
           Format.fprintf fmt "@[%s =@ " "cond";
4083
           ((__1 ()) fmt) x.cond;
4084
           Format.fprintf fmt "@]");
4085
          Format.fprintf fmt "@ }@]")
4086
    [@ocaml.warning "-A"])
4087

    
4088
and show_vhdl_signal_condition_t :
4089
  vhdl_signal_condition_t -> Ppx_deriving_runtime.string =
4090
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_condition_t x
4091

    
4092
let rec (vhdl_signal_condition_t_to_yojson :
4093
          vhdl_signal_condition_t -> Yojson.Safe.json)
4094
  =
4095
  ((let open! Ppx_deriving_yojson_runtime in
4096
      fun x  ->
4097
        let fields = []  in
4098
        let fields =
4099
          if x.cond = IsNull
4100
          then fields
4101
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4102
            fields
4103
           in
4104
        let fields =
4105
          ("expr",
4106
            ((fun x  ->
4107
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
4108
               x.expr))
4109
          :: fields  in
4110
        `Assoc fields)
4111
  [@ocaml.warning "-A"])
4112

    
4113
and (vhdl_signal_condition_t_of_yojson :
4114
      Yojson.Safe.json ->
4115
        vhdl_signal_condition_t Ppx_deriving_yojson_runtime.error_or)
4116
  =
4117
  ((let open! Ppx_deriving_yojson_runtime in
4118
      function
4119
      | `Assoc xs ->
4120
          let rec loop xs ((arg0,arg1) as _state) =
4121
            match xs with
4122
            | ("expr",x)::xs ->
4123
                loop xs
4124
                  (((function
4125
                     | `List xs ->
4126
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4127
                     | _ ->
4128
                         Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr")
4129
                      x), arg1)
4130
            | ("cond",x)::xs ->
4131
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4132
            | [] ->
4133
                arg1 >>=
4134
                  ((fun arg1  ->
4135
                      arg0 >>=
4136
                        (fun arg0  -> Result.Ok { expr = arg0; cond = arg1 })))
4137
            | _::xs -> loop xs _state  in
4138
          loop xs
4139
            ((Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr"),
4140
              (Result.Ok IsNull))
4141
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_condition_t")
4142
  [@ocaml.warning "-A"])
4143

    
4144
type vhdl_signal_selection_t =
4145
  {
4146
  expr: vhdl_expr_t ;
4147
  when_sel: vhdl_expr_t list [@default []]}
4148

    
4149
let rec pp_vhdl_signal_selection_t :
4150
  Format.formatter -> vhdl_signal_selection_t -> Ppx_deriving_runtime.unit =
4151
  let __1 () = pp_vhdl_expr_t
4152
  
4153
  and __0 () = pp_vhdl_expr_t
4154
   in
4155
  ((let open! Ppx_deriving_runtime in
4156
      fun fmt  ->
4157
        fun x  ->
4158
          Format.fprintf fmt "@[<2>{ ";
4159
          ((Format.fprintf fmt "@[%s =@ " "expr";
4160
            ((__0 ()) fmt) x.expr;
4161
            Format.fprintf fmt "@]");
4162
           Format.fprintf fmt ";@ ";
4163
           Format.fprintf fmt "@[%s =@ " "when_sel";
4164
           ((fun x  ->
4165
               Format.fprintf fmt "@[<2>[";
4166
               ignore
4167
                 (List.fold_left
4168
                    (fun sep  ->
4169
                       fun x  ->
4170
                         if sep then Format.fprintf fmt ";@ ";
4171
                         ((__1 ()) fmt) x;
4172
                         true) false x);
4173
               Format.fprintf fmt "@,]@]")) x.when_sel;
4174
           Format.fprintf fmt "@]");
4175
          Format.fprintf fmt "@ }@]")
4176
    [@ocaml.warning "-A"])
4177

    
4178
and show_vhdl_signal_selection_t :
4179
  vhdl_signal_selection_t -> Ppx_deriving_runtime.string =
4180
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_selection_t x
4181

    
4182
let rec (vhdl_signal_selection_t_to_yojson :
4183
          vhdl_signal_selection_t -> Yojson.Safe.json)
4184
  =
4185
  ((let open! Ppx_deriving_yojson_runtime in
4186
      fun x  ->
4187
        let fields = []  in
4188
        let fields =
4189
          if x.when_sel = []
4190
          then fields
4191
          else
4192
            ("when_sel",
4193
              (((fun x  ->
4194
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
4195
                 x.when_sel))
4196
            :: fields
4197
           in
4198
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
4199
          :: fields  in
4200
        `Assoc fields)
4201
  [@ocaml.warning "-A"])
4202

    
4203
and (vhdl_signal_selection_t_of_yojson :
4204
      Yojson.Safe.json ->
4205
        vhdl_signal_selection_t Ppx_deriving_yojson_runtime.error_or)
4206
  =
4207
  ((let open! Ppx_deriving_yojson_runtime in
4208
      function
4209
      | `Assoc xs ->
4210
          let rec loop xs ((arg0,arg1) as _state) =
4211
            match xs with
4212
            | ("expr",x)::xs ->
4213
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
4214
            | ("when_sel",x)::xs ->
4215
                loop xs
4216
                  (arg0,
4217
                    ((function
4218
                      | `List xs ->
4219
                          map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4220
                      | _ ->
4221
                          Result.Error
4222
                            "Vhdl_ast.vhdl_signal_selection_t.when_sel") x))
4223
            | [] ->
4224
                arg1 >>=
4225
                  ((fun arg1  ->
4226
                      arg0 >>=
4227
                        (fun arg0  ->
4228
                           Result.Ok { expr = arg0; when_sel = arg1 })))
4229
            | _::xs -> loop xs _state  in
4230
          loop xs
4231
            ((Result.Error "Vhdl_ast.vhdl_signal_selection_t.expr"),
4232
              (Result.Ok []))
4233
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_selection_t")
4234
  [@ocaml.warning "-A"])
4235

    
4236
type vhdl_conditional_signal_t =
4237
  {
4238
  postponed: bool [@default false];
4239
  label: vhdl_name_t [@default NoName];
4240
  lhs: vhdl_name_t ;
4241
  rhs: vhdl_signal_condition_t list ;
4242
  cond: vhdl_expr_t [@default IsNull];
4243
  delay: vhdl_expr_t [@default IsNull]}
4244

    
4245
let rec pp_vhdl_conditional_signal_t :
4246
  Format.formatter -> vhdl_conditional_signal_t -> Ppx_deriving_runtime.unit
4247
  =
4248
  let __4 () = pp_vhdl_expr_t
4249
  
4250
  and __3 () = pp_vhdl_expr_t
4251
  
4252
  and __2 () = pp_vhdl_signal_condition_t
4253
  
4254
  and __1 () = pp_vhdl_name_t
4255
  
4256
  and __0 () = pp_vhdl_name_t
4257
   in
4258
  ((let open! Ppx_deriving_runtime in
4259
      fun fmt  ->
4260
        fun x  ->
4261
          Format.fprintf fmt "@[<2>{ ";
4262
          ((((((Format.fprintf fmt "@[%s =@ " "postponed";
4263
                (Format.fprintf fmt "%B") x.postponed;
4264
                Format.fprintf fmt "@]");
4265
               Format.fprintf fmt ";@ ";
4266
               Format.fprintf fmt "@[%s =@ " "label";
4267
               ((__0 ()) fmt) x.label;
4268
               Format.fprintf fmt "@]");
4269
              Format.fprintf fmt ";@ ";
4270
              Format.fprintf fmt "@[%s =@ " "lhs";
4271
              ((__1 ()) fmt) x.lhs;
4272
              Format.fprintf fmt "@]");
4273
             Format.fprintf fmt ";@ ";
4274
             Format.fprintf fmt "@[%s =@ " "rhs";
4275
             ((fun x  ->
4276
                 Format.fprintf fmt "@[<2>[";
4277
                 ignore
4278
                   (List.fold_left
4279
                      (fun sep  ->
4280
                         fun x  ->
4281
                           if sep then Format.fprintf fmt ";@ ";
4282
                           ((__2 ()) fmt) x;
4283
                           true) false x);
4284
                 Format.fprintf fmt "@,]@]")) x.rhs;
4285
             Format.fprintf fmt "@]");
4286
            Format.fprintf fmt ";@ ";
4287
            Format.fprintf fmt "@[%s =@ " "cond";
4288
            ((__3 ()) fmt) x.cond;
4289
            Format.fprintf fmt "@]");
4290
           Format.fprintf fmt ";@ ";
4291
           Format.fprintf fmt "@[%s =@ " "delay";
4292
           ((__4 ()) fmt) x.delay;
4293
           Format.fprintf fmt "@]");
4294
          Format.fprintf fmt "@ }@]")
4295
    [@ocaml.warning "-A"])
4296

    
4297
and show_vhdl_conditional_signal_t :
4298
  vhdl_conditional_signal_t -> Ppx_deriving_runtime.string =
4299
  fun x  -> Format.asprintf "%a" pp_vhdl_conditional_signal_t x
4300

    
4301
let rec (vhdl_conditional_signal_t_to_yojson :
4302
          vhdl_conditional_signal_t -> Yojson.Safe.json)
4303
  =
4304
  ((let open! Ppx_deriving_yojson_runtime in
4305
      fun x  ->
4306
        let fields = []  in
4307
        let fields =
4308
          if x.delay = IsNull
4309
          then fields
4310
          else ("delay", (((fun x  -> vhdl_expr_t_to_yojson x)) x.delay)) ::
4311
            fields
4312
           in
4313
        let fields =
4314
          if x.cond = IsNull
4315
          then fields
4316
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4317
            fields
4318
           in
4319
        let fields =
4320
          ("rhs",
4321
            ((fun x  ->
4322
                `List
4323
                  (List.map (fun x  -> vhdl_signal_condition_t_to_yojson x) x))
4324
               x.rhs))
4325
          :: fields  in
4326
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4327
          fields  in
4328
        let fields =
4329
          if x.label = NoName
4330
          then fields
4331
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4332
            fields
4333
           in
4334
        let fields =
4335
          if x.postponed = false
4336
          then fields
4337
          else
4338
            ("postponed",
4339
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4340
                 x.postponed))
4341
            :: fields
4342
           in
4343
        `Assoc fields)
4344
  [@ocaml.warning "-A"])
4345

    
4346
and (vhdl_conditional_signal_t_of_yojson :
4347
      Yojson.Safe.json ->
4348
        vhdl_conditional_signal_t Ppx_deriving_yojson_runtime.error_or)
4349
  =
4350
  ((let open! Ppx_deriving_yojson_runtime in
4351
      function
4352
      | `Assoc xs ->
4353
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4354
            match xs with
4355
            | ("postponed",x)::xs ->
4356
                loop xs
4357
                  (((function
4358
                     | `Bool x -> Result.Ok x
4359
                     | _ ->
4360
                         Result.Error
4361
                           "Vhdl_ast.vhdl_conditional_signal_t.postponed") x),
4362
                    arg1, arg2, arg3, arg4, arg5)
4363
            | ("label",x)::xs ->
4364
                loop xs
4365
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4366
                    arg4, arg5)
4367
            | ("lhs",x)::xs ->
4368
                loop xs
4369
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4370
                    arg4, arg5)
4371
            | ("rhs",x)::xs ->
4372
                loop xs
4373
                  (arg0, arg1, arg2,
4374
                    ((function
4375
                      | `List xs ->
4376
                          map_bind
4377
                            (fun x  -> vhdl_signal_condition_t_of_yojson x)
4378
                            [] xs
4379
                      | _ ->
4380
                          Result.Error
4381
                            "Vhdl_ast.vhdl_conditional_signal_t.rhs") x),
4382
                    arg4, arg5)
4383
            | ("cond",x)::xs ->
4384
                loop xs
4385
                  (arg0, arg1, arg2, arg3,
4386
                    ((fun x  -> vhdl_expr_t_of_yojson x) x), arg5)
4387
            | ("delay",x)::xs ->
4388
                loop xs
4389
                  (arg0, arg1, arg2, arg3, arg4,
4390
                    ((fun x  -> vhdl_expr_t_of_yojson x) x))
4391
            | [] ->
4392
                arg5 >>=
4393
                  ((fun arg5  ->
4394
                      arg4 >>=
4395
                        (fun arg4  ->
4396
                           arg3 >>=
4397
                             (fun arg3  ->
4398
                                arg2 >>=
4399
                                  (fun arg2  ->
4400
                                     arg1 >>=
4401
                                       (fun arg1  ->
4402
                                          arg0 >>=
4403
                                            (fun arg0  ->
4404
                                               Result.Ok
4405
                                                 {
4406
                                                   postponed = arg0;
4407
                                                   label = arg1;
4408
                                                   lhs = arg2;
4409
                                                   rhs = arg3;
4410
                                                   cond = arg4;
4411
                                                   delay = arg5
4412
                                                 })))))))
4413
            | _::xs -> loop xs _state  in
4414
          loop xs
4415
            ((Result.Ok false), (Result.Ok NoName),
4416
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.lhs"),
4417
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.rhs"),
4418
              (Result.Ok IsNull), (Result.Ok IsNull))
4419
      | _ -> Result.Error "Vhdl_ast.vhdl_conditional_signal_t")
4420
  [@ocaml.warning "-A"])
4421

    
4422
type vhdl_process_t =
4423
  {
4424
  id: vhdl_name_t [@default NoName];
4425
  declarations: vhdl_declaration_t list option
4426
    [@key "PROCESS_DECLARATIVE_PART"][@default Some []];
4427
  active_sigs: vhdl_name_t list [@default []];
4428
  body: vhdl_sequential_stmt_t list
4429
    [@key "PROCESS_STATEMENT_PART"][@default []]}
4430

    
4431
let rec pp_vhdl_process_t :
4432
  Format.formatter -> vhdl_process_t -> Ppx_deriving_runtime.unit =
4433
  let __3 () = pp_vhdl_sequential_stmt_t
4434
  
4435
  and __2 () = pp_vhdl_name_t
4436
  
4437
  and __1 () = pp_vhdl_declaration_t
4438
  
4439
  and __0 () = pp_vhdl_name_t
4440
   in
4441
  ((let open! Ppx_deriving_runtime in
4442
      fun fmt  ->
4443
        fun x  ->
4444
          Format.fprintf fmt "@[<2>{ ";
4445
          ((((Format.fprintf fmt "@[%s =@ " "id";
4446
              ((__0 ()) fmt) x.id;
4447
              Format.fprintf fmt "@]");
4448
             Format.fprintf fmt ";@ ";
4449
             Format.fprintf fmt "@[%s =@ " "declarations";
4450
             ((function
4451
               | None  -> Format.pp_print_string fmt "None"
4452
               | Some x ->
4453
                   (Format.pp_print_string fmt "(Some ";
4454
                    ((fun x  ->
4455
                        Format.fprintf fmt "@[<2>[";
4456
                        ignore
4457
                          (List.fold_left
4458
                             (fun sep  ->
4459
                                fun x  ->
4460
                                  if sep then Format.fprintf fmt ";@ ";
4461
                                  ((__1 ()) fmt) x;
4462
                                  true) false x);
4463
                        Format.fprintf fmt "@,]@]")) x;
4464
                    Format.pp_print_string fmt ")"))) x.declarations;
4465
             Format.fprintf fmt "@]");
4466
            Format.fprintf fmt ";@ ";
4467
            Format.fprintf fmt "@[%s =@ " "active_sigs";
4468
            ((fun x  ->
4469
                Format.fprintf fmt "@[<2>[";
4470
                ignore
4471
                  (List.fold_left
4472
                     (fun sep  ->
4473
                        fun x  ->
4474
                          if sep then Format.fprintf fmt ";@ ";
4475
                          ((__2 ()) fmt) x;
4476
                          true) false x);
4477
                Format.fprintf fmt "@,]@]")) x.active_sigs;
4478
            Format.fprintf fmt "@]");
4479
           Format.fprintf fmt ";@ ";
4480
           Format.fprintf fmt "@[%s =@ " "body";
4481
           ((fun x  ->
4482
               Format.fprintf fmt "@[<2>[";
4483
               ignore
4484
                 (List.fold_left
4485
                    (fun sep  ->
4486
                       fun x  ->
4487
                         if sep then Format.fprintf fmt ";@ ";
4488
                         ((__3 ()) fmt) x;
4489
                         true) false x);
4490
               Format.fprintf fmt "@,]@]")) x.body;
4491
           Format.fprintf fmt "@]");
4492
          Format.fprintf fmt "@ }@]")
4493
    [@ocaml.warning "-A"])
4494

    
4495
and show_vhdl_process_t : vhdl_process_t -> Ppx_deriving_runtime.string =
4496
  fun x  -> Format.asprintf "%a" pp_vhdl_process_t x
4497

    
4498
let rec (vhdl_process_t_to_yojson : vhdl_process_t -> Yojson.Safe.json) =
4499
  ((let open! Ppx_deriving_yojson_runtime in
4500
      fun x  ->
4501
        let fields = []  in
4502
        let fields =
4503
          if x.body = []
4504
          then fields
4505
          else
4506
            ("PROCESS_STATEMENT_PART",
4507
              (((fun x  ->
4508
                   `List
4509
                     (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x)
4510
                        x))) x.body))
4511
            :: fields
4512
           in
4513
        let fields =
4514
          if x.active_sigs = []
4515
          then fields
4516
          else
4517
            ("active_sigs",
4518
              (((fun x  ->
4519
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
4520
                 x.active_sigs))
4521
            :: fields
4522
           in
4523
        let fields =
4524
          if x.declarations = (Some [])
4525
          then fields
4526
          else
4527
            ("PROCESS_DECLARATIVE_PART",
4528
              (((function
4529
                 | None  -> `Null
4530
                 | Some x ->
4531
                     ((fun x  ->
4532
                         `List
4533
                           (List.map
4534
                              (fun x  -> vhdl_declaration_t_to_yojson x) x)))
4535
                       x)) x.declarations))
4536
            :: fields
4537
           in
4538
        let fields =
4539
          if x.id = NoName
4540
          then fields
4541
          else ("id", (((fun x  -> vhdl_name_t_to_yojson x)) x.id)) :: fields
4542
           in
4543
        `Assoc fields)
4544
  [@ocaml.warning "-A"])
4545

    
4546
and (vhdl_process_t_of_yojson :
4547
      Yojson.Safe.json -> vhdl_process_t Ppx_deriving_yojson_runtime.error_or)
4548
  =
4549
  ((let open! Ppx_deriving_yojson_runtime in
4550
      function
4551
      | `Assoc xs ->
4552
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
4553
            match xs with
4554
            | ("id",x)::xs ->
4555
                loop xs
4556
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3)
4557
            | ("PROCESS_DECLARATIVE_PART",x)::xs ->
4558
                loop xs
4559
                  (arg0,
4560
                    ((function
4561
                      | `Null -> Result.Ok None
4562
                      | x ->
4563
                          ((function
4564
                            | `List xs ->
4565
                                map_bind
4566
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4567
                                  [] xs
4568
                            | _ ->
4569
                                Result.Error
4570
                                  "Vhdl_ast.vhdl_process_t.declarations") x)
4571
                            >>= ((fun x  -> Result.Ok (Some x)))) x), arg2,
4572
                    arg3)
4573
            | ("active_sigs",x)::xs ->
4574
                loop xs
4575
                  (arg0, arg1,
4576
                    ((function
4577
                      | `List xs ->
4578
                          map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4579
                      | _ ->
4580
                          Result.Error "Vhdl_ast.vhdl_process_t.active_sigs")
4581
                       x), arg3)
4582
            | ("PROCESS_STATEMENT_PART",x)::xs ->
4583
                loop xs
4584
                  (arg0, arg1, arg2,
4585
                    ((function
4586
                      | `List xs ->
4587
                          map_bind
4588
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
4589
                            xs
4590
                      | _ -> Result.Error "Vhdl_ast.vhdl_process_t.body") x))
4591
            | [] ->
4592
                arg3 >>=
4593
                  ((fun arg3  ->
4594
                      arg2 >>=
4595
                        (fun arg2  ->
4596
                           arg1 >>=
4597
                             (fun arg1  ->
4598
                                arg0 >>=
4599
                                  (fun arg0  ->
4600
                                     Result.Ok
4601
                                       {
4602
                                         id = arg0;
4603
                                         declarations = arg1;
4604
                                         active_sigs = arg2;
4605
                                         body = arg3
4606
                                       })))))
4607
            | _::xs -> loop xs _state  in
4608
          loop xs
4609
            ((Result.Ok NoName), (Result.Ok (Some [])), (Result.Ok []),
4610
              (Result.Ok []))
4611
      | _ -> Result.Error "Vhdl_ast.vhdl_process_t")
4612
  [@ocaml.warning "-A"])
4613

    
4614
type vhdl_selected_signal_t =
4615
  {
4616
  postponed: bool [@default false];
4617
  label: vhdl_name_t [@default NoName];
4618
  lhs: vhdl_name_t ;
4619
  sel: vhdl_expr_t ;
4620
  branches: vhdl_signal_selection_t list [@default []];
4621
  delay: vhdl_expr_t option }
4622

    
4623
let rec pp_vhdl_selected_signal_t :
4624
  Format.formatter -> vhdl_selected_signal_t -> Ppx_deriving_runtime.unit =
4625
  let __4 () = pp_vhdl_expr_t
4626
  
4627
  and __3 () = pp_vhdl_signal_selection_t
4628
  
4629
  and __2 () = pp_vhdl_expr_t
4630
  
4631
  and __1 () = pp_vhdl_name_t
4632
  
4633
  and __0 () = pp_vhdl_name_t
4634
   in
4635
  ((let open! Ppx_deriving_runtime in
4636
      fun fmt  ->
4637
        fun x  ->
4638
          Format.fprintf fmt "@[<2>{ ";
4639
          ((((((Format.fprintf fmt "@[%s =@ " "postponed";
4640
                (Format.fprintf fmt "%B") x.postponed;
4641
                Format.fprintf fmt "@]");
4642
               Format.fprintf fmt ";@ ";
4643
               Format.fprintf fmt "@[%s =@ " "label";
4644
               ((__0 ()) fmt) x.label;
4645
               Format.fprintf fmt "@]");
4646
              Format.fprintf fmt ";@ ";
4647
              Format.fprintf fmt "@[%s =@ " "lhs";
4648
              ((__1 ()) fmt) x.lhs;
4649
              Format.fprintf fmt "@]");
4650
             Format.fprintf fmt ";@ ";
4651
             Format.fprintf fmt "@[%s =@ " "sel";
4652
             ((__2 ()) fmt) x.sel;
4653
             Format.fprintf fmt "@]");
4654
            Format.fprintf fmt ";@ ";
4655
            Format.fprintf fmt "@[%s =@ " "branches";
4656
            ((fun x  ->
4657
                Format.fprintf fmt "@[<2>[";
4658
                ignore
4659
                  (List.fold_left
4660
                     (fun sep  ->
4661
                        fun x  ->
4662
                          if sep then Format.fprintf fmt ";@ ";
4663
                          ((__3 ()) fmt) x;
4664
                          true) false x);
4665
                Format.fprintf fmt "@,]@]")) x.branches;
4666
            Format.fprintf fmt "@]");
4667
           Format.fprintf fmt ";@ ";
4668
           Format.fprintf fmt "@[%s =@ " "delay";
4669
           ((function
4670
             | None  -> Format.pp_print_string fmt "None"
4671
             | Some x ->
4672
                 (Format.pp_print_string fmt "(Some ";
4673
                  ((__4 ()) fmt) x;
4674
                  Format.pp_print_string fmt ")"))) x.delay;
4675
           Format.fprintf fmt "@]");
4676
          Format.fprintf fmt "@ }@]")
4677
    [@ocaml.warning "-A"])
4678

    
4679
and show_vhdl_selected_signal_t :
4680
  vhdl_selected_signal_t -> Ppx_deriving_runtime.string =
4681
  fun x  -> Format.asprintf "%a" pp_vhdl_selected_signal_t x
4682

    
4683
let rec (vhdl_selected_signal_t_to_yojson :
4684
          vhdl_selected_signal_t -> Yojson.Safe.json)
4685
  =
4686
  ((let open! Ppx_deriving_yojson_runtime in
4687
      fun x  ->
4688
        let fields = []  in
4689
        let fields =
4690
          ("delay",
4691
            ((function
4692
              | None  -> `Null
4693
              | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x) x.delay))
4694
          :: fields  in
4695
        let fields =
4696
          if x.branches = []
4697
          then fields
4698
          else
4699
            ("branches",
4700
              (((fun x  ->
4701
                   `List
4702
                     (List.map
4703
                        (fun x  -> vhdl_signal_selection_t_to_yojson x) x)))
4704
                 x.branches))
4705
            :: fields
4706
           in
4707
        let fields = ("sel", ((fun x  -> vhdl_expr_t_to_yojson x) x.sel)) ::
4708
          fields  in
4709
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4710
          fields  in
4711
        let fields =
4712
          if x.label = NoName
4713
          then fields
4714
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4715
            fields
4716
           in
4717
        let fields =
4718
          if x.postponed = false
4719
          then fields
4720
          else
4721
            ("postponed",
4722
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4723
                 x.postponed))
4724
            :: fields
4725
           in
4726
        `Assoc fields)
4727
  [@ocaml.warning "-A"])
4728

    
4729
and (vhdl_selected_signal_t_of_yojson :
4730
      Yojson.Safe.json ->
4731
        vhdl_selected_signal_t Ppx_deriving_yojson_runtime.error_or)
4732
  =
4733
  ((let open! Ppx_deriving_yojson_runtime in
4734
      function
4735
      | `Assoc xs ->
4736
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4737
            match xs with
4738
            | ("postponed",x)::xs ->
4739
                loop xs
4740
                  (((function
4741
                     | `Bool x -> Result.Ok x
4742
                     | _ ->
4743
                         Result.Error
4744
                           "Vhdl_ast.vhdl_selected_signal_t.postponed") x),
4745
                    arg1, arg2, arg3, arg4, arg5)
4746
            | ("label",x)::xs ->
4747
                loop xs
4748
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4749
                    arg4, arg5)
4750
            | ("lhs",x)::xs ->
4751
                loop xs
4752
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4753
                    arg4, arg5)
4754
            | ("sel",x)::xs ->
4755
                loop xs
4756
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x),
4757
                    arg4, arg5)
4758
            | ("branches",x)::xs ->
4759
                loop xs
4760
                  (arg0, arg1, arg2, arg3,
4761
                    ((function
4762
                      | `List xs ->
4763
                          map_bind
4764
                            (fun x  -> vhdl_signal_selection_t_of_yojson x)
4765
                            [] xs
4766
                      | _ ->
4767
                          Result.Error
4768
                            "Vhdl_ast.vhdl_selected_signal_t.branches") x),
4769
                    arg5)
4770
            | ("delay",x)::xs ->
4771
                loop xs
4772
                  (arg0, arg1, arg2, arg3, arg4,
4773
                    ((function
4774
                      | `Null -> Result.Ok None
4775
                      | x ->
4776
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
4777
                            ((fun x  -> Result.Ok (Some x)))) x))
4778
            | [] ->
4779
                arg5 >>=
4780
                  ((fun arg5  ->
4781
                      arg4 >>=
4782
                        (fun arg4  ->
4783
                           arg3 >>=
4784
                             (fun arg3  ->
4785
                                arg2 >>=
4786
                                  (fun arg2  ->
4787
                                     arg1 >>=
4788
                                       (fun arg1  ->
4789
                                          arg0 >>=
4790
                                            (fun arg0  ->
4791
                                               Result.Ok
4792
                                                 {
4793
                                                   postponed = arg0;
4794
                                                   label = arg1;
4795
                                                   lhs = arg2;
4796
                                                   sel = arg3;
4797
                                                   branches = arg4;
4798
                                                   delay = arg5
4799
                                                 })))))))
4800
            | _::xs -> loop xs _state  in
4801
          loop xs
4802
            ((Result.Ok false), (Result.Ok NoName),
4803
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.lhs"),
4804
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.sel"),
4805
              (Result.Ok []),
4806
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.delay"))
4807
      | _ -> Result.Error "Vhdl_ast.vhdl_selected_signal_t")
4808
  [@ocaml.warning "-A"])
4809

    
4810
type vhdl_concurrent_stmt_t =
4811
  | SigAssign of vhdl_conditional_signal_t
4812
  [@name "CONDITIONAL_SIGNAL_ASSIGNMENT"]
4813
  | Process of vhdl_process_t [@name "PROCESS_STATEMENT"]
4814
  | SelectedSig of vhdl_selected_signal_t
4815
  [@name "SELECTED_SIGNAL_ASSIGNMENT"]
4816

    
4817
(* Adapted *)
4818
let rec pp_vhdl_concurrent_stmt_t :
4819
  Format.formatter -> vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.unit =
4820
  let __2 () = pp_vhdl_selected_signal_t
4821
  
4822
  and __1 () = pp_vhdl_process_t
4823
  
4824
  and __0 () = pp_vhdl_conditional_signal_t
4825
   in
4826
  ((let open! Ppx_deriving_runtime in
4827
      fun fmt  ->
4828
        function
4829
        | SigAssign a0 ->
4830
             ((__0 ()) fmt) a0;
4831
        | Process a0 ->
4832
             ((__1 ()) fmt) a0;
4833
        | SelectedSig a0 ->
4834
             ((__2 ()) fmt) a0;
4835
    )
4836
    [@ocaml.warning "-A"])
4837

    
4838
and show_vhdl_concurrent_stmt_t :
4839
  vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.string =
4840
  fun x  -> Format.asprintf "%a" pp_vhdl_concurrent_stmt_t x
4841

    
4842
let rec (vhdl_concurrent_stmt_t_to_yojson :
4843
          vhdl_concurrent_stmt_t -> Yojson.Safe.json)
4844
  =
4845
  ((let open! Ppx_deriving_yojson_runtime in
4846
      function
4847
      | SigAssign arg0 ->
4848
          `List
4849
            [`String "CONDITIONAL_SIGNAL_ASSIGNMENT";
4850
            ((fun x  -> vhdl_conditional_signal_t_to_yojson x)) arg0]
4851
      | Process arg0 ->
4852
          `List
4853
            [`String "PROCESS_STATEMENT";
4854
            ((fun x  -> vhdl_process_t_to_yojson x)) arg0]
4855
      | SelectedSig arg0 ->
4856
          `List
4857
            [`String "SELECTED_SIGNAL_ASSIGNMENT";
4858
            ((fun x  -> vhdl_selected_signal_t_to_yojson x)) arg0])
4859
  [@ocaml.warning "-A"])
4860

    
4861
and (vhdl_concurrent_stmt_t_of_yojson :
4862
      Yojson.Safe.json ->
4863
        vhdl_concurrent_stmt_t Ppx_deriving_yojson_runtime.error_or)
4864
  =
4865
  ((let open! Ppx_deriving_yojson_runtime in
4866
      function
4867
      | `List ((`String "CONDITIONAL_SIGNAL_ASSIGNMENT")::arg0::[]) ->
4868
          ((fun x  -> vhdl_conditional_signal_t_of_yojson x) arg0) >>=
4869
            ((fun arg0  -> Result.Ok (SigAssign arg0)))
4870
      | `List ((`String "PROCESS_STATEMENT")::arg0::[]) ->
4871
          ((fun x  -> vhdl_process_t_of_yojson x) arg0) >>=
4872
            ((fun arg0  -> Result.Ok (Process arg0)))
4873
      | `List ((`String "SELECTED_SIGNAL_ASSIGNMENT")::arg0::[]) ->
4874
          ((fun x  -> vhdl_selected_signal_t_of_yojson x) arg0) >>=
4875
            ((fun arg0  -> Result.Ok (SelectedSig arg0)))
4876
      | _ -> Result.Error "Vhdl_ast.vhdl_concurrent_stmt_t")
4877
  [@ocaml.warning "-A"])
4878

    
4879
type vhdl_port_mode_t =
4880
  | InPort [@name "in"]
4881
  | OutPort [@name "out"]
4882
  | InoutPort [@name "inout"]
4883
  | BufferPort [@name "buffer"]
4884

    
4885
let rec (pp_vhdl_port_mode_t :
4886
          Format.formatter -> vhdl_port_mode_t -> Ppx_deriving_runtime.unit)
4887
  =
4888
  ((let open! Ppx_deriving_runtime in
4889
      fun fmt  ->
4890
        function
4891
        | InPort  -> Format.pp_print_string fmt "in"
4892
        | OutPort  -> Format.pp_print_string fmt "out"
4893
        | InoutPort  -> Format.pp_print_string fmt "inout"
4894
        | BufferPort  -> Format.pp_print_string fmt "buffer")
4895
  [@ocaml.warning "-A"])
4896

    
4897
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string =
4898
  fun x  -> Format.asprintf "%a" pp_vhdl_port_mode_t x
4899

    
4900
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) =
4901
  ((let open! Ppx_deriving_yojson_runtime in
4902
      function
4903
      | InPort  -> `List [`String "in"]
4904
      | OutPort  -> `List [`String "out"]
4905
      | InoutPort  -> `List [`String "inout"]
4906
      | BufferPort  -> `List [`String "buffer"])
4907
  [@ocaml.warning "-A"])
4908

    
4909
and (vhdl_port_mode_t_of_yojson :
4910
      Yojson.Safe.json ->
4911
        vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or)
4912
  =
4913
  ((let open! Ppx_deriving_yojson_runtime in
4914
      function
4915
      | `List ((`String "in")::[]) -> Result.Ok InPort
4916
      | `List ((`String "out")::[]) -> Result.Ok OutPort
4917
      | `List ((`String "inout")::[]) -> Result.Ok InoutPort
4918
      | `List ((`String "buffer")::[]) -> Result.Ok BufferPort
4919
      | _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t")
4920
  [@ocaml.warning "-A"])
4921

    
4922
type vhdl_port_t =
4923
  {
4924
  names: vhdl_name_t list [@default []];
4925
  mode: vhdl_port_mode_t [@default InPort];
4926
  typ: vhdl_subtype_indication_t ;
4927
  expr: vhdl_expr_t [@default IsNull]}
4928

    
4929
(* Adapted *)
4930
let rec pp_vhdl_port_t :
4931
  Format.formatter -> vhdl_port_t -> Ppx_deriving_runtime.unit =
4932
  let __3 () = pp_vhdl_expr_t
4933
  
4934
  and __2 () = pp_vhdl_subtype_indication_t
4935
  
4936
  and __1 () = pp_vhdl_port_mode_t
4937
  
4938
  and __0 () = pp_vhdl_name_t
4939
   in
4940
  ((let open! Ppx_deriving_runtime in
4941
      fun fmt  ->
4942
        fun x  ->
4943
          Format.fprintf fmt "@[";
4944
          ((((
4945
              ((fun x  ->
4946
                  Format.fprintf fmt "@[";
4947
                  ignore
4948
                    (List.fold_left
4949
                       (fun sep  ->
4950
                          fun x  ->
4951
                            if sep then Format.fprintf fmt ",@ ";
4952
                            ((__0 ()) fmt) x;
4953
                            true) false x);
4954
                  Format.fprintf fmt "@,@]")) x.names;
4955
              );
4956
             Format.fprintf fmt ":@ ";
4957
             ((__1 ()) fmt) x.mode;
4958
             );
4959
             Format.fprintf fmt "@ ";
4960
            ((__2 ()) fmt) x.typ;
4961
            );
4962
          (match x.expr with
4963
           | IsNull -> Format.fprintf fmt "";
4964
           | _ -> (Format.fprintf fmt "@[:=@ ";
4965
                   ((__3 ()) fmt) x.expr;
4966
                   Format.fprintf fmt "@]"));
4967
          Format.fprintf fmt "@]"))
4968
    [@ocaml.warning "-A"])
4969

    
4970
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string =
4971
  fun x  -> Format.asprintf "%a" pp_vhdl_port_t x
4972

    
4973
let rec (vhdl_port_t_to_yojson : vhdl_port_t -> Yojson.Safe.json) =
4974
  ((let open! Ppx_deriving_yojson_runtime in
4975
      fun x  ->
4976
        let fields = []  in
4977
        let fields =
4978
          if x.expr = IsNull
4979
          then fields
4980
          else ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) x.expr)) ::
4981
            fields
4982
           in
4983
        let fields =
4984
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
4985
          :: fields  in
4986
        let fields =
4987
          if x.mode = InPort
4988
          then fields
4989
          else ("mode", (((fun x  -> vhdl_port_mode_t_to_yojson x)) x.mode))
4990
            :: fields
4991
           in
4992
        let fields =
4993
          if x.names = []
4994
          then fields
4995
          else
4996
            ("names",
4997
              (((fun x  ->
4998
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
4999
                 x.names))
5000
            :: fields
5001
           in
5002
        `Assoc fields)
5003
  [@ocaml.warning "-A"])
5004

    
5005
and (vhdl_port_t_of_yojson :
5006
      Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
5007
  =
5008
  ((let open! Ppx_deriving_yojson_runtime in
5009
      function
5010
      | `Assoc xs ->
5011
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
5012
            match xs with
5013
            | ("names",x)::xs ->
5014
                loop xs
5015
                  (((function
5016
                     | `List xs ->
5017
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5018
                     | _ -> Result.Error "Vhdl_ast.vhdl_port_t.names") x),
5019
                    arg1, arg2, arg3)
5020
            | ("mode",x)::xs ->
5021
                loop xs
5022
                  (arg0, ((fun x  -> vhdl_port_mode_t_of_yojson x) x), arg2,
5023
                    arg3)
5024
            | ("typ",x)::xs ->
5025
                loop xs
5026
                  (arg0, arg1,
5027
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
5028
                    arg3)
5029
            | ("expr",x)::xs ->
5030
                loop xs
5031
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x))
5032
            | [] ->
5033
                arg3 >>=
5034
                  ((fun arg3  ->
5035
                      arg2 >>=
5036
                        (fun arg2  ->
5037
                           arg1 >>=
5038
                             (fun arg1  ->
5039
                                arg0 >>=
5040
                                  (fun arg0  ->
5041
                                     Result.Ok
5042
                                       {
5043
                                         names = arg0;
5044
                                         mode = arg1;
5045
                                         typ = arg2;
5046
                                         expr = arg3
5047
                                       })))))
5048
            | _::xs -> loop xs _state  in
5049
          loop xs
5050
            ((Result.Ok []), (Result.Ok InPort),
5051
              (Result.Error "Vhdl_ast.vhdl_port_t.typ"), (Result.Ok IsNull))
5052
      | _ -> Result.Error "Vhdl_ast.vhdl_port_t")
5053
  [@ocaml.warning "-A"])
5054

    
5055
type vhdl_entity_t =
5056
  {
5057
  name: vhdl_name_t [@default NoName];
5058
  generics: vhdl_port_t list [@default []];
5059
  ports: vhdl_port_t list [@default []];
5060
  declaration: vhdl_declaration_t list
5061
    [@key "ENTITY_DECLARATIVE_PART"][@default []];
5062
  stmts: vhdl_concurrent_stmt_t list
5063
    [@key "ENTITY_STATEMENT_PART"][@default []]}
5064

    
5065
(* Adapted *)
5066
let rec pp_vhdl_entity_t :
5067
  Format.formatter -> vhdl_entity_t -> Ppx_deriving_runtime.unit =
5068
  let __4 () = pp_vhdl_concurrent_stmt_t
5069
  
5070
  and __3 () = pp_vhdl_declaration_t
5071
  
5072
  and __2 () = pp_vhdl_port_t
5073
  
5074
  and __1 () = pp_vhdl_port_t
5075
  
5076
  and __0 () = pp_vhdl_name_t
5077
   in
5078
  ((let open! Ppx_deriving_runtime in
5079
      fun fmt  ->
5080
        fun x  ->
5081
          (((((
5082
               ((__0 ()) fmt) x.name;
5083
               Format.fprintf fmt " is@ ");
5084
              Format.fprintf fmt "@[<v>";
5085
              ((fun x  ->
5086
                  Format.fprintf fmt "@[";
5087
                  ignore
5088
                    (List.fold_left
5089
                       (fun sep  ->
5090
                          fun x  ->
5091
                            if sep then Format.fprintf fmt ";@ ";
5092
                            ((__1 ()) fmt) x;
5093
                            true) false x);
5094
                  Format.fprintf fmt "@]")) x.generics;
5095
              Format.fprintf fmt "@]");
5096
             Format.fprintf fmt "port (@[<v>";
5097
             ((fun x  ->
5098
                 Format.fprintf fmt "@[";
5099
                 ignore
5100
                   (List.fold_left
5101
                      (fun sep  ->
5102
                         fun x  ->
5103
                           if sep then Format.fprintf fmt ";@ ";
5104
                           ((__2 ()) fmt) x;
5105
                           true) false x);
5106
                 Format.fprintf fmt "@]")) x.ports;
5107
             Format.fprintf fmt "@]);");
5108
            Format.fprintf fmt "@[<v>";
5109
            ((fun x  ->
5110
                Format.fprintf fmt "@[";
5111
                ignore
5112
                  (List.fold_left
5113
                     (fun sep  ->
5114
                        fun x  ->
5115
                          if sep then Format.fprintf fmt ";@ ";
5116
                          ((__3 ()) fmt) x;
5117
                          true) false x);
5118
                Format.fprintf fmt "@]")) x.declaration;
5119
            Format.fprintf fmt "@]");
5120
           Format.fprintf fmt "@[<v>";
5121
           ((fun x  ->
5122
               Format.fprintf fmt "@[";
5123
               ignore
5124
                 (List.fold_left
5125
                    (fun sep  ->
5126
                       fun x  ->
5127
                         if sep then Format.fprintf fmt ";@ ";
5128
                         ((__4 ()) fmt) x;
5129
                         true) false x);
5130
               Format.fprintf fmt "@]")) x.stmts;
5131
           Format.fprintf fmt "@]");
5132
          Format.fprintf fmt "@]")
5133
    [@ocaml.warning "-A"])
5134

    
5135
and show_vhdl_entity_t : vhdl_entity_t -> Ppx_deriving_runtime.string =
5136
  fun x  -> Format.asprintf "%a" pp_vhdl_entity_t x
5137

    
5138
let rec (vhdl_entity_t_to_yojson : vhdl_entity_t -> Yojson.Safe.json) =
5139
  ((let open! Ppx_deriving_yojson_runtime in
5140
      fun x  ->
5141
        let fields = []  in
5142
        let fields =
5143
          if x.stmts = []
5144
          then fields
5145
          else
5146
            ("ENTITY_STATEMENT_PART",
5147
              (((fun x  ->
5148
                   `List
5149
                     (List.map (fun x  -> vhdl_concurrent_stmt_t_to_yojson x)
5150
                        x))) x.stmts))
5151
            :: fields
5152
           in
5153
        let fields =
5154
          if x.declaration = []
5155
          then fields
5156
          else
5157
            ("ENTITY_DECLARATIVE_PART",
5158
              (((fun x  ->
5159
                   `List
5160
                     (List.map (fun x  -> vhdl_declaration_t_to_yojson x) x)))
5161
                 x.declaration))
5162
            :: fields
5163
           in
5164
        let fields =
5165
          if x.ports = []
5166
          then fields
5167
          else
5168
            ("ports",
5169
              (((fun x  ->
5170
                   `List (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
5171
                 x.ports))
5172
            :: fields
5173
           in
5174
        let fields =
5175
          if x.generics = []
5176
          then fields
5177
          else
5178
            ("generics",
5179
              (((fun x  ->
5180
                   `List (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
5181
                 x.generics))
5182
            :: fields
5183
           in
5184
        let fields =
5185
          if x.name = NoName
5186
          then fields
5187
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
5188
            fields
5189
           in
5190
        `Assoc fields)
5191
  [@ocaml.warning "-A"])
5192

    
5193
and (vhdl_entity_t_of_yojson :
5194
      Yojson.Safe.json -> vhdl_entity_t Ppx_deriving_yojson_runtime.error_or)
5195
  =
5196
  ((let open! Ppx_deriving_yojson_runtime in
5197
      function
5198
      | `Assoc xs ->
5199
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
5200
            match xs with
5201
            | ("name",x)::xs ->
5202
                loop xs
5203
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3,
5204
                    arg4)
5205
            | ("generics",x)::xs ->
5206
                loop xs
5207
                  (arg0,
5208
                    ((function
5209
                      | `List xs ->
5210
                          map_bind (fun x  -> vhdl_port_t_of_yojson x) [] xs
5211
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.generics")
5212
                       x), arg2, arg3, arg4)
5213
            | ("ports",x)::xs ->
5214
                loop xs
5215
                  (arg0, arg1,
5216
                    ((function
5217
                      | `List xs ->
5218
                          map_bind (fun x  -> vhdl_port_t_of_yojson x) [] xs
5219
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.ports") x),
5220
                    arg3, arg4)
5221
            | ("ENTITY_DECLARATIVE_PART",x)::xs ->
5222
                loop xs
5223
                  (arg0, arg1, arg2,
5224
                    ((function
5225
                      | `List xs ->
5226
                          map_bind (fun x  -> vhdl_declaration_t_of_yojson x)
5227
                            [] xs
5228
                      | _ ->
5229
                          Result.Error "Vhdl_ast.vhdl_entity_t.declaration")
5230
                       x), arg4)
5231
            | ("ENTITY_STATEMENT_PART",x)::xs ->
5232
                loop xs
5233
                  (arg0, arg1, arg2, arg3,
5234
                    ((function
5235
                      | `List xs ->
5236
                          map_bind
5237
                            (fun x  -> vhdl_concurrent_stmt_t_of_yojson x) []
5238
                            xs
5239
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.stmts") x))
5240
            | [] ->
5241
                arg4 >>=
5242
                  ((fun arg4  ->
5243
                      arg3 >>=
5244
                        (fun arg3  ->
5245
                           arg2 >>=
5246
                             (fun arg2  ->
5247
                                arg1 >>=
5248
                                  (fun arg1  ->
5249
                                     arg0 >>=
5250
                                       (fun arg0  ->
5251
                                          Result.Ok
5252
                                            {
5253
                                              name = arg0;
5254
                                              generics = arg1;
5255
                                              ports = arg2;
5256
                                              declaration = arg3;
5257
                                              stmts = arg4
5258
                                            }))))))
5259
            | _::xs -> loop xs _state  in
5260
          loop xs
5261
            ((Result.Ok NoName), (Result.Ok []), (Result.Ok []),
5262
              (Result.Ok []), (Result.Ok []))
5263
      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t")
5264
  [@ocaml.warning "-A"])
5265

    
5266
type vhdl_package_t =
5267
  {
5268
  name: vhdl_name_t [@default NoName];
5269
  shared_defs: vhdl_definition_t list [@default []]}
5270

    
5271
(* Adapted -- TODO: indentation of package content is not correct *)
5272
let rec pp_vhdl_package_t :
5273
  Format.formatter -> vhdl_package_t -> Ppx_deriving_runtime.unit =
5274
  let __1 () = pp_vhdl_definition_t
5275
  
5276
  and __0 () = pp_vhdl_name_t
5277
   in
5278
  ((let open! Ppx_deriving_runtime in
5279
      fun fmt  ->
5280
        fun x  ->
5281
          ((Format.fprintf fmt "@[";
5282
            ((__0 ()) fmt) x.name;
5283
            Format.fprintf fmt " is@.");
5284
           Format.fprintf fmt "@[<v 2>";
5285
           ((fun x  ->
5286
               Format.fprintf fmt "@[";
5287
               ignore
5288
                 (List.fold_left
5289
                    (fun sep  ->
5290
                       fun x  ->
5291
                         if sep then Format.fprintf fmt ";@ ";
5292
                         ((__1 ()) fmt) x;
5293
                         true) false x);
5294
               Format.fprintf fmt "@,@]")) x.shared_defs;
5295
           Format.fprintf fmt "@]");
5296
          Format.fprintf fmt "@]")
5297
    [@ocaml.warning "-A"])
5298

    
5299
and show_vhdl_package_t : vhdl_package_t -> Ppx_deriving_runtime.string =
5300
  fun x  -> Format.asprintf "%a" pp_vhdl_package_t x
5301

    
5302
let rec (vhdl_package_t_to_yojson : vhdl_package_t -> Yojson.Safe.json) =
5303
  ((let open! Ppx_deriving_yojson_runtime in
5304
      fun x  ->
5305
        let fields = []  in
5306
        let fields =
5307
          if x.shared_defs = []
5308
          then fields
5309
          else
5310
            ("shared_defs",
5311
              (((fun x  ->
5312
                   `List
5313
                     (List.map (fun x  -> vhdl_definition_t_to_yojson x) x)))
5314
                 x.shared_defs))
5315
            :: fields
5316
           in
5317
        let fields =
5318
          if x.name = NoName
5319
          then fields
5320
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
5321
            fields
5322
           in
5323
        `Assoc fields)
5324
  [@ocaml.warning "-A"])
5325

    
5326
and (vhdl_package_t_of_yojson :
5327
      Yojson.Safe.json -> vhdl_package_t Ppx_deriving_yojson_runtime.error_or)
5328
  =
5329
  ((let open! Ppx_deriving_yojson_runtime in
5330
      function
5331
      | `Assoc xs ->
5332
          let rec loop xs ((arg0,arg1) as _state) =
5333
            match xs with
5334
            | ("name",x)::xs ->
5335
                loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
5336
            | ("shared_defs",x)::xs ->
5337
                loop xs
5338
                  (arg0,
5339
                    ((function
5340
                      | `List xs ->
5341
                          map_bind (fun x  -> vhdl_definition_t_of_yojson x)
5342
                            [] xs
5343
                      | _ ->
5344
                          Result.Error "Vhdl_ast.vhdl_package_t.shared_defs")
5345
                       x))
5346
            | [] ->
5347
                arg1 >>=
5348
                  ((fun arg1  ->
5349
                      arg0 >>=
5350
                        (fun arg0  ->
5351
                           Result.Ok { name = arg0; shared_defs = arg1 })))
5352
            | _::xs -> loop xs _state  in
5353
          loop xs ((Result.Ok NoName), (Result.Ok []))
5354
      | _ -> Result.Error "Vhdl_ast.vhdl_package_t")
5355
  [@ocaml.warning "-A"])
5356

    
5357
type vhdl_load_t =
5358
  | Library of vhdl_name_t list [@name "LIBRARY_CLAUSE"][@default []]
5359
  | Use of vhdl_name_t list [@name "USE_CLAUSE"][@default []]
5360

    
5361
(* Adapted *)
5362
let rec pp_vhdl_load_t :
5363
  Format.formatter -> vhdl_load_t -> Ppx_deriving_runtime.unit =
5364
  let __1 () = pp_vhdl_name_t
5365
  
5366
  and __0 () = pp_vhdl_name_t
5367
   in
5368
  ((let open! Ppx_deriving_runtime in
5369
      fun fmt  ->
5370
        function
5371
        | Library a0 ->
5372
            (Format.fprintf fmt "@[<2>library@ ";
5373
             ((fun x  ->
5374
                 Format.fprintf fmt "@[<2>";
5375
                 ignore
5376
                   (List.fold_left
5377
                      (fun sep  ->
5378
                         fun x  ->
5379
                           if sep then Format.fprintf fmt ".";
5380
                           ((__0 ()) fmt) x;
5381
                           true) false x);
5382
                 Format.fprintf fmt "@,@]")) a0;
5383
             Format.fprintf fmt "@]:")
5384
        | Use a0 ->
5385
            (Format.fprintf fmt "@[<2>use@ ";
5386
             ((fun x  ->
5387
                 Format.fprintf fmt "@[<2>";
5388
                 ignore
5389
                   (List.fold_left
5390
                      (fun sep  ->
5391
                         fun x  ->
5392
                           if sep then Format.fprintf fmt ".";
5393
                           ((__1 ()) fmt) x;
5394
                           true) false x);
5395
                 Format.fprintf fmt "@,@]")) a0;
5396
             Format.fprintf fmt "@];"))
5397
    [@ocaml.warning "-A"])
5398

    
5399
and show_vhdl_load_t : vhdl_load_t -> Ppx_deriving_runtime.string =
5400
  fun x  -> Format.asprintf "%a" pp_vhdl_load_t x
5401

    
5402
let rec (vhdl_load_t_to_yojson : vhdl_load_t -> Yojson.Safe.json) =
5403
  ((let open! Ppx_deriving_yojson_runtime in
5404
      function
5405
      | Library arg0 ->
5406
          `List
5407
            [`String "LIBRARY_CLAUSE";
5408
            ((fun x  ->
5409
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
5410
      | Use arg0 ->
5411
          `List
5412
            [`String "USE_CLAUSE";
5413
            ((fun x  ->
5414
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0])
5415
  [@ocaml.warning "-A"])
5416

    
5417
and (vhdl_load_t_of_yojson :
5418
      Yojson.Safe.json -> vhdl_load_t Ppx_deriving_yojson_runtime.error_or)
5419
  =
5420
  ((let open! Ppx_deriving_yojson_runtime in
5421
      function
5422
      | `List ((`String "LIBRARY_CLAUSE")::arg0::[]) ->
5423
          ((function
5424
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5425
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
5426
            ((fun arg0  -> Result.Ok (Library arg0)))
5427
      | `List ((`String "USE_CLAUSE")::arg0::[]) ->
5428
          ((function
5429
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5430
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
5431
            ((fun arg0  -> Result.Ok (Use arg0)))
5432
      | _ -> Result.Error "Vhdl_ast.vhdl_load_t")
5433
  [@ocaml.warning "-A"])
5434

    
5435
type vhdl_architecture_t =
5436
  {
5437
  name: vhdl_name_t [@default NoName];
5438
  entity: vhdl_name_t [@default NoName];
5439
  declarations: vhdl_declaration_t list
5440
    [@key "ARCHITECTURE_DECLARATIVE_PART"][@default []];
5441
  body: vhdl_concurrent_stmt_t list
5442
    [@key "ARCHITECTURE_STATEMENT_PART"][@default []]}
5443

    
5444
(* Adapted *)
5445
let rec pp_vhdl_architecture_t :
5446
  Format.formatter -> vhdl_architecture_t -> Ppx_deriving_runtime.unit =
5447
  let __3 () = pp_vhdl_concurrent_stmt_t
5448
  
5449
  and __2 () = pp_vhdl_declaration_t
5450
  
5451
  and __1 () = pp_vhdl_name_t
5452
  
5453
  and __0 () = pp_vhdl_name_t
5454
   in
5455
  ((let open! Ppx_deriving_runtime in
5456
      fun fmt  ->
5457
        fun x  ->
5458
          ((((
5459
              ((__0 ()) fmt) x.name;
5460
             );
5461
             Format.fprintf fmt " of ";
5462
             ((__1 ()) fmt) x.entity;
5463
            );
5464
            Format.fprintf fmt " is @ ";
5465
            Format.fprintf fmt "@[<v>";
5466
            ((fun x  ->
5467
                Format.fprintf fmt "@[";
5468
                ignore
5469
                  (List.fold_left
5470
                     (fun sep  ->
5471
                        fun x  ->
5472
                          if sep then Format.fprintf fmt "@ ";
5473
                          ((__2 ()) fmt) x;
5474
                          Format.fprintf fmt ";";
5475
                          true) false x);
5476
                Format.fprintf fmt "@]")) x.declarations;
5477
            Format.fprintf fmt "@]");
5478
           Format.fprintf fmt "@ ";
5479
           Format.fprintf fmt "@[<v>";
5480
           (match x.body with
5481