Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / backends / VHDL / vhdl_ast_deriving.ml @ 32614c2d

History | View | Annotate | Download (243 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
let rec (pp_vhdl_cst_val_t :
18
          Format.formatter -> vhdl_cst_val_t -> Ppx_deriving_runtime.unit)
19
  =
20
  ((let open! Ppx_deriving_runtime in
21
      fun fmt  ->
22
        function
23
        | CstInt a0 ->
24
             (Format.fprintf fmt "%d") a0;
25
        | CstStdLogic a0 ->
26
             (Format.fprintf fmt "%S") a0;
27
        | CstLiteral a0 ->
28
             (Format.fprintf fmt "%s") a0;)
29
  [@ocaml.warning "-A"])
30

    
31
and show_vhdl_cst_val_t : vhdl_cst_val_t -> Ppx_deriving_runtime.string =
32
  fun x  -> Format.asprintf "%a" pp_vhdl_cst_val_t x
33

    
34
let rec (vhdl_cst_val_t_to_yojson : vhdl_cst_val_t -> Yojson.Safe.json) =
35
  ((let open! Ppx_deriving_yojson_runtime in
36
      function
37
      | CstInt arg0 ->
38
          `List
39
            [`String "CstInt";
40
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0]
41
      | CstStdLogic arg0 ->
42
          `List
43
            [`String "CstStdLogic";
44
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
45
      | CstLiteral arg0 ->
46
          `List
47
            [`String "CST_LITERAL";
48
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
49
  [@ocaml.warning "-A"])
50

    
51
and (vhdl_cst_val_t_of_yojson :
52
      Yojson.Safe.json -> vhdl_cst_val_t Ppx_deriving_yojson_runtime.error_or)
53
  =
54
  ((let open! Ppx_deriving_yojson_runtime in
55
      function
56
      | `List ((`String "CstInt")::arg0::[]) ->
57
          ((function
58
            | `Int x -> Result.Ok x
59
            | _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>=
60
            ((fun arg0  -> Result.Ok (CstInt arg0)))
61
      | `List ((`String "CstStdLogic")::arg0::[]) ->
62
          ((function
63
            | `String x -> Result.Ok x
64
            | _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>=
65
            ((fun arg0  -> Result.Ok (CstStdLogic arg0)))
66
      | `List ((`String "CST_LITERAL")::arg0::[]) ->
67
          ((function
68
            | `String x -> Result.Ok x
69
            | _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t") arg0) >>=
70
            ((fun arg0  -> Result.Ok (CstLiteral arg0)))
71
      | _ -> Result.Error "Vhdl_ast.vhdl_cst_val_t")
72
  [@ocaml.warning "-A"])
73

    
74
type vhdl_type_t =
75
  | Base of string 
76
  | Range of string option * int * int 
77
  | Bit_vector of int * int 
78
  | Array of
79
  {
80
  indexes: vhdl_name_t list [@default []];
81
  const: vhdl_constraint_t option [@default None];
82
  definition: vhdl_subtype_indication_t } [@name "ARRAY_TYPE_DEFINITION"]
83
  | Record of vhdl_element_declaration_t list
84
  [@name "RECORD_TYPE_DEFINITION"]
85
  | Enumerated of vhdl_name_t list [@name "ENUMERATION_TYPE_DEFINITION"]
86
  | Void 
87
and vhdl_element_declaration_t =
88
  {
89
  names: vhdl_name_t list ;
90
  definition: vhdl_subtype_indication_t }
91
and vhdl_subtype_indication_t =
92
  {
93
  name: vhdl_name_t [@default NoName];
94
  functionName: vhdl_name_t [@default NoName];
95
  const: vhdl_constraint_t [@default NoConstraint]}
96
and vhdl_discrete_range_t =
97
  | SubDiscreteRange of vhdl_subtype_indication_t
98
  [@name "SUB_DISCRETE_RANGE"]
99
  | NamedRange of vhdl_name_t [@name "NAMED_RANGE"]
100
  | DirectedRange of
101
  {
102
  direction: string ;
103
  from: vhdl_expr_t ;
104
  _to: vhdl_expr_t } [@name "RANGE_WITH_DIRECTION"]
105
and vhdl_constraint_t =
106
  | RefConstraint of {
107
  ref_name: vhdl_name_t } 
108
  | RangeConstraint of {
109
  range: vhdl_discrete_range_t } [@name "RANGE_CONSTRAINT"]
110
  | IndexConstraint of {
111
  ranges: vhdl_discrete_range_t list } [@name "INDEX_CONSTRAINT"]
112
  | ArrayConstraint of
113
  {
114
  ranges: vhdl_discrete_range_t list ;
115
  sub: vhdl_constraint_t } [@name "ARRAY_CONSTRAINT"]
116
  | RecordConstraint 
117
  | NoConstraint 
118
and vhdl_definition_t =
119
  | Type of {
120
  name: vhdl_name_t ;
121
  definition: vhdl_type_t } [@name "TYPE_DECLARATION"]
122
  | Subtype of {
123
  name: vhdl_name_t ;
124
  typ: vhdl_subtype_indication_t } [@name "SUBTYPE_DECLARATION"]
125
and vhdl_expr_t =
126
  | Call of vhdl_name_t [@name "CALL"]
127
  | Cst of
128
  {
129
  value: vhdl_cst_val_t ;
130
  unit_name: vhdl_name_t option [@default None]} [@name "CONSTANT_VALUE"]
131
  | Op of {
132
  id: string [@default ""];
133
  args: vhdl_expr_t list [@default []]} [@name "EXPRESSION"]
134
  | IsNull [@name "IsNull"]
135
  | Time of {
136
  value: int ;
137
  phy_unit: string [@default ""]} 
138
  | Sig of {
139
  name: vhdl_name_t ;
140
  att: vhdl_signal_attributes_t option } 
141
  | SuffixMod of {
142
  expr: vhdl_expr_t ;
143
  selection: vhdl_suffix_selection_t } 
144
  | Aggregate of {
145
  elems: vhdl_element_assoc_t list } [@name "AGGREGATE"]
146
  | Others [@name "OTHERS"]
147
and vhdl_name_t =
148
  | Simple of string [@name "SIMPLE_NAME"]
149
  | Identifier of string [@name "IDENTIFIER"]
150
  | Selected of vhdl_name_t list [@name "SELECTED_NAME"]
151
  | Index of {
152
  id: vhdl_name_t ;
153
  exprs: vhdl_expr_t list } [@name "INDEXED_NAME"]
154
  | Slice of {
155
  id: vhdl_name_t ;
156
  range: vhdl_discrete_range_t } [@name "SLICE_NAME"]
157
  | Attribute of
158
  {
159
  id: vhdl_name_t ;
160
  designator: vhdl_name_t ;
161
  expr: vhdl_expr_t [@default IsNull]} [@name "ATTRIBUTE_NAME"]
162
  | Function of {
163
  id: vhdl_name_t ;
164
  assoc_list: vhdl_assoc_element_t list } [@name "FUNCTION_CALL"]
165
  | NoName 
166
and vhdl_assoc_element_t =
167
  {
168
  formal_name: vhdl_name_t option [@default None];
169
  formal_arg: vhdl_name_t option [@default None];
170
  actual_name: vhdl_name_t option [@default None];
171
  actual_designator: vhdl_name_t option [@default None];
172
  actual_expr: vhdl_expr_t option [@default None]}
173
and vhdl_element_assoc_t = {
174
  choices: vhdl_expr_t list [@default []];
175
  expr: vhdl_expr_t }
176
and vhdl_array_attributes_t =
177
  | AAttInt of {
178
  id: string ;
179
  arg: int } 
180
  | AAttAscending 
181
and vhdl_signal_attributes_t =
182
  | SigAtt of string 
183
and vhdl_string_attributes_t =
184
  | StringAtt of string 
185
and vhdl_suffix_selection_t =
186
  | Idx of int 
187
  | SuffixRange of int * int
188

    
189
let rec pp_vhdl_type_t :
190
  Format.formatter -> vhdl_type_t -> Ppx_deriving_runtime.unit =
191
  let __4 () = pp_vhdl_name_t
192
  
193
  and __3 () = pp_vhdl_element_declaration_t
194
  
195
  and __2 () = pp_vhdl_subtype_indication_t
196
  
197
  and __1 () = pp_vhdl_constraint_t
198
  
199
  and __0 () = pp_vhdl_name_t
200
in
201
  ((let open! Ppx_deriving_runtime in
202
      fun fmt  ->
203
        function
204
        | Base a0 ->
205
             (Format.fprintf fmt "%s") a0;
206
        | Range (a0,a1,a2) ->
207
             ((
208
               (Format.fprintf fmt "%d") a1);
209
               ((function
210
                 | None  -> Format.pp_print_string fmt ""
211
                 | Some x ->
212
                      (Format.fprintf fmt "%s") x;
213
                      )) a0;
214
              (Format.fprintf fmt "%d") a2);
215
        | Bit_vector (a0,a1) ->
216
             (Format.fprintf fmt "array (%d,%d) of bit") a0 a1;
217
        | Array
218
            { indexes = aindexes; const = aconst; definition = adefinition }
219
            ->
220
            Format.fprintf fmt "array";
221
            (match aindexes with
222
            | [] -> Format.fprintf fmt "";
223
            | _ ->
224
              ((fun x  ->
225
                ignore
226
                (List.fold_left
227
                  (fun sep  ->
228
                    fun x  ->
229
                      if sep then Format.fprintf fmt ",@ ";
230
                      ((__0 ()) fmt) x;
231
                      true) false x)) aindexes));
232
            (function
233
              | None  -> Format.pp_print_string fmt ""
234
              | Some x ->
235
                ((__1 ()) fmt) x) aconst;
236
            Format.fprintf fmt " of ";
237
            ((__2 ()) fmt) adefinition;
238
        | Record a0 ->
239
            Format.fprintf fmt "@[<v 2>record@;";
240
            (fun x  ->
241
              ignore
242
                (List.fold_left
243
                  (fun sep  ->
244
                    fun x  ->
245
                      if sep then Format.fprintf fmt ";@;";
246
                        ((__3 ()) fmt) x;
247
                        true) false x);
248
              Format.fprintf fmt "@]@;end record") a0;
249
        | Enumerated a0 ->
250
            (Format.fprintf fmt "(";
251
            ((fun x  ->
252
              ignore
253
              (List.fold_left
254
                (fun sep  ->
255
                  fun x  ->
256
                    if sep then Format.fprintf fmt ",@ ";
257
                      ((__4 ()) fmt) x;
258
                    true) false x))) a0;
259
             Format.fprintf fmt ")");
260
        | Void  -> Format.pp_print_string fmt "")
261
    [@ocaml.warning "-A"])
262

    
263
and show_vhdl_type_t : vhdl_type_t -> Ppx_deriving_runtime.string =
264
  fun x  -> Format.asprintf "%a" pp_vhdl_type_t x
265

    
266
and pp_vhdl_element_declaration_t :
267
  Format.formatter -> vhdl_element_declaration_t -> Ppx_deriving_runtime.unit
268
  =
269
  let __1 () = pp_vhdl_subtype_indication_t
270
  
271
  and __0 () = pp_vhdl_name_t
272
   in
273
  ((let open! Ppx_deriving_runtime in
274
      fun fmt  ->
275
        fun x  ->
276
            (fun x  ->
277
                ignore
278
                  (List.fold_left
279
                     (fun sep  ->
280
                        fun x  ->
281
                          if sep then Format.fprintf fmt ",@ ";
282
                          ((__0 ()) fmt) x;
283
                          true) false x)) x.names;
284
           Format.fprintf fmt ":@ ";
285
           ((__1 ()) fmt) x.definition)
286
    [@ocaml.warning "-A"])
287

    
288
and show_vhdl_element_declaration_t :
289
  vhdl_element_declaration_t -> Ppx_deriving_runtime.string =
290
  fun x  -> Format.asprintf "%a" pp_vhdl_element_declaration_t x
291

    
292
and pp_vhdl_subtype_indication_t :
293
  Format.formatter -> vhdl_subtype_indication_t -> Ppx_deriving_runtime.unit
294
  =
295
  let __2 () = pp_vhdl_constraint_t
296
  
297
  and __1 () = pp_vhdl_name_t
298
  
299
  and __0 () = pp_vhdl_name_t
300
   in
301
  ((let open! Ppx_deriving_runtime in
302
      fun fmt  ->
303
        fun x  ->
304
          ((__0 ()) fmt) x.name;
305
          ((__1 ()) fmt) x.functionName;
306
          (match x.const with
307
            | NoConstraint -> Format.fprintf fmt "";
308
            | _ -> Format.fprintf fmt " ";
309
                   ((__2 ()) fmt) x.const))
310
    [@ocaml.warning "-A"])
311

    
312
and show_vhdl_subtype_indication_t :
313
  vhdl_subtype_indication_t -> Ppx_deriving_runtime.string =
314
  fun x  -> Format.asprintf "%a" pp_vhdl_subtype_indication_t x
315

    
316
and pp_vhdl_discrete_range_t :
317
  Format.formatter -> vhdl_discrete_range_t -> Ppx_deriving_runtime.unit =
318
  let __3 () = pp_vhdl_expr_t
319
  
320
  and __2 () = pp_vhdl_expr_t
321
  
322
  and __1 () = pp_vhdl_name_t
323
  
324
  and __0 () = pp_vhdl_subtype_indication_t
325
   in
326
  ((let open! Ppx_deriving_runtime in
327
      fun fmt  ->
328
        function
329
        | SubDiscreteRange a0 ->
330
             ((__0 ()) fmt) a0;
331
        | NamedRange a0 ->
332
             ((__1 ()) fmt) a0;
333
        | DirectedRange { direction = adirection; from = afrom; _to = a_to }
334
            ->
335
               ((__2 ()) fmt) afrom;
336
               (Format.fprintf fmt " %s ") adirection;
337
               ((__3 ()) fmt) a_to;
338
    )
339
    [@ocaml.warning "-A"])
340

    
341
and show_vhdl_discrete_range_t :
342
  vhdl_discrete_range_t -> Ppx_deriving_runtime.string =
343
  fun x  -> Format.asprintf "%a" pp_vhdl_discrete_range_t x
344

    
345
(* TODO Adapt for: ArrayConstraint, RecordConstraint *)
346
and pp_vhdl_constraint_t :
347
  Format.formatter -> vhdl_constraint_t -> Ppx_deriving_runtime.unit =
348
  let __4 () = pp_vhdl_constraint_t
349
  
350
  and __3 () = pp_vhdl_discrete_range_t
351
  
352
  and __2 () = pp_vhdl_discrete_range_t
353
  
354
  and __1 () = pp_vhdl_discrete_range_t
355
  
356
  and __0 () = pp_vhdl_name_t
357
   in
358
  ((let open! Ppx_deriving_runtime in
359
      fun fmt  ->
360
        function
361
        | RefConstraint { ref_name = aref_name } ->
362
             (Format.fprintf fmt "(";
363
              ((__0 ()) fmt) aref_name;
364
              Format.fprintf fmt ")");
365
        | RangeConstraint { range = arange } ->
366
             (Format.fprintf fmt "(";
367
              ((__1 ()) fmt) arange;
368
              Format.fprintf fmt ")");
369
        | IndexConstraint { ranges = aranges } ->
370
            Format.fprintf fmt "(";
371
            ((fun x  ->
372
                ignore
373
                  (List.fold_left
374
                     (fun sep  ->
375
                        fun x  ->
376
                          if sep then Format.fprintf fmt ", ";
377
                          ((__2 ()) fmt) x;
378
                          true) false x))) aranges;
379
            Format.fprintf fmt ")";
380
        | ArrayConstraint { ranges = aranges; sub = asub } ->
381
            (Format.fprintf fmt "@[<2>ArrayConstraint {@,";
382
             ((Format.fprintf fmt "@[%s =@ " "ranges";
383
               ((fun x  ->
384
                   Format.fprintf fmt "@[<2>[";
385
                   ignore
386
                     (List.fold_left
387
                        (fun sep  ->
388
                           fun x  ->
389
                             if sep then Format.fprintf fmt ";@ ";
390
                             ((__3 ()) fmt) x;
391
                             true) false x);
392
                   Format.fprintf fmt "@,]@]")) aranges;
393
               Format.fprintf fmt "@]");
394
              Format.fprintf fmt ";@ ";
395
              Format.fprintf fmt "@[%s =@ " "sub";
396
              ((__4 ()) fmt) asub;
397
              Format.fprintf fmt "@]");
398
             Format.fprintf fmt "@]}")
399
        | RecordConstraint  -> Format.pp_print_string fmt ""
400
        | NoConstraint  -> Format.pp_print_string fmt "")
401
    [@ocaml.warning "-A"])
402

    
403
and show_vhdl_constraint_t : vhdl_constraint_t -> Ppx_deriving_runtime.string
404
  = fun x  -> Format.asprintf "%a" pp_vhdl_constraint_t x
405

    
406
and pp_vhdl_definition_t :
407
  Format.formatter -> vhdl_definition_t -> Ppx_deriving_runtime.unit =
408
  let __3 () = pp_vhdl_subtype_indication_t
409
  
410
  and __2 () = pp_vhdl_name_t
411
  
412
  and __1 () = pp_vhdl_type_t
413
  
414
  and __0 () = pp_vhdl_name_t
415
   in
416
  ((let open! Ppx_deriving_runtime in
417
      fun fmt  ->
418
        function
419
        | Type { name = aname; definition = adefinition } ->
420
            Format.fprintf fmt "type ";
421
            ((__0 ()) fmt) aname;
422
            Format.fprintf fmt " is ";
423
            ((__1 ()) fmt) adefinition;
424
        | Subtype { name = aname; typ = atyp } ->
425
            Format.fprintf fmt "subtype ";
426
            ((__2 ()) fmt) aname;
427
            Format.fprintf fmt " is ";
428
            ((__3 ()) fmt) atyp;
429
   )
430
    [@ocaml.warning "-A"])
431

    
432
and show_vhdl_definition_t : vhdl_definition_t -> Ppx_deriving_runtime.string
433
  = fun x  -> Format.asprintf "%a" pp_vhdl_definition_t x
434

    
435
(* TODO adapt for Op, Time, Sig, suffixMod, Aggregate *)
436
and pp_vhdl_expr_t :
437
  Format.formatter -> vhdl_expr_t -> Ppx_deriving_runtime.unit =
438
  let __8 () = pp_vhdl_element_assoc_t
439
  
440
  and __7 () = pp_vhdl_suffix_selection_t
441
  
442
  and __6 () = pp_vhdl_expr_t
443
  
444
  and __5 () = pp_vhdl_signal_attributes_t
445
  
446
  and __4 () = pp_vhdl_name_t
447
  
448
  and __3 () = pp_vhdl_expr_t
449
  
450
  and __2 () = pp_vhdl_name_t
451
  
452
  and __1 () = pp_vhdl_cst_val_t
453
  
454
  and __0 () = pp_vhdl_name_t
455
   in
456
  ((let open! Ppx_deriving_runtime in
457
      fun fmt  ->
458
        function
459
        | Call a0 ->
460
             ((__0 ()) fmt) a0;
461
        | Cst { value = avalue; unit_name = aunit_name } ->
462
             ((__1 ()) fmt) avalue;
463
             (function
464
                | None  -> Format.pp_print_string fmt ""
465
                | Some x ->
466
                    Format.fprintf fmt " ";
467
                    ((__2 ()) fmt) x) aunit_name;
468
        | Op { id = aid; args = aargs } ->
469
            (match aargs with
470
            | [] -> (Format.fprintf fmt "%s") aid;
471
            | hd::[] ->
472
               (Format.fprintf fmt "%s") aid;
473
               ((__3 ()) fmt) hd
474
            | hd::(hd2::[]) -> 
475
               ((__3 ()) fmt) hd;
476
               (Format.fprintf fmt " %s ") aid;
477
               ((__3 ()) fmt) hd2
478
            | _ ->
479
            (Format.fprintf fmt "@[<2>Op {@,";
480
             ((Format.fprintf fmt "@[%s =@ " "id";
481
               (Format.fprintf fmt "%S") aid;
482
               Format.fprintf fmt "@]");
483
              Format.fprintf fmt ";@ ";
484
              Format.fprintf fmt "@[%s =@ " "args";
485
              ((fun x  ->
486
                  Format.fprintf fmt "@[<2>[";
487
                  ignore
488
                    (List.fold_left
489
                       (fun sep  ->
490
                          fun x  ->
491
                            if sep then Format.fprintf fmt ";@ ";
492
                            ((__3 ()) fmt) x;
493
                            true) false x);
494
                  Format.fprintf fmt "@,]@]")) aargs;
495
              Format.fprintf fmt "@]");
496
             Format.fprintf fmt "@]}"))
497
        | IsNull  -> Format.pp_print_string fmt ""
498
        | Time { value = avalue; phy_unit = aphy_unit } ->
499
            (Format.fprintf fmt "@[<2>Time {@,";
500
             ((Format.fprintf fmt "@[%s =@ " "value";
501
               (Format.fprintf fmt "%d") avalue;
502
               Format.fprintf fmt "@]");
503
              Format.fprintf fmt ";@ ";
504
              Format.fprintf fmt "@[%s =@ " "phy_unit";
505
              (Format.fprintf fmt "%S") aphy_unit;
506
              Format.fprintf fmt "@]");
507
             Format.fprintf fmt "@]}")
508
        | Sig { name = aname; att = aatt } ->
509
            (Format.fprintf fmt "--@[<2>Sig {@,";
510
             ((Format.fprintf fmt "@[%s =@ " "name";
511
               ((__4 ()) fmt) aname;
512
               Format.fprintf fmt "@]");
513
              Format.fprintf fmt ";@ ";
514
              Format.fprintf fmt "@[%s =@ " "att";
515
              ((function
516
                | None  -> Format.pp_print_string fmt "None"
517
                | Some x ->
518
                    (Format.pp_print_string fmt "(Some ";
519
                     ((__5 ()) fmt) x;
520
                     Format.pp_print_string fmt ")"))) aatt;
521
              Format.fprintf fmt "@]");
522
             Format.fprintf fmt "@]}")
523
        | SuffixMod { expr = aexpr; selection = aselection } ->
524
            (Format.fprintf fmt "--@[<2>SuffixMod {@,";
525
             ((Format.fprintf fmt "@[%s =@ " "expr";
526
               ((__6 ()) fmt) aexpr;
527
               Format.fprintf fmt "@]");
528
              Format.fprintf fmt ";@ ";
529
              Format.fprintf fmt "@[%s =@ " "selection";
530
              ((__7 ()) fmt) aselection;
531
              Format.fprintf fmt "@]");
532
             Format.fprintf fmt "@]}")
533
        | Aggregate { elems = aelems } ->
534
            (match aelems with
535
            | [] -> Format.fprintf fmt "";
536
            | _ ->
537
              (Format.fprintf fmt "(@[";
538
              ((fun x  ->
539
                  ignore
540
                    (List.fold_left
541
                       (fun sep  ->
542
                          fun x  ->
543
                            if sep then Format.fprintf fmt ", ";
544
                            ((__8 ()) fmt) x;
545
                            true) false x))) aelems;
546
              Format.fprintf fmt ")@]");)
547
        | Others  -> Format.pp_print_string fmt "others")
548
    [@ocaml.warning "-A"])
549

    
550
and show_vhdl_expr_t : vhdl_expr_t -> Ppx_deriving_runtime.string =
551
  fun x  -> Format.asprintf "%a" pp_vhdl_expr_t x
552

    
553
and pp_vhdl_name_t :
554
  Format.formatter -> vhdl_name_t -> Ppx_deriving_runtime.unit =
555
  let __9 () = pp_vhdl_assoc_element_t
556
  
557
  and __8 () = pp_vhdl_name_t
558
  
559
  and __7 () = pp_vhdl_expr_t
560
  
561
  and __6 () = pp_vhdl_name_t
562
  
563
  and __5 () = pp_vhdl_name_t
564
  
565
  and __4 () = pp_vhdl_discrete_range_t
566
  
567
  and __3 () = pp_vhdl_name_t
568
  
569
  and __2 () = pp_vhdl_expr_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
        function
578
        | Simple a0 ->
579
             (Format.fprintf fmt "%s") a0;
580
        | Identifier a0 ->
581
             (Format.fprintf fmt "%s") a0;
582
        | Selected a0 ->
583
             ((fun x  ->
584
                 ignore
585
                   (List.fold_left
586
                      (fun sep  ->
587
                         fun x  ->
588
                           if sep then Format.fprintf fmt ".";
589
                           ((__0 ()) fmt) x;
590
                           true) false x);) a0;)
591
        | Index { id = aid; exprs = aexprs } ->
592
            ((__1 ()) fmt) aid;
593
            Format.fprintf fmt "(";
594
            (fun x  ->
595
                ignore
596
                (List.fold_left
597
                  (fun sep  ->
598
                    fun x  ->
599
                      if sep then Format.fprintf fmt ",@ ";
600
                                  ((__2 ()) fmt) x;
601
                                  true
602
                  ) false x);
603
            ) aexprs;
604
            Format.fprintf fmt ")";
605
        | Slice { id = aid; range = arange } ->
606
              ((__3 ()) fmt) aid;
607
              Format.fprintf fmt "(";
608
              ((__4 ()) fmt) arange;
609
              Format.fprintf fmt ")";
610
        | Attribute { id = aid; designator = adesignator; expr = aexpr } ->
611
              ((__5 ()) fmt) aid;
612
              Format.fprintf fmt "\'";
613
              ((__6 ()) fmt) adesignator;
614
              (match aexpr with
615
              | IsNull -> Format.fprintf fmt "";
616
              | _ ->
617
                Format.fprintf fmt "(";
618
                ((__7 ()) fmt) aexpr;
619
                Format.fprintf fmt ")")
620
        | Function { id = aid; assoc_list = aassoc_list } ->
621
            (((__8 ()) fmt) aid;
622
            Format.fprintf fmt "(";
623
            ((fun x  ->
624
              Format.fprintf fmt "@[";
625
              ignore
626
                (List.fold_left
627
                   (fun sep  ->
628
                      fun x  ->
629
                        if sep then Format.fprintf fmt ";@ ";
630
                        ((__9 ()) fmt) x;
631
                        true) false x);
632
            Format.fprintf fmt "@]")) aassoc_list;
633
            Format.fprintf fmt ")";)
634
        | NoName  -> Format.pp_print_string fmt "")
635
    [@ocaml.warning "-A"])
636

    
637
and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string =
638
  fun x  -> Format.asprintf "%a" pp_vhdl_name_t x
639

    
640
and pp_vhdl_assoc_element_t :
641
  Format.formatter -> vhdl_assoc_element_t -> Ppx_deriving_runtime.unit =
642
  let __4 () = pp_vhdl_expr_t
643
  
644
  and __3 () = pp_vhdl_name_t
645
  
646
  and __2 () = pp_vhdl_name_t
647
  
648
  and __1 () = pp_vhdl_name_t
649
  
650
  and __0 () = pp_vhdl_name_t
651
   in
652
  ((let open! Ppx_deriving_runtime in
653
      fun fmt  ->
654
        fun x  ->
655
          (match x.formal_name with
656
          | None -> Format.pp_print_string fmt ""
657
          | Some NoName -> Format.pp_print_string fmt ""
658
          | Some a -> 
659
              (((__0 ()) fmt) a;
660
              (match x.formal_arg with
661
              | None -> ()
662
              | Some b -> Format.fprintf fmt "(";
663
                          ((__1 ()) fmt) b;
664
                          Format.fprintf fmt ")");
665
              Format.fprintf fmt " => "));
666
          (match x.actual_name with
667
          | None -> Format.pp_print_string fmt ""
668
          | Some a -> 
669
              (((__2 ()) fmt) a;
670
              (match x.actual_designator with
671
              | None -> ()
672
              | Some NoName -> Format.pp_print_string fmt ""
673
              | Some b -> (Format.fprintf fmt "(";
674
                          ((__3 ()) fmt) b;
675
                          Format.fprintf fmt ")"));
676
              (match x.actual_expr with
677
              | None -> ()
678
              | Some IsNull -> Format.pp_print_string fmt ""
679
              | Some c -> (Format.fprintf fmt "(";
680
                          ((__4 ()) fmt) c;
681
                          Format.fprintf fmt ")"))));)
682
    [@ocaml.warning "-A"])
683

    
684
and show_vhdl_assoc_element_t :
685
  vhdl_assoc_element_t -> Ppx_deriving_runtime.string =
686
  fun x  -> Format.asprintf "%a" pp_vhdl_assoc_element_t x
687

    
688
and pp_vhdl_element_assoc_t :
689
  Format.formatter -> vhdl_element_assoc_t -> Ppx_deriving_runtime.unit =
690
  let __1 () = pp_vhdl_expr_t
691
  
692
  and __0 () = pp_vhdl_expr_t
693
   in
694
  ((let open! Ppx_deriving_runtime in
695
      fun fmt  ->
696
        fun x  ->
697
            (match x.choices with
698
            | [] -> Format.fprintf fmt "";
699
            | _ -> 
700
              (((fun x  ->
701
                ignore
702
                  (List.fold_left
703
                     (fun sep  ->
704
                        fun x  ->
705
                          if sep then Format.fprintf fmt "|@ ";
706
                          ((__0 ()) fmt) x;
707
                          true) false x))) x.choices;
708
              Format.fprintf fmt " => ";));
709
           ((__1 ()) fmt) x.expr)
710
    [@ocaml.warning "-A"])
711

    
712
and show_vhdl_element_assoc_t :
713
  vhdl_element_assoc_t -> Ppx_deriving_runtime.string =
714
  fun x  -> Format.asprintf "%a" pp_vhdl_element_assoc_t x
715

    
716
(* TODO *)
717
and (pp_vhdl_array_attributes_t :
718
      Format.formatter ->
719
        vhdl_array_attributes_t -> Ppx_deriving_runtime.unit)
720
  =
721
  ((let open! Ppx_deriving_runtime in
722
      fun fmt  ->
723
        function
724
        | AAttInt { id = aid; arg = aarg } ->
725
            (Format.fprintf fmt "@[<2>AAttInt {@,";
726
             ((Format.fprintf fmt "@[%s =@ " "id";
727
               (Format.fprintf fmt "%S") aid;
728
               Format.fprintf fmt "@]");
729
              Format.fprintf fmt ";@ ";
730
              Format.fprintf fmt "@[%s =@ " "arg";
731
              (Format.fprintf fmt "%d") aarg;
732
              Format.fprintf fmt "@]");
733
             Format.fprintf fmt "@]}")
734
        | AAttAscending  -> Format.pp_print_string fmt "AAttAscending")
735
  [@ocaml.warning "-A"])
736

    
737
and show_vhdl_array_attributes_t :
738
  vhdl_array_attributes_t -> Ppx_deriving_runtime.string =
739
  fun x  -> Format.asprintf "%a" pp_vhdl_array_attributes_t x
740

    
741
(* TODO *)
742
and (pp_vhdl_signal_attributes_t :
743
      Format.formatter ->
744
        vhdl_signal_attributes_t -> Ppx_deriving_runtime.unit)
745
  =
746
  ((let open! Ppx_deriving_runtime in
747
      fun fmt  ->
748
        function
749
        | SigAtt a0 ->
750
            (Format.fprintf fmt "(@[<2>SigAtt@ ";
751
             (Format.fprintf fmt "%S") a0;
752
             Format.fprintf fmt "@])"))
753
  [@ocaml.warning "-A"])
754

    
755
and show_vhdl_signal_attributes_t :
756
  vhdl_signal_attributes_t -> Ppx_deriving_runtime.string =
757
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_attributes_t x
758

    
759
(* TODO *)
760
and (pp_vhdl_string_attributes_t :
761
      Format.formatter ->
762
        vhdl_string_attributes_t -> Ppx_deriving_runtime.unit)
763
  =
764
  ((let open! Ppx_deriving_runtime in
765
      fun fmt  ->
766
        function
767
        | StringAtt a0 ->
768
            (Format.fprintf fmt "(@[<2>StringAtt@ ";
769
             (Format.fprintf fmt "%S") a0;
770
             Format.fprintf fmt "@])"))
771
  [@ocaml.warning "-A"])
772

    
773
and show_vhdl_string_attributes_t :
774
  vhdl_string_attributes_t -> Ppx_deriving_runtime.string =
775
  fun x  -> Format.asprintf "%a" pp_vhdl_string_attributes_t x
776

    
777
(* TODO *)
778
and (pp_vhdl_suffix_selection_t :
779
      Format.formatter ->
780
        vhdl_suffix_selection_t -> Ppx_deriving_runtime.unit)
781
  =
782
  ((let open! Ppx_deriving_runtime in
783
      fun fmt  ->
784
        function
785
        | Idx a0 ->
786
            (Format.fprintf fmt "(@[<2>Idx@ ";
787
             (Format.fprintf fmt "%d") a0;
788
             Format.fprintf fmt "@])")
789
        | SuffixRange (a0,a1) ->
790
            (Format.fprintf fmt "(@[<2>SuffixRange (@,";
791
             ((Format.fprintf fmt "%d") a0;
792
              Format.fprintf fmt ",@ ";
793
              (Format.fprintf fmt "%d") a1);
794
             Format.fprintf fmt "@,))@]"))
795
  [@ocaml.warning "-A"])
796

    
797
and show_vhdl_suffix_selection_t :
798
  vhdl_suffix_selection_t -> Ppx_deriving_runtime.string =
799
  fun x  -> Format.asprintf "%a" pp_vhdl_suffix_selection_t x
800

    
801
let rec (vhdl_type_t_to_yojson : vhdl_type_t -> Yojson.Safe.json) =
802
  ((let open! Ppx_deriving_yojson_runtime in
803
      function
804
      | Base arg0 ->
805
          `List
806
            [`String "Base";
807
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
808
      | Range (arg0,arg1,arg2) ->
809
          `List
810
            [`String "Range";
811
            ((function
812
              | None  -> `Null
813
              | Some x ->
814
                  ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x))
815
              arg0;
816
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1;
817
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg2]
818
      | Bit_vector (arg0,arg1) ->
819
          `List
820
            [`String "Bit_vector";
821
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
822
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1]
823
      | Array arg0 ->
824
          `List
825
            [`String "ARRAY_TYPE_DEFINITION";
826
            (let fields = []  in
827
             let fields =
828
               ("definition",
829
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x)
830
                    arg0.definition))
831
               :: fields  in
832
             let fields =
833
               if arg0.const = None
834
               then fields
835
               else
836
                 ("const",
837
                   (((function
838
                      | None  -> `Null
839
                      | Some x ->
840
                          ((fun x  -> vhdl_constraint_t_to_yojson x)) x))
841
                      arg0.const))
842
                 :: fields
843
                in
844
             let fields =
845
               if arg0.indexes = []
846
               then fields
847
               else
848
                 ("indexes",
849
                   (((fun x  ->
850
                        `List
851
                          (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
852
                      arg0.indexes))
853
                 :: fields
854
                in
855
             `Assoc fields)]
856
      | Record arg0 ->
857
          `List
858
            [`String "RECORD_TYPE_DEFINITION";
859
            ((fun x  ->
860
                `List
861
                  (List.map
862
                     (fun x  -> vhdl_element_declaration_t_to_yojson x) x)))
863
              arg0]
864
      | Enumerated arg0 ->
865
          `List
866
            [`String "ENUMERATION_TYPE_DEFINITION";
867
            ((fun x  ->
868
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
869
      | Void  -> `List [`String "Void"])
870
  [@ocaml.warning "-A"])
871

    
872
and (vhdl_type_t_of_yojson :
873
      Yojson.Safe.json -> vhdl_type_t Ppx_deriving_yojson_runtime.error_or)
874
  =
875
  ((let open! Ppx_deriving_yojson_runtime in
876
      function
877
      | `List ((`String "Base")::arg0::[]) ->
878
          ((function
879
            | `String x -> Result.Ok x
880
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
881
            ((fun arg0  -> Result.Ok (Base arg0)))
882
      | `List ((`String "Range")::arg0::arg1::arg2::[]) ->
883
          ((function
884
            | `Int x -> Result.Ok x
885
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg2) >>=
886
            ((fun arg2  ->
887
                ((function
888
                  | `Int x -> Result.Ok x
889
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
890
                  (fun arg1  ->
891
                     ((function
892
                       | `Null -> Result.Ok None
893
                       | x ->
894
                           ((function
895
                             | `String x -> Result.Ok x
896
                             | _ -> Result.Error "Vhdl_ast.vhdl_type_t") x)
897
                             >>= ((fun x  -> Result.Ok (Some x)))) arg0)
898
                       >>=
899
                       (fun arg0  -> Result.Ok (Range (arg0, arg1, arg2))))))
900
      | `List ((`String "Bit_vector")::arg0::arg1::[]) ->
901
          ((function
902
            | `Int x -> Result.Ok x
903
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
904
            ((fun arg1  ->
905
                ((function
906
                  | `Int x -> Result.Ok x
907
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
908
                  (fun arg0  -> Result.Ok (Bit_vector (arg0, arg1)))))
909
      | `List ((`String "ARRAY_TYPE_DEFINITION")::arg0::[]) ->
910
          ((function
911
            | `Assoc xs ->
912
                let rec loop xs ((arg0,arg1,arg2) as _state) =
913
                  match xs with
914
                  | ("indexes",x)::xs ->
915
                      loop xs
916
                        (((function
917
                           | `List xs ->
918
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
919
                                 [] xs
920
                           | _ -> Result.Error "Vhdl_ast.vhdl_type_t.indexes")
921
                            x), arg1, arg2)
922
                  | ("const",x)::xs ->
923
                      loop xs
924
                        (arg0,
925
                          ((function
926
                            | `Null -> Result.Ok None
927
                            | x ->
928
                                ((fun x  -> vhdl_constraint_t_of_yojson x) x)
929
                                  >>= ((fun x  -> Result.Ok (Some x)))) x),
930
                          arg2)
931
                  | ("definition",x)::xs ->
932
                      loop xs
933
                        (arg0, arg1,
934
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
935
                             x))
936
                  | [] ->
937
                      arg2 >>=
938
                        ((fun arg2  ->
939
                            arg1 >>=
940
                              (fun arg1  ->
941
                                 arg0 >>=
942
                                   (fun arg0  ->
943
                                      Result.Ok
944
                                        (Array
945
                                           {
946
                                             indexes = arg0;
947
                                             const = arg1;
948
                                             definition = arg2
949
                                           })))))
950
                  | _::xs -> loop xs _state  in
951
                loop xs
952
                  ((Result.Ok []), (Result.Ok None),
953
                    (Result.Error "Vhdl_ast.vhdl_type_t.definition"))
954
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t")) arg0
955
      | `List ((`String "RECORD_TYPE_DEFINITION")::arg0::[]) ->
956
          ((function
957
            | `List xs ->
958
                map_bind (fun x  -> vhdl_element_declaration_t_of_yojson x)
959
                  [] xs
960
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
961
            ((fun arg0  -> Result.Ok (Record arg0)))
962
      | `List ((`String "ENUMERATION_TYPE_DEFINITION")::arg0::[]) ->
963
          ((function
964
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
965
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
966
            ((fun arg0  -> Result.Ok (Enumerated arg0)))
967
      | `List ((`String "Void")::[]) -> Result.Ok Void
968
      | _ -> Result.Error "Vhdl_ast.vhdl_type_t")
969
  [@ocaml.warning "-A"])
970

    
971
and (vhdl_element_declaration_t_to_yojson :
972
      vhdl_element_declaration_t -> Yojson.Safe.json)
973
  =
974
  ((let open! Ppx_deriving_yojson_runtime in
975
      fun x  ->
976
        let fields = []  in
977
        let fields =
978
          ("definition",
979
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.definition))
980
          :: fields  in
981
        let fields =
982
          ("names",
983
            ((fun x  ->
984
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
985
               x.names))
986
          :: fields  in
987
        `Assoc fields)
988
  [@ocaml.warning "-A"])
989

    
990
and (vhdl_element_declaration_t_of_yojson :
991
      Yojson.Safe.json ->
992
        vhdl_element_declaration_t Ppx_deriving_yojson_runtime.error_or)
993
  =
994
  ((let open! Ppx_deriving_yojson_runtime in
995
      function
996
      | `Assoc xs ->
997
          let rec loop xs ((arg0,arg1) as _state) =
998
            match xs with
999
            | ("names",x)::xs ->
1000
                loop xs
1001
                  (((function
1002
                     | `List xs ->
1003
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1004
                     | _ ->
1005
                         Result.Error
1006
                           "Vhdl_ast.vhdl_element_declaration_t.names") x),
1007
                    arg1)
1008
            | ("definition",x)::xs ->
1009
                loop xs
1010
                  (arg0,
1011
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x))
1012
            | [] ->
1013
                arg1 >>=
1014
                  ((fun arg1  ->
1015
                      arg0 >>=
1016
                        (fun arg0  ->
1017
                           Result.Ok { names = arg0; definition = arg1 })))
1018
            | _::xs -> loop xs _state  in
1019
          loop xs
1020
            ((Result.Error "Vhdl_ast.vhdl_element_declaration_t.names"),
1021
              (Result.Error "Vhdl_ast.vhdl_element_declaration_t.definition"))
1022
      | _ -> Result.Error "Vhdl_ast.vhdl_element_declaration_t")
1023
  [@ocaml.warning "-A"])
1024

    
1025
and (vhdl_subtype_indication_t_to_yojson :
1026
      vhdl_subtype_indication_t -> Yojson.Safe.json)
1027
  =
1028
  ((let open! Ppx_deriving_yojson_runtime in
1029
      fun x  ->
1030
        let fields = []  in
1031
        let fields =
1032
          if x.const = NoConstraint
1033
          then fields
1034
          else
1035
            ("const", (((fun x  -> vhdl_constraint_t_to_yojson x)) x.const))
1036
            :: fields
1037
           in
1038
        let fields =
1039
          if x.functionName = NoName
1040
          then fields
1041
          else
1042
            ("functionName",
1043
              (((fun x  -> vhdl_name_t_to_yojson x)) x.functionName))
1044
            :: fields
1045
           in
1046
        let fields =
1047
          if x.name = NoName
1048
          then fields
1049
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
1050
            fields
1051
           in
1052
        `Assoc fields)
1053
  [@ocaml.warning "-A"])
1054

    
1055
and (vhdl_subtype_indication_t_of_yojson :
1056
      Yojson.Safe.json ->
1057
        vhdl_subtype_indication_t Ppx_deriving_yojson_runtime.error_or)
1058
  =
1059
  ((let open! Ppx_deriving_yojson_runtime in
1060
      function
1061
      | `Assoc xs ->
1062
          let rec loop xs ((arg0,arg1,arg2) as _state) =
1063
            match xs with
1064
            | ("name",x)::xs ->
1065
                loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
1066
            | ("functionName",x)::xs ->
1067
                loop xs (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
1068
            | ("const",x)::xs ->
1069
                loop xs
1070
                  (arg0, arg1, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
1071
            | [] ->
1072
                arg2 >>=
1073
                  ((fun arg2  ->
1074
                      arg1 >>=
1075
                        (fun arg1  ->
1076
                           arg0 >>=
1077
                             (fun arg0  ->
1078
                                Result.Ok
1079
                                  {
1080
                                    name = arg0;
1081
                                    functionName = arg1;
1082
                                    const = arg2
1083
                                  }))))
1084
            | _::xs -> loop xs _state  in
1085
          loop xs
1086
            ((Result.Ok NoName), (Result.Ok NoName),
1087
              (Result.Ok NoConstraint))
1088
      | _ -> Result.Error "Vhdl_ast.vhdl_subtype_indication_t")
1089
  [@ocaml.warning "-A"])
1090

    
1091
and (vhdl_discrete_range_t_to_yojson :
1092
      vhdl_discrete_range_t -> Yojson.Safe.json)
1093
  =
1094
  ((let open! Ppx_deriving_yojson_runtime in
1095
      function
1096
      | SubDiscreteRange arg0 ->
1097
          `List
1098
            [`String "SUB_DISCRETE_RANGE";
1099
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x)) arg0]
1100
      | NamedRange arg0 ->
1101
          `List
1102
            [`String "NAMED_RANGE";
1103
            ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
1104
      | DirectedRange arg0 ->
1105
          `List
1106
            [`String "RANGE_WITH_DIRECTION";
1107
            (let fields = []  in
1108
             let fields =
1109
               ("_to", ((fun x  -> vhdl_expr_t_to_yojson x) arg0._to)) ::
1110
               fields  in
1111
             let fields =
1112
               ("from", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.from)) ::
1113
               fields  in
1114
             let fields =
1115
               ("direction",
1116
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
1117
                    arg0.direction))
1118
               :: fields  in
1119
             `Assoc fields)])
1120
  [@ocaml.warning "-A"])
1121

    
1122
and (vhdl_discrete_range_t_of_yojson :
1123
      Yojson.Safe.json ->
1124
        vhdl_discrete_range_t Ppx_deriving_yojson_runtime.error_or)
1125
  =
1126
  ((let open! Ppx_deriving_yojson_runtime in
1127
      function
1128
      | `List ((`String "SUB_DISCRETE_RANGE")::arg0::[]) ->
1129
          ((fun x  -> vhdl_subtype_indication_t_of_yojson x) arg0) >>=
1130
            ((fun arg0  -> Result.Ok (SubDiscreteRange arg0)))
1131
      | `List ((`String "NAMED_RANGE")::arg0::[]) ->
1132
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
1133
            ((fun arg0  -> Result.Ok (NamedRange arg0)))
1134
      | `List ((`String "RANGE_WITH_DIRECTION")::arg0::[]) ->
1135
          ((function
1136
            | `Assoc xs ->
1137
                let rec loop xs ((arg0,arg1,arg2) as _state) =
1138
                  match xs with
1139
                  | ("direction",x)::xs ->
1140
                      loop xs
1141
                        (((function
1142
                           | `String x -> Result.Ok x
1143
                           | _ ->
1144
                               Result.Error
1145
                                 "Vhdl_ast.vhdl_discrete_range_t.direction")
1146
                            x), arg1, arg2)
1147
                  | ("from",x)::xs ->
1148
                      loop xs
1149
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
1150
                  | ("_to",x)::xs ->
1151
                      loop xs
1152
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1153
                  | [] ->
1154
                      arg2 >>=
1155
                        ((fun arg2  ->
1156
                            arg1 >>=
1157
                              (fun arg1  ->
1158
                                 arg0 >>=
1159
                                   (fun arg0  ->
1160
                                      Result.Ok
1161
                                        (DirectedRange
1162
                                           {
1163
                                             direction = arg0;
1164
                                             from = arg1;
1165
                                             _to = arg2
1166
                                           })))))
1167
                  | _::xs -> loop xs _state  in
1168
                loop xs
1169
                  ((Result.Error "Vhdl_ast.vhdl_discrete_range_t.direction"),
1170
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t.from"),
1171
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t._to"))
1172
            | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")) arg0
1173
      | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")
1174
  [@ocaml.warning "-A"])
1175

    
1176
and (vhdl_constraint_t_to_yojson : vhdl_constraint_t -> Yojson.Safe.json) =
1177
  ((let open! Ppx_deriving_yojson_runtime in
1178
      function
1179
      | RefConstraint arg0 ->
1180
          `List
1181
            [`String "RefConstraint";
1182
            (let fields = []  in
1183
             let fields =
1184
               ("ref_name",
1185
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.ref_name))
1186
               :: fields  in
1187
             `Assoc fields)]
1188
      | RangeConstraint arg0 ->
1189
          `List
1190
            [`String "RANGE_CONSTRAINT";
1191
            (let fields = []  in
1192
             let fields =
1193
               ("range",
1194
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
1195
               :: fields  in
1196
             `Assoc fields)]
1197
      | IndexConstraint arg0 ->
1198
          `List
1199
            [`String "INDEX_CONSTRAINT";
1200
            (let fields = []  in
1201
             let fields =
1202
               ("ranges",
1203
                 ((fun x  ->
1204
                     `List
1205
                       (List.map
1206
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1207
                    arg0.ranges))
1208
               :: fields  in
1209
             `Assoc fields)]
1210
      | ArrayConstraint arg0 ->
1211
          `List
1212
            [`String "ARRAY_CONSTRAINT";
1213
            (let fields = []  in
1214
             let fields =
1215
               ("sub", ((fun x  -> vhdl_constraint_t_to_yojson x) arg0.sub))
1216
               :: fields  in
1217
             let fields =
1218
               ("ranges",
1219
                 ((fun x  ->
1220
                     `List
1221
                       (List.map
1222
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1223
                    arg0.ranges))
1224
               :: fields  in
1225
             `Assoc fields)]
1226
      | RecordConstraint  -> `List [`String "RecordConstraint"]
1227
      | NoConstraint  -> `List [`String "NoConstraint"])
1228
  [@ocaml.warning "-A"])
1229

    
1230
and (vhdl_constraint_t_of_yojson :
1231
      Yojson.Safe.json ->
1232
        vhdl_constraint_t Ppx_deriving_yojson_runtime.error_or)
1233
  =
1234
  ((let open! Ppx_deriving_yojson_runtime in
1235
      function
1236
      | `List ((`String "RefConstraint")::arg0::[]) ->
1237
          ((function
1238
            | `Assoc xs ->
1239
                let rec loop xs (arg0 as _state) =
1240
                  match xs with
1241
                  | ("ref_name",x)::xs ->
1242
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
1243
                  | [] ->
1244
                      arg0 >>=
1245
                        ((fun arg0  ->
1246
                            Result.Ok (RefConstraint { ref_name = arg0 })))
1247
                  | _::xs -> loop xs _state  in
1248
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ref_name")
1249
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1250
      | `List ((`String "RANGE_CONSTRAINT")::arg0::[]) ->
1251
          ((function
1252
            | `Assoc xs ->
1253
                let rec loop xs (arg0 as _state) =
1254
                  match xs with
1255
                  | ("range",x)::xs ->
1256
                      loop xs
1257
                        ((fun x  -> vhdl_discrete_range_t_of_yojson x) x)
1258
                  | [] ->
1259
                      arg0 >>=
1260
                        ((fun arg0  ->
1261
                            Result.Ok (RangeConstraint { range = arg0 })))
1262
                  | _::xs -> loop xs _state  in
1263
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.range")
1264
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1265
      | `List ((`String "INDEX_CONSTRAINT")::arg0::[]) ->
1266
          ((function
1267
            | `Assoc xs ->
1268
                let rec loop xs (arg0 as _state) =
1269
                  match xs with
1270
                  | ("ranges",x)::xs ->
1271
                      loop xs
1272
                        ((function
1273
                          | `List xs ->
1274
                              map_bind
1275
                                (fun x  -> vhdl_discrete_range_t_of_yojson x)
1276
                                [] xs
1277
                          | _ ->
1278
                              Result.Error
1279
                                "Vhdl_ast.vhdl_constraint_t.ranges") x)
1280
                  | [] ->
1281
                      arg0 >>=
1282
                        ((fun arg0  ->
1283
                            Result.Ok (IndexConstraint { ranges = arg0 })))
1284
                  | _::xs -> loop xs _state  in
1285
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ranges")
1286
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1287
      | `List ((`String "ARRAY_CONSTRAINT")::arg0::[]) ->
1288
          ((function
1289
            | `Assoc xs ->
1290
                let rec loop xs ((arg0,arg1) as _state) =
1291
                  match xs with
1292
                  | ("ranges",x)::xs ->
1293
                      loop xs
1294
                        (((function
1295
                           | `List xs ->
1296
                               map_bind
1297
                                 (fun x  -> vhdl_discrete_range_t_of_yojson x)
1298
                                 [] xs
1299
                           | _ ->
1300
                               Result.Error
1301
                                 "Vhdl_ast.vhdl_constraint_t.ranges") x),
1302
                          arg1)
1303
                  | ("sub",x)::xs ->
1304
                      loop xs
1305
                        (arg0, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
1306
                  | [] ->
1307
                      arg1 >>=
1308
                        ((fun arg1  ->
1309
                            arg0 >>=
1310
                              (fun arg0  ->
1311
                                 Result.Ok
1312
                                   (ArrayConstraint
1313
                                      { ranges = arg0; sub = arg1 }))))
1314
                  | _::xs -> loop xs _state  in
1315
                loop xs
1316
                  ((Result.Error "Vhdl_ast.vhdl_constraint_t.ranges"),
1317
                    (Result.Error "Vhdl_ast.vhdl_constraint_t.sub"))
1318
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1319
      | `List ((`String "RecordConstraint")::[]) ->
1320
          Result.Ok RecordConstraint
1321
      | `List ((`String "NoConstraint")::[]) -> Result.Ok NoConstraint
1322
      | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")
1323
  [@ocaml.warning "-A"])
1324

    
1325
and (vhdl_definition_t_to_yojson : vhdl_definition_t -> Yojson.Safe.json) =
1326
  ((let open! Ppx_deriving_yojson_runtime in
1327
      function
1328
      | Type arg0 ->
1329
          `List
1330
            [`String "TYPE_DECLARATION";
1331
            (let fields = []  in
1332
             let fields =
1333
               ("definition",
1334
                 ((fun x  -> vhdl_type_t_to_yojson x) arg0.definition))
1335
               :: fields  in
1336
             let fields =
1337
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1338
               fields  in
1339
             `Assoc fields)]
1340
      | Subtype arg0 ->
1341
          `List
1342
            [`String "SUBTYPE_DECLARATION";
1343
            (let fields = []  in
1344
             let fields =
1345
               ("typ",
1346
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
1347
               :: fields  in
1348
             let fields =
1349
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1350
               fields  in
1351
             `Assoc fields)])
1352
  [@ocaml.warning "-A"])
1353

    
1354
and (vhdl_definition_t_of_yojson :
1355
      Yojson.Safe.json ->
1356
        vhdl_definition_t Ppx_deriving_yojson_runtime.error_or)
1357
  =
1358
  ((let open! Ppx_deriving_yojson_runtime in
1359
      function
1360
      | `List ((`String "TYPE_DECLARATION")::arg0::[]) ->
1361
          ((function
1362
            | `Assoc xs ->
1363
                let rec loop xs ((arg0,arg1) as _state) =
1364
                  match xs with
1365
                  | ("name",x)::xs ->
1366
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1367
                  | ("definition",x)::xs ->
1368
                      loop xs (arg0, ((fun x  -> vhdl_type_t_of_yojson x) x))
1369
                  | [] ->
1370
                      arg1 >>=
1371
                        ((fun arg1  ->
1372
                            arg0 >>=
1373
                              (fun arg0  ->
1374
                                 Result.Ok
1375
                                   (Type { name = arg0; definition = arg1 }))))
1376
                  | _::xs -> loop xs _state  in
1377
                loop xs
1378
                  ((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
1379
                    (Result.Error "Vhdl_ast.vhdl_definition_t.definition"))
1380
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
1381
      | `List ((`String "SUBTYPE_DECLARATION")::arg0::[]) ->
1382
          ((function
1383
            | `Assoc xs ->
1384
                let rec loop xs ((arg0,arg1) as _state) =
1385
                  match xs with
1386
                  | ("name",x)::xs ->
1387
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1388
                  | ("typ",x)::xs ->
1389
                      loop xs
1390
                        (arg0,
1391
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
1392
                             x))
1393
                  | [] ->
1394
                      arg1 >>=
1395
                        ((fun arg1  ->
1396
                            arg0 >>=
1397
                              (fun arg0  ->
1398
                                 Result.Ok
1399
                                   (Subtype { name = arg0; typ = arg1 }))))
1400
                  | _::xs -> loop xs _state  in
1401
                loop xs
1402
                  ((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
1403
                    (Result.Error "Vhdl_ast.vhdl_definition_t.typ"))
1404
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
1405
      | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")
1406
  [@ocaml.warning "-A"])
1407

    
1408
and (vhdl_expr_t_to_yojson : vhdl_expr_t -> Yojson.Safe.json) =
1409
  ((let open! Ppx_deriving_yojson_runtime in
1410
      function
1411
      | Call arg0 ->
1412
          `List [`String "CALL"; ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
1413
      | Cst arg0 ->
1414
          `List
1415
            [`String "CONSTANT_VALUE";
1416
            (let fields = []  in
1417
             let fields =
1418
               if arg0.unit_name = None
1419
               then fields
1420
               else
1421
                 ("unit_name",
1422
                   (((function
1423
                      | None  -> `Null
1424
                      | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1425
                      arg0.unit_name))
1426
                 :: fields
1427
                in
1428
             let fields =
1429
               ("value", ((fun x  -> vhdl_cst_val_t_to_yojson x) arg0.value))
1430
               :: fields  in
1431
             `Assoc fields)]
1432
      | Op arg0 ->
1433
          `List
1434
            [`String "EXPRESSION";
1435
            (let fields = []  in
1436
             let fields =
1437
               if arg0.args = []
1438
               then fields
1439
               else
1440
                 ("args",
1441
                   (((fun x  ->
1442
                        `List
1443
                          (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
1444
                      arg0.args))
1445
                 :: fields
1446
                in
1447
             let fields =
1448
               if arg0.id = ""
1449
               then fields
1450
               else
1451
                 ("id",
1452
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
1453
                      arg0.id))
1454
                 :: fields
1455
                in
1456
             `Assoc fields)]
1457
      | IsNull  -> `List [`String "IsNull"]
1458
      | Time arg0 ->
1459
          `List
1460
            [`String "Time";
1461
            (let fields = []  in
1462
             let fields =
1463
               if arg0.phy_unit = ""
1464
               then fields
1465
               else
1466
                 ("phy_unit",
1467
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
1468
                      arg0.phy_unit))
1469
                 :: fields
1470
                in
1471
             let fields =
1472
               ("value",
1473
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.value))
1474
               :: fields  in
1475
             `Assoc fields)]
1476
      | Sig arg0 ->
1477
          `List
1478
            [`String "Sig";
1479
            (let fields = []  in
1480
             let fields =
1481
               ("att",
1482
                 ((function
1483
                   | None  -> `Null
1484
                   | Some x ->
1485
                       ((fun x  -> vhdl_signal_attributes_t_to_yojson x)) x)
1486
                    arg0.att))
1487
               :: fields  in
1488
             let fields =
1489
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1490
               fields  in
1491
             `Assoc fields)]
1492
      | SuffixMod arg0 ->
1493
          `List
1494
            [`String "SuffixMod";
1495
            (let fields = []  in
1496
             let fields =
1497
               ("selection",
1498
                 ((fun x  -> vhdl_suffix_selection_t_to_yojson x)
1499
                    arg0.selection))
1500
               :: fields  in
1501
             let fields =
1502
               ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.expr)) ::
1503
               fields  in
1504
             `Assoc fields)]
1505
      | Aggregate arg0 ->
1506
          `List
1507
            [`String "AGGREGATE";
1508
            (let fields = []  in
1509
             let fields =
1510
               ("elems",
1511
                 ((fun x  ->
1512
                     `List
1513
                       (List.map (fun x  -> vhdl_element_assoc_t_to_yojson x)
1514
                          x)) arg0.elems))
1515
               :: fields  in
1516
             `Assoc fields)]
1517
      | Others  -> `List [`String "OTHERS"])
1518
  [@ocaml.warning "-A"])
1519

    
1520
and (vhdl_expr_t_of_yojson :
1521
      Yojson.Safe.json -> vhdl_expr_t Ppx_deriving_yojson_runtime.error_or)
1522
  =
1523
  ((let open! Ppx_deriving_yojson_runtime in
1524
      function
1525
      | `List ((`String "CALL")::arg0::[]) ->
1526
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
1527
            ((fun arg0  -> Result.Ok (Call arg0)))
1528
      | `List ((`String "CONSTANT_VALUE")::arg0::[]) ->
1529
          ((function
1530
            | `Assoc xs ->
1531
                let rec loop xs ((arg0,arg1) as _state) =
1532
                  match xs with
1533
                  | ("value",x)::xs ->
1534
                      loop xs
1535
                        (((fun x  -> vhdl_cst_val_t_of_yojson x) x), arg1)
1536
                  | ("unit_name",x)::xs ->
1537
                      loop xs
1538
                        (arg0,
1539
                          ((function
1540
                            | `Null -> Result.Ok None
1541
                            | x ->
1542
                                ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1543
                                  ((fun x  -> Result.Ok (Some x)))) x))
1544
                  | [] ->
1545
                      arg1 >>=
1546
                        ((fun arg1  ->
1547
                            arg0 >>=
1548
                              (fun arg0  ->
1549
                                 Result.Ok
1550
                                   (Cst { value = arg0; unit_name = arg1 }))))
1551
                  | _::xs -> loop xs _state  in
1552
                loop xs
1553
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.value"),
1554
                    (Result.Ok None))
1555
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1556
      | `List ((`String "EXPRESSION")::arg0::[]) ->
1557
          ((function
1558
            | `Assoc xs ->
1559
                let rec loop xs ((arg0,arg1) as _state) =
1560
                  match xs with
1561
                  | ("id",x)::xs ->
1562
                      loop xs
1563
                        (((function
1564
                           | `String x -> Result.Ok x
1565
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.id") x),
1566
                          arg1)
1567
                  | ("args",x)::xs ->
1568
                      loop xs
1569
                        (arg0,
1570
                          ((function
1571
                            | `List xs ->
1572
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1573
                                  [] xs
1574
                            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.args")
1575
                             x))
1576
                  | [] ->
1577
                      arg1 >>=
1578
                        ((fun arg1  ->
1579
                            arg0 >>=
1580
                              (fun arg0  ->
1581
                                 Result.Ok (Op { id = arg0; args = arg1 }))))
1582
                  | _::xs -> loop xs _state  in
1583
                loop xs ((Result.Ok ""), (Result.Ok []))
1584
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1585
      | `List ((`String "IsNull")::[]) -> Result.Ok IsNull
1586
      | `List ((`String "Time")::arg0::[]) ->
1587
          ((function
1588
            | `Assoc xs ->
1589
                let rec loop xs ((arg0,arg1) as _state) =
1590
                  match xs with
1591
                  | ("value",x)::xs ->
1592
                      loop xs
1593
                        (((function
1594
                           | `Int x -> Result.Ok x
1595
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.value")
1596
                            x), arg1)
1597
                  | ("phy_unit",x)::xs ->
1598
                      loop xs
1599
                        (arg0,
1600
                          ((function
1601
                            | `String x -> Result.Ok x
1602
                            | _ ->
1603
                                Result.Error "Vhdl_ast.vhdl_expr_t.phy_unit")
1604
                             x))
1605
                  | [] ->
1606
                      arg1 >>=
1607
                        ((fun arg1  ->
1608
                            arg0 >>=
1609
                              (fun arg0  ->
1610
                                 Result.Ok
1611
                                   (Time { value = arg0; phy_unit = arg1 }))))
1612
                  | _::xs -> loop xs _state  in
1613
                loop xs
1614
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.value"),
1615
                    (Result.Ok ""))
1616
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1617
      | `List ((`String "Sig")::arg0::[]) ->
1618
          ((function
1619
            | `Assoc xs ->
1620
                let rec loop xs ((arg0,arg1) as _state) =
1621
                  match xs with
1622
                  | ("name",x)::xs ->
1623
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1624
                  | ("att",x)::xs ->
1625
                      loop xs
1626
                        (arg0,
1627
                          ((function
1628
                            | `Null -> Result.Ok None
1629
                            | x ->
1630
                                ((fun x  ->
1631
                                    vhdl_signal_attributes_t_of_yojson x) x)
1632
                                  >>= ((fun x  -> Result.Ok (Some x)))) x))
1633
                  | [] ->
1634
                      arg1 >>=
1635
                        ((fun arg1  ->
1636
                            arg0 >>=
1637
                              (fun arg0  ->
1638
                                 Result.Ok (Sig { name = arg0; att = arg1 }))))
1639
                  | _::xs -> loop xs _state  in
1640
                loop xs
1641
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.name"),
1642
                    (Result.Error "Vhdl_ast.vhdl_expr_t.att"))
1643
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1644
      | `List ((`String "SuffixMod")::arg0::[]) ->
1645
          ((function
1646
            | `Assoc xs ->
1647
                let rec loop xs ((arg0,arg1) as _state) =
1648
                  match xs with
1649
                  | ("expr",x)::xs ->
1650
                      loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
1651
                  | ("selection",x)::xs ->
1652
                      loop xs
1653
                        (arg0,
1654
                          ((fun x  -> vhdl_suffix_selection_t_of_yojson x) x))
1655
                  | [] ->
1656
                      arg1 >>=
1657
                        ((fun arg1  ->
1658
                            arg0 >>=
1659
                              (fun arg0  ->
1660
                                 Result.Ok
1661
                                   (SuffixMod
1662
                                      { expr = arg0; selection = arg1 }))))
1663
                  | _::xs -> loop xs _state  in
1664
                loop xs
1665
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.expr"),
1666
                    (Result.Error "Vhdl_ast.vhdl_expr_t.selection"))
1667
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1668
      | `List ((`String "AGGREGATE")::arg0::[]) ->
1669
          ((function
1670
            | `Assoc xs ->
1671
                let rec loop xs (arg0 as _state) =
1672
                  match xs with
1673
                  | ("elems",x)::xs ->
1674
                      loop xs
1675
                        ((function
1676
                          | `List xs ->
1677
                              map_bind
1678
                                (fun x  -> vhdl_element_assoc_t_of_yojson x)
1679
                                [] xs
1680
                          | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.elems") x)
1681
                  | [] ->
1682
                      arg0 >>=
1683
                        ((fun arg0  -> Result.Ok (Aggregate { elems = arg0 })))
1684
                  | _::xs -> loop xs _state  in
1685
                loop xs (Result.Error "Vhdl_ast.vhdl_expr_t.elems")
1686
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1687
      | `List ((`String "OTHERS")::[]) -> Result.Ok Others
1688
      | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")
1689
  [@ocaml.warning "-A"])
1690

    
1691
and (vhdl_name_t_to_yojson : vhdl_name_t -> Yojson.Safe.json) =
1692
  ((let open! Ppx_deriving_yojson_runtime in
1693
      function
1694
      | Simple arg0 ->
1695
          `List
1696
            [`String "SIMPLE_NAME";
1697
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1698
      | Identifier arg0 ->
1699
          `List
1700
            [`String "IDENTIFIER";
1701
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1702
      | Selected arg0 ->
1703
          `List
1704
            [`String "SELECTED_NAME";
1705
            ((fun x  ->
1706
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
1707
      | Index arg0 ->
1708
          `List
1709
            [`String "INDEXED_NAME";
1710
            (let fields = []  in
1711
             let fields =
1712
               ("exprs",
1713
                 ((fun x  ->
1714
                     `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
1715
                    arg0.exprs))
1716
               :: fields  in
1717
             let fields =
1718
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1719
               fields  in
1720
             `Assoc fields)]
1721
      | Slice arg0 ->
1722
          `List
1723
            [`String "SLICE_NAME";
1724
            (let fields = []  in
1725
             let fields =
1726
               ("range",
1727
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
1728
               :: fields  in
1729
             let fields =
1730
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1731
               fields  in
1732
             `Assoc fields)]
1733
      | Attribute arg0 ->
1734
          `List
1735
            [`String "ATTRIBUTE_NAME";
1736
            (let fields = []  in
1737
             let fields =
1738
               if arg0.expr = IsNull
1739
               then fields
1740
               else
1741
                 ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.expr))
1742
                 :: fields
1743
                in
1744
             let fields =
1745
               ("designator",
1746
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.designator))
1747
               :: fields  in
1748
             let fields =
1749
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1750
               fields  in
1751
             `Assoc fields)]
1752
      | Function arg0 ->
1753
          `List
1754
            [`String "FUNCTION_CALL";
1755
            (let fields = []  in
1756
             let fields =
1757
               ("assoc_list",
1758
                 ((fun x  ->
1759
                     `List
1760
                       (List.map (fun x  -> vhdl_assoc_element_t_to_yojson x)
1761
                          x)) arg0.assoc_list))
1762
               :: fields  in
1763
             let fields =
1764
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1765
               fields  in
1766
             `Assoc fields)]
1767
      | NoName  -> `List [`String "NoName"])
1768
  [@ocaml.warning "-A"])
1769

    
1770
and (vhdl_name_t_of_yojson :
1771
      Yojson.Safe.json -> vhdl_name_t Ppx_deriving_yojson_runtime.error_or)
1772
  =
1773
  ((let open! Ppx_deriving_yojson_runtime in
1774
      function
1775
      | `List ((`String "SIMPLE_NAME")::arg0::[]) ->
1776
          ((function
1777
            | `String x -> Result.Ok x
1778
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1779
            ((fun arg0  -> Result.Ok (Simple arg0)))
1780
      | `List ((`String "IDENTIFIER")::arg0::[]) ->
1781
          ((function
1782
            | `String x -> Result.Ok x
1783
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1784
            ((fun arg0  -> Result.Ok (Identifier arg0)))
1785
      | `List ((`String "SELECTED_NAME")::arg0::[]) ->
1786
          ((function
1787
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1788
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1789
            ((fun arg0  -> Result.Ok (Selected arg0)))
1790
      | `List ((`String "INDEXED_NAME")::arg0::[]) ->
1791
          ((function
1792
            | `Assoc xs ->
1793
                let rec loop xs ((arg0,arg1) as _state) =
1794
                  match xs with
1795
                  | ("id",x)::xs ->
1796
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1797
                  | ("exprs",x)::xs ->
1798
                      loop xs
1799
                        (arg0,
1800
                          ((function
1801
                            | `List xs ->
1802
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1803
                                  [] xs
1804
                            | _ -> Result.Error "Vhdl_ast.vhdl_name_t.exprs")
1805
                             x))
1806
                  | [] ->
1807
                      arg1 >>=
1808
                        ((fun arg1  ->
1809
                            arg0 >>=
1810
                              (fun arg0  ->
1811
                                 Result.Ok
1812
                                   (Index { id = arg0; exprs = arg1 }))))
1813
                  | _::xs -> loop xs _state  in
1814
                loop xs
1815
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1816
                    (Result.Error "Vhdl_ast.vhdl_name_t.exprs"))
1817
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1818
      | `List ((`String "SLICE_NAME")::arg0::[]) ->
1819
          ((function
1820
            | `Assoc xs ->
1821
                let rec loop xs ((arg0,arg1) as _state) =
1822
                  match xs with
1823
                  | ("id",x)::xs ->
1824
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1825
                  | ("range",x)::xs ->
1826
                      loop xs
1827
                        (arg0,
1828
                          ((fun x  -> vhdl_discrete_range_t_of_yojson x) x))
1829
                  | [] ->
1830
                      arg1 >>=
1831
                        ((fun arg1  ->
1832
                            arg0 >>=
1833
                              (fun arg0  ->
1834
                                 Result.Ok
1835
                                   (Slice { id = arg0; range = arg1 }))))
1836
                  | _::xs -> loop xs _state  in
1837
                loop xs
1838
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1839
                    (Result.Error "Vhdl_ast.vhdl_name_t.range"))
1840
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1841
      | `List ((`String "ATTRIBUTE_NAME")::arg0::[]) ->
1842
          ((function
1843
            | `Assoc xs ->
1844
                let rec loop xs ((arg0,arg1,arg2) as _state) =
1845
                  match xs with
1846
                  | ("id",x)::xs ->
1847
                      loop xs
1848
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
1849
                  | ("designator",x)::xs ->
1850
                      loop xs
1851
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
1852
                  | ("expr",x)::xs ->
1853
                      loop xs
1854
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1855
                  | [] ->
1856
                      arg2 >>=
1857
                        ((fun arg2  ->
1858
                            arg1 >>=
1859
                              (fun arg1  ->
1860
                                 arg0 >>=
1861
                                   (fun arg0  ->
1862
                                      Result.Ok
1863
                                        (Attribute
1864
                                           {
1865
                                             id = arg0;
1866
                                             designator = arg1;
1867
                                             expr = arg2
1868
                                           })))))
1869
                  | _::xs -> loop xs _state  in
1870
                loop xs
1871
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1872
                    (Result.Error "Vhdl_ast.vhdl_name_t.designator"),
1873
                    (Result.Ok IsNull))
1874
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1875
      | `List ((`String "FUNCTION_CALL")::arg0::[]) ->
1876
          ((function
1877
            | `Assoc xs ->
1878
                let rec loop xs ((arg0,arg1) as _state) =
1879
                  match xs with
1880
                  | ("id",x)::xs ->
1881
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1882
                  | ("assoc_list",x)::xs ->
1883
                      loop xs
1884
                        (arg0,
1885
                          ((function
1886
                            | `List xs ->
1887
                                map_bind
1888
                                  (fun x  -> vhdl_assoc_element_t_of_yojson x)
1889
                                  [] xs
1890
                            | _ ->
1891
                                Result.Error
1892
                                  "Vhdl_ast.vhdl_name_t.assoc_list") x))
1893
                  | [] ->
1894
                      arg1 >>=
1895
                        ((fun arg1  ->
1896
                            arg0 >>=
1897
                              (fun arg0  ->
1898
                                 Result.Ok
1899
                                   (Function { id = arg0; assoc_list = arg1 }))))
1900
                  | _::xs -> loop xs _state  in
1901
                loop xs
1902
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1903
                    (Result.Error "Vhdl_ast.vhdl_name_t.assoc_list"))
1904
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1905
      | `List ((`String "NoName")::[]) -> Result.Ok NoName
1906
      | _ -> Result.Error "Vhdl_ast.vhdl_name_t")
1907
  [@ocaml.warning "-A"])
1908

    
1909
and (vhdl_assoc_element_t_to_yojson :
1910
      vhdl_assoc_element_t -> Yojson.Safe.json)
1911
  =
1912
  ((let open! Ppx_deriving_yojson_runtime in
1913
      fun x  ->
1914
        let fields = []  in
1915
        let fields =
1916
          if x.actual_expr = None
1917
          then fields
1918
          else
1919
            ("actual_expr",
1920
              (((function
1921
                 | None  -> `Null
1922
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
1923
                 x.actual_expr))
1924
            :: fields
1925
           in
1926
        let fields =
1927
          if x.actual_designator = None
1928
          then fields
1929
          else
1930
            ("actual_designator",
1931
              (((function
1932
                 | None  -> `Null
1933
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1934
                 x.actual_designator))
1935
            :: fields
1936
           in
1937
        let fields =
1938
          if x.actual_name = None
1939
          then fields
1940
          else
1941
            ("actual_name",
1942
              (((function
1943
                 | None  -> `Null
1944
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1945
                 x.actual_name))
1946
            :: fields
1947
           in
1948
        let fields =
1949
          if x.formal_arg = None
1950
          then fields
1951
          else
1952
            ("formal_arg",
1953
              (((function
1954
                 | None  -> `Null
1955
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1956
                 x.formal_arg))
1957
            :: fields
1958
           in
1959
        let fields =
1960
          if x.formal_name = None
1961
          then fields
1962
          else
1963
            ("formal_name",
1964
              (((function
1965
                 | None  -> `Null
1966
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1967
                 x.formal_name))
1968
            :: fields
1969
           in
1970
        `Assoc fields)
1971
  [@ocaml.warning "-A"])
1972

    
1973
and (vhdl_assoc_element_t_of_yojson :
1974
      Yojson.Safe.json ->
1975
        vhdl_assoc_element_t Ppx_deriving_yojson_runtime.error_or)
1976
  =
1977
  ((let open! Ppx_deriving_yojson_runtime in
1978
      function
1979
      | `Assoc xs ->
1980
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
1981
            match xs with
1982
            | ("formal_name",x)::xs ->
1983
                loop xs
1984
                  (((function
1985
                     | `Null -> Result.Ok None
1986
                     | x ->
1987
                         ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1988
                           ((fun x  -> Result.Ok (Some x)))) x), arg1, arg2,
1989
                    arg3, arg4)
1990
            | ("formal_arg",x)::xs ->
1991
                loop xs
1992
                  (arg0,
1993
                    ((function
1994
                      | `Null -> Result.Ok None
1995
                      | x ->
1996
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1997
                            ((fun x  -> Result.Ok (Some x)))) x), arg2, arg3,
1998
                    arg4)
1999
            | ("actual_name",x)::xs ->
2000
                loop xs
2001
                  (arg0, arg1,
2002
                    ((function
2003
                      | `Null -> Result.Ok None
2004
                      | x ->
2005
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
2006
                            ((fun x  -> Result.Ok (Some x)))) x), arg3, arg4)
2007
            | ("actual_designator",x)::xs ->
2008
                loop xs
2009
                  (arg0, arg1, arg2,
2010
                    ((function
2011
                      | `Null -> Result.Ok None
2012
                      | x ->
2013
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
2014
                            ((fun x  -> Result.Ok (Some x)))) x), arg4)
2015
            | ("actual_expr",x)::xs ->
2016
                loop xs
2017
                  (arg0, arg1, arg2, arg3,
2018
                    ((function
2019
                      | `Null -> Result.Ok None
2020
                      | x ->
2021
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
2022
                            ((fun x  -> Result.Ok (Some x)))) x))
2023
            | [] ->
2024
                arg4 >>=
2025
                  ((fun arg4  ->
2026
                      arg3 >>=
2027
                        (fun arg3  ->
2028
                           arg2 >>=
2029
                             (fun arg2  ->
2030
                                arg1 >>=
2031
                                  (fun arg1  ->
2032
                                     arg0 >>=
2033
                                       (fun arg0  ->
2034
                                          Result.Ok
2035
                                            {
2036
                                              formal_name = arg0;
2037
                                              formal_arg = arg1;
2038
                                              actual_name = arg2;
2039
                                              actual_designator = arg3;
2040
                                              actual_expr = arg4
2041
                                            }))))))
2042
            | _::xs -> loop xs _state  in
2043
          loop xs
2044
            ((Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
2045
              (Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
2046
              (Result.Ok (Some IsNull)))
2047
      | _ -> Result.Error "Vhdl_ast.vhdl_assoc_element_t")
2048
  [@ocaml.warning "-A"])
2049

    
2050
and (vhdl_element_assoc_t_to_yojson :
2051
      vhdl_element_assoc_t -> Yojson.Safe.json)
2052
  =
2053
  ((let open! Ppx_deriving_yojson_runtime in
2054
      fun x  ->
2055
        let fields = []  in
2056
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
2057
          :: fields  in
2058
        let fields =
2059
          if x.choices = []
2060
          then fields
2061
          else
2062
            ("choices",
2063
              (((fun x  ->
2064
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
2065
                 x.choices))
2066
            :: fields
2067
           in
2068
        `Assoc fields)
2069
  [@ocaml.warning "-A"])
2070

    
2071
and (vhdl_element_assoc_t_of_yojson :
2072
      Yojson.Safe.json ->
2073
        vhdl_element_assoc_t Ppx_deriving_yojson_runtime.error_or)
2074
  =
2075
  ((let open! Ppx_deriving_yojson_runtime in
2076
      function
2077
      | `Assoc xs ->
2078
          let rec loop xs ((arg0,arg1) as _state) =
2079
            match xs with
2080
            | ("choices",x)::xs ->
2081
                loop xs
2082
                  (((function
2083
                     | `List xs ->
2084
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
2085
                     | _ ->
2086
                         Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices")
2087
                      x), arg1)
2088
            | ("expr",x)::xs ->
2089
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
2090
            | [] ->
2091
                arg1 >>=
2092
                  ((fun arg1  ->
2093
                      arg0 >>=
2094
                        (fun arg0  ->
2095
                           Result.Ok { choices = arg0; expr = arg1 })))
2096
            | _::xs -> loop xs _state  in
2097
          loop xs
2098
            ((Result.Ok []),
2099
              (Result.Error "Vhdl_ast.vhdl_element_assoc_t.expr"))
2100
      | _ -> Result.Error "Vhdl_ast.vhdl_element_assoc_t")
2101
  [@ocaml.warning "-A"])
2102

    
2103
and (vhdl_array_attributes_t_to_yojson :
2104
      vhdl_array_attributes_t -> Yojson.Safe.json)
2105
  =
2106
  ((let open! Ppx_deriving_yojson_runtime in
2107
      function
2108
      | AAttInt arg0 ->
2109
          `List
2110
            [`String "AAttInt";
2111
            (let fields = []  in
2112
             let fields =
2113
               ("arg",
2114
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
2115
               :: fields  in
2116
             let fields =
2117
               ("id",
2118
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2119
                    arg0.id))
2120
               :: fields  in
2121
             `Assoc fields)]
2122
      | AAttAscending  -> `List [`String "AAttAscending"])
2123
  [@ocaml.warning "-A"])
2124

    
2125
and (vhdl_array_attributes_t_of_yojson :
2126
      Yojson.Safe.json ->
2127
        vhdl_array_attributes_t Ppx_deriving_yojson_runtime.error_or)
2128
  =
2129
  ((let open! Ppx_deriving_yojson_runtime in
2130
      function
2131
      | `List ((`String "AAttInt")::arg0::[]) ->
2132
          ((function
2133
            | `Assoc xs ->
2134
                let rec loop xs ((arg0,arg1) as _state) =
2135
                  match xs with
2136
                  | ("id",x)::xs ->
2137
                      loop xs
2138
                        (((function
2139
                           | `String x -> Result.Ok x
2140
                           | _ ->
2141
                               Result.Error
2142
                                 "Vhdl_ast.vhdl_array_attributes_t.id") x),
2143
                          arg1)
2144
                  | ("arg",x)::xs ->
2145
                      loop xs
2146
                        (arg0,
2147
                          ((function
2148
                            | `Int x -> Result.Ok x
2149
                            | _ ->
2150
                                Result.Error
2151
                                  "Vhdl_ast.vhdl_array_attributes_t.arg") x))
2152
                  | [] ->
2153
                      arg1 >>=
2154
                        ((fun arg1  ->
2155
                            arg0 >>=
2156
                              (fun arg0  ->
2157
                                 Result.Ok
2158
                                   (AAttInt { id = arg0; arg = arg1 }))))
2159
                  | _::xs -> loop xs _state  in
2160
                loop xs
2161
                  ((Result.Error "Vhdl_ast.vhdl_array_attributes_t.id"),
2162
                    (Result.Error "Vhdl_ast.vhdl_array_attributes_t.arg"))
2163
            | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")) arg0
2164
      | `List ((`String "AAttAscending")::[]) -> Result.Ok AAttAscending
2165
      | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")
2166
  [@ocaml.warning "-A"])
2167

    
2168
and (vhdl_signal_attributes_t_to_yojson :
2169
      vhdl_signal_attributes_t -> Yojson.Safe.json)
2170
  =
2171
  ((let open! Ppx_deriving_yojson_runtime in
2172
      function
2173
      | SigAtt arg0 ->
2174
          `List
2175
            [`String "SigAtt";
2176
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
2177
  [@ocaml.warning "-A"])
2178

    
2179
and (vhdl_signal_attributes_t_of_yojson :
2180
      Yojson.Safe.json ->
2181
        vhdl_signal_attributes_t Ppx_deriving_yojson_runtime.error_or)
2182
  =
2183
  ((let open! Ppx_deriving_yojson_runtime in
2184
      function
2185
      | `List ((`String "SigAtt")::arg0::[]) ->
2186
          ((function
2187
            | `String x -> Result.Ok x
2188
            | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t") arg0)
2189
            >>= ((fun arg0  -> Result.Ok (SigAtt arg0)))
2190
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t")
2191
  [@ocaml.warning "-A"])
2192

    
2193
and (vhdl_string_attributes_t_to_yojson :
2194
      vhdl_string_attributes_t -> Yojson.Safe.json)
2195
  =
2196
  ((let open! Ppx_deriving_yojson_runtime in
2197
      function
2198
      | StringAtt arg0 ->
2199
          `List
2200
            [`String "StringAtt";
2201
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
2202
  [@ocaml.warning "-A"])
2203

    
2204
and (vhdl_string_attributes_t_of_yojson :
2205
      Yojson.Safe.json ->
2206
        vhdl_string_attributes_t Ppx_deriving_yojson_runtime.error_or)
2207
  =
2208
  ((let open! Ppx_deriving_yojson_runtime in
2209
      function
2210
      | `List ((`String "StringAtt")::arg0::[]) ->
2211
          ((function
2212
            | `String x -> Result.Ok x
2213
            | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t") arg0)
2214
            >>= ((fun arg0  -> Result.Ok (StringAtt arg0)))
2215
      | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t")
2216
  [@ocaml.warning "-A"])
2217

    
2218
and (vhdl_suffix_selection_t_to_yojson :
2219
      vhdl_suffix_selection_t -> Yojson.Safe.json)
2220
  =
2221
  ((let open! Ppx_deriving_yojson_runtime in
2222
      function
2223
      | Idx arg0 ->
2224
          `List
2225
            [`String "Idx";
2226
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0]
2227
      | SuffixRange (arg0,arg1) ->
2228
          `List
2229
            [`String "SuffixRange";
2230
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
2231
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1])
2232
  [@ocaml.warning "-A"])
2233

    
2234
and (vhdl_suffix_selection_t_of_yojson :
2235
      Yojson.Safe.json ->
2236
        vhdl_suffix_selection_t Ppx_deriving_yojson_runtime.error_or)
2237
  =
2238
  ((let open! Ppx_deriving_yojson_runtime in
2239
      function
2240
      | `List ((`String "Idx")::arg0::[]) ->
2241
          ((function
2242
            | `Int x -> Result.Ok x
2243
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg0) >>=
2244
            ((fun arg0  -> Result.Ok (Idx arg0)))
2245
      | `List ((`String "SuffixRange")::arg0::arg1::[]) ->
2246
          ((function
2247
            | `Int x -> Result.Ok x
2248
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg1) >>=
2249
            ((fun arg1  ->
2250
                ((function
2251
                  | `Int x -> Result.Ok x
2252
                  | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2253
                   arg0)
2254
                  >>= (fun arg0  -> Result.Ok (SuffixRange (arg0, arg1)))))
2255
      | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2256
  [@ocaml.warning "-A"])
2257

    
2258
type 'basetype vhdl_type_attributes_t =
2259
  | TAttNoArg of {
2260
  id: string } 
2261
  | TAttIntArg of {
2262
  id: string ;
2263
  arg: int } 
2264
  | TAttValArg of {
2265
  id: string ;
2266
  arg: 'basetype } 
2267
  | TAttStringArg of {
2268
  id: string ;
2269
  arg: string } 
2270

    
2271
(* TODO *)
2272
let rec pp_vhdl_type_attributes_t
2273
  =
2274
  ((let open! Ppx_deriving_runtime in
2275
      fun poly_basetype  ->
2276
        fun fmt  ->
2277
          function
2278
          | TAttNoArg { id = aid } ->
2279
              (Format.fprintf fmt "@[<2>TAttNoArg {@,";
2280
               (Format.fprintf fmt "@[%s =@ " "id";
2281
                (Format.fprintf fmt "%S") aid;
2282
                Format.fprintf fmt "@]");
2283
               Format.fprintf fmt "@]}")
2284
          | TAttIntArg { id = aid; arg = aarg } ->
2285
              (Format.fprintf fmt "@[<2>TAttIntArg {@,";
2286
               ((Format.fprintf fmt "@[%s =@ " "id";
2287
                 (Format.fprintf fmt "%S") aid;
2288
                 Format.fprintf fmt "@]");
2289
                Format.fprintf fmt ";@ ";
2290
                Format.fprintf fmt "@[%s =@ " "arg";
2291
                (Format.fprintf fmt "%d") aarg;
2292
                Format.fprintf fmt "@]");
2293
               Format.fprintf fmt "@]}")
2294
          | TAttValArg { id = aid; arg = aarg } ->
2295
              (Format.fprintf fmt "@[<2>TAttValArg {@,";
2296
               ((Format.fprintf fmt "@[%s =@ " "id";
2297
                 (Format.fprintf fmt "%S") aid;
2298
                 Format.fprintf fmt "@]");
2299
                Format.fprintf fmt ";@ ";
2300
                Format.fprintf fmt "@[%s =@ " "arg";
2301
                (poly_basetype fmt) aarg;
2302
                Format.fprintf fmt "@]");
2303
               Format.fprintf fmt "@]}")
2304
          | TAttStringArg { id = aid; arg = aarg } ->
2305
              (Format.fprintf fmt "@[<2>TAttStringArg {@,";
2306
               ((Format.fprintf fmt "@[%s =@ " "id";
2307
                 (Format.fprintf fmt "%S") aid;
2308
                 Format.fprintf fmt "@]");
2309
                Format.fprintf fmt ";@ ";
2310
                Format.fprintf fmt "@[%s =@ " "arg";
2311
                (Format.fprintf fmt "%S") aarg;
2312
                Format.fprintf fmt "@]");
2313
               Format.fprintf fmt "@]}"))
2314
  [@ocaml.warning "-A"])
2315

    
2316
and show_vhdl_type_attributes_t  =
2317
  fun poly_basetype  ->
2318
    fun x  ->
2319
      Format.asprintf "%a" (pp_vhdl_type_attributes_t poly_basetype) x
2320

    
2321
let rec vhdl_type_attributes_t_to_yojson :
2322
  'basetype .
2323
    ('basetype -> Yojson.Safe.json) ->
2324
      'basetype vhdl_type_attributes_t -> Yojson.Safe.json
2325
  =
2326
  fun poly_basetype  ->
2327
    ((let open! Ppx_deriving_yojson_runtime in
2328
        function
2329
        | TAttNoArg arg0 ->
2330
            `List
2331
              [`String "TAttNoArg";
2332
              (let fields = []  in
2333
               let fields =
2334
                 ("id",
2335
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2336
                      arg0.id))
2337
                 :: fields  in
2338
               `Assoc fields)]
2339
        | TAttIntArg arg0 ->
2340
            `List
2341
              [`String "TAttIntArg";
2342
              (let fields = []  in
2343
               let fields =
2344
                 ("arg",
2345
                   ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
2346
                 :: fields  in
2347
               let fields =
2348
                 ("id",
2349
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2350
                      arg0.id))
2351
                 :: fields  in
2352
               `Assoc fields)]
2353
        | TAttValArg arg0 ->
2354
            `List
2355
              [`String "TAttValArg";
2356
              (let fields = []  in
2357
               let fields =
2358
                 ("arg", ((poly_basetype : _ -> Yojson.Safe.json) arg0.arg))
2359
                 :: fields  in
2360
               let fields =
2361
                 ("id",
2362
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2363
                      arg0.id))
2364
                 :: fields  in
2365
               `Assoc fields)]
2366
        | TAttStringArg arg0 ->
2367
            `List
2368
              [`String "TAttStringArg";
2369
              (let fields = []  in
2370
               let fields =
2371
                 ("arg",
2372
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2373
                      arg0.arg))
2374
                 :: fields  in
2375
               let fields =
2376
                 ("id",
2377
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2378
                      arg0.id))
2379
                 :: fields  in
2380
               `Assoc fields)])
2381
    [@ocaml.warning "-A"])
2382

    
2383
and vhdl_type_attributes_t_of_yojson :
2384
  'basetype .
2385
    (Yojson.Safe.json -> 'basetype Ppx_deriving_yojson_runtime.error_or) ->
2386
      Yojson.Safe.json ->
2387
        'basetype vhdl_type_attributes_t Ppx_deriving_yojson_runtime.error_or
2388
  =
2389
  fun poly_basetype  ->
2390
    ((let open! Ppx_deriving_yojson_runtime in
2391
        function
2392
        | `List ((`String "TAttNoArg")::arg0::[]) ->
2393
            ((function
2394
              | `Assoc xs ->
2395
                  let rec loop xs (arg0 as _state) =
2396
                    match xs with
2397
                    | ("id",x)::xs ->
2398
                        loop xs
2399
                          ((function
2400
                            | `String x -> Result.Ok x
2401
                            | _ ->
2402
                                Result.Error
2403
                                  "Vhdl_ast.vhdl_type_attributes_t.id") x)
2404
                    | [] ->
2405
                        arg0 >>=
2406
                          ((fun arg0  -> Result.Ok (TAttNoArg { id = arg0 })))
2407
                    | _::xs -> loop xs _state  in
2408
                  loop xs (Result.Error "Vhdl_ast.vhdl_type_attributes_t.id")
2409
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2410
        | `List ((`String "TAttIntArg")::arg0::[]) ->
2411
            ((function
2412
              | `Assoc xs ->
2413
                  let rec loop xs ((arg0,arg1) as _state) =
2414
                    match xs with
2415
                    | ("id",x)::xs ->
2416
                        loop xs
2417
                          (((function
2418
                             | `String x -> Result.Ok x
2419
                             | _ ->
2420
                                 Result.Error
2421
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2422
                            arg1)
2423
                    | ("arg",x)::xs ->
2424
                        loop xs
2425
                          (arg0,
2426
                            ((function
2427
                              | `Int x -> Result.Ok x
2428
                              | _ ->
2429
                                  Result.Error
2430
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2431
                    | [] ->
2432
                        arg1 >>=
2433
                          ((fun arg1  ->
2434
                              arg0 >>=
2435
                                (fun arg0  ->
2436
                                   Result.Ok
2437
                                     (TAttIntArg { id = arg0; arg = arg1 }))))
2438
                    | _::xs -> loop xs _state  in
2439
                  loop xs
2440
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2441
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2442
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2443
        | `List ((`String "TAttValArg")::arg0::[]) ->
2444
            ((function
2445
              | `Assoc xs ->
2446
                  let rec loop xs ((arg0,arg1) as _state) =
2447
                    match xs with
2448
                    | ("id",x)::xs ->
2449
                        loop xs
2450
                          (((function
2451
                             | `String x -> Result.Ok x
2452
                             | _ ->
2453
                                 Result.Error
2454
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2455
                            arg1)
2456
                    | ("arg",x)::xs ->
2457
                        loop xs
2458
                          (arg0,
2459
                            ((poly_basetype : Yojson.Safe.json -> _ error_or)
2460
                               x))
2461
                    | [] ->
2462
                        arg1 >>=
2463
                          ((fun arg1  ->
2464
                              arg0 >>=
2465
                                (fun arg0  ->
2466
                                   Result.Ok
2467
                                     (TAttValArg { id = arg0; arg = arg1 }))))
2468
                    | _::xs -> loop xs _state  in
2469
                  loop xs
2470
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2471
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2472
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2473
        | `List ((`String "TAttStringArg")::arg0::[]) ->
2474
            ((function
2475
              | `Assoc xs ->
2476
                  let rec loop xs ((arg0,arg1) as _state) =
2477
                    match xs with
2478
                    | ("id",x)::xs ->
2479
                        loop xs
2480
                          (((function
2481
                             | `String x -> Result.Ok x
2482
                             | _ ->
2483
                                 Result.Error
2484
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2485
                            arg1)
2486
                    | ("arg",x)::xs ->
2487
                        loop xs
2488
                          (arg0,
2489
                            ((function
2490
                              | `String x -> Result.Ok x
2491
                              | _ ->
2492
                                  Result.Error
2493
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2494
                    | [] ->
2495
                        arg1 >>=
2496
                          ((fun arg1  ->
2497
                              arg0 >>=
2498
                                (fun arg0  ->
2499
                                   Result.Ok
2500
                                     (TAttStringArg { id = arg0; arg = arg1 }))))
2501
                    | _::xs -> loop xs _state  in
2502
                  loop xs
2503
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2504
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2505
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2506
        | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")
2507
    [@ocaml.warning "-A"])
2508

    
2509
let typ_att_noarg = ["base"; "left"; "right"; "high"; "low"] 
2510
let typ_att_intarg = ["pos"; "val"; "succ"; "pred"; "leftof"; "rightof"] 
2511
let typ_att_valarg = ["image"] 
2512
let typ_att_stringarg = ["value"] 
2513
let array_att_intarg =
2514
  ["left"; "right"; "high"; "low"; "range"; "reverse_range"; "length"] 
2515
type vhdl_parameter_t =
2516
  {
2517
  names: vhdl_name_t list ;
2518
  mode: string list [@default []];
2519
  typ: vhdl_subtype_indication_t ;
2520
  init_val: vhdl_cst_val_t option [@default None]}
2521

    
2522
(* TODO *)
2523
let rec pp_vhdl_parameter_t :
2524
  Format.formatter -> vhdl_parameter_t -> Ppx_deriving_runtime.unit =
2525
  let __2 () = pp_vhdl_cst_val_t
2526
  
2527
  and __1 () = pp_vhdl_subtype_indication_t
2528
  
2529
  and __0 () = pp_vhdl_name_t
2530
   in
2531
  ((let open! Ppx_deriving_runtime in
2532
      fun fmt  ->
2533
        fun x  ->
2534
          Format.fprintf fmt "@[<2>{ ";
2535
          ((((Format.fprintf fmt "@[%s =@ " "names";
2536
              ((fun x  ->
2537
                  Format.fprintf fmt "@[<2>[";
2538
                  ignore
2539
                    (List.fold_left
2540
                       (fun sep  ->
2541
                          fun x  ->
2542
                            if sep then Format.fprintf fmt ";@ ";
2543
                            ((__0 ()) fmt) x;
2544
                            true) false x);
2545
                  Format.fprintf fmt "@,]@]")) x.names;
2546
              Format.fprintf fmt "@]");
2547
             Format.fprintf fmt ";@ ";
2548
             Format.fprintf fmt "@[%s =@ " "mode";
2549
             ((fun x  ->
2550
                 Format.fprintf fmt "@[<2>[";
2551
                 ignore
2552
                   (List.fold_left
2553
                      (fun sep  ->
2554
                         fun x  ->
2555
                           if sep then Format.fprintf fmt ";@ ";
2556
                           (Format.fprintf fmt "%S") x;
2557
                           true) false x);
2558
                 Format.fprintf fmt "@,]@]")) x.mode;
2559
             Format.fprintf fmt "@]");
2560
            Format.fprintf fmt ";@ ";
2561
            Format.fprintf fmt "@[%s =@ " "typ";
2562
            ((__1 ()) fmt) x.typ;
2563
            Format.fprintf fmt "@]");
2564
           Format.fprintf fmt ";@ ";
2565
           Format.fprintf fmt "@[%s =@ " "init_val";
2566
           ((function
2567
             | None  -> Format.pp_print_string fmt "None"
2568
             | Some x ->
2569
                 (Format.pp_print_string fmt "(Some ";
2570
                  ((__2 ()) fmt) x;
2571
                  Format.pp_print_string fmt ")"))) x.init_val;
2572
           Format.fprintf fmt "@]");
2573
          Format.fprintf fmt "@ }@]")
2574
    [@ocaml.warning "-A"])
2575

    
2576
and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string =
2577
  fun x  -> Format.asprintf "%a" pp_vhdl_parameter_t x
2578

    
2579
let rec (vhdl_parameter_t_to_yojson : vhdl_parameter_t -> Yojson.Safe.json) =
2580
  ((let open! Ppx_deriving_yojson_runtime in
2581
      fun x  ->
2582
        let fields = []  in
2583
        let fields =
2584
          if x.init_val = None
2585
          then fields
2586
          else
2587
            ("init_val",
2588
              (((function
2589
                 | None  -> `Null
2590
                 | Some x -> ((fun x  -> vhdl_cst_val_t_to_yojson x)) x))
2591
                 x.init_val))
2592
            :: fields
2593
           in
2594
        let fields =
2595
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
2596
          :: fields  in
2597
        let fields =
2598
          if x.mode = []
2599
          then fields
2600
          else
2601
            ("mode",
2602
              (((fun x  ->
2603
                   `List
2604
                     (List.map
2605
                        (fun (x : Ppx_deriving_runtime.string)  -> `String x)
2606
                        x))) x.mode))
2607
            :: fields
2608
           in
2609
        let fields =
2610
          ("names",
2611
            ((fun x  ->
2612
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
2613
               x.names))
2614
          :: fields  in
2615
        `Assoc fields)
2616
  [@ocaml.warning "-A"])
2617

    
2618
and (vhdl_parameter_t_of_yojson :
2619
      Yojson.Safe.json ->
2620
        vhdl_parameter_t Ppx_deriving_yojson_runtime.error_or)
2621
  =
2622
  ((let open! Ppx_deriving_yojson_runtime in
2623
      function
2624
      | `Assoc xs ->
2625
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2626
            match xs with
2627
            | ("names",x)::xs ->
2628
                loop xs
2629
                  (((function
2630
                     | `List xs ->
2631
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
2632
                     | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.names") x),
2633
                    arg1, arg2, arg3)
2634
            | ("mode",x)::xs ->
2635
                loop xs
2636
                  (arg0,
2637
                    ((function
2638
                      | `List xs ->
2639
                          map_bind
2640
                            (function
2641
                             | `String x -> Result.Ok x
2642
                             | _ ->
2643
                                 Result.Error
2644
                                   "Vhdl_ast.vhdl_parameter_t.mode") [] xs
2645
                      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.mode") x),
2646
                    arg2, arg3)
2647
            | ("typ",x)::xs ->
2648
                loop xs
2649
                  (arg0, arg1,
2650
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
2651
                    arg3)
2652
            | ("init_val",x)::xs ->
2653
                loop xs
2654
                  (arg0, arg1, arg2,
2655
                    ((function
2656
                      | `Null -> Result.Ok None
2657
                      | x ->
2658
                          ((fun x  -> vhdl_cst_val_t_of_yojson x) x) >>=
2659
                            ((fun x  -> Result.Ok (Some x)))) x))
2660
            | [] ->
2661
                arg3 >>=
2662
                  ((fun arg3  ->
2663
                      arg2 >>=
2664
                        (fun arg2  ->
2665
                           arg1 >>=
2666
                             (fun arg1  ->
2667
                                arg0 >>=
2668
                                  (fun arg0  ->
2669
                                     Result.Ok
2670
                                       {
2671
                                         names = arg0;
2672
                                         mode = arg1;
2673
                                         typ = arg2;
2674
                                         init_val = arg3
2675
                                       })))))
2676
            | _::xs -> loop xs _state  in
2677
          loop xs
2678
            ((Result.Error "Vhdl_ast.vhdl_parameter_t.names"),
2679
              (Result.Ok []), (Result.Error "Vhdl_ast.vhdl_parameter_t.typ"),
2680
              (Result.Ok (Some (CstInt 0))))
2681
      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t")
2682
  [@ocaml.warning "-A"])
2683

    
2684
type vhdl_subprogram_spec_t =
2685
  {
2686
  name: string [@default ""];
2687
  typeMark: vhdl_name_t [@default NoName];
2688
  parameters: vhdl_parameter_t list ;
2689
  isPure: bool [@default false]}
2690

    
2691
(* TODO *)
2692
let rec pp_vhdl_subprogram_spec_t :
2693
  Format.formatter -> vhdl_subprogram_spec_t -> Ppx_deriving_runtime.unit =
2694
  let __1 () = pp_vhdl_parameter_t
2695
  
2696
  and __0 () = pp_vhdl_name_t
2697
   in
2698
  ((let open! Ppx_deriving_runtime in
2699
      fun fmt  ->
2700
        fun x  ->
2701
          Format.fprintf fmt "@[<2>{ ";
2702
          ((((Format.fprintf fmt "@[%s =@ " "name";
2703
              (Format.fprintf fmt "%S") x.name;
2704
              Format.fprintf fmt "@]");
2705
             Format.fprintf fmt ";@ ";
2706
             Format.fprintf fmt "@[%s =@ " "typeMark";
2707
             ((__0 ()) fmt) x.typeMark;
2708
             Format.fprintf fmt "@]");
2709
            Format.fprintf fmt ";@ ";
2710
            Format.fprintf fmt "@[%s =@ " "parameters";
2711
            ((fun x  ->
2712
                Format.fprintf fmt "@[<2>[";
2713
                ignore
2714
                  (List.fold_left
2715
                     (fun sep  ->
2716
                        fun x  ->
2717
                          if sep then Format.fprintf fmt ";@ ";
2718
                          ((__1 ()) fmt) x;
2719
                          true) false x);
2720
                Format.fprintf fmt "@,]@]")) x.parameters;
2721
            Format.fprintf fmt "@]");
2722
           Format.fprintf fmt ";@ ";
2723
           Format.fprintf fmt "@[%s =@ " "isPure";
2724
           (Format.fprintf fmt "%B") x.isPure;
2725
           Format.fprintf fmt "@]");
2726
          Format.fprintf fmt "@ }@]")
2727
    [@ocaml.warning "-A"])
2728

    
2729
and show_vhdl_subprogram_spec_t :
2730
  vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string =
2731
  fun x  -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x
2732

    
2733
let rec (vhdl_subprogram_spec_t_to_yojson :
2734
          vhdl_subprogram_spec_t -> Yojson.Safe.json)
2735
  =
2736
  ((let open! Ppx_deriving_yojson_runtime in
2737
      fun x  ->
2738
        let fields = []  in
2739
        let fields =
2740
          if x.isPure = false
2741
          then fields
2742
          else
2743
            ("isPure",
2744
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x)) x.isPure))
2745
            :: fields
2746
           in
2747
        let fields =
2748
          if x.parameters = []
2749
          then fields
2750
          else
2751
            ("parameters",
2752
              (((fun x  ->
2753
                   `List
2754
                     (List.map (fun x  -> vhdl_parameter_t_to_yojson x) x)))
2755
                 x.parameters))
2756
            :: fields
2757
           in
2758
        let fields =
2759
          if x.typeMark = NoName
2760
          then fields
2761
          else
2762
            ("typeMark", (((fun x  -> vhdl_name_t_to_yojson x)) x.typeMark))
2763
            :: fields
2764
           in
2765
        let fields =
2766
          if x.name = ""
2767
          then fields
2768
          else
2769
            ("name",
2770
              (((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x.name))
2771
            :: fields
2772
           in
2773
        `Assoc fields)
2774
  [@ocaml.warning "-A"])
2775

    
2776
and (vhdl_subprogram_spec_t_of_yojson :
2777
      Yojson.Safe.json ->
2778
        vhdl_subprogram_spec_t Ppx_deriving_yojson_runtime.error_or)
2779
  =
2780
  ((let open! Ppx_deriving_yojson_runtime in
2781
      function
2782
      | `Assoc xs ->
2783
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2784
            match xs with
2785
            | ("name",x)::xs ->
2786
                loop xs
2787
                  (((function
2788
                     | `String x -> Result.Ok x
2789
                     | _ ->
2790
                         Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.name")
2791
                      x), arg1, arg2, arg3)
2792
            | ("typeMark",x)::xs ->
2793
                loop xs
2794
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3)
2795
            | ("parameters",x)::xs ->
2796
                loop xs
2797
                  (arg0, arg1,
2798
                    ((function
2799
                      | `List xs ->
2800
                          map_bind (fun x  -> vhdl_parameter_t_of_yojson x)
2801
                            [] xs
2802
                      | _ ->
2803
                          Result.Error
2804
                            "Vhdl_ast.vhdl_subprogram_spec_t.parameters") x),
2805
                    arg3)
2806
            | ("isPure",x)::xs ->
2807
                loop xs
2808
                  (arg0, arg1, arg2,
2809
                    ((function
2810
                      | `Bool x -> Result.Ok x
2811
                      | _ ->
2812
                          Result.Error
2813
                            "Vhdl_ast.vhdl_subprogram_spec_t.isPure") x))
2814
            | [] ->
2815
                arg3 >>=
2816
                  ((fun arg3  ->
2817
                      arg2 >>=
2818
                        (fun arg2  ->
2819
                           arg1 >>=
2820
                             (fun arg1  ->
2821
                                arg0 >>=
2822
                                  (fun arg0  ->
2823
                                     Result.Ok
2824
                                       {
2825
                                         name = arg0;
2826
                                         typeMark = arg1;
2827
                                         parameters = arg2;
2828
                                         isPure = arg3
2829
                                       })))))
2830
            | _::xs -> loop xs _state  in
2831
          loop xs
2832
            ((Result.Ok ""), (Result.Ok NoName), (Result.Ok []),
2833
              (Result.Ok false))
2834
      | _ -> Result.Error "Vhdl_ast.vhdl_subprogram_spec_t")
2835
  [@ocaml.warning "-A"])
2836

    
2837
let arith_funs = ["+"; "-"; "*"; "/"; "mod"; "rem"; "abs"; "**"; "&"] 
2838
let bool_funs = ["and"; "or"; "nand"; "nor"; "xor"; "not"] 
2839
let rel_funs =
2840
  ["<";
2841
  ">";
2842
  "<=";
2843
  ">=";
2844
  "/=";
2845
  "=";
2846
  "?=";
2847
  "?/=";
2848
  "?<";
2849
  "?<=";
2850
  "?>";
2851
  "?>=";
2852
  "??"] 
2853
let shift_funs = ["sll"; "srl"; "sla"; "sra"; "rol"; "ror"] 
2854
type vhdl_sequential_stmt_t =
2855
  | VarAssign of
2856
  {
2857
  label: vhdl_name_t [@default NoName];
2858
  lhs: vhdl_name_t ;
2859
  rhs: vhdl_expr_t } [@name "VARIABLE_ASSIGNMENT_STATEMENT"]
2860
  | SigSeqAssign of
2861
  {
2862
  label: vhdl_name_t [@default NoName];
2863
  lhs: vhdl_name_t ;
2864
  rhs: vhdl_expr_t list } [@name "SIGNAL_ASSIGNMENT_STATEMENT"]
2865
  | If of
2866
  {
2867
  label: vhdl_name_t [@default NoName];
2868
  if_cases: vhdl_if_case_t list ;
2869
  default: vhdl_sequential_stmt_t list [@default []]} [@name "IF_STATEMENT"]
2870
  | Case of
2871
  {
2872
  label: vhdl_name_t [@default NoName];
2873
  guard: vhdl_expr_t ;
2874
  branches: vhdl_case_item_t list } [@name "CASE_STATEMENT_TREE"]
2875
  | Exit of
2876
  {
2877
  label: vhdl_name_t [@default NoName];
2878
  loop_label: string option [@default Some ""];
2879
  condition: vhdl_expr_t option [@default Some IsNull]}
2880
  [@name "EXIT_STATEMENT"]
2881
  | Assert of
2882
  {
2883
  label: vhdl_name_t [@default NoName];
2884
  cond: vhdl_expr_t ;
2885
  report: vhdl_expr_t [@default IsNull];
2886
  severity: vhdl_expr_t [@default IsNull]} [@name "ASSERTION_STATEMENT"]
2887
  | ProcedureCall of
2888
  {
2889
  label: vhdl_name_t [@default NoName];
2890
  name: vhdl_name_t ;
2891
  assocs: vhdl_assoc_element_t list } [@name "PROCEDURE_CALL_STATEMENT"]
2892
  | Wait [@name "WAIT_STATEMENT"]
2893
  | Null of {
2894
  label: vhdl_name_t [@default NoName]} [@name "NULL_STATEMENT"]
2895
  | Return of {
2896
  label: vhdl_name_t [@default NoName]} [@name "RETURN_STATEMENT"]
2897
and vhdl_if_case_t =
2898
  {
2899
  if_cond: vhdl_expr_t ;
2900
  if_block: vhdl_sequential_stmt_t list }
2901
and vhdl_case_item_t =
2902
  {
2903
  when_cond: vhdl_expr_t list ;
2904
  when_stmt: vhdl_sequential_stmt_t list }
2905

    
2906
let rec pp_vhdl_sequential_stmt_t :
2907
  Format.formatter -> vhdl_sequential_stmt_t -> Ppx_deriving_runtime.unit =
2908
  let __22 () = pp_vhdl_name_t
2909
  
2910
  and __21 () = pp_vhdl_name_t
2911
  
2912
  and __20 () = pp_vhdl_assoc_element_t
2913
  
2914
  and __19 () = pp_vhdl_name_t
2915
  
2916
  and __18 () = pp_vhdl_name_t
2917
  
2918
  and __17 () = pp_vhdl_expr_t
2919
  
2920
  and __16 () = pp_vhdl_expr_t
2921
  
2922
  and __15 () = pp_vhdl_expr_t
2923
  
2924
  and __14 () = pp_vhdl_name_t
2925
  
2926
  and __13 () = pp_vhdl_expr_t
2927
  
2928
  and __12 () = pp_vhdl_name_t
2929
  
2930
  and __11 () = pp_vhdl_case_item_t
2931
  
2932
  and __10 () = pp_vhdl_expr_t
2933
  
2934
  and __9 () = pp_vhdl_name_t
2935
  
2936
  and __8 () = pp_vhdl_sequential_stmt_t
2937
  
2938
  and __7 () = pp_vhdl_if_case_t
2939
  
2940
  and __6 () = pp_vhdl_name_t
2941
  
2942
  and __5 () = pp_vhdl_expr_t
2943
  
2944
  and __4 () = pp_vhdl_name_t
2945
  
2946
  and __3 () = pp_vhdl_name_t
2947
  
2948
  and __2 () = pp_vhdl_expr_t
2949
  
2950
  and __1 () = pp_vhdl_name_t
2951
  
2952
  and __0 () = pp_vhdl_name_t
2953
   in
2954
  ((let open! Ppx_deriving_runtime in
2955
      fun fmt  ->
2956
        function
2957
        | VarAssign { label = alabel; lhs = alhs; rhs = arhs } ->
2958
            (match alabel with
2959
              | NoName -> Format.fprintf fmt "";
2960
              | _ -> (((__0 ()) fmt) alabel;
2961
                     Format.fprintf fmt ": ")
2962
            );
2963
            ((__1 ()) fmt) alhs;
2964
            Format.fprintf fmt " := ";
2965
            ((__2 ()) fmt) arhs;
2966
(* TODO: Check
2967
            (Format.fprintf fmt "@[<2>VarAssign {@,";
2968
             (((Format.fprintf fmt "@[%s =@ " "label";
2969
                ((__0 ()) fmt) alabel;
2970
                Format.fprintf fmt "@]");
2971
               Format.fprintf fmt ";@ ";
2972
               Format.fprintf fmt "@[%s =@ " "lhs";
2973
               ((__1 ()) fmt) alhs;
2974
               Format.fprintf fmt "@]");
2975
              Format.fprintf fmt ";@ ";
2976
              Format.fprintf fmt "@[%s =@ " "rhs";
2977
              ((__2 ()) fmt) arhs;
2978
              Format.fprintf fmt "@]");
2979
             Format.fprintf fmt "@]}") *)
2980
        | SigSeqAssign { label = alabel; lhs = alhs; rhs = arhs } ->
2981
            (match alabel with
2982
              | NoName -> Format.fprintf fmt "";
2983
              | _ -> (((__3 ()) fmt) alabel;
2984
                     Format.fprintf fmt ":@ ")
2985
            );
2986
            Format.fprintf fmt "@[<2>";
2987
            ((__4 ()) fmt) alhs;
2988
            Format.fprintf fmt "@ <=@ ";
2989
            ((fun x  ->
2990
               Format.fprintf fmt "@[";
2991
               ignore
2992
                 (List.fold_left
2993
                   (fun sep  ->
2994
                     fun x  ->
2995
                       if sep then Format.fprintf fmt "";
2996
                        ((__5 ()) fmt) x;
2997
                        true) false x);
2998
            Format.fprintf fmt "@]@]")) arhs;
2999
        | If { label = alabel; if_cases = aif_cases; default = adefault } ->
3000
            (match alabel with
3001
              | NoName -> Format.fprintf fmt "";
3002
              | _ -> (((__6 ()) fmt) alabel;
3003
                     Format.fprintf fmt ":@ ")
3004
            );
3005
            Format.fprintf fmt "@[<v>if";
3006
            ((fun x ->
3007
               ignore
3008
               (List.fold_left
3009
                 (fun sep  ->
3010
                   fun x  ->
3011
                           if sep then Format.fprintf fmt "@;elseif";
3012
                                ((__7 ()) fmt) x;
3013
                                true
3014
                 ) false x);
3015
             )) aif_cases;
3016
             (match adefault with
3017
              | [] -> Format.fprintf fmt "";
3018
              | _  -> (Format.fprintf fmt "@;else";
3019
                      ((fun x  ->
3020
                          Format.fprintf fmt "@;<0 2>";
3021
                          ignore
3022
                            (List.fold_left
3023
                              (fun sep  ->
3024
                                fun x  ->
3025
                                        if sep then Format.fprintf fmt "";
3026
                          ((__8 ()) fmt) x;
3027
                          true) false x))) adefault));
3028
            Format.fprintf fmt "@;end if;@]"
3029
        | Case { label = alabel; guard = aguard; branches = abranches } ->
3030
            (match alabel with
3031
              | NoName -> Format.fprintf fmt "";
3032
              | _ -> (((__9 ()) fmt) alabel;
3033
                     Format.fprintf fmt ":@ ")
3034
            );
3035
            Format.fprintf fmt "@[<v>case ";
3036
            ((__10 ()) fmt) aguard;
3037
            Format.fprintf fmt " is";
3038
            ((fun x  ->
3039
                ignore
3040
                  (List.fold_left
3041
                     (fun sep  ->
3042
                        fun x  ->
3043
                          if sep then Format.fprintf fmt "";
3044
                          ((__11 ()) fmt) x;
3045
                          true) false x);)) abranches;
3046
            Format.fprintf fmt "@;end case;@]";
3047
        | Exit
3048
            { label = alabel; loop_label = aloop_label;
3049
              condition = acondition }
3050
            ->
3051
            (match alabel with
3052
              | NoName -> Format.fprintf fmt "";
3053
              | _ -> (((__12 ()) fmt) alabel;
3054
                     Format.fprintf fmt ":@ ")
3055
            );
3056
            Format.fprintf fmt "exit";
3057
            (match aloop_label with
3058
               | None  -> Format.pp_print_string fmt ""
3059
               | Some x -> (Format.fprintf fmt "@ %s@ ") x);
3060
            ((function
3061
               | None  -> Format.pp_print_string fmt ""
3062
               | Some x ->
3063
                   (Format.pp_print_string fmt "when@ ";
3064
                    ((__13 ()) fmt) x;))) acondition;
3065
        | Assert
3066
            { label = alabel; cond = acond; report = areport;
3067
              severity = aseverity }
3068
            ->
3069
            Format.fprintf fmt "@[<v 2>";
3070
            (match alabel with
3071
              | NoName -> Format.fprintf fmt "";
3072
              | _ -> (((__14 ()) fmt) alabel;
3073
                     Format.fprintf fmt ":@ ")
3074
            );
3075
            Format.fprintf fmt "assert ";
3076
            ((__15 ()) fmt) acond;
3077
            (match areport with
3078
            | IsNull -> Format.fprintf fmt "";
3079
            | _ -> 
3080
                Format.fprintf fmt "@;report ";
3081
                ((__16 ()) fmt) areport);
3082
            (match aseverity with
3083
            | IsNull -> Format.fprintf fmt "";
3084
            | _ -> 
3085
                Format.fprintf fmt "@;severity ";
3086
                ((__17 ()) fmt) aseverity);
3087
            Format.fprintf fmt "@]";
3088
        | ProcedureCall { label = alabel; name = aname; assocs = aassocs } ->
3089
            (match alabel with
3090
              | NoName -> Format.fprintf fmt "";
3091
              | _ -> (((__18 ()) fmt) alabel;
3092
                     Format.fprintf fmt ":@ ")
3093
            );
3094
            ((__19 ()) fmt) aname;
3095
            (match aassocs with
3096
            | [] -> Format.fprintf fmt "";
3097
            | _ ->
3098
               ((fun x  ->
3099
                Format.fprintf fmt "(";
3100
                ignore
3101
                  (List.fold_left
3102
                     (fun sep  ->
3103
                        fun x  ->
3104
                          if sep then Format.fprintf fmt ",@ ";
3105
                          ((__20 ()) fmt) x;
3106
                          true) false x);
3107
              Format.fprintf fmt ")")) aassocs);
3108
        | Wait  -> Format.pp_print_string fmt "wait"
3109
        | Null { label = alabel } ->
3110
            (match alabel with
3111
              | NoName -> Format.fprintf fmt "";
3112
              | _ -> (((__18 ()) fmt) alabel;
3113
                     Format.fprintf fmt ":@ ")
3114
            );
3115
            Format.fprintf fmt "null";
3116
        | Return { label = alabel } ->
3117
            (match alabel with
3118
              | NoName -> Format.fprintf fmt "";
3119
              | _ -> (((__19 ()) fmt) alabel;
3120
                     Format.fprintf fmt ":@ ")
3121
            );
3122
            Format.fprintf fmt "return";)
3123
    [@ocaml.warning "-A"])
3124

    
3125
and show_vhdl_sequential_stmt_t :
3126
  vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string =
3127
  fun x  -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x
3128

    
3129
and pp_vhdl_if_case_t :
3130
  Format.formatter -> vhdl_if_case_t -> Ppx_deriving_runtime.unit =
3131
  let __1 () = pp_vhdl_sequential_stmt_t
3132
  
3133
  and __0 () = pp_vhdl_expr_t
3134
   in
3135
  ((let open! Ppx_deriving_runtime in
3136
      fun fmt  ->
3137
        fun x  ->
3138
          Format.fprintf fmt " (";
3139
          ((__0 ()) fmt) x.if_cond;
3140
          Format.fprintf fmt ") then@;<0 2>";
3141
          ((fun x  ->
3142
             ignore
3143
               (List.fold_left
3144
                  (fun sep  ->
3145
                     fun x  ->
3146
                             if sep then Format.fprintf fmt "@;<0 2>";
3147
                       ((__1 ()) fmt) x;
3148
                       true) false x);
3149
          )) x.if_block;)
3150
    [@ocaml.warning "-A"])
3151

    
3152
and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string =
3153
  fun x  -> Format.asprintf "%a" pp_vhdl_if_case_t x
3154

    
3155
and pp_vhdl_case_item_t :
3156
  Format.formatter -> vhdl_case_item_t -> Ppx_deriving_runtime.unit =
3157
  let __1 () = pp_vhdl_sequential_stmt_t
3158
  
3159
  and __0 () = pp_vhdl_expr_t
3160
   in
3161
  ((let open! Ppx_deriving_runtime in
3162
      fun fmt  ->
3163
        fun x  ->
3164
                Format.fprintf fmt "@;@[<v 2>when ";
3165
            ((fun x  ->
3166
                ignore
3167
                  (List.fold_left
3168
                     (fun sep  ->
3169
                        fun x  ->
3170
                          if sep then Format.fprintf fmt "@ |@ ";
3171
                          ((__0 ()) fmt) x;
3172
                          true) false x);)) x.when_cond;
3173
           Format.fprintf fmt " => ";
3174
           (fun x  ->
3175
               ignore
3176
                 (List.fold_left
3177
                    (fun sep  ->
3178
                       fun x  ->
3179
                         if sep then Format.fprintf fmt "@;";
3180
                         ((__1 ()) fmt) x;
3181
                         Format.fprintf fmt ";";
3182
                         true) ((List.length x) > 1) x);) x.when_stmt;
3183
           Format.fprintf fmt "@]")
3184
    [@ocaml.warning "-A"])
3185

    
3186
and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string =
3187
  fun x  -> Format.asprintf "%a" pp_vhdl_case_item_t x
3188

    
3189
let rec (vhdl_sequential_stmt_t_to_yojson :
3190
          vhdl_sequential_stmt_t -> Yojson.Safe.json)
3191
  =
3192
  ((let open! Ppx_deriving_yojson_runtime in
3193
      function
3194
      | VarAssign arg0 ->
3195
          `List
3196
            [`String "VARIABLE_ASSIGNMENT_STATEMENT";
3197
            (let fields = []  in
3198
             let fields =
3199
               ("rhs", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.rhs)) ::
3200
               fields  in
3201
             let fields =
3202
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
3203
               fields  in
3204
             let fields =
3205
               if arg0.label = NoName
3206
               then fields
3207
               else
3208
                 ("label",
3209
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3210
                 :: fields
3211
                in
3212
             `Assoc fields)]
3213
      | SigSeqAssign arg0 ->
3214
          `List
3215
            [`String "SIGNAL_ASSIGNMENT_STATEMENT";
3216
            (let fields = []  in
3217
             let fields =
3218
               ("rhs",
3219
                 ((fun x  ->
3220
                     `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
3221
                    arg0.rhs))
3222
               :: fields  in
3223
             let fields =
3224
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
3225
               fields  in
3226
             let fields =
3227
               if arg0.label = NoName
3228
               then fields
3229
               else
3230
                 ("label",
3231
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3232
                 :: fields
3233
                in
3234
             `Assoc fields)]
3235
      | If arg0 ->
3236
          `List
3237
            [`String "IF_STATEMENT";
3238
            (let fields = []  in
3239
             let fields =
3240
               if arg0.default = []
3241
               then fields
3242
               else
3243
                 ("default",
3244
                   (((fun x  ->
3245
                        `List
3246
                          (List.map
3247
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
3248
                      arg0.default))
3249
                 :: fields
3250
                in
3251
             let fields =
3252
               ("if_cases",
3253
                 ((fun x  ->
3254
                     `List
3255
                       (List.map (fun x  -> vhdl_if_case_t_to_yojson x) x))
3256
                    arg0.if_cases))
3257
               :: fields  in
3258
             let fields =
3259
               if arg0.label = NoName
3260
               then fields
3261
               else
3262
                 ("label",
3263
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3264
                 :: fields
3265
                in
3266
             `Assoc fields)]
3267
      | Case arg0 ->
3268
          `List
3269
            [`String "CASE_STATEMENT_TREE";
3270
            (let fields = []  in
3271
             let fields =
3272
               ("branches",
3273
                 ((fun x  ->
3274
                     `List
3275
                       (List.map (fun x  -> vhdl_case_item_t_to_yojson x) x))
3276
                    arg0.branches))
3277
               :: fields  in
3278
             let fields =
3279
               ("guard", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.guard)) ::
3280
               fields  in
3281
             let fields =
3282
               if arg0.label = NoName
3283
               then fields
3284
               else
3285
                 ("label",
3286
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3287
                 :: fields
3288
                in
3289
             `Assoc fields)]
3290
      | Exit arg0 ->
3291
          `List
3292
            [`String "EXIT_STATEMENT";
3293
            (let fields = []  in
3294
             let fields =
3295
               if arg0.condition = (Some IsNull)
3296
               then fields
3297
               else
3298
                 ("condition",
3299
                   (((function
3300
                      | None  -> `Null
3301
                      | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
3302
                      arg0.condition))
3303
                 :: fields
3304
                in
3305
             let fields =
3306
               if arg0.loop_label = (Some "")
3307
               then fields
3308
               else
3309
                 ("loop_label",
3310
                   (((function
3311
                      | None  -> `Null
3312
                      | Some x ->
3313
                          ((fun (x : Ppx_deriving_runtime.string)  ->
3314
                              `String x)) x)) arg0.loop_label))
3315
                 :: fields
3316
                in
3317
             let fields =
3318
               if arg0.label = NoName
3319
               then fields
3320
               else
3321
                 ("label",
3322
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3323
                 :: fields
3324
                in
3325
             `Assoc fields)]
3326
      | Assert arg0 ->
3327
          `List
3328
            [`String "ASSERTION_STATEMENT";
3329
            (let fields = []  in
3330
             let fields =
3331
               if arg0.severity = IsNull
3332
               then fields
3333
               else
3334
                 ("severity",
3335
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.severity))
3336
                 :: fields
3337
                in
3338
             let fields =
3339
               if arg0.report = IsNull
3340
               then fields
3341
               else
3342
                 ("report",
3343
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.report))
3344
                 :: fields
3345
                in
3346
             let fields =
3347
               ("cond", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.cond)) ::
3348
               fields  in
3349
             let fields =
3350
               if arg0.label = NoName
3351
               then fields
3352
               else
3353
                 ("label",
3354
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3355
                 :: fields
3356
                in
3357
             `Assoc fields)]
3358
      | ProcedureCall arg0 ->
3359
          `List
3360
            [`String "PROCEDURE_CALL_STATEMENT";
3361
            (let fields = []  in
3362
             let fields =
3363
               if arg0.assocs = []
3364
               then fields
3365
               else
3366
                 ("assocs",
3367
                   (((fun x  ->
3368
                        `List
3369
                          (List.map
3370
                             (fun x  -> vhdl_assoc_element_t_to_yojson x) x)))
3371
                      arg0.assocs))
3372
                 :: fields
3373
                in
3374
             let fields =
3375
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
3376
               fields  in
3377
             let fields =
3378
               if arg0.label = NoName
3379
               then fields
3380
               else
3381
                 ("label",
3382
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3383
                 :: fields
3384
                in
3385
             `Assoc fields)]
3386
      | Wait  -> `List [`String "WAIT_STATEMENT"]
3387
      | Null arg0 ->
3388
          `List
3389
            [`String "NULL_STATEMENT";
3390
            (let fields = []  in
3391
             let fields =
3392
               if arg0.label = NoName
3393
               then fields
3394
               else
3395
                 ("label",
3396
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3397
                 :: fields
3398
                in
3399
             `Assoc fields)]
3400
      | Return arg0 ->
3401
          `List
3402
            [`String "RETURN_STATEMENT";
3403
            (let fields = []  in
3404
             let fields =
3405
               if arg0.label = NoName
3406
               then fields
3407
               else
3408
                 ("label",
3409
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3410
                 :: fields
3411
                in
3412
             `Assoc fields)])
3413
  [@ocaml.warning "-A"])
3414

    
3415
and (vhdl_sequential_stmt_t_of_yojson :
3416
      Yojson.Safe.json ->
3417
        vhdl_sequential_stmt_t Ppx_deriving_yojson_runtime.error_or)
3418
  =
3419
  ((let open! Ppx_deriving_yojson_runtime in
3420
      function
3421
      | `List ((`String "VARIABLE_ASSIGNMENT_STATEMENT")::arg0::[]) ->
3422
          ((function
3423
            | `Assoc xs ->
3424
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3425
                  match xs with
3426
                  | ("label",x)::xs ->
3427
                      loop xs
3428
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3429
                  | ("lhs",x)::xs ->
3430
                      loop xs
3431
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3432
                  | ("rhs",x)::xs ->
3433
                      loop xs
3434
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
3435
                  | [] ->
3436
                      arg2 >>=
3437
                        ((fun arg2  ->
3438
                            arg1 >>=
3439
                              (fun arg1  ->
3440
                                 arg0 >>=
3441
                                   (fun arg0  ->
3442
                                      Result.Ok
3443
                                        (VarAssign
3444
                                           {
3445
                                             label = arg0;
3446
                                             lhs = arg1;
3447
                                             rhs = arg2
3448
                                           })))))
3449
                  | _::xs -> loop xs _state  in
3450
                loop xs
3451
                  ((Result.Ok NoName),
3452
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
3453
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
3454
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3455
      | `List ((`String "SIGNAL_ASSIGNMENT_STATEMENT")::arg0::[]) ->
3456
          ((function
3457
            | `Assoc xs ->
3458
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3459
                  match xs with
3460
                  | ("label",x)::xs ->
3461
                      loop xs
3462
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3463
                  | ("lhs",x)::xs ->
3464
                      loop xs
3465
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3466
                  | ("rhs",x)::xs ->
3467
                      loop xs
3468
                        (arg0, arg1,
3469
                          ((function
3470
                            | `List xs ->
3471
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
3472
                                  [] xs
3473
                            | _ ->
3474
                                Result.Error
3475
                                  "Vhdl_ast.vhdl_sequential_stmt_t.rhs") x))
3476
                  | [] ->
3477
                      arg2 >>=
3478
                        ((fun arg2  ->
3479
                            arg1 >>=
3480
                              (fun arg1  ->
3481
                                 arg0 >>=
3482
                                   (fun arg0  ->
3483
                                      Result.Ok
3484
                                        (SigSeqAssign
3485
                                           {
3486
                                             label = arg0;
3487
                                             lhs = arg1;
3488
                                             rhs = arg2
3489
                                           })))))
3490
                  | _::xs -> loop xs _state  in
3491
                loop xs
3492
                  ((Result.Ok NoName),
3493
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
3494
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
3495
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3496
      | `List ((`String "IF_STATEMENT")::arg0::[]) ->
3497
          ((function
3498
            | `Assoc xs ->
3499
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3500
                  match xs with
3501
                  | ("label",x)::xs ->
3502
                      loop xs
3503
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3504
                  | ("if_cases",x)::xs ->
3505
                      loop xs
3506
                        (arg0,
3507
                          ((function
3508
                            | `List xs ->
3509
                                map_bind
3510
                                  (fun x  -> vhdl_if_case_t_of_yojson x) []
3511
                                  xs
3512
                            | _ ->
3513
                                Result.Error
3514
                                  "Vhdl_ast.vhdl_sequential_stmt_t.if_cases")
3515
                             x), arg2)
3516
                  | ("default",x)::xs ->
3517
                      loop xs
3518
                        (arg0, arg1,
3519
                          ((function
3520
                            | `List xs ->
3521
                                map_bind
3522
                                  (fun x  ->
3523
                                     vhdl_sequential_stmt_t_of_yojson x) []
3524
                                  xs
3525
                            | _ ->
3526
                                Result.Error
3527
                                  "Vhdl_ast.vhdl_sequential_stmt_t.default")
3528
                             x))
3529
                  | [] ->
3530
                      arg2 >>=
3531
                        ((fun arg2  ->
3532
                            arg1 >>=
3533
                              (fun arg1  ->
3534
                                 arg0 >>=
3535
                                   (fun arg0  ->
3536
                                      Result.Ok
3537
                                        (If
3538
                                           {
3539
                                             label = arg0;
3540
                                             if_cases = arg1;
3541
                                             default = arg2
3542
                                           })))))
3543
                  | _::xs -> loop xs _state  in
3544
                loop xs
3545
                  ((Result.Ok NoName),
3546
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.if_cases"),
3547
                    (Result.Ok []))
3548
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3549
      | `List ((`String "CASE_STATEMENT_TREE")::arg0::[]) ->
3550
          ((function
3551
            | `Assoc xs ->
3552
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3553
                  match xs with
3554
                  | ("label",x)::xs ->
3555
                      loop xs
3556
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3557
                  | ("guard",x)::xs ->
3558
                      loop xs
3559
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
3560
                  | ("branches",x)::xs ->
3561
                      loop xs
3562
                        (arg0, arg1,
3563
                          ((function
3564
                            | `List xs ->
3565
                                map_bind
3566
                                  (fun x  -> vhdl_case_item_t_of_yojson x) []
3567
                                  xs
3568
                            | _ ->
3569
                                Result.Error
3570
                                  "Vhdl_ast.vhdl_sequential_stmt_t.branches")
3571
                             x))
3572
                  | [] ->
3573
                      arg2 >>=
3574
                        ((fun arg2  ->
3575
                            arg1 >>=
3576
                              (fun arg1  ->
3577
                                 arg0 >>=
3578
                                   (fun arg0  ->
3579
                                      Result.Ok
3580
                                        (Case
3581
                                           {
3582
                                             label = arg0;
3583
                                             guard = arg1;
3584
                                             branches = arg2
3585
                                           })))))
3586
                  | _::xs -> loop xs _state  in
3587
                loop xs
3588
                  ((Result.Ok NoName),
3589
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.guard"),
3590
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.branches"))
3591
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3592
      | `List ((`String "EXIT_STATEMENT")::arg0::[]) ->
3593
          ((function
3594
            | `Assoc xs ->
3595
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3596
                  match xs with
3597
                  | ("label",x)::xs ->
3598
                      loop xs
3599
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3600
                  | ("loop_label",x)::xs ->
3601
                      loop xs
3602
                        (arg0,
3603
                          ((function
3604
                            | `Null -> Result.Ok None
3605
                            | x ->
3606
                                ((function
3607
                                  | `String x -> Result.Ok x
3608
                                  | _ ->
3609
                                      Result.Error
3610
                                        "Vhdl_ast.vhdl_sequential_stmt_t.loop_label")
3611
                                   x)
3612
                                  >>= ((fun x  -> Result.Ok (Some x)))) x),
3613
                          arg2)
3614
                  | ("condition",x)::xs ->
3615
                      loop xs
3616
                        (arg0, arg1,
3617
                          ((function
3618
                            | `Null -> Result.Ok None
3619
                            | x ->
3620
                                ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
3621
                                  ((fun x  -> Result.Ok (Some x)))) x))
3622
                  | [] ->
3623
                      arg2 >>=
3624
                        ((fun arg2  ->
3625
                            arg1 >>=
3626
                              (fun arg1  ->
3627
                                 arg0 >>=
3628
                                   (fun arg0  ->
3629
                                      Result.Ok
3630
                                        (Exit
3631
                                           {
3632
                                             label = arg0;
3633
                                             loop_label = arg1;
3634
                                             condition = arg2
3635
                                           })))))
3636
                  | _::xs -> loop xs _state  in
3637
                loop xs
3638
                  ((Result.Ok NoName), (Result.Ok (Some "")),
3639
                    (Result.Ok (Some IsNull)))
3640
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3641
      | `List ((`String "ASSERTION_STATEMENT")::arg0::[]) ->
3642
          ((function
3643
            | `Assoc xs ->
3644
                let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
3645
                  match xs with
3646
                  | ("label",x)::xs ->
3647
                      loop xs
3648
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2,
3649
                          arg3)
3650
                  | ("cond",x)::xs ->
3651
                      loop xs
3652
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2,
3653
                          arg3)
3654
                  | ("report",x)::xs ->
3655
                      loop xs
3656
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x),
3657
                          arg3)
3658
                  | ("severity",x)::xs ->
3659
                      loop xs
3660
                        (arg0, arg1, arg2,
3661
                          ((fun x  -> vhdl_expr_t_of_yojson x) x))
3662
                  | [] ->
3663
                      arg3 >>=
3664
                        ((fun arg3  ->
3665
                            arg2 >>=
3666
                              (fun arg2  ->
3667
                                 arg1 >>=
3668
                                   (fun arg1  ->
3669
                                      arg0 >>=
3670
                                        (fun arg0  ->
3671
                                           Result.Ok
3672
                                             (Assert
3673
                                                {
3674
                                                  label = arg0;
3675
                                                  cond = arg1;
3676
                                                  report = arg2;
3677
                                                  severity = arg3
3678
                                                }))))))
3679
                  | _::xs -> loop xs _state  in
3680
                loop xs
3681
                  ((Result.Ok NoName),
3682
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.cond"),
3683
                    (Result.Ok IsNull), (Result.Ok IsNull))
3684
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3685
      | `List ((`String "PROCEDURE_CALL_STATEMENT")::arg0::[]) ->
3686
          ((function
3687
            | `Assoc xs ->
3688
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3689
                  match xs with
3690
                  | ("label",x)::xs ->
3691
                      loop xs
3692
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3693
                  | ("name",x)::xs ->
3694
                      loop xs
3695
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3696
                  | ("assocs",x)::xs ->
3697
                      loop xs
3698
                        (arg0, arg1,
3699
                          ((function
3700
                            | `List xs ->
3701
                                map_bind
3702
                                  (fun x  -> vhdl_assoc_element_t_of_yojson x)
3703
                                  [] xs
3704
                            | _ ->
3705
                                Result.Error
3706
                                  "Vhdl_ast.vhdl_sequential_stmt_t.assocs") x))
3707
                  | [] ->
3708
                      arg2 >>=
3709
                        ((fun arg2  ->
3710
                            arg1 >>=
3711
                              (fun arg1  ->
3712
                                 arg0 >>=
3713
                                   (fun arg0  ->
3714
                                      Result.Ok
3715
                                        (ProcedureCall
3716
                                           {
3717
                                             label = arg0;
3718
                                             name = arg1;
3719
                                             assocs = arg2
3720
                                           })))))
3721
                  | _::xs -> loop xs _state  in
3722
                loop xs
3723
                  ((Result.Ok NoName),
3724
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.name"),
3725
                    (Result.Ok []))
3726
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3727
      | `List ((`String "WAIT_STATEMENT")::[]) -> Result.Ok Wait
3728
      | `List ((`String "NULL_STATEMENT")::arg0::[]) ->
3729
          ((function
3730
            | `Assoc xs ->
3731
                let rec loop xs (arg0 as _state) =
3732
                  match xs with
3733
                  | ("label",x)::xs ->
3734
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
3735
                  | [] ->
3736
                      arg0 >>=
3737
                        ((fun arg0  -> Result.Ok (Null { label = arg0 })))
3738
                  | _::xs -> loop xs _state  in
3739
                loop xs (Result.Ok NoName)
3740
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3741
      | `List ((`String "RETURN_STATEMENT")::arg0::[]) ->
3742
          ((function
3743
            | `Assoc xs ->
3744
                let rec loop xs (arg0 as _state) =
3745
                  match xs with
3746
                  | ("label",x)::xs ->
3747
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
3748
                  | [] ->
3749
                      arg0 >>=
3750
                        ((fun arg0  -> Result.Ok (Return { label = arg0 })))
3751
                  | _::xs -> loop xs _state  in
3752
                loop xs (Result.Ok NoName)
3753
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3754
      | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")
3755
  [@ocaml.warning "-A"])
3756

    
3757
and (vhdl_if_case_t_to_yojson : vhdl_if_case_t -> Yojson.Safe.json) =
3758
  ((let open! Ppx_deriving_yojson_runtime in
3759
      fun x  ->
3760
        let fields = []  in
3761
        let fields =
3762
          ("if_block",
3763
            ((fun x  ->
3764
                `List
3765
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3766
               x.if_block))
3767
          :: fields  in
3768
        let fields =
3769
          ("if_cond", ((fun x  -> vhdl_expr_t_to_yojson x) x.if_cond)) ::
3770
          fields  in
3771
        `Assoc fields)
3772
  [@ocaml.warning "-A"])
3773

    
3774
and (vhdl_if_case_t_of_yojson :
3775
      Yojson.Safe.json -> vhdl_if_case_t Ppx_deriving_yojson_runtime.error_or)
3776
  =
3777
  ((let open! Ppx_deriving_yojson_runtime in
3778
      function
3779
      | `Assoc xs ->
3780
          let rec loop xs ((arg0,arg1) as _state) =
3781
            match xs with
3782
            | ("if_cond",x)::xs ->
3783
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
3784
            | ("if_block",x)::xs ->
3785
                loop xs
3786
                  (arg0,
3787
                    ((function
3788
                      | `List xs ->
3789
                          map_bind
3790
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3791
                            xs
3792
                      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t.if_block")
3793
                       x))
3794
            | [] ->
3795
                arg1 >>=
3796
                  ((fun arg1  ->
3797
                      arg0 >>=
3798
                        (fun arg0  ->
3799
                           Result.Ok { if_cond = arg0; if_block = arg1 })))
3800
            | _::xs -> loop xs _state  in
3801
          loop xs
3802
            ((Result.Error "Vhdl_ast.vhdl_if_case_t.if_cond"),
3803
              (Result.Error "Vhdl_ast.vhdl_if_case_t.if_block"))
3804
      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t")
3805
  [@ocaml.warning "-A"])
3806

    
3807
and (vhdl_case_item_t_to_yojson : vhdl_case_item_t -> Yojson.Safe.json) =
3808
  ((let open! Ppx_deriving_yojson_runtime in
3809
      fun x  ->
3810
        let fields = []  in
3811
        let fields =
3812
          ("when_stmt",
3813
            ((fun x  ->
3814
                `List
3815
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3816
               x.when_stmt))
3817
          :: fields  in
3818
        let fields =
3819
          ("when_cond",
3820
            ((fun x  ->
3821
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
3822
               x.when_cond))
3823
          :: fields  in
3824
        `Assoc fields)
3825
  [@ocaml.warning "-A"])
3826

    
3827
and (vhdl_case_item_t_of_yojson :
3828
      Yojson.Safe.json ->
3829
        vhdl_case_item_t Ppx_deriving_yojson_runtime.error_or)
3830
  =
3831
  ((let open! Ppx_deriving_yojson_runtime in
3832
      function
3833
      | `Assoc xs ->
3834
          let rec loop xs ((arg0,arg1) as _state) =
3835
            match xs with
3836
            | ("when_cond",x)::xs ->
3837
                loop xs
3838
                  (((function
3839
                     | `List xs ->
3840
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
3841
                     | _ ->
3842
                         Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond")
3843
                      x), arg1)
3844
            | ("when_stmt",x)::xs ->
3845
                loop xs
3846
                  (arg0,
3847
                    ((function
3848
                      | `List xs ->
3849
                          map_bind
3850
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3851
                            xs
3852
                      | _ ->
3853
                          Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt")
3854
                       x))
3855
            | [] ->
3856
                arg1 >>=
3857
                  ((fun arg1  ->
3858
                      arg0 >>=
3859
                        (fun arg0  ->
3860
                           Result.Ok { when_cond = arg0; when_stmt = arg1 })))
3861
            | _::xs -> loop xs _state  in
3862
          loop xs
3863
            ((Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond"),
3864
              (Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt"))
3865
      | _ -> Result.Error "Vhdl_ast.vhdl_case_item_t")
3866
  [@ocaml.warning "-A"])
3867

    
3868
type vhdl_port_mode_t =
3869
  | InPort [@name "in"]
3870
  | OutPort [@name "out"]
3871
  | InoutPort [@name "inout"]
3872
  | BufferPort [@name "buffer"]
3873

    
3874
let rec (pp_vhdl_port_mode_t :
3875
          Format.formatter -> vhdl_port_mode_t -> Ppx_deriving_runtime.unit)
3876
  =
3877
  ((let open! Ppx_deriving_runtime in
3878
      fun fmt  ->
3879
        function
3880
        | InPort  -> Format.pp_print_string fmt "in"
3881
        | OutPort  -> Format.pp_print_string fmt "out"
3882
        | InoutPort  -> Format.pp_print_string fmt "inout"
3883
        | BufferPort  -> Format.pp_print_string fmt "buffer")
3884
  [@ocaml.warning "-A"])
3885

    
3886
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string =
3887
  fun x  -> Format.asprintf "%a" pp_vhdl_port_mode_t x
3888

    
3889
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) =
3890
  ((let open! Ppx_deriving_yojson_runtime in
3891
      function
3892
      | InPort  -> `List [`String "in"]
3893
      | OutPort  -> `List [`String "out"]
3894
      | InoutPort  -> `List [`String "inout"]
3895
      | BufferPort  -> `List [`String "buffer"])
3896
  [@ocaml.warning "-A"])
3897

    
3898
and (vhdl_port_mode_t_of_yojson :
3899
      Yojson.Safe.json ->
3900
        vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or)
3901
  =
3902
  ((let open! Ppx_deriving_yojson_runtime in
3903
      function
3904
      | `List ((`String "in")::[]) -> Result.Ok InPort
3905
      | `List ((`String "out")::[]) -> Result.Ok OutPort
3906
      | `List ((`String "inout")::[]) -> Result.Ok InoutPort
3907
      | `List ((`String "buffer")::[]) -> Result.Ok BufferPort
3908
      | _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t")
3909
  [@ocaml.warning "-A"])
3910

    
3911
type vhdl_port_t =
3912
  {
3913
  names: vhdl_name_t list [@default []];
3914
  mode: vhdl_port_mode_t [@default InPort];
3915
  typ: vhdl_subtype_indication_t ;
3916
  expr: vhdl_expr_t [@default IsNull]}
3917

    
3918
let rec pp_vhdl_port_t :
3919
  Format.formatter -> vhdl_port_t -> Ppx_deriving_runtime.unit =
3920
  let __3 () = pp_vhdl_expr_t
3921
  
3922
  and __2 () = pp_vhdl_subtype_indication_t
3923
  
3924
  and __1 () = pp_vhdl_port_mode_t
3925
  
3926
  and __0 () = pp_vhdl_name_t
3927
   in
3928
  ((let open! Ppx_deriving_runtime in
3929
      fun fmt  ->
3930
        fun x  ->
3931
          Format.fprintf fmt "@[";
3932
          ((((
3933
              ((fun x  ->
3934
                  Format.fprintf fmt "@[";
3935
                  ignore
3936
                    (List.fold_left
3937
                       (fun sep  ->
3938
                          fun x  ->
3939
                            if sep then Format.fprintf fmt ",@ ";
3940
                            ((__0 ()) fmt) x;
3941
                            true) false x);
3942
                  Format.fprintf fmt "@,@]")) x.names;
3943
              );
3944
             Format.fprintf fmt ": ";
3945
             ((__1 ()) fmt) x.mode;
3946
             );
3947
             Format.fprintf fmt " ";
3948
            ((__2 ()) fmt) x.typ;
3949
            );
3950
          (match x.expr with
3951
           | IsNull -> Format.fprintf fmt "";
3952
           | _ -> (Format.fprintf fmt "@[:= ";
3953
                   ((__3 ()) fmt) x.expr;
3954
                   Format.fprintf fmt "@]"));
3955
          Format.fprintf fmt "@]"))
3956
    [@ocaml.warning "-A"])
3957

    
3958
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string =
3959
  fun x  -> Format.asprintf "%a" pp_vhdl_port_t x
3960

    
3961
let rec (vhdl_port_t_to_yojson : vhdl_port_t -> Yojson.Safe.json) =
3962
  ((let open! Ppx_deriving_yojson_runtime in
3963
      fun x  ->
3964
        let fields = []  in
3965
        let fields =
3966
          if x.expr = IsNull
3967
          then fields
3968
          else ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) x.expr)) ::
3969
            fields
3970
           in
3971
        let fields =
3972
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
3973
          :: fields  in
3974
        let fields =
3975
          if x.mode = InPort
3976
          then fields
3977
          else ("mode", (((fun x  -> vhdl_port_mode_t_to_yojson x)) x.mode))
3978
            :: fields
3979
           in
3980
        let fields =
3981
          if x.names = []
3982
          then fields
3983
          else
3984
            ("names",
3985
              (((fun x  ->
3986
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
3987
                 x.names))
3988
            :: fields
3989
           in
3990
        `Assoc fields)
3991
  [@ocaml.warning "-A"])
3992

    
3993
and (vhdl_port_t_of_yojson :
3994
      Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
3995
  =
3996
  ((let open! Ppx_deriving_yojson_runtime in
3997
      function
3998
      | `Assoc xs ->
3999
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
4000
            match xs with
4001
            | ("names",x)::xs ->
4002
                loop xs
4003
                  (((function
4004
                     | `List xs ->
4005
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4006
                     | _ -> Result.Error "Vhdl_ast.vhdl_port_t.names") x),
4007
                    arg1, arg2, arg3)
4008
            | ("mode",x)::xs ->
4009
                loop xs
4010
                  (arg0, ((fun x  -> vhdl_port_mode_t_of_yojson x) x), arg2,
4011
                    arg3)
4012
            | ("typ",x)::xs ->
4013
                loop xs
4014
                  (arg0, arg1,
4015
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
4016
                    arg3)
4017
            | ("expr",x)::xs ->
4018
                loop xs
4019
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4020
            | [] ->
4021
                arg3 >>=
4022
                  ((fun arg3  ->
4023
                      arg2 >>=
4024
                        (fun arg2  ->
4025
                           arg1 >>=
4026
                             (fun arg1  ->
4027
                                arg0 >>=
4028
                                  (fun arg0  ->
4029
                                     Result.Ok
4030
                                       {
4031
                                         names = arg0;
4032
                                         mode = arg1;
4033
                                         typ = arg2;
4034
                                         expr = arg3
4035
                                       })))))
4036
            | _::xs -> loop xs _state  in
4037
          loop xs
4038
            ((Result.Ok []), (Result.Ok InPort),
4039
              (Result.Error "Vhdl_ast.vhdl_port_t.typ"), (Result.Ok IsNull))
4040
      | _ -> Result.Error "Vhdl_ast.vhdl_port_t")
4041
  [@ocaml.warning "-A"])
4042
type vhdl_declaration_t =
4043
  | VarDecl of
4044
  {
4045
  names: vhdl_name_t list ;
4046
  typ: vhdl_subtype_indication_t ;
4047
  init_val: vhdl_expr_t [@default IsNull]} [@name "VARIABLE_DECLARATION"]
4048
  | CstDecl of
4049
  {
4050
  names: vhdl_name_t list ;
4051
  typ: vhdl_subtype_indication_t ;
4052
  init_val: vhdl_expr_t } [@name "CONSTANT_DECLARATION"]
4053
  | SigDecl of
4054
  {
4055
  names: vhdl_name_t list ;
4056
  typ: vhdl_subtype_indication_t ;
4057
  init_val: vhdl_expr_t [@default IsNull]} [@name "SIGNAL_DECLARATION"]
4058
  | ComponentDecl of
4059
  {
4060
  name: vhdl_name_t [@default NoName];
4061
  generics: vhdl_port_t list [@default []];
4062
  ports: vhdl_port_t list [@default []]} [@name "COMPONENT_DECLARATION"]
4063
  | Subprogram of
4064
  {
4065
  name: string [@default ""];
4066
  kind: string [@default ""];
4067
  spec: vhdl_subprogram_spec_t option [@default None];
4068
  decl_part: vhdl_declaration_t list [@default []];
4069
  stmts: vhdl_sequential_stmt_t list [@default []]} [@name "SUBPROGRAM_BODY"]
4070

    
4071
(* Needs adaptation for: SubProgram *)
4072
let rec pp_vhdl_declaration_t :
4073
  Format.formatter -> vhdl_declaration_t -> Ppx_deriving_runtime.unit =
4074
  let __14 () = pp_vhdl_sequential_stmt_t
4075
  
4076
  and __13 () = pp_vhdl_declaration_t
4077
  
4078
  and __12 () = pp_vhdl_subprogram_spec_t
4079

    
4080
  and __11 () = pp_vhdl_port_t
4081
  
4082
  and __10 () = pp_vhdl_port_t
4083
  
4084
  and __9 () = pp_vhdl_name_t
4085
  
4086
  and __8 () = pp_vhdl_expr_t
4087
  
4088
  and __7 () = pp_vhdl_subtype_indication_t
4089
  
4090
  and __6 () = pp_vhdl_name_t
4091
  
4092
  and __5 () = pp_vhdl_expr_t
4093
  
4094
  and __4 () = pp_vhdl_subtype_indication_t
4095
  
4096
  and __3 () = pp_vhdl_name_t
4097
  
4098
  and __2 () = pp_vhdl_expr_t
4099
  
4100
  and __1 () = pp_vhdl_subtype_indication_t
4101
  
4102
  and __0 () = pp_vhdl_name_t
4103
   in
4104
  ((let open! Ppx_deriving_runtime in
4105
      fun fmt  ->
4106
        function
4107
        | VarDecl { names = anames; typ = atyp; init_val = ainit_val } ->
4108
            (Format.fprintf fmt "variable ";
4109
             ((((fun x  ->
4110
                    ignore
4111
                      (List.fold_left
4112
                         (fun sep  ->
4113
                            fun x  ->
4114
                              if sep then Format.fprintf fmt ",";
4115
                              ((__0 ()) fmt) x;
4116
                              true) false x);)) anames;
4117
               Format.fprintf fmt " : ";
4118
               ((__1 ()) fmt) atyp;
4119
               (match ainit_val with
4120
                | IsNull  -> Format.pp_print_string fmt ""
4121
                | _ ->
4122
                    (Format.fprintf fmt ":=";
4123
                     ((__2 ()) fmt) ainit_val;))));)
4124
        | CstDecl { names = anames; typ = atyp; init_val = ainit_val } ->
4125
            (Format.fprintf fmt "constant ";
4126
             ((((fun x  ->
4127
                    ignore
4128
                      (List.fold_left
4129
                         (fun sep  ->
4130
                            fun x  ->
4131
                              if sep then Format.fprintf fmt ",";
4132
                              ((__3 ()) fmt) x;
4133
                              true) false x);)) anames;
4134
               Format.fprintf fmt " : ";
4135
               ((__4 ()) fmt) atyp;
4136
              Format.fprintf fmt ":=";
4137
              ((__5 ()) fmt) ainit_val)))
4138
        | SigDecl { names = anames; typ = atyp; init_val = ainit_val } ->
4139
            (Format.fprintf fmt "signal ";
4140
            ((fun x  ->
4141
              ignore
4142
              (List.fold_left
4143
                (fun sep  ->
4144
                  fun x  ->
4145
                    if sep then Format.fprintf fmt ",";
4146
                                ((__6 ()) fmt) x;
4147
                                true) false x);
4148
              )) anames;
4149
            Format.fprintf fmt " : ";
4150
            ((__7 ()) fmt) atyp;
4151
            (match ainit_val with
4152
              | IsNull  -> Format.pp_print_string fmt ""
4153
              | _ ->
4154
                  (Format.fprintf fmt ":=";
4155
                  ((__8 ()) fmt) ainit_val;)))
4156
        | ComponentDecl
4157
            { name = aname; generics = agenerics; ports = aports } ->
4158
            Format.fprintf fmt "@[<v 2>component ";
4159
            ((__9 ()) fmt) aname;
4160
            Format.fprintf fmt " is@;";
4161
            ((fun x  ->
4162
              ignore
4163
                (List.fold_left
4164
                  (fun sep  ->
4165
                    fun x  ->
4166
                      if sep then Format.fprintf fmt "@;";
4167
                        ((__10 ()) fmt) x;
4168
                        true) false x))) agenerics;
4169
            ((fun x  ->
4170
              ignore
4171
                (List.fold_left
4172
                  (fun sep  ->
4173
                    fun x  ->
4174
                      if sep then Format.fprintf fmt "@;";
4175
                        ((__11 ()) fmt) x;
4176
                        true) false x))) aports;
4177
            Format.fprintf fmt "@]@;end component";
4178
        | Subprogram
4179
            { name = aname; kind = akind; spec = aspec;
4180
              decl_part = adecl_part; stmts = astmts }
4181
            ->
4182
            (Format.fprintf fmt "@[<2>Subprogram {@,";
4183
             (((((Format.fprintf fmt "@[%s =@ " "name";
4184
                  (Format.fprintf fmt "%S") aname;
4185
                  Format.fprintf fmt "@]");
4186
                 Format.fprintf fmt ";@ ";
4187
                 Format.fprintf fmt "@[%s =@ " "kind";
4188
                 (Format.fprintf fmt "%S") akind;
4189
                 Format.fprintf fmt "@]");
4190
                Format.fprintf fmt ";@ ";
4191
                Format.fprintf fmt "@[%s =@ " "spec";
4192
                ((function
4193
                  | None  -> Format.pp_print_string fmt "None"
4194
                  | Some x ->
4195
                      (Format.pp_print_string fmt "(Some ";
4196
                       ((__12 ()) fmt) x;
4197
                       Format.pp_print_string fmt ")"))) aspec;
4198
                Format.fprintf fmt "@]");
4199
               Format.fprintf fmt ";@ ";
4200
               Format.fprintf fmt "@[%s =@ " "decl_part";
4201
               ((fun x  ->
4202
                   Format.fprintf fmt "@[<2>[";
4203
                   ignore
4204
                     (List.fold_left
4205
                        (fun sep  ->
4206
                           fun x  ->
4207
                             if sep then Format.fprintf fmt ";@ ";
4208
                             ((__13 ()) fmt) x;
4209
                             true) false x);
4210
                   Format.fprintf fmt "@,]@]")) adecl_part;
4211
               Format.fprintf fmt "@]");
4212
              Format.fprintf fmt ";@ ";
4213
              Format.fprintf fmt "@[%s =@ " "stmts";
4214
              ((fun x  ->
4215
                  Format.fprintf fmt "@[<2>[";
4216
                  ignore
4217
                    (List.fold_left
4218
                       (fun sep  ->
4219
                          fun x  ->
4220
                            if sep then Format.fprintf fmt ";@ ";
4221
                            ((__14 ()) fmt) x;
4222
                            true) false x);
4223
                  Format.fprintf fmt "@,]@]")) astmts;
4224
              Format.fprintf fmt "@]");
4225
             Format.fprintf fmt "@]}"))
4226
    [@ocaml.warning "-A"])
4227

    
4228
and show_vhdl_declaration_t :
4229
  vhdl_declaration_t -> Ppx_deriving_runtime.string =
4230
  fun x  -> Format.asprintf "%a" pp_vhdl_declaration_t x
4231

    
4232
let rec (vhdl_declaration_t_to_yojson :
4233
          vhdl_declaration_t -> Yojson.Safe.json)
4234
  =
4235
  ((let open! Ppx_deriving_yojson_runtime in
4236
      function
4237
      | VarDecl arg0 ->
4238
          `List
4239
            [`String "VARIABLE_DECLARATION";
4240
            (let fields = []  in
4241
             let fields =
4242
               if arg0.init_val = IsNull
4243
               then fields
4244
               else
4245
                 ("init_val",
4246
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.init_val))
4247
                 :: fields
4248
                in
4249
             let fields =
4250
               ("typ",
4251
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
4252
               :: fields  in
4253
             let fields =
4254
               ("names",
4255
                 ((fun x  ->
4256
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
4257
                    arg0.names))
4258
               :: fields  in
4259
             `Assoc fields)]
4260
      | CstDecl arg0 ->
4261
          `List
4262
            [`String "CONSTANT_DECLARATION";
4263
            (let fields = []  in
4264
             let fields =
4265
               ("init_val",
4266
                 ((fun x  -> vhdl_expr_t_to_yojson x) arg0.init_val))
4267
               :: fields  in
4268
             let fields =
4269
               ("typ",
4270
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
4271
               :: fields  in
4272
             let fields =
4273
               ("names",
4274
                 ((fun x  ->
4275
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
4276
                    arg0.names))
4277
               :: fields  in
4278
             `Assoc fields)]
4279
      | SigDecl arg0 ->
4280
          `List
4281
            [`String "SIGNAL_DECLARATION";
4282
            (let fields = []  in
4283
             let fields =
4284
               if arg0.init_val = IsNull
4285
               then fields
4286
               else
4287
                 ("init_val",
4288
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.init_val))
4289
                 :: fields
4290
                in
4291
             let fields =
4292
               ("typ",
4293
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
4294
               :: fields  in
4295
             let fields =
4296
               ("names",
4297
                 ((fun x  ->
4298
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
4299
                    arg0.names))
4300
               :: fields  in
4301
             `Assoc fields)]
4302
      | ComponentDecl arg0 ->
4303
          `List
4304
            [`String "COMPONENT_DECLARATION";
4305
            (let fields = []  in
4306
             let fields =
4307
               if arg0.ports = []
4308
               then fields
4309
               else
4310
                 ("ports",
4311
                   (((fun x  ->
4312
                        `List
4313
                          (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
4314
                      arg0.ports))
4315
                 :: fields
4316
                in
4317
             let fields =
4318
               if arg0.generics = []
4319
               then fields
4320
               else
4321
                 ("generics",
4322
                   (((fun x  ->
4323
                        `List
4324
                          (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
4325
                      arg0.generics))
4326
                 :: fields
4327
                in
4328
             let fields =
4329
               if arg0.name = NoName
4330
               then fields
4331
               else
4332
                 ("name", (((fun x  -> vhdl_name_t_to_yojson x)) arg0.name))
4333
                 :: fields
4334
                in
4335
             `Assoc fields)]
4336
      | Subprogram arg0 ->
4337
          `List
4338
            [`String "SUBPROGRAM_BODY";
4339
            (let fields = []  in
4340
             let fields =
4341
               if arg0.stmts = []
4342
               then fields
4343
               else
4344
                 ("stmts",
4345
                   (((fun x  ->
4346
                        `List
4347
                          (List.map
4348
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
4349
                      arg0.stmts))
4350
                 :: fields
4351
                in
4352
             let fields =
4353
               if arg0.decl_part = []
4354
               then fields
4355
               else
4356
                 ("decl_part",
4357
                   (((fun x  ->
4358
                        `List
4359
                          (List.map
4360
                             (fun x  -> vhdl_declaration_t_to_yojson x) x)))
4361
                      arg0.decl_part))
4362
                 :: fields
4363
                in
4364
             let fields =
4365
               if arg0.spec = None
4366
               then fields
4367
               else
4368
                 ("spec",
4369
                   (((function
4370
                      | None  -> `Null
4371
                      | Some x ->
4372
                          ((fun x  -> vhdl_subprogram_spec_t_to_yojson x)) x))
4373
                      arg0.spec))
4374
                 :: fields
4375
                in
4376
             let fields =
4377
               if arg0.kind = ""
4378
               then fields
4379
               else
4380
                 ("kind",
4381
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
4382
                      arg0.kind))
4383
                 :: fields
4384
                in
4385
             let fields =
4386
               if arg0.name = ""
4387
               then fields
4388
               else
4389
                 ("name",
4390
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
4391
                      arg0.name))
4392
                 :: fields
4393
                in
4394
             `Assoc fields)])
4395
  [@ocaml.warning "-A"])
4396

    
4397
and (vhdl_declaration_t_of_yojson :
4398
      Yojson.Safe.json ->
4399
        vhdl_declaration_t Ppx_deriving_yojson_runtime.error_or)
4400
  =
4401
  ((let open! Ppx_deriving_yojson_runtime in
4402
      function
4403
      | `List ((`String "VARIABLE_DECLARATION")::arg0::[]) ->
4404
          ((function
4405
            | `Assoc xs ->
4406
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4407
                  match xs with
4408
                  | ("names",x)::xs ->
4409
                      loop xs
4410
                        (((function
4411
                           | `List xs ->
4412
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4413
                                 [] xs
4414
                           | _ ->
4415
                               Result.Error
4416
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4417
                          arg1, arg2)
4418
                  | ("typ",x)::xs ->
4419
                      loop xs
4420
                        (arg0,
4421
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4422
                             x), arg2)
4423
                  | ("init_val",x)::xs ->
4424
                      loop xs
4425
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4426
                  | [] ->
4427
                      arg2 >>=
4428
                        ((fun arg2  ->
4429
                            arg1 >>=
4430
                              (fun arg1  ->
4431
                                 arg0 >>=
4432
                                   (fun arg0  ->
4433
                                      Result.Ok
4434
                                        (VarDecl
4435
                                           {
4436
                                             names = arg0;
4437
                                             typ = arg1;
4438
                                             init_val = arg2
4439
                                           })))))
4440
                  | _::xs -> loop xs _state  in
4441
                loop xs
4442
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4443
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4444
                    (Result.Ok IsNull))
4445
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4446
      | `List ((`String "CONSTANT_DECLARATION")::arg0::[]) ->
4447
          ((function
4448
            | `Assoc xs ->
4449
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4450
                  match xs with
4451
                  | ("names",x)::xs ->
4452
                      loop xs
4453
                        (((function
4454
                           | `List xs ->
4455
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4456
                                 [] xs
4457
                           | _ ->
4458
                               Result.Error
4459
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4460
                          arg1, arg2)
4461
                  | ("typ",x)::xs ->
4462
                      loop xs
4463
                        (arg0,
4464
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4465
                             x), arg2)
4466
                  | ("init_val",x)::xs ->
4467
                      loop xs
4468
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4469
                  | [] ->
4470
                      arg2 >>=
4471
                        ((fun arg2  ->
4472
                            arg1 >>=
4473
                              (fun arg1  ->
4474
                                 arg0 >>=
4475
                                   (fun arg0  ->
4476
                                      Result.Ok
4477
                                        (CstDecl
4478
                                           {
4479
                                             names = arg0;
4480
                                             typ = arg1;
4481
                                             init_val = arg2
4482
                                           })))))
4483
                  | _::xs -> loop xs _state  in
4484
                loop xs
4485
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4486
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4487
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.init_val"))
4488
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4489
      | `List ((`String "SIGNAL_DECLARATION")::arg0::[]) ->
4490
          ((function
4491
            | `Assoc xs ->
4492
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4493
                  match xs with
4494
                  | ("names",x)::xs ->
4495
                      loop xs
4496
                        (((function
4497
                           | `List xs ->
4498
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4499
                                 [] xs
4500
                           | _ ->
4501
                               Result.Error
4502
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4503
                          arg1, arg2)
4504
                  | ("typ",x)::xs ->
4505
                      loop xs
4506
                        (arg0,
4507
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4508
                             x), arg2)
4509
                  | ("init_val",x)::xs ->
4510
                      loop xs
4511
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4512
                  | [] ->
4513
                      arg2 >>=
4514
                        ((fun arg2  ->
4515
                            arg1 >>=
4516
                              (fun arg1  ->
4517
                                 arg0 >>=
4518
                                   (fun arg0  ->
4519
                                      Result.Ok
4520
                                        (SigDecl
4521
                                           {
4522
                                             names = arg0;
4523
                                             typ = arg1;
4524
                                             init_val = arg2
4525
                                           })))))
4526
                  | _::xs -> loop xs _state  in
4527
                loop xs
4528
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4529
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4530
                    (Result.Ok IsNull))
4531
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4532
      | `List ((`String "COMPONENT_DECLARATION")::arg0::[]) ->
4533
          ((function
4534
            | `Assoc xs ->
4535
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4536
                  match xs with
4537
                  | ("name",x)::xs ->
4538
                      loop xs
4539
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
4540
                  | ("generics",x)::xs ->
4541
                      loop xs
4542
                        (arg0,
4543
                          ((function
4544
                            | `List xs ->
4545
                                map_bind (fun x  -> vhdl_port_t_of_yojson x)
4546
                                  [] xs
4547
                            | _ ->
4548
                                Result.Error
4549
                                  "Vhdl_ast.vhdl_declaration_t.generics") x),
4550
                          arg2)
4551
                  | ("ports",x)::xs ->
4552
                      loop xs
4553
                        (arg0, arg1,
4554
                          ((function
4555
                            | `List xs ->
4556
                                map_bind (fun x  -> vhdl_port_t_of_yojson x)
4557
                                  [] xs
4558
                            | _ ->
4559
                                Result.Error
4560
                                  "Vhdl_ast.vhdl_declaration_t.ports") x))
4561
                  | [] ->
4562
                      arg2 >>=
4563
                        ((fun arg2  ->
4564
                            arg1 >>=
4565
                              (fun arg1  ->
4566
                                 arg0 >>=
4567
                                   (fun arg0  ->
4568
                                      Result.Ok
4569
                                        (ComponentDecl
4570
                                           {
4571
                                             name = arg0;
4572
                                             generics = arg1;
4573
                                             ports = arg2
4574
                                           })))))
4575
                  | _::xs -> loop xs _state  in
4576
                loop xs ((Result.Ok NoName), (Result.Ok []), (Result.Ok []))
4577
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4578
      | `List ((`String "SUBPROGRAM_BODY")::arg0::[]) ->
4579
          ((function
4580
            | `Assoc xs ->
4581
                let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
4582
                  match xs with
4583
                  | ("name",x)::xs ->
4584
                      loop xs
4585
                        (((function
4586
                           | `String x -> Result.Ok x
4587
                           | _ ->
4588
                               Result.Error
4589
                                 "Vhdl_ast.vhdl_declaration_t.name") x),
4590
                          arg1, arg2, arg3, arg4)
4591
                  | ("kind",x)::xs ->
4592
                      loop xs
4593
                        (arg0,
4594
                          ((function
4595
                            | `String x -> Result.Ok x
4596
                            | _ ->
4597
                                Result.Error
4598
                                  "Vhdl_ast.vhdl_declaration_t.kind") x),
4599
                          arg2, arg3, arg4)
4600
                  | ("spec",x)::xs ->
4601
                      loop xs
4602
                        (arg0, arg1,
4603
                          ((function
4604
                            | `Null -> Result.Ok None
4605
                            | x ->
4606
                                ((fun x  ->
4607
                                    vhdl_subprogram_spec_t_of_yojson x) x)
4608
                                  >>= ((fun x  -> Result.Ok (Some x)))) x),
4609
                          arg3, arg4)
4610
                  | ("decl_part",x)::xs ->
4611
                      loop xs
4612
                        (arg0, arg1, arg2,
4613
                          ((function
4614
                            | `List xs ->
4615
                                map_bind
4616
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4617
                                  [] xs
4618
                            | _ ->
4619
                                Result.Error
4620
                                  "Vhdl_ast.vhdl_declaration_t.decl_part") x),
4621
                          arg4)
4622
                  | ("stmts",x)::xs ->
4623
                      loop xs
4624
                        (arg0, arg1, arg2, arg3,
4625
                          ((function
4626
                            | `List xs ->
4627
                                map_bind
4628
                                  (fun x  ->
4629
                                     vhdl_sequential_stmt_t_of_yojson x) []
4630
                                  xs
4631
                            | _ ->
4632
                                Result.Error
4633
                                  "Vhdl_ast.vhdl_declaration_t.stmts") x))
4634
                  | [] ->
4635
                      arg4 >>=
4636
                        ((fun arg4  ->
4637
                            arg3 >>=
4638
                              (fun arg3  ->
4639
                                 arg2 >>=
4640
                                   (fun arg2  ->
4641
                                      arg1 >>=
4642
                                        (fun arg1  ->
4643
                                           arg0 >>=
4644
                                             (fun arg0  ->
4645
                                                Result.Ok
4646
                                                  (Subprogram
4647
                                                     {
4648
                                                       name = arg0;
4649
                                                       kind = arg1;
4650
                                                       spec = arg2;
4651
                                                       decl_part = arg3;
4652
                                                       stmts = arg4
4653
                                                     })))))))
4654
                  | _::xs -> loop xs _state  in
4655
                loop xs
4656
                  ((Result.Ok ""), (Result.Ok ""), (Result.Ok None),
4657
                    (Result.Ok []), (Result.Ok []))
4658
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4659
      | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")
4660
  [@ocaml.warning "-A"])
4661

    
4662
type vhdl_load_t =
4663
  | Library of vhdl_name_t list [@name "LIBRARY_CLAUSE"][@default []]
4664
  | Use of vhdl_name_t list [@name "USE_CLAUSE"][@default []]
4665

    
4666
(* Adapted. TODO: check indentation *)
4667
let rec pp_vhdl_load_t :
4668
  Format.formatter -> vhdl_load_t -> Ppx_deriving_runtime.unit =
4669
  let __1 () = pp_vhdl_name_t
4670
  
4671
  and __0 () = pp_vhdl_name_t
4672
   in
4673
  ((let open! Ppx_deriving_runtime in
4674
      fun fmt  ->
4675
        function
4676
        | Library a0 ->
4677
            (Format.fprintf fmt "library ";
4678
             ((fun x  ->
4679
                 ignore
4680
                   (List.fold_left
4681
                      (fun sep  ->
4682
                         fun x  ->
4683
                           if sep then Format.fprintf fmt ".";
4684
                           ((__0 ()) fmt) x;
4685
                           true) false x))) a0;
4686
             Format.fprintf fmt ":")
4687
        | Use a0 ->
4688
            (Format.fprintf fmt "use ";
4689
             ((fun x  ->
4690
                 ignore
4691
                   (List.fold_left
4692
                      (fun sep  ->
4693
                         fun x  ->
4694
                           if sep then Format.fprintf fmt ".";
4695
                           ((__1 ()) fmt) x;
4696
                           true) false x))) a0;
4697
             Format.fprintf fmt ";"))
4698
    [@ocaml.warning "-A"])
4699

    
4700
and show_vhdl_load_t : vhdl_load_t -> Ppx_deriving_runtime.string =
4701
  fun x  -> Format.asprintf "%a" pp_vhdl_load_t x
4702

    
4703
let rec (vhdl_load_t_to_yojson : vhdl_load_t -> Yojson.Safe.json) =
4704
  ((let open! Ppx_deriving_yojson_runtime in
4705
      function
4706
      | Library arg0 ->
4707
          `List
4708
            [`String "LIBRARY_CLAUSE";
4709
            ((fun x  ->
4710
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
4711
      | Use arg0 ->
4712
          `List
4713
            [`String "USE_CLAUSE";
4714
            ((fun x  ->
4715
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0])
4716
  [@ocaml.warning "-A"])
4717

    
4718
and (vhdl_load_t_of_yojson :
4719
      Yojson.Safe.json -> vhdl_load_t Ppx_deriving_yojson_runtime.error_or)
4720
  =
4721
  ((let open! Ppx_deriving_yojson_runtime in
4722
      function
4723
      | `List ((`String "LIBRARY_CLAUSE")::arg0::[]) ->
4724
          ((function
4725
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4726
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
4727
            ((fun arg0  -> Result.Ok (Library arg0)))
4728
      | `List ((`String "USE_CLAUSE")::arg0::[]) ->
4729
          ((function
4730
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4731
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
4732
            ((fun arg0  -> Result.Ok (Use arg0)))
4733
      | _ -> Result.Error "Vhdl_ast.vhdl_load_t")
4734
  [@ocaml.warning "-A"])
4735

    
4736
type vhdl_declarative_item_t =
4737
  {
4738
  use_clause: vhdl_load_t option [@default None];
4739
  declaration: vhdl_declaration_t option [@default None];
4740
  definition: vhdl_definition_t option [@default None]}[@@deriving
4741
                                                         ((show
4742
                                                             {
4743
                                                               with_path =
4744
                                                                 false
4745
                                                             }),
4746
                                                           (yojson
4747
                                                              {
4748
                                                                strict =
4749
                                                                  false
4750
                                                              }))]
4751
let rec pp_vhdl_declarative_item_t :
4752
  Format.formatter -> vhdl_declarative_item_t -> Ppx_deriving_runtime.unit =
4753
  let __2 () = pp_vhdl_definition_t
4754
  
4755
  and __1 () = pp_vhdl_declaration_t
4756
  
4757
  and __0 () = pp_vhdl_load_t
4758
   in
4759
  ((let open! Ppx_deriving_runtime in
4760
      fun fmt  ->
4761
        fun x  ->
4762
          (match x.use_clause with
4763
          | None -> Format.fprintf fmt "";
4764
          | Some e -> ((__0 ()) fmt) e);
4765
          (match x.declaration with
4766
          | None -> Format.fprintf fmt "";
4767
          | Some e -> ((__1 ()) fmt) e);
4768
          (match x.definition with
4769
          | None -> Format.fprintf fmt "";
4770
          | Some e -> ((__2 ()) fmt) e);)
4771
    [@ocaml.warning "-A"])
4772

    
4773
and show_vhdl_declarative_item_t :
4774
  vhdl_declarative_item_t -> Ppx_deriving_runtime.string =
4775
  fun x  -> Format.asprintf "%a" pp_vhdl_declarative_item_t x
4776

    
4777
let rec (vhdl_declarative_item_t_to_yojson :
4778
          vhdl_declarative_item_t -> Yojson.Safe.json)
4779
  =
4780
  ((let open! Ppx_deriving_yojson_runtime in
4781
      fun x  ->
4782
        let fields = []  in
4783
        let fields =
4784
          if x.definition = None
4785
          then fields
4786
          else
4787
            ("definition",
4788
              (((function
4789
                 | None  -> `Null
4790
                 | Some x -> ((fun x  -> vhdl_definition_t_to_yojson x)) x))
4791
                 x.definition))
4792
            :: fields
4793
           in
4794
        let fields =
4795
          if x.declaration = None
4796
          then fields
4797
          else
4798
            ("declaration",
4799
              (((function
4800
                 | None  -> `Null
4801
                 | Some x -> ((fun x  -> vhdl_declaration_t_to_yojson x)) x))
4802
                 x.declaration))
4803
            :: fields
4804
           in
4805
        let fields =
4806
          if x.use_clause = None
4807
          then fields
4808
          else
4809
            ("use_clause",
4810
              (((function
4811
                 | None  -> `Null
4812
                 | Some x -> ((fun x  -> vhdl_load_t_to_yojson x)) x))
4813
                 x.use_clause))
4814
            :: fields
4815
           in
4816
        `Assoc fields)
4817
  [@ocaml.warning "-A"])
4818

    
4819
and (vhdl_declarative_item_t_of_yojson :
4820
      Yojson.Safe.json ->
4821
        vhdl_declarative_item_t Ppx_deriving_yojson_runtime.error_or)
4822
  =
4823
  ((let open! Ppx_deriving_yojson_runtime in
4824
      function
4825
      | `Assoc xs ->
4826
          let rec loop xs ((arg0,arg1,arg2) as _state) =
4827
            match xs with
4828
            | ("use_clause",x)::xs ->
4829
                loop xs
4830
                  (((function
4831
                     | `Null -> Result.Ok None
4832
                     | x ->
4833
                         ((fun x  -> vhdl_load_t_of_yojson x) x) >>=
4834
                           ((fun x  -> Result.Ok (Some x)))) x), arg1, arg2)
4835
            | ("declaration",x)::xs ->
4836
                loop xs
4837
                  (arg0,
4838
                    ((function
4839
                      | `Null -> Result.Ok None
4840
                      | x ->
4841
                          ((fun x  -> vhdl_declaration_t_of_yojson x) x) >>=
4842
                            ((fun x  -> Result.Ok (Some x)))) x), arg2)
4843
            | ("definition",x)::xs ->
4844
                loop xs
4845
                  (arg0, arg1,
4846
                    ((function
4847
                      | `Null -> Result.Ok None
4848
                      | x ->
4849
                          ((fun x  -> vhdl_definition_t_of_yojson x) x) >>=
4850
                            ((fun x  -> Result.Ok (Some x)))) x))
4851
            | [] ->
4852
                arg2 >>=
4853
                  ((fun arg2  ->
4854
                      arg1 >>=
4855
                        (fun arg1  ->
4856
                           arg0 >>=
4857
                             (fun arg0  ->
4858
                                Result.Ok
4859
                                  {
4860
                                    use_clause = arg0;
4861
                                    declaration = arg1;
4862
                                    definition = arg2
4863
                                  }))))
4864
            | _::xs -> loop xs _state  in
4865
          loop xs ((Result.Ok None), (Result.Ok None), (Result.Ok None))
4866
      | _ -> Result.Error "Vhdl_ast.vhdl_declarative_item_t")
4867
  [@ocaml.warning "-A"])
4868

    
4869
type vhdl_signal_condition_t =
4870
  {
4871
  expr: vhdl_expr_t list ;
4872
  cond: vhdl_expr_t [@default IsNull]}
4873

    
4874
let rec pp_vhdl_signal_condition_t :
4875
  Format.formatter -> vhdl_signal_condition_t -> Ppx_deriving_runtime.unit =
4876
  let __1 () = pp_vhdl_expr_t
4877
  
4878
  and __0 () = pp_vhdl_expr_t
4879
   in
4880
  ((let open! Ppx_deriving_runtime in
4881
      fun fmt  ->
4882
        fun x  ->
4883
          ((fun x  ->
4884
              ignore
4885
                (List.fold_left
4886
                   (fun sep  ->
4887
                      fun x  ->
4888
                        if sep then Format.fprintf fmt ";@ ";
4889
                        ((__0 ()) fmt) x;
4890
                        true) false x))) x.expr;
4891
          (match x.cond with
4892
          | IsNull -> Format.fprintf fmt "";
4893
          | _ -> Format.fprintf fmt "when ";
4894
                 ((__1 ()) fmt) x.cond);)
4895
    [@ocaml.warning "-A"])
4896

    
4897
and show_vhdl_signal_condition_t :
4898
  vhdl_signal_condition_t -> Ppx_deriving_runtime.string =
4899
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_condition_t x
4900

    
4901
let rec (vhdl_signal_condition_t_to_yojson :
4902
          vhdl_signal_condition_t -> Yojson.Safe.json)
4903
  =
4904
  ((let open! Ppx_deriving_yojson_runtime in
4905
      fun x  ->
4906
        let fields = []  in
4907
        let fields =
4908
          if x.cond = IsNull
4909
          then fields
4910
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4911
            fields
4912
           in
4913
        let fields =
4914
          ("expr",
4915
            ((fun x  ->
4916
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
4917
               x.expr))
4918
          :: fields  in
4919
        `Assoc fields)
4920
  [@ocaml.warning "-A"])
4921

    
4922
and (vhdl_signal_condition_t_of_yojson :
4923
      Yojson.Safe.json ->
4924
        vhdl_signal_condition_t Ppx_deriving_yojson_runtime.error_or)
4925
  =
4926
  ((let open! Ppx_deriving_yojson_runtime in
4927
      function
4928
      | `Assoc xs ->
4929
          let rec loop xs ((arg0,arg1) as _state) =
4930
            match xs with
4931
            | ("expr",x)::xs ->
4932
                loop xs
4933
                  (((function
4934
                     | `List xs ->
4935
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4936
                     | _ ->
4937
                         Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr")
4938
                      x), arg1)
4939
            | ("cond",x)::xs ->
4940
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4941
            | [] ->
4942
                arg1 >>=
4943
                  ((fun arg1  ->
4944
                      arg0 >>=
4945
                        (fun arg0  -> Result.Ok { expr = arg0; cond = arg1 })))
4946
            | _::xs -> loop xs _state  in
4947
          loop xs
4948
            ((Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr"),
4949
              (Result.Ok IsNull))
4950
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_condition_t")
4951
  [@ocaml.warning "-A"])
4952

    
4953
type vhdl_signal_selection_t =
4954
  {
4955
  expr: vhdl_expr_t ;
4956
  when_sel: vhdl_expr_t list [@default []]}
4957

    
4958
(* TODO *)
4959
let rec pp_vhdl_signal_selection_t :
4960
  Format.formatter -> vhdl_signal_selection_t -> Ppx_deriving_runtime.unit =
4961
  let __1 () = pp_vhdl_expr_t
4962
  
4963
  and __0 () = pp_vhdl_expr_t
4964
   in
4965
  ((let open! Ppx_deriving_runtime in
4966
      fun fmt  ->
4967
        fun x  ->
4968
          Format.fprintf fmt "@[<2>{ ";
4969
          ((Format.fprintf fmt "@[%s =@ " "expr";
4970
            ((__0 ()) fmt) x.expr;
4971
            Format.fprintf fmt "@]");
4972
           Format.fprintf fmt ";@ ";
4973
           Format.fprintf fmt "@[%s =@ " "when_sel";
4974
           ((fun x  ->
4975
               Format.fprintf fmt "@[<2>[";
4976
               ignore
4977
                 (List.fold_left
4978
                    (fun sep  ->
4979
                       fun x  ->
4980
                         if sep then Format.fprintf fmt ";@ ";
4981
                         ((__1 ()) fmt) x;
4982
                         true) false x);
4983
               Format.fprintf fmt "@,]@]")) x.when_sel;
4984
           Format.fprintf fmt "@]");
4985
          Format.fprintf fmt "@ }@]")
4986
    [@ocaml.warning "-A"])
4987

    
4988
and show_vhdl_signal_selection_t :
4989
  vhdl_signal_selection_t -> Ppx_deriving_runtime.string =
4990
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_selection_t x
4991

    
4992
let rec (vhdl_signal_selection_t_to_yojson :
4993
          vhdl_signal_selection_t -> Yojson.Safe.json)
4994
  =
4995
  ((let open! Ppx_deriving_yojson_runtime in
4996
      fun x  ->
4997
        let fields = []  in
4998
        let fields =
4999
          if x.when_sel = []
5000
          then fields
5001
          else
5002
            ("when_sel",
5003
              (((fun x  ->
5004
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
5005
                 x.when_sel))
5006
            :: fields
5007
           in
5008
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
5009
          :: fields  in
5010
        `Assoc fields)
5011
  [@ocaml.warning "-A"])
5012

    
5013
and (vhdl_signal_selection_t_of_yojson :
5014
      Yojson.Safe.json ->
5015
        vhdl_signal_selection_t Ppx_deriving_yojson_runtime.error_or)
5016
  =
5017
  ((let open! Ppx_deriving_yojson_runtime in
5018
      function
5019
      | `Assoc xs ->
5020
          let rec loop xs ((arg0,arg1) as _state) =
5021
            match xs with
5022
            | ("expr",x)::xs ->
5023
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
5024
            | ("when_sel",x)::xs ->
5025
                loop xs
5026
                  (arg0,
5027
                    ((function
5028
                      | `List xs ->
5029
                          map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
5030
                      | _ ->
5031
                          Result.Error
5032
                            "Vhdl_ast.vhdl_signal_selection_t.when_sel") x))
5033
            | [] ->
5034
                arg1 >>=
5035
                  ((fun arg1  ->
5036
                      arg0 >>=
5037
                        (fun arg0  ->
5038
                           Result.Ok { expr = arg0; when_sel = arg1 })))
5039
            | _::xs -> loop xs _state  in
5040
          loop xs
5041
            ((Result.Error "Vhdl_ast.vhdl_signal_selection_t.expr"),
5042
              (Result.Ok []))
5043
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_selection_t")
5044
  [@ocaml.warning "-A"])
5045

    
5046
type vhdl_conditional_signal_t =
5047
  {
5048
  postponed: bool [@default false];
5049
  label: vhdl_name_t [@default NoName];
5050
  lhs: vhdl_name_t ;
5051
  rhs: vhdl_signal_condition_t list ;
5052
  cond: vhdl_expr_t [@default IsNull];
5053
  delay: vhdl_expr_t [@default IsNull]}
5054

    
5055
let rec pp_vhdl_conditional_signal_t :
5056
  Format.formatter -> vhdl_conditional_signal_t -> Ppx_deriving_runtime.unit
5057
  =
5058
  let __4 () = pp_vhdl_expr_t
5059
  
5060
  and __3 () = pp_vhdl_expr_t
5061
  
5062
  and __2 () = pp_vhdl_signal_condition_t
5063
  
5064
  and __1 () = pp_vhdl_name_t
5065
  
5066
  and __0 () = pp_vhdl_name_t
5067
   in
5068
  ((let open! Ppx_deriving_runtime in
5069
      fun fmt  ->
5070
        fun x  ->
5071
          (match x.label with
5072
            | NoName -> Format.fprintf fmt "";
5073
            | _ -> (((__0 ()) fmt) x.label;
5074
                   Format.fprintf fmt ":@ ")
5075
          );
5076
          if (x.postponed) then Format.fprintf fmt "postponed@ ";
5077
          ((__1 ()) fmt) x.lhs;
5078
          Format.fprintf fmt " <= ";
5079
          (match x.delay with
5080
            | IsNull -> Format.fprintf fmt "";
5081
            | _ -> ((__4 ()) fmt) x.delay;
5082
                   Format.fprintf fmt " ");
5083
          ((fun x  ->
5084
             Format.fprintf fmt "@[";
5085
             ignore
5086
               (List.fold_left
5087
                 (fun sep  ->
5088
                   fun x  ->
5089
                     if sep then Format.fprintf fmt "";
5090
                      ((__2 ()) fmt) x;
5091
                      Format.fprintf fmt ";";
5092
                      true) false x);
5093
          Format.fprintf fmt "@]")) x.rhs;
5094
          (match x.cond with
5095
            | IsNull -> Format.fprintf fmt "";
5096
            | _ -> Format.fprintf fmt "when (";
5097
                   ((__3 ()) fmt) x.cond;
5098
                   Format.fprintf fmt ")"))
5099
   [@ocaml.warning "-A"])
5100

    
5101
and show_vhdl_conditional_signal_t :
5102
  vhdl_conditional_signal_t -> Ppx_deriving_runtime.string =
5103
  fun x  -> Format.asprintf "%a" pp_vhdl_conditional_signal_t x
5104

    
5105
let rec (vhdl_conditional_signal_t_to_yojson :
5106
          vhdl_conditional_signal_t -> Yojson.Safe.json)
5107
  =
5108
  ((let open! Ppx_deriving_yojson_runtime in
5109
      fun x  ->
5110
        let fields = []  in
5111
        let fields =
5112
          if x.delay = IsNull
5113
          then fields
5114
          else ("delay", (((fun x  -> vhdl_expr_t_to_yojson x)) x.delay)) ::
5115
            fields
5116
           in
5117
        let fields =
5118
          if x.cond = IsNull
5119
          then fields
5120
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
5121
            fields
5122
           in
5123
        let fields =
5124
          ("rhs",
5125
            ((fun x  ->
5126
                `List
5127
                  (List.map (fun x  -> vhdl_signal_condition_t_to_yojson x) x))
5128
               x.rhs))
5129
          :: fields  in
5130
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
5131
          fields  in
5132
        let fields =
5133
          if x.label = NoName
5134
          then fields
5135
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
5136
            fields
5137
           in
5138
        let fields =
5139
          if x.postponed = false
5140
          then fields
5141
          else
5142
            ("postponed",
5143
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
5144
                 x.postponed))
5145
            :: fields
5146
           in
5147
        `Assoc fields)
5148
  [@ocaml.warning "-A"])
5149

    
5150
and (vhdl_conditional_signal_t_of_yojson :
5151
      Yojson.Safe.json ->
5152
        vhdl_conditional_signal_t Ppx_deriving_yojson_runtime.error_or)
5153
  =
5154
  ((let open! Ppx_deriving_yojson_runtime in
5155
      function
5156
      | `Assoc xs ->
5157
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
5158
            match xs with
5159
            | ("postponed",x)::xs ->
5160
                loop xs
5161
                  (((function
5162
                     | `Bool x -> Result.Ok x
5163
                     | _ ->
5164
                         Result.Error
5165
                           "Vhdl_ast.vhdl_conditional_signal_t.postponed") x),
5166
                    arg1, arg2, arg3, arg4, arg5)
5167
            | ("label",x)::xs ->
5168
                loop xs
5169
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
5170
                    arg4, arg5)
5171
            | ("lhs",x)::xs ->
5172
                loop xs
5173
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
5174
                    arg4, arg5)
5175
            | ("rhs",x)::xs ->
5176
                loop xs
5177
                  (arg0, arg1, arg2,
5178
                    ((function
5179
                      | `List xs ->
5180
                          map_bind
5181
                            (fun x  -> vhdl_signal_condition_t_of_yojson x)
5182
                            [] xs
5183
                      | _ ->
5184
                          Result.Error
5185
                            "Vhdl_ast.vhdl_conditional_signal_t.rhs") x),
5186
                    arg4, arg5)
5187
            | ("cond",x)::xs ->
5188
                loop xs
5189
                  (arg0, arg1, arg2, arg3,
5190
                    ((fun x  -> vhdl_expr_t_of_yojson x) x), arg5)
5191
            | ("delay",x)::xs ->
5192
                loop xs
5193
                  (arg0, arg1, arg2, arg3, arg4,
5194
                    ((fun x  -> vhdl_expr_t_of_yojson x) x))
5195
            | [] ->
5196
                arg5 >>=
5197
                  ((fun arg5  ->
5198
                      arg4 >>=
5199
                        (fun arg4  ->
5200
                           arg3 >>=
5201
                             (fun arg3  ->
5202
                                arg2 >>=
5203
                                  (fun arg2  ->
5204
                                     arg1 >>=
5205
                                       (fun arg1  ->
5206
                                          arg0 >>=
5207
                                            (fun arg0  ->
5208
                                               Result.Ok
5209
                                                 {
5210
                                                   postponed = arg0;
5211
                                                   label = arg1;
5212
                                                   lhs = arg2;
5213
                                                   rhs = arg3;
5214
                                                   cond = arg4;
5215
                                                   delay = arg5
5216
                                                 })))))))
5217
            | _::xs -> loop xs _state  in
5218
          loop xs
5219
            ((Result.Ok false), (Result.Ok NoName),
5220
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.lhs"),
5221
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.rhs"),
5222
              (Result.Ok IsNull), (Result.Ok IsNull))
5223
      | _ -> Result.Error "Vhdl_ast.vhdl_conditional_signal_t")
5224
  [@ocaml.warning "-A"])
5225

    
5226
type vhdl_process_t =
5227
  {
5228
  id: vhdl_name_t [@default NoName];
5229
  declarations: vhdl_declarative_item_t list
5230
    [@key "PROCESS_DECLARATIVE_PART"][@default Some []];
5231
  active_sigs: vhdl_name_t list [@default []];
5232
  body: vhdl_sequential_stmt_t list
5233
    [@key "PROCESS_STATEMENT_PART"][@default []]}
5234

    
5235
let rec pp_vhdl_process_t :
5236
  Format.formatter -> vhdl_process_t -> Ppx_deriving_runtime.unit =
5237
  let __3 () = pp_vhdl_sequential_stmt_t
5238
  
5239
  and __2 () = pp_vhdl_name_t
5240
  
5241
  and __1 () = pp_vhdl_declarative_item_t
5242
  
5243
  and __0 () = pp_vhdl_name_t
5244
   in
5245
  ((let open! Ppx_deriving_runtime in
5246
      fun fmt  ->
5247
        fun x  ->
5248
          Format.fprintf fmt "@[<v 2>";
5249
          (match x.id with
5250
          | NoName -> Format.fprintf fmt "";
5251
          | _ -> 
5252
              ((__0 ()) fmt) x.id;
5253
              Format.fprintf fmt ": ");
5254
          Format.fprintf fmt "process ";
5255
          (match x.active_sigs with
5256
          | [] -> Format.fprintf fmt "";
5257
          | _ -> Format.fprintf fmt "(";
5258
                 ((fun x  ->
5259
                    ignore
5260
                      (List.fold_left
5261
                         (fun sep  ->
5262
                            fun x  ->
5263
                              if sep then Format.fprintf fmt ",";
5264
                              ((__2 ()) fmt) x;
5265
                              true) false x))) x.active_sigs;
5266
                 Format.fprintf fmt ")");
5267
          Format.fprintf fmt " is@;";
5268
          ((fun x  ->
5269
            ignore
5270
            (List.fold_left
5271
              (fun sep  ->
5272
                fun x  ->
5273
                  if sep then Format.fprintf fmt "@;";
5274
                    ((__1 ()) fmt) x;
5275
                    Format.fprintf fmt ";";
5276
                    true) false x))) x.declarations;
5277
          Format.fprintf fmt "@]@;@[<v 2>begin@;";
5278
          ((fun x  ->
5279
               ignore
5280
                 (List.fold_left
5281
                    (fun sep  ->
5282
                       fun x  ->
5283
                         if sep then Format.fprintf fmt "@;";
5284
                         ((__3 ()) fmt) x;
5285
                         Format.fprintf fmt ";";
5286
                         true) false x);)) x.body;
5287
          Format.fprintf fmt "@]@;end process;@;";
5288
          Format.fprintf fmt "@]";)
5289
    [@ocaml.warning "-A"])
5290

    
5291
and show_vhdl_process_t : vhdl_process_t -> Ppx_deriving_runtime.string =
5292
  fun x  -> Format.asprintf "%a" pp_vhdl_process_t x
5293

    
5294
let rec (vhdl_process_t_to_yojson : vhdl_process_t -> Yojson.Safe.json) =
5295
  ((let open! Ppx_deriving_yojson_runtime in
5296
      fun x  ->
5297
        let fields = []  in
5298
        let fields =
5299
          if x.body = []
5300
          then fields
5301
          else
5302
            ("PROCESS_STATEMENT_PART",
5303
              (((fun x  ->
5304
                   `List
5305
                     (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x)
5306
                        x))) x.body))
5307
            :: fields
5308
           in
5309
        let fields =
5310
          if x.active_sigs = []
5311
          then fields
5312
          else
5313
            ("active_sigs",
5314
              (((fun x  ->
5315
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
5316
                 x.active_sigs))
5317
            :: fields
5318
           in
5319
        let fields =
5320
          if x.declarations = []
5321
          then fields
5322
          else
5323
            ("PROCESS_DECLARATIVE_PART",
5324
              (((fun x  ->
5325
                   `List
5326
                     (List.map
5327
                        (fun x  -> vhdl_declarative_item_t_to_yojson x) x)))
5328
                 x.declarations))
5329
            :: fields
5330
           in
5331
        let fields =
5332
          if x.id = NoName
5333
          then fields
5334
          else ("id", (((fun x  -> vhdl_name_t_to_yojson x)) x.id)) :: fields
5335
           in
5336
        `Assoc fields)
5337
  [@ocaml.warning "-A"])
5338

    
5339
and (vhdl_process_t_of_yojson :
5340
      Yojson.Safe.json -> vhdl_process_t Ppx_deriving_yojson_runtime.error_or)
5341
  =
5342
  ((let open! Ppx_deriving_yojson_runtime in
5343
      function
5344
      | `Assoc xs ->
5345
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
5346
            match xs with
5347
            | ("id",x)::xs ->
5348
                loop xs
5349
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3)
5350
            | ("PROCESS_DECLARATIVE_PART",x)::xs ->
5351
                loop xs
5352
                  (arg0,
5353
                    ((function
5354
                      | `List xs ->
5355
                          map_bind
5356
                            (fun x  -> vhdl_declarative_item_t_of_yojson x)
5357
                            [] xs
5358
                      | _ ->
5359
                          Result.Error "Vhdl_ast.vhdl_process_t.declarations")
5360
                       x), arg2, arg3)
5361
            | ("active_sigs",x)::xs ->
5362
                loop xs
5363
                  (arg0, arg1,
5364
                    ((function
5365
                      | `List xs ->
5366
                          map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5367
                      | _ ->
5368
                          Result.Error "Vhdl_ast.vhdl_process_t.active_sigs")
5369
                       x), arg3)
5370
            | ("PROCESS_STATEMENT_PART",x)::xs ->
5371
                loop xs
5372
                  (arg0, arg1, arg2,
5373
                    ((function
5374
                      | `List xs ->
5375
                          map_bind
5376
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
5377
                            xs
5378
                      | _ -> Result.Error "Vhdl_ast.vhdl_process_t.body") x))
5379
            | [] ->
5380
                arg3 >>=
5381
                  ((fun arg3  ->
5382
                      arg2 >>=
5383
                        (fun arg2  ->
5384
                           arg1 >>=
5385
                             (fun arg1  ->
5386
                                arg0 >>=
5387
                                  (fun arg0  ->
5388
                                     Result.Ok
5389
                                       {
5390
                                         id = arg0;
5391
                                         declarations = arg1;
5392
                                         active_sigs = arg2;
5393
                                         body = arg3
5394
                                       })))))
5395
            | _::xs -> loop xs _state  in
5396
          loop xs
5397
            ((Result.Ok NoName), (Result.Ok []), (Result.Ok []),
5398
              (Result.Ok []))
5399
      | _ -> Result.Error "Vhdl_ast.vhdl_process_t")
5400
  [@ocaml.warning "-A"])
5401

    
5402
type vhdl_selected_signal_t =
5403
  {
5404
  postponed: bool [@default false];
5405
  label: vhdl_name_t [@default NoName];
5406
  lhs: vhdl_name_t ;
5407
  sel: vhdl_expr_t ;
5408
  branches: vhdl_signal_selection_t list [@default []];
5409
  delay: vhdl_expr_t option }
5410

    
5411
(* TODO *)
5412
let rec pp_vhdl_selected_signal_t :
5413
  Format.formatter -> vhdl_selected_signal_t -> Ppx_deriving_runtime.unit =
5414
  let __4 () = pp_vhdl_expr_t
5415
  
5416
  and __3 () = pp_vhdl_signal_selection_t
5417
  
5418
  and __2 () = pp_vhdl_expr_t
5419
  
5420
  and __1 () = pp_vhdl_name_t
5421
  
5422
  and __0 () = pp_vhdl_name_t
5423
   in
5424
  ((let open! Ppx_deriving_runtime in
5425
      fun fmt  ->
5426
        fun x  ->
5427
          Format.fprintf fmt "@[<2>{ ";
5428
          ((((((Format.fprintf fmt "@[%s =@ " "postponed";
5429
                (Format.fprintf fmt "%B") x.postponed;
5430
                Format.fprintf fmt "@]");
5431
               Format.fprintf fmt ";@ ";
5432
               Format.fprintf fmt "@[%s =@ " "label";
5433
               ((__0 ()) fmt) x.label;
5434
               Format.fprintf fmt "@]");
5435
              Format.fprintf fmt ";@ ";
5436
              Format.fprintf fmt "@[%s =@ " "lhs";
5437
              ((__1 ()) fmt) x.lhs;
5438
              Format.fprintf fmt "@]");
5439
             Format.fprintf fmt ";@ ";
5440
             Format.fprintf fmt "@[%s =@ " "sel";
5441
             ((__2 ()) fmt) x.sel;
5442
             Format.fprintf fmt "@]");
5443
            Format.fprintf fmt ";@ ";
5444
            Format.fprintf fmt "@[%s =@ " "branches";
5445
            ((fun x  ->
5446
                Format.fprintf fmt "@[<2>[";
5447
                ignore
5448
                  (List.fold_left
5449
                     (fun sep  ->
5450
                        fun x  ->
5451
                          if sep then Format.fprintf fmt ";@ ";
5452
                          ((__3 ()) fmt) x;
5453
                          true) false x);
5454
                Format.fprintf fmt "@,]@]")) x.branches;
5455
            Format.fprintf fmt "@]");
5456
           Format.fprintf fmt ";@ ";
5457
           Format.fprintf fmt "@[%s =@ " "delay";
5458
           ((function
5459
             | None  -> Format.pp_print_string fmt "None"
5460
             | Some x ->
5461
                 (Format.pp_print_string fmt "(Some ";
5462
                  ((__4 ()) fmt) x;
5463
                  Format.pp_print_string fmt ")"))) x.delay;
5464
           Format.fprintf fmt "@]");
5465
          Format.fprintf fmt "@ }@]")
5466
    [@ocaml.warning "-A"])
5467

    
5468
and show_vhdl_selected_signal_t :
5469
  vhdl_selected_signal_t -> Ppx_deriving_runtime.string =
5470
  fun x  -> Format.asprintf "%a" pp_vhdl_selected_signal_t x
5471

    
5472
let rec (vhdl_selected_signal_t_to_yojson :
5473
          vhdl_selected_signal_t -> Yojson.Safe.json)
5474
  =
5475
  ((let open! Ppx_deriving_yojson_runtime in
5476
      fun x  ->
5477
        let fields = []  in
5478
        let fields =
5479
          ("delay",
5480
            ((function
5481
              | None  -> `Null
5482
              | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x) x.delay))
5483
          :: fields  in
5484
        let fields =
5485
          if x.branches = []
5486