Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / backends / VHDL / vhdl_ast_deriving.ml @ 21b75edb

History | View | Annotate | Download (233 KB)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5480
and (vhdl_port_t_of_yojson :
5481
      Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
5482
  =