Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (240 KB)

1
let base_types =
2
  ["integer";
3
  "character";
4
  "bit";
5
  "real";
6
  "natural";
7
  "positive";
8
  "std_logic";
9
  "std_logic_vector"] 
10
let std_logic_cst = ["U"; "X"; "0"; "1"; "Z"; "W"; "L"; "H"; "-"] 
11
let literal_base = ["B"; "O"; "X"; "UB"; "UO"; "UX"; "SB"; "SO"; "SX"; "D"] 
12
type vhdl_cst_val_t =
13
  | CstInt of int 
14
  | CstStdLogic of string 
15
  | CstLiteral of string [@name "CST_LITERAL"]
16

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2786
and (vhdl_subprogram_spec_t_of_yojson :
2787
      Yojson.Safe.json ->
2788
        vhdl_subprogram_spec_t Ppx_deriving_yojson_runtime.error_or)
2789
  =
2790
  ((let open! Ppx_deriving_yojson_runtime in
2791
      function
2792
      | `Assoc xs ->
2793
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
2794
            match xs with
2795
            | ("name",x)::xs ->
2796
                loop xs
2797
                  (((function
2798
                     | `String x -> Result.Ok x
2799
                     | _ ->
2800
                         Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.name")
2801
                      x), arg1, arg2, arg3, arg4)
2802
            | ("subprogram_type",x)::xs ->
2803
                loop xs
2804
                  (arg0,
2805
                    ((function
2806
                      | `String x -> Result.Ok x
2807
                      | _ ->
2808
                          Result.Error
2809
                            "Vhdl_ast.vhdl_subprogram_spec_t.subprogram_type")
2810
                       x), arg2, arg3, arg4)
2811
            | ("typeMark",x)::xs ->
2812
                loop xs
2813
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
2814
                    arg4)
2815
            | ("parameters",x)::xs ->
2816
                loop xs
2817
                  (arg0, arg1, arg2,
2818
                    ((function
2819
                      | `List xs ->
2820
                          map_bind (fun x  -> vhdl_parameter_t_of_yojson x)
2821
                            [] xs
2822
                      | _ ->
2823
                          Result.Error
2824
                            "Vhdl_ast.vhdl_subprogram_spec_t.parameters") x),
2825
                    arg4)
2826
            | ("isPure",x)::xs ->
2827
                loop xs
