Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (212 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
          (match x.const with
232
            | NoConstraint -> Format.fprintf fmt "";
233
            | _ -> Format.fprintf fmt " ";
234
                   ((__2 ()) fmt) x.const))
235
    [@ocaml.warning "-A"])
236

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3670
and show_vhdl_declaration_t :
3671
  vhdl_declaration_t -> Ppx_deriving_runtime.string =
3672
  fun x  -> Format.asprintf "%a" pp_vhdl_declaration_t x
3673

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

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

    
4023
type vhdl_signal_condition_t =
4024
  {
4025
  expr: vhdl_expr_t list ;
4026
  cond: vhdl_expr_t [@default IsNull]}
4027

    
4028
(* Adapted *)
4029
let rec pp_vhdl_signal_condition_t :
4030
  Format.formatter -> vhdl_signal_condition_t -> Ppx_deriving_runtime.unit =
4031
  let __1 () = pp_vhdl_expr_t
4032
  
4033
  and __0 () = pp_vhdl_expr_t
4034
   in
4035
  ((let open! Ppx_deriving_runtime in
4036
      fun fmt  ->
4037
        fun x  ->
4038
          ((fun x  ->
4039
              ignore
4040
                (List.fold_left
4041
                   (fun sep  ->
4042
                      fun x  ->
4043
                        if sep then Format.fprintf fmt ";@ ";
4044
                        ((__0 ()) fmt) x;
4045
                        true) false x))) x.expr;
4046
          (match x.cond with
4047
          | IsNull -> Format.fprintf fmt "";
4048
          | _ -> Format.fprintf fmt "when ";
4049
                 ((__1 ()) fmt) x.cond);)
4050
    [@ocaml.warning "-A"])
4051

    
4052
and show_vhdl_signal_condition_t :
4053
  vhdl_signal_condition_t -> Ppx_deriving_runtime.string =
4054
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_condition_t x
4055

    
4056
let rec (vhdl_signal_condition_t_to_yojson :
4057
          vhdl_signal_condition_t -> Yojson.Safe.json)
4058
  =
