Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / backends / VHDL / vhdl_ast_deriving.ml @ 9d5959cb

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

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

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

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

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

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

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

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

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

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

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

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

    
3850
type vhdl_port_mode_t =
3851
  | InPort [@name "in"]
3852
  | OutPort [@name "out"]
3853
  | InoutPort [@name "inout"]
3854
  | BufferPort [@name "buffer"]
3855

    
3856
let rec (pp_vhdl_port_mode_t :
3857
          Format.formatter -> vhdl_port_mode_t -> Ppx_deriving_runtime.unit)
3858
  =
3859
  ((let open! Ppx_deriving_runtime in
3860
      fun fmt  ->
3861
        function
3862
        | InPort  -> Format.pp_print_string fmt "in"
3863
        | OutPort  -> Format.pp_print_string fmt "out"
3864
        | InoutPort  -> Format.pp_print_string fmt "inout"
3865
        | BufferPort  -> Format.pp_print_string fmt "buffer")
3866
  [@ocaml.warning "-A"])
3867

    
3868
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string =
3869
  fun x  -> Format.asprintf "%a" pp_vhdl_port_mode_t x
3870

    
3871
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) =
3872
  ((let open! Ppx_deriving_yojson_runtime in
3873
      function
3874
      | InPort  -> `List [`String "in"]
3875
      | OutPort  -> `List [`String "out"]
3876
      | InoutPort  -> `List [`String "inout"]
3877
      | BufferPort  -> `List [`String "buffer"])
3878
  [@ocaml.warning "-A"])
3879

    
3880
and (vhdl_port_mode_t_of_yojson :
3881
      Yojson.Safe.json ->
3882
        vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or)
3883
  =
3884
  ((let open! Ppx_deriving_yojson_runtime in
3885
      function
3886
      | `List ((`String "in")::[]) -> Result.Ok InPort
3887
      | `List ((`String "out")::[]) -> Result.Ok OutPort
3888
      | `List ((`String "inout")::[]) -> Result.Ok InoutPort
3889
      | `List ((`String "buffer")::[]) -> Result.Ok BufferPort
3890
      | _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t")
3891
  [@ocaml.warning "-A"])
3892

    
3893
type vhdl_port_t =
3894
  {
3895
  names: vhdl_name_t list [@default []];
3896
  mode: vhdl_port_mode_t [@default InPort];
3897
  typ: vhdl_subtype_indication_t ;
3898
  expr: vhdl_expr_t [@default IsNull]}
3899

    
3900
let rec pp_vhdl_port_t :
3901
  Format.formatter -> vhdl_port_t -> Ppx_deriving_runtime.unit =
3902
  let __3 () = pp_vhdl_expr_t
3903
  
3904
  and __2 () = pp_vhdl_subtype_indication_t
3905
  
3906
  and __1 () = pp_vhdl_port_mode_t
3907
  
3908
  and __0 () = pp_vhdl_name_t
3909
   in
3910
  ((let open! Ppx_deriving_runtime in
3911
      fun fmt  ->
3912
        fun x  ->
3913
          Format.fprintf fmt "@[";
3914
          ((((
3915
              ((fun x  ->
3916
                  Format.fprintf fmt "@[";
3917
                  ignore
3918
                    (List.fold_left
3919
                       (fun sep  ->
3920
                          fun x  ->
3921
                            if sep then Format.fprintf fmt ",@ ";
3922
                            ((__0 ()) fmt) x;
3923
                            true) false x);
3924
                  Format.fprintf fmt "@,@]")) x.names;
3925
              );
3926
             Format.fprintf fmt ": ";
3927
             ((__1 ()) fmt) x.mode;
3928
             );
3929
             Format.fprintf fmt " ";
3930
            ((__2 ()) fmt) x.typ;
3931
            );
3932
          (match x.expr with
3933
           | IsNull -> Format.fprintf fmt "";
3934
           | _ -> (Format.fprintf fmt "@[:= ";
3935
                   ((__3 ()) fmt) x.expr;
3936
                   Format.fprintf fmt "@]"));
3937
          Format.fprintf fmt "@]"))
3938
    [@ocaml.warning "-A"])
3939

    
3940
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string =
3941
  fun x  -> Format.asprintf "%a" pp_vhdl_port_t x
3942

    
3943
let rec (vhdl_port_t_to_yojson : vhdl_port_t -> Yojson.Safe.json) =
3944
  ((let open! Ppx_deriving_yojson_runtime in
3945
      fun x  ->
3946
        let fields = []  in
3947
        let fields =
3948
          if x.expr = IsNull
3949
          then fields
3950
          else ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) x.expr)) ::
3951
            fields
3952
           in
3953
        let fields =
3954
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
3955
          :: fields  in
3956
        let fields =
3957
          if x.mode = InPort
3958
          then fields
3959
          else ("mode", (((fun x  -> vhdl_port_mode_t_to_yojson x)) x.mode))
3960
            :: fields
3961
           in
3962
        let fields =
3963
          if x.names = []
3964
          then fields
3965
          else