2828
                  (arg0, arg1, arg2, arg3,
2829
                    ((function
2830
                      | `Bool x -> Result.Ok x
2831
                      | _ ->
2832
                          Result.Error
2833
                            "Vhdl_ast.vhdl_subprogram_spec_t.isPure") x))
2834
            | [] ->
2835
                arg4 >>=
2836
                  ((fun arg4  ->
2837
                      arg3 >>=
2838
                        (fun arg3  ->
2839
                           arg2 >>=
2840
                             (fun arg2  ->
2841
                                arg1 >>=
2842
                                  (fun arg1  ->
2843
                                     arg0 >>=
2844
                                       (fun arg0  ->
2845
                                          Result.Ok
2846
                                            {
2847
                                              name = arg0;
2848
                                              subprogram_type = arg1;
2849
                                              typeMark = arg2;
2850
                                              parameters = arg3;
2851
                                              isPure = arg4
2852
                                            }))))))
2853
            | _::xs -> loop xs _state  in
2854
          loop xs
2855
            ((Result.Ok ""), (Result.Ok ""), (Result.Ok NoName),
2856
              (Result.Ok []), (Result.Ok false))
2857
      | _ -> Result.Error "Vhdl_ast.vhdl_subprogram_spec_t")
2858
  [@ocaml.warning "-A"])
2859

    
2860
let arith_funs = ["+"; "-"; "*"; "/"; "mod"; "rem"; "abs"; "**"; "&"] 
2861
let bool_funs = ["and"; "or"; "nand"; "nor"; "xor"; "not"] 
2862
let rel_funs =
2863
  ["<";
2864
  ">";
2865
  "<=";
2866
  ">=";
2867
  "/=";
2868
  "=";
2869
  "?=";
2870
  "?/=";
2871
  "?<";
2872
  "?<=";
2873
  "?>";
2874
  "?>=";
2875
  "??"] 
2876
let shift_funs = ["sll"; "srl"; "sla"; "sra"; "rol"; "ror"] 
2877
type vhdl_sequential_stmt_t =
2878
  | VarAssign of
2879
  {
2880
  label: vhdl_name_t [@default NoName];
2881
  lhs: vhdl_name_t ;
2882
  rhs: vhdl_expr_t } [@name "VARIABLE_ASSIGNMENT_STATEMENT"]
2883
  | SigSeqAssign of
2884
  {
2885
  label: vhdl_name_t [@default NoName];
2886
  lhs: vhdl_name_t ;
2887
  rhs: vhdl_expr_t list } [@name "SIGNAL_ASSIGNMENT_STATEMENT"]
2888
  | If of
2889
  {
2890
  label: vhdl_name_t [@default NoName];
2891
  if_cases: vhdl_if_case_t list ;
2892
  default: vhdl_sequential_stmt_t list [@default []]} [@name "IF_STATEMENT"]
2893
  | Case of
2894
  {
2895
  label: vhdl_name_t [@default NoName];
2896
  guard: vhdl_expr_t ;
2897
  branches: vhdl_case_item_t list } [@name "CASE_STATEMENT_TREE"]
2898
  | Exit of
2899
  {
2900
  label: vhdl_name_t [@default NoName];
2901
  loop_label: string option [@default Some ""];
2902
  condition: vhdl_expr_t option [@default Some IsNull]}
2903
  [@name "EXIT_STATEMENT"]
2904
  | Assert of
2905
  {
2906
  label: vhdl_name_t [@default NoName];
2907
  cond: vhdl_expr_t ;
2908
  report: vhdl_expr_t [@default IsNull];
2909
  severity: vhdl_expr_t [@default IsNull]} [@name "ASSERTION_STATEMENT"]
2910
  | ProcedureCall of
2911
  {
2912
  label: vhdl_name_t [@default NoName];
2913
  name: vhdl_name_t ;
2914
  assocs: vhdl_assoc_element_t list } [@name "PROCEDURE_CALL_STATEMENT"]
2915
  | Wait [@name "WAIT_STATEMENT"]
2916
  | Null of {
2917
  label: vhdl_name_t [@default NoName]} [@name "NULL_STATEMENT"]
2918
  | Return of {
2919
  label: vhdl_name_t [@default NoName]} [@name "RETURN_STATEMENT"]
2920
and vhdl_if_case_t =
2921
  {
2922
  if_cond: vhdl_expr_t ;
2923
  if_block: vhdl_sequential_stmt_t list }
2924
and vhdl_case_item_t =
2925
  {
2926
  when_cond: vhdl_expr_t list ;
2927
  when_stmt: vhdl_sequential_stmt_t list }
2928

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

    
3148
and show_vhdl_sequential_stmt_t :
3149
  vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string =
3150
  fun x  -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x
3151

    
3152
and pp_vhdl_if_case_t :
3153
  Format.formatter -> vhdl_if_case_t -> Ppx_deriving_runtime.unit =
3154
  let __1 () = pp_vhdl_sequential_stmt_t
3155
  
3156
  and __0 () = pp_vhdl_expr_t
3157
   in
3158
  ((let open! Ppx_deriving_runtime in
3159
      fun fmt  ->
3160
        fun x  ->
3161
          Format.fprintf fmt " (";
3162
          ((__0 ()) fmt) x.if_cond;
3163
          Format.fprintf fmt ") then@;<0 2>";
3164
          ((fun x  ->
3165
             ignore
3166
               (List.fold_left
3167
                  (fun sep  ->
3168
                     fun x  ->
3169
                             if sep then Format.fprintf fmt "@;<0 2>";
3170
                       ((__1 ()) fmt) x;
3171
                       true) false x);
3172
          )) x.if_block;)
3173
    [@ocaml.warning "-A"])
3174

    
3175
and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string =
3176
  fun x  -> Format.asprintf "%a" pp_vhdl_if_case_t x
3177

    
3178
and pp_vhdl_case_item_t :
3179
  Format.formatter -> vhdl_case_item_t -> Ppx_deriving_runtime.unit =
3180
  let __1 () = pp_vhdl_sequential_stmt_t
3181
  
3182
  and __0 () = pp_vhdl_expr_t
3183
   in
3184
  ((let open! Ppx_deriving_runtime in
3185
      fun fmt  ->
3186
        fun x  ->
3187
                Format.fprintf fmt "@;@[<v 2>when ";
3188
            ((fun x  ->
3189
                ignore
3190
                  (List.fold_left
3191
                     (fun sep  ->
3192
                        fun x  ->
3193
                          if sep then Format.fprintf fmt "@ |@ ";
3194
                          ((__0 ()) fmt) x;
3195
                          true) false x);)) x.when_cond;
3196
           Format.fprintf fmt " => ";
3197
           (fun x  ->
3198
               ignore
3199
                 (List.fold_left
3200
                    (fun sep  ->
3201
                       fun x  ->
3202
                         if sep then Format.fprintf fmt "@;";
3203
                         ((__1 ()) fmt) x;
3204
                         Format.fprintf fmt ";";
3205
                         true) ((List.length x) > 1) x);) x.when_stmt;
3206
           Format.fprintf fmt "@]")
3207
    [@ocaml.warning "-A"])
3208

    
3209
and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string =
3210
  fun x  -> Format.asprintf "%a" pp_vhdl_case_item_t x
3211

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

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

    
3780
and (vhdl_if_case_t_to_yojson : vhdl_if_case_t -> Yojson.Safe.json) =
3781
  ((let open! Ppx_deriving_yojson_runtime in
3782
      fun x  ->
3783
        let fields = []  in
3784
        let fields =
3785
          ("if_block",
3786
            ((fun x  ->
3787
                `List
3788
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3789
               x.if_block))
3790
          :: fields  in
3791
        let fields =
3792
          ("if_cond", ((fun x  -> vhdl_expr_t_to_yojson x) x.if_cond)) ::
3793
          fields  in
3794
        `Assoc fields)
3795
  [@ocaml.warning "-A"])
3796

    
3797
and (vhdl_if_case_t_of_yojson :
3798
      Yojson.Safe.json -> vhdl_if_case_t Ppx_deriving_yojson_runtime.error_or)
3799
  =
3800
  ((let open! Ppx_deriving_yojson_runtime in
3801
      function
3802
      | `Assoc xs ->
3803
          let rec loop xs ((arg0,arg1) as _state) =
3804
            match xs with
3805
            | ("if_cond",x)::xs ->
3806
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
3807
            | ("if_block",x)::xs ->
3808
                loop xs
3809
                  (arg0,
3810
                    ((function
3811
                      | `List xs ->
3812
                          map_bind
3813
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3814
                            xs
3815
                      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t.if_block")
3816
                       x))
3817
            | [] ->
3818
                arg1 >>=
3819
                  ((fun arg1  ->
3820
                      arg0 >>=
3821
                        (fun arg0  ->
3822
                           Result.Ok { if_cond = arg0; if_block = arg1 })))
3823
            | _::xs -> loop xs _state  in
3824
          loop xs
3825
            ((Result.Error "Vhdl_ast.vhdl_if_case_t.if_cond"),
3826
              (Result.Error "Vhdl_ast.vhdl_if_case_t.if_block"))
3827
      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t")
3828
  [@ocaml.warning "-A"])
3829

    
3830
and (vhdl_case_item_t_to_yojson : vhdl_case_item_t -> Yojson.Safe.json) =
3831
  ((let open! Ppx_deriving_yojson_runtime in
3832
      fun x  ->
3833
        let fields = []  in
3834
        let fields =
3835
          ("when_stmt",
3836
            ((fun x  ->
3837
                `List
3838
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3839
               x.when_stmt))
3840
          :: fields  in
3841
        let fields =
3842
          ("when_cond",
3843
            ((fun x  ->
3844
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
3845
               x.when_cond))
3846
          :: fields  in
3847
        `Assoc fields)
3848
  [@ocaml.warning "-A"])
3849

    
3850
and (vhdl_case_item_t_of_yojson :
3851
      Yojson.Safe.json ->
3852
        vhdl_case_item_t Ppx_deriving_yojson_runtime.error_or)
3853
  =
3854
  ((let open! Ppx_deriving_yojson_runtime in
3855
      function
3856
      | `Assoc xs ->
3857
          let rec loop xs ((arg0,arg1) as _state) =
3858
            match xs with
3859
            | ("when_cond",x)::xs ->
3860
                loop xs
3861
                  (((function
3862
                     | `List xs ->
3863
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
3864
                     | _ ->
3865
                         Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond")
3866
                      x), arg1)
3867
            | ("when_stmt",x)::xs ->
3868
                loop xs
3869
                  (arg0,
3870
                    ((function
3871
                      | `List xs ->
3872
                          map_bind
3873
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3874
                            xs
3875
                      | _ ->
3876
                          Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt")
3877
                       x))
3878
            | [] ->
3879
                arg1 >>=
3880
                  ((fun arg1  ->
3881
                      arg0 >>=
3882
                        (fun arg0  ->
3883
                           Result.Ok { when_cond = arg0; when_stmt = arg1 })))
3884
            | _::xs -> loop xs _state  in
3885
          loop xs
3886
            ((Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond"),
3887
              (Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt"))
3888
      | _ -> Result.Error "Vhdl_ast.vhdl_case_item_t")
3889
  [@ocaml.warning "-A"])
3890

    
3891
type vhdl_port_mode_t =
3892
  | InPort [@name "in"]
3893
  | OutPort [@name "out"]
3894
  | InoutPort [@name "inout"]
3895
  | BufferPort [@name "buffer"]
3896

    
3897
let rec (pp_vhdl_port_mode_t :
3898
          Format.formatter -> vhdl_port_mode_t -> Ppx_deriving_runtime.unit)
3899
  =
3900
  ((let open! Ppx_deriving_runtime in
3901
      fun fmt  ->
3902
        function
3903
        | InPort  -> Format.pp_print_string fmt "in"
3904
        | OutPort  -> Format.pp_print_string fmt "out"
3905
        | InoutPort  -> Format.pp_print_string fmt "inout"
3906
        | BufferPort  -> Format.pp_print_string fmt "buffer")
3907
  [@ocaml.warning "-A"])
3908

    
3909
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string =
3910
  fun x  -> Format.asprintf "%a" pp_vhdl_port_mode_t x
3911

    
3912
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) =
3913
  ((let open! Ppx_deriving_yojson_runtime in
3914
      function
3915
      | InPort  -> `List [`String "in"]
3916
      | OutPort  -> `List [`String "out"]
3917
      | InoutPort  -> `List [`String "inout"]
3918
      | BufferPort  -> `List [`String "buffer"])
3919
  [@ocaml.warning "-A"])
3920

    
3921
and (vhdl_port_mode_t_of_yojson :
3922
      Yojson.Safe.json ->
3923
        vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or)
3924
  =
3925
  ((let open! Ppx_deriving_yojson_runtime in
3926
      function
3927
      | `List ((`String "in")::[]) -> Result.Ok InPort
3928
      | `List ((`String "out")::[]) -> Result.Ok OutPort
3929
      | `List ((`String "inout")::[]) -> Result.Ok InoutPort
3930
      | `List ((`String "buffer")::[]) -> Result.Ok BufferPort
3931
      | _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t")
3932
  [@ocaml.warning "-A"])
3933

    
3934
type vhdl_port_t =
3935
  {
3936
  names: vhdl_name_t list [@default []];
3937
  mode: vhdl_port_mode_t [@default InPort];
3938
  typ: vhdl_subtype_indication_t ;
3939
  expr: vhdl_expr_t [@default IsNull]}
3940

    
3941
let rec pp_vhdl_port_t :
3942
  Format.formatter -> vhdl_port_t -> Ppx_deriving_runtime.unit =
3943
  let __3 () = pp_vhdl_expr_t
3944
  
3945
  and __2 () = pp_vhdl_subtype_indication_t
3946
  
3947
  and __1 () = pp_vhdl_port_mode_t
3948
  
3949
  and __0 () = pp_vhdl_name_t
