Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (233 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 ;
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 ;
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
                     ((__2 ()) fmt) x)) aunit_name;
467
        | Op { id = aid; args = aargs } ->
468
            (match aargs with
469
            | [] -> (Format.fprintf fmt "%s") aid;
470
            | hd::[] ->
471
               (Format.fprintf fmt "%s") aid;
472
               ((__3 ()) fmt) hd
473
            | hd::(hd2::[]) -> 
474
               ((__3 ()) fmt) hd;
475
               (Format.fprintf fmt " %s ") aid;
476
               ((__3 ()) fmt) hd2
477
            | _ ->
478
            (Format.fprintf fmt "@[<2>Op {@,";
479
             ((Format.fprintf fmt "@[%s =@ " "id";
480
               (Format.fprintf fmt "%S") aid;
481
               Format.fprintf fmt "@]");
482
              Format.fprintf fmt ";@ ";
483
              Format.fprintf fmt "@[%s =@ " "args";
484
              ((fun x  ->
485
                  Format.fprintf fmt "@[<2>[";
486
                  ignore
487
                    (List.fold_left
488
                       (fun sep  ->
489
                          fun x  ->
490
                            if sep then Format.fprintf fmt ";@ ";
491
                            ((__3 ()) fmt) x;
492
                            true) false x);
493
                  Format.fprintf fmt "@,]@]")) aargs;
494
              Format.fprintf fmt "@]");
495
             Format.fprintf fmt "@]}"))
496
        | IsNull  -> Format.pp_print_string fmt ""
497
        | Time { value = avalue; phy_unit = aphy_unit } ->
498
            (Format.fprintf fmt "@[<2>Time {@,";
499
             ((Format.fprintf fmt "@[%s =@ " "value";
500
               (Format.fprintf fmt "%d") avalue;
501
               Format.fprintf fmt "@]");
502
              Format.fprintf fmt ";@ ";
503
              Format.fprintf fmt "@[%s =@ " "phy_unit";
504
              (Format.fprintf fmt "%S") aphy_unit;
505
              Format.fprintf fmt "@]");
506
             Format.fprintf fmt "@]}")
507
        | Sig { name = aname; att = aatt } ->
508
            (Format.fprintf fmt "--@[<2>Sig {@,";
509
             ((Format.fprintf fmt "@[%s =@ " "name";
510
               ((__4 ()) fmt) aname;
511
               Format.fprintf fmt "@]");
512
              Format.fprintf fmt ";@ ";
513
              Format.fprintf fmt "@[%s =@ " "att";
514
              ((function
515
                | None  -> Format.pp_print_string fmt "None"
516
                | Some x ->
517
                    (Format.pp_print_string fmt "(Some ";
518
                     ((__5 ()) fmt) x;
519
                     Format.pp_print_string fmt ")"))) aatt;
520
              Format.fprintf fmt "@]");
521
             Format.fprintf fmt "@]}")
522
        | SuffixMod { expr = aexpr; selection = aselection } ->
523
            (Format.fprintf fmt "--@[<2>SuffixMod {@,";
524
             ((Format.fprintf fmt "@[%s =@ " "expr";
525
               ((__6 ()) fmt) aexpr;
526
               Format.fprintf fmt "@]");
527
              Format.fprintf fmt ";@ ";
528
              Format.fprintf fmt "@[%s =@ " "selection";
529
              ((__7 ()) fmt) aselection;
530
              Format.fprintf fmt "@]");
531
             Format.fprintf fmt "@]}")
532
        | Aggregate { elems = aelems } ->
533
            (Format.fprintf fmt "--@[<2>Aggregate {@,";
534
             (Format.fprintf fmt "@[%s =@ " "elems";
535
              ((fun x  ->
536
                  Format.fprintf fmt "@[<2>[";
537
                  ignore
538
                    (List.fold_left
539
                       (fun sep  ->
540
                          fun x  ->
541
                            if sep then Format.fprintf fmt ";@ ";
542
                            ((__8 ()) fmt) x;
543
                            true) false x);
544
                  Format.fprintf fmt "@,]@]")) aelems;
545
              Format.fprintf fmt "@]");
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
                Format.fprintf fmt "@[<2>[";
702
                ignore
703
                  (List.fold_left
704
                     (fun sep  ->
705
                        fun x  ->
706
                          if sep then Format.fprintf fmt "|@ ";
707
                          ((__0 ()) fmt) x;
708
                          true) false x))) x.choices;
709
              Format.fprintf fmt " => ";));
710
           ((__1 ()) fmt) x.expr)
711
    [@ocaml.warning "-A"])
712

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2047
and (vhdl_element_assoc_t_to_yojson :
2048
      vhdl_element_assoc_t -> Yojson.Safe.json)
2049
  =