3966
            ("names",
3967
              (((fun x  ->
3968
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
3969
                 x.names))
3970
            :: fields
3971
           in
3972
        `Assoc fields)
3973
  [@ocaml.warning "-A"])
3974

    
3975
and (vhdl_port_t_of_yojson :
3976
      Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
3977
  =
3978
  ((let open! Ppx_deriving_yojson_runtime in
3979
      function
3980
      | `Assoc xs ->
3981
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
3982
            match xs with
3983
            | ("names",x)::xs ->
3984
                loop xs
3985
                  (((function
3986
                     | `List xs ->
3987
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
3988
                     | _ -> Result.Error "Vhdl_ast.vhdl_port_t.names") x),
3989
                    arg1, arg2, arg3)
3990
            | ("mode",x)::xs ->
3991
                loop xs
3992
                  (arg0, ((fun x  -> vhdl_port_mode_t_of_yojson x) x), arg2,
3993
                    arg3)
3994
            | ("typ",x)::xs ->
3995
                loop xs
3996
                  (arg0, arg1,
3997
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
3998
                    arg3)
3999
            | ("expr",x)::xs ->
4000
                loop xs
4001
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4002
            | [] ->
4003
                arg3 >>=
4004
                  ((fun arg3  ->
4005
                      arg2 >>=
4006
                        (fun arg2  ->
4007
                           arg1 >>=
4008
                             (fun arg1  ->
4009
                                arg0 >>=
4010
                                  (fun arg0  ->
4011
                                     Result.Ok
4012
                                       {
4013
                                         names = arg0;
4014
                                         mode = arg1;
4015
                                         typ = arg2;
4016
                                         expr = arg3
4017
                                       })))))
4018
            | _::xs -> loop xs _state  in
4019
          loop xs
4020
            ((Result.Ok []), (Result.Ok InPort),
4021
              (Result.Error "Vhdl_ast.vhdl_port_t.typ"), (Result.Ok IsNull))
4022
      | _ -> Result.Error "Vhdl_ast.vhdl_port_t")
4023
  [@ocaml.warning "-A"])
4024
type vhdl_declaration_t =
4025
  | VarDecl of
4026
  {
4027
  names: vhdl_name_t list ;
4028
  typ: vhdl_subtype_indication_t ;
4029
  init_val: vhdl_expr_t [@default IsNull]} [@name "VARIABLE_DECLARATION"]
4030
  | CstDecl of
4031
  {
4032
  names: vhdl_name_t list ;
4033
  typ: vhdl_subtype_indication_t ;
4034
  init_val: vhdl_expr_t } [@name "CONSTANT_DECLARATION"]
4035
  | SigDecl of
4036
  {
4037
  names: vhdl_name_t list ;
4038
  typ: vhdl_subtype_indication_t ;
4039
  init_val: vhdl_expr_t [@default IsNull]} [@name "SIGNAL_DECLARATION"]
4040
  | ComponentDecl of
4041
  {
4042
  name: vhdl_name_t [@default NoName];
4043
  generics: vhdl_port_t list [@default []];
4044
  ports: vhdl_port_t list [@default []]} [@name "COMPONENT_DECLARATION"]
4045
  | Subprogram of
4046
  {
4047
  name: vhdl_name_t [@default NoName];
4048
  kind: string [@default ""];
4049
  spec: vhdl_subprogram_spec_t
4050
    [@default
4051
      { name = ""; typeMark = NoName; parameters = []; isPure = false }];
4052
  decl_part: vhdl_declaration_t list [@default []];
4053
  stmts: vhdl_sequential_stmt_t list [@default []]} [@name "SUBPROGRAM_BODY"]
4054

    
4055
(* Needs adaptation for: SubProgram *)
4056
let rec pp_vhdl_declaration_t :
4057
  Format.formatter -> vhdl_declaration_t -> Ppx_deriving_runtime.unit =
4058
  let __15 () = pp_vhdl_sequential_stmt_t
4059
  
4060
  and __14 () = pp_vhdl_declaration_t
4061
  
4062
  and __13 () = pp_vhdl_subprogram_spec_t
4063
  
4064
  and __12 () = pp_vhdl_name_t
4065
  
4066
  and __11 () = pp_vhdl_port_t
4067
  
4068
  and __10 () = pp_vhdl_port_t
4069
  
4070
  and __9 () = pp_vhdl_name_t
4071
  
4072
  and __8 () = pp_vhdl_expr_t
4073
  
4074
  and __7 () = pp_vhdl_subtype_indication_t
4075
  
4076
  and __6 () = pp_vhdl_name_t
4077
  
4078
  and __5 () = pp_vhdl_expr_t
4079
  
4080
  and __4 () = pp_vhdl_subtype_indication_t
4081
  
4082
  and __3 () = pp_vhdl_name_t
4083
  
4084
  and __2 () = pp_vhdl_expr_t
4085
  
4086
  and __1 () = pp_vhdl_subtype_indication_t
4087
  
4088
  and __0 () = pp_vhdl_name_t
4089
   in
4090
  ((let open! Ppx_deriving_runtime in
4091
      fun fmt  ->
4092
        function
4093
        | VarDecl { names = anames; typ = atyp; init_val = ainit_val } ->
4094
            (Format.fprintf fmt "variable ";
4095
             ((((fun x  ->
4096
                    ignore
4097
                      (List.fold_left
4098
                         (fun sep  ->
4099
                            fun x  ->
4100
                              if sep then Format.fprintf fmt ",";
4101
                              ((__0 ()) fmt) x;
4102
                              true) false x);)) anames;
4103
               Format.fprintf fmt " : ";
4104
               ((__1 ()) fmt) atyp;
4105
               (match ainit_val with
4106
                | IsNull  -> Format.pp_print_string fmt ""
4107
                | _ ->
4108
                    (Format.fprintf fmt ":=";
4109
                     ((__2 ()) fmt) ainit_val;))));)
4110
        | CstDecl { names = anames; typ = atyp; init_val = ainit_val } ->
4111
            (Format.fprintf fmt "constant ";
4112
             ((((fun x  ->
4113
                    ignore
4114
                      (List.fold_left
4115
                         (fun sep  ->
4116
                            fun x  ->
4117
                              if sep then Format.fprintf fmt ",";
4118
                              ((__3 ()) fmt) x;
4119
                              true) false x);)) anames;
4120
               Format.fprintf fmt " : ";
4121
               ((__4 ()) fmt) atyp;
4122
              Format.fprintf fmt ":=";
4123
              ((__5 ()) fmt) ainit_val)))
4124
        | SigDecl { names = anames; typ = atyp; init_val = ainit_val } ->
4125
            (Format.fprintf fmt "signal ";
4126
            ((fun x  ->
4127
              ignore
4128
              (List.fold_left
4129
                (fun sep  ->
4130
                  fun x  ->
4131
                    if sep then Format.fprintf fmt ",";
4132
                                ((__6 ()) fmt) x;
4133
                                true) false x);
4134
              )) anames;
4135
            Format.fprintf fmt " : ";
4136
            ((__7 ()) fmt) atyp;
4137
            (match ainit_val with
4138
              | IsNull  -> Format.pp_print_string fmt ""
4139
              | _ ->
4140
                  (Format.fprintf fmt ":=";
4141
                  ((__8 ()) fmt) ainit_val;)))
4142
        | ComponentDecl
4143
            { name = aname; generics = agenerics; ports = aports } ->
4144
            Format.fprintf fmt "@[<v 2>component ";
4145
            ((__9 ()) fmt) aname;
4146
            Format.fprintf fmt " is@;";
4147
            ((fun x  ->
4148
              ignore
4149
                (List.fold_left
4150
                  (fun sep  ->
4151
                    fun x  ->
4152
                      if sep then Format.fprintf fmt "@;";
4153
                        ((__10 ()) fmt) x;
4154
                        true) false x))) agenerics;
4155
            ((fun x  ->
4156
              ignore
4157
                (List.fold_left
4158
                  (fun sep  ->
4159
                    fun x  ->
4160
                      if sep then Format.fprintf fmt "@;";
4161
                        ((__11 ()) fmt) x;
4162
                        true) false x))) aports;
4163
            Format.fprintf fmt "@]@;end component";
4164
        | Subprogram
4165
            { name = aname; kind = akind; spec = aspec;
4166
              decl_part = adecl_part; stmts = astmts }
4167
            ->
4168
            (Format.fprintf fmt "@[<2>Subprogram {@,";
4169
             (((((Format.fprintf fmt "@[%s =@ " "name";
4170
                  ((__12 ()) fmt) aname;
4171
                  Format.fprintf fmt "@]");
4172
                 Format.fprintf fmt ";@ ";
4173
                 Format.fprintf fmt "@[%s =@ " "kind";
4174
                 (Format.fprintf fmt "%S") akind;
4175
                 Format.fprintf fmt "@]");
4176
                Format.fprintf fmt ";@ ";
4177
                Format.fprintf fmt "@[%s =@ " "spec";
4178
                ((__13 ()) fmt) aspec;
4179
                Format.fprintf fmt "@]");
4180
               Format.fprintf fmt ";@ ";
4181
               Format.fprintf fmt "@[%s =@ " "decl_part";
4182
               ((fun x  ->
4183
                   Format.fprintf fmt "@[<2>[";
4184
                   ignore
4185
                     (List.fold_left
4186
                        (fun sep  ->
4187
                           fun x  ->
4188
                             if sep then Format.fprintf fmt ";@ ";
4189
                             ((__14 ()) fmt) x;
4190
                             true) false x);
4191
                   Format.fprintf fmt "@,]@]")) adecl_part;
4192
               Format.fprintf fmt "@]");
4193
              Format.fprintf fmt ";@ ";
4194
              Format.fprintf fmt "@[%s =@ " "stmts";
4195
              ((fun x  ->
4196
                  Format.fprintf fmt "@[<2>[";
4197
                  ignore
4198
                    (List.fold_left
4199
                       (fun sep  ->
4200
                          fun x  ->
4201
                            if sep then Format.fprintf fmt ";@ ";
4202
                            ((__15 ()) fmt) x;
4203
                            true) false x);
4204
                  Format.fprintf fmt "@,]@]")) astmts;
4205
              Format.fprintf fmt "@]");
4206
             Format.fprintf fmt "@]}"))
4207
    [@ocaml.warning "-A"])
4208

    
4209
and show_vhdl_declaration_t :
4210
  vhdl_declaration_t -> Ppx_deriving_runtime.string =
4211
  fun x  -> Format.asprintf "%a" pp_vhdl_declaration_t x
4212

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

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

    
4642
type vhdl_signal_condition_t =
4643
  {
4644
  expr: vhdl_expr_t list ;
4645
  cond: vhdl_expr_t [@default IsNull]}
4646

    
4647
let rec pp_vhdl_signal_condition_t :
4648
  Format.formatter -> vhdl_signal_condition_t -> Ppx_deriving_runtime.unit =
4649
  let __1 () = pp_vhdl_expr_t
4650
  
4651
  and __0 () = pp_vhdl_expr_t
4652
   in
4653
  ((let open! Ppx_deriving_runtime in
4654
      fun fmt  ->
4655
        fun x  ->
4656
          ((fun x  ->
4657
              ignore
4658
                (List.fold_left
4659
                   (fun sep  ->
4660
                      fun x  ->
4661
                        if sep then Format.fprintf fmt ";@ ";
4662
                        ((__0 ()) fmt) x;
4663
                        true) false x))) x.expr;
4664
          (match x.cond with
4665
          | IsNull -> Format.fprintf fmt "";
4666
          | _ -> Format.fprintf fmt "when ";
4667
                 ((__1 ()) fmt) x.cond);)
4668
    [@ocaml.warning "-A"])
4669

    
4670
and show_vhdl_signal_condition_t :
4671
  vhdl_signal_condition_t -> Ppx_deriving_runtime.string =
4672
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_condition_t x
4673

    
4674
let rec (vhdl_signal_condition_t_to_yojson :
4675
          vhdl_signal_condition_t -> Yojson.Safe.json)
4676
  =
4677
  ((let open! Ppx_deriving_yojson_runtime in
4678
      fun x  ->
4679
        let fields = []  in
4680
        let fields =
4681
          if x.cond = IsNull
4682
          then fields
4683
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4684
            fields
4685
           in
4686
        let fields =
4687
          ("expr",
4688
            ((fun x  ->
4689
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
4690
               x.expr))
4691
          :: fields  in
4692
        `Assoc fields)
4693
  [@ocaml.warning "-A"])
4694

    
4695
and (vhdl_signal_condition_t_of_yojson :
4696
      Yojson.Safe.json ->
4697
        vhdl_signal_condition_t Ppx_deriving_yojson_runtime.error_or)
4698
  =
4699
  ((let open! Ppx_deriving_yojson_runtime in
4700
      function
4701
      | `Assoc xs ->
4702
          let rec loop xs ((arg0,arg1) as _state) =
4703
            match xs with
4704
            | ("expr",x)::xs ->
4705
                loop xs
4706
                  (((function
4707
                     | `List xs ->
4708
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4709
                     | _ ->
4710
                         Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr")
4711
                      x), arg1)
4712
            | ("cond",x)::xs ->
4713
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4714
            | [] ->
4715
                arg1 >>=
4716
                  ((fun arg1  ->
4717
                      arg0 >>=
4718
                        (fun arg0  -> Result.Ok { expr = arg0; cond = arg1 })))
4719
            | _::xs -> loop xs _state  in
4720
          loop xs
4721
            ((Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr"),
4722
              (Result.Ok IsNull))
4723
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_condition_t")
4724
  [@ocaml.warning "-A"])
4725

    
4726
type vhdl_signal_selection_t =
4727
  {
4728
  expr: vhdl_expr_t ;
4729
  when_sel: vhdl_expr_t list [@default []]}
4730

    
4731
(* TODO *)
4732
let rec pp_vhdl_signal_selection_t :
4733
  Format.formatter -> vhdl_signal_selection_t -> Ppx_deriving_runtime.unit =
4734
  let __1 () = pp_vhdl_expr_t
4735
  
4736
  and __0 () = pp_vhdl_expr_t
4737
   in
4738
  ((let open! Ppx_deriving_runtime in
4739
      fun fmt  ->
4740
        fun x  ->
4741
          Format.fprintf fmt "@[<2>{ ";
4742
          ((Format.fprintf fmt "@[%s =@ " "expr";
4743
            ((__0 ()) fmt) x.expr;
4744
            Format.fprintf fmt "@]");
4745
           Format.fprintf fmt ";@ ";
4746
           Format.fprintf fmt "@[%s =@ " "when_sel";
4747
           ((fun x  ->
4748
               Format.fprintf fmt "@[<2>[";
4749
               ignore
4750
                 (List.fold_left
4751
                    (fun sep  ->
4752
                       fun x  ->
4753
                         if sep then Format.fprintf fmt ";@ ";
4754
                         ((__1 ()) fmt) x;
4755
                         true) false x);
4756
               Format.fprintf fmt "@,]@]")) x.when_sel;
4757
           Format.fprintf fmt "@]");
4758
          Format.fprintf fmt "@ }@]")
4759
    [@ocaml.warning "-A"])
4760

    
4761
and show_vhdl_signal_selection_t :
4762
  vhdl_signal_selection_t -> Ppx_deriving_runtime.string =
4763
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_selection_t x
4764

    
4765
let rec (vhdl_signal_selection_t_to_yojson :
4766
          vhdl_signal_selection_t -> Yojson.Safe.json)
4767
  =
4768
  ((let open! Ppx_deriving_yojson_runtime in
4769
      fun x  ->
4770
        let fields = []  in
4771
        let fields =
4772
          if x.when_sel = []
4773
          then fields
4774
          else
4775
            ("when_sel",
4776
              (((fun x  ->
4777
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
4778
                 x.when_sel))
4779
            :: fields
4780
           in
4781
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
4782
          :: fields  in
4783
        `Assoc fields)
4784
  [@ocaml.warning "-A"])
4785

    
4786
and (vhdl_signal_selection_t_of_yojson :
4787
      Yojson.Safe.json ->
4788
        vhdl_signal_selection_t Ppx_deriving_yojson_runtime.error_or)
4789
  =
4790
  ((let open! Ppx_deriving_yojson_runtime in
4791
      function
4792
      | `Assoc xs ->
4793
          let rec loop xs ((arg0,arg1) as _state) =
4794
            match xs with
4795
            | ("expr",x)::xs ->
4796
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
4797
            | ("when_sel",x)::xs ->
4798
                loop xs
4799
                  (arg0,
4800
                    ((function
4801
                      | `List xs ->
4802
                          map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4803
                      | _ ->
4804
                          Result.Error
4805
                            "Vhdl_ast.vhdl_signal_selection_t.when_sel") x))
4806
            | [] ->
4807
                arg1 >>=
4808
                  ((fun arg1  ->
4809
                      arg0 >>=
4810
                        (fun arg0  ->
4811
                           Result.Ok { expr = arg0; when_sel = arg1 })))
4812
            | _::xs -> loop xs _state  in
4813
          loop xs
4814
            ((Result.Error "Vhdl_ast.vhdl_signal_selection_t.expr"),
4815
              (Result.Ok []))
4816
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_selection_t")
4817
  [@ocaml.warning "-A"])
4818

    
4819
type vhdl_conditional_signal_t =
4820
  {
4821
  postponed: bool [@default false];
4822
  label: vhdl_name_t [@default NoName];
4823
  lhs: vhdl_name_t ;
4824
  rhs: vhdl_signal_condition_t list ;
4825
  cond: vhdl_expr_t [@default IsNull];
4826
  delay: vhdl_expr_t [@default IsNull]}
4827

    
4828
let rec pp_vhdl_conditional_signal_t :
4829
  Format.formatter -> vhdl_conditional_signal_t -> Ppx_deriving_runtime.unit
4830
  =
4831
  let __4 () = pp_vhdl_expr_t
4832
  
4833
  and __3 () = pp_vhdl_expr_t
4834
  
4835
  and __2 () = pp_vhdl_signal_condition_t
4836
  
4837
  and __1 () = pp_vhdl_name_t
4838
  
4839
  and __0 () = pp_vhdl_name_t
4840
   in
4841
  ((let open! Ppx_deriving_runtime in
4842
      fun fmt  ->
4843
        fun x  ->
4844
          (match x.label with
4845
            | NoName -> Format.fprintf fmt "";
4846
            | _ -> (((__0 ()) fmt) x.label;
4847
                   Format.fprintf fmt ":@ ")
4848
          );
4849
          if (x.postponed) then Format.fprintf fmt "postponed@ ";
4850
          ((__1 ()) fmt) x.lhs;
4851
          Format.fprintf fmt " <= ";
4852
          (match x.delay with
4853
            | IsNull -> Format.fprintf fmt "";
4854
            | _ -> ((__4 ()) fmt) x.delay;
4855
                   Format.fprintf fmt " ");
4856
          ((fun x  ->
4857
             Format.fprintf fmt "@[";
4858
             ignore
4859
               (List.fold_left
4860
                 (fun sep  ->
4861
                   fun x  ->
4862
                     if sep then Format.fprintf fmt "";
4863
                      ((__2 ()) fmt) x;
4864
                      Format.fprintf fmt ";";
4865
                      true) false x);
4866
          Format.fprintf fmt "@]")) x.rhs;
4867
          (match x.cond with
4868
            | IsNull -> Format.fprintf fmt "";
4869
            | _ -> Format.fprintf fmt "when (";
4870
                   ((__3 ()) fmt) x.cond;
4871
                   Format.fprintf fmt ")"))
4872
   [@ocaml.warning "-A"])
4873

    
4874
and show_vhdl_conditional_signal_t :
4875
  vhdl_conditional_signal_t -> Ppx_deriving_runtime.string =
4876
  fun x  -> Format.asprintf "%a" pp_vhdl_conditional_signal_t x
4877

    
4878
let rec (vhdl_conditional_signal_t_to_yojson :
4879
          vhdl_conditional_signal_t -> Yojson.Safe.json)
4880
  =
4881
  ((let open! Ppx_deriving_yojson_runtime in
4882
      fun x  ->
4883
        let fields = []  in
4884
        let fields =
4885
          if x.delay = IsNull
4886
          then fields
4887
          else ("delay", (((fun x  -> vhdl_expr_t_to_yojson x)) x.delay)) ::
4888
            fields
4889
           in
4890
        let fields =
4891
          if x.cond = IsNull
4892
          then fields
4893
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4894
            fields
4895
           in
4896
        let fields =
4897
          ("rhs",
4898
            ((fun x  ->
4899
                `List
4900
                  (List.map (fun x  -> vhdl_signal_condition_t_to_yojson x) x))
4901
               x.rhs))
4902
          :: fields  in
4903
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4904
          fields  in
4905
        let fields =
4906
          if x.label = NoName
4907
          then fields
4908
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4909
            fields
4910
           in
4911
        let fields =
4912
          if x.postponed = false
4913
          then fields
4914
          else
4915
            ("postponed",
4916
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4917
                 x.postponed))
4918
            :: fields
4919
           in
4920
        `Assoc fields)
4921
  [@ocaml.warning "-A"])
4922

    
4923
and (vhdl_conditional_signal_t_of_yojson :
4924
      Yojson.Safe.json ->
4925
        vhdl_conditional_signal_t Ppx_deriving_yojson_runtime.error_or)
4926
  =
4927
  ((let open! Ppx_deriving_yojson_runtime in
4928
      function
4929
      | `Assoc xs ->
4930
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4931
            match xs with
4932
            | ("postponed",x)::xs ->
4933
                loop xs
4934
                  (((function
4935
                     | `Bool x -> Result.Ok x
4936
                     | _ ->
4937
                         Result.Error
4938
                           "Vhdl_ast.vhdl_conditional_signal_t.postponed") x),
4939
                    arg1, arg2, arg3, arg4, arg5)
4940
            | ("label",x)::xs ->
4941
                loop xs
4942
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4943
                    arg4, arg5)
4944
            | ("lhs",x)::xs ->
4945
                loop xs
4946
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4947
                    arg4, arg5)
4948
            | ("rhs",x)::xs ->
4949
                loop xs
4950
                  (arg0, arg1, arg2,
4951
                    ((function
4952
                      | `List xs ->
4953
                          map_bind
4954
                            (fun x  -> vhdl_signal_condition_t_of_yojson x)
4955
                            [] xs
4956
                      | _ ->
4957
                          Result.Error
4958
                            "Vhdl_ast.vhdl_conditional_signal_t.rhs") x),
4959
                    arg4, arg5)
4960
            | ("cond",x)::xs ->
4961
                loop xs
4962
                  (arg0, arg1, arg2, arg3,
4963
                    ((fun x  -> vhdl_expr_t_of_yojson x) x), arg5)
4964
            | ("delay",x)::xs ->
4965
                loop xs
4966
                  (arg0, arg1, arg2, arg3, arg4,
4967
                    ((fun x  -> vhdl_expr_t_of_yojson x) x))
4968
            | [] ->
4969
                arg5 >>=
4970
                  ((fun arg5  ->
4971
                      arg4 >>=
4972
                        (fun arg4  ->
4973
                           arg3 >>=
4974
                             (fun arg3  ->
4975
                                arg2 >>=
4976
                                  (fun arg2  ->
4977
                                     arg1 >>=
4978
                                       (fun arg1  ->
4979
                                          arg0 >>=
4980
                                            (fun arg0  ->
4981
                                               Result.Ok
4982
                                                 {
4983
                                                   postponed = arg0;
4984
                                                   label = arg1;
4985
                                                   lhs = arg2;
4986
                                                   rhs = arg3;
4987
                                                   cond = arg4;
4988
                                                   delay = arg5
4989
                                                 })))))))
4990
            | _::xs -> loop xs _state  in
4991
          loop xs
4992
            ((Result.Ok false), (Result.Ok NoName),
4993
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.lhs"),
4994
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.rhs"),
4995
              (Result.Ok IsNull), (Result.Ok IsNull))
4996
      | _ -> Result.Error "Vhdl_ast.vhdl_conditional_signal_t")
4997
  [@ocaml.warning "-A"])
4998

    
4999
type vhdl_process_t =
5000
  {
5001
  id: vhdl_name_t [@default NoName];
5002
  declarations: vhdl_declaration_t list option
5003
    [@key "PROCESS_DECLARATIVE_PART"][@default Some []];
5004
  active_sigs: vhdl_name_t list [@default []];
5005
  body: vhdl_sequential_stmt_t list
5006
    [@key "PROCESS_STATEMENT_PART"][@default []]}
5007

    
5008
let rec pp_vhdl_process_t :
5009
  Format.formatter -> vhdl_process_t -> Ppx_deriving_runtime.unit =
5010
  let __3 () = pp_vhdl_sequential_stmt_t
5011
  
5012
  and __2 () = pp_vhdl_name_t
5013
  
5014
  and __1 () = pp_vhdl_declaration_t
5015
  
5016
  and __0 () = pp_vhdl_name_t
5017
   in
5018
  ((let open! Ppx_deriving_runtime in
5019
      fun fmt  ->
5020
        fun x  ->
5021
          Format.fprintf fmt "@[<v>@[<v 2>";
5022
          (match x.id with
5023
          | NoName -> Format.fprintf fmt "";
5024
          | _ -> 
5025
              ((__0 ()) fmt) x.id;
5026
              Format.fprintf fmt ": ");
5027
          Format.fprintf fmt "process ";
5028
          (match x.active_sigs with
5029
          | [] -> Format.fprintf fmt "";
5030
          | _ -> Format.fprintf fmt "(";
5031
                 ((fun x  ->
5032
                    ignore
5033
                      (List.fold_left
5034
                         (fun sep  ->
5035
                            fun x  ->
5036
                              if sep then Format.fprintf fmt ",";
5037
                              ((__2 ()) fmt) x;
5038
                              true) false x))) x.active_sigs;
5039
                 Format.fprintf fmt ")");
5040
          ((function
5041
             | None  -> Format.pp_print_string fmt ""
5042
             | Some x ->
5043
                 Format.fprintf fmt "@;";
5044
                  ((fun x  ->
5045
                      ignore
5046
                        (List.fold_left
5047
                           (fun sep  ->
5048
                              fun x  ->
5049
                                if sep then Format.fprintf fmt "@;";
5050
                                ((__1 ()) fmt) x;
5051
                                true) false x);)) x;)) x.declarations;
5052
          Format.fprintf fmt "@]@;@[<v 2>begin@;";
5053
          ((fun x  ->
5054
               ignore
5055
                 (List.fold_left
5056
                    (fun sep  ->
5057
                       fun x  ->
5058
                         if sep then Format.fprintf fmt "@;";
5059
                         ((__3 ()) fmt) x;
5060
                         true) false x);)) x.body;
5061
          Format.fprintf fmt "@]@;end process;@;";
5062
          Format.fprintf fmt "@]";)
5063
    [@ocaml.warning "-A"])
5064

    
5065
and show_vhdl_process_t : vhdl_process_t -> Ppx_deriving_runtime.string =
5066
  fun x  -> Format.asprintf "%a" pp_vhdl_process_t x
5067

    
5068
let rec (vhdl_process_t_to_yojson : vhdl_process_t -> Yojson.Safe.json) =
5069
  ((let open! Ppx_deriving_yojson_runtime in
5070
      fun x  ->
5071
        let fields = []  in
5072
        let fields =
5073
          if x.body = []
5074
          then fields
5075
          else
5076
            ("PROCESS_STATEMENT_PART",
5077
              (((fun x  ->
5078
                   `List
5079
                     (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x)
5080
                        x))) x.body))
5081
            :: fields
5082
           in
5083
        let fields =
5084
          if x.active_sigs = []
5085
          then fields
5086
          else
5087
            ("active_sigs",
5088
              (((fun x  ->
5089
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
5090
                 x.active_sigs))
5091
            :: fields
5092
           in
5093
        let fields =
5094
          if x.declarations = (Some [])
5095
          then fields
5096
          else
5097
            ("PROCESS_DECLARATIVE_PART",
5098
              (((function
5099
                 | None  -> `Null
5100
                 | Some x ->
5101
                     ((fun x  ->
5102
                         `List
5103
                           (List.map
5104
                              (fun x  -> vhdl_declaration_t_to_yojson x) x)))
5105
                       x)) x.declarations))
5106
            :: fields
5107
           in
5108
        let fields =
5109
          if x.id = NoName
5110
          then fields
5111
          else ("id", (((fun x  -> vhdl_name_t_to_yojson x)) x.id)) :: fields
5112
           in
5113
        `Assoc fields)
5114
  [@ocaml.warning "-A"])
5115

    
5116
and (vhdl_process_t_of_yojson :
5117
      Yojson.Safe.json -> vhdl_process_t Ppx_deriving_yojson_runtime.error_or)
5118
  =
5119
  ((let open! Ppx_deriving_yojson_runtime in
5120
      function
5121
      | `Assoc xs ->
5122
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
5123
            match xs with
5124
            | ("id",x)::xs ->
5125
                loop xs
5126
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3)
5127
            | ("PROCESS_DECLARATIVE_PART",x)::xs ->
5128
                loop xs
5129
                  (arg0,
5130
                    ((function
5131
                      | `Null -> Result.Ok None
5132
                      | x ->
5133
                          ((function
5134
                            | `List xs ->
5135
                                map_bind
5136
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
5137
                                  [] xs
5138
                            | _ ->
5139
                                Result.Error
5140
                                  "Vhdl_ast.vhdl_process_t.declarations") x)
5141
                            >>= ((fun x  -> Result.Ok (Some x)))) x), arg2,
5142
                    arg3)
5143
            | ("active_sigs",x)::xs ->
5144
                loop xs
5145
                  (arg0, arg1,
5146
                    ((function
5147
                      | `List xs ->
5148
                          map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5149
                      | _ ->
5150
                          Result.Error "Vhdl_ast.vhdl_process_t.active_sigs")
5151
                       x), arg3)
5152
            | ("PROCESS_STATEMENT_PART",x)::xs ->
5153
                loop xs
5154
                  (arg0, arg1, arg2,
5155
                    ((function
5156
                      | `List xs ->
5157
                          map_bind
5158
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
5159
                            xs
5160
                      | _ -> Result.Error "Vhdl_ast.vhdl_process_t.body") x))
5161
            | [] ->
5162
                arg3 >>=
5163
                  ((fun arg3  ->
5164
                      arg2 >>=
5165
                        (fun arg2  ->
5166
                           arg1 >>=
5167
                             (fun arg1  ->
5168
                                arg0 >>=
5169
                                  (fun arg0  ->
5170
                                     Result.Ok
5171
                                       {
5172
                                         id = arg0;
5173
                                         declarations = arg1;
5174
                                         active_sigs = arg2;
5175
                                         body = arg3
5176
                                       })))))
5177
            | _::xs -> loop xs _state  in
5178
          loop xs
5179
            ((Result.Ok NoName), (Result.Ok (Some [])), (Result.Ok []),
5180
              (Result.Ok []))
5181
      | _ -> Result.Error "Vhdl_ast.vhdl_process_t")
5182
  [@ocaml.warning "-A"])
5183

    
5184
type vhdl_selected_signal_t =
5185
  {
5186
  postponed: bool [@default false];
5187
  label: vhdl_name_t [@default NoName];
5188
  lhs: vhdl_name_t ;
5189
  sel: vhdl_expr_t ;
5190
  branches: vhdl_signal_selection_t list [@default []];
5191
  delay: vhdl_expr_t option }
5192

    
5193
(* TODO *)
5194
let rec pp_vhdl_selected_signal_t :
5195
  Format.formatter -> vhdl_selected_signal_t -> Ppx_deriving_runtime.unit =
5196
  let __4 () = pp_vhdl_expr_t
5197
  
5198
  and __3 () = pp_vhdl_signal_selection_t
5199
  
5200
  and __2 () = pp_vhdl_expr_t
5201
  
5202
  and __1 () = pp_vhdl_name_t
5203
  
5204
  and __0 () = pp_vhdl_name_t
5205
   in
5206
  ((let open! Ppx_deriving_runtime in
5207
      fun fmt  ->
5208
        fun x  ->
5209
          Format.fprintf fmt "@[<2>{ ";
5210
          ((((((Format.fprintf fmt "@[%s =@ " "postponed";
5211
                (Format.fprintf fmt "%B") x.postponed;
5212
                Format.fprintf fmt "@]");
5213
               Format.fprintf fmt ";@ ";
5214
               Format.fprintf fmt "@[%s =@ " "label";
5215
               ((__0 ()) fmt) x.label;
5216
               Format.fprintf fmt "@]");
5217
              Format.fprintf fmt ";@ ";
5218
              Format.fprintf fmt "@[%s =@ " "lhs";
5219
              ((__1 ()) fmt) x.lhs;
5220
              Format.fprintf fmt "@]");
5221
             Format.fprintf fmt ";@ ";
5222
             Format.fprintf fmt "@[%s =@ " "sel";
5223
             ((__2 ()) fmt) x.sel;
5224
             Format.fprintf fmt "@]");
5225
            Format.fprintf fmt ";@ ";
5226
            Format.fprintf fmt "@[%s =@ " "branches";
5227
            ((fun x  ->
5228
                Format.fprintf fmt "@[<2>[";
5229
                ignore
5230
                  (List.fold_left
5231
                     (fun sep  ->
5232
                        fun x  ->
5233
                          if sep then Format.fprintf fmt ";@ ";
5234
                          ((__3 ()) fmt) x;
5235
                          true) false x);
5236
                Format.fprintf fmt "@,]@]")) x.branches;
5237
            Format.fprintf fmt "@]");
5238
           Format.fprintf fmt ";@ ";
5239
           Format.fprintf fmt "@[%s =@ " "delay";
5240
           ((function
5241
             | None  -> Format.pp_print_string fmt "None"
5242
             | Some x ->
5243
                 (Format.pp_print_string fmt "(Some ";
5244
                  ((__4 ()) fmt) x;
5245
                  Format.pp_print_string fmt ")"))) x.delay;
5246
           Format.fprintf fmt "@]");
5247
          Format.fprintf fmt "@ }@]")
5248
    [@ocaml.warning "-A"])
5249

    
5250
and show_vhdl_selected_signal_t :
5251
  vhdl_selected_signal_t -> Ppx_deriving_runtime.string =
5252
  fun x  -> Format.asprintf "%a" pp_vhdl_selected_signal_t x
5253

    
5254
let rec (vhdl_selected_signal_t_to_yojson :
5255
          vhdl_selected_signal_t -> Yojson.Safe.json)
5256
  =
5257
  ((let open! Ppx_deriving_yojson_runtime in
5258
      fun x  ->
5259
        let fields = []  in
5260
        let fields =
5261
          ("delay",
5262
            ((function
5263
              | None  -> `Null
5264
              | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x) x.delay))
5265
          :: fields  in
5266
        let fields =
5267
          if x.branches = []
5268
          then fields
5269
          else
5270
            ("branches",
5271
              (((fun x  ->
5272
                   `List
5273
                     (List.map
5274
                        (fun x  -> vhdl_signal_selection_t_to_yojson x) x)))
5275
                 x.branches))
5276
            :: fields
5277
           in
5278
        let fields = ("sel", ((fun x  -> vhdl_expr_t_to_yojson x) x.sel)) ::
5279
          fields  in
5280
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
5281
          fields  in
5282
        let fields =
5283
          if x.label = NoName
5284
          then fields
5285
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
5286
            fields
5287
           in
5288
        let fields =
5289
          if x.postponed = false
5290
          then fields
5291
          else
5292
            ("postponed",
5293
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
5294
                 x.postponed))
5295
            :: fields
5296
           in
5297
        `Assoc fields)
5298
  [@ocaml.warning "-A"])
5299

    
5300
and (vhdl_selected_signal_t_of_yojson :
5301
      Yojson.Safe.json ->
5302
        vhdl_selected_signal_t Ppx_deriving_yojson_runtime.error_or)
5303
  =
5304
  ((let open! Ppx_deriving_yojson_runtime in
5305
      function
5306
      | `Assoc xs ->
5307
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
5308
            match xs with
5309
            | ("postponed",x)::xs ->
5310
                loop xs
5311
                  (((function
5312
                     | `Bool x -> Result.Ok x
5313
                     | _ ->
5314
                         Result.Error
5315
                           "Vhdl_ast.vhdl_selected_signal_t.postponed") x),
5316
                    arg1, arg2, arg3, arg4, arg5)
5317
            | ("label",x)::xs ->
5318
                loop xs
5319
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
5320
                    arg4, arg5)
5321
            | ("lhs",x)::xs ->
5322
                loop xs
5323
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
5324
                    arg4, arg5)
5325
            | ("sel",x)::xs ->
5326
                loop xs
5327
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x),
5328
                    arg4, arg5)
5329
            | ("branches",x)::xs ->
5330
                loop xs
5331
                  (arg0, arg1, arg2, arg3,
5332
                    ((function
5333
                      | `List xs ->
5334
                          map_bind
5335
                            (fun x  -> vhdl_signal_selection_t_of_yojson x)
5336
                            [] xs
5337
                      | _ ->
5338
                          Result.Error
5339
                            "Vhdl_ast.vhdl_selected_signal_t.branches") x),
5340
                    arg5)
5341
            | ("delay",x)::xs ->
5342
                loop xs
5343
                  (arg0, arg1, arg2, arg3, arg4,
5344
                    ((function
5345
                      | `Null -> Result.Ok None
5346
                      | x ->
5347
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
5348
                            ((fun x  -> Result.Ok (Some x)))) x))
5349
            | [] ->
5350
                arg5 >>=
5351
                  ((fun arg5  ->
5352
                      arg4 >>=
5353
                        (fun arg4  ->
5354
                           arg3 >>=
5355
                             (fun arg3  ->
5356
                                arg2 >>=
5357
                                  (fun arg2  ->
5358
                                     arg1 >>=
5359
                                       (fun arg1  ->
5360
                                          arg0 >>=
5361
                                            (fun arg0  ->
5362
                                               Result.Ok
5363
                                                 {
5364
                                                   postponed = arg0;
5365
                                                   label = arg1;
5366
                                                   lhs = arg2;
5367
                                                   sel = arg3;
5368
                                                   branches = arg4;
5369
                                                   delay = arg5
5370
                                                 })))))))
5371
            | _::xs -> loop xs _state  in
5372
          loop xs
5373
            ((Result.Ok false), (Result.Ok NoName),
5374
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.lhs"),
5375
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.sel"),
5376
              (Result.Ok []),
5377
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.delay"))
5378
      | _ -> Result.Error "Vhdl_ast.vhdl_selected_signal_t")
5379
  [@ocaml.warning "-A"])
5380

    
5381
type vhdl_component_instantiation_t =
5382
  {
5383
  name: vhdl_name_t ;
5384
  inst_unit: vhdl_name_t ;
5385
  archi_name: vhdl_name_t option [@default None];
5386
  generic_map: vhdl_assoc_element_t list [@default []];
5387
  port_map: vhdl_assoc_element_t list [@default []]}[@@deriving
5388
                                                      ((show
5389
                                                          { with_path = false
5390
                                                          }),
5391
                                                        (yojson
5392
                                                           { strict = false }))]
5393

    
5394
let rec pp_vhdl_component_instantiation_t :
5395
  Format.formatter ->
5396
    vhdl_component_instantiation_t -> Ppx_deriving_runtime.unit
5397
  =
5398
  let __4 () = pp_vhdl_assoc_element_t
5399
  
5400
  and __3 () = pp_vhdl_assoc_element_t
5401
  
5402
  and __2 () = pp_vhdl_name_t
5403
  
5404
  and __1 () = pp_vhdl_name_t
5405
  
5406
  and __0 () = pp_vhdl_name_t
5407
   in
5408
  ((let open! Ppx_deriving_runtime in
5409
      fun fmt  ->
5410
        fun x  ->
5411
          Format.fprintf fmt "@[<v 2>";
5412
          ((__0 ()) fmt) x.name;
5413
          Format.fprintf fmt " : ";
5414
          ((__1 ()) fmt) x.inst_unit;
5415
          ((function
5416
             | None  -> Format.pp_print_string fmt ""
5417
             | Some x ->
5418
                 (Format.fprintf fmt "(";
5419
                 ((__2 ()) fmt) x;
5420
                 Format.fprintf fmt ")@;"))) x.archi_name;
5421
          (match x.generic_map with
5422
          | [] -> Format.fprintf fmt "";
5423
          | _ ->
5424
            (Format.fprintf fmt "@[<v 2>generic map (";
5425
            ((fun x  ->
5426
            ignore
5427
            (List.fold_left
5428
               (fun sep  ->
5429
                 fun x  ->
5430
                   if sep then Format.fprintf fmt ",@,";
5431
                   ((__3 ()) fmt) x;
5432
                   true) false x))) x.generic_map;
5433
            Format.fprintf fmt ")@]@;"));
5434
          (match x.port_map with
5435
          | [] -> Format.fprintf fmt ";";
5436
          | _ ->
5437
            (Format.fprintf fmt "@[<v 2>port map (";
5438
            ((fun x  ->
5439
            ignore
5440
            (List.fold_left
5441
               (fun sep  ->
5442
                 fun x  ->
5443
                   if sep then Format.fprintf fmt ",@,";
5444
                   ((__4 ()) fmt) x;
5445
                   true) false x))) x.port_map;
5446
            Format.fprintf fmt ")@];"));
5447
          Format.fprintf fmt "@]")
5448
    [@ocaml.warning "-A"])
5449

    
5450
and show_vhdl_component_instantiation_t :
5451
  vhdl_component_instantiation_t -> Ppx_deriving_runtime.string =
5452
  fun x  -> Format.asprintf "%a" pp_vhdl_component_instantiation_t x
5453

    
5454
let rec (vhdl_component_instantiation_t_to_yojson :
5455
          vhdl_component_instantiation_t -> Yojson.Safe.json)
5456
  =
5457
  ((let open! Ppx_deriving_yojson_runtime in
5458
      fun x  ->
5459
        let fields = []  in
5460
        let fields =
5461
          if x.port_map = []
5462
          then fields
5463
          else
5464
            ("port_map",
5465
              (((fun x  ->
5466
                   `List
5467
                     (List.map (fun x  -> vhdl_assoc_element_t_to_yojson x) x)))
5468
                 x.port_map))
5469
            :: fields
5470
           in
5471
        let fields =
5472
          if x.generic_map = []
5473
          then fields
5474
          else
5475
            ("generic_map",
5476
              (((fun x  ->
5477
                   `List
5478
                     (List.map (fun x  -> vhdl_assoc_element_t_to_yojson x) x)))
5479
                 x.generic_map))
5480
            :: fields
5481
           in
5482
        let fields =
5483
          if x.archi_name = None
5484
          then fields