3950
   in
3951
  ((let open! Ppx_deriving_runtime in
3952
      fun fmt  ->
3953
        fun x  ->
3954
          Format.fprintf fmt "@[";
3955
          ((((
3956
              ((fun x  ->
3957
                  Format.fprintf fmt "@[";
3958
                  ignore
3959
                    (List.fold_left
3960
                       (fun sep  ->
3961
                          fun x  ->
3962
                            if sep then Format.fprintf fmt ",@ ";
3963
                            ((__0 ()) fmt) x;
3964
                            true) false x);
3965
                  Format.fprintf fmt "@,@]")) x.names;
3966
              );
3967
             Format.fprintf fmt ": ";
3968
             ((__1 ()) fmt) x.mode;
3969
             );
3970
             Format.fprintf fmt " ";
3971
            ((__2 ()) fmt) x.typ;
3972
            );
3973
          (match x.expr with
3974
           | IsNull -> Format.fprintf fmt "";
3975
           | _ -> (Format.fprintf fmt "@[:= ";
3976
                   ((__3 ()) fmt) x.expr;
3977
                   Format.fprintf fmt "@]"));
3978
          Format.fprintf fmt "@]"))
3979
    [@ocaml.warning "-A"])
3980

    
3981
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string =
3982
  fun x  -> Format.asprintf "%a" pp_vhdl_port_t x
3983

    
3984
let rec (vhdl_port_t_to_yojson : vhdl_port_t -> Yojson.Safe.json) =
3985
  ((let open! Ppx_deriving_yojson_runtime in
3986
      fun x  ->
3987
        let fields = []  in
3988
        let fields =
3989
          if x.expr = IsNull
3990
          then fields
3991
          else ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) x.expr)) ::
3992
            fields
3993
           in
3994
        let fields =
3995
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
3996
          :: fields  in
3997
        let fields =
3998
          if x.mode = InPort
3999
          then fields
4000
          else ("mode", (((fun x  -> vhdl_port_mode_t_to_yojson x)) x.mode))
4001
            :: fields
4002
           in
4003
        let fields =
4004
          if x.names = []
4005
          then fields
4006
          else