4059
  ((let open! Ppx_deriving_yojson_runtime in
4060
      fun x  ->
4061
        let fields = []  in
4062
        let fields =
4063
          if x.cond = IsNull
4064
          then fields
4065
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4066
            fields
4067
           in
4068
        let fields =
4069
          ("expr",
4070
            ((fun x  ->
4071
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
4072
               x.expr))
4073
          :: fields  in
4074
        `Assoc fields)
4075
  [@ocaml.warning "-A"])
4076

    
4077
and (vhdl_signal_condition_t_of_yojson :
4078
      Yojson.Safe.json ->
4079
        vhdl_signal_condition_t Ppx_deriving_yojson_runtime.error_or)
4080
  =
4081
  ((let open! Ppx_deriving_yojson_runtime in
4082
      function
4083
      | `Assoc xs ->
4084
          let rec loop xs ((arg0,arg1) as _state) =
4085
            match xs with
4086
            | ("expr",x)::xs ->
4087
                loop xs
4088
                  (((function
4089
                     | `List xs ->
4090
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4091
                     | _ ->
4092
                         Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr")
4093
                      x), arg1)
4094
            | ("cond",x)::xs ->
4095
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4096
            | [] ->
4097
                arg1 >>=
4098
                  ((fun arg1  ->
4099
                      arg0 >>=
4100
                        (fun arg0  -> Result.Ok { expr = arg0; cond = arg1 })))
4101
            | _::xs -> loop xs _state  in
4102
          loop xs
4103
            ((Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr"),
4104
              (Result.Ok IsNull))
4105
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_condition_t")
4106
  [@ocaml.warning "-A"])
4107

    
4108
type vhdl_signal_selection_t =
4109
  {
4110
  expr: vhdl_expr_t ;
4111
  when_sel: vhdl_expr_t list [@default []]}
4112

    
4113
let rec pp_vhdl_signal_selection_t :
4114
  Format.formatter -> vhdl_signal_selection_t -> Ppx_deriving_runtime.unit =
4115
  let __1 () = pp_vhdl_expr_t
4116
  
4117
  and __0 () = pp_vhdl_expr_t
4118
   in
4119
  ((let open! Ppx_deriving_runtime in
4120
      fun fmt  ->
4121
        fun x  ->
4122
          Format.fprintf fmt "@[<2>{ ";
4123
          ((Format.fprintf fmt "@[%s =@ " "expr";
4124
            ((__0 ()) fmt) x.expr;
4125
            Format.fprintf fmt "@]");
4126
           Format.fprintf fmt ";@ ";
4127
           Format.fprintf fmt "@[%s =@ " "when_sel";
4128
           ((fun x  ->
4129
               Format.fprintf fmt "@[<2>[";
4130
               ignore
4131
                 (List.fold_left
4132
                    (fun sep  ->
4133
                       fun x  ->
4134
                         if sep then Format.fprintf fmt ";@ ";
4135
                         ((__1 ()) fmt) x;
4136
                         true) false x);
4137
               Format.fprintf fmt "@,]@]")) x.when_sel;
4138
           Format.fprintf fmt "@]");
4139
          Format.fprintf fmt "@ }@]")
4140
    [@ocaml.warning "-A"])
4141

    
4142
and show_vhdl_signal_selection_t :
4143
  vhdl_signal_selection_t -> Ppx_deriving_runtime.string =
4144
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_selection_t x
4145

    
4146
let rec (vhdl_signal_selection_t_to_yojson :
4147
          vhdl_signal_selection_t -> Yojson.Safe.json)
4148
  =
4149
  ((let open! Ppx_deriving_yojson_runtime in
4150
      fun x  ->
4151
        let fields = []  in
4152
        let fields =
4153
          if x.when_sel = []
4154
          then fields
4155
          else
4156
            ("when_sel",
4157
              (((fun x  ->
4158
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
4159
                 x.when_sel))
4160
            :: fields
4161
           in
4162
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
4163
          :: fields  in
4164
        `Assoc fields)
4165
  [@ocaml.warning "-A"])
4166

    
4167
and (vhdl_signal_selection_t_of_yojson :
4168
      Yojson.Safe.json ->
4169
        vhdl_signal_selection_t Ppx_deriving_yojson_runtime.error_or)
4170
  =
4171
  ((let open! Ppx_deriving_yojson_runtime in
4172
      function
4173
      | `Assoc xs ->
4174
          let rec loop xs ((arg0,arg1) as _state) =
4175
            match xs with
4176
            | ("expr",x)::xs ->
4177
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
4178
            | ("when_sel",x)::xs ->
4179
                loop xs
4180
                  (arg0,
4181
                    ((function
4182
                      | `List xs ->
4183
                          map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4184
                      | _ ->
4185
                          Result.Error
4186
                            "Vhdl_ast.vhdl_signal_selection_t.when_sel") x))
4187
            | [] ->
4188
                arg1 >>=
4189
                  ((fun arg1  ->
4190
                      arg0 >>=
4191
                        (fun arg0  ->
4192
                           Result.Ok { expr = arg0; when_sel = arg1 })))
4193
            | _::xs -> loop xs _state  in
4194
          loop xs
4195
            ((Result.Error "Vhdl_ast.vhdl_signal_selection_t.expr"),
4196
              (Result.Ok []))
4197
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_selection_t")
4198
  [@ocaml.warning "-A"])
4199

    
4200
type vhdl_conditional_signal_t =
4201
  {
4202
  postponed: bool [@default false];
4203
  label: vhdl_name_t [@default NoName];
4204
  lhs: vhdl_name_t ;
4205
  rhs: vhdl_signal_condition_t list ;
4206
  cond: vhdl_expr_t [@default IsNull];
4207
  delay: vhdl_expr_t [@default IsNull]}
4208

    
4209
(* Adapted *)
4210
let rec pp_vhdl_conditional_signal_t :
4211
  Format.formatter -> vhdl_conditional_signal_t -> Ppx_deriving_runtime.unit
4212
  =
4213
  let __4 () = pp_vhdl_expr_t
4214
  
4215
  and __3 () = pp_vhdl_expr_t
4216
  
4217
  and __2 () = pp_vhdl_signal_condition_t
4218
  
4219
  and __1 () = pp_vhdl_name_t
4220
  
4221
  and __0 () = pp_vhdl_name_t
4222
   in
4223
  ((let open! Ppx_deriving_runtime in
4224
      fun fmt  ->
4225
        fun x  ->
4226
          (match x.label with
4227
            | NoName -> Format.fprintf fmt "";
4228
            | _ -> (((__0 ()) fmt) x.label;
4229
                   Format.fprintf fmt ":@ ")
4230
          );
4231
          if (x.postponed) then Format.fprintf fmt "postponed@ ";
4232
          ((__1 ()) fmt) x.lhs;
4233
          Format.fprintf fmt " <= ";
4234
          (match x.delay with
4235
            | IsNull -> Format.fprintf fmt "";
4236
            | _ -> ((__4 ()) fmt) x.delay;
4237
                   Format.fprintf fmt " ");
4238
          ((fun x  ->
4239
             Format.fprintf fmt "@[";
4240
             ignore
4241
               (List.fold_left
4242
                 (fun sep  ->
4243
                   fun x  ->
4244
                     if sep then Format.fprintf fmt "";
4245
                      ((__2 ()) fmt) x;
4246
                      Format.fprintf fmt ";";
4247
                      true) false x);
4248
          Format.fprintf fmt "@]")) x.rhs;
4249
          (match x.cond with
4250
            | IsNull -> Format.fprintf fmt "";
4251
            | _ -> Format.fprintf fmt "when (";
4252
                   ((__3 ()) fmt) x.cond;
4253
                   Format.fprintf fmt ")"))
4254
   [@ocaml.warning "-A"])
4255

    
4256
and show_vhdl_conditional_signal_t :
4257
  vhdl_conditional_signal_t -> Ppx_deriving_runtime.string =
4258
  fun x  -> Format.asprintf "%a" pp_vhdl_conditional_signal_t x
4259

    
4260
let rec (vhdl_conditional_signal_t_to_yojson :
4261
          vhdl_conditional_signal_t -> Yojson.Safe.json)
4262
  =
4263
  ((let open! Ppx_deriving_yojson_runtime in
4264
      fun x  ->
4265
        let fields = []  in
4266
        let fields =
4267
          if x.delay = IsNull
4268
          then fields
4269
          else ("delay", (((fun x  -> vhdl_expr_t_to_yojson x)) x.delay)) ::
4270
            fields
4271
           in
4272
        let fields =
4273
          if x.cond = IsNull
4274
          then fields
4275
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4276
            fields
4277
           in
4278
        let fields =
4279
          ("rhs",
4280
            ((fun x  ->
4281
                `List
4282
                  (List.map (fun x  -> vhdl_signal_condition_t_to_yojson x) x))
4283
               x.rhs))
4284
          :: fields  in
4285
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4286
          fields  in
4287
        let fields =
4288
          if x.label = NoName
4289
          then fields
4290
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4291
            fields
4292
           in
4293
        let fields =
4294
          if x.postponed = false
4295
          then fields
4296
          else
4297
            ("postponed",
4298
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4299
                 x.postponed))
4300
            :: fields
4301
           in
4302
        `Assoc fields)
4303
  [@ocaml.warning "-A"])
4304

    
4305
and (vhdl_conditional_signal_t_of_yojson :
4306
      Yojson.Safe.json ->
4307
        vhdl_conditional_signal_t Ppx_deriving_yojson_runtime.error_or)
4308
  =
4309
  ((let open! Ppx_deriving_yojson_runtime in
4310
      function
4311
      | `Assoc xs ->
4312
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4313
            match xs with
4314
            | ("postponed",x)::xs ->
4315
                loop xs
4316
                  (((function
4317
                     | `Bool x -> Result.Ok x
4318
                     | _ ->
4319
                         Result.Error
4320
                           "Vhdl_ast.vhdl_conditional_signal_t.postponed") x),
4321
                    arg1, arg2, arg3, arg4, arg5)
4322
            | ("label",x)::xs ->
4323
                loop xs
4324
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4325
                    arg4, arg5)
4326
            | ("lhs",x)::xs ->
4327
                loop xs
4328
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4329
                    arg4, arg5)
4330
            | ("rhs",x)::xs ->
4331
                loop xs
4332
                  (arg0, arg1, arg2,
4333
                    ((function
4334
                      | `List xs ->
4335
                          map_bind
4336
                            (fun x  -> vhdl_signal_condition_t_of_yojson x)
4337
                            [] xs
4338
                      | _ ->
4339
                          Result.Error
4340
                            "Vhdl_ast.vhdl_conditional_signal_t.rhs") x),
4341
                    arg4, arg5)
4342
            | ("cond",x)::xs ->
4343
                loop xs
4344
                  (arg0, arg1, arg2, arg3,
4345
                    ((fun x  -> vhdl_expr_t_of_yojson x) x), arg5)
4346
            | ("delay",x)::xs ->
4347
                loop xs
4348
                  (arg0, arg1, arg2, arg3, arg4,
4349
                    ((fun x  -> vhdl_expr_t_of_yojson x) x))
4350
            | [] ->
4351
                arg5 >>=
4352
                  ((fun arg5  ->
4353
                      arg4 >>=
4354
                        (fun arg4  ->
4355
                           arg3 >>=
4356
                             (fun arg3  ->
4357
                                arg2 >>=
4358
                                  (fun arg2  ->
4359
                                     arg1 >>=
4360
                                       (fun arg1  ->
4361
                                          arg0 >>=
4362
                                            (fun arg0  ->
4363
                                               Result.Ok
4364
                                                 {
4365
                                                   postponed = arg0;
4366
                                                   label = arg1;
4367
                                                   lhs = arg2;
4368
                                                   rhs = arg3;
4369
                                                   cond = arg4;
4370
                                                   delay = arg5
4371
                                                 })))))))
4372
            | _::xs -> loop xs _state  in
4373
          loop xs
4374
            ((Result.Ok false), (Result.Ok NoName),
4375
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.lhs"),
4376
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.rhs"),
4377
              (Result.Ok IsNull), (Result.Ok IsNull))
4378
      | _ -> Result.Error "Vhdl_ast.vhdl_conditional_signal_t")
4379
  [@ocaml.warning "-A"])
4380

    
4381
type vhdl_process_t =
4382
  {
4383
  id: vhdl_name_t [@default NoName];
4384
  declarations: vhdl_declaration_t list option
4385
    [@key "PROCESS_DECLARATIVE_PART"][@default Some []];
4386
  active_sigs: vhdl_name_t list [@default []];
4387
  body: vhdl_sequential_stmt_t list
4388
    [@key "PROCESS_STATEMENT_PART"][@default []]}
4389

    
4390
(* Adapted *)
4391
let rec pp_vhdl_process_t :
4392
  Format.formatter -> vhdl_process_t -> Ppx_deriving_runtime.unit =
4393
  let __3 () = pp_vhdl_sequential_stmt_t
4394
  
4395
  and __2 () = pp_vhdl_name_t
4396
  
4397
  and __1 () = pp_vhdl_declaration_t
4398
  
4399
  and __0 () = pp_vhdl_name_t
4400
   in
4401
  ((let open! Ppx_deriving_runtime in
4402
      fun fmt  ->
4403
        fun x  ->
4404
          Format.fprintf fmt "@[<v>process ";
4405
          (match x.active_sigs with
4406
          | [] -> Format.fprintf fmt "";
4407
          | _ -> Format.fprintf fmt "(";
4408
                 ((fun x  ->
4409
                    ignore
4410
                      (List.fold_left
4411
                         (fun sep  ->
4412
                            fun x  ->
4413
                              if sep then Format.fprintf fmt ",";
4414
                              ((__2 ()) fmt) x;
4415
                              true) false x))) x.active_sigs;
4416
                 Format.fprintf fmt ")");
4417
          ((function
4418
             | None  -> Format.pp_print_string fmt ""
4419
             | Some x ->
4420
                  ((fun x  ->
4421
                      Format.fprintf fmt "@[<2>";
4422
                      ignore
4423
                        (List.fold_left
4424
                           (fun sep  ->
4425
                              fun x  ->
4426
                                if sep then Format.fprintf fmt "@;";
4427
                                ((__1 ()) fmt) x;
4428
                                true) false x);
4429
                      Format.fprintf fmt "@]")) x;)) x.declarations;
4430
          Format.fprintf fmt "@;@[<v 2>begin@;";
4431
          ((fun x  ->
4432
               ignore
4433
                 (List.fold_left
4434
                    (fun sep  ->
4435
                       fun x  ->
4436
                         if sep then Format.fprintf fmt "@;";
4437
                         ((__3 ()) fmt) x;
4438
                         true) false x);)) x.body;
4439
          Format.fprintf fmt "@]@;end process;@;";
4440
          Format.fprintf fmt "@]";)
4441
    [@ocaml.warning "-A"])
4442

    
4443
and show_vhdl_process_t : vhdl_process_t -> Ppx_deriving_runtime.string =
4444
  fun x  -> Format.asprintf "%a" pp_vhdl_process_t x
4445

    
4446
let rec (vhdl_process_t_to_yojson : vhdl_process_t -> Yojson.Safe.json) =
4447
  ((let open! Ppx_deriving_yojson_runtime in
4448
      fun x  ->
4449
        let fields = []  in
4450
        let fields =
4451
          if x.body = []
4452
          then fields
4453
          else
4454
            ("PROCESS_STATEMENT_PART",
4455
              (((fun x  ->
4456
                   `List
4457
                     (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x)
4458
                        x))) x.body))
