Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / backends / VHDL / vhdl_ast_deriving.ml @ 1f15a1b9

History | View | Annotate | Download (233 KB)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
435
(* TODO adapt for Op, Time, Sig, suffixMod, Aggregate *)
436
and pp_vhdl_expr_t :
437
  Format.formatter -> vhdl_expr_t -> Ppx_deriving_runtime.unit =
438
  let __8 () = pp_vhdl_element_assoc_t
439
  
440
  and __7 () = pp_vhdl_suffix_selection_t
441
  
442
  and __6 () = pp_vhdl_expr_t
443
  
444
  and __5 () = pp_vhdl_signal_attributes_t
445
  
446
  and __4 () = pp_vhdl_name_t
447
  
448
  and __3 () = pp_vhdl_expr_t
449
  
450
  and __2 () = pp_vhdl_name_t
451
  
452
  and __1 () = pp_vhdl_cst_val_t
453
  
454
  and __0 () = pp_vhdl_name_t
455
   in
456
  ((let open! Ppx_deriving_runtime in
457
      fun fmt  ->
458
        function
459
        | Call a0 ->
460
             ((__0 ()) fmt) a0;
461
        | Cst { value = avalue; unit_name = aunit_name } ->
462
             ((__1 ()) fmt) avalue;
463
             (function
464
                | None  -> Format.pp_print_string fmt ""
465
                | Some x ->
466
                    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
            (Format.fprintf fmt "--@[<2>Aggregate {@,";
535
             (Format.fprintf fmt "@[%s =@ " "elems";
536
              ((fun x  ->
537
                  Format.fprintf fmt "@[<2>[";
538
                  ignore
539
                    (List.fold_left
540
                       (fun sep  ->
541
                          fun x  ->
542
                            if sep then Format.fprintf fmt ";@ ";
543
                            ((__8 ()) fmt) x;
544
                            true) false x);
545
                  Format.fprintf fmt "@,]@]")) aelems;
546
              Format.fprintf fmt "@]");
547
             Format.fprintf fmt "@]}")
548
        | Others  -> Format.pp_print_string fmt "others")
549
    [@ocaml.warning "-A"])
550

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4777
and show_vhdl_process_t : vhdl_process_t -> Ppx_deriving_runtime.string =
4778
  fun x  -> Format.asprintf "%a" pp_vhdl_process_t x
4779

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

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

    
4896
type vhdl_selected_signal_t =
4897
  {
4898
  postponed: bool [@default false];
4899
  label: vhdl_name_t [@default NoName];
4900
  lhs: vhdl_name_t ;
4901
  sel: vhdl_expr_t ;
4902
  branches: vhdl_signal_selection_t list [@default []];
4903
  delay: vhdl_expr_t option }
4904

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

    
4962
and show_vhdl_selected_signal_t :
4963
  vhdl_selected_signal_t -> Ppx_deriving_runtime.string =
4964
  fun x  -> Format.asprintf "%a" pp_vhdl_selected_signal_t x
4965

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

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

    
5093
type vhdl_component_instantiation_t =
5094
  {
5095
  name: vhdl_name_t ;
5096
  inst_unit: vhdl_name_t ;
5097
  archi_name: vhdl_name_t option [@default None];
5098
  generic_map: vhdl_assoc_element_t option [@default None];
5099
  port_map: vhdl_assoc_element_t option [@default None]}[@@deriving
5100
                                                          ((show
5101
                                                              {
5102
                                                                with_path =
5103
                                                                  false
5104
                                                              }),
5105
                                                            (yojson
5106
                                                               {
5107
                                                                 strict =
5108
                                                                   false
5109
                                                               }))]
5110

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

    
5152
and show_vhdl_component_instantiation_t :
5153
  vhdl_component_instantiation_t -> Ppx_deriving_runtime.string =
5154
  fun x  -> Format.asprintf "%a" pp_vhdl_component_instantiation_t x
5155

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

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

    
5272
type vhdl_concurrent_stmt_t =
5273
  | SigAssign of vhdl_conditional_signal_t
5274
  [@name "CONDITIONAL_SIGNAL_ASSIGNMENT"]
5275
  | Process of vhdl_process_t [@name "PROCESS_STATEMENT"]
5276
  | SelectedSig of vhdl_selected_signal_t
5277
  [@name "SELECTED_SIGNAL_ASSIGNMENT"]
5278
  | ComponentInst of vhdl_component_instantiation_t
5279
  [@name "COMPONENT_INSTANTIATION_STATEMENT"]
5280

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

    
5305
and show_vhdl_concurrent_stmt_t :
5306
  vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.string =
5307
  fun x  -> Format.asprintf "%a" pp_vhdl_concurrent_stmt_t x
5308

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

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

    
5353
type vhdl_port_mode_t =
5354
  | InPort [@name "in"]
5355
  | OutPort [@name "out"]
5356
  | InoutPort [@name "inout"]
5357
  | BufferPort [@name "buffer"]
5358

    
5359
let rec (pp_vhdl_port_mode_t :
5360
          Format.formatter -> vhdl_port_mode_t -> Ppx_deriving_runtime.unit)
5361
  =
5362
  ((let open! Ppx_deriving_runtime in
5363
      fun fmt  ->
5364
        function
5365
        | InPort  -> Format.pp_print_string fmt "in"
5366
        | OutPort  -> Format.pp_print_string fmt "out"
5367
        | InoutPort  -> Format.pp_print_string fmt "inout"
5368
        | BufferPort  -> Format.pp_print_string fmt "buffer")
5369
  [@ocaml.warning "-A"])
5370

    
5371
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string =
5372
  fun x  -> Format.asprintf "%a" pp_vhdl_port_mode_t x
5373

    
5374
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) =
5375
  ((let open! Ppx_deriving_yojson_runtime in
5376
      function
5377
      | InPort  -> `List [`String "in"]
5378
      | OutPort  -> `List [`String "out"]
5379
      | InoutPort  -> `List [`String "inout"]
5380
      | BufferPort  -> `List [`String "buffer"])
5381
  [@ocaml.warning "-A"])
5382

    
5383
and (vhdl_port_mode_t_of_yojson :
5384
      Yojson.Safe.json ->
5385
        vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or)
5386
  =
5387
  ((let open! Ppx_deriving_yojson_runtime in
5388
      function
5389
      | `List ((`String "in")::[]) -> Result.Ok InPort
5390
      | `List ((`String "out")::[]) -> Result.Ok OutPort
5391
      | `List ((`String "inout")::[]) -> Result.Ok InoutPort
5392
      | `List ((`String "buffer")::[]) -> Result.Ok BufferPort
5393
      | _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t")
5394
  [@ocaml.warning "-A"])
5395

    
5396
type vhdl_port_t =
5397
  {
5398
  names: vhdl_name_t list [@default []];
5399
  mode: vhdl_port_mode_t [@default InPort];
5400
  typ: vhdl_subtype_indication_t ;
5401
  expr: vhdl_expr_t [@default IsNull]}
5402

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

    
5443
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string =
5444
  fun x  -> Format.asprintf "%a" pp_vhdl_port_t x
5445

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

    
5478
and (vhdl_port_t_of_yojson :
5479
      Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
5480
  =
5481
  ((let open! Ppx_deriving_yojson_runtime in