4007
            ("names",
4008
              (((fun x  ->
4009
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
4010
                 x.names))
4011
            :: fields
4012
           in
4013
        `Assoc fields)
4014
  [@ocaml.warning "-A"])
4015

    
4016
and (vhdl_port_t_of_yojson :
4017
      Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
4018
  =
4019
  ((let open! Ppx_deriving_yojson_runtime in
4020
      function
4021
      | `Assoc xs ->
4022
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
4023
            match xs with
4024
            | ("names",x)::xs ->
4025
                loop xs
4026
                  (((function
4027
                     | `List xs ->
4028
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4029
                     | _ -> Result.Error "Vhdl_ast.vhdl_port_t.names") x),
4030
                    arg1, arg2, arg3)
4031
            | ("mode",x)::xs ->
4032
                loop xs
4033
                  (arg0, ((fun x  -> vhdl_port_mode_t_of_yojson x) x), arg2,
4034
                    arg3)
4035
            | ("typ",x)::xs ->
4036
                loop xs
4037
                  (arg0, arg1,
4038
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
4039
                    arg3)
4040
            | ("expr",x)::xs ->
4041
                loop xs
4042
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4043
            | [] ->
4044
                arg3 >>=
4045
                  ((fun arg3  ->
4046
                      arg2 >>=
4047
                        (fun arg2  ->
4048
                           arg1 >>=
4049
                             (fun arg1  ->
4050
                                arg0 >>=
4051
                                  (fun arg0  ->
4052
                                     Result.Ok
4053
                                       {
4054
                                         names = arg0;
4055
                                         mode = arg1;
4056
                                         typ = arg2;
4057
                                         expr = arg3
4058
                                       })))))
4059
            | _::xs -> loop xs _state  in
4060
          loop xs
4061
            ((Result.Ok []), (Result.Ok InPort),
4062
              (Result.Error "Vhdl_ast.vhdl_port_t.typ"), (Result.Ok IsNull))
4063
      | _ -> Result.Error "Vhdl_ast.vhdl_port_t")
4064
  [@ocaml.warning "-A"])
4065
type vhdl_declaration_t =
4066
  | VarDecl of
4067
  {
4068
  names: vhdl_name_t list ;
4069
  typ: vhdl_subtype_indication_t ;
4070
  init_val: vhdl_expr_t [@default IsNull]} [@name "VARIABLE_DECLARATION"]
4071
  | CstDecl of
4072
  {
4073
  names: vhdl_name_t list ;
4074
  typ: vhdl_subtype_indication_t ;
4075
  init_val: vhdl_expr_t } [@name "CONSTANT_DECLARATION"]
4076
  | SigDecl of
4077
  {
4078
  names: vhdl_name_t list ;
4079
  typ: vhdl_subtype_indication_t ;
4080
  init_val: vhdl_expr_t [@default IsNull]} [@name "SIGNAL_DECLARATION"]
4081
  | ComponentDecl of
4082
  {
4083
  name: vhdl_name_t [@default NoName];
4084
  generics: vhdl_port_t list [@default []];
4085
  ports: vhdl_port_t list [@default []]} [@name "COMPONENT_DECLARATION"]
4086
  | Subprogram of
4087
  {
4088
  spec: vhdl_subprogram_spec_t ;
4089
  decl_part: vhdl_declaration_t list [@default []];
4090
  stmts: vhdl_sequential_stmt_t list [@default []]} [@name "SUBPROGRAM_BODY"]
4091

    
4092
let rec pp_vhdl_declaration_t :
4093
  Format.formatter -> vhdl_declaration_t -> Ppx_deriving_runtime.unit =
4094
  let __14 () = pp_vhdl_sequential_stmt_t
4095
  
4096
  and __13 () = pp_vhdl_declaration_t
4097
  
4098
  and __12 () = pp_vhdl_subprogram_spec_t
4099

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

    
4231
and show_vhdl_declaration_t :
4232
  vhdl_declaration_t -> Ppx_deriving_runtime.string =
4233
  fun x  -> Format.asprintf "%a" pp_vhdl_declaration_t x
4234

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

    
4374
and (vhdl_declaration_t_of_yojson :
4375
      Yojson.Safe.json ->
4376
        vhdl_declaration_t Ppx_deriving_yojson_runtime.error_or)
4377
  =
4378
  ((let open! Ppx_deriving_yojson_runtime in
4379
      function
4380
      | `List ((`String "VARIABLE_DECLARATION")::arg0::[]) ->
4381
          ((function
4382
            | `Assoc xs ->
4383
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4384
                  match xs with
4385
                  | ("names",x)::xs ->
4386
                      loop xs
4387
                        (((function
4388
                           | `List xs ->
4389
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4390
                                 [] xs
4391
                           | _ ->
4392
                               Result.Error
4393
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4394
                          arg1, arg2)
4395
                  | ("typ",x)::xs ->
4396
                      loop xs
4397
                        (arg0,
4398
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4399
                             x), arg2)
4400
                  | ("init_val",x)::xs ->
4401
                      loop xs
4402
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4403
                  | [] ->
4404
                      arg2 >>=
4405
                        ((fun arg2  ->
4406
                            arg1 >>=
4407
                              (fun arg1  ->
4408
                                 arg0 >>=
4409
                                   (fun arg0  ->
4410
                                      Result.Ok
4411
                                        (VarDecl
4412
                                           {
4413
                                             names = arg0;
4414
                                             typ = arg1;
4415
                                             init_val = arg2
4416
                                           })))))
4417
                  | _::xs -> loop xs _state  in
4418
                loop xs
4419
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4420
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4421
                    (Result.Ok IsNull))
4422
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4423
      | `List ((`String "CONSTANT_DECLARATION")::arg0::[]) ->
4424
          ((function
4425
            | `Assoc xs ->
4426
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4427
                  match xs with
4428
                  | ("names",x)::xs ->
4429
                      loop xs
4430
                        (((function
4431
                           | `List xs ->
4432
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4433
                                 [] xs
4434
                           | _ ->
4435
                               Result.Error
4436
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4437
                          arg1, arg2)
4438
                  | ("typ",x)::xs ->
4439
                      loop xs
4440
                        (arg0,
4441
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4442
                             x), arg2)
4443
                  | ("init_val",x)::xs ->
4444
                      loop xs
4445
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4446
                  | [] ->
4447
                      arg2 >>=
4448
                        ((fun arg2  ->
4449
                            arg1 >>=
4450
                              (fun arg1  ->
4451
                                 arg0 >>=
4452
                                   (fun arg0  ->
4453
                                      Result.Ok
4454
                                        (CstDecl
4455
                                           {
4456
                                             names = arg0;
4457
                                             typ = arg1;
4458
                                             init_val = arg2
4459
                                           })))))
4460
                  | _::xs -> loop xs _state  in
4461
                loop xs
4462
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4463
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4464
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.init_val"))
4465
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4466
      | `List ((`String "SIGNAL_DECLARATION")::arg0::[]) ->
4467
          ((function
4468
            | `Assoc xs ->
4469
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4470
                  match xs with
4471
                  | ("names",x)::xs ->
4472
                      loop xs
4473
                        (((function
4474
                           | `List xs ->
4475
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4476
                                 [] xs
4477
                           | _ ->
4478
                               Result.Error
4479
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4480
                          arg1, arg2)
4481
                  | ("typ",x)::xs ->
4482
                      loop xs
4483
                        (arg0,
4484
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4485
                             x), arg2)
4486
                  | ("init_val",x)::xs ->
4487
                      loop xs
4488
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4489
                  | [] ->
4490
                      arg2 >>=
4491
                        ((fun arg2  ->
4492
                            arg1 >>=
4493
                              (fun arg1  ->
4494
                                 arg0 >>=
4495
                                   (fun arg0  ->
4496
                                      Result.Ok
4497
                                        (SigDecl
4498
                                           {
4499
                                             names = arg0;
4500
                                             typ = arg1;
4501
                                             init_val = arg2
4502
                                           })))))
4503
                  | _::xs -> loop xs _state  in
4504
                loop xs
4505
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4506
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4507
                    (Result.Ok IsNull))
4508
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4509
      | `List ((`String "COMPONENT_DECLARATION")::arg0::[]) ->
4510
          ((function
4511
            | `Assoc xs ->
4512
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4513
                  match xs with
4514
                  | ("name",x)::xs ->
4515
                      loop xs
4516
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
4517
                  | ("generics",x)::xs ->
4518
                      loop xs
4519
                        (arg0,
4520
                          ((function
4521
                            | `List xs ->
4522
                                map_bind (fun x  -> vhdl_port_t_of_yojson x)
4523
                                  [] xs
4524
                            | _ ->
4525
                                Result.Error
4526
                                  "Vhdl_ast.vhdl_declaration_t.generics") x),
4527
                          arg2)
4528
                  | ("ports",x)::xs ->
4529
                      loop xs
4530
                        (arg0, arg1,
4531
                          ((function
4532
                            | `List xs ->
4533
                                map_bind (fun x  -> vhdl_port_t_of_yojson x)
4534
                                  [] xs
4535
                            | _ ->
4536
                                Result.Error
4537
                                  "Vhdl_ast.vhdl_declaration_t.ports") x))
4538
                  | [] ->
4539
                      arg2 >>=
4540
                        ((fun arg2  ->
4541
                            arg1 >>=
4542
                              (fun arg1  ->
4543
                                 arg0 >>=
4544
                                   (fun arg0  ->
4545
                                      Result.Ok
4546
                                        (ComponentDecl
4547
                                           {
4548
                                             name = arg0;
4549
                                             generics = arg1;
4550
                                             ports = arg2
4551
                                           })))))
4552
                  | _::xs -> loop xs _state  in
4553
                loop xs ((Result.Ok NoName), (Result.Ok []), (Result.Ok []))
4554
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4555
      | `List ((`String "SUBPROGRAM_BODY")::arg0::[]) ->
4556
          ((function
4557
            | `Assoc xs ->
4558
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4559
                  match xs with
4560
                  | ("spec",x)::xs ->
4561
                      loop xs
4562
                        (((fun x  -> vhdl_subprogram_spec_t_of_yojson x) x),
4563
                          arg1, arg2)
4564
                  | ("decl_part",x)::xs ->
4565
                      loop xs
4566
                        (arg0,
4567
                          ((function
4568
                            | `List xs ->
4569
                                map_bind
4570
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4571
                                  [] xs
4572
                            | _ ->
4573
                                Result.Error
4574
                                  "Vhdl_ast.vhdl_declaration_t.decl_part") x),
4575
                          arg2)
4576
                  | ("stmts",x)::xs ->
4577
                      loop xs
4578
                        (arg0, arg1,
4579
                          ((function
4580
                            | `List xs ->
4581
                                map_bind
4582
                                  (fun x  ->
4583
                                     vhdl_sequential_stmt_t_of_yojson x) []
4584
                                  xs
4585
                            | _ ->
4586
                                Result.Error
4587
                                  "Vhdl_ast.vhdl_declaration_t.stmts") x))
4588
                  | [] ->
4589
                      arg2 >>=
4590
                        ((fun arg2  ->
4591
                            arg1 >>=
4592
                              (fun arg1  ->
4593
                                 arg0 >>=
4594
                                   (fun arg0  ->
4595
                                      Result.Ok
4596
                                        (Subprogram
4597
                                           {
4598
                                             spec = arg0;
4599
                                             decl_part = arg1;
4600
                                             stmts = arg2
4601
                                           })))))
4602
                  | _::xs -> loop xs _state  in
4603
                loop xs
4604
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.spec"),
4605
                    (Result.Ok []), (Result.Ok []))
4606
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4607
      | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")
4608
  [@ocaml.warning "-A"])
4609

    
4610
type vhdl_load_t =
4611
  | Library of vhdl_name_t list [@name "LIBRARY_CLAUSE"][@default []]
4612
  | Use of vhdl_name_t list [@name "USE_CLAUSE"][@default []]
4613

    
4614
(* Adapted. TODO: check indentation *)
4615
let rec pp_vhdl_load_t :
4616
  Format.formatter -> vhdl_load_t -> Ppx_deriving_runtime.unit =
4617
  let __1 () = pp_vhdl_name_t
4618
  
4619
  and __0 () = pp_vhdl_name_t
4620
   in
4621
  ((let open! Ppx_deriving_runtime in
4622
      fun fmt  ->
4623
        function
4624
        | Library a0 ->
4625
            (Format.fprintf fmt "library ";
4626
             ((fun x  ->
4627
                 ignore
4628
                   (List.fold_left
4629
                      (fun sep  ->
4630
                         fun x  ->
4631
                           if sep then Format.fprintf fmt ".";
4632
                           ((__0 ()) fmt) x;
4633
                           true) false x))) a0;
4634
             Format.fprintf fmt ":")
4635
        | Use a0 ->
4636
            (Format.fprintf fmt "use ";
4637
             ((fun x  ->
4638
                 ignore
4639
                   (List.fold_left
4640
                      (fun sep  ->
4641
                         fun x  ->
4642
                           if sep then Format.fprintf fmt ".";
4643
                           ((__1 ()) fmt) x;
4644
                           true) false x))) a0;
4645
             Format.fprintf fmt ";"))
4646
    [@ocaml.warning "-A"])
4647

    
4648
and show_vhdl_load_t : vhdl_load_t -> Ppx_deriving_runtime.string =
4649
  fun x  -> Format.asprintf "%a" pp_vhdl_load_t x
4650

    
4651
let rec (vhdl_load_t_to_yojson : vhdl_load_t -> Yojson.Safe.json) =
4652
  ((let open! Ppx_deriving_yojson_runtime in
4653
      function
4654
      | Library arg0 ->
4655
          `List
4656
            [`String "LIBRARY_CLAUSE";
4657
            ((fun x  ->
4658
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
4659
      | Use arg0 ->
4660
          `List
4661
            [`String "USE_CLAUSE";
4662
            ((fun x  ->
4663
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0])
4664
  [@ocaml.warning "-A"])
4665

    
4666
and (vhdl_load_t_of_yojson :
4667
      Yojson.Safe.json -> vhdl_load_t Ppx_deriving_yojson_runtime.error_or)
4668
  =
4669
  ((let open! Ppx_deriving_yojson_runtime in
4670
      function
4671
      | `List ((`String "LIBRARY_CLAUSE")::arg0::[]) ->
4672
          ((function
4673
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4674
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
4675
            ((fun arg0  -> Result.Ok (Library arg0)))
4676
      | `List ((`String "USE_CLAUSE")::arg0::[]) ->
4677
          ((function
4678
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4679
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
4680
            ((fun arg0  -> Result.Ok (Use arg0)))
4681
      | _ -> Result.Error "Vhdl_ast.vhdl_load_t")
4682
  [@ocaml.warning "-A"])
4683

    
4684
type vhdl_declarative_item_t =
4685
  {
4686
  use_clause: vhdl_load_t option [@default None];
4687
  declaration: vhdl_declaration_t option [@default None];
4688
  definition: vhdl_definition_t option [@default None]}[@@deriving
4689
                                                         ((show
4690
                                                             {
4691
                                                               with_path =
4692
                                                                 false
4693
                                                             }),
4694
                                                           (yojson
4695
                                                              {
4696
                                                                strict =
4697
                                                                  false
4698
                                                              }))]
4699
let rec pp_vhdl_declarative_item_t :
4700
  Format.formatter -> vhdl_declarative_item_t -> Ppx_deriving_runtime.unit =
4701
  let __2 () = pp_vhdl_definition_t
4702
  
4703
  and __1 () = pp_vhdl_declaration_t
4704
  
4705
  and __0 () = pp_vhdl_load_t
4706
   in
4707
  ((let open! Ppx_deriving_runtime in
4708
      fun fmt  ->
4709
        fun x  ->
4710
          (match x.use_clause with
4711
          | None -> Format.fprintf fmt "";
4712
          | Some e -> ((__0 ()) fmt) e);
4713
          (match x.declaration with
4714
          | None -> Format.fprintf fmt "";
4715
          | Some e -> ((__1 ()) fmt) e);
4716
          (match x.definition with
4717
          | None -> Format.fprintf fmt "";
4718
          | Some e -> ((__2 ()) fmt) e);)
4719
    [@ocaml.warning "-A"])
4720

    
4721
and show_vhdl_declarative_item_t :
4722
  vhdl_declarative_item_t -> Ppx_deriving_runtime.string =
4723
  fun x  -> Format.asprintf "%a" pp_vhdl_declarative_item_t x
4724

    
4725
let rec (vhdl_declarative_item_t_to_yojson :
4726
          vhdl_declarative_item_t -> Yojson.Safe.json)
4727
  =
4728
  ((let open! Ppx_deriving_yojson_runtime in
4729
      fun x  ->
4730
        let fields = []  in
4731
        let fields =
4732
          if x.definition = None
4733
          then fields
4734
          else
4735
            ("definition",
4736
              (((function
4737
                 | None  -> `Null
4738
                 | Some x -> ((fun x  -> vhdl_definition_t_to_yojson x)) x))
4739
                 x.definition))
4740
            :: fields
4741
           in
4742
        let fields =
4743
          if x.declaration = None
4744
          then fields
4745
          else
4746
            ("declaration",
4747
              (((function
4748
                 | None  -> `Null
4749
                 | Some x -> ((fun x  -> vhdl_declaration_t_to_yojson x)) x))
4750
                 x.declaration))
4751
            :: fields
4752
           in
4753
        let fields =
4754
          if x.use_clause = None
4755
          then fields
4756
          else
4757
            ("use_clause",
4758
              (((function
4759
                 | None  -> `Null
4760
                 | Some x -> ((fun x  -> vhdl_load_t_to_yojson x)) x))
4761
                 x.use_clause))
4762
            :: fields
4763
           in
4764
        `Assoc fields)
4765
  [@ocaml.warning "-A"])
4766

    
4767
and (vhdl_declarative_item_t_of_yojson :
4768
      Yojson.Safe.json ->
4769
        vhdl_declarative_item_t Ppx_deriving_yojson_runtime.error_or)
4770
  =
4771
  ((let open! Ppx_deriving_yojson_runtime in
4772
      function
4773
      | `Assoc xs ->
4774
          let rec loop xs ((arg0,arg1,arg2) as _state) =
4775
            match xs with
4776
            | ("use_clause",x)::xs ->
4777
                loop xs
4778
                  (((function
4779
                     | `Null -> Result.Ok None
4780
                     | x ->
4781
                         ((fun x  -> vhdl_load_t_of_yojson x) x) >>=
4782
                           ((fun x  -> Result.Ok (Some x)))) x), arg1, arg2)
4783
            | ("declaration",x)::xs ->
4784
                loop xs
4785
                  (arg0,
4786
                    ((function
4787
                      | `Null -> Result.Ok None
4788
                      | x ->
4789
                          ((fun x  -> vhdl_declaration_t_of_yojson x) x) >>=
4790
                            ((fun x  -> Result.Ok (Some x)))) x), arg2)
4791
            | ("definition",x)::xs ->
4792
                loop xs
4793
                  (arg0, arg1,
4794
                    ((function
4795
                      | `Null -> Result.Ok None
4796
                      | x ->
4797
                          ((fun x  -> vhdl_definition_t_of_yojson x) x) >>=
4798
                            ((fun x  -> Result.Ok (Some x)))) x))
4799
            | [] ->
4800
                arg2 >>=
4801
                  ((fun arg2  ->
4802
                      arg1 >>=
4803
                        (fun arg1  ->
4804
                           arg0 >>=
4805
                             (fun arg0  ->
4806
                                Result.Ok
4807
                                  {
4808
                                    use_clause = arg0;
4809
                                    declaration = arg1;
4810
                                    definition = arg2
4811
                                  }))))
4812
            | _::xs -> loop xs _state  in
4813
          loop xs ((Result.Ok None), (Result.Ok None), (Result.Ok None))
4814
      | _ -> Result.Error "Vhdl_ast.vhdl_declarative_item_t")
4815
  [@ocaml.warning "-A"])
4816

    
4817
type vhdl_signal_condition_t =
4818
  {
4819
  expr: vhdl_expr_t list ;
4820
  cond: vhdl_expr_t [@default IsNull]}
4821

    
4822
let rec pp_vhdl_signal_condition_t :
4823
  Format.formatter -> vhdl_signal_condition_t -> Ppx_deriving_runtime.unit =
4824
  let __1 () = pp_vhdl_expr_t
4825
  
4826
  and __0 () = pp_vhdl_expr_t
4827
   in
4828
  ((let open! Ppx_deriving_runtime in
4829
      fun fmt  ->
4830
        fun x  ->
4831
          ((fun x  ->
4832
              ignore
4833
                (List.fold_left
4834
                   (fun sep  ->
4835
                      fun x  ->
4836
                        if sep then Format.fprintf fmt ";@ ";
4837
                        ((__0 ()) fmt) x;
4838
                        true) false x))) x.expr;
4839
          (match x.cond with
4840
          | IsNull -> Format.fprintf fmt "";
4841
          | _ -> Format.fprintf fmt "when ";
4842
                 ((__1 ()) fmt) x.cond);)
4843
    [@ocaml.warning "-A"])
4844

    
4845
and show_vhdl_signal_condition_t :
4846
  vhdl_signal_condition_t -> Ppx_deriving_runtime.string =
4847
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_condition_t x
4848

    
4849
let rec (vhdl_signal_condition_t_to_yojson :
4850
          vhdl_signal_condition_t -> Yojson.Safe.json)
4851
  =
4852
  ((let open! Ppx_deriving_yojson_runtime in
4853
      fun x  ->
4854
        let fields = []  in
4855
        let fields =
4856
          if x.cond = IsNull
4857
          then fields
4858
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4859
            fields
4860
           in
4861
        let fields =
4862
          ("expr",
4863
            ((fun x  ->
4864
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
4865
               x.expr))
4866
          :: fields  in
4867
        `Assoc fields)
4868
  [@ocaml.warning "-A"])
4869

    
4870
and (vhdl_signal_condition_t_of_yojson :
4871
      Yojson.Safe.json ->
4872
        vhdl_signal_condition_t Ppx_deriving_yojson_runtime.error_or)
4873
  =
4874
  ((let open! Ppx_deriving_yojson_runtime in
4875
      function
4876
      | `Assoc xs ->
4877
          let rec loop xs ((arg0,arg1) as _state) =
4878
            match xs with
4879
            | ("expr",x)::xs ->
4880
                loop xs
4881
                  (((function
4882
                     | `List xs ->
4883
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4884
                     | _ ->
4885
                         Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr")
4886
                      x), arg1)
4887
            | ("cond",x)::xs ->
4888
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4889
            | [] ->
4890
                arg1 >>=
4891
                  ((fun arg1  ->
4892
                      arg0 >>=
4893
                        (fun arg0  -> Result.Ok { expr = arg0; cond = arg1 })))
4894
            | _::xs -> loop xs _state  in
4895
          loop xs
4896
            ((Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr"),
4897
              (Result.Ok IsNull))
4898
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_condition_t")
4899
  [@ocaml.warning "-A"])
4900

    
4901
type vhdl_signal_selection_t =
4902
  {
4903
  expr: vhdl_expr_t ;
4904
  when_sel: vhdl_expr_t list [@default []]}
4905

    
4906
(* TODO *)
4907
let rec pp_vhdl_signal_selection_t :
4908
  Format.formatter -> vhdl_signal_selection_t -> Ppx_deriving_runtime.unit =
4909
  let __1 () = pp_vhdl_expr_t
4910
  
4911
  and __0 () = pp_vhdl_expr_t
4912
   in
4913
  ((let open! Ppx_deriving_runtime in
4914
      fun fmt  ->
4915
        fun x  ->
4916
          Format.fprintf fmt "@[<2>{ ";
4917
          ((Format.fprintf fmt "@[%s =@ " "expr";
4918
            ((__0 ()) fmt) x.expr;
4919
            Format.fprintf fmt "@]");
4920
           Format.fprintf fmt ";@ ";
4921
           Format.fprintf fmt "@[%s =@ " "when_sel";
4922
           ((fun x  ->
4923
               Format.fprintf fmt "@[<2>[";
4924
               ignore
4925
                 (List.fold_left
4926
                    (fun sep  ->
4927
                       fun x  ->
4928
                         if sep then Format.fprintf fmt ";@ ";
4929
                         ((__1 ()) fmt) x;
4930
                         true) false x);
4931
               Format.fprintf fmt "@,]@]")) x.when_sel;
4932
           Format.fprintf fmt "@]");
4933
          Format.fprintf fmt "@ }@]")
4934
    [@ocaml.warning "-A"])
4935

    
4936
and show_vhdl_signal_selection_t :
4937
  vhdl_signal_selection_t -> Ppx_deriving_runtime.string =
4938
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_selection_t x
4939

    
4940
let rec (vhdl_signal_selection_t_to_yojson :
4941
          vhdl_signal_selection_t -> Yojson.Safe.json)
4942
  =
4943
  ((let open! Ppx_deriving_yojson_runtime in
4944
      fun x  ->
4945
        let fields = []  in
4946
        let fields =
4947
          if x.when_sel = []
4948
          then fields
4949
          else
4950
            ("when_sel",
4951
              (((fun x  ->
4952
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
4953
                 x.when_sel))
4954
            :: fields
4955
           in
4956
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
4957
          :: fields  in
4958
        `Assoc fields)
4959
  [@ocaml.warning "-A"])
4960

    
4961
and (vhdl_signal_selection_t_of_yojson :
4962
      Yojson.Safe.json ->
4963
        vhdl_signal_selection_t Ppx_deriving_yojson_runtime.error_or)
4964
  =
4965
  ((let open! Ppx_deriving_yojson_runtime in
4966
      function
4967
      | `Assoc xs ->
4968
          let rec loop xs ((arg0,arg1) as _state) =
4969
            match xs with
4970
            | ("expr",x)::xs ->
4971
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
4972
            | ("when_sel",x)::xs ->
4973
                loop xs
4974
                  (arg0,
4975
                    ((function
4976
                      | `List xs ->
4977
                          map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4978
                      | _ ->
4979
                          Result.Error
4980
                            "Vhdl_ast.vhdl_signal_selection_t.when_sel") x))
4981
            | [] ->
4982
                arg1 >>=
4983
                  ((fun arg1  ->
4984
                      arg0 >>=
4985
                        (fun arg0  ->
4986
                           Result.Ok { expr = arg0; when_sel = arg1 })))
4987
            | _::xs -> loop xs _state  in
4988
          loop xs
4989
            ((Result.Error "Vhdl_ast.vhdl_signal_selection_t.expr"),
4990
              (Result.Ok []))
4991
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_selection_t")
4992
  [@ocaml.warning "-A"])
4993

    
4994
type vhdl_conditional_signal_t =
4995
  {
4996
  postponed: bool [@default false];
4997
  label: vhdl_name_t [@default NoName];
4998
  lhs: vhdl_name_t ;
4999
  rhs: vhdl_signal_condition_t list ;
5000
  cond: vhdl_expr_t [@default IsNull];
5001
  delay: vhdl_expr_t [@default IsNull]}
5002

    
5003
let rec pp_vhdl_conditional_signal_t :
5004
  Format.formatter -> vhdl_conditional_signal_t -> Ppx_deriving_runtime.unit
5005
  =
5006
  let __4 () = pp_vhdl_expr_t
5007
  
5008
  and __3 () = pp_vhdl_expr_t
5009
  
5010
  and __2 () = pp_vhdl_signal_condition_t
5011
  
5012
  and __1 () = pp_vhdl_name_t
5013
  
5014
  and __0 () = pp_vhdl_name_t
5015
   in
5016
  ((let open! Ppx_deriving_runtime in
5017
      fun fmt  ->
5018
        fun x  ->
5019
          (match x.label with
5020
            | NoName -> Format.fprintf fmt "";
5021
            | _ -> (((__0 ()) fmt) x.label;
5022
                   Format.fprintf fmt ":@ ")
5023
          );
5024
          if (x.postponed) then Format.fprintf fmt "postponed@ ";
5025
          ((__1 ()) fmt) x.lhs;
5026
          Format.fprintf fmt " <= ";
5027
          (match x.delay with
5028
            | IsNull -> Format.fprintf fmt "";
5029
            | _ -> ((__4 ()) fmt) x.delay;
5030
                   Format.fprintf fmt " ");
5031
          ((fun x  ->
5032
             Format.fprintf fmt "@[";
5033
             ignore
5034
               (List.fold_left
5035
                 (fun sep  ->
5036
                   fun x  ->
5037
                     if sep then Format.fprintf fmt "";
5038
                      ((__2 ()) fmt) x;
5039
                      Format.fprintf fmt ";";
5040
                      true) false x);
5041
          Format.fprintf fmt "@]")) x.rhs;
5042
          (match x.cond with
5043
            | IsNull -> Format.fprintf fmt "";
5044
            | _ -> Format.fprintf fmt "when (";
5045
                   ((__3 ()) fmt) x.cond;
5046
                   Format.fprintf fmt ")"))
5047
   [@ocaml.warning "-A"])
5048

    
5049
and show_vhdl_conditional_signal_t :
5050
  vhdl_conditional_signal_t -> Ppx_deriving_runtime.string =
5051
  fun x  -> Format.asprintf "%a" pp_vhdl_conditional_signal_t x
5052

    
5053
let rec (vhdl_conditional_signal_t_to_yojson :
5054
          vhdl_conditional_signal_t -> Yojson.Safe.json)
5055
  =
5056
  ((let open! Ppx_deriving_yojson_runtime in
5057
      fun x  ->
5058
        let fields = []  in
5059
        let fields =
5060
          if x.delay = IsNull
5061
          then fields
5062
          else ("delay", (((fun x  -> vhdl_expr_t_to_yojson x)) x.delay)) ::
5063
            fields
5064
           in
5065
        let fields =
5066
          if x.cond = IsNull
5067
          then fields
5068
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
5069
            fields
5070
           in
5071
        let fields =
5072
          ("rhs",
5073
            ((fun x  ->
5074
                `List
5075
                  (List.map (fun x  -> vhdl_signal_condition_t_to_yojson x) x))
5076
               x.rhs))
5077
          :: fields  in
5078
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
5079
          fields  in
5080
        let fields =
5081
          if x.label = NoName
5082
          then fields
5083
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
5084
            fields
5085
           in
5086
        let fields =
5087
          if x.postponed = false
5088
          then fields
5089
          else
5090
            ("postponed",
5091
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
5092
                 x.postponed))
5093
            :: fields
5094
           in
5095
        `Assoc fields)
5096
  [@ocaml.warning "-A"])
5097

    
5098
and (vhdl_conditional_signal_t_of_yojson :
5099
      Yojson.Safe.json ->
5100
        vhdl_conditional_signal_t Ppx_deriving_yojson_runtime.error_or)
5101
  =
5102
  ((let open! Ppx_deriving_yojson_runtime in
5103
      function
5104
      | `Assoc xs ->
5105
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
5106
            match xs with
5107
            | ("postponed",x)::xs ->
5108
                loop xs
5109
                  (((function
5110
                     | `Bool x -> Result.Ok x
5111
                     | _ ->
5112
                         Result.Error
5113
                           "Vhdl_ast.vhdl_conditional_signal_t.postponed") x),
5114
                    arg1, arg2, arg3, arg4, arg5)
5115
            | ("label",x)::xs ->
5116
                loop xs
5117
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
5118
                    arg4, arg5)
5119
            | ("lhs",x)::xs ->
5120
                loop xs
5121
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
5122
                    arg4, arg5)
5123
            | ("rhs",x)::xs ->
5124
                loop xs
5125
                  (arg0, arg1, arg2,
5126
                    ((function
5127
                      | `List xs ->
5128
                          map_bind
5129
                            (fun x  -> vhdl_signal_condition_t_of_yojson x)
5130
                            [] xs
5131
                      | _ ->
5132
                          Result.Error
5133
                            "Vhdl_ast.vhdl_conditional_signal_t.rhs") x),
5134
                    arg4, arg5)
5135
            | ("cond",x)::xs ->
5136
                loop xs
5137
                  (arg0, arg1, arg2, arg3,
5138
                    ((fun x  -> vhdl_expr_t_of_yojson x) x), arg5)
5139
            | ("delay",x)::xs ->
5140
                loop xs
5141
                  (arg0, arg1, arg2, arg3, arg4,
5142
                    ((fun x  -> vhdl_expr_t_of_yojson x) x))
5143
            | [] ->
5144
                arg5 >>=
5145
                  ((fun arg5  ->
5146
                      arg4 >>=
5147
                        (fun arg4  ->
5148
                           arg3 >>=
5149
                             (fun arg3  ->
5150
                                arg2 >>=
5151
                                  (fun arg2  ->
5152
                                     arg1 >>=
5153
                                       (fun arg1  ->
5154
                                          arg0 >>=
5155
                                            (fun arg0  ->
5156
                                               Result.Ok
5157
                                                 {
5158
                                                   postponed = arg0;
5159
                                                   label = arg1;
5160
                                                   lhs = arg2;
5161
                                                   rhs = arg3;
5162
                                                   cond = arg4;
5163
                                                   delay = arg5
5164
                                                 })))))))
5165
            | _::xs -> loop xs _state  in
5166
          loop xs
5167
            ((Result.Ok false), (Result.Ok NoName),
5168
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.lhs"),
5169
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.rhs"),
5170
              (Result.Ok IsNull), (Result.Ok IsNull))
5171
      | _ -> Result.Error "Vhdl_ast.vhdl_conditional_signal_t")
5172
  [@ocaml.warning "-A"])
5173

    
5174
type vhdl_process_t =
5175
  {
5176
  id: vhdl_name_t [@default NoName];
5177
  declarations: vhdl_declarative_item_t list
5178
    [@key "PROCESS_DECLARATIVE_PART"][@default Some []];
5179
  active_sigs: vhdl_name_t list [@default []];
5180
  body: vhdl_sequential_stmt_t list
5181
    [@key "PROCESS_STATEMENT_PART"][@default []]}
5182

    
5183
let rec pp_vhdl_process_t :
5184
  Format.formatter -> vhdl_process_t -> Ppx_deriving_runtime.unit =
5185
  let __3 () = pp_vhdl_sequential_stmt_t
5186
  
5187
  and __2 () = pp_vhdl_name_t
5188
  
5189
  and __1 () = pp_vhdl_declarative_item_t
5190
  
5191
  and __0 () = pp_vhdl_name_t
5192
   in
5193
  ((let open! Ppx_deriving_runtime in
5194
      fun fmt  ->
5195
        fun x  ->
5196
          Format.fprintf fmt "@[<v 2>";
5197
          (match x.id with
5198
          | NoName -> Format.fprintf fmt "";
5199
          | _ -> 
5200
              ((__0 ()) fmt) x.id;
5201
              Format.fprintf fmt ": ");
5202
          Format.fprintf fmt "process ";
5203
          (match x.active_sigs with
5204
          | [] -> Format.fprintf fmt "";
5205
          | _ -> Format.fprintf fmt "(";
5206
                 ((fun x  ->
5207
                    ignore
5208
                      (List.fold_left
5209
                         (fun sep  ->
5210
                            fun x  ->
5211
                              if sep then Format.fprintf fmt ",";
5212
                              ((__2 ()) fmt) x;
5213
                              true) false x))) x.active_sigs;
5214
                 Format.fprintf fmt ")");
5215
          Format.fprintf fmt " is@;";
5216
          ((fun x  ->
5217
            ignore
5218
            (List.fold_left
5219
              (fun sep  ->
5220
                fun x  ->
5221
                  if sep then Format.fprintf fmt "@;";
5222
                    ((__1 ()) fmt) x;
5223
                    Format.fprintf fmt ";";
5224
                    true) false x))) x.declarations;
5225
          Format.fprintf fmt "@]@;@[<v 2>begin@;";
5226
          ((fun x  ->
5227
               ignore
5228
                 (List.fold_left
5229
                    (fun sep  ->
5230
                       fun x  ->
5231
                         if sep then Format.fprintf fmt "@;";
5232
                         ((__3 ()) fmt) x;
5233
                         Format.fprintf fmt ";";
5234
                         true) false x);)) x.body;
5235
          Format.fprintf fmt "@]@;end process;@;";
5236
          Format.fprintf fmt "@]";)
5237
    [@ocaml.warning "-A"])
5238

    
5239
and show_vhdl_process_t : vhdl_process_t -> Ppx_deriving_runtime.string =
5240
  fun x  -> Format.asprintf "%a" pp_vhdl_process_t x
5241

    
5242
let rec (vhdl_process_t_to_yojson : vhdl_process_t -> Yojson.Safe.json) =
5243
  ((let open! Ppx_deriving_yojson_runtime in
5244
      fun x  ->
5245
        let fields = []  in
5246
        let fields =
5247
          if x.body = []
5248
          then fields
5249
          else
5250
            ("PROCESS_STATEMENT_PART",
5251
              (((fun x  ->
5252
                   `List
5253
                     (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x)
5254
                        x))) x.body))
5255
            :: fields
5256
           in
5257
        let fields =
5258
          if x.active_sigs = []
5259
          then fields
5260
          else
5261
            ("active_sigs",
5262
              (((fun x  ->
5263
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
5264
                 x.active_sigs))
5265
            :: fields
5266
           in
5267
        let fields =
5268
          if x.declarations = []
5269
          then fields
5270
          else
5271
            ("PROCESS_DECLARATIVE_PART",
5272
              (((fun x  ->
5273
                   `List
5274
                     (List.map
5275
                        (fun x  -> vhdl_declarative_item_t_to_yojson x) x)))
5276
                 x.declarations))
5277
            :: fields
5278
           in
5279
        let fields =
5280
          if x.id = NoName
5281
          then fields
5282
          else ("id", (((fun x  -> vhdl_name_t_to_yojson x)) x.id)) :: fields
5283
           in
5284
        `Assoc fields)
5285
  [@ocaml.warning "-A"])
5286

    
5287
and (vhdl_process_t_of_yojson :
5288
      Yojson.Safe.json -> vhdl_process_t Ppx_deriving_yojson_runtime.error_or)
5289
  =
5290
  ((let open! Ppx_deriving_yojson_runtime in
5291
      function
5292
      | `Assoc xs ->
5293
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
5294
            match xs with
5295
            | ("id",x)::xs ->
5296
                loop xs
5297
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3)
5298
            | ("PROCESS_DECLARATIVE_PART",x)::xs ->
5299
                loop xs
5300
                  (arg0,
5301
                    ((function
5302
                      | `List xs ->
5303
                          map_bind
5304
                            (fun x  -> vhdl_declarative_item_t_of_yojson x)
5305
                            [] xs
5306
                      | _ ->
5307
                          Result.Error "Vhdl_ast.vhdl_process_t.declarations")
5308
                       x), arg2, arg3)
5309
            | ("active_sigs",x)::xs ->
5310
                loop xs
5311
                  (arg0, arg1,
5312
                    ((function
5313
                      | `List xs ->
5314
                          map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5315
                      | _ ->
5316
                          Result.Error "Vhdl_ast.vhdl_process_t.active_sigs")
5317
                       x), arg3)
5318
            | ("PROCESS_STATEMENT_PART",x)::xs ->
5319
                loop xs
5320
                  (arg0, arg1, arg2,
5321
                    ((function
5322
                      | `List xs ->
5323
                          map_bind
5324
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
5325
                            xs
5326
                      | _ -> Result.Error "Vhdl_ast.vhdl_process_t.body") x))
5327
            | [] ->
5328
                arg3 >>=
5329
                  ((fun arg3  ->
5330
                      arg2 >>=
5331
                        (fun arg2  ->
5332
                           arg1 >>=
5333
                             (fun arg1  ->
5334
                                arg0 >>=
5335
                                  (fun arg0  ->
5336
                                     Result.Ok
5337
                                       {
5338
                                         id = arg0;
5339
                                         declarations = arg1;
5340
                                         active_sigs = arg2;
5341
                                         body = arg3
5342
                                       })))))
5343
            | _::xs -> loop xs _state  in
5344
          loop xs
5345
            ((Result.Ok NoName), (Result.Ok []), (Result.Ok []),
5346
              (Result.Ok []))
5347
      | _ -> Result.Error "Vhdl_ast.vhdl_process_t")
5348
  [@ocaml.warning "-A"])
5349

    
5350
type vhdl_selected_signal_t =
5351
  {
5352
  postponed: bool [@default false];
5353
  label: vhdl_name_t [@default NoName];
5354
  lhs: vhdl_name_t ;
5355
  sel: vhdl_expr_t ;
5356
  branches: vhdl_signal_selection_t list [@default []];
5357
  delay: vhdl_expr_t option }
5358

    
5359
(* TODO *)
5360
let rec pp_vhdl_selected_signal_t :
5361
  Format.formatter -> vhdl_selected_signal_t -> Ppx_deriving_runtime.unit =
5362
  let __4 () = pp_vhdl_expr_t
5363
  
5364
  and __3 () = pp_vhdl_signal_selection_t
5365
  
5366
  and __2 () = pp_vhdl_expr_t
5367
  
5368
  and __1 () = pp_vhdl_name_t
5369
  
5370
  and __0 () = pp_vhdl_name_t
5371
   in
5372
  ((let open! Ppx_deriving_runtime in
5373
      fun fmt  ->
5374
        fun x  ->
5375
          Format.fprintf fmt "@[<2>{ ";
5376
          ((((((Format.fprintf fmt "@[%s =@ " "postponed";
5377
                (Format.fprintf fmt "%B") x.postponed;
5378
                Format.fprintf fmt "@]");
5379
               Format.fprintf fmt ";@ ";
5380
               Format.fprintf fmt "@[%s =@ " "label";
5381
               ((__0 ()) fmt) x.label;
5382
               Format.fprintf fmt "@]");
5383
              Format.fprintf fmt ";@ ";
5384
              Format.fprintf fmt "@[%s =@ " "lhs";
5385
              ((__1 ()) fmt) x.lhs;
5386
              Format.fprintf fmt "@]");
5387
             Format.fprintf fmt ";@ ";
5388
             Format.fprintf fmt "@[%s =@ " "sel";
5389
             ((__2 ()) fmt) x.sel;
5390
             Format.fprintf fmt "@]");
5391
            Format.fprintf fmt ";@ ";
5392
            Format.fprintf fmt "@[%s =@ " "branches";
5393
            ((fun x  ->
5394
                Format.fprintf fmt "@[<2>[";
5395
                ignore
5396
                  (List.fold_left
5397
                     (fun sep  ->
5398
                        fun x  ->
5399
                          if sep then Format.fprintf fmt ";@ ";
5400
                          ((__3 ()) fmt) x;
5401
                          true) false x);
5402
                Format.fprintf fmt "@,]@]")) x.branches;
5403
            Format.fprintf fmt "@]");
5404
           Format.fprintf fmt ";@ ";
5405
           Format.fprintf fmt "@[%s =@ " "delay";
5406
           ((function
5407
             | None  -> Format.pp_print_string fmt "None"
5408
             | Some x ->
5409
                 (Format.pp_print_string fmt "(Some ";
5410
                  ((__4 ()) fmt) x;
5411
                  Format.pp_print_string fmt ")"))) x.delay;
5412
           Format.fprintf fmt "@]");
5413
          Format.fprintf fmt "@ }@]")
5414
    [@ocaml.warning "-A"])
5415

    
5416
and show_vhdl_selected_signal_t :
5417
  vhdl_selected_signal_t -> Ppx_deriving_runtime.string =
5418
  fun x  -> Format.asprintf "%a" pp_vhdl_selected_signal_t x
5419

    
5420
let rec (vhdl_selected_signal_t_to_yojson :
5421
          vhdl_selected_signal_t -> Yojson.Safe.json)
5422
  =
5423
  ((let open! Ppx_deriving_yojson_runtime in
5424
      fun x  ->
5425
        let fields = []  in
5426
        let fields =
5427
          ("delay",
5428
            ((function
5429
              | None  -> `Null
5430
              | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x) x.delay))
5431
          :: fields  in
5432
        let fields =
5433
          if x.branches = []
5434
          then fields
5435
          else
5436
            ("branches",
5437
              (((fun x  ->
5438
                   `List
5439
                     (List.map
5440
                        (fun x  -> vhdl_signal_selection_t_to_yojson x) x)))
5441
                 x.branches))
5442
            :: fields
5443
           in
5444
        let fields = ("sel", ((fun x  -> vhdl_expr_t_to_yojson x) x.sel)) ::
5445
          fields  in
5446
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
5447
          fields  in
5448
        let fields =
5449
          if x.label = NoName
5450
          then fields
5451
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
5452
            fields
5453
           in
5454
        let fields =
5455
          if x.postponed = false
5456
          then fields
5457
          else
5458
            ("postponed",
5459
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
5460
                 x.postponed))
5461
            :: fields
5462
           in
5463
        `Assoc fields)
5464
  [@ocaml.warning "-A"])
5465

    
5466
and (vhdl_selected_signal_t_of_yojson :
5467
      Yojson.Safe.json ->
5468
        vhdl_selected_signal_t Ppx_deriving_yojson_runtime.error_or)
5469
  =
5470
  ((let open! Ppx_deriving_yojson_runtime in
5471
      function
5472
      | `Assoc xs ->
5473
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
5474
            match xs with
5475
            | ("postponed",x)::xs ->
5476
                loop xs
5477
                  (((function
5478
                     | `Bool x -> Result.Ok x
5479
                     | _ ->
5480
                         Result.Error
5481
                           "Vhdl_ast.vhdl_selected_signal_t.postponed") x),
5482
                    arg1, arg2, arg3, arg4, arg5)
5483
            | ("label",x)::xs ->
5484
                loop xs
5485
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
5486
                    arg4, arg5)
5487
            | ("lhs",x)::xs ->
5488
                loop xs
5489
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
5490
                    arg4, arg5)
5491
            | ("sel",x)::xs ->
5492</