4459
            :: fields
4460
           in
4461
        let fields =
4462
          if x.active_sigs = []
4463
          then fields
4464
          else
4465
            ("active_sigs",
4466
              (((fun x  ->
4467
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
4468
                 x.active_sigs))
4469
            :: fields
4470
           in
4471
        let fields =
4472
          if x.declarations = (Some [])
4473
          then fields
4474
          else
4475
            ("PROCESS_DECLARATIVE_PART",
4476
              (((function
4477
                 | None  -> `Null
4478
                 | Some x ->
4479
                     ((fun x  ->
4480
                         `List
4481
                           (List.map
4482
                              (fun x  -> vhdl_declaration_t_to_yojson x) x)))
4483
                       x)) x.declarations))
4484
            :: fields
4485
           in
4486
        let fields =
4487
          if x.id = NoName
4488
          then fields
4489
          else ("id", (((fun x  -> vhdl_name_t_to_yojson x)) x.id)) :: fields
4490
           in
4491
        `Assoc fields)
4492
  [@ocaml.warning "-A"])
4493

    
4494
and (vhdl_process_t_of_yojson :
4495
      Yojson.Safe.json -> vhdl_process_t Ppx_deriving_yojson_runtime.error_or)
4496
  =
4497
  ((let open! Ppx_deriving_yojson_runtime in
4498
      function
4499
      | `Assoc xs ->
4500
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
4501
            match xs with
4502
            | ("id",x)::xs ->
4503
                loop xs
4504
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3)
4505
            | ("PROCESS_DECLARATIVE_PART",x)::xs ->
4506
                loop xs
4507
                  (arg0,
4508
                    ((function
4509
                      | `Null -> Result.Ok None
4510
                      | x ->
4511
                          ((function
4512
                            | `List xs ->
4513
                                map_bind
4514
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4515
                                  [] xs
4516
                            | _ ->
4517
                                Result.Error
4518
                                  "Vhdl_ast.vhdl_process_t.declarations") x)
4519
                            >>= ((fun x  -> Result.Ok (Some x)))) x), arg2,
4520
                    arg3)
4521
            | ("active_sigs",x)::xs ->
4522
                loop xs
4523
                  (arg0, arg1,
4524
                    ((function
4525
                      | `List xs ->
4526
                          map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4527
                      | _ ->
4528
                          Result.Error "Vhdl_ast.vhdl_process_t.active_sigs")
4529
                       x), arg3)
4530
            | ("PROCESS_STATEMENT_PART",x)::xs ->
4531
                loop xs
4532
                  (arg0, arg1, arg2,
4533
                    ((function
4534
                      | `List xs ->
4535
                          map_bind
4536
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
4537
                            xs
4538
                      | _ -> Result.Error "Vhdl_ast.vhdl_process_t.body") x))
4539
            | [] ->
4540
                arg3 >>=
4541
                  ((fun arg3  ->
4542
                      arg2 >>=
4543
                        (fun arg2  ->
4544
                           arg1 >>=
4545
                             (fun arg1  ->
4546
                                arg0 >>=
4547
                                  (fun arg0  ->
4548
                                     Result.Ok
4549
                                       {
4550
                                         id = arg0;
4551
                                         declarations = arg1;
4552
                                         active_sigs = arg2;
4553
                                         body = arg3
4554
                                       })))))
4555
            | _::xs -> loop xs _state  in
4556
          loop xs
4557
            ((Result.Ok NoName), (Result.Ok (Some [])), (Result.Ok []),
4558
              (Result.Ok []))
4559
      | _ -> Result.Error "Vhdl_ast.vhdl_process_t")
4560
  [@ocaml.warning "-A"])
4561

    
4562
type vhdl_selected_signal_t =
4563
  {
4564
  postponed: bool [@default false];
4565
  label: vhdl_name_t [@default NoName];
4566
  lhs: vhdl_name_t ;
4567
  sel: vhdl_expr_t ;
4568
  branches: vhdl_signal_selection_t list [@default []];
4569
  delay: vhdl_expr_t option }
4570

    
4571
let rec pp_vhdl_selected_signal_t :
4572
  Format.formatter -> vhdl_selected_signal_t -> Ppx_deriving_runtime.unit =
4573
  let __4 () = pp_vhdl_expr_t
4574
  
4575
  and __3 () = pp_vhdl_signal_selection_t
4576
  
4577
  and __2 () = pp_vhdl_expr_t
4578
  