2050
  ((let open! Ppx_deriving_yojson_runtime in
2051
      fun x  ->
2052
        let fields = []  in
2053
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
2054
          :: fields  in
2055
        let fields =
2056
          ("choices",
2057
            ((fun x  ->
2058
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
2059
               x.choices))
2060
          :: fields  in
2061
        `Assoc fields)
2062
  [@ocaml.warning "-A"])
2063

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

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

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

    
2161
and (vhdl_signal_attributes_t_to_yojson :
2162
      vhdl_signal_attributes_t -> Yojson.Safe.json)
2163
  =
2164
  ((let open! Ppx_deriving_yojson_runtime in
2165
      function
2166
      | SigAtt arg0 ->
2167
          `List
2168
            [`String "SigAtt";
2169
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
2170
  [@ocaml.warning "-A"])
2171

    
2172
and (vhdl_signal_attributes_t_of_yojson :
2173
      Yojson.Safe.json ->
2174
        vhdl_signal_attributes_t Ppx_deriving_yojson_runtime.error_or)
2175
  =
2176
  ((let open! Ppx_deriving_yojson_runtime in
2177
      function
2178
      | `List ((`String "SigAtt")::arg0::[]) ->
2179
          ((function
2180
            | `String x -> Result.Ok x
2181
            | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t") arg0)
2182
            >>= ((fun arg0  -> Result.Ok (SigAtt arg0)))
2183
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t")
2184
  [@ocaml.warning "-A"])
2185

    
2186
and (vhdl_string_attributes_t_to_yojson :
2187
      vhdl_string_attributes_t -> Yojson.Safe.json)
2188
  =
2189
  ((let open! Ppx_deriving_yojson_runtime in
2190
      function
2191
      | StringAtt arg0 ->
2192
          `List
2193
            [`String "StringAtt";
2194
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
2195
  [@ocaml.warning "-A"])
2196

    
2197
and (vhdl_string_attributes_t_of_yojson :
2198
      Yojson.Safe.json ->
2199
        vhdl_string_attributes_t Ppx_deriving_yojson_runtime.error_or)
2200
  =
2201
  ((let open! Ppx_deriving_yojson_runtime in
2202
      function
2203
      | `List ((`String "StringAtt")::arg0::[]) ->
2204
          ((function
2205
            | `String x -> Result.Ok x
2206
            | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t") arg0)
2207
            >>= ((fun arg0  -> Result.Ok (StringAtt arg0)))
2208
      | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t")
2209
  [@ocaml.warning "-A"])
2210

    
2211
and (vhdl_suffix_selection_t_to_yojson :
2212
      vhdl_suffix_selection_t -> Yojson.Safe.json)
2213
  =
2214
  ((let open! Ppx_deriving_yojson_runtime in
2215
      function
2216
      | Idx arg0 ->
2217
          `List
2218
            [`String "Idx";
2219
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0]
2220
      | SuffixRange (arg0,arg1) ->
2221
          `List
2222
            [`String "SuffixRange";
2223
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
2224
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1])
2225
  [@ocaml.warning "-A"])
2226

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

    
2251
type 'basetype vhdl_type_attributes_t =
2252
  | TAttNoArg of {
2253
  id: string } 
2254
  | TAttIntArg of {
2255
  id: string ;
2256
  arg: int } 
2257
  | TAttValArg of {
2258
  id: string ;
2259
  arg: 'basetype } 
2260
  | TAttStringArg of {
2261
  id: string ;
2262
  arg: string } 
2263

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

    
2309
and show_vhdl_type_attributes_t  =
2310
  fun poly_basetype  ->
2311
    fun x  ->
2312
      Format.asprintf "%a" (pp_vhdl_type_attributes_t poly_basetype) x
2313

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

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

    
2502
let typ_att_noarg = ["base"; "left"; "right"; "high"; "low"] 
2503
let typ_att_intarg = ["pos"; "val"; "succ"; "pred"; "leftof"; "rightof"] 
2504
let typ_att_valarg = ["image"] 
2505
let typ_att_stringarg = ["value"] 
2506
let array_att_intarg =
2507
  ["left"; "right"; "high"; "low"; "range"; "reverse_range"; "length"] 
2508
type vhdl_parameter_t =
2509
  {
2510
  names: vhdl_name_t list ;
2511
  mode: string list [@default []];
2512
  typ: vhdl_subtype_indication_t ;
2513
  init_val: vhdl_cst_val_t option [@default None]}
2514

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

    
2569
and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string =
2570
  fun x  -> Format.asprintf "%a" pp_vhdl_parameter_t x
2571

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

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

    
2677
type vhdl_subprogram_spec_t =
2678
  {
2679
  name: string [@default ""];
2680
  typeMark: vhdl_name_t [@default NoName];
2681
  parameters: vhdl_parameter_t list ;
2682
  isPure: bool [@default false]}
2683

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

    
2722
and show_vhdl_subprogram_spec_t :
2723
  vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string =
2724
  fun x  -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x
2725

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

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

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

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

    
3111
and show_vhdl_sequential_stmt_t :
3112
  vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string =
3113
  fun x  -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x
3114

    
3115
and pp_vhdl_if_case_t :
3116
  Format.formatter -> vhdl_if_case_t -> Ppx_deriving_runtime.unit =
3117
  let __1 () = pp_vhdl_sequential_stmt_t
3118
  
3119
  and __0 () = pp_vhdl_expr_t
3120
   in
3121
  ((let open! Ppx_deriving_runtime in
3122
      fun fmt  ->
3123
        fun x  ->
3124
          Format.fprintf fmt " (";
3125
          ((__0 ()) fmt) x.if_cond;
3126
          Format.fprintf fmt ") then@;<0 2>";
3127
          ((fun x  ->
3128
             ignore
3129
               (List.fold_left
3130
                  (fun sep  ->
3131
                     fun x  ->
3132
                             if sep then Format.fprintf fmt "@;<0 2>";
3133
                       ((__1 ()) fmt) x;
3134
                       true) false x);
3135
          )) x.if_block;)
3136
    [@ocaml.warning "-A"])
3137

    
3138
and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string =
3139
  fun x  -> Format.asprintf "%a" pp_vhdl_if_case_t x
3140

    
3141
and pp_vhdl_case_item_t :
3142
  Format.formatter -> vhdl_case_item_t -> Ppx_deriving_runtime.unit =
3143
  let __1 () = pp_vhdl_sequential_stmt_t
3144
  
3145
  and __0 () = pp_vhdl_expr_t
3146
   in
3147
  ((let open! Ppx_deriving_runtime in
3148
      fun fmt  ->
3149
        fun x  ->
3150
                Format.fprintf fmt "@;<0 2>when ";
3151
            ((fun x  ->
3152
                ignore
3153
                  (List.fold_left
3154
                     (fun sep  ->
3155
                        fun x  ->
3156
                          if sep then Format.fprintf fmt "@ |@ ";
3157
                          ((__0 ()) fmt) x;
3158
                          true) false x);)) x.when_cond;
3159
           Format.fprintf fmt " => ";
3160
           ((fun x  ->
3161
               ignore
3162
                 (List.fold_left
3163
                    (fun sep  ->
3164
                       fun x  ->
3165
                         if sep then Format.fprintf fmt "";
3166
                         ((__1 ()) fmt) x;
3167
                         true) false x);)) x.when_stmt)
3168
    [@ocaml.warning "-A"])
3169

    
3170
and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string =
3171
  fun x  -> Format.asprintf "%a" pp_vhdl_case_item_t x
3172

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

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

    
3736
and (vhdl_if_case_t_to_yojson : vhdl_if_case_t -> Yojson.Safe.json) =
3737
  ((let open! Ppx_deriving_yojson_runtime in
3738
      fun x  ->
3739
        let fields = []  in
3740
        let fields =
3741
          ("if_block",
3742
            ((fun x  ->
3743
                `List
3744
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3745
               x.if_block))
3746
          :: fields  in
3747
        let fields =
3748
          ("if_cond", ((fun x  -> vhdl_expr_t_to_yojson x) x.if_cond)) ::
3749
          fields  in
3750
        `Assoc fields)
3751
  [@ocaml.warning "-A"])
3752

    
3753
and (vhdl_if_case_t_of_yojson :
3754
      Yojson.Safe.json -> vhdl_if_case_t Ppx_deriving_yojson_runtime.error_or)
3755
  =
3756
  ((let open! Ppx_deriving_yojson_runtime in
3757
      function
3758
      | `Assoc xs ->
3759
          let rec loop xs ((arg0,arg1) as _state) =
3760
            match xs with
3761
            | ("if_cond",x)::xs ->
3762
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
3763
            | ("if_block",x)::xs ->
3764
                loop xs
3765
                  (arg0,
3766
                    ((function
3767
                      | `List xs ->
3768
                          map_bind
3769
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3770
                            xs
3771
                      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t.if_block")
3772
                       x))
3773
            | [] ->
3774
                arg1 >>=
3775
                  ((fun arg1  ->
3776
                      arg0 >>=
3777
                        (fun arg0  ->
3778
                           Result.Ok { if_cond = arg0; if_block = arg1 })))
3779
            | _::xs -> loop xs _state  in
3780
          loop xs
3781
            ((Result.Error "Vhdl_ast.vhdl_if_case_t.if_cond"),
3782
              (Result.Error "Vhdl_ast.vhdl_if_case_t.if_block"))
3783
      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t")
3784
  [@ocaml.warning "-A"])
3785

    
3786
and (vhdl_case_item_t_to_yojson : vhdl_case_item_t -> Yojson.Safe.json) =
3787
  ((let open! Ppx_deriving_yojson_runtime in
3788
      fun x  ->
3789
        let fields = []  in
3790
        let fields =
3791
          ("when_stmt",
3792
            ((fun x  ->
3793
                `List
3794
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3795
               x.when_stmt))
3796
          :: fields  in
3797
        let fields =
3798
          ("when_cond",
3799
            ((fun x  ->
3800
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
3801
               x.when_cond))
3802
          :: fields  in
3803
        `Assoc fields)
3804
  [@ocaml.warning "-A"])
3805

    
3806
and (vhdl_case_item_t_of_yojson :
3807
      Yojson.Safe.json ->
3808
        vhdl_case_item_t Ppx_deriving_yojson_runtime.error_or)
3809
  =
3810
  ((let open! Ppx_deriving_yojson_runtime in
3811
      function
3812
      | `Assoc xs ->
3813
          let rec loop xs ((arg0,arg1) as _state) =
3814
            match xs with
3815
            | ("when_cond",x)::xs ->
3816
                loop xs
3817
                  (((function
3818
                     | `List xs ->
3819
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
3820
                     | _ ->
3821
                         Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond")
3822
                      x), arg1)
3823
            | ("when_stmt",x)::xs ->
3824
                loop xs
3825
                  (arg0,
3826
                    ((function
3827
                      | `List xs ->
3828
                          map_bind
3829
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3830
                            xs
3831
                      | _ ->
3832
                          Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt")
3833
                       x))
3834
            | [] ->
3835
                arg1 >>=
3836
                  ((fun arg1  ->
3837
                      arg0 >>=
3838
                        (fun arg0  ->
3839
                           Result.Ok { when_cond = arg0; when_stmt = arg1 })))
3840
            | _::xs -> loop xs _state  in
3841
          loop xs
3842
            ((Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond"),
3843
              (Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt"))
3844
      | _ -> Result.Error "Vhdl_ast.vhdl_case_item_t")
3845
  [@ocaml.warning "-A"])
3846

    
3847
type vhdl_declaration_t =
3848
  | VarDecl of
3849
  {
3850
  names: vhdl_name_t list ;
3851
  typ: vhdl_subtype_indication_t ;
3852
  init_val: vhdl_expr_t [@default IsNull]} [@name "VARIABLE_DECLARATION"]
3853
  | CstDecl of
3854
  {
3855
  names: vhdl_name_t list ;
3856
  typ: vhdl_subtype_indication_t ;
3857
  init_val: vhdl_expr_t } [@name "CONSTANT_DECLARATION"]
3858
  | SigDecl of
3859
  {
3860
  names: vhdl_name_t list ;
3861
  typ: vhdl_subtype_indication_t ;
3862
  init_val: vhdl_expr_t [@default IsNull]} [@name "SIGNAL_DECLARATION"]
3863
  | Subprogram of
3864
  {
3865
  name: vhdl_name_t [@default NoName];
3866
  kind: string [@default ""];
3867
  spec: vhdl_subprogram_spec_t
3868
    [@default
3869
      { name = ""; typeMark = NoName; parameters = []; isPure = false }];
3870
  decl_part: vhdl_declaration_t list [@default []];
3871
  stmts: vhdl_sequential_stmt_t list [@default []]} [@name "SUBPROGRAM_BODY"]
3872

    
3873
(* Needs adaptation for: SubProgram *)
3874
let rec pp_vhdl_declaration_t :
3875
  Format.formatter -> vhdl_declaration_t -> Ppx_deriving_runtime.unit =
3876
  let __12 () = pp_vhdl_sequential_stmt_t
3877
  
3878
  and __11 () = pp_vhdl_declaration_t
3879
  
3880
  and __10 () = pp_vhdl_subprogram_spec_t
3881
  
3882
  and __9 () = pp_vhdl_name_t
3883
  
3884
  and __8 () = pp_vhdl_expr_t
3885
  
3886
  and __7 () = pp_vhdl_subtype_indication_t
3887
  
3888
  and __6 () = pp_vhdl_name_t
3889
  
3890
  and __5 () = pp_vhdl_expr_t
3891
  
3892
  and __4 () = pp_vhdl_subtype_indication_t
3893
  
3894
  and __3 () = pp_vhdl_name_t
3895
  
3896
  and __2 () = pp_vhdl_expr_t
3897
  
3898
  and __1 () = pp_vhdl_subtype_indication_t
3899
  
3900
  and __0 () = pp_vhdl_name_t
3901
   in
3902
  ((let open! Ppx_deriving_runtime in
3903
      fun fmt  ->
3904
        function
3905
        | VarDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3906
            (Format.fprintf fmt "variable ";
3907
             ((((fun x  ->
3908
                    ignore
3909
                      (List.fold_left
3910
                         (fun sep  ->
3911
                            fun x  ->
3912
                              if sep then Format.fprintf fmt ",";
3913
                              ((__0 ()) fmt) x;
3914
                              true) false x);)) anames;
3915
               Format.fprintf fmt " : ";
3916
               ((__1 ()) fmt) atyp;
3917
               (match ainit_val with
3918
                | IsNull  -> Format.pp_print_string fmt ""
3919
                | _ ->
3920
                    (Format.fprintf fmt ":=";
3921
                     ((__2 ()) fmt) ainit_val;))));)
3922
        | CstDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3923
            (Format.fprintf fmt "constant ";
3924
             ((((fun x  ->
3925
                    ignore
3926
                      (List.fold_left
3927
                         (fun sep  ->
3928
                            fun x  ->
3929
                              if sep then Format.fprintf fmt ",";
3930
                              ((__3 ()) fmt) x;
3931
                              true) false x);)) anames;
3932
               Format.fprintf fmt " : ";
3933
               ((__4 ()) fmt) atyp;
3934
              Format.fprintf fmt ":=";
3935
              ((__5 ()) fmt) ainit_val)))
3936
        | SigDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3937
            (Format.fprintf fmt "signal ";
3938
            ((fun x  ->
3939
              ignore
3940
              (List.fold_left
3941
                (fun sep  ->
3942
                  fun x  ->
3943
                    if sep then Format.fprintf fmt ",";
3944
                                ((__6 ()) fmt) x;
3945
                                true) false x);
3946
              )) anames;
3947
            Format.fprintf fmt " : ";
3948
            ((__7 ()) fmt) atyp;
3949
            (match ainit_val with
3950
              | IsNull  -> Format.pp_print_string fmt ""
3951
              | _ ->
3952
                  (Format.fprintf fmt ":=";
3953
                  ((__8 ()) fmt) ainit_val;)))
3954
        | Subprogram
3955
            { name = aname; kind = akind; spec = aspec;
3956
              decl_part = adecl_part; stmts = astmts }
3957
            ->
3958
            (Format.fprintf fmt "@[<2>Subprogram {@,";
3959
             (((((Format.fprintf fmt "@[%s =@ " "name";
3960
                  ((__9 ()) fmt) aname;
3961
                  Format.fprintf fmt "@]");
3962
                 Format.fprintf fmt ";@ ";
3963
                 Format.fprintf fmt "@[%s =@ " "kind";
3964
                 (Format.fprintf fmt "%S") akind;
3965
                 Format.fprintf fmt "@]");
3966
                Format.fprintf fmt ";@ ";
3967
                Format.fprintf fmt "@[%s =@ " "spec";
3968
                ((__10 ()) fmt) aspec;
3969
                Format.fprintf fmt "@]");
3970
               Format.fprintf fmt ";@ ";
3971
               Format.fprintf fmt "@[%s =@ " "decl_part";
3972
               ((fun x  ->
3973
                   Format.fprintf fmt "@[<2>[";
3974
                   ignore
3975
                     (List.fold_left
3976
                        (fun sep  ->
3977
                           fun x  ->
3978
                             if sep then Format.fprintf fmt ";@ ";
3979
                             ((__11 ()) fmt) x;
3980
                             true) false x);
3981
                   Format.fprintf fmt "@,]@]")) adecl_part;
3982
               Format.fprintf fmt "@]");
3983
              Format.fprintf fmt ";@ ";
3984
              Format.fprintf fmt "@[%s =@ " "stmts";
3985
              ((fun x  ->
3986
                  Format.fprintf fmt "@[<2>[";
3987
                  ignore
3988
                    (List.fold_left
3989
                       (fun sep  ->
3990
                          fun x  ->
3991
                            if sep then Format.fprintf fmt ";@ ";
3992
                            ((__12 ()) fmt) x;
3993
                            true) false x);
3994
                  Format.fprintf fmt "@,]@]")) astmts;
3995
              Format.fprintf fmt "@]");
3996
             Format.fprintf fmt "@]}"))
3997
    [@ocaml.warning "-A"])
3998

    
3999
and show_vhdl_declaration_t :
4000
  vhdl_declaration_t -> Ppx_deriving_runtime.string =
4001
  fun x  -> Format.asprintf "%a" pp_vhdl_declaration_t x
4002

    
4003
let rec (vhdl_declaration_t_to_yojson :
4004
          vhdl_declaration_t -> Yojson.Safe.json)
4005
  =
4006
  ((let open! Ppx_deriving_yojson_runtime in
4007
      function
4008
      | VarDecl arg0 ->
4009
          `List
4010
            [`String "VARIABLE_DECLARATION";
4011
            (let fields = []  in
4012
             let fields =
4013
               if arg0.init_val = IsNull
4014
               then fields
4015
               else
4016
                 ("init_val",
4017
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.init_val))
4018
                 :: fields
4019
                in
4020
             let fields =
4021
               ("typ",
4022
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
4023
               :: fields  in
4024
             let fields =
4025
               ("names",
4026
                 ((fun x  ->
4027
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
4028
                    arg0.names))
4029
               :: fields  in
4030
             `Assoc fields)]
4031
      | CstDecl arg0 ->
4032
          `List
4033
            [`String "CONSTANT_DECLARATION";
4034
            (let fields = []  in
4035
             let fields =
4036
               ("init_val",
4037
                 ((fun x  -> vhdl_expr_t_to_yojson x) arg0.init_val))
4038
               :: fields  in
4039
             let fields =
4040
               ("typ",
4041
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
4042
               :: fields  in
4043
             let fields =
4044
               ("names",
4045
                 ((fun x  ->
4046
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
4047
                    arg0.names))
4048
               :: fields  in
4049
             `Assoc fields)]
4050
      | SigDecl arg0 ->
4051
          `List
4052
            [`String "SIGNAL_DECLARATION";
4053
            (let fields = []  in
4054
             let fields =
4055
               if arg0.init_val = IsNull
4056
               then fields
4057
               else
4058
                 ("init_val",
4059
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.init_val))
4060
                 :: fields
4061
                in
4062
             let fields =
4063
               ("typ",
4064
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
4065
               :: fields  in
4066
             let fields =
4067
               ("names",
4068
                 ((fun x  ->
4069
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
4070
                    arg0.names))
4071
               :: fields  in
4072
             `Assoc fields)]
4073
      | Subprogram arg0 ->
4074
          `List
4075
            [`String "SUBPROGRAM_BODY";
4076
            (let fields = []  in
4077
             let fields =
4078
               if arg0.stmts = []
4079
               then fields
4080
               else
4081
                 ("stmts",
4082
                   (((fun x  ->
4083
                        `List
4084
                          (List.map
4085
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
4086
                      arg0.stmts))
4087
                 :: fields
4088
                in
4089
             let fields =
4090
               if arg0.decl_part = []
4091
               then fields
4092
               else
4093
                 ("decl_part",
4094
                   (((fun x  ->
4095
                        `List
4096
                          (List.map
4097
                             (fun x  -> vhdl_declaration_t_to_yojson x) x)))
4098
                      arg0.decl_part))
4099
                 :: fields
4100
                in
4101
             let fields =
4102
               if
4103
                 arg0.spec =
4104
                   {
4105
                     name = "";
4106
                     typeMark = NoName;
4107
                     parameters = [];
4108
                     isPure = false
4109
                   }
4110
               then fields
4111
               else
4112
                 ("spec",
4113
                   (((fun x  -> vhdl_subprogram_spec_t_to_yojson x))
4114
                      arg0.spec))
4115
                 :: fields
4116
                in
4117
             let fields =
4118
               if arg0.kind = ""
4119
               then fields
4120
               else
4121
                 ("kind",
4122
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
4123
                      arg0.kind))
4124
                 :: fields
4125
                in
4126
             let fields =
4127
               if arg0.name = NoName
4128
               then fields
4129
               else
4130
                 ("name", (((fun x  -> vhdl_name_t_to_yojson x)) arg0.name))
4131
                 :: fields
4132
                in
4133
             `Assoc fields)])
4134
  [@ocaml.warning "-A"])
4135

    
4136
and (vhdl_declaration_t_of_yojson :
4137
      Yojson.Safe.json ->
4138
        vhdl_declaration_t Ppx_deriving_yojson_runtime.error_or)
4139
  =
4140
  ((let open! Ppx_deriving_yojson_runtime in
4141
      function
4142
      | `List ((`String "VARIABLE_DECLARATION")::arg0::[]) ->
4143
          ((function
4144
            | `Assoc xs ->
4145
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4146
                  match xs with
4147
                  | ("names",x)::xs ->
4148
                      loop xs
4149
                        (((function
4150
                           | `List xs ->
4151
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4152
                                 [] xs
4153
                           | _ ->
4154
                               Result.Error
4155
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4156
                          arg1, arg2)
4157
                  | ("typ",x)::xs ->
4158
                      loop xs
4159
                        (arg0,
4160
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4161
                             x), arg2)
4162
                  | ("init_val",x)::xs ->
4163
                      loop xs
4164
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4165
                  | [] ->
4166
                      arg2 >>=
4167
                        ((fun arg2  ->
4168
                            arg1 >>=
4169
                              (fun arg1  ->
4170
                                 arg0 >>=
4171
                                   (fun arg0  ->
4172
                                      Result.Ok
4173
                                        (VarDecl
4174
                                           {
4175
                                             names = arg0;
4176
                                             typ = arg1;
4177
                                             init_val = arg2
4178
                                           })))))
4179
                  | _::xs -> loop xs _state  in
4180
                loop xs
4181
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4182
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4183
                    (Result.Ok IsNull))
4184
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4185
      | `List ((`String "CONSTANT_DECLARATION")::arg0::[]) ->
4186
          ((function
4187
            | `Assoc xs ->
4188
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4189
                  match xs with
4190
                  | ("names",x)::xs ->
4191
                      loop xs
4192
                        (((function
4193
                           | `List xs ->
4194
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4195
                                 [] xs
4196
                           | _ ->
4197
                               Result.Error
4198
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4199
                          arg1, arg2)
4200
                  | ("typ",x)::xs ->
4201
                      loop xs
4202
                        (arg0,
4203
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4204
                             x), arg2)
4205
                  | ("init_val",x)::xs ->
4206
                      loop xs
4207
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4208
                  | [] ->
4209
                      arg2 >>=
4210
                        ((fun arg2  ->
4211
                            arg1 >>=
4212
                              (fun arg1  ->
4213
                                 arg0 >>=
4214
                                   (fun arg0  ->
4215
                                      Result.Ok
4216
                                        (CstDecl
4217
                                           {
4218
                                             names = arg0;
4219
                                             typ = arg1;
4220
                                             init_val = arg2
4221
                                           })))))
4222
                  | _::xs -> loop xs _state  in
4223
                loop xs
4224
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4225
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4226
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.init_val"))
4227
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4228
      | `List ((`String "SIGNAL_DECLARATION")::arg0::[]) ->
4229
          ((function
4230
            | `Assoc xs ->
4231
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4232
                  match xs with
4233
                  | ("names",x)::xs ->
4234
                      loop xs
4235
                        (((function
4236
                           | `List xs ->
4237
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4238
                                 [] xs
4239
                           | _ ->
4240
                               Result.Error
4241
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4242
                          arg1, arg2)
4243
                  | ("typ",x)::xs ->
4244
                      loop xs
4245
                        (arg0,
4246
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4247
                             x), arg2)
4248
                  | ("init_val",x)::xs ->
4249
                      loop xs
4250
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4251
                  | [] ->
4252
                      arg2 >>=
4253
                        ((fun arg2  ->
4254
                            arg1 >>=
4255
                              (fun arg1  ->
4256
                                 arg0 >>=
4257
                                   (fun arg0  ->
4258
                                      Result.Ok
4259
                                        (SigDecl
4260
                                           {
4261
                                             names = arg0;
4262
                                             typ = arg1;
4263
                                             init_val = arg2
4264
                                           })))))
4265
                  | _::xs -> loop xs _state  in
4266
                loop xs
4267
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4268
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4269
                    (Result.Ok IsNull))
4270
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4271
      | `List ((`String "SUBPROGRAM_BODY")::arg0::[]) ->
4272
          ((function
4273
            | `Assoc xs ->
4274
                let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
4275
                  match xs with
4276
                  | ("name",x)::xs ->
4277
                      loop xs
4278
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2,
4279
                          arg3, arg4)
4280
                  | ("kind",x)::xs ->
4281
                      loop xs
4282
                        (arg0,
4283
                          ((function
4284
                            | `String x -> Result.Ok x
4285
                            | _ ->
4286
                                Result.Error
4287
                                  "Vhdl_ast.vhdl_declaration_t.kind") x),
4288
                          arg2, arg3, arg4)
4289
                  | ("spec",x)::xs ->
4290
                      loop xs
4291
                        (arg0, arg1,
4292
                          ((fun x  -> vhdl_subprogram_spec_t_of_yojson x) x),
4293
                          arg3, arg4)
4294
                  | ("decl_part",x)::xs ->
4295
                      loop xs
4296
                        (arg0, arg1, arg2,
4297
                          ((function
4298
                            | `List xs ->
4299
                                map_bind
4300
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4301
                                  [] xs
4302
                            | _ ->
4303
                                Result.Error
4304
                                  "Vhdl_ast.vhdl_declaration_t.decl_part") x),
4305
                          arg4)
4306
                  | ("stmts",x)::xs ->
4307
                      loop xs
4308
                        (arg0, arg1, arg2, arg3,
4309
                          ((function
4310
                            | `List xs ->
4311
                                map_bind
4312
                                  (fun x  ->
4313
                                     vhdl_sequential_stmt_t_of_yojson x) []
4314
                                  xs
4315
                            | _ ->
4316
                                Result.Error
4317
                                  "Vhdl_ast.vhdl_declaration_t.stmts") x))
4318
                  | [] ->
4319
                      arg4 >>=
4320
                        ((fun arg4  ->
4321
                            arg3 >>=
4322
                              (fun arg3  ->
4323
                                 arg2 >>=
4324
                                   (fun arg2  ->
4325
                                      arg1 >>=
4326
                                        (fun arg1  ->
4327
                                           arg0 >>=
4328
                                             (fun arg0  ->
4329
                                                Result.Ok
4330
                                                  (Subprogram
4331
                                                     {
4332
                                                       name = arg0;
4333
                                                       kind = arg1;
4334
                                                       spec = arg2;
4335
                                                       decl_part = arg3;
4336
                                                       stmts = arg4
4337
                                                     })))))))
4338
                  | _::xs -> loop xs _state  in
4339
                loop xs
4340
                  ((Result.Ok NoName), (Result.Ok ""),
4341
                    (Result.Ok
4342
                       {
4343
                         name = "";
4344
                         typeMark = NoName;
4345
                         parameters = [];
4346
                         isPure = false
4347
                       }), (Result.Ok []), (Result.Ok []))
4348
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4349
      | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")
4350
  [@ocaml.warning "-A"])
4351

    
4352
type vhdl_signal_condition_t =
4353
  {
4354
  expr: vhdl_expr_t list ;
4355
  cond: vhdl_expr_t [@default IsNull]}
4356

    
4357
let rec pp_vhdl_signal_condition_t :
4358
  Format.formatter -> vhdl_signal_condition_t -> Ppx_deriving_runtime.unit =
4359
  let __1 () = pp_vhdl_expr_t
4360
  
4361
  and __0 () = pp_vhdl_expr_t
4362
   in
4363
  ((let open! Ppx_deriving_runtime in
4364
      fun fmt  ->
4365
        fun x  ->
4366
          ((fun x  ->
4367
              ignore
4368
                (List.fold_left
4369
                   (fun sep  ->
4370
                      fun x  ->
4371
                        if sep then Format.fprintf fmt ";@ ";
4372
                        ((__0 ()) fmt) x;
4373
                        true) false x))) x.expr;
4374
          (match x.cond with
4375
          | IsNull -> Format.fprintf fmt "";
4376
          | _ -> Format.fprintf fmt "when ";
4377
                 ((__1 ()) fmt) x.cond);)
4378
    [@ocaml.warning "-A"])
4379

    
4380
and show_vhdl_signal_condition_t :
4381
  vhdl_signal_condition_t -> Ppx_deriving_runtime.string =
4382
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_condition_t x
4383

    
4384
let rec (vhdl_signal_condition_t_to_yojson :
4385
          vhdl_signal_condition_t -> Yojson.Safe.json)
4386
  =
4387
  ((let open! Ppx_deriving_yojson_runtime in
4388
      fun x  ->
4389
        let fields = []  in
4390
        let fields =
4391
          if x.cond = IsNull
4392
          then fields
4393
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4394
            fields
4395
           in
4396
        let fields =
4397
          ("expr",
4398
            ((fun x  ->
4399
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
4400
               x.expr))
4401
          :: fields  in
4402
        `Assoc fields)
4403
  [@ocaml.warning "-A"])
4404

    
4405
and (vhdl_signal_condition_t_of_yojson :
4406
      Yojson.Safe.json ->
4407
        vhdl_signal_condition_t Ppx_deriving_yojson_runtime.error_or)
4408
  =
4409
  ((let open! Ppx_deriving_yojson_runtime in
4410
      function
4411
      | `Assoc xs ->
4412
          let rec loop xs ((arg0,arg1) as _state) =
4413
            match xs with
4414
            | ("expr",x)::xs ->
4415
                loop xs
4416
                  (((function
4417
                     | `List xs ->
4418
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4419
                     | _ ->
4420
                         Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr")
4421
                      x), arg1)
4422
            | ("cond",x)::xs ->
4423
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4424
            | [] ->
4425
                arg1 >>=
4426
                  ((fun arg1  ->
4427
                      arg0 >>=
4428
                        (fun arg0  -> Result.Ok { expr = arg0; cond = arg1 })))
4429
            | _::xs -> loop xs _state  in
4430
          loop xs
4431
            ((Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr"),
4432
              (Result.Ok IsNull))
4433
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_condition_t")
4434
  [@ocaml.warning "-A"])
4435

    
4436
type vhdl_signal_selection_t =
4437
  {
4438
  expr: vhdl_expr_t ;
4439
  when_sel: vhdl_expr_t list [@default []]}
4440

    
4441
(* TODO *)
4442
let rec pp_vhdl_signal_selection_t :
4443
  Format.formatter -> vhdl_signal_selection_t -> Ppx_deriving_runtime.unit =
4444
  let __1 () = pp_vhdl_expr_t
4445
  
4446
  and __0 () = pp_vhdl_expr_t
4447
   in
4448
  ((let open! Ppx_deriving_runtime in
4449
      fun fmt  ->
4450
        fun x  ->
4451
          Format.fprintf fmt "@[<2>{ ";
4452
          ((Format.fprintf fmt "@[%s =@ " "expr";
4453
            ((__0 ()) fmt) x.expr;
4454
            Format.fprintf fmt "@]");
4455
           Format.fprintf fmt ";@ ";
4456
           Format.fprintf fmt "@[%s =@ " "when_sel";
4457
           ((fun x  ->
4458
               Format.fprintf fmt "@[<2>[";
4459
               ignore
4460
                 (List.fold_left
4461
                    (fun sep  ->
4462
                       fun x  ->
4463
                         if sep then Format.fprintf fmt ";@ ";
4464
                         ((__1 ()) fmt) x;
4465
                         true) false x);
4466
               Format.fprintf fmt "@,]@]")) x.when_sel;
4467
           Format.fprintf fmt "@]");
4468
          Format.fprintf fmt "@ }@]")
4469
    [@ocaml.warning "-A"])
4470

    
4471
and show_vhdl_signal_selection_t :
4472
  vhdl_signal_selection_t -> Ppx_deriving_runtime.string =
4473
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_selection_t x
4474

    
4475
let rec (vhdl_signal_selection_t_to_yojson :
4476
          vhdl_signal_selection_t -> Yojson.Safe.json)
4477
  =
4478
  ((let open! Ppx_deriving_yojson_runtime in
4479
      fun x  ->
4480
        let fields = []  in
4481
        let fields =
4482
          if x.when_sel = []
4483
          then fields
4484
          else
4485
            ("when_sel",
4486
              (((fun x  ->
4487
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
4488
                 x.when_sel))
4489
            :: fields
4490
           in
4491
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
4492
          :: fields  in
4493
        `Assoc fields)
4494
  [@ocaml.warning "-A"])
4495

    
4496
and (vhdl_signal_selection_t_of_yojson :
4497
      Yojson.Safe.json ->
4498
        vhdl_signal_selection_t Ppx_deriving_yojson_runtime.error_or)
4499
  =
4500
  ((let open! Ppx_deriving_yojson_runtime in
4501
      function
4502
      | `Assoc xs ->
4503
          let rec loop xs ((arg0,arg1) as _state) =
4504
            match xs with
4505
            | ("expr",x)::xs ->
4506
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
4507
            | ("when_sel",x)::xs ->
4508
                loop xs
4509
                  (arg0,
4510
                    ((function
4511
                      | `List xs ->
4512
                          map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4513
                      | _ ->
4514
                          Result.Error
4515
                            "Vhdl_ast.vhdl_signal_selection_t.when_sel") x))
4516
            | [] ->
4517
                arg1 >>=
4518
                  ((fun arg1  ->
4519
                      arg0 >>=
4520
                        (fun arg0  ->
4521
                           Result.Ok { expr = arg0; when_sel = arg1 })))
4522
            | _::xs -> loop xs _state  in
4523
          loop xs
4524
            ((Result.Error "Vhdl_ast.vhdl_signal_selection_t.expr"),
4525
              (Result.Ok []))
4526
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_selection_t")
4527
  [@ocaml.warning "-A"])
4528

    
4529
type vhdl_conditional_signal_t =
4530
  {
4531
  postponed: bool [@default false];
4532
  label: vhdl_name_t [@default NoName];
4533
  lhs: vhdl_name_t ;
4534
  rhs: vhdl_signal_condition_t list ;
4535
  cond: vhdl_expr_t [@default IsNull];
4536
  delay: vhdl_expr_t [@default IsNull]}
4537

    
4538
let rec pp_vhdl_conditional_signal_t :
4539
  Format.formatter -> vhdl_conditional_signal_t -> Ppx_deriving_runtime.unit
4540
  =
4541
  let __4 () = pp_vhdl_expr_t
4542
  
4543
  and __3 () = pp_vhdl_expr_t
4544
  
4545
  and __2 () = pp_vhdl_signal_condition_t
4546
  
4547
  and __1 () = pp_vhdl_name_t
4548
  
4549
  and __0 () = pp_vhdl_name_t
4550
   in
4551
  ((let open! Ppx_deriving_runtime in
4552
      fun fmt  ->
4553
        fun x  ->
4554
          (match x.label with
4555
            | NoName -> Format.fprintf fmt "";
4556
            | _ -> (((__0 ()) fmt) x.label;
4557
                   Format.fprintf fmt ":@ ")
4558
          );
4559
          if (x.postponed) then Format.fprintf fmt "postponed@ ";
4560
          ((__1 ()) fmt) x.lhs;
4561
          Format.fprintf fmt " <= ";
4562
          (match x.delay with
4563
            | IsNull -> Format.fprintf fmt "";
4564
            | _ -> ((__4 ()) fmt) x.delay;
4565
                   Format.fprintf fmt " ");
4566
          ((fun x  ->
4567
             Format.fprintf fmt "@[";
4568
             ignore
4569
               (List.fold_left
4570
                 (fun sep  ->
4571
                   fun x  ->
4572
                     if sep then Format.fprintf fmt "";
4573
                      ((__2 ()) fmt) x;
4574
                      Format.fprintf fmt ";";
4575
                      true) false x);
4576
          Format.fprintf fmt "@]")) x.rhs;
4577
          (match x.cond with
4578
            | IsNull -> Format.fprintf fmt "";
4579
            | _ -> Format.fprintf fmt "when (";
4580
                   ((__3 ()) fmt) x.cond;
4581
                   Format.fprintf fmt ")"))
4582
   [@ocaml.warning "-A"])
4583

    
4584
and show_vhdl_conditional_signal_t :
4585
  vhdl_conditional_signal_t -> Ppx_deriving_runtime.string =
4586
  fun x  -> Format.asprintf "%a" pp_vhdl_conditional_signal_t x
4587

    
4588
let rec (vhdl_conditional_signal_t_to_yojson :
4589
          vhdl_conditional_signal_t -> Yojson.Safe.json)
4590
  =
4591
  ((let open! Ppx_deriving_yojson_runtime in
4592
      fun x  ->
4593
        let fields = []  in
4594
        let fields =
4595
          if x.delay = IsNull
4596
          then fields
4597
          else ("delay", (((fun x  -> vhdl_expr_t_to_yojson x)) x.delay)) ::
4598
            fields
4599
           in
4600
        let fields =
4601
          if x.cond = IsNull
4602
          then fields
4603
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4604
            fields
4605
           in
4606
        let fields =
4607
          ("rhs",
4608
            ((fun x  ->
4609
                `List
4610
                  (List.map (fun x  -> vhdl_signal_condition_t_to_yojson x) x))
4611
               x.rhs))
4612
          :: fields  in
4613
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4614
          fields  in
4615
        let fields =
4616
          if x.label = NoName
4617
          then fields
4618
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4619
            fields
4620
           in
4621
        let fields =
4622
          if x.postponed = false
4623
          then fields
4624
          else
4625
            ("postponed",
4626
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4627
                 x.postponed))
4628
            :: fields
4629
           in
4630
        `Assoc fields)
4631
  [@ocaml.warning "-A"])
4632

    
4633
and (vhdl_conditional_signal_t_of_yojson :
4634
      Yojson.Safe.json ->
4635
        vhdl_conditional_signal_t Ppx_deriving_yojson_runtime.error_or)
4636
  =
4637
  ((let open! Ppx_deriving_yojson_runtime in
4638
      function
4639
      | `Assoc xs ->
4640
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4641
            match xs with
4642
            | ("postponed",x)::xs ->
4643
                loop xs
4644
                  (((function
4645
                     | `Bool x -> Result.Ok x
4646
                     | _ ->
4647
                         Result.Error
4648
                           "Vhdl_ast.vhdl_conditional_signal_t.postponed") x),
4649
                    arg1, arg2, arg3, arg4, arg5)
4650
            | ("label",x)::xs ->
4651
                loop xs
4652
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4653
                    arg4, arg5)
4654
            | ("lhs",x)::xs ->
4655
                loop xs
4656
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4657
                    arg4, arg5)
4658
            | ("rhs",x)::xs ->
4659
                loop xs
4660
                  (arg0, arg1, arg2,
4661
                    ((function
4662
                      | `List xs ->
4663
                          map_bind
4664
                            (fun x  -> vhdl_signal_condition_t_of_yojson x)
4665
                            [] xs
4666
                      | _ ->
4667
                          Result.Error
4668
                            "Vhdl_ast.vhdl_conditional_signal_t.rhs") x),
4669
                    arg4, arg5)
4670
            | ("cond",x)::xs ->
4671
                loop xs
4672
                  (arg0, arg1, arg2, arg3,
4673
                    ((fun x  -> vhdl_expr_t_of_yojson x) x), arg5)
4674
            | ("delay",x)::xs ->
4675
                loop xs
4676
                  (arg0, arg1, arg2, arg3, arg4,
4677
                    ((fun x  -> vhdl_expr_t_of_yojson x) x))
4678
            | [] ->
4679
                arg5 >>=
4680
                  ((fun arg5  ->
4681
                      arg4 >>=
4682
                        (fun arg4  ->
4683
                           arg3 >>=
4684
                             (fun arg3  ->
4685
                                arg2 >>=
4686
                                  (fun arg2  ->
4687
                                     arg1 >>=
4688
                                       (fun arg1  ->
4689
                                          arg0 >>=
4690
                                            (fun arg0  ->
4691
                                               Result.Ok
4692
                                                 {
4693
                                                   postponed = arg0;
4694
                                                   label = arg1;
4695
                                                   lhs = arg2;
4696
                                                   rhs = arg3;
4697
                                                   cond = arg4;
4698
                                                   delay = arg5
4699
                                                 })))))))
4700
            | _::xs -> loop xs _state  in
4701
          loop xs
4702
            ((Result.Ok false), (Result.Ok NoName),
4703
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.lhs"),
4704
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.rhs"),
4705
              (Result.Ok IsNull), (Result.Ok IsNull))
4706
      | _ -> Result.Error "Vhdl_ast.vhdl_conditional_signal_t")
4707
  [@ocaml.warning "-A"])
4708

    
4709
type vhdl_process_t =
4710
  {
4711
  id: vhdl_name_t [@default NoName];
4712
  declarations: vhdl_declaration_t list option
4713
    [@key "PROCESS_DECLARATIVE_PART"][@default Some []];
4714
  active_sigs: vhdl_name_t list [@default []];
4715
  body: vhdl_sequential_stmt_t list
4716
    [@key "PROCESS_STATEMENT_PART"][@default []]}
4717

    
4718
let rec pp_vhdl_process_t :
4719
  Format.formatter -> vhdl_process_t -> Ppx_deriving_runtime.unit =
4720
  let __3 () = pp_vhdl_sequential_stmt_t
4721
  
4722
  and __2 () = pp_vhdl_name_t
4723
  
4724
  and __1 () = pp_vhdl_declaration_t
4725
  
4726
  and __0 () = pp_vhdl_name_t
4727
   in
4728
  ((let open! Ppx_deriving_runtime in
4729
      fun fmt  ->
4730
        fun x  ->
4731
          Format.fprintf fmt "@[<v>process ";
4732
          (match x.active_sigs with
4733
          | [] -> Format.fprintf fmt "";
4734
          | _ -> Format.fprintf fmt "(";
4735
                 ((fun x  ->
4736
                    ignore
4737
                      (List.fold_left
4738
                         (fun sep  ->
4739
                            fun x  ->
4740
                              if sep then Format.fprintf fmt ",";
4741
                              ((__2 ()) fmt) x;
4742
                              true) false x))) x.active_sigs;
4743
                 Format.fprintf fmt ")");
4744
          ((function
4745
             | None  -> Format.pp_print_string fmt ""
4746
             | Some x ->
4747
                  ((fun x  ->
4748
                      Format.fprintf fmt "@[<2>";
4749
                      ignore
4750
                        (List.fold_left
4751
                           (fun sep  ->
4752
                              fun x  ->
4753
                                if sep then Format.fprintf fmt "@;";
4754
                                ((__1 ()) fmt) x;
4755
                                true) false x);
4756
                      Format.fprintf fmt "@]")) x;)) x.declarations;
4757
          Format.fprintf fmt "@;@[<v 2>begin@;";
4758
          ((fun x  ->
4759
               ignore
4760
                 (List.fold_left
4761
                    (fun sep  ->
4762
                       fun x  ->
4763
                         if sep then Format.fprintf fmt "@;";
4764
                         ((__3 ()) fmt) x;
4765
                         true) false x);)) x.body;
4766
          Format.fprintf fmt "@]@;end process;@;";
4767
          Format.fprintf fmt "@]";)
4768
    [@ocaml.warning "-A"])
4769

    
4770
and show_vhdl_process_t : vhdl_process_t -> Ppx_deriving_runtime.string =
4771
  fun x  -> Format.asprintf "%a" pp_vhdl_process_t x
4772

    
4773
let rec (vhdl_process_t_to_yojson : vhdl_process_t -> Yojson.Safe.json) =
4774
  ((let open! Ppx_deriving_yojson_runtime in
4775
      fun x  ->
4776
        let fields = []  in
4777
        let fields =
4778
          if x.body = []
4779
          then fields
4780
          else
4781
            ("PROCESS_STATEMENT_PART",
4782
              (((fun x  ->
4783
                   `List
4784
                     (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x)
4785
                        x))) x.body))
4786
            :: fields
4787
           in
4788
        let fields =
4789
          if x.active_sigs = []
4790
          then fields
4791
          else
4792
            ("active_sigs",
4793
              (((fun x  ->
4794
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
4795
                 x.active_sigs))
4796
            :: fields
4797
           in
4798
        let fields =
4799
          if x.declarations = (Some [])
4800
          then fields
4801
          else
4802
            ("PROCESS_DECLARATIVE_PART",
4803
              (((function
4804
                 | None  -> `Null
4805
                 | Some x ->
4806
                     ((fun x  ->
4807
                         `List
4808
                           (List.map
4809
                              (fun x  -> vhdl_declaration_t_to_yojson x) x)))
4810
                       x)) x.declarations))
4811
            :: fields
4812
           in
4813
        let fields =
4814
          if x.id = NoName
4815
          then fields
4816
          else ("id", (((fun x  -> vhdl_name_t_to_yojson x)) x.id)) :: fields
4817
           in
4818
        `Assoc fields)
4819
  [@ocaml.warning "-A"])
4820

    
4821
and (vhdl_process_t_of_yojson :
4822
      Yojson.Safe.json -> vhdl_process_t Ppx_deriving_yojson_runtime.error_or)
4823
  =
4824
  ((let open! Ppx_deriving_yojson_runtime in
4825
      function
4826
      | `Assoc xs ->
4827
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
4828
            match xs with
4829
            | ("id",x)::xs ->
4830
                loop xs
4831
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3)
4832
            | ("PROCESS_DECLARATIVE_PART",x)::xs ->
4833
                loop xs
4834
                  (arg0,
4835
                    ((function
4836
                      | `Null -> Result.Ok None
4837
                      | x ->
4838
                          ((function
4839
                            | `List xs ->
4840
                                map_bind
4841
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4842
                                  [] xs
4843
                            | _ ->
4844
                                Result.Error
4845
                                  "Vhdl_ast.vhdl_process_t.declarations") x)
4846
                            >>= ((fun x  -> Result.Ok (Some x)))) x), arg2,
4847
                    arg3)
4848
            | ("active_sigs",x)::xs ->
4849
                loop xs
4850
                  (arg0, arg1,
4851
                    ((function
4852
                      | `List xs ->
4853
                          map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4854
                      | _ ->
4855
                          Result.Error "Vhdl_ast.vhdl_process_t.active_sigs")
4856
                       x), arg3)
4857
            | ("PROCESS_STATEMENT_PART",x)::xs ->
4858
                loop xs
4859
                  (arg0, arg1, arg2,
4860
                    ((function
4861
                      | `List xs ->
4862
                          map_bind
4863
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
4864
                            xs
4865
                      | _ -> Result.Error "Vhdl_ast.vhdl_process_t.body") x))
4866
            | [] ->
4867
                arg3 >>=
4868
                  ((fun arg3  ->
4869
                      arg2 >>=
4870
                        (fun arg2  ->
4871
                           arg1 >>=
4872
                             (fun arg1  ->
4873
                                arg0 >>=
4874
                                  (fun arg0  ->
4875
                                     Result.Ok
4876
                                       {
4877
                                         id = arg0;
4878
                                         declarations = arg1;
4879
                                         active_sigs = arg2;
4880
                                         body = arg3
4881
                                       })))))
4882
            | _::xs -> loop xs _state  in
4883
          loop xs
4884
            ((Result.Ok NoName), (Result.Ok (Some [])), (Result.Ok []),
4885
              (Result.Ok []))
4886
      | _ -> Result.Error "Vhdl_ast.vhdl_process_t")
4887
  [@ocaml.warning "-A"])
4888

    
4889
type vhdl_selected_signal_t =
4890
  {
4891
  postponed: bool [@default false];
4892
  label: vhdl_name_t [@default NoName];
4893
  lhs: vhdl_name_t ;
4894
  sel: vhdl_expr_t ;
4895
  branches: vhdl_signal_selection_t list [@default []];
4896
  delay: vhdl_expr_t option }
4897

    
4898
(* TODO *)
4899
let rec pp_vhdl_selected_signal_t :
4900
  Format.formatter -> vhdl_selected_signal_t -> Ppx_deriving_runtime.unit =
4901
  let __4 () = pp_vhdl_expr_t
4902
  
4903
  and __3 () = pp_vhdl_signal_selection_t
4904
  
4905
  and __2 () = pp_vhdl_expr_t
4906
  
4907
  and __1 () = pp_vhdl_name_t
4908
  
4909
  and __0 () = pp_vhdl_name_t
4910
   in
4911
  ((let open! Ppx_deriving_runtime in
4912
      fun fmt  ->
4913
        fun x  ->
4914
          Format.fprintf fmt "@[<2>{ ";
4915
          ((((((Format.fprintf fmt "@[%s =@ " "postponed";
4916
                (Format.fprintf fmt "%B") x.postponed;
4917
                Format.fprintf fmt "@]");
4918
               Format.fprintf fmt ";@ ";
4919
               Format.fprintf fmt "@[%s =@ " "label";
4920
               ((__0 ()) fmt) x.label;
4921
               Format.fprintf fmt "@]");
4922
              Format.fprintf fmt ";@ ";
4923
              Format.fprintf fmt "@[%s =@ " "lhs";
4924
              ((__1 ()) fmt) x.lhs;
4925
              Format.fprintf fmt "@]");
4926
             Format.fprintf fmt ";@ ";
4927
             Format.fprintf fmt "@[%s =@ " "sel";
4928
             ((__2 ()) fmt) x.sel;
4929
             Format.fprintf fmt "@]");
4930
            Format.fprintf fmt ";@ ";
4931
            Format.fprintf fmt "@[%s =@ " "branches";
4932
            ((fun x  ->
4933
                Format.fprintf fmt "@[<2>[";
4934
                ignore
4935
                  (List.fold_left
4936
                     (fun sep  ->
4937
                        fun x  ->
4938
                          if sep then Format.fprintf fmt ";@ ";
4939
                          ((__3 ()) fmt) x;
4940
                          true) false x);
4941
                Format.fprintf fmt "@,]@]")) x.branches;
4942
            Format.fprintf fmt "@]");
4943
           Format.fprintf fmt ";@ ";
4944
           Format.fprintf fmt "@[%s =@ " "delay";
4945
           ((function
4946
             | None  -> Format.pp_print_string fmt "None"
4947
             | Some x ->
4948
                 (Format.pp_print_string fmt "(Some ";
4949
                  ((__4 ()) fmt) x;
4950
                  Format.pp_print_string fmt ")"))) x.delay;
4951
           Format.fprintf fmt "@]");
4952
          Format.fprintf fmt "@ }@]")
4953
    [@ocaml.warning "-A"])
4954

    
4955
and show_vhdl_selected_signal_t :
4956
  vhdl_selected_signal_t -> Ppx_deriving_runtime.string =
4957
  fun x  -> Format.asprintf "%a" pp_vhdl_selected_signal_t x
4958

    
4959
let rec (vhdl_selected_signal_t_to_yojson :
4960
          vhdl_selected_signal_t -> Yojson.Safe.json)
4961
  =
4962
  ((let open! Ppx_deriving_yojson_runtime in
4963
      fun x  ->
4964
        let fields = []  in
4965
        let fields =
4966
          ("delay",
4967
            ((function
4968
              | None  -> `Null
4969
              | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x) x.delay))
4970
          :: fields  in
4971
        let fields =
4972
          if x.branches = []
4973
          then fields
4974
          else
4975
            ("branches",
4976
              (((fun x  ->
4977
                   `List
4978
                     (List.map
4979
                        (fun x  -> vhdl_signal_selection_t_to_yojson x) x)))
4980
                 x.branches))
4981
            :: fields
4982
           in
4983
        let fields = ("sel", ((fun x  -> vhdl_expr_t_to_yojson x) x.sel)) ::
4984
          fields  in
4985
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4986
          fields  in
4987
        let fields =
4988
          if x.label = NoName
4989
          then fields
4990
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4991
            fields
4992
           in
4993
        let fields =
4994
          if x.postponed = false
4995
          then fields
4996
          else
4997
            ("postponed",
4998
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4999
                 x.postponed))
5000
            :: fields
5001
           in
5002
        `Assoc fields)
5003
  [@ocaml.warning "-A"])
5004

    
5005
and (vhdl_selected_signal_t_of_yojson :
5006
      Yojson.Safe.json ->
5007
        vhdl_selected_signal_t Ppx_deriving_yojson_runtime.error_or)
5008
  =
5009
  ((let open! Ppx_deriving_yojson_runtime in
5010
      function
5011
      | `Assoc xs ->
5012
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
5013
            match xs with
5014
            | ("postponed",x)::xs ->
5015
                loop xs
5016
                  (((function
5017
                     | `Bool x -> Result.Ok x
5018
                     | _ ->
5019
                         Result.Error
5020
                           "Vhdl_ast.vhdl_selected_signal_t.postponed") x),
5021
                    arg1, arg2, arg3, arg4, arg5)
5022
            | ("label",x)::xs ->
5023
                loop xs
5024
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
5025
                    arg4, arg5)
5026
            | ("lhs",x)::xs ->
5027
                loop xs
5028
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
5029
                    arg4, arg5)
5030
            | ("sel",x)::xs ->
5031
                loop xs
5032
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x),
5033
                    arg4, arg5)
5034
            | ("branches",x)::xs ->
5035
                loop xs
5036
                  (arg0, arg1, arg2, arg3,
5037
                    ((function
5038
                      | `List xs ->
5039
                          map_bind
5040
                            (fun x  -> vhdl_signal_selection_t_of_yojson x)
5041
                            [] xs
5042
                      | _ ->
5043
                          Result.Error
5044
                            "Vhdl_ast.vhdl_selected_signal_t.branches") x),
5045
                    arg5)
5046
            | ("delay",x)::xs ->
5047
                loop xs
5048
                  (arg0, arg1, arg2, arg3, arg4,
5049
                    ((function
5050
                      | `Null -> Result.Ok None
5051
                      | x ->
5052
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
5053
                            ((fun x  -> Result.Ok (Some x)))) x))
5054
            | [] ->
5055
                arg5 >>=
5056
                  ((fun arg5  ->
5057
                      arg4 >>=
5058
                        (fun arg4  ->
5059
                           arg3 >>=
5060
                             (fun arg3  ->
5061
                                arg2 >>=
5062
                                  (fun arg2  ->
5063
                                     arg1 >>=
5064
                                       (fun arg1  ->
5065
                                          arg0 >>=
5066
                                            (fun arg0  ->
5067
                                               Result.Ok
5068
                                                 {
5069
                                                   postponed = arg0;
5070
                                                   label = arg1;
5071
                                                   lhs = arg2;
5072
                                                   sel = arg3;
5073
                                                   branches = arg4;
5074
                                                   delay = arg5
5075
                                                 })))))))
5076
            | _::xs -> loop xs _state  in
5077
          loop xs
5078
            ((Result.Ok false), (Result.Ok NoName),
5079
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.lhs"),
5080
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.sel"),
5081
              (Result.Ok []),
5082
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.delay"))
5083
      | _ -> Result.Error "Vhdl_ast.vhdl_selected_signal_t")
5084
  [@ocaml.warning "-A"])
5085

    
5086
type vhdl_component_instantiation_t =
5087
  {
5088
  name: vhdl_name_t ;
5089
  inst_unit: vhdl_name_t ;
5090
  archi_name: vhdl_name_t option [@default None];
5091
  generic_map: vhdl_assoc_element_t option [@default None];
5092
  port_map: vhdl_assoc_element_t option [@default None]}[@@deriving
5093
                                                          ((show
5094
                                                              {
5095
                                                                with_path =
5096
                                                                  false
5097
                                                              }),
5098
                                                            (yojson
5099
                                                               {
5100
                                                                 strict =
5101
                                                                   false
5102
                                                               }))]
5103

    
5104
(* TODO *)
5105
let rec pp_vhdl_component_instantiation_t :
5106
  Format.formatter ->
5107
    vhdl_component_instantiation_t -> Ppx_deriving_runtime.unit
5108
  =
5109
  let __4 () = pp_vhdl_assoc_element_t
5110
  
5111
  and __3 () = pp_vhdl_assoc_element_t
5112
  
5113
  and __2 () = pp_vhdl_name_t
5114
  
5115
  and __1 () = pp_vhdl_name_t
5116
  
5117
  and __0 () = pp_vhdl_name_t
5118
   in
5119
  ((let open! Ppx_deriving_runtime in
5120
      fun fmt  ->
5121
        fun x  ->
5122
          ((__0 ()) fmt) x.name;
5123
          Format.fprintf fmt " : ";
5124
          ((__1 ()) fmt) x.inst_unit;
5125
          ((function
5126
             | None  -> Format.pp_print_string fmt ""
5127
             | Some x ->
5128
                 (Format.pp_print_string fmt "(";
5129
                 ((__2 ()) fmt) x;
5130
                 Format.pp_print_string fmt ")@;"))) x.archi_name;
5131
          ((function
5132
             | None  -> Format.pp_print_string fmt ""
5133
             | Some x ->
5134
                 (Format.pp_print_string fmt "(";
5135
                 ((__3 ()) fmt) x;
5136
                 Format.pp_print_string fmt ")@;"))) x.generic_map;
5137
          ((function
5138
             | None  -> Format.pp_print_string fmt "None"
5139
             | Some x ->
5140
                 (Format.pp_print_string fmt "(";
5141
                 ((__4 ()) fmt) x;
5142
                 Format.pp_print_string fmt ")@;"))) x.port_map;)
5143
    [@ocaml.warning "-A"])
5144

    
5145
and show_vhdl_component_instantiation_t :
5146
  vhdl_component_instantiation_t -> Ppx_deriving_runtime.string =
5147
  fun x  -> Format.asprintf "%a" pp_vhdl_component_instantiation_t x
5148

    
5149
let rec (vhdl_component_instantiation_t_to_yojson :
5150
          vhdl_component_instantiation_t -> Yojson.Safe.json)
5151
  =
5152
  ((let open! Ppx_deriving_yojson_runtime in
5153
      fun x  ->
5154
        let fields = []  in
5155
        let fields =
5156
          if x.port_map = None
5157
          then fields
5158
          else
5159
            ("port_map",
5160
              (((function
5161
                 | None  -> `Null
5162
                 | Some x -> ((fun x  -> vhdl_assoc_element_t_to_yojson x)) x))
5163
                 x.port_map))
5164
            :: fields
5165
           in
5166
        let fields =
5167
          if x.generic_map = None
5168
          then fields
5169
          else
5170
            ("generic_map",
5171
              (((function
5172
                 | None  -> `Null
5173
                 | Some x -> ((fun x  -> vhdl_assoc_element_t_to_yojson x)) x))
5174
                 x.generic_map))
5175
            :: fields
5176
           in
5177
        let fields =
5178
          if x.archi_name = None
5179
          then fields
5180
          else
5181
            ("archi_name",
5182
              (((function
5183
                 | None  -> `Null
5184
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
5185
                 x.archi_name))
5186
            :: fields
5187
           in
5188
        let fields =
5189
          ("inst_unit", ((fun x  -> vhdl_name_t_to_yojson x) x.inst_unit)) ::
5190
          fields  in
5191
        let fields = ("name", ((fun x  -> vhdl_name_t_to_yojson x) x.name))
5192
          :: fields  in
5193
        `Assoc fields)
5194
  [@ocaml.warning "-A"])
5195

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

    
5265
type vhdl_concurrent_stmt_t =
5266
  | SigAssign of vhdl_conditional_signal_t
5267
  [@name "CONDITIONAL_SIGNAL_ASSIGNMENT"]
5268
  | Process of vhdl_process_t [@name "PROCESS_STATEMENT"]
5269
  | SelectedSig of vhdl_selected_signal_t
5270
  [@name "SELECTED_SIGNAL_ASSIGNMENT"]
5271
  | ComponentInst of vhdl_component_instantiation_t
5272
  [@name "COMPONENT_INSTANTIATION_STATEMENT"]
5273

    
5274
let rec pp_vhdl_concurrent_stmt_t :
5275
  Format.formatter -> vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.unit =
5276
  let __3 () = pp_vhdl_component_instantiation_t
5277
  
5278
  and __2 () = pp_vhdl_selected_signal_t
5279
  
5280
  and __1 () = pp_vhdl_process_t
5281
  
5282
  and __0 () = pp_vhdl_conditional_signal_t
5283
   in
5284
  ((let open! Ppx_deriving_runtime in
5285
      fun fmt  ->
5286
        function
5287
        | SigAssign a0 ->
5288
             ((__0 ()) fmt) a0;
5289
        | Process a0 ->
5290
             ((__1 ()) fmt) a0;
5291
        | SelectedSig a0 ->
5292
             ((__2 ()) fmt) a0;
5293
        | ComponentInst a0 ->
5294
             ((__3 ()) fmt) a0;
5295
    )
5296
    [@ocaml.warning "-A"])
5297

    
5298
and show_vhdl_concurrent_stmt_t :
5299
  vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.string =
5300
  fun x  -> Format.asprintf "%a" pp_vhdl_concurrent_stmt_t x
5301

    
5302
let rec (vhdl_concurrent_stmt_t_to_yojson :
5303
          vhdl_concurrent_stmt_t -> Yojson.Safe.json)
5304
  =
5305
  ((let open! Ppx_deriving_yojson_runtime in
5306
      function
5307
      | SigAssign arg0 ->
5308
          `List
5309
            [`String "CONDITIONAL_SIGNAL_ASSIGNMENT";
5310
            ((fun x  -> vhdl_conditional_signal_t_to_yojson x)) arg0]
5311
      | Process arg0 ->
5312
          `List
5313
            [`String "PROCESS_STATEMENT";
5314
            ((fun x  -> vhdl_process_t_to_yojson x)) arg0]
5315
      | SelectedSig arg0 ->
5316
          `List
5317
            [`String "SELECTED_SIGNAL_ASSIGNMENT";
5318
            ((fun x  -> vhdl_selected_signal_t_to_yojson x)) arg0]
5319
      | ComponentInst arg0 ->
5320
          `List
5321
            [`String "COMPONENT_INSTANTIATION_STATEMENT";
5322
            ((fun x  -> vhdl_component_instantiation_t_to_yojson x)) arg0])
5323
  [@ocaml.warning "-A"])
5324

    
5325
and (vhdl_concurrent_stmt_t_of_yojson :
5326
      Yojson.Safe.json ->
5327
        vhdl_concurrent_stmt_t Ppx_deriving_yojson_runtime.error_or)
5328
  =
5329
  ((let open! Ppx_deriving_yojson_runtime in
5330
      function
5331
      | `List ((`String "CONDITIONAL_SIGNAL_ASSIGNMENT")::arg0::[]) ->
5332
          ((fun x  -> vhdl_conditional_signal_t_of_yojson x) arg0) >>=
5333
            ((fun arg0  -> Result.Ok (SigAssign arg0)))
5334
      | `List ((`String "PROCESS_STATEMENT")::arg0::[]) ->
5335
          ((fun x  -> vhdl_process_t_of_yojson x) arg0) >>=
5336
            ((fun arg0  -> Result.Ok (Process arg0)))
5337
      | `List ((`String "SELECTED_SIGNAL_ASSIGNMENT")::arg0::[]) ->
5338
          ((fun x  -> vhdl_selected_signal_t_of_yojson x) arg0) >>=
5339
            ((fun arg0  -> Result.Ok (SelectedSig arg0)))
5340
      | `List ((`String "COMPONENT_INSTANTIATION_STATEMENT")::arg0::[]) ->
5341
          ((fun x  -> vhdl_component_instantiation_t_of_yojson x) arg0) >>=
5342
            ((fun arg0  -> Result.Ok (ComponentInst arg0)))
5343
      | _ -> Result.Error "Vhdl_ast.vhdl_concurrent_stmt_t")
5344
  [@ocaml.warning "-A"])
5345

    
5346
type vhdl_port_mode_t =
5347
  | InPort [@name "in"]
5348
  | OutPort [@name "out"]
5349
  | InoutPort [@name "inout"]
5350
  | BufferPort [@name "buffer"]
5351

    
5352
let rec (pp_vhdl_port_mode_t :
5353
          Format.formatter -> vhdl_port_mode_t -> Ppx_deriving_runtime.unit)
5354
  =
5355
  ((let open! Ppx_deriving_runtime in
5356
      fun fmt  ->
5357
        function
5358
        | InPort  -> Format.pp_print_string fmt "in"
5359
        | OutPort  -> Format.pp_print_string fmt "out"
5360
        | InoutPort  -> Format.pp_print_string fmt "inout"
5361
        | BufferPort  -> Format.pp_print_string fmt "buffer")
5362
  [@ocaml.warning "-A"])
5363

    
5364
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string =
5365
  fun x  -> Format.asprintf "%a" pp_vhdl_port_mode_t x
5366

    
5367
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) =
5368
  ((let open! Ppx_deriving_yojson_runtime in
5369
      function
5370
      | InPort  -> `List [`String "in"]
5371
      | OutPort  -> `List [`String "out"]
5372
      | InoutPort  -> `List [`String "inout"]
5373
      | BufferPort  -> `List [`String "buffer"])
5374
  [@ocaml.warning "-A"])
5375

    
5376
and (vhdl_port_mode_t_of_yojson :
5377
      Yojson.Safe.json ->
5378
        vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or)
5379
  =
5380
  ((let open! Ppx_deriving_yojson_runtime in
5381
      function
5382
      | `List ((`String "in")::[]) -> Result.Ok InPort
5383
      | `List ((`String "out")::[]) -> Result.Ok OutPort
5384
      | `List ((`String "inout")::[]) -> Result.Ok InoutPort
5385
      | `List ((`String "buffer")::[]) -> Result.Ok BufferPort
5386
      | _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t")
5387
  [@ocaml.warning "-A"])
5388

    
5389
type vhdl_port_t =
5390
  {
5391
  names: vhdl_name_t list [@default []];
5392
  mode: vhdl_port_mode_t [@default InPort];
5393
  typ: vhdl_subtype_indication_t ;
5394
  expr: vhdl_expr_t [@default IsNull]}
5395

    
5396
let rec pp_vhdl_port_t :
5397
  Format.formatter -> vhdl_port_t -> Ppx_deriving_runtime.unit =
5398
  let __3 () = pp_vhdl_expr_t
5399
  
5400
  and __2 () = pp_vhdl_subtype_indication_t
5401
  
5402
  and __1 () = pp_vhdl_port_mode_t
5403
  
5404
  and __0 () = pp_vhdl_name_t
5405
   in
5406
  ((let open! Ppx_deriving_runtime in
5407
      fun fmt  ->
5408
        fun x  ->
5409
          Format.fprintf fmt "@[";
5410
          ((((
5411
              ((fun x  ->
5412
                  Format.fprintf fmt "@[";
5413
                  ignore
5414
                    (List.fold_left
5415
                       (fun sep  ->
5416
                          fun x  ->
5417
                            if sep then Format.fprintf fmt ",@ ";
5418
                            ((__0 ()) fmt) x;
5419
                            true) false x);
5420
                  Format.fprintf fmt "@,@]")) x.names;
5421
              );
5422
             Format.fprintf fmt ": ";
5423
             ((__1 ()) fmt) x.mode;
5424
             );
5425
             Format.fprintf fmt " ";
5426
            ((__2 ()) fmt) x.typ;
5427
            );
5428
          (match x.expr with
5429
           | IsNull -> Format.fprintf fmt "";
5430
           | _ -> (Format.fprintf fmt "@[:= ";
5431
                   ((__3 ()) fmt) x.expr;
5432
                   Format.fprintf fmt "@]"));
5433
          Format.fprintf fmt "@]"))
5434
    [@ocaml.warning "-A"])
5435

    
5436
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string =
5437
  fun x  -> Format.asprintf "%a" pp_vhdl_port_t x
5438

    
5439
let rec (vhdl_port_t_to_yojson : vhdl_port_t -> Yojson.Safe.json) =
5440
  ((let open! Ppx_deriving_yojson_runtime in
5441
      fun x  ->
5442
        let fields = []  in
5443
        let fields =
5444
          if x.expr = IsNull
5445
          then fields
5446
          else ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) x.expr)) ::
5447
            fields
5448
           in
5449
        let fields =
5450
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
5451
          :: fields  in
5452
        let fields =
5453
          if x.mode = InPort
5454
          then fields
5455
          else ("mode", (((fun x  -> vhdl_port_mode_t_to_yojson x)) x.mode))
5456
            :: fields
5457
           in
5458
        let fields =
5459
          if x.names = []
5460
          then fields
5461
          else
5462
            ("names",
5463
              (((fun x  ->
5464
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
5465
                 x.names))
5466
            :: fields
5467
           in
5468
        `Assoc fields)
5469
  [@ocaml.warning "-A"])
5470

    
5471
and (vhdl_port_t_of_yojson :
5472
      Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
5473
  =
5474
  ((let open! Ppx_deriving_yojson_runtime in
5475
      function
5476
      | `Assoc xs ->
5477
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
5478
            match xs with
5479
            | ("names",x)::xs ->
5480
                loop xs
5481
                  (((function
5482