4579
  and __1 () = pp_vhdl_name_t
4580
  
4581
  and __0 () = pp_vhdl_name_t
4582
   in
4583
  ((let open! Ppx_deriving_runtime in
4584
      fun fmt  ->
4585
        fun x  ->
4586
          Format.fprintf fmt "@[<2>{ ";
4587
          ((((((Format.fprintf fmt "@[%s =@ " "postponed";
4588
                (Format.fprintf fmt "%B") x.postponed;
4589
                Format.fprintf fmt "@]");
4590
               Format.fprintf fmt ";@ ";
4591
               Format.fprintf fmt "@[%s =@ " "label";
4592
               ((__0 ()) fmt) x.label;
4593
               Format.fprintf fmt "@]");
4594
              Format.fprintf fmt ";@ ";
4595
              Format.fprintf fmt "@[%s =@ " "lhs";
4596
              ((__1 ()) fmt) x.lhs;
4597
              Format.fprintf fmt "@]");
4598
             Format.fprintf fmt ";@ ";
4599
             Format.fprintf fmt "@[%s =@ " "sel";
4600
             ((__2 ()) fmt) x.sel;
4601
             Format.fprintf fmt "@]");
4602
            Format.fprintf fmt ";@ ";
4603
            Format.fprintf fmt "@[%s =@ " "branches";
4604
            ((fun x  ->
4605
                Format.fprintf fmt "@[<2>[";
4606
                ignore
4607
                  (List.fold_left
4608
                     (fun sep  ->
4609
                        fun x  ->
4610
                          if sep then Format.fprintf fmt ";@ ";
4611
                          ((__3 ()) fmt) x;
4612
                          true) false x);
4613
                Format.fprintf fmt "@,]@]")) x.branches;
4614
            Format.fprintf fmt "@]");
4615
           Format.fprintf fmt ";@ ";
4616
           Format.fprintf fmt "@[%s =@ " "delay";
4617
           ((function
4618
             | None  -> Format.pp_print_string fmt "None"
4619
             | Some x ->
4620
                 (Format.pp_print_string fmt "(Some ";
4621
                  ((__4 ()) fmt) x;
4622
                  Format.pp_print_string fmt ")"))) x.delay;
4623
           Format.fprintf fmt "@]");
4624
          Format.fprintf fmt "@ }@]")
4625
    [@ocaml.warning "-A"])
4626

    
4627
and show_vhdl_selected_signal_t :
4628
  vhdl_selected_signal_t -> Ppx_deriving_runtime.string =
4629
  fun x  -> Format.asprintf "%a" pp_vhdl_selected_signal_t x
4630

    
4631
let rec (vhdl_selected_signal_t_to_yojson :
4632
          vhdl_selected_signal_t -> Yojson.Safe.json)
4633
  =
4634
  ((let open! Ppx_deriving_yojson_runtime in
4635
      fun x  ->
4636
        let fields = []  in
4637
        let fields =
4638
          ("delay",
4639
            ((function
4640
              | None  -> `Null
4641
              | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x) x.delay))
4642
          :: fields  in
4643
        let fields =
4644
          if x.branches = []
4645
          then fields
4646
          else
4647
            ("branches",
4648
              (((fun x  ->
4649
                   `List
4650
                     (List.map
4651
                        (fun x  -> vhdl_signal_selection_t_to_yojson x) x)))
4652
                 x.branches))
4653
            :: fields
4654
           in
4655
        let fields = ("sel", ((fun x  -> vhdl_expr_t_to_yojson x) x.sel)) ::
4656
          fields  in
4657
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4658
          fields  in
4659
        let fields =
4660
          if x.label = NoName
4661
          then fields
4662
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4663
            fields
4664
           in
4665
        let fields =
4666
          if x.postponed = false
4667
          then fields
4668
          else
4669
            ("postponed",
4670
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4671
                 x.postponed))
4672
            :: fields
4673
           in
4674
        `Assoc fields)
4675
  [@ocaml.warning "-A"])
4676

    
4677
and (vhdl_selected_signal_t_of_yojson :
4678
      Yojson.Safe.json ->
4679
        vhdl_selected_signal_t Ppx_deriving_yojson_runtime.error_or)
4680
  =
4681
  ((let open! Ppx_deriving_yojson_runtime in
4682
      function
4683
      | `Assoc xs ->
4684
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4685
            match xs with
4686
            | ("postponed",x)::xs ->
4687
                loop xs
4688
                  (((function
4689
                     | `Bool x -> Result.Ok x
4690
                     | _ ->
4691
                         Result.Error
4692
                           "Vhdl_ast.vhdl_selected_signal_t.postponed") x),
4693
                    arg1, arg2, arg3, arg4, arg5)
4694
            | ("label",x)::xs ->
4695
                loop xs
4696
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4697
                    arg4, arg5)
4698
            | ("lhs",x)::xs ->
4699
                loop xs
4700
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4701
                    arg4, arg5)
4702
            | ("sel",x)::xs ->
4703
                loop xs
4704
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x),
4705
                    arg4, arg5)
4706
            | ("branches",x)::xs ->
4707
                loop xs
4708
                  (arg0, arg1, arg2, arg3,
4709
                    ((function
4710
                      | `List xs ->
4711
                          map_bind
4712
                            (fun x  -> vhdl_signal_selection_t_of_yojson x)
4713
                            [] xs
4714
                      | _ ->
4715
                          Result.Error
4716
                            "Vhdl_ast.vhdl_selected_signal_t.branches") x),
4717
                    arg5)
4718
            | ("delay",x)::xs ->
4719
                loop xs
4720
                  (arg0, arg1, arg2, arg3, arg4,
4721
                    ((function
4722
                      | `Null -> Result.Ok None
4723
                      | x ->
4724
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
4725
                            ((fun x  -> Result.Ok (Some x)))) x))
4726
            | [] ->
4727
                arg5 >>=
4728
                  ((fun arg5  ->
4729
                      arg4 >>=
4730
                        (fun arg4  ->
4731
                           arg3 >>=
4732
                             (fun arg3  ->
4733
                                arg2 >>=
4734
                                  (fun arg2  ->
4735
                                     arg1 >>=
4736
                                       (fun arg1  ->
4737
                                          arg0 >>=
4738
                                            (fun arg0  ->
4739
                                               Result.Ok
4740
                                                 {
4741
                                                   postponed = arg0;
4742
                                                   label = arg1;
4743
                                                   lhs = arg2;
4744
                                                   sel = arg3;
4745
                                                   branches = arg4;
4746
                                                   delay = arg5
4747
                                                 })))))))
4748
            | _::xs -> loop xs _state  in
4749
          loop xs
4750
            ((Result.Ok false), (Result.Ok NoName),
4751
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.lhs"),
4752
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.sel"),
4753
              (Result.Ok []),
4754
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.delay"))
4755
      | _ -> Result.Error "Vhdl_ast.vhdl_selected_signal_t")
4756
  [@ocaml.warning "-A"])
4757

    
4758
type vhdl_concurrent_stmt_t =
4759
  | SigAssign of vhdl_conditional_signal_t
4760
  [@name "CONDITIONAL_SIGNAL_ASSIGNMENT"]
4761
  | Process of vhdl_process_t [@name "PROCESS_STATEMENT"]
4762
  | SelectedSig of vhdl_selected_signal_t
4763
  [@name "SELECTED_SIGNAL_ASSIGNMENT"]
4764

    
4765
(* Adapted *)
4766
let rec pp_vhdl_concurrent_stmt_t :
4767
  Format.formatter -> vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.unit =
4768
  let __2 () = pp_vhdl_selected_signal_t
4769
  
4770
  and __1 () = pp_vhdl_process_t
4771
  
4772
  and __0 () = pp_vhdl_conditional_signal_t
4773
   in
4774
  ((let open! Ppx_deriving_runtime in
4775
      fun fmt  ->
4776
        function
4777
        | SigAssign a0 ->
4778
             ((__0 ()) fmt) a0;
4779
        | Process a0 ->
4780
             ((__1 ()) fmt) a0;
4781
        | SelectedSig a0 ->
4782
             ((__2 ()) fmt) a0;
4783
    )
4784
    [@ocaml.warning "-A"])
4785

    
4786
and show_vhdl_concurrent_stmt_t :
4787
  vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.string =
4788
  fun x  -> Format.asprintf "%a" pp_vhdl_concurrent_stmt_t x
4789

    
4790
let rec (vhdl_concurrent_stmt_t_to_yojson :
4791
          vhdl_concurrent_stmt_t -> Yojson.Safe.json)
4792
  =
4793
  ((let open! Ppx_deriving_yojson_runtime in
4794
      function
4795
      | SigAssign arg0 ->
4796
          `List
4797
            [`String "CONDITIONAL_SIGNAL_ASSIGNMENT";
4798
            ((fun x  -> vhdl_conditional_signal_t_to_yojson x)) arg0]
4799
      | Process arg0 ->
4800
          `List
4801
            [`String "PROCESS_STATEMENT";
4802
            ((fun x  -> vhdl_process_t_to_yojson x)) arg0]
4803
      | SelectedSig arg0 ->
4804
          `List
4805
            [`String "SELECTED_SIGNAL_ASSIGNMENT";
4806
            ((fun x  -> vhdl_selected_signal_t_to_yojson x)) arg0])
4807
  [@ocaml.warning "-A"])
4808

    
4809
and (vhdl_concurrent_stmt_t_of_yojson :
4810
      Yojson.Safe.json ->
4811
        vhdl_concurrent_stmt_t Ppx_deriving_yojson_runtime.error_or)
4812
  =
4813
  ((let open! Ppx_deriving_yojson_runtime in
4814
      function
4815
      | `List ((`String "CONDITIONAL_SIGNAL_ASSIGNMENT")::arg0::[]) ->
4816
          ((fun x  -> vhdl_conditional_signal_t_of_yojson x) arg0) >>=
4817
            ((fun arg0  -> Result.Ok (SigAssign arg0)))
4818
      | `List ((`String "PROCESS_STATEMENT")::arg0::[]) ->
4819
          ((fun x  -> vhdl_process_t_of_yojson x) arg0) >>=
4820
            ((fun arg0  -> Result.Ok (Process arg0)))
4821
      | `List ((`String "SELECTED_SIGNAL_ASSIGNMENT")::arg0::[]) ->
4822
          ((fun x  -> vhdl_selected_signal_t_of_yojson x) arg0) >>=
4823
            ((fun arg0  -> Result.Ok (SelectedSig arg0)))
4824
      | _ -> Result.Error "Vhdl_ast.vhdl_concurrent_stmt_t")
4825
  [@ocaml.warning "-A"])
4826

    
4827
type vhdl_port_mode_t =
4828
  | InPort [@name "in"]
4829
  | OutPort [@name "out"]
4830
  | InoutPort [@name "inout"]
4831
  | BufferPort [@name "buffer"]
4832

    
4833
let rec (pp_vhdl_port_mode_t :
4834
          Format.formatter -> vhdl_port_mode_t -> Ppx_deriving_runtime.unit)
4835
  =
4836
  ((let open! Ppx_deriving_runtime in
4837
      fun fmt  ->
4838
        function
4839
        | InPort  -> Format.pp_print_string fmt "in"
4840
        | OutPort  -> Format.pp_print_string fmt "out"
4841
        | InoutPort  -> Format.pp_print_string fmt "inout"
4842
        | BufferPort  -> Format.pp_print_string fmt "buffer")
4843
  [@ocaml.warning "-A"])
4844

    
4845
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string =
4846
  fun x  -> Format.asprintf "%a" pp_vhdl_port_mode_t x
4847

    
4848
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) =
4849
  ((let open! Ppx_deriving_yojson_runtime in
4850
      function
4851
      | InPort  -> `List [`String "in"]
4852
      | OutPort  -> `List [`String "out"]
4853
      | InoutPort  -> `List [`String "inout"]
4854
      | BufferPort  -> `List [`String "buffer"])
4855
  [@ocaml.warning "-A"])
4856

    
4857
and (vhdl_port_mode_t_of_yojson :
4858
      Yojson.Safe.json ->
4859
        vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or)
4860
  =
4861
  ((let open! Ppx_deriving_yojson_runtime in
4862
      function
4863
      | `List ((`String "in")::[]) -> Result.Ok InPort
4864
      | `List ((`String "out")::[]) -> Result.Ok OutPort
4865
      | `List ((`String "inout")::[]) -> Result.Ok InoutPort
4866
      | `List ((`String "buffer")::[]) -> Result.Ok BufferPort
4867
      | _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t")
4868
  [@ocaml.warning "-A"])
4869

    
4870
type vhdl_port_t =
4871
  {
4872
  names: vhdl_name_t list [@default []];
4873
  mode: vhdl_port_mode_t [@default InPort];
4874
  typ: vhdl_subtype_indication_t ;
4875
  expr: vhdl_expr_t [@default IsNull]}
4876

    
4877
(* Adapted *)
4878
let rec pp_vhdl_port_t :
4879
  Format.formatter -> vhdl_port_t -> Ppx_deriving_runtime.unit =
4880
  let __3 () = pp_vhdl_expr_t
4881
  
4882
  and __2 () = pp_vhdl_subtype_indication_t
4883
  
4884
  and __1 () = pp_vhdl_port_mode_t
4885
  
4886
  and __0 () = pp_vhdl_name_t
4887
   in
4888
  ((let open! Ppx_deriving_runtime in
4889
      fun fmt  ->
4890
        fun x  ->
4891
          Format.fprintf fmt "@[";
4892
          ((((
4893
              ((fun x  ->
4894
                  Format.fprintf fmt "@[";
4895
                  ignore
4896
                    (List.fold_left
4897
                       (fun sep  ->
4898
                          fun x  ->
4899
                            if sep then Format.fprintf fmt ",@ ";
4900
                            ((__0 ()) fmt) x;
4901
                            true) false x);
4902
                  Format.fprintf fmt "@,@]")) x.names;
4903
              );
4904
             Format.fprintf fmt ": ";
4905
             ((__1 ()) fmt) x.mode;
4906
             );
4907
             Format.fprintf fmt " ";
4908
            ((__2 ()) fmt) x.typ;
4909
            );
4910
          (match x.expr with
4911
           | IsNull -> Format.fprintf fmt "";
4912
           | _ -> (Format.fprintf fmt "@[:= ";
4913
                   ((__3 ()) fmt) x.expr;
4914
                   Format.fprintf fmt "@]"));
4915
          Format.fprintf fmt "@]"))
4916
    [@ocaml.warning "-A"])
4917

    
4918
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string =
4919
  fun x  -> Format.asprintf "%a" pp_vhdl_port_t x
4920

    
4921
let rec (vhdl_port_t_to_yojson : vhdl_port_t -> Yojson.Safe.json) =
4922
  ((let open! Ppx_deriving_yojson_runtime in
4923
      fun x  ->
4924
        let fields = []  in
4925
        let fields =
4926
          if x.expr = IsNull
4927
          then fields
4928
          else ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) x.expr)) ::
4929
            fields
4930
           in
4931
        let fields =
4932
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
4933
          :: fields  in
4934
        let fields =
4935
          if x.mode = InPort
4936
          then fields
4937
          else ("mode", (((fun x  -> vhdl_port_mode_t_to_yojson x)) x.mode))
4938
            :: fields
4939
           in
4940
        let fields =
4941
          if x.names = []
4942
          then fields
4943
          else
4944
            ("names",
4945
              (((fun x  ->
4946
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
4947
                 x.names))
4948
            :: fields
4949
           in
4950
        `Assoc fields)
4951
  [@ocaml.warning "-A"])
4952

    
4953
and (vhdl_port_t_of_yojson :
4954
      Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
4955
  =
4956
  ((let open! Ppx_deriving_yojson_runtime in
4957
      function
4958
      | `Assoc xs ->
4959
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
4960
            match xs with
4961
            | ("names",x)::xs ->
4962
                loop xs
4963
                  (((function
4964
                     | `List xs ->
4965
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4966
                     | _ -> Result.Error "Vhdl_ast.vhdl_port_t.names") x),
4967
                    arg1, arg2, arg3)
4968
            | ("mode",x)::xs ->
4969
                loop xs
4970
                  (arg0, ((fun x  -> vhdl_port_mode_t_of_yojson x) x), arg2,
4971
                    arg3)
4972
            | ("typ",x)::xs ->
4973
                loop xs
4974
                  (arg0, arg1,
4975
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
4976
                    arg3)
4977
            | ("expr",x)::xs ->
4978
                loop xs
4979
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4980
            | [] ->
4981
                arg3 >>=
4982
                  ((fun arg3  ->
4983
                      arg2 >>=
4984
                        (fun arg2  ->
4985
                           arg1 >>=
4986
                             (fun arg1  ->
4987
                                arg0 >>=
4988
                                  (fun arg0  ->
4989
                                     Result.Ok
4990
                                       {
4991
                                         names = arg0;
4992
                                         mode = arg1;
4993
                                         typ = arg2;
4994
                                         expr = arg3
4995
                                       })))))
4996
            | _::xs -> loop xs _state  in
4997
          loop xs
4998
            ((Result.Ok []), (Result.Ok InPort),
4999
              (Result.Error "Vhdl_ast.vhdl_port_t.typ"), (Result.Ok IsNull))
5000
      | _ -> Result.Error "Vhdl_ast.vhdl_port_t")
5001
  [@ocaml.warning "-A"])
5002

    
5003
type vhdl_entity_t =
5004
  {
5005
  name: vhdl_name_t [@default NoName];
5006
  generics: vhdl_port_t list [@default []];
5007
  ports: vhdl_port_t list [@default []];
5008
  declaration: vhdl_declaration_t list
5009
    [@key "ENTITY_DECLARATIVE_PART"][@default []];
5010
  stmts: vhdl_concurrent_stmt_t list
5011
    [@key "ENTITY_STATEMENT_PART"][@default []]}
5012

    
5013
(* Adapted *)
5014
let rec pp_vhdl_entity_t :
5015
  Format.formatter -> vhdl_entity_t -> Ppx_deriving_runtime.unit =
5016
  let __4 () = pp_vhdl_concurrent_stmt_t
5017
  
5018
  and __3 () = pp_vhdl_declaration_t
5019
  
5020
  and __2 () = pp_vhdl_port_t
5021
  
5022
  and __1 () = pp_vhdl_port_t
5023
  
5024
  and __0 () = pp_vhdl_name_t
5025
   in
5026
  ((let open! Ppx_deriving_runtime in
5027
      fun fmt  ->
5028
        fun x  ->
5029
          (((((
5030
               ((__0 ()) fmt) x.name;
5031
               Format.fprintf fmt " is@ ");
5032
              Format.fprintf fmt "@[<v>";
5033
              ((fun x  ->
5034
                  ignore
5035
                    (List.fold_left
5036
                       (fun sep  ->
5037
                          fun x  ->
5038
                            if sep then Format.fprintf fmt ";@;";
5039
                            ((__1 ()) fmt) x;
5040
                            true) false x))) x.generics;
5041
              Format.fprintf fmt "@]");
5042
             Format.fprintf fmt "port (@[<v>";
5043
             ((fun x  ->
5044
                 ignore
5045
                   (List.fold_left
5046
                      (fun sep  ->
5047
                         fun x  ->
5048
                           if sep then Format.fprintf fmt ";@;";
5049
                           ((__2 ()) fmt) x;
5050
                           true) false x))) x.ports;
5051
             Format.fprintf fmt "@]);");
5052
            Format.fprintf fmt "@[<v>";
5053
            ((fun x  ->
5054
                Format.fprintf fmt "@[";
5055
                ignore
5056
                  (List.fold_left
5057
                     (fun sep  ->
5058
                        fun x  ->
5059
                          if sep then Format.fprintf fmt ";@ ";
5060
                          ((__3 ()) fmt) x;
5061
                          true) false x);
5062
                Format.fprintf fmt "@]")) x.declaration;
5063
            Format.fprintf fmt "@]");
5064
           Format.fprintf fmt "@[<v>";
5065
           ((fun x  ->
5066
               Format.fprintf fmt "@[";
5067
               ignore
5068
                 (List.fold_left
5069
                    (fun sep  ->
5070
                       fun x  ->
5071
                         if sep then Format.fprintf fmt ";@ ";
5072
                         ((__4 ()) fmt) x;
5073
                         true) false x);
5074
               Format.fprintf fmt "@]")) x.stmts;
5075
           Format.fprintf fmt "@]");
5076
          Format.fprintf fmt "@]")
5077
    [@ocaml.warning "-A"])
5078

    
5079
and show_vhdl_entity_t : vhdl_entity_t -> Ppx_deriving_runtime.string =
5080
  fun x  -> Format.asprintf "%a" pp_vhdl_entity_t x
5081

    
5082
let rec (vhdl_entity_t_to_yojson : vhdl_entity_t -> Yojson.Safe.json) =
5083
  ((let open! Ppx_deriving_yojson_runtime in
5084
      fun x  ->
5085
        let fields = []  in
5086
        let fields =
5087
          if x.stmts = []
5088
          then fields
5089
          else
5090
            ("ENTITY_STATEMENT_PART",
5091
              (((fun x  ->
5092
                   `List
5093
                     (List.map (fun x  -> vhdl_concurrent_stmt_t_to_yojson x)
5094
                        x))) x.stmts))
5095
            :: fields
5096
           in
5097
        let fields =
5098
          if x.declaration = []
5099
          then fields
5100
          else
5101
            ("ENTITY_DECLARATIVE_PART",
5102
              (((fun x  ->
5103
                   `List
5104
                     (List.map (fun x  -> vhdl_declaration_t_to_yojson x) x)))
5105
                 x.declaration))
5106
            :: fields
5107
           in
5108
        let fields =
5109
          if x.ports = []
5110
          then fields
5111
          else
5112
            ("ports",
5113
              (((fun x  ->
5114
                   `List (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
5115
                 x.ports))
5116
            :: fields
5117
           in
5118
        let fields =
5119
          if x.generics = []
5120
          then fields
5121
          else
5122
            ("generics",
5123
              (((fun x  ->
5124
                   `List (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
5125
                 x.generics))
5126
            :: fields
5127
           in
5128
        let fields =
5129
          if x.name = NoName
5130
          then fields
5131
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
5132
            fields
5133
           in
5134
        `Assoc fields)
5135
  [@ocaml.warning "-A"])
5136

    
5137
and (vhdl_entity_t_of_yojson :
5138
      Yojson.Safe.json -> vhdl_entity_t Ppx_deriving_yojson_runtime.error_or)
5139
  =
5140
  ((let open! Ppx_deriving_yojson_runtime in
5141
      function
5142
      | `Assoc xs ->
5143
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
5144
            match xs with
5145
            | ("name",x)::xs ->
5146
                loop xs
5147
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3,
5148
                    arg4)
5149
            | ("generics",x)::xs ->
5150
                loop xs
5151
                  (arg0,
5152
                    ((function
5153
                      | `List xs ->
5154
                          map_bind (fun x  -> vhdl_port_t_of_yojson x) [] xs
5155
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.generics")
5156
                       x), arg2, arg3, arg4)
5157
            | ("ports",x)::xs ->
5158
                loop xs
5159
                  (arg0, arg1,
5160
                    ((function
5161
                      | `List xs ->
5162
                          map_bind (fun x  -> vhdl_port_t_of_yojson x) [] xs
5163
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.ports") x),
5164
                    arg3, arg4)
5165
            | ("ENTITY_DECLARATIVE_PART",x)::xs ->
5166
                loop xs
5167
                  (arg0, arg1, arg2,
5168
                    ((function
5169
                      | `List xs ->
5170
                          map_bind (fun x  -> vhdl_declaration_t_of_yojson x)
5171
                            [] xs
5172
                      | _ ->
5173
                          Result.Error "Vhdl_ast.vhdl_entity_t.declaration")
5174
                       x), arg4)
5175
            | ("ENTITY_STATEMENT_PART",x)::xs ->
5176
                loop xs
5177
                  (arg0, arg1, arg2, arg3,
5178
                    ((function
5179
                      | `List xs ->
5180
                          map_bind
5181
                            (fun x  -> vhdl_concurrent_stmt_t_of_yojson x) []
5182
                            xs
5183
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.stmts") x))
5184
            | [] ->
5185
                arg4 >>=
5186
                  ((fun arg4  ->
5187
                      arg3 >>=
5188
                        (fun arg3  ->
5189
                           arg2 >>=
5190
                             (fun arg2  ->
5191
                                arg1 >>=
5192
                                  (fun arg1  ->
5193
                                     arg0 >>=
5194
                                       (fun arg0  ->
5195
                                          Result.Ok
5196
                                            {
5197
                                              name = arg0;
5198
                                              generics = arg1;
5199
                                              ports = arg2;
5200
                                              declaration = arg3;
5201
                                              stmts = arg4
5202
                                            }))))))
5203
            | _::xs -> loop xs _state  in
5204
          loop xs
5205
            ((Result.Ok NoName), (Result.Ok []), (Result.Ok []),
5206
              (Result.Ok []), (Result.Ok []))
5207
      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t")
5208
  [@ocaml.warning "-A"])
5209

    
5210
type vhdl_package_t =
5211
  {
5212
  name: vhdl_name_t [@default NoName];
5213
  shared_defs: vhdl_definition_t list [@default []]}
5214

    
5215
(* Adapted *)
5216
let rec pp_vhdl_package_t :
5217
  Format.formatter -> vhdl_package_t -> Ppx_deriving_runtime.unit =
5218
  let __1 () = pp_vhdl_definition_t
5219
  
5220
  and __0 () = pp_vhdl_name_t
5221
   in
5222
  ((let open! Ppx_deriving_runtime in
5223
      fun fmt  ->
5224
        fun x  ->
5225
          ((__0 ()) fmt) x.name;
5226
          Format.fprintf fmt " is@;";
5227
          ((fun x  ->
5228
             ignore
5229
               (List.fold_left
5230
                  (fun sep  ->
5231
                     fun x  ->
5232
                       if sep then Format.fprintf fmt "";
5233
                       ((__1 ()) fmt) x;
5234
                       Format.fprintf fmt ";";
5235
                       true) false x))) x.shared_defs;)
5236
    [@ocaml.warning "-A"])
5237

    
5238
and show_vhdl_package_t : vhdl_package_t -> Ppx_deriving_runtime.string =
5239
  fun x  -> Format.asprintf "%a" pp_vhdl_package_t x
5240

    
5241
let rec (vhdl_package_t_to_yojson : vhdl_package_t -> Yojson.Safe.json) =
5242
  ((let open! Ppx_deriving_yojson_runtime in
5243
      fun x  ->
5244
        let fields = []  in
5245
        let fields =
5246
          if x.shared_defs = []
5247
          then fields
5248
          else
5249
            ("shared_defs",
5250
              (((fun x  ->
5251
                   `List
5252
                     (List.map (fun x  -> vhdl_definition_t_to_yojson x) x)))
5253
                 x.shared_defs))
5254
            :: fields
5255
           in
5256
        let fields =
5257
          if x.name = NoName
5258
          then fields
5259
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
5260
            fields
5261
           in
5262
        `Assoc fields)
5263
  [@ocaml.warning "-A"])
5264

    
5265
and (vhdl_package_t_of_yojson :
5266
      Yojson.Safe.json -> vhdl_package_t Ppx_deriving_yojson_runtime.error_or)
5267
  =
5268
  ((let open! Ppx_deriving_yojson_runtime in
5269
      function
5270
      | `Assoc xs ->
5271
          let rec loop xs ((arg0,arg1) as _state) =
5272
            match xs with
5273
            | ("name",x)::xs ->
5274
                loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
5275
            | ("shared_defs",x)::xs ->
5276
                loop xs
5277
                  (arg0,
5278
                    ((function
5279
                      | `List xs ->
5280
                          map_bind (fun x  -> vhdl_definition_t_of_yojson x)
5281
                            [] xs
5282
                      | _ ->
5283
                          Result.Error "Vhdl_ast.vhdl_package_t.shared_defs")
5284
                       x))
5285
            | [] ->
5286
                arg1 >>=
5287
                  ((fun arg1  ->
5288
                      arg0 >>=
5289
                        (fun arg0  ->
5290
                           Result.Ok { name = arg0; shared_defs = arg1 })))
5291
            | _::xs -> loop xs _state  in
5292
          loop xs ((Result.Ok NoName), (Result.Ok []))
5293
      | _ -> Result.Error "Vhdl_ast.vhdl_package_t")
5294
  [@ocaml.warning "-A"])
5295

    
5296
type vhdl_load_t =
5297
  | Library of vhdl_name_t list [@name "LIBRARY_CLAUSE"][@default []]
5298
  | Use of vhdl_name_t list [@name "USE_CLAUSE"][@default []]
5299

    
5300
(* Adapted. TODO: check indentation *)
5301
let rec pp_vhdl_load_t :
5302
  Format.formatter -> vhdl_load_t -> Ppx_deriving_runtime.unit =
5303
  let __1 () = pp_vhdl_name_t
5304
  
5305
  and __0 () = pp_vhdl_name_t
5306
   in
5307
  ((let open! Ppx_deriving_runtime in
5308
      fun fmt  ->
5309
        function
5310
        | Library a0 ->
5311
            (Format.fprintf fmt "library ";
5312
             ((fun x  ->
5313
                 ignore
5314
                   (List.fold_left
5315
                      (fun sep  ->
5316
                         fun x  ->
5317
                           if sep then Format.fprintf fmt ".";
5318
                           ((__0 ()) fmt) x;
5319
                           true) false x))) a0;
5320
             Format.fprintf fmt ":")
5321
        | Use a0 ->
5322
            (Format.fprintf fmt "use ";
5323
             ((fun x  ->
5324
                 ignore
5325
                   (List.fold_left
5326
                      (fun sep  ->
5327
                         fun x  ->
5328
                           if sep then Format.fprintf fmt ".";
5329
                           ((__1 ()) fmt) x;
5330
                           true) false x))) a0;
5331
             Format.fprintf fmt ";"))
5332
    [@ocaml.warning "-A"])
5333

    
5334
and show_vhdl_load_t : vhdl_load_t -> Ppx_deriving_runtime.string =
5335
  fun x  -> Format.asprintf "%a" pp_vhdl_load_t x
5336

    
5337
let rec (vhdl_load_t_to_yojson : vhdl_load_t -> Yojson.Safe.json) =
5338
  ((let open! Ppx_deriving_yojson_runtime in
5339
      function
5340
      | Library arg0 ->
5341
          `List
5342
            [`String "LIBRARY_CLAUSE";
5343
            ((fun x  ->
5344
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
5345
      | Use arg0 ->
5346
          `List
5347
            [`String "USE_CLAUSE";
5348
            ((fun x  ->
5349
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0])
5350
  [@ocaml.warning "-A"])
5351

    
5352
and (vhdl_load_t_of_yojson :
5353
      Yojson.Safe.json -> vhdl_load_t Ppx_deriving_yojson_runtime.error_or)
5354
  =
5355
  ((let open! Ppx_deriving_yojson_runtime in
5356
      function
5357
      | `List ((`String "LIBRARY_CLAUSE")::arg0::[]) ->
5358
          ((function
5359
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5360
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
5361
            ((fun arg0  -> Result.Ok (Library arg0)))
5362
      | `List ((`String "USE_CLAUSE")::arg0::[]) ->
5363
          ((function
5364
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5365
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
5366
            ((fun arg0  -> Result.Ok (Use arg0)))
5367
      | _ -> Result.Error "Vhdl_ast.vhdl_load_t")
5368
  [@ocaml.warning "-A"])
5369

    
5370
type vhdl_architecture_t =
5371
  {
5372
  name: vhdl_name_t [@default NoName];
5373
  entity: vhdl_name_t [@default NoName];
5374
  declarations: vhdl_declaration_t list
5375
    [@key "ARCHITECTURE_DECLARATIVE_PART"][@default []];
5376
  body: vhdl_concurrent_stmt_t list
5377
    [@key "ARCHITECTURE_STATEMENT_PART"][@default []]}
5378

    
5379
(* Adapted *)
5380
let rec pp_vhdl_architecture_t :
5381
  Format.formatter -> vhdl_architecture_t -> Ppx_deriving_runtime.unit =
5382
  let __3 () = pp_vhdl_concurrent_stmt_t
5383
  
5384
  and __2 () = pp_vhdl_declaration_t
5385
  
5386
  and __1 () = pp_vhdl_name_t
5387
  
5388
  and __0 () = pp_vhdl_name_t
5389
   in
5390
  ((let open! Ppx_deriving_runtime in
5391
      fun fmt  ->
5392
        fun x  ->
5393
          ((__0 ()) fmt) x.name;
5394
          Format.fprintf fmt " of ";
5395
          ((__1 ()) fmt) x.entity;
5396
          Format.fprintf fmt " is@;";
5397
          ((fun x  ->
5398
             ignore
5399
               (List.fold_left
5400
                  (fun sep  ->
5401
                     fun x  ->
5402
                       if sep then Format.fprintf fmt "@;";
5403
                       ((__2 ()) fmt) x;
5404
                       Format.fprintf fmt ";";
5405
                       true) false x))) x.declarations;
5406
          Format.fprintf fmt "@;";
5407
          (match x.body with
5408
            | [] -> Format.fprintf fmt "";
5409
            | _ -> Format.fprintf fmt "@[<v 2>begin@;";
5410
          ((fun x  ->
5411
               ignore
5412
                 (List.fold_left
5413
                    (fun sep  ->
5414
                       fun x  ->
5415
                         if sep then Format.fprintf fmt "";
5416
                         ((__3 ()) fmt) x;
5417
                         true) false x))) x.body;
5418
          Format.fprintf fmt "@]@;end;"))
5419
    [@ocaml.warning "-A"])
5420

    
5421
and show_vhdl_architecture_t :
5422
  vhdl_architecture_t -> Ppx_deriving_runtime.string =
5423
  fun x  -> Format.asprintf "%a" pp_vhdl_architecture_t x
5424

    
5425
let rec (vhdl_architecture_t_to_yojson :
5426
          vhdl_architecture_t -> Yojson.Safe.json)
5427
  =
5428
  ((let open! Ppx_deriving_yojson_runtime in
5429
      fun x  ->
5430
        let fields = []  in
5431
        let fields =
5432
          if x.body = []
5433
          then fields
5434
          else
5435
            ("ARCHITECTURE_STATEMENT_PART",
5436
              (((fun x  ->
5437
                   `List
5438
                     (List.map (fun x  -> vhdl_concurrent_stmt_t_to_yojson x)
5439
                        x))) x.body))
5440
            :: fields
5441
           in
5442
        let fields =
5443
          if x.declarations = []
5444
          then fields
5445
          else
5446
            ("ARCHITECTURE_DECLARATIVE_PART",
5447
              (((fun x  ->
5448
                   `List
5449
                     (List.map (fun x  -> vhdl_declaration_t_to_yojson x) x)))
5450
                 x.declarations))
5451
            :: fields
5452
           in
5453
        let fields =
5454
          if x.entity = NoName
5455
          then fields
5456
          else ("entity", (((fun x  -> vhdl_name_t_to_yojson x)) x.entity))
5457
            :: fields
5458
           in
5459
        let fields =
5460
          if x.name = NoName
5461
          then fields
5462
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
5463
            fields
5464
           in
5465
        `Assoc fields)
5466
  [@ocaml.warning "-A"])
5467

    
5468
and (vhdl_architecture_t_of_yojson :
5469
      Yojson.Safe.json ->
5470
        vhdl_architecture_t Ppx_deriving_yojson_runtime.error_or)
5471
  =
5472
  ((let open! Ppx_deriving_yojson_runtime in
5473
      function
5474
      | `Assoc xs ->
5475
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
5476
            match xs with
5477
            | ("name",x)::xs ->
5478
                loop xs
5479
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3)
5480
            | ("entity",x)::xs ->
5481
                loop xs
5482
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3)
5483
            | ("ARCHITECTURE_DECLARATIVE_PART",x)::xs ->
5484
                loop xs
5485
                  (arg0, arg1,
5486
                    ((function
5487
                      | `List xs ->
5488
                          map_bind (fun x  -> vhdl_declaration_t_of_yojson x)
5489
                            [] xs