Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / backends / VHDL / vhdl_ast_deriving.ml @ 6d3b5007

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

    
176
let rec pp_vhdl_type_t :
177
  Format.formatter -> vhdl_type_t -> Ppx_deriving_runtime.unit =
178
  let __0 () = pp_vhdl_type_t  in
179
  ((let open! Ppx_deriving_runtime in
180
      fun fmt  ->
181
        function
182
        | Base a0 ->
183
             (Format.fprintf fmt "%s") a0;
184
        | Range (a0,a1,a2) ->
185
             ((
186
               (Format.fprintf fmt "%d") a1);
187
               ((function
188
                 | None  -> Format.pp_print_string fmt ""
189
                 | Some x ->
190
                      (Format.fprintf fmt "%s") x;
191
                      )) a0;
192
              (Format.fprintf fmt "%d") a2);
193
        | Bit_vector (a0,a1) ->
194
             (Format.fprintf fmt "array (%d,%d) of bit") a0 a1;
195
        | Array (a0,a1,a2) ->
196
             (Format.fprintf fmt "array ";
197
             (Format.fprintf fmt "(%d,%d)") a0 a1;
198
             Format.fprintf fmt " of ";
199
             ((__0 ()) fmt) a2)
200
        | Enumerated a0 ->
201
             ((fun x  ->
202
                 ignore
203
                   (List.fold_left
204
                      (fun sep  ->
205
                         fun x  ->
206
                           if sep then Format.fprintf fmt ",@ ";
207
                           (Format.fprintf fmt "%s") x;
208
                           true) false x))) a0;
209
        | Void  -> Format.pp_print_string fmt "")
210
    [@ocaml.warning "-A"])
211

    
212
and show_vhdl_type_t : vhdl_type_t -> Ppx_deriving_runtime.string =
213
  fun x  -> Format.asprintf "%a" pp_vhdl_type_t x
214

    
215
and pp_vhdl_subtype_indication_t :
216
  Format.formatter -> vhdl_subtype_indication_t -> Ppx_deriving_runtime.unit
217
  =
218
  let __2 () = pp_vhdl_constraint_t
219
  
220
  and __1 () = pp_vhdl_name_t
221
  
222
  and __0 () = pp_vhdl_name_t
223
   in
224
  ((let open! Ppx_deriving_runtime in
225
      fun fmt  ->
226
        fun x  ->
227
          ((__0 ()) fmt) x.name;
228
          ((__1 ()) fmt) x.functionName;
229
          (match x.const with
230
            | NoConstraint -> Format.fprintf fmt "";
231
            | _ -> Format.fprintf fmt " ";
232
                   ((__2 ()) fmt) x.const))
233
    [@ocaml.warning "-A"])
234

    
235
and show_vhdl_subtype_indication_t :
236
  vhdl_subtype_indication_t -> Ppx_deriving_runtime.string =
237
  fun x  -> Format.asprintf "%a" pp_vhdl_subtype_indication_t x
238

    
239
and pp_vhdl_discrete_range_t :
240
  Format.formatter -> vhdl_discrete_range_t -> Ppx_deriving_runtime.unit =
241
  let __3 () = pp_vhdl_expr_t
242
  
243
  and __2 () = pp_vhdl_expr_t
244
  
245
  and __1 () = pp_vhdl_name_t
246
  
247
  and __0 () = pp_vhdl_subtype_indication_t
248
   in
249
  ((let open! Ppx_deriving_runtime in
250
      fun fmt  ->
251
        function
252
        | SubDiscreteRange a0 ->
253
             ((__0 ()) fmt) a0;
254
        | NamedRange a0 ->
255
             ((__1 ()) fmt) a0;
256
        | DirectedRange { direction = adirection; from = afrom; _to = a_to }
257
            ->
258
               ((__2 ()) fmt) afrom;
259
               (Format.fprintf fmt " %s ") adirection;
260
               ((__3 ()) fmt) a_to;
261
    )
262
    [@ocaml.warning "-A"])
263

    
264
and show_vhdl_discrete_range_t :
265
  vhdl_discrete_range_t -> Ppx_deriving_runtime.string =
266
  fun x  -> Format.asprintf "%a" pp_vhdl_discrete_range_t x
267

    
268
(* TODO Adapt for: ArrayConstraint, RecordConstraint *)
269
and pp_vhdl_constraint_t :
270
  Format.formatter -> vhdl_constraint_t -> Ppx_deriving_runtime.unit =
271
  let __4 () = pp_vhdl_constraint_t
272
  
273
  and __3 () = pp_vhdl_discrete_range_t
274
  
275
  and __2 () = pp_vhdl_discrete_range_t
276
  
277
  and __1 () = pp_vhdl_discrete_range_t
278
  
279
  and __0 () = pp_vhdl_name_t
280
   in
281
  ((let open! Ppx_deriving_runtime in
282
      fun fmt  ->
283
        function
284
        | RefConstraint { ref_name = aref_name } ->
285
             (Format.fprintf fmt "(";
286
              ((__0 ()) fmt) aref_name;
287
              Format.fprintf fmt ")");
288
        | RangeConstraint { range = arange } ->
289
             (Format.fprintf fmt "(";
290
              ((__1 ()) fmt) arange;
291
              Format.fprintf fmt ")");
292
        | IndexConstraint { ranges = aranges } ->
293
            Format.fprintf fmt "(";
294
            ((fun x  ->
295
                ignore
296
                  (List.fold_left
297
                     (fun sep  ->
298
                        fun x  ->
299
                          if sep then Format.fprintf fmt ", ";
300
                          ((__2 ()) fmt) x;
301
                          true) false x))) aranges;
302
            Format.fprintf fmt ")";
303
        | ArrayConstraint { ranges = aranges; sub = asub } ->
304
            (Format.fprintf fmt "@[<2>ArrayConstraint {@,";
305
             ((Format.fprintf fmt "@[%s =@ " "ranges";
306
               ((fun x  ->
307
                   Format.fprintf fmt "@[<2>[";
308
                   ignore
309
                     (List.fold_left
310
                        (fun sep  ->
311
                           fun x  ->
312
                             if sep then Format.fprintf fmt ";@ ";
313
                             ((__3 ()) fmt) x;
314
                             true) false x);
315
                   Format.fprintf fmt "@,]@]")) aranges;
316
               Format.fprintf fmt "@]");
317
              Format.fprintf fmt ";@ ";
318
              Format.fprintf fmt "@[%s =@ " "sub";
319
              ((__4 ()) fmt) asub;
320
              Format.fprintf fmt "@]");
321
             Format.fprintf fmt "@]}")
322
        | RecordConstraint  -> Format.pp_print_string fmt ""
323
        | NoConstraint  -> Format.pp_print_string fmt "")
324
    [@ocaml.warning "-A"])
325

    
326
and show_vhdl_constraint_t : vhdl_constraint_t -> Ppx_deriving_runtime.string
327
  = fun x  -> Format.asprintf "%a" pp_vhdl_constraint_t x
328

    
329
and pp_vhdl_definition_t :
330
  Format.formatter -> vhdl_definition_t -> Ppx_deriving_runtime.unit =
331
  let __3 () = pp_vhdl_subtype_indication_t
332
  
333
  and __2 () = pp_vhdl_name_t
334
  
335
  and __1 () = pp_vhdl_type_t
336
  
337
  and __0 () = pp_vhdl_name_t
338
   in
339
  ((let open! Ppx_deriving_runtime in
340
      fun fmt  ->
341
        function
342
        | Type { name = aname; definition = adefinition } ->
343
            Format.fprintf fmt "type ";
344
            ((__0 ()) fmt) aname;
345
            Format.fprintf fmt " is ";
346
            ((__1 ()) fmt) adefinition;
347
        | Subtype { name = aname; typ = atyp } ->
348
            Format.fprintf fmt "subtype ";
349
            ((__2 ()) fmt) aname;
350
            Format.fprintf fmt " is ";
351
            ((__3 ()) fmt) atyp;
352
   )
353
    [@ocaml.warning "-A"])
354

    
355
and show_vhdl_definition_t : vhdl_definition_t -> Ppx_deriving_runtime.string
356
  = fun x  -> Format.asprintf "%a" pp_vhdl_definition_t x
357

    
358
(* TODO adapt for Op, Time, Sig, suffixMod, Aggregate *)
359
and pp_vhdl_expr_t :
360
  Format.formatter -> vhdl_expr_t -> Ppx_deriving_runtime.unit =
361
  let __7 () = pp_vhdl_element_assoc_t
362
  
363
  and __6 () = pp_vhdl_suffix_selection_t
364
  
365
  and __5 () = pp_vhdl_expr_t
366
  
367
  and __4 () = pp_vhdl_signal_attributes_t
368
  
369
  and __3 () = pp_vhdl_name_t
370
  
371
  and __2 () = pp_vhdl_expr_t
372
  
373
  and __1 () = pp_vhdl_cst_val_t
374
  
375
  and __0 () = pp_vhdl_name_t
376
   in
377
  ((let open! Ppx_deriving_runtime in
378
      fun fmt  ->
379
        function
380
        | Call a0 ->
381
             ((__0 ()) fmt) a0;
382
        | Cst a0 ->
383
             ((__1 ()) fmt) a0;
384
        | Op { id = aid; args = aargs } ->
385
            (match aargs with
386
            | [] -> (Format.fprintf fmt "%s") aid;
387
            | hd::[] ->
388
               (Format.fprintf fmt "%s") aid;
389
               ((__2 ()) fmt) hd
390
            | hd::(hd2::[]) -> 
391
               ((__2 ()) fmt) hd;
392
               (Format.fprintf fmt " %s ") aid;
393
               ((__2 ()) fmt) hd2
394
            | _ ->
395
            (Format.fprintf fmt "@[<2>Op {@,";
396
             ((Format.fprintf fmt "@[%s =@ " "id";
397
               (Format.fprintf fmt "%S") aid;
398
               Format.fprintf fmt "@]");
399
              Format.fprintf fmt ";@ ";
400
              Format.fprintf fmt "@[%s =@ " "args";
401
              ((fun x  ->
402
                  Format.fprintf fmt "@[<2>[";
403
                  ignore
404
                    (List.fold_left
405
                       (fun sep  ->
406
                          fun x  ->
407
                            if sep then Format.fprintf fmt ";@ ";
408
                            ((__2 ()) fmt) x;
409
                            true) false x);
410
                  Format.fprintf fmt "@,]@]")) aargs;
411
              Format.fprintf fmt "@]");
412
             Format.fprintf fmt "@]}"))
413
        | IsNull  -> Format.pp_print_string fmt ""
414
        | Time { value = avalue; phy_unit = aphy_unit } ->
415
            (Format.fprintf fmt "@[<2>Time {@,";
416
             ((Format.fprintf fmt "@[%s =@ " "value";
417
               (Format.fprintf fmt "%d") avalue;
418
               Format.fprintf fmt "@]");
419
              Format.fprintf fmt ";@ ";
420
              Format.fprintf fmt "@[%s =@ " "phy_unit";
421
              (Format.fprintf fmt "%S") aphy_unit;
422
              Format.fprintf fmt "@]");
423
             Format.fprintf fmt "@]}")
424
        | Sig { name = aname; att = aatt } ->
425
            (Format.fprintf fmt "--@[<2>Sig {@,";
426
             ((Format.fprintf fmt "@[%s =@ " "name";
427
               ((__3 ()) fmt) aname;
428
               Format.fprintf fmt "@]");
429
              Format.fprintf fmt ";@ ";
430
              Format.fprintf fmt "@[%s =@ " "att";
431
              ((function
432
                | None  -> Format.pp_print_string fmt "None"
433
                | Some x ->
434
                    (Format.pp_print_string fmt "(Some ";
435
                     ((__4 ()) fmt) x;
436
                     Format.pp_print_string fmt ")"))) aatt;
437
              Format.fprintf fmt "@]");
438
             Format.fprintf fmt "@]}")
439
        | SuffixMod { expr = aexpr; selection = aselection } ->
440
            (Format.fprintf fmt "--@[<2>SuffixMod {@,";
441
             ((Format.fprintf fmt "@[%s =@ " "expr";
442
               ((__5 ()) fmt) aexpr;
443
               Format.fprintf fmt "@]");
444
              Format.fprintf fmt ";@ ";
445
              Format.fprintf fmt "@[%s =@ " "selection";
446
              ((__6 ()) fmt) aselection;
447
              Format.fprintf fmt "@]");
448
             Format.fprintf fmt "@]}")
449
        | Aggregate { elems = aelems } ->
450
            (Format.fprintf fmt "--@[<2>Aggregate {@,";
451
             (Format.fprintf fmt "@[%s =@ " "elems";
452
              ((fun x  ->
453
                  Format.fprintf fmt "@[<2>[";
454
                  ignore
455
                    (List.fold_left
456
                       (fun sep  ->
457
                          fun x  ->
458
                            if sep then Format.fprintf fmt ";@ ";
459
                            ((__7 ()) fmt) x;
460
                            true) false x);
461
                  Format.fprintf fmt "@,]@]")) aelems;
462
              Format.fprintf fmt "@]");
463
             Format.fprintf fmt "@]}")
464
        | Others  -> Format.pp_print_string fmt "others")
465
    [@ocaml.warning "-A"])
466

    
467
and show_vhdl_expr_t : vhdl_expr_t -> Ppx_deriving_runtime.string =
468
  fun x  -> Format.asprintf "%a" pp_vhdl_expr_t x
469

    
470
and pp_vhdl_name_t :
471
  Format.formatter -> vhdl_name_t -> Ppx_deriving_runtime.unit =
472
  let __9 () = pp_vhdl_assoc_element_t
473
  
474
  and __8 () = pp_vhdl_name_t
475
  
476
  and __7 () = pp_vhdl_expr_t
477
  
478
  and __6 () = pp_vhdl_name_t
479
  
480
  and __5 () = pp_vhdl_name_t
481
  
482
  and __4 () = pp_vhdl_discrete_range_t
483
  
484
  and __3 () = pp_vhdl_name_t
485
  
486
  and __2 () = pp_vhdl_expr_t
487
  
488
  and __1 () = pp_vhdl_name_t
489
  
490
  and __0 () = pp_vhdl_name_t
491
   in
492
  ((let open! Ppx_deriving_runtime in
493
      fun fmt  ->
494
        function
495
        | Simple a0 ->
496
             (Format.fprintf fmt "%s") a0;
497
        | Identifier a0 ->
498
             (Format.fprintf fmt "%s") a0;
499
        | Selected a0 ->
500
             ((fun x  ->
501
                 ignore
502
                   (List.fold_left
503
                      (fun sep  ->
504
                         fun x  ->
505
                           if sep then Format.fprintf fmt ".";
506
                           ((__0 ()) fmt) x;
507
                           true) false x);) a0;)
508
        | Index { id = aid; exprs = aexprs } ->
509
            ((__1 ()) fmt) aid;
510
            Format.fprintf fmt "(";
511
            (fun x  ->
512
                ignore
513
                (List.fold_left
514
                  (fun sep  ->
515
                    fun x  ->
516
                      if sep then Format.fprintf fmt ",@ ";
517
                                  ((__2 ()) fmt) x;
518
                                  true
519
                  ) false x);
520
            ) aexprs;
521
            Format.fprintf fmt ")";
522
        | Slice { id = aid; range = arange } ->
523
              ((__3 ()) fmt) aid;
524
              Format.fprintf fmt "(";
525
              ((__4 ()) fmt) arange;
526
              Format.fprintf fmt ")";
527
        | Attribute { id = aid; designator = adesignator; expr = aexpr } ->
528
              ((__5 ()) fmt) aid;
529
              Format.fprintf fmt "\'";
530
              ((__6 ()) fmt) adesignator;
531
              (match aexpr with
532
              | IsNull -> Format.fprintf fmt "";
533
              | _ ->
534
                Format.fprintf fmt "(";
535
                ((__7 ()) fmt) aexpr;
536
                Format.fprintf fmt ")")
537
        | Function { id = aid; assoc_list = aassoc_list } ->
538
            (((__8 ()) fmt) aid;
539
            Format.fprintf fmt "(";
540
            ((fun x  ->
541
              Format.fprintf fmt "@[";
542
              ignore
543
                (List.fold_left
544
                   (fun sep  ->
545
                      fun x  ->
546
                        if sep then Format.fprintf fmt ";@ ";
547
                        ((__9 ()) fmt) x;
548
                        true) false x);
549
            Format.fprintf fmt "@]")) aassoc_list;
550
            Format.fprintf fmt ")";)
551
        | NoName  -> Format.pp_print_string fmt "")
552
    [@ocaml.warning "-A"])
553

    
554
and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string =
555
  fun x  -> Format.asprintf "%a" pp_vhdl_name_t x
556

    
557
and pp_vhdl_assoc_element_t :
558
  Format.formatter -> vhdl_assoc_element_t -> Ppx_deriving_runtime.unit =
559
  let __4 () = pp_vhdl_expr_t
560
  
561
  and __3 () = pp_vhdl_name_t
562
  
563
  and __2 () = pp_vhdl_name_t
564
  
565
  and __1 () = pp_vhdl_name_t
566
  
567
  and __0 () = pp_vhdl_name_t
568
   in
569
  ((let open! Ppx_deriving_runtime in
570
      fun fmt  ->
571
        fun x  ->
572
          (match x.formal_name with
573
          | None -> Format.pp_print_string fmt ""
574
          | Some NoName -> Format.pp_print_string fmt ""
575
          | Some a -> 
576
              (((__0 ()) fmt) a;
577
              (match x.formal_arg with
578
              | None -> ()
579
              | Some b -> Format.fprintf fmt "(";
580
                          ((__1 ()) fmt) b;
581
                          Format.fprintf fmt ")");
582
              Format.fprintf fmt " => "));
583
          (match x.actual_name with
584
          | None -> Format.pp_print_string fmt ""
585
          | Some a -> 
586
              (((__2 ()) fmt) a;
587
              (match x.actual_designator with
588
              | None -> ()
589
              | Some NoName -> Format.pp_print_string fmt ""
590
              | Some b -> (Format.fprintf fmt "(";
591
                          ((__3 ()) fmt) b;
592
                          Format.fprintf fmt ")"));
593
              (match x.actual_expr with
594
              | None -> ()
595
              | Some IsNull -> Format.pp_print_string fmt ""
596
              | Some c -> (Format.fprintf fmt "(";
597
                          ((__4 ()) fmt) c;
598
                          Format.fprintf fmt ")"))));)
599
    [@ocaml.warning "-A"])
600

    
601
and show_vhdl_assoc_element_t :
602
  vhdl_assoc_element_t -> Ppx_deriving_runtime.string =
603
  fun x  -> Format.asprintf "%a" pp_vhdl_assoc_element_t x
604

    
605
and pp_vhdl_element_assoc_t :
606
  Format.formatter -> vhdl_element_assoc_t -> Ppx_deriving_runtime.unit =
607
  let __1 () = pp_vhdl_expr_t
608
  
609
  and __0 () = pp_vhdl_expr_t
610
   in
611
  ((let open! Ppx_deriving_runtime in
612
      fun fmt  ->
613
        fun x  ->
614
            (match x.choices with
615
            | [] -> Format.fprintf fmt "";
616
            | _ -> 
617
              (((fun x  ->
618
                Format.fprintf fmt "@[<2>[";
619
                ignore
620
                  (List.fold_left
621
                     (fun sep  ->
622
                        fun x  ->
623
                          if sep then Format.fprintf fmt "|@ ";
624
                          ((__0 ()) fmt) x;
625
                          true) false x))) x.choices;
626
              Format.fprintf fmt " => ";));
627
           ((__1 ()) fmt) x.expr)
628
    [@ocaml.warning "-A"])
629

    
630
and show_vhdl_element_assoc_t :
631
  vhdl_element_assoc_t -> Ppx_deriving_runtime.string =
632
  fun x  -> Format.asprintf "%a" pp_vhdl_element_assoc_t x
633

    
634
(* TODO *)
635
and (pp_vhdl_array_attributes_t :
636
      Format.formatter ->
637
        vhdl_array_attributes_t -> Ppx_deriving_runtime.unit)
638
  =
639
  ((let open! Ppx_deriving_runtime in
640
      fun fmt  ->
641
        function
642
        | AAttInt { id = aid; arg = aarg } ->
643
            (Format.fprintf fmt "@[<2>AAttInt {@,";
644
             ((Format.fprintf fmt "@[%s =@ " "id";
645
               (Format.fprintf fmt "%S") aid;
646
               Format.fprintf fmt "@]");
647
              Format.fprintf fmt ";@ ";
648
              Format.fprintf fmt "@[%s =@ " "arg";
649
              (Format.fprintf fmt "%d") aarg;
650
              Format.fprintf fmt "@]");
651
             Format.fprintf fmt "@]}")
652
        | AAttAscending  -> Format.pp_print_string fmt "AAttAscending")
653
  [@ocaml.warning "-A"])
654

    
655
and show_vhdl_array_attributes_t :
656
  vhdl_array_attributes_t -> Ppx_deriving_runtime.string =
657
  fun x  -> Format.asprintf "%a" pp_vhdl_array_attributes_t x
658

    
659
(* TODO *)
660
and (pp_vhdl_signal_attributes_t :
661
      Format.formatter ->
662
        vhdl_signal_attributes_t -> Ppx_deriving_runtime.unit)
663
  =
664
  ((let open! Ppx_deriving_runtime in
665
      fun fmt  ->
666
        function
667
        | SigAtt a0 ->
668
            (Format.fprintf fmt "(@[<2>SigAtt@ ";
669
             (Format.fprintf fmt "%S") a0;
670
             Format.fprintf fmt "@])"))
671
  [@ocaml.warning "-A"])
672

    
673
and show_vhdl_signal_attributes_t :
674
  vhdl_signal_attributes_t -> Ppx_deriving_runtime.string =
675
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_attributes_t x
676

    
677
(* TODO *)
678
and (pp_vhdl_string_attributes_t :
679
      Format.formatter ->
680
        vhdl_string_attributes_t -> Ppx_deriving_runtime.unit)
681
  =
682
  ((let open! Ppx_deriving_runtime in
683
      fun fmt  ->
684
        function
685
        | StringAtt a0 ->
686
            (Format.fprintf fmt "(@[<2>StringAtt@ ";
687
             (Format.fprintf fmt "%S") a0;
688
             Format.fprintf fmt "@])"))
689
  [@ocaml.warning "-A"])
690

    
691
and show_vhdl_string_attributes_t :
692
  vhdl_string_attributes_t -> Ppx_deriving_runtime.string =
693
  fun x  -> Format.asprintf "%a" pp_vhdl_string_attributes_t x
694

    
695
(* TODO *)
696
and (pp_vhdl_suffix_selection_t :
697
      Format.formatter ->
698
        vhdl_suffix_selection_t -> Ppx_deriving_runtime.unit)
699
  =
700
  ((let open! Ppx_deriving_runtime in
701
      fun fmt  ->
702
        function
703
        | Idx a0 ->
704
            (Format.fprintf fmt "(@[<2>Idx@ ";
705
             (Format.fprintf fmt "%d") a0;
706
             Format.fprintf fmt "@])")
707
        | SuffixRange (a0,a1) ->
708
            (Format.fprintf fmt "(@[<2>SuffixRange (@,";
709
             ((Format.fprintf fmt "%d") a0;
710
              Format.fprintf fmt ",@ ";
711
              (Format.fprintf fmt "%d") a1);
712
             Format.fprintf fmt "@,))@]"))
713
  [@ocaml.warning "-A"])
714

    
715
and show_vhdl_suffix_selection_t :
716
  vhdl_suffix_selection_t -> Ppx_deriving_runtime.string =
717
  fun x  -> Format.asprintf "%a" pp_vhdl_suffix_selection_t x
718

    
719
let rec (vhdl_type_t_to_yojson : vhdl_type_t -> Yojson.Safe.json) =
720
  ((let open! Ppx_deriving_yojson_runtime in
721
      function
722
      | Base arg0 ->
723
          `List
724
            [`String "Base";
725
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
726
      | Range (arg0,arg1,arg2) ->
727
          `List
728
            [`String "Range";
729
            ((function
730
              | None  -> `Null
731
              | Some x ->
732
                  ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x))
733
              arg0;
734
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1;
735
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg2]
736
      | Bit_vector (arg0,arg1) ->
737
          `List
738
            [`String "Bit_vector";
739
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
740
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1]
741
      | Array (arg0,arg1,arg2) ->
742
          `List
743
            [`String "Array";
744
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
745
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1;
746
            ((fun x  -> vhdl_type_t_to_yojson x)) arg2]
747
      | Enumerated arg0 ->
748
          `List
749
            [`String "Enumerated";
750
            ((fun x  ->
751
                `List
752
                  (List.map
753
                     (fun (x : Ppx_deriving_runtime.string)  -> `String x) x)))
754
              arg0]
755
      | Void  -> `List [`String "Void"])
756
  [@ocaml.warning "-A"])
757

    
758
and (vhdl_type_t_of_yojson :
759
      Yojson.Safe.json -> vhdl_type_t Ppx_deriving_yojson_runtime.error_or)
760
  =
761
  ((let open! Ppx_deriving_yojson_runtime in
762
      function
763
      | `List ((`String "Base")::arg0::[]) ->
764
          ((function
765
            | `String x -> Result.Ok x
766
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
767
            ((fun arg0  -> Result.Ok (Base arg0)))
768
      | `List ((`String "Range")::arg0::arg1::arg2::[]) ->
769
          ((function
770
            | `Int x -> Result.Ok x
771
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg2) >>=
772
            ((fun arg2  ->
773
                ((function
774
                  | `Int x -> Result.Ok x
775
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
776
                  (fun arg1  ->
777
                     ((function
778
                       | `Null -> Result.Ok None
779
                       | x ->
780
                           ((function
781
                             | `String x -> Result.Ok x
782
                             | _ -> Result.Error "Vhdl_ast.vhdl_type_t") x)
783
                             >>= ((fun x  -> Result.Ok (Some x)))) arg0)
784
                       >>=
785
                       (fun arg0  -> Result.Ok (Range (arg0, arg1, arg2))))))
786
      | `List ((`String "Bit_vector")::arg0::arg1::[]) ->
787
          ((function
788
            | `Int x -> Result.Ok x
789
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
790
            ((fun arg1  ->
791
                ((function
792
                  | `Int x -> Result.Ok x
793
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
794
                  (fun arg0  -> Result.Ok (Bit_vector (arg0, arg1)))))
795
      | `List ((`String "Array")::arg0::arg1::arg2::[]) ->
796
          ((fun x  -> vhdl_type_t_of_yojson x) arg2) >>=
797
            ((fun arg2  ->
798
                ((function
799
                  | `Int x -> Result.Ok x
800
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
801
                  (fun arg1  ->
802
                     ((function
803
                       | `Int x -> Result.Ok x
804
                       | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
805
                       (fun arg0  -> Result.Ok (Array (arg0, arg1, arg2))))))
806
      | `List ((`String "Enumerated")::arg0::[]) ->
807
          ((function
808
            | `List xs ->
809
                map_bind
810
                  (function
811
                   | `String x -> Result.Ok x
812
                   | _ -> Result.Error "Vhdl_ast.vhdl_type_t") [] xs
813
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
814
            ((fun arg0  -> Result.Ok (Enumerated arg0)))
815
      | `List ((`String "Void")::[]) -> Result.Ok Void
816
      | _ -> Result.Error "Vhdl_ast.vhdl_type_t")
817
  [@ocaml.warning "-A"])
818

    
819
and (vhdl_subtype_indication_t_to_yojson :
820
      vhdl_subtype_indication_t -> Yojson.Safe.json)
821
  =
822
  ((let open! Ppx_deriving_yojson_runtime in
823
      fun x  ->
824
        let fields = []  in
825
        let fields =
826
          if x.const = NoConstraint
827
          then fields
828
          else
829
            ("const", (((fun x  -> vhdl_constraint_t_to_yojson x)) x.const))
830
            :: fields
831
           in
832
        let fields =
833
          if x.functionName = NoName
834
          then fields
835
          else
836
            ("functionName",
837
              (((fun x  -> vhdl_name_t_to_yojson x)) x.functionName))
838
            :: fields
839
           in
840
        let fields =
841
          if x.name = NoName
842
          then fields
843
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
844
            fields
845
           in
846
        `Assoc fields)
847
  [@ocaml.warning "-A"])
848

    
849
and (vhdl_subtype_indication_t_of_yojson :
850
      Yojson.Safe.json ->
851
        vhdl_subtype_indication_t Ppx_deriving_yojson_runtime.error_or)
852
  =
853
  ((let open! Ppx_deriving_yojson_runtime in
854
      function
855
      | `Assoc xs ->
856
          let rec loop xs ((arg0,arg1,arg2) as _state) =
857
            match xs with
858
            | ("name",x)::xs ->
859
                loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
860
            | ("functionName",x)::xs ->
861
                loop xs (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
862
            | ("const",x)::xs ->
863
                loop xs
864
                  (arg0, arg1, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
865
            | [] ->
866
                arg2 >>=
867
                  ((fun arg2  ->
868
                      arg1 >>=
869
                        (fun arg1  ->
870
                           arg0 >>=
871
                             (fun arg0  ->
872
                                Result.Ok
873
                                  {
874
                                    name = arg0;
875
                                    functionName = arg1;
876
                                    const = arg2
877
                                  }))))
878
            | _::xs -> loop xs _state  in
879
          loop xs
880
            ((Result.Ok NoName), (Result.Ok NoName),
881
              (Result.Ok NoConstraint))
882
      | _ -> Result.Error "Vhdl_ast.vhdl_subtype_indication_t")
883
  [@ocaml.warning "-A"])
884

    
885
and (vhdl_discrete_range_t_to_yojson :
886
      vhdl_discrete_range_t -> Yojson.Safe.json)
887
  =
888
  ((let open! Ppx_deriving_yojson_runtime in
889
      function
890
      | SubDiscreteRange arg0 ->
891
          `List
892
            [`String "SUB_DISCRETE_RANGE";
893
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x)) arg0]
894
      | NamedRange arg0 ->
895
          `List
896
            [`String "NAMED_RANGE";
897
            ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
898
      | DirectedRange arg0 ->
899
          `List
900
            [`String "RANGE_WITH_DIRECTION";
901
            (let fields = []  in
902
             let fields =
903
               ("_to", ((fun x  -> vhdl_expr_t_to_yojson x) arg0._to)) ::
904
               fields  in
905
             let fields =
906
               ("from", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.from)) ::
907
               fields  in
908
             let fields =
909
               ("direction",
910
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
911
                    arg0.direction))
912
               :: fields  in
913
             `Assoc fields)])
914
  [@ocaml.warning "-A"])
915

    
916
and (vhdl_discrete_range_t_of_yojson :
917
      Yojson.Safe.json ->
918
        vhdl_discrete_range_t Ppx_deriving_yojson_runtime.error_or)
919
  =
920
  ((let open! Ppx_deriving_yojson_runtime in
921
      function
922
      | `List ((`String "SUB_DISCRETE_RANGE")::arg0::[]) ->
923
          ((fun x  -> vhdl_subtype_indication_t_of_yojson x) arg0) >>=
924
            ((fun arg0  -> Result.Ok (SubDiscreteRange arg0)))
925
      | `List ((`String "NAMED_RANGE")::arg0::[]) ->
926
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
927
            ((fun arg0  -> Result.Ok (NamedRange arg0)))
928
      | `List ((`String "RANGE_WITH_DIRECTION")::arg0::[]) ->
929
          ((function
930
            | `Assoc xs ->
931
                let rec loop xs ((arg0,arg1,arg2) as _state) =
932
                  match xs with
933
                  | ("direction",x)::xs ->
934
                      loop xs
935
                        (((function
936
                           | `String x -> Result.Ok x
937
                           | _ ->
938
                               Result.Error
939
                                 "Vhdl_ast.vhdl_discrete_range_t.direction")
940
                            x), arg1, arg2)
941
                  | ("from",x)::xs ->
942
                      loop xs
943
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
944
                  | ("_to",x)::xs ->
945
                      loop xs
946
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
947
                  | [] ->
948
                      arg2 >>=
949
                        ((fun arg2  ->
950
                            arg1 >>=
951
                              (fun arg1  ->
952
                                 arg0 >>=
953
                                   (fun arg0  ->
954
                                      Result.Ok
955
                                        (DirectedRange
956
                                           {
957
                                             direction = arg0;
958
                                             from = arg1;
959
                                             _to = arg2
960
                                           })))))
961
                  | _::xs -> loop xs _state  in
962
                loop xs
963
                  ((Result.Error "Vhdl_ast.vhdl_discrete_range_t.direction"),
964
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t.from"),
965
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t._to"))
966
            | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")) arg0
967
      | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")
968
  [@ocaml.warning "-A"])
969

    
970
and (vhdl_constraint_t_to_yojson : vhdl_constraint_t -> Yojson.Safe.json) =
971
  ((let open! Ppx_deriving_yojson_runtime in
972
      function
973
      | RefConstraint arg0 ->
974
          `List
975
            [`String "RefConstraint";
976
            (let fields = []  in
977
             let fields =
978
               ("ref_name",
979
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.ref_name))
980
               :: fields  in
981
             `Assoc fields)]
982
      | RangeConstraint arg0 ->
983
          `List
984
            [`String "RANGE_CONSTRAINT";
985
            (let fields = []  in
986
             let fields =
987
               ("range",
988
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
989
               :: fields  in
990
             `Assoc fields)]
991
      | IndexConstraint arg0 ->
992
          `List
993
            [`String "INDEX_CONSTRAINT";
994
            (let fields = []  in
995
             let fields =
996
               ("ranges",
997
                 ((fun x  ->
998
                     `List
999
                       (List.map
1000
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1001
                    arg0.ranges))
1002
               :: fields  in
1003
             `Assoc fields)]
1004
      | ArrayConstraint arg0 ->
1005
          `List
1006
            [`String "ARRAY_CONSTRAINT";
1007
            (let fields = []  in
1008
             let fields =
1009
               ("sub", ((fun x  -> vhdl_constraint_t_to_yojson x) arg0.sub))
1010
               :: fields  in
1011
             let fields =
1012
               ("ranges",
1013
                 ((fun x  ->
1014
                     `List
1015
                       (List.map
1016
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1017
                    arg0.ranges))
1018
               :: fields  in
1019
             `Assoc fields)]
1020
      | RecordConstraint  -> `List [`String "RecordConstraint"]
1021
      | NoConstraint  -> `List [`String "NoConstraint"])
1022
  [@ocaml.warning "-A"])
1023

    
1024
and (vhdl_constraint_t_of_yojson :
1025
      Yojson.Safe.json ->
1026
        vhdl_constraint_t Ppx_deriving_yojson_runtime.error_or)
1027
  =
1028
  ((let open! Ppx_deriving_yojson_runtime in
1029
      function
1030
      | `List ((`String "RefConstraint")::arg0::[]) ->
1031
          ((function
1032
            | `Assoc xs ->
1033
                let rec loop xs (arg0 as _state) =
1034
                  match xs with
1035
                  | ("ref_name",x)::xs ->
1036
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
1037
                  | [] ->
1038
                      arg0 >>=
1039
                        ((fun arg0  ->
1040
                            Result.Ok (RefConstraint { ref_name = arg0 })))
1041
                  | _::xs -> loop xs _state  in
1042
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ref_name")
1043
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1044
      | `List ((`String "RANGE_CONSTRAINT")::arg0::[]) ->
1045
          ((function
1046
            | `Assoc xs ->
1047
                let rec loop xs (arg0 as _state) =
1048
                  match xs with
1049
                  | ("range",x)::xs ->
1050
                      loop xs
1051
                        ((fun x  -> vhdl_discrete_range_t_of_yojson x) x)
1052
                  | [] ->
1053
                      arg0 >>=
1054
                        ((fun arg0  ->
1055
                            Result.Ok (RangeConstraint { range = arg0 })))
1056
                  | _::xs -> loop xs _state  in
1057
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.range")
1058
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1059
      | `List ((`String "INDEX_CONSTRAINT")::arg0::[]) ->
1060
          ((function
1061
            | `Assoc xs ->
1062
                let rec loop xs (arg0 as _state) =
1063
                  match xs with
1064
                  | ("ranges",x)::xs ->
1065
                      loop xs
1066
                        ((function
1067
                          | `List xs ->
1068
                              map_bind
1069
                                (fun x  -> vhdl_discrete_range_t_of_yojson x)
1070
                                [] xs
1071
                          | _ ->
1072
                              Result.Error
1073
                                "Vhdl_ast.vhdl_constraint_t.ranges") x)
1074
                  | [] ->
1075
                      arg0 >>=
1076
                        ((fun arg0  ->
1077
                            Result.Ok (IndexConstraint { ranges = arg0 })))
1078
                  | _::xs -> loop xs _state  in
1079
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ranges")
1080
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1081
      | `List ((`String "ARRAY_CONSTRAINT")::arg0::[]) ->
1082
          ((function
1083
            | `Assoc xs ->
1084
                let rec loop xs ((arg0,arg1) as _state) =
1085
                  match xs with
1086
                  | ("ranges",x)::xs ->
1087
                      loop xs
1088
                        (((function
1089
                           | `List xs ->
1090
                               map_bind
1091
                                 (fun x  -> vhdl_discrete_range_t_of_yojson x)
1092
                                 [] xs
1093
                           | _ ->
1094
                               Result.Error
1095
                                 "Vhdl_ast.vhdl_constraint_t.ranges") x),
1096
                          arg1)
1097
                  | ("sub",x)::xs ->
1098
                      loop xs
1099
                        (arg0, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
1100
                  | [] ->
1101
                      arg1 >>=
1102
                        ((fun arg1  ->
1103
                            arg0 >>=
1104
                              (fun arg0  ->
1105
                                 Result.Ok
1106
                                   (ArrayConstraint
1107
                                      { ranges = arg0; sub = arg1 }))))
1108
                  | _::xs -> loop xs _state  in
1109
                loop xs
1110
                  ((Result.Error "Vhdl_ast.vhdl_constraint_t.ranges"),
1111
                    (Result.Error "Vhdl_ast.vhdl_constraint_t.sub"))
1112
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1113
      | `List ((`String "RecordConstraint")::[]) ->
1114
          Result.Ok RecordConstraint
1115
      | `List ((`String "NoConstraint")::[]) -> Result.Ok NoConstraint
1116
      | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")
1117
  [@ocaml.warning "-A"])
1118

    
1119
and (vhdl_definition_t_to_yojson : vhdl_definition_t -> Yojson.Safe.json) =
1120
  ((let open! Ppx_deriving_yojson_runtime in
1121
      function
1122
      | Type arg0 ->
1123
          `List
1124
            [`String "TYPE_DECLARATION";
1125
            (let fields = []  in
1126
             let fields =
1127
               ("definition",
1128
                 ((fun x  -> vhdl_type_t_to_yojson x) arg0.definition))
1129
               :: fields  in
1130
             let fields =
1131
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1132
               fields  in
1133
             `Assoc fields)]
1134
      | Subtype arg0 ->
1135
          `List
1136
            [`String "SUBTYPE_DECLARATION";
1137
            (let fields = []  in
1138
             let fields =
1139
               ("typ",
1140
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
1141
               :: fields  in
1142
             let fields =
1143
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1144
               fields  in
1145
             `Assoc fields)])
1146
  [@ocaml.warning "-A"])
1147

    
1148
and (vhdl_definition_t_of_yojson :
1149
      Yojson.Safe.json ->
1150
        vhdl_definition_t Ppx_deriving_yojson_runtime.error_or)
1151
  =
1152
  ((let open! Ppx_deriving_yojson_runtime in
1153
      function
1154
      | `List ((`String "TYPE_DECLARATION")::arg0::[]) ->
1155
          ((function
1156
            | `Assoc xs ->
1157
                let rec loop xs ((arg0,arg1) as _state) =
1158
                  match xs with
1159
                  | ("name",x)::xs ->
1160
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1161
                  | ("definition",x)::xs ->
1162
                      loop xs (arg0, ((fun x  -> vhdl_type_t_of_yojson x) x))
1163
                  | [] ->
1164
                      arg1 >>=
1165
                        ((fun arg1  ->
1166
                            arg0 >>=
1167
                              (fun arg0  ->
1168
                                 Result.Ok
1169
                                   (Type { name = arg0; definition = arg1 }))))
1170
                  | _::xs -> loop xs _state  in
1171
                loop xs
1172
                  ((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
1173
                    (Result.Error "Vhdl_ast.vhdl_definition_t.definition"))
1174
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
1175
      | `List ((`String "SUBTYPE_DECLARATION")::arg0::[]) ->
1176
          ((function
1177
            | `Assoc xs ->
1178
                let rec loop xs ((arg0,arg1) as _state) =
1179
                  match xs with
1180
                  | ("name",x)::xs ->
1181
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1182
                  | ("typ",x)::xs ->
1183
                      loop xs
1184
                        (arg0,
1185
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
1186
                             x))
1187
                  | [] ->
1188
                      arg1 >>=
1189
                        ((fun arg1  ->
1190
                            arg0 >>=
1191
                              (fun arg0  ->
1192
                                 Result.Ok
1193
                                   (Subtype { name = arg0; typ = arg1 }))))
1194
                  | _::xs -> loop xs _state  in
1195
                loop xs
1196
                  ((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
1197
                    (Result.Error "Vhdl_ast.vhdl_definition_t.typ"))
1198
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
1199
      | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")
1200
  [@ocaml.warning "-A"])
1201

    
1202
and (vhdl_expr_t_to_yojson : vhdl_expr_t -> Yojson.Safe.json) =
1203
  ((let open! Ppx_deriving_yojson_runtime in
1204
      function
1205
      | Call arg0 ->
1206
          `List [`String "CALL"; ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
1207
      | Cst arg0 ->
1208
          `List
1209
            [`String "CONSTANT_VALUE";
1210
            ((fun x  -> vhdl_cst_val_t_to_yojson x)) arg0]
1211
      | Op arg0 ->
1212
          `List
1213
            [`String "EXPRESSION";
1214
            (let fields = []  in
1215
             let fields =
1216
               if arg0.args = []
1217
               then fields
1218
               else
1219
                 ("args",
1220
                   (((fun x  ->
1221
                        `List
1222
                          (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
1223
                      arg0.args))
1224
                 :: fields
1225
                in
1226
             let fields =
1227
               if arg0.id = ""
1228
               then fields
1229
               else
1230
                 ("id",
1231
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
1232
                      arg0.id))
1233
                 :: fields
1234
                in
1235
             `Assoc fields)]
1236
      | IsNull  -> `List [`String "IsNull"]
1237
      | Time arg0 ->
1238
          `List
1239
            [`String "Time";
1240
            (let fields = []  in
1241
             let fields =
1242
               if arg0.phy_unit = ""
1243
               then fields
1244
               else
1245
                 ("phy_unit",
1246
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
1247
                      arg0.phy_unit))
1248
                 :: fields
1249
                in
1250
             let fields =
1251
               ("value",
1252
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.value))
1253
               :: fields  in
1254
             `Assoc fields)]
1255
      | Sig arg0 ->
1256
          `List
1257
            [`String "Sig";
1258
            (let fields = []  in
1259
             let fields =
1260
               ("att",
1261
                 ((function
1262
                   | None  -> `Null
1263
                   | Some x ->
1264
                       ((fun x  -> vhdl_signal_attributes_t_to_yojson x)) x)
1265
                    arg0.att))
1266
               :: fields  in
1267
             let fields =
1268
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1269
               fields  in
1270
             `Assoc fields)]
1271
      | SuffixMod arg0 ->
1272
          `List
1273
            [`String "SuffixMod";
1274
            (let fields = []  in
1275
             let fields =
1276
               ("selection",
1277
                 ((fun x  -> vhdl_suffix_selection_t_to_yojson x)
1278
                    arg0.selection))
1279
               :: fields  in
1280
             let fields =
1281
               ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.expr)) ::
1282
               fields  in
1283
             `Assoc fields)]
1284
      | Aggregate arg0 ->
1285
          `List
1286
            [`String "AGGREGATE";
1287
            (let fields = []  in
1288
             let fields =
1289
               ("elems",
1290
                 ((fun x  ->
1291
                     `List
1292
                       (List.map (fun x  -> vhdl_element_assoc_t_to_yojson x)
1293
                          x)) arg0.elems))
1294
               :: fields  in
1295
             `Assoc fields)]
1296
      | Others  -> `List [`String "OTHERS"])
1297
  [@ocaml.warning "-A"])
1298

    
1299
and (vhdl_expr_t_of_yojson :
1300
      Yojson.Safe.json -> vhdl_expr_t Ppx_deriving_yojson_runtime.error_or)
1301
  =
1302
  ((let open! Ppx_deriving_yojson_runtime in
1303
      function
1304
      | `List ((`String "CALL")::arg0::[]) ->
1305
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
1306
            ((fun arg0  -> Result.Ok (Call arg0)))
1307
      | `List ((`String "CONSTANT_VALUE")::arg0::[]) ->
1308
          ((fun x  -> vhdl_cst_val_t_of_yojson x) arg0) >>=
1309
            ((fun arg0  -> Result.Ok (Cst arg0)))
1310
      | `List ((`String "EXPRESSION")::arg0::[]) ->
1311
          ((function
1312
            | `Assoc xs ->
1313
                let rec loop xs ((arg0,arg1) as _state) =
1314
                  match xs with
1315
                  | ("id",x)::xs ->
1316
                      loop xs
1317
                        (((function
1318
                           | `String x -> Result.Ok x
1319
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.id") x),
1320
                          arg1)
1321
                  | ("args",x)::xs ->
1322
                      loop xs
1323
                        (arg0,
1324
                          ((function
1325
                            | `List xs ->
1326
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1327
                                  [] xs
1328
                            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.args")
1329
                             x))
1330
                  | [] ->
1331
                      arg1 >>=
1332
                        ((fun arg1  ->
1333
                            arg0 >>=
1334
                              (fun arg0  ->
1335
                                 Result.Ok (Op { id = arg0; args = arg1 }))))
1336
                  | _::xs -> loop xs _state  in
1337
                loop xs ((Result.Ok ""), (Result.Ok []))
1338
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1339
      | `List ((`String "IsNull")::[]) -> Result.Ok IsNull
1340
      | `List ((`String "Time")::arg0::[]) ->
1341
          ((function
1342
            | `Assoc xs ->
1343
                let rec loop xs ((arg0,arg1) as _state) =
1344
                  match xs with
1345
                  | ("value",x)::xs ->
1346
                      loop xs
1347
                        (((function
1348
                           | `Int x -> Result.Ok x
1349
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.value")
1350
                            x), arg1)
1351
                  | ("phy_unit",x)::xs ->
1352
                      loop xs
1353
                        (arg0,
1354
                          ((function
1355
                            | `String x -> Result.Ok x
1356
                            | _ ->
1357
                                Result.Error "Vhdl_ast.vhdl_expr_t.phy_unit")
1358
                             x))
1359
                  | [] ->
1360
                      arg1 >>=
1361
                        ((fun arg1  ->
1362
                            arg0 >>=
1363
                              (fun arg0  ->
1364
                                 Result.Ok
1365
                                   (Time { value = arg0; phy_unit = arg1 }))))
1366
                  | _::xs -> loop xs _state  in
1367
                loop xs
1368
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.value"),
1369
                    (Result.Ok ""))
1370
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1371
      | `List ((`String "Sig")::arg0::[]) ->
1372
          ((function
1373
            | `Assoc xs ->
1374
                let rec loop xs ((arg0,arg1) as _state) =
1375
                  match xs with
1376
                  | ("name",x)::xs ->
1377
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1378
                  | ("att",x)::xs ->
1379
                      loop xs
1380
                        (arg0,
1381
                          ((function
1382
                            | `Null -> Result.Ok None
1383
                            | x ->
1384
                                ((fun x  ->
1385
                                    vhdl_signal_attributes_t_of_yojson x) x)
1386
                                  >>= ((fun x  -> Result.Ok (Some x)))) x))
1387
                  | [] ->
1388
                      arg1 >>=
1389
                        ((fun arg1  ->
1390
                            arg0 >>=
1391
                              (fun arg0  ->
1392
                                 Result.Ok (Sig { name = arg0; att = arg1 }))))
1393
                  | _::xs -> loop xs _state  in
1394
                loop xs
1395
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.name"),
1396
                    (Result.Error "Vhdl_ast.vhdl_expr_t.att"))
1397
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1398
      | `List ((`String "SuffixMod")::arg0::[]) ->
1399
          ((function
1400
            | `Assoc xs ->
1401
                let rec loop xs ((arg0,arg1) as _state) =
1402
                  match xs with
1403
                  | ("expr",x)::xs ->
1404
                      loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
1405
                  | ("selection",x)::xs ->
1406
                      loop xs
1407
                        (arg0,
1408
                          ((fun x  -> vhdl_suffix_selection_t_of_yojson x) x))
1409
                  | [] ->
1410
                      arg1 >>=
1411
                        ((fun arg1  ->
1412
                            arg0 >>=
1413
                              (fun arg0  ->
1414
                                 Result.Ok
1415
                                   (SuffixMod
1416
                                      { expr = arg0; selection = arg1 }))))
1417
                  | _::xs -> loop xs _state  in
1418
                loop xs
1419
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.expr"),
1420
                    (Result.Error "Vhdl_ast.vhdl_expr_t.selection"))
1421
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1422
      | `List ((`String "AGGREGATE")::arg0::[]) ->
1423
          ((function
1424
            | `Assoc xs ->
1425
                let rec loop xs (arg0 as _state) =
1426
                  match xs with
1427
                  | ("elems",x)::xs ->
1428
                      loop xs
1429
                        ((function
1430
                          | `List xs ->
1431
                              map_bind
1432
                                (fun x  -> vhdl_element_assoc_t_of_yojson x)
1433
                                [] xs
1434
                          | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.elems") x)
1435
                  | [] ->
1436
                      arg0 >>=
1437
                        ((fun arg0  -> Result.Ok (Aggregate { elems = arg0 })))
1438
                  | _::xs -> loop xs _state  in
1439
                loop xs (Result.Error "Vhdl_ast.vhdl_expr_t.elems")
1440
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1441
      | `List ((`String "OTHERS")::[]) -> Result.Ok Others
1442
      | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")
1443
  [@ocaml.warning "-A"])
1444

    
1445
and (vhdl_name_t_to_yojson : vhdl_name_t -> Yojson.Safe.json) =
1446
  ((let open! Ppx_deriving_yojson_runtime in
1447
      function
1448
      | Simple arg0 ->
1449
          `List
1450
            [`String "SIMPLE_NAME";
1451
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1452
      | Identifier arg0 ->
1453
          `List
1454
            [`String "IDENTIFIER";
1455
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1456
      | Selected arg0 ->
1457
          `List
1458
            [`String "SELECTED_NAME";
1459
            ((fun x  ->
1460
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
1461
      | Index arg0 ->
1462
          `List
1463
            [`String "INDEXED_NAME";
1464
            (let fields = []  in
1465
             let fields =
1466
               ("exprs",
1467
                 ((fun x  ->
1468
                     `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
1469
                    arg0.exprs))
1470
               :: fields  in
1471
             let fields =
1472
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1473
               fields  in
1474
             `Assoc fields)]
1475
      | Slice arg0 ->
1476
          `List
1477
            [`String "SLICE_NAME";
1478
            (let fields = []  in
1479
             let fields =
1480
               ("range",
1481
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
1482
               :: fields  in
1483
             let fields =
1484
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1485
               fields  in
1486
             `Assoc fields)]
1487
      | Attribute arg0 ->
1488
          `List
1489
            [`String "ATTRIBUTE_NAME";
1490
            (let fields = []  in
1491
             let fields =
1492
               if arg0.expr = IsNull
1493
               then fields
1494
               else
1495
                 ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.expr))
1496
                 :: fields
1497
                in
1498
             let fields =
1499
               ("designator",
1500
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.designator))
1501
               :: fields  in
1502
             let fields =
1503
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1504
               fields  in
1505
             `Assoc fields)]
1506
      | Function arg0 ->
1507
          `List
1508
            [`String "FUNCTION_CALL";
1509
            (let fields = []  in
1510
             let fields =
1511
               ("assoc_list",
1512
                 ((fun x  ->
1513
                     `List
1514
                       (List.map (fun x  -> vhdl_assoc_element_t_to_yojson x)
1515
                          x)) arg0.assoc_list))
1516
               :: fields  in
1517
             let fields =
1518
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1519
               fields  in
1520
             `Assoc fields)]
1521
      | NoName  -> `List [`String "NoName"])
1522
  [@ocaml.warning "-A"])
1523

    
1524
and (vhdl_name_t_of_yojson :
1525
      Yojson.Safe.json -> vhdl_name_t Ppx_deriving_yojson_runtime.error_or)
1526
  =
1527
  ((let open! Ppx_deriving_yojson_runtime in
1528
      function
1529
      | `List ((`String "SIMPLE_NAME")::arg0::[]) ->
1530
          ((function
1531
            | `String x -> Result.Ok x
1532
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1533
            ((fun arg0  -> Result.Ok (Simple arg0)))
1534
      | `List ((`String "IDENTIFIER")::arg0::[]) ->
1535
          ((function
1536
            | `String x -> Result.Ok x
1537
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1538
            ((fun arg0  -> Result.Ok (Identifier arg0)))
1539
      | `List ((`String "SELECTED_NAME")::arg0::[]) ->
1540
          ((function
1541
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1542
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1543
            ((fun arg0  -> Result.Ok (Selected arg0)))
1544
      | `List ((`String "INDEXED_NAME")::arg0::[]) ->
1545
          ((function
1546
            | `Assoc xs ->
1547
                let rec loop xs ((arg0,arg1) as _state) =
1548
                  match xs with
1549
                  | ("id",x)::xs ->
1550
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1551
                  | ("exprs",x)::xs ->
1552
                      loop xs
1553
                        (arg0,
1554
                          ((function
1555
                            | `List xs ->
1556
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1557
                                  [] xs
1558
                            | _ -> Result.Error "Vhdl_ast.vhdl_name_t.exprs")
1559
                             x))
1560
                  | [] ->
1561
                      arg1 >>=
1562
                        ((fun arg1  ->
1563
                            arg0 >>=
1564
                              (fun arg0  ->
1565
                                 Result.Ok
1566
                                   (Index { id = arg0; exprs = arg1 }))))
1567
                  | _::xs -> loop xs _state  in
1568
                loop xs
1569
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1570
                    (Result.Error "Vhdl_ast.vhdl_name_t.exprs"))
1571
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1572
      | `List ((`String "SLICE_NAME")::arg0::[]) ->
1573
          ((function
1574
            | `Assoc xs ->
1575
                let rec loop xs ((arg0,arg1) as _state) =
1576
                  match xs with
1577
                  | ("id",x)::xs ->
1578
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1579
                  | ("range",x)::xs ->
1580
                      loop xs
1581
                        (arg0,
1582
                          ((fun x  -> vhdl_discrete_range_t_of_yojson x) x))
1583
                  | [] ->
1584
                      arg1 >>=
1585
                        ((fun arg1  ->
1586
                            arg0 >>=
1587
                              (fun arg0  ->
1588
                                 Result.Ok
1589
                                   (Slice { id = arg0; range = arg1 }))))
1590
                  | _::xs -> loop xs _state  in
1591
                loop xs
1592
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1593
                    (Result.Error "Vhdl_ast.vhdl_name_t.range"))
1594
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1595
      | `List ((`String "ATTRIBUTE_NAME")::arg0::[]) ->
1596
          ((function
1597
            | `Assoc xs ->
1598
                let rec loop xs ((arg0,arg1,arg2) as _state) =
1599
                  match xs with
1600
                  | ("id",x)::xs ->
1601
                      loop xs
1602
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
1603
                  | ("designator",x)::xs ->
1604
                      loop xs
1605
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
1606
                  | ("expr",x)::xs ->
1607
                      loop xs
1608
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1609
                  | [] ->
1610
                      arg2 >>=
1611
                        ((fun arg2  ->
1612
                            arg1 >>=
1613
                              (fun arg1  ->
1614
                                 arg0 >>=
1615
                                   (fun arg0  ->
1616
                                      Result.Ok
1617
                                        (Attribute
1618
                                           {
1619
                                             id = arg0;
1620
                                             designator = arg1;
1621
                                             expr = arg2
1622
                                           })))))
1623
                  | _::xs -> loop xs _state  in
1624
                loop xs
1625
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1626
                    (Result.Error "Vhdl_ast.vhdl_name_t.designator"),
1627
                    (Result.Ok IsNull))
1628
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1629
      | `List ((`String "FUNCTION_CALL")::arg0::[]) ->
1630
          ((function
1631
            | `Assoc xs ->
1632
                let rec loop xs ((arg0,arg1) as _state) =
1633
                  match xs with
1634
                  | ("id",x)::xs ->
1635
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1636
                  | ("assoc_list",x)::xs ->
1637
                      loop xs
1638
                        (arg0,
1639
                          ((function
1640
                            | `List xs ->
1641
                                map_bind
1642
                                  (fun x  -> vhdl_assoc_element_t_of_yojson x)
1643
                                  [] xs
1644
                            | _ ->
1645
                                Result.Error
1646
                                  "Vhdl_ast.vhdl_name_t.assoc_list") x))
1647
                  | [] ->
1648
                      arg1 >>=
1649
                        ((fun arg1  ->
1650
                            arg0 >>=
1651
                              (fun arg0  ->
1652
                                 Result.Ok
1653
                                   (Function { id = arg0; assoc_list = arg1 }))))
1654
                  | _::xs -> loop xs _state  in
1655
                loop xs
1656
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1657
                    (Result.Error "Vhdl_ast.vhdl_name_t.assoc_list"))
1658
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1659
      | `List ((`String "NoName")::[]) -> Result.Ok NoName
1660
      | _ -> Result.Error "Vhdl_ast.vhdl_name_t")
1661
  [@ocaml.warning "-A"])
1662

    
1663
and (vhdl_assoc_element_t_to_yojson :
1664
      vhdl_assoc_element_t -> Yojson.Safe.json)
1665
  =
1666
  ((let open! Ppx_deriving_yojson_runtime in
1667
      fun x  ->
1668
        let fields = []  in
1669
        let fields =
1670
          if x.actual_expr = None
1671
          then fields
1672
          else
1673
            ("actual_expr",
1674
              (((function
1675
                 | None  -> `Null
1676
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
1677
                 x.actual_expr))
1678
            :: fields
1679
           in
1680
        let fields =
1681
          if x.actual_designator = None
1682
          then fields
1683
          else
1684
            ("actual_designator",
1685
              (((function
1686
                 | None  -> `Null
1687
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1688
                 x.actual_designator))
1689
            :: fields
1690
           in
1691
        let fields =
1692
          if x.actual_name = None
1693
          then fields
1694
          else
1695
            ("actual_name",
1696
              (((function
1697
                 | None  -> `Null
1698
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1699
                 x.actual_name))
1700
            :: fields
1701
           in
1702
        let fields =
1703
          if x.formal_arg = None
1704
          then fields
1705
          else
1706
            ("formal_arg",
1707
              (((function
1708
                 | None  -> `Null
1709
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1710
                 x.formal_arg))
1711
            :: fields
1712
           in
1713
        let fields =
1714
          if x.formal_name = None
1715
          then fields
1716
          else
1717
            ("formal_name",
1718
              (((function
1719
                 | None  -> `Null
1720
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1721
                 x.formal_name))
1722
            :: fields
1723
           in
1724
        `Assoc fields)
1725
  [@ocaml.warning "-A"])
1726

    
1727
and (vhdl_assoc_element_t_of_yojson :
1728
      Yojson.Safe.json ->
1729
        vhdl_assoc_element_t Ppx_deriving_yojson_runtime.error_or)
1730
  =
1731
  ((let open! Ppx_deriving_yojson_runtime in
1732
      function
1733
      | `Assoc xs ->
1734
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
1735
            match xs with
1736
            | ("formal_name",x)::xs ->
1737
                loop xs
1738
                  (((function
1739
                     | `Null -> Result.Ok None
1740
                     | x ->
1741
                         ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1742
                           ((fun x  -> Result.Ok (Some x)))) x), arg1, arg2,
1743
                    arg3, arg4)
1744
            | ("formal_arg",x)::xs ->
1745
                loop xs
1746
                  (arg0,
1747
                    ((function
1748
                      | `Null -> Result.Ok None
1749
                      | x ->
1750
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1751
                            ((fun x  -> Result.Ok (Some x)))) x), arg2, arg3,
1752
                    arg4)
1753
            | ("actual_name",x)::xs ->
1754
                loop xs
1755
                  (arg0, arg1,
1756
                    ((function
1757
                      | `Null -> Result.Ok None
1758
                      | x ->
1759
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1760
                            ((fun x  -> Result.Ok (Some x)))) x), arg3, arg4)
1761
            | ("actual_designator",x)::xs ->
1762
                loop xs
1763
                  (arg0, arg1, arg2,
1764
                    ((function
1765
                      | `Null -> Result.Ok None
1766
                      | x ->
1767
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1768
                            ((fun x  -> Result.Ok (Some x)))) x), arg4)
1769
            | ("actual_expr",x)::xs ->
1770
                loop xs
1771
                  (arg0, arg1, arg2, arg3,
1772
                    ((function
1773
                      | `Null -> Result.Ok None
1774
                      | x ->
1775
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
1776
                            ((fun x  -> Result.Ok (Some x)))) x))
1777
            | [] ->
1778
                arg4 >>=
1779
                  ((fun arg4  ->
1780
                      arg3 >>=
1781
                        (fun arg3  ->
1782
                           arg2 >>=
1783
                             (fun arg2  ->
1784
                                arg1 >>=
1785
                                  (fun arg1  ->
1786
                                     arg0 >>=
1787
                                       (fun arg0  ->
1788
                                          Result.Ok
1789
                                            {
1790
                                              formal_name = arg0;
1791
                                              formal_arg = arg1;
1792
                                              actual_name = arg2;
1793
                                              actual_designator = arg3;
1794
                                              actual_expr = arg4
1795
                                            }))))))
1796
            | _::xs -> loop xs _state  in
1797
          loop xs
1798
            ((Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
1799
              (Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
1800
              (Result.Ok (Some IsNull)))
1801
      | _ -> Result.Error "Vhdl_ast.vhdl_assoc_element_t")
1802
  [@ocaml.warning "-A"])
1803

    
1804
and (vhdl_element_assoc_t_to_yojson :
1805
      vhdl_element_assoc_t -> Yojson.Safe.json)
1806
  =
1807
  ((let open! Ppx_deriving_yojson_runtime in
1808
      fun x  ->
1809
        let fields = []  in
1810
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
1811
          :: fields  in
1812
        let fields =
1813
          ("choices",
1814
            ((fun x  ->
1815
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
1816
               x.choices))
1817
          :: fields  in
1818
        `Assoc fields)
1819
  [@ocaml.warning "-A"])
1820

    
1821
and (vhdl_element_assoc_t_of_yojson :
1822
      Yojson.Safe.json ->
1823
        vhdl_element_assoc_t Ppx_deriving_yojson_runtime.error_or)
1824
  =
1825
  ((let open! Ppx_deriving_yojson_runtime in
1826
      function
1827
      | `Assoc xs ->
1828
          let rec loop xs ((arg0,arg1) as _state) =
1829
            match xs with
1830
            | ("choices",x)::xs ->
1831
                loop xs
1832
                  (((function
1833
                     | `List xs ->
1834
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
1835
                     | _ ->
1836
                         Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices")
1837
                      x), arg1)
1838
            | ("expr",x)::xs ->
1839
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1840
            | [] ->
1841
                arg1 >>=
1842
                  ((fun arg1  ->
1843
                      arg0 >>=
1844
                        (fun arg0  ->
1845
                           Result.Ok { choices = arg0; expr = arg1 })))
1846
            | _::xs -> loop xs _state  in
1847
          loop xs
1848
            ((Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices"),
1849
              (Result.Error "Vhdl_ast.vhdl_element_assoc_t.expr"))
1850
      | _ -> Result.Error "Vhdl_ast.vhdl_element_assoc_t")
1851
  [@ocaml.warning "-A"])
1852

    
1853
and (vhdl_array_attributes_t_to_yojson :
1854
      vhdl_array_attributes_t -> Yojson.Safe.json)
1855
  =
1856
  ((let open! Ppx_deriving_yojson_runtime in
1857
      function
1858
      | AAttInt arg0 ->
1859
          `List
1860
            [`String "AAttInt";
1861
            (let fields = []  in
1862
             let fields =
1863
               ("arg",
1864
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
1865
               :: fields  in
1866
             let fields =
1867
               ("id",
1868
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
1869
                    arg0.id))
1870
               :: fields  in
1871
             `Assoc fields)]
1872
      | AAttAscending  -> `List [`String "AAttAscending"])
1873
  [@ocaml.warning "-A"])
1874

    
1875
and (vhdl_array_attributes_t_of_yojson :
1876
      Yojson.Safe.json ->
1877
        vhdl_array_attributes_t Ppx_deriving_yojson_runtime.error_or)
1878
  =
1879
  ((let open! Ppx_deriving_yojson_runtime in
1880
      function
1881
      | `List ((`String "AAttInt")::arg0::[]) ->
1882
          ((function
1883
            | `Assoc xs ->
1884
                let rec loop xs ((arg0,arg1) as _state) =
1885
                  match xs with
1886
                  | ("id",x)::xs ->
1887
                      loop xs
1888
                        (((function
1889
                           | `String x -> Result.Ok x
1890
                           | _ ->
1891
                               Result.Error
1892
                                 "Vhdl_ast.vhdl_array_attributes_t.id") x),
1893
                          arg1)
1894
                  | ("arg",x)::xs ->
1895
                      loop xs
1896
                        (arg0,
1897
                          ((function
1898
                            | `Int x -> Result.Ok x
1899
                            | _ ->
1900
                                Result.Error
1901
                                  "Vhdl_ast.vhdl_array_attributes_t.arg") x))
1902
                  | [] ->
1903
                      arg1 >>=
1904
                        ((fun arg1  ->
1905
                            arg0 >>=
1906
                              (fun arg0  ->
1907
                                 Result.Ok
1908
                                   (AAttInt { id = arg0; arg = arg1 }))))
1909
                  | _::xs -> loop xs _state  in
1910
                loop xs
1911
                  ((Result.Error "Vhdl_ast.vhdl_array_attributes_t.id"),
1912
                    (Result.Error "Vhdl_ast.vhdl_array_attributes_t.arg"))
1913
            | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")) arg0
1914
      | `List ((`String "AAttAscending")::[]) -> Result.Ok AAttAscending
1915
      | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")
1916
  [@ocaml.warning "-A"])
1917

    
1918
and (vhdl_signal_attributes_t_to_yojson :
1919
      vhdl_signal_attributes_t -> Yojson.Safe.json)
1920
  =
1921
  ((let open! Ppx_deriving_yojson_runtime in
1922
      function
1923
      | SigAtt arg0 ->
1924
          `List
1925
            [`String "SigAtt";
1926
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
1927
  [@ocaml.warning "-A"])
1928

    
1929
and (vhdl_signal_attributes_t_of_yojson :
1930
      Yojson.Safe.json ->
1931
        vhdl_signal_attributes_t Ppx_deriving_yojson_runtime.error_or)
1932
  =
1933
  ((let open! Ppx_deriving_yojson_runtime in
1934
      function
1935
      | `List ((`String "SigAtt")::arg0::[]) ->
1936
          ((function
1937
            | `String x -> Result.Ok x
1938
            | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t") arg0)
1939
            >>= ((fun arg0  -> Result.Ok (SigAtt arg0)))
1940
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t")
1941
  [@ocaml.warning "-A"])
1942

    
1943
and (vhdl_string_attributes_t_to_yojson :
1944
      vhdl_string_attributes_t -> Yojson.Safe.json)
1945
  =
1946
  ((let open! Ppx_deriving_yojson_runtime in
1947
      function
1948
      | StringAtt arg0 ->
1949
          `List
1950
            [`String "StringAtt";
1951
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
1952
  [@ocaml.warning "-A"])
1953

    
1954
and (vhdl_string_attributes_t_of_yojson :
1955
      Yojson.Safe.json ->
1956
        vhdl_string_attributes_t Ppx_deriving_yojson_runtime.error_or)
1957
  =
1958
  ((let open! Ppx_deriving_yojson_runtime in
1959
      function
1960
      | `List ((`String "StringAtt")::arg0::[]) ->
1961
          ((function
1962
            | `String x -> Result.Ok x
1963
            | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t") arg0)
1964
            >>= ((fun arg0  -> Result.Ok (StringAtt arg0)))
1965
      | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t")
1966
  [@ocaml.warning "-A"])
1967

    
1968
and (vhdl_suffix_selection_t_to_yojson :
1969
      vhdl_suffix_selection_t -> Yojson.Safe.json)
1970
  =
1971
  ((let open! Ppx_deriving_yojson_runtime in
1972
      function
1973
      | Idx arg0 ->
1974
          `List
1975
            [`String "Idx";
1976
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0]
1977
      | SuffixRange (arg0,arg1) ->
1978
          `List
1979
            [`String "SuffixRange";
1980
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
1981
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1])
1982
  [@ocaml.warning "-A"])
1983

    
1984
and (vhdl_suffix_selection_t_of_yojson :
1985
      Yojson.Safe.json ->
1986
        vhdl_suffix_selection_t Ppx_deriving_yojson_runtime.error_or)
1987
  =
1988
  ((let open! Ppx_deriving_yojson_runtime in
1989
      function
1990
      | `List ((`String "Idx")::arg0::[]) ->
1991
          ((function
1992
            | `Int x -> Result.Ok x
1993
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg0) >>=
1994
            ((fun arg0  -> Result.Ok (Idx arg0)))
1995
      | `List ((`String "SuffixRange")::arg0::arg1::[]) ->
1996
          ((function
1997
            | `Int x -> Result.Ok x
1998
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg1) >>=
1999
            ((fun arg1  ->
2000
                ((function
2001
                  | `Int x -> Result.Ok x
2002
                  | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2003
                   arg0)
2004
                  >>= (fun arg0  -> Result.Ok (SuffixRange (arg0, arg1)))))
2005
      | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2006
  [@ocaml.warning "-A"])
2007

    
2008
type 'basetype vhdl_type_attributes_t =
2009
  | TAttNoArg of {
2010
  id: string } 
2011
  | TAttIntArg of {
2012
  id: string ;
2013
  arg: int } 
2014
  | TAttValArg of {
2015
  id: string ;
2016
  arg: 'basetype } 
2017
  | TAttStringArg of {
2018
  id: string ;
2019
  arg: string } 
2020

    
2021
(* TODO *)
2022
let rec pp_vhdl_type_attributes_t
2023
  =
2024
  ((let open! Ppx_deriving_runtime in
2025
      fun poly_basetype  ->
2026
        fun fmt  ->
2027
          function
2028
          | TAttNoArg { id = aid } ->
2029
              (Format.fprintf fmt "@[<2>TAttNoArg {@,";
2030
               (Format.fprintf fmt "@[%s =@ " "id";
2031
                (Format.fprintf fmt "%S") aid;
2032
                Format.fprintf fmt "@]");
2033
               Format.fprintf fmt "@]}")
2034
          | TAttIntArg { id = aid; arg = aarg } ->
2035
              (Format.fprintf fmt "@[<2>TAttIntArg {@,";
2036
               ((Format.fprintf fmt "@[%s =@ " "id";
2037
                 (Format.fprintf fmt "%S") aid;
2038
                 Format.fprintf fmt "@]");
2039
                Format.fprintf fmt ";@ ";
2040
                Format.fprintf fmt "@[%s =@ " "arg";
2041
                (Format.fprintf fmt "%d") aarg;
2042
                Format.fprintf fmt "@]");
2043
               Format.fprintf fmt "@]}")
2044
          | TAttValArg { id = aid; arg = aarg } ->
2045
              (Format.fprintf fmt "@[<2>TAttValArg {@,";
2046
               ((Format.fprintf fmt "@[%s =@ " "id";
2047
                 (Format.fprintf fmt "%S") aid;
2048
                 Format.fprintf fmt "@]");
2049
                Format.fprintf fmt ";@ ";
2050
                Format.fprintf fmt "@[%s =@ " "arg";
2051
                (poly_basetype fmt) aarg;
2052
                Format.fprintf fmt "@]");
2053
               Format.fprintf fmt "@]}")
2054
          | TAttStringArg { id = aid; arg = aarg } ->
2055
              (Format.fprintf fmt "@[<2>TAttStringArg {@,";
2056
               ((Format.fprintf fmt "@[%s =@ " "id";
2057
                 (Format.fprintf fmt "%S") aid;
2058
                 Format.fprintf fmt "@]");
2059
                Format.fprintf fmt ";@ ";
2060
                Format.fprintf fmt "@[%s =@ " "arg";
2061
                (Format.fprintf fmt "%S") aarg;
2062
                Format.fprintf fmt "@]");
2063
               Format.fprintf fmt "@]}"))
2064
  [@ocaml.warning "-A"])
2065

    
2066
and show_vhdl_type_attributes_t  =
2067
  fun poly_basetype  ->
2068
    fun x  ->
2069
      Format.asprintf "%a" (pp_vhdl_type_attributes_t poly_basetype) x
2070

    
2071
let rec vhdl_type_attributes_t_to_yojson :
2072
  'basetype .
2073
    ('basetype -> Yojson.Safe.json) ->
2074
      'basetype vhdl_type_attributes_t -> Yojson.Safe.json
2075
  =
2076
  fun poly_basetype  ->
2077
    ((let open! Ppx_deriving_yojson_runtime in
2078
        function
2079
        | TAttNoArg arg0 ->
2080
            `List
2081
              [`String "TAttNoArg";
2082
              (let fields = []  in
2083
               let fields =
2084
                 ("id",
2085
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2086
                      arg0.id))
2087
                 :: fields  in
2088
               `Assoc fields)]
2089
        | TAttIntArg arg0 ->
2090
            `List
2091
              [`String "TAttIntArg";
2092
              (let fields = []  in
2093
               let fields =
2094
                 ("arg",
2095
                   ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
2096
                 :: fields  in
2097
               let fields =
2098
                 ("id",
2099
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2100
                      arg0.id))
2101
                 :: fields  in
2102
               `Assoc fields)]
2103
        | TAttValArg arg0 ->
2104
            `List
2105
              [`String "TAttValArg";
2106
              (let fields = []  in
2107
               let fields =
2108
                 ("arg", ((poly_basetype : _ -> Yojson.Safe.json) 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
        | TAttStringArg arg0 ->
2117
            `List
2118
              [`String "TAttStringArg";
2119
              (let fields = []  in
2120
               let fields =
2121
                 ("arg",
2122
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2123
                      arg0.arg))
2124
                 :: fields  in
2125
               let fields =
2126
                 ("id",
2127
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2128
                      arg0.id))
2129
                 :: fields  in
2130
               `Assoc fields)])
2131
    [@ocaml.warning "-A"])
2132

    
2133
and vhdl_type_attributes_t_of_yojson :
2134
  'basetype .
2135
    (Yojson.Safe.json -> 'basetype Ppx_deriving_yojson_runtime.error_or) ->
2136
      Yojson.Safe.json ->
2137
        'basetype vhdl_type_attributes_t Ppx_deriving_yojson_runtime.error_or
2138
  =
2139
  fun poly_basetype  ->
2140
    ((let open! Ppx_deriving_yojson_runtime in
2141
        function
2142
        | `List ((`String "TAttNoArg")::arg0::[]) ->
2143
            ((function
2144
              | `Assoc xs ->
2145
                  let rec loop xs (arg0 as _state) =
2146
                    match xs with
2147
                    | ("id",x)::xs ->
2148
                        loop xs
2149
                          ((function
2150
                            | `String x -> Result.Ok x
2151
                            | _ ->
2152
                                Result.Error
2153
                                  "Vhdl_ast.vhdl_type_attributes_t.id") x)
2154
                    | [] ->
2155
                        arg0 >>=
2156
                          ((fun arg0  -> Result.Ok (TAttNoArg { id = arg0 })))
2157
                    | _::xs -> loop xs _state  in
2158
                  loop xs (Result.Error "Vhdl_ast.vhdl_type_attributes_t.id")
2159
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2160
        | `List ((`String "TAttIntArg")::arg0::[]) ->
2161
            ((function
2162
              | `Assoc xs ->
2163
                  let rec loop xs ((arg0,arg1) as _state) =
2164
                    match xs with
2165
                    | ("id",x)::xs ->
2166
                        loop xs
2167
                          (((function
2168
                             | `String x -> Result.Ok x
2169
                             | _ ->
2170
                                 Result.Error
2171
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2172
                            arg1)
2173
                    | ("arg",x)::xs ->
2174
                        loop xs
2175
                          (arg0,
2176
                            ((function
2177
                              | `Int x -> Result.Ok x
2178
                              | _ ->
2179
                                  Result.Error
2180
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2181
                    | [] ->
2182
                        arg1 >>=
2183
                          ((fun arg1  ->
2184
                              arg0 >>=
2185
                                (fun arg0  ->
2186
                                   Result.Ok
2187
                                     (TAttIntArg { id = arg0; arg = arg1 }))))
2188
                    | _::xs -> loop xs _state  in
2189
                  loop xs
2190
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2191
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2192
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2193
        | `List ((`String "TAttValArg")::arg0::[]) ->
2194
            ((function
2195
              | `Assoc xs ->
2196
                  let rec loop xs ((arg0,arg1) as _state) =
2197
                    match xs with
2198
                    | ("id",x)::xs ->
2199
                        loop xs
2200
                          (((function
2201
                             | `String x -> Result.Ok x
2202
                             | _ ->
2203
                                 Result.Error
2204
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2205
                            arg1)
2206
                    | ("arg",x)::xs ->
2207
                        loop xs
2208
                          (arg0,
2209
                            ((poly_basetype : Yojson.Safe.json -> _ error_or)
2210
                               x))
2211
                    | [] ->
2212
                        arg1 >>=
2213
                          ((fun arg1  ->
2214
                              arg0 >>=
2215
                                (fun arg0  ->
2216
                                   Result.Ok
2217
                                     (TAttValArg { id = arg0; arg = arg1 }))))
2218
                    | _::xs -> loop xs _state  in
2219
                  loop xs
2220
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2221
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2222
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2223
        | `List ((`String "TAttStringArg")::arg0::[]) ->
2224
            ((function
2225
              | `Assoc xs ->
2226
                  let rec loop xs ((arg0,arg1) as _state) =
2227
                    match xs with
2228
                    | ("id",x)::xs ->
2229
                        loop xs
2230
                          (((function
2231
                             | `String x -> Result.Ok x
2232
                             | _ ->
2233
                                 Result.Error
2234
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2235
                            arg1)
2236
                    | ("arg",x)::xs ->
2237
                        loop xs
2238
                          (arg0,
2239
                            ((function
2240
                              | `String x -> Result.Ok x
2241
                              | _ ->
2242
                                  Result.Error
2243
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2244
                    | [] ->
2245
                        arg1 >>=
2246
                          ((fun arg1  ->
2247
                              arg0 >>=
2248
                                (fun arg0  ->
2249
                                   Result.Ok
2250
                                     (TAttStringArg { id = arg0; arg = arg1 }))))
2251
                    | _::xs -> loop xs _state  in
2252
                  loop xs
2253
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2254
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2255
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2256
        | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")
2257
    [@ocaml.warning "-A"])
2258

    
2259
let typ_att_noarg = ["base"; "left"; "right"; "high"; "low"] 
2260
let typ_att_intarg = ["pos"; "val"; "succ"; "pred"; "leftof"; "rightof"] 
2261
let typ_att_valarg = ["image"] 
2262
let typ_att_stringarg = ["value"] 
2263
let array_att_intarg =
2264
  ["left"; "right"; "high"; "low"; "range"; "reverse_range"; "length"] 
2265
type vhdl_parameter_t =
2266
  {
2267
  names: vhdl_name_t list ;
2268
  mode: string list [@default []];
2269
  typ: vhdl_subtype_indication_t ;
2270
  init_val: vhdl_cst_val_t option [@default None]}
2271

    
2272
(* TODO *)
2273
let rec pp_vhdl_parameter_t :
2274
  Format.formatter -> vhdl_parameter_t -> Ppx_deriving_runtime.unit =
2275
  let __2 () = pp_vhdl_cst_val_t
2276
  
2277
  and __1 () = pp_vhdl_subtype_indication_t
2278
  
2279
  and __0 () = pp_vhdl_name_t
2280
   in
2281
  ((let open! Ppx_deriving_runtime in
2282
      fun fmt  ->
2283
        fun x  ->
2284
          Format.fprintf fmt "@[<2>{ ";
2285
          ((((Format.fprintf fmt "@[%s =@ " "names";
2286
              ((fun x  ->
2287
                  Format.fprintf fmt "@[<2>[";
2288
                  ignore
2289
                    (List.fold_left
2290
                       (fun sep  ->
2291
                          fun x  ->
2292
                            if sep then Format.fprintf fmt ";@ ";
2293
                            ((__0 ()) fmt) x;
2294
                            true) false x);
2295
                  Format.fprintf fmt "@,]@]")) x.names;
2296
              Format.fprintf fmt "@]");
2297
             Format.fprintf fmt ";@ ";
2298
             Format.fprintf fmt "@[%s =@ " "mode";
2299
             ((fun x  ->
2300
                 Format.fprintf fmt "@[<2>[";
2301
                 ignore
2302
                   (List.fold_left
2303
                      (fun sep  ->
2304
                         fun x  ->
2305
                           if sep then Format.fprintf fmt ";@ ";
2306
                           (Format.fprintf fmt "%S") x;
2307
                           true) false x);
2308
                 Format.fprintf fmt "@,]@]")) x.mode;
2309
             Format.fprintf fmt "@]");
2310
            Format.fprintf fmt ";@ ";
2311
            Format.fprintf fmt "@[%s =@ " "typ";
2312
            ((__1 ()) fmt) x.typ;
2313
            Format.fprintf fmt "@]");
2314
           Format.fprintf fmt ";@ ";
2315
           Format.fprintf fmt "@[%s =@ " "init_val";
2316
           ((function
2317
             | None  -> Format.pp_print_string fmt "None"
2318
             | Some x ->
2319
                 (Format.pp_print_string fmt "(Some ";
2320
                  ((__2 ()) fmt) x;
2321
                  Format.pp_print_string fmt ")"))) x.init_val;
2322
           Format.fprintf fmt "@]");
2323
          Format.fprintf fmt "@ }@]")
2324
    [@ocaml.warning "-A"])
2325

    
2326
and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string =
2327
  fun x  -> Format.asprintf "%a" pp_vhdl_parameter_t x
2328

    
2329
let rec (vhdl_parameter_t_to_yojson : vhdl_parameter_t -> Yojson.Safe.json) =
2330
  ((let open! Ppx_deriving_yojson_runtime in
2331
      fun x  ->
2332
        let fields = []  in
2333
        let fields =
2334
          if x.init_val = None
2335
          then fields
2336
          else
2337
            ("init_val",
2338
              (((function
2339
                 | None  -> `Null
2340
                 | Some x -> ((fun x  -> vhdl_cst_val_t_to_yojson x)) x))
2341
                 x.init_val))
2342
            :: fields
2343
           in
2344
        let fields =
2345
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
2346
          :: fields  in
2347
        let fields =
2348
          if x.mode = []
2349
          then fields
2350
          else
2351
            ("mode",
2352
              (((fun x  ->
2353
                   `List
2354
                     (List.map
2355
                        (fun (x : Ppx_deriving_runtime.string)  -> `String x)
2356
                        x))) x.mode))
2357
            :: fields
2358
           in
2359
        let fields =
2360
          ("names",
2361
            ((fun x  ->
2362
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
2363
               x.names))
2364
          :: fields  in
2365
        `Assoc fields)
2366
  [@ocaml.warning "-A"])
2367

    
2368
and (vhdl_parameter_t_of_yojson :
2369
      Yojson.Safe.json ->
2370
        vhdl_parameter_t Ppx_deriving_yojson_runtime.error_or)
2371
  =
2372
  ((let open! Ppx_deriving_yojson_runtime in
2373
      function
2374
      | `Assoc xs ->
2375
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2376
            match xs with
2377
            | ("names",x)::xs ->
2378
                loop xs
2379
                  (((function
2380
                     | `List xs ->
2381
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
2382
                     | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.names") x),
2383
                    arg1, arg2, arg3)
2384
            | ("mode",x)::xs ->
2385
                loop xs
2386
                  (arg0,
2387
                    ((function
2388
                      | `List xs ->
2389
                          map_bind
2390
                            (function
2391
                             | `String x -> Result.Ok x
2392
                             | _ ->
2393
                                 Result.Error
2394
                                   "Vhdl_ast.vhdl_parameter_t.mode") [] xs
2395
                      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.mode") x),
2396
                    arg2, arg3)
2397
            | ("typ",x)::xs ->
2398
                loop xs
2399
                  (arg0, arg1,
2400
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
2401
                    arg3)
2402
            | ("init_val",x)::xs ->
2403
                loop xs
2404
                  (arg0, arg1, arg2,
2405
                    ((function
2406
                      | `Null -> Result.Ok None
2407
                      | x ->
2408
                          ((fun x  -> vhdl_cst_val_t_of_yojson x) x) >>=
2409
                            ((fun x  -> Result.Ok (Some x)))) x))
2410
            | [] ->
2411
                arg3 >>=
2412
                  ((fun arg3  ->
2413
                      arg2 >>=
2414
                        (fun arg2  ->
2415
                           arg1 >>=
2416
                             (fun arg1  ->
2417
                                arg0 >>=
2418
                                  (fun arg0  ->
2419
                                     Result.Ok
2420
                                       {
2421
                                         names = arg0;
2422
                                         mode = arg1;
2423
                                         typ = arg2;
2424
                                         init_val = arg3
2425
                                       })))))
2426
            | _::xs -> loop xs _state  in
2427
          loop xs
2428
            ((Result.Error "Vhdl_ast.vhdl_parameter_t.names"),
2429
              (Result.Ok []), (Result.Error "Vhdl_ast.vhdl_parameter_t.typ"),
2430
              (Result.Ok (Some (CstInt 0))))
2431
      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t")
2432
  [@ocaml.warning "-A"])
2433

    
2434
type vhdl_subprogram_spec_t =
2435
  {
2436
  name: string [@default ""];
2437
  typeMark: vhdl_name_t [@default NoName];
2438
  parameters: vhdl_parameter_t list ;
2439
  isPure: bool [@default false]}
2440

    
2441
(* TODO *)
2442
let rec pp_vhdl_subprogram_spec_t :
2443
  Format.formatter -> vhdl_subprogram_spec_t -> Ppx_deriving_runtime.unit =
2444
  let __1 () = pp_vhdl_parameter_t
2445
  
2446
  and __0 () = pp_vhdl_name_t
2447
   in
2448
  ((let open! Ppx_deriving_runtime in
2449
      fun fmt  ->
2450
        fun x  ->
2451
          Format.fprintf fmt "@[<2>{ ";
2452
          ((((Format.fprintf fmt "@[%s =@ " "name";
2453
              (Format.fprintf fmt "%S") x.name;
2454
              Format.fprintf fmt "@]");
2455
             Format.fprintf fmt ";@ ";
2456
             Format.fprintf fmt "@[%s =@ " "typeMark";
2457
             ((__0 ()) fmt) x.typeMark;
2458
             Format.fprintf fmt "@]");
2459
            Format.fprintf fmt ";@ ";
2460
            Format.fprintf fmt "@[%s =@ " "parameters";
2461
            ((fun x  ->
2462
                Format.fprintf fmt "@[<2>[";
2463
                ignore
2464
                  (List.fold_left
2465
                     (fun sep  ->
2466
                        fun x  ->
2467
                          if sep then Format.fprintf fmt ";@ ";
2468
                          ((__1 ()) fmt) x;
2469
                          true) false x);
2470
                Format.fprintf fmt "@,]@]")) x.parameters;
2471
            Format.fprintf fmt "@]");
2472
           Format.fprintf fmt ";@ ";
2473
           Format.fprintf fmt "@[%s =@ " "isPure";
2474
           (Format.fprintf fmt "%B") x.isPure;
2475
           Format.fprintf fmt "@]");
2476
          Format.fprintf fmt "@ }@]")
2477
    [@ocaml.warning "-A"])
2478

    
2479
and show_vhdl_subprogram_spec_t :
2480
  vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string =
2481
  fun x  -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x
2482

    
2483
let rec (vhdl_subprogram_spec_t_to_yojson :
2484
          vhdl_subprogram_spec_t -> Yojson.Safe.json)
2485
  =
2486
  ((let open! Ppx_deriving_yojson_runtime in
2487
      fun x  ->
2488
        let fields = []  in
2489
        let fields =
2490
          if x.isPure = false
2491
          then fields
2492
          else
2493
            ("isPure",
2494
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x)) x.isPure))
2495
            :: fields
2496
           in
2497
        let fields =
2498
          ("parameters",
2499
            ((fun x  ->
2500
                `List (List.map (fun x  -> vhdl_parameter_t_to_yojson x) x))
2501
               x.parameters))
2502
          :: fields  in
2503
        let fields =
2504
          if x.typeMark = NoName
2505
          then fields
2506
          else
2507
            ("typeMark", (((fun x  -> vhdl_name_t_to_yojson x)) x.typeMark))
2508
            :: fields
2509
           in
2510
        let fields =
2511
          if x.name = ""
2512
          then fields
2513
          else
2514
            ("name",
2515
              (((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x.name))
2516
            :: fields
2517
           in
2518
        `Assoc fields)
2519
  [@ocaml.warning "-A"])
2520

    
2521
and (vhdl_subprogram_spec_t_of_yojson :
2522
      Yojson.Safe.json ->
2523
        vhdl_subprogram_spec_t Ppx_deriving_yojson_runtime.error_or)
2524
  =
2525
  ((let open! Ppx_deriving_yojson_runtime in
2526
      function
2527
      | `Assoc xs ->
2528
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2529
            match xs with
2530
            | ("name",x)::xs ->
2531
                loop xs
2532
                  (((function
2533
                     | `String x -> Result.Ok x
2534
                     | _ ->
2535
                         Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.name")
2536
                      x), arg1, arg2, arg3)
2537
            | ("typeMark",x)::xs ->
2538
                loop xs
2539
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3)
2540
            | ("parameters",x)::xs ->
2541
                loop xs
2542
                  (arg0, arg1,
2543
                    ((function
2544
                      | `List xs ->
2545
                          map_bind (fun x  -> vhdl_parameter_t_of_yojson x)
2546
                            [] xs
2547
                      | _ ->
2548
                          Result.Error
2549
                            "Vhdl_ast.vhdl_subprogram_spec_t.parameters") x),
2550
                    arg3)
2551
            | ("isPure",x)::xs ->
2552
                loop xs
2553
                  (arg0, arg1, arg2,
2554
                    ((function
2555
                      | `Bool x -> Result.Ok x
2556
                      | _ ->
2557
                          Result.Error
2558
                            "Vhdl_ast.vhdl_subprogram_spec_t.isPure") x))
2559
            | [] ->
2560
                arg3 >>=
2561
                  ((fun arg3  ->
2562
                      arg2 >>=
2563
                        (fun arg2  ->
2564
                           arg1 >>=
2565
                             (fun arg1  ->
2566
                                arg0 >>=
2567
                                  (fun arg0  ->
2568
                                     Result.Ok
2569
                                       {
2570
                                         name = arg0;
2571
                                         typeMark = arg1;
2572
                                         parameters = arg2;
2573
                                         isPure = arg3
2574
                                       })))))
2575
            | _::xs -> loop xs _state  in
2576
          loop xs
2577
            ((Result.Ok ""), (Result.Ok NoName),
2578
              (Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.parameters"),
2579
              (Result.Ok false))
2580
      | _ -> Result.Error "Vhdl_ast.vhdl_subprogram_spec_t")
2581
  [@ocaml.warning "-A"])
2582

    
2583
let arith_funs = ["+"; "-"; "*"; "/"; "mod"; "rem"; "abs"; "**"; "&"] 
2584
let bool_funs = ["and"; "or"; "nand"; "nor"; "xor"; "not"] 
2585
let rel_funs =
2586
  ["<";
2587
  ">";
2588
  "<=";
2589
  ">=";
2590
  "/=";
2591
  "=";
2592
  "?=";
2593
  "?/=";
2594
  "?<";
2595
  "?<=";
2596
  "?>";
2597
  "?>=";
2598
  "??"] 
2599
let shift_funs = ["sll"; "srl"; "sla"; "sra"; "rol"; "ror"] 
2600
type vhdl_sequential_stmt_t =
2601
  | VarAssign of
2602
  {
2603
  label: vhdl_name_t [@default NoName];
2604
  lhs: vhdl_name_t ;
2605
  rhs: vhdl_expr_t } [@name "VARIABLE_ASSIGNMENT_STATEMENT"]
2606
  | SigSeqAssign of
2607
  {
2608
  label: vhdl_name_t [@default NoName];
2609
  lhs: vhdl_name_t ;
2610
  rhs: vhdl_expr_t list } [@name "SIGNAL_ASSIGNMENT_STATEMENT"]
2611
  | If of
2612
  {
2613
  label: vhdl_name_t [@default NoName];
2614
  if_cases: vhdl_if_case_t list ;
2615
  default: vhdl_sequential_stmt_t list [@default []]} [@name "IF_STATEMENT"]
2616
  | Case of
2617
  {
2618
  label: vhdl_name_t [@default NoName];
2619
  guard: vhdl_expr_t ;
2620
  branches: vhdl_case_item_t list } [@name "CASE_STATEMENT_TREE"]
2621
  | Exit of
2622
  {
2623
  label: vhdl_name_t [@default NoName];
2624
  loop_label: string option [@default Some ""];
2625
  condition: vhdl_expr_t option [@default Some IsNull]}
2626
  [@name "EXIT_STATEMENT"]
2627
  | Assert of
2628
  {
2629
  label: vhdl_name_t [@default NoName];
2630
  cond: vhdl_expr_t ;
2631
  report: vhdl_expr_t [@default IsNull];
2632
  severity: vhdl_expr_t [@default IsNull]} [@name "ASSERTION_STATEMENT"]
2633
  | ProcedureCall of
2634
  {
2635
  label: vhdl_name_t [@default NoName];
2636
  name: vhdl_name_t ;
2637
  assocs: vhdl_assoc_element_t list } [@name "PROCEDURE_CALL_STATEMENT"]
2638
  | Wait [@name "WAIT_STATEMENT"]
2639
  | Null of {
2640
  label: vhdl_name_t [@default NoName]} [@name "NULL_STATEMENT"]
2641
  | Return of {
2642
  label: vhdl_name_t [@default NoName]} [@name "RETURN_STATEMENT"]
2643
and vhdl_if_case_t =
2644
  {
2645
  if_cond: vhdl_expr_t ;
2646
  if_block: vhdl_sequential_stmt_t list }
2647
and vhdl_case_item_t =
2648
  {
2649
  when_cond: vhdl_expr_t list ;
2650
  when_stmt: vhdl_sequential_stmt_t list }
2651

    
2652
(* TODO Adapt for: Assert, ProcedureCall *)
2653
let rec pp_vhdl_sequential_stmt_t :
2654
  Format.formatter -> vhdl_sequential_stmt_t -> Ppx_deriving_runtime.unit =
2655
  let __22 () = pp_vhdl_name_t
2656
  
2657
  and __21 () = pp_vhdl_name_t
2658
  
2659
  and __20 () = pp_vhdl_assoc_element_t
2660
  
2661
  and __19 () = pp_vhdl_name_t
2662
  
2663
  and __18 () = pp_vhdl_name_t
2664
  
2665
  and __17 () = pp_vhdl_expr_t
2666
  
2667
  and __16 () = pp_vhdl_expr_t
2668
  
2669
  and __15 () = pp_vhdl_expr_t
2670
  
2671
  and __14 () = pp_vhdl_name_t
2672
  
2673
  and __13 () = pp_vhdl_expr_t
2674
  
2675
  and __12 () = pp_vhdl_name_t
2676
  
2677
  and __11 () = pp_vhdl_case_item_t
2678
  
2679
  and __10 () = pp_vhdl_expr_t
2680
  
2681
  and __9 () = pp_vhdl_name_t
2682
  
2683
  and __8 () = pp_vhdl_sequential_stmt_t
2684
  
2685
  and __7 () = pp_vhdl_if_case_t
2686
  
2687
  and __6 () = pp_vhdl_name_t
2688
  
2689
  and __5 () = pp_vhdl_expr_t
2690
  
2691
  and __4 () = pp_vhdl_name_t
2692
  
2693
  and __3 () = pp_vhdl_name_t
2694
  
2695
  and __2 () = pp_vhdl_expr_t
2696
  
2697
  and __1 () = pp_vhdl_name_t
2698
  
2699
  and __0 () = pp_vhdl_name_t
2700
   in
2701
  ((let open! Ppx_deriving_runtime in
2702
      fun fmt  ->
2703
        function
2704
        | VarAssign { label = alabel; lhs = alhs; rhs = arhs } ->
2705
            (match alabel with
2706
              | NoName -> Format.fprintf fmt "";
2707
              | _ -> (((__0 ()) fmt) alabel;
2708
                     Format.fprintf fmt ":@ ")
2709
            );
2710
            ((__1 ()) fmt) alhs;
2711
            Format.fprintf fmt "@ :=@ ";
2712
            ((__2 ()) fmt) arhs;
2713
(* TODO: Check
2714
            (Format.fprintf fmt "@[<2>VarAssign {@,";
2715
             (((Format.fprintf fmt "@[%s =@ " "label";
2716
                ((__0 ()) fmt) alabel;
2717
                Format.fprintf fmt "@]");
2718
               Format.fprintf fmt ";@ ";
2719
               Format.fprintf fmt "@[%s =@ " "lhs";
2720
               ((__1 ()) fmt) alhs;
2721
               Format.fprintf fmt "@]");
2722
              Format.fprintf fmt ";@ ";
2723
              Format.fprintf fmt "@[%s =@ " "rhs";
2724
              ((__2 ()) fmt) arhs;
2725
              Format.fprintf fmt "@]");
2726
             Format.fprintf fmt "@]}") *)
2727
        | SigSeqAssign { label = alabel; lhs = alhs; rhs = arhs } ->
2728
            (match alabel with
2729
              | NoName -> Format.fprintf fmt "";
2730
              | _ -> (((__3 ()) fmt) alabel;
2731
                     Format.fprintf fmt ":@ ")
2732
            );
2733
            Format.fprintf fmt "@[<2>";
2734
            ((__4 ()) fmt) alhs;
2735
            Format.fprintf fmt "@ <=@ ";
2736
            ((fun x  ->
2737
               Format.fprintf fmt "@[";
2738
               ignore
2739
                 (List.fold_left
2740
                   (fun sep  ->
2741
                     fun x  ->
2742
                       if sep then Format.fprintf fmt "";
2743
                        ((__5 ()) fmt) x;
2744
                        Format.fprintf fmt ";";
2745
                        true) false x);
2746
            Format.fprintf fmt "@]@]")) arhs;
2747
        | If { label = alabel; if_cases = aif_cases; default = adefault } ->
2748
            (match alabel with
2749
              | NoName -> Format.fprintf fmt "";
2750
              | _ -> (((__6 ()) fmt) alabel;
2751
                     Format.fprintf fmt ":@ ")
2752
            );
2753
            Format.fprintf fmt "@[<v>if";
2754
            ((fun x ->
2755
               ignore
2756
               (List.fold_left
2757
                 (fun sep  ->
2758
                   fun x  ->
2759
                           if sep then Format.fprintf fmt "@;elseif";
2760
                                ((__7 ()) fmt) x;
2761
                                true
2762
                 ) false x);
2763
             )) aif_cases;
2764
             (match adefault with
2765
              | [] -> Format.fprintf fmt "";
2766
              | _  -> (Format.fprintf fmt "@;else";
2767
                      ((fun x  ->
2768
                          Format.fprintf fmt "@;<0 2>";
2769
                          ignore
2770
                            (List.fold_left
2771
                              (fun sep  ->
2772
                                fun x  ->
2773
                                        if sep then Format.fprintf fmt "";
2774
                          ((__8 ()) fmt) x;
2775
                          true) false x))) adefault));
2776
            Format.fprintf fmt "@;end if;@]"
2777
        | Case { label = alabel; guard = aguard; branches = abranches } ->
2778
            (match alabel with
2779
              | NoName -> Format.fprintf fmt "";
2780
              | _ -> (((__9 ()) fmt) alabel;
2781
                     Format.fprintf fmt ":@ ")
2782
            );
2783
            Format.fprintf fmt "@[<v>case ";
2784
            ((__10 ()) fmt) aguard;
2785
            Format.fprintf fmt " is";
2786
            ((fun x  ->
2787
                ignore
2788
                  (List.fold_left
2789
                     (fun sep  ->
2790
                        fun x  ->
2791
                          if sep then Format.fprintf fmt "";
2792
                          ((__11 ()) fmt) x;
2793
                          true) false x);)) abranches;
2794
            Format.fprintf fmt "@;end case;@]";
2795
        | Exit
2796
            { label = alabel; loop_label = aloop_label;
2797
              condition = acondition }
2798
            ->
2799
            (match alabel with
2800
              | NoName -> Format.fprintf fmt "";
2801
              | _ -> (((__12 ()) fmt) alabel;
2802
                     Format.fprintf fmt ":@ ")
2803
            );
2804
            Format.fprintf fmt "exit";
2805
            (match aloop_label with
2806
               | None  -> Format.pp_print_string fmt ""
2807
               | Some x -> (Format.fprintf fmt "@ %s@ ") x);
2808
            ((function
2809
               | None  -> Format.pp_print_string fmt ""
2810
               | Some x ->
2811
                   (Format.pp_print_string fmt "when@ ";
2812
                    ((__13 ()) fmt) x;))) acondition;
2813
        | Assert
2814
            { label = alabel; cond = acond; report = areport;
2815
              severity = aseverity }
2816
            ->
2817
            (Format.fprintf fmt "@[<2>Assert {@,";
2818
             ((((Format.fprintf fmt "@[%s =@ " "label";
2819
                 ((__14 ()) fmt) alabel;
2820
                 Format.fprintf fmt "@]");
2821
                Format.fprintf fmt ";@ ";
2822
                Format.fprintf fmt "@[%s =@ " "cond";
2823
                ((__15 ()) fmt) acond;
2824
                Format.fprintf fmt "@]");
2825
               Format.fprintf fmt ";@ ";
2826
               Format.fprintf fmt "@[%s =@ " "report";
2827
               ((__16 ()) fmt) areport;
2828
               Format.fprintf fmt "@]");
2829
              Format.fprintf fmt ";@ ";
2830
              Format.fprintf fmt "@[%s =@ " "severity";
2831
              ((__17 ()) fmt) aseverity;
2832
              Format.fprintf fmt "@]");
2833
             Format.fprintf fmt "@]}")
2834
        | ProcedureCall { label = alabel; name = aname; assocs = aassocs } ->
2835
            (match alabel with
2836
              | NoName -> Format.fprintf fmt "";
2837
              | _ -> (((__18 ()) fmt) alabel;
2838
                     Format.fprintf fmt ":@ ")
2839
            );
2840
            ((__19 ()) fmt) aname;
2841
            ((fun x  ->
2842
                Format.fprintf fmt "(";
2843
                ignore
2844
                  (List.fold_left
2845
                     (fun sep  ->
2846
                        fun x  ->
2847
                          if sep then Format.fprintf fmt ",@ ";
2848
                          ((__20 ()) fmt) x;
2849
                          true) false x);
2850
            Format.fprintf fmt ")")) aassocs;
2851
        | Wait  -> Format.pp_print_string fmt "wait"
2852
        | Null { label = alabel } ->
2853
            (match alabel with
2854
              | NoName -> Format.fprintf fmt "";
2855
              | _ -> (((__18 ()) fmt) alabel;
2856
                     Format.fprintf fmt ":@ ")
2857
            );
2858
            Format.fprintf fmt "null";
2859
        | Return { label = alabel } ->
2860
            (match alabel with
2861
              | NoName -> Format.fprintf fmt "";
2862
              | _ -> (((__19 ()) fmt) alabel;
2863
                     Format.fprintf fmt ":@ ")
2864
            );
2865
            Format.fprintf fmt "return";)
2866
    [@ocaml.warning "-A"])
2867

    
2868
and show_vhdl_sequential_stmt_t :
2869
  vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string =
2870
  fun x  -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x
2871

    
2872
and pp_vhdl_if_case_t :
2873
  Format.formatter -> vhdl_if_case_t -> Ppx_deriving_runtime.unit =
2874
  let __1 () = pp_vhdl_sequential_stmt_t
2875
  
2876
  and __0 () = pp_vhdl_expr_t
2877
   in
2878
  ((let open! Ppx_deriving_runtime in
2879
      fun fmt  ->
2880
        fun x  ->
2881
          Format.fprintf fmt " (";
2882
          ((__0 ()) fmt) x.if_cond;
2883
          Format.fprintf fmt ") then@;<0 2>";
2884
          ((fun x  ->
2885
             ignore
2886
               (List.fold_left
2887
                  (fun sep  ->
2888
                     fun x  ->
2889
                             if sep then Format.fprintf fmt "@;<0 2>";
2890
                       ((__1 ()) fmt) x;
2891
                       true) false x);
2892
          )) x.if_block;)
2893
    [@ocaml.warning "-A"])
2894

    
2895
and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string =
2896
  fun x  -> Format.asprintf "%a" pp_vhdl_if_case_t x
2897

    
2898
and pp_vhdl_case_item_t :
2899
  Format.formatter -> vhdl_case_item_t -> Ppx_deriving_runtime.unit =
2900
  let __1 () = pp_vhdl_sequential_stmt_t
2901
  
2902
  and __0 () = pp_vhdl_expr_t
2903
   in
2904
  ((let open! Ppx_deriving_runtime in
2905
      fun fmt  ->
2906
        fun x  ->
2907
                Format.fprintf fmt "@;<0 2>when ";
2908
            ((fun x  ->
2909
                ignore
2910
                  (List.fold_left
2911
                     (fun sep  ->
2912
                        fun x  ->
2913
                          if sep then Format.fprintf fmt "@ |@ ";
2914
                          ((__0 ()) fmt) x;
2915
                          true) false x);)) x.when_cond;
2916
           Format.fprintf fmt " => ";
2917
           ((fun x  ->
2918
               ignore
2919
                 (List.fold_left
2920
                    (fun sep  ->
2921
                       fun x  ->
2922
                         if sep then Format.fprintf fmt "";
2923
                         ((__1 ()) fmt) x;
2924
                         true) false x);)) x.when_stmt)
2925
    [@ocaml.warning "-A"])
2926

    
2927
and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string =
2928
  fun x  -> Format.asprintf "%a" pp_vhdl_case_item_t x
2929

    
2930
let rec (vhdl_sequential_stmt_t_to_yojson :
2931
          vhdl_sequential_stmt_t -> Yojson.Safe.json)
2932
  =
2933
  ((let open! Ppx_deriving_yojson_runtime in
2934
      function
2935
      | VarAssign arg0 ->
2936
          `List
2937
            [`String "VARIABLE_ASSIGNMENT_STATEMENT";
2938
            (let fields = []  in
2939
             let fields =
2940
               ("rhs", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.rhs)) ::
2941
               fields  in
2942
             let fields =
2943
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
2944
               fields  in
2945
             let fields =
2946
               if arg0.label = NoName
2947
               then fields
2948
               else
2949
                 ("label",
2950
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
2951
                 :: fields
2952
                in
2953
             `Assoc fields)]
2954
      | SigSeqAssign arg0 ->
2955
          `List
2956
            [`String "SIGNAL_ASSIGNMENT_STATEMENT";
2957
            (let fields = []  in
2958
             let fields =
2959
               ("rhs",
2960
                 ((fun x  ->
2961
                     `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
2962
                    arg0.rhs))
2963
               :: fields  in
2964
             let fields =
2965
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
2966
               fields  in
2967
             let fields =
2968
               if arg0.label = NoName
2969
               then fields
2970
               else
2971
                 ("label",
2972
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
2973
                 :: fields
2974
                in
2975
             `Assoc fields)]
2976
      | If arg0 ->
2977
          `List
2978
            [`String "IF_STATEMENT";
2979
            (let fields = []  in
2980
             let fields =
2981
               if arg0.default = []
2982
               then fields
2983
               else
2984
                 ("default",
2985
                   (((fun x  ->
2986
                        `List
2987
                          (List.map
2988
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
2989
                      arg0.default))
2990
                 :: fields
2991
                in
2992
             let fields =
2993
               ("if_cases",
2994
                 ((fun x  ->
2995
                     `List
2996
                       (List.map (fun x  -> vhdl_if_case_t_to_yojson x) x))
2997
                    arg0.if_cases))
2998
               :: fields  in
2999
             let fields =
3000
               if arg0.label = NoName
3001
               then fields
3002
               else
3003
                 ("label",
3004
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3005
                 :: fields
3006
                in
3007
             `Assoc fields)]
3008
      | Case arg0 ->
3009
          `List
3010
            [`String "CASE_STATEMENT_TREE";
3011
            (let fields = []  in
3012
             let fields =
3013
               ("branches",
3014
                 ((fun x  ->
3015
                     `List
3016
                       (List.map (fun x  -> vhdl_case_item_t_to_yojson x) x))
3017
                    arg0.branches))
3018
               :: fields  in
3019
             let fields =
3020
               ("guard", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.guard)) ::
3021
               fields  in
3022
             let fields =
3023
               if arg0.label = NoName
3024
               then fields
3025
               else
3026
                 ("label",
3027
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3028
                 :: fields
3029
                in
3030
             `Assoc fields)]
3031
      | Exit arg0 ->
3032
          `List
3033
            [`String "EXIT_STATEMENT";
3034
            (let fields = []  in
3035
             let fields =
3036
               if arg0.condition = (Some IsNull)
3037
               then fields
3038
               else
3039
                 ("condition",
3040
                   (((function
3041
                      | None  -> `Null
3042
                      | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
3043
                      arg0.condition))
3044
                 :: fields
3045
                in
3046
             let fields =
3047
               if arg0.loop_label = (Some "")
3048
               then fields
3049
               else
3050
                 ("loop_label",
3051
                   (((function
3052
                      | None  -> `Null
3053
                      | Some x ->
3054
                          ((fun (x : Ppx_deriving_runtime.string)  ->
3055
                              `String x)) x)) arg0.loop_label))
3056
                 :: fields
3057
                in
3058
             let fields =
3059
               if arg0.label = NoName
3060
               then fields
3061
               else
3062
                 ("label",
3063
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3064
                 :: fields
3065
                in
3066
             `Assoc fields)]
3067
      | Assert arg0 ->
3068
          `List
3069
            [`String "ASSERTION_STATEMENT";
3070
            (let fields = []  in
3071
             let fields =
3072
               if arg0.severity = IsNull
3073
               then fields
3074
               else
3075
                 ("severity",
3076
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.severity))
3077
                 :: fields
3078
                in
3079
             let fields =
3080
               if arg0.report = IsNull
3081
               then fields
3082
               else
3083
                 ("report",
3084
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.report))
3085
                 :: fields
3086
                in
3087
             let fields =
3088
               ("cond", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.cond)) ::
3089
               fields  in
3090
             let fields =
3091
               if arg0.label = NoName
3092
               then fields
3093
               else
3094
                 ("label",
3095
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3096
                 :: fields
3097
                in
3098
             `Assoc fields)]
3099
      | ProcedureCall arg0 ->
3100
          `List
3101
            [`String "PROCEDURE_CALL_STATEMENT";
3102
            (let fields = []  in
3103
             let fields =
3104
               ("assocs",
3105
                 ((fun x  ->
3106
                     `List
3107
                       (List.map (fun x  -> vhdl_assoc_element_t_to_yojson x)
3108
                          x)) arg0.assocs))
3109
               :: fields  in
3110
             let fields =
3111
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
3112
               fields  in
3113
             let fields =
3114
               if arg0.label = NoName
3115
               then fields
3116
               else
3117
                 ("label",
3118
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3119
                 :: fields
3120
                in
3121
             `Assoc fields)]
3122
      | Wait  -> `List [`String "WAIT_STATEMENT"]
3123
      | Null arg0 ->
3124
          `List
3125
            [`String "NULL_STATEMENT";
3126
            (let fields = []  in
3127
             let fields =
3128
               if arg0.label = NoName
3129
               then fields
3130
               else
3131
                 ("label",
3132
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3133
                 :: fields
3134
                in
3135
             `Assoc fields)]
3136
      | Return arg0 ->
3137
          `List
3138
            [`String "RETURN_STATEMENT";
3139
            (let fields = []  in
3140
             let fields =
3141
               if arg0.label = NoName
3142
               then fields
3143
               else
3144
                 ("label",
3145
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3146
                 :: fields
3147
                in
3148
             `Assoc fields)])
3149
  [@ocaml.warning "-A"])
3150

    
3151
and (vhdl_sequential_stmt_t_of_yojson :
3152
      Yojson.Safe.json ->
3153
        vhdl_sequential_stmt_t Ppx_deriving_yojson_runtime.error_or)
3154
  =
3155
  ((let open! Ppx_deriving_yojson_runtime in
3156
      function
3157
      | `List ((`String "VARIABLE_ASSIGNMENT_STATEMENT")::arg0::[]) ->
3158
          ((function
3159
            | `Assoc xs ->
3160
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3161
                  match xs with
3162
                  | ("label",x)::xs ->
3163
                      loop xs
3164
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3165
                  | ("lhs",x)::xs ->
3166
                      loop xs
3167
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3168
                  | ("rhs",x)::xs ->
3169
                      loop xs
3170
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
3171
                  | [] ->
3172
                      arg2 >>=
3173
                        ((fun arg2  ->
3174
                            arg1 >>=
3175
                              (fun arg1  ->
3176
                                 arg0 >>=
3177
                                   (fun arg0  ->
3178
                                      Result.Ok
3179
                                        (VarAssign
3180
                                           {
3181
                                             label = arg0;
3182
                                             lhs = arg1;
3183
                                             rhs = arg2
3184
                                           })))))
3185
                  | _::xs -> loop xs _state  in
3186
                loop xs
3187
                  ((Result.Ok NoName),
3188
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
3189
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
3190
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3191
      | `List ((`String "SIGNAL_ASSIGNMENT_STATEMENT")::arg0::[]) ->
3192
          ((function
3193
            | `Assoc xs ->
3194
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3195
                  match xs with
3196
                  | ("label",x)::xs ->
3197
                      loop xs
3198
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3199
                  | ("lhs",x)::xs ->
3200
                      loop xs
3201
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3202
                  | ("rhs",x)::xs ->
3203
                      loop xs
3204
                        (arg0, arg1,
3205
                          ((function
3206
                            | `List xs ->
3207
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
3208
                                  [] xs
3209
                            | _ ->
3210
                                Result.Error
3211
                                  "Vhdl_ast.vhdl_sequential_stmt_t.rhs") x))
3212
                  | [] ->
3213
                      arg2 >>=
3214
                        ((fun arg2  ->
3215
                            arg1 >>=
3216
                              (fun arg1  ->
3217
                                 arg0 >>=
3218
                                   (fun arg0  ->
3219
                                      Result.Ok
3220
                                        (SigSeqAssign
3221
                                           {
3222
                                             label = arg0;
3223
                                             lhs = arg1;
3224
                                             rhs = arg2
3225
                                           })))))
3226
                  | _::xs -> loop xs _state  in
3227
                loop xs
3228
                  ((Result.Ok NoName),
3229
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
3230
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
3231
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3232
      | `List ((`String "IF_STATEMENT")::arg0::[]) ->
3233
          ((function
3234
            | `Assoc xs ->
3235
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3236
                  match xs with
3237
                  | ("label",x)::xs ->
3238
                      loop xs
3239
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3240
                  | ("if_cases",x)::xs ->
3241
                      loop xs
3242
                        (arg0,
3243
                          ((function
3244
                            | `List xs ->
3245
                                map_bind
3246
                                  (fun x  -> vhdl_if_case_t_of_yojson x) []
3247
                                  xs
3248
                            | _ ->
3249
                                Result.Error
3250
                                  "Vhdl_ast.vhdl_sequential_stmt_t.if_cases")
3251
                             x), arg2)
3252
                  | ("default",x)::xs ->
3253
                      loop xs
3254
                        (arg0, arg1,
3255
                          ((function
3256
                            | `List xs ->
3257
                                map_bind
3258
                                  (fun x  ->
3259
                                     vhdl_sequential_stmt_t_of_yojson x) []
3260
                                  xs
3261
                            | _ ->
3262
                                Result.Error
3263
                                  "Vhdl_ast.vhdl_sequential_stmt_t.default")
3264
                             x))
3265
                  | [] ->
3266
                      arg2 >>=
3267
                        ((fun arg2  ->
3268
                            arg1 >>=
3269
                              (fun arg1  ->
3270
                                 arg0 >>=
3271
                                   (fun arg0  ->
3272
                                      Result.Ok
3273
                                        (If
3274
                                           {
3275
                                             label = arg0;
3276
                                             if_cases = arg1;
3277
                                             default = arg2
3278
                                           })))))
3279
                  | _::xs -> loop xs _state  in
3280
                loop xs
3281
                  ((Result.Ok NoName),
3282
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.if_cases"),
3283
                    (Result.Ok []))
3284
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3285
      | `List ((`String "CASE_STATEMENT_TREE")::arg0::[]) ->
3286
          ((function
3287
            | `Assoc xs ->
3288
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3289
                  match xs with
3290
                  | ("label",x)::xs ->
3291
                      loop xs
3292
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3293
                  | ("guard",x)::xs ->
3294
                      loop xs
3295
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
3296
                  | ("branches",x)::xs ->
3297
                      loop xs
3298
                        (arg0, arg1,
3299
                          ((function
3300
                            | `List xs ->
3301
                                map_bind
3302
                                  (fun x  -> vhdl_case_item_t_of_yojson x) []
3303
                                  xs
3304
                            | _ ->
3305
                                Result.Error
3306
                                  "Vhdl_ast.vhdl_sequential_stmt_t.branches")
3307
                             x))
3308
                  | [] ->
3309
                      arg2 >>=
3310
                        ((fun arg2  ->
3311
                            arg1 >>=
3312
                              (fun arg1  ->
3313
                                 arg0 >>=
3314
                                   (fun arg0  ->
3315
                                      Result.Ok
3316
                                        (Case
3317
                                           {
3318
                                             label = arg0;
3319
                                             guard = arg1;
3320
                                             branches = arg2
3321
                                           })))))
3322
                  | _::xs -> loop xs _state  in
3323
                loop xs
3324
                  ((Result.Ok NoName),
3325
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.guard"),
3326
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.branches"))
3327
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3328
      | `List ((`String "EXIT_STATEMENT")::arg0::[]) ->
3329
          ((function
3330
            | `Assoc xs ->
3331
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3332
                  match xs with
3333
                  | ("label",x)::xs ->
3334
                      loop xs
3335
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3336
                  | ("loop_label",x)::xs ->
3337
                      loop xs
3338
                        (arg0,
3339
                          ((function
3340
                            | `Null -> Result.Ok None
3341
                            | x ->
3342
                                ((function
3343
                                  | `String x -> Result.Ok x
3344
                                  | _ ->
3345
                                      Result.Error
3346
                                        "Vhdl_ast.vhdl_sequential_stmt_t.loop_label")
3347
                                   x)
3348
                                  >>= ((fun x  -> Result.Ok (Some x)))) x),
3349
                          arg2)
3350
                  | ("condition",x)::xs ->
3351
                      loop xs
3352
                        (arg0, arg1,
3353
                          ((function
3354
                            | `Null -> Result.Ok None
3355
                            | x ->
3356
                                ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
3357
                                  ((fun x  -> Result.Ok (Some x)))) x))
3358
                  | [] ->
3359
                      arg2 >>=
3360
                        ((fun arg2  ->
3361
                            arg1 >>=
3362
                              (fun arg1  ->
3363
                                 arg0 >>=
3364
                                   (fun arg0  ->
3365
                                      Result.Ok
3366
                                        (Exit
3367
                                           {
3368
                                             label = arg0;
3369
                                             loop_label = arg1;
3370
                                             condition = arg2
3371
                                           })))))
3372
                  | _::xs -> loop xs _state  in
3373
                loop xs
3374
                  ((Result.Ok NoName), (Result.Ok (Some "")),
3375
                    (Result.Ok (Some IsNull)))
3376
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3377
      | `List ((`String "ASSERTION_STATEMENT")::arg0::[]) ->
3378
          ((function
3379
            | `Assoc xs ->
3380
                let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
3381
                  match xs with
3382
                  | ("label",x)::xs ->
3383
                      loop xs
3384
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2,
3385
                          arg3)
3386
                  | ("cond",x)::xs ->
3387
                      loop xs
3388
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2,
3389
                          arg3)
3390
                  | ("report",x)::xs ->
3391
                      loop xs
3392
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x),
3393
                          arg3)
3394
                  | ("severity",x)::xs ->
3395
                      loop xs
3396
                        (arg0, arg1, arg2,
3397
                          ((fun x  -> vhdl_expr_t_of_yojson x) x))
3398
                  | [] ->
3399
                      arg3 >>=
3400
                        ((fun arg3  ->
3401
                            arg2 >>=
3402
                              (fun arg2  ->
3403
                                 arg1 >>=
3404
                                   (fun arg1  ->
3405
                                      arg0 >>=
3406
                                        (fun arg0  ->
3407
                                           Result.Ok
3408
                                             (Assert
3409
                                                {
3410
                                                  label = arg0;
3411
                                                  cond = arg1;
3412
                                                  report = arg2;
3413
                                                  severity = arg3
3414
                                                }))))))
3415
                  | _::xs -> loop xs _state  in
3416
                loop xs
3417
                  ((Result.Ok NoName),
3418
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.cond"),
3419
                    (Result.Ok IsNull), (Result.Ok IsNull))
3420
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3421
      | `List ((`String "PROCEDURE_CALL_STATEMENT")::arg0::[]) ->
3422
          ((function
3423
            | `Assoc xs ->
3424
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3425
                  match xs with
3426
                  | ("label",x)::xs ->
3427
                      loop xs
3428
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3429
                  | ("name",x)::xs ->
3430
                      loop xs
3431
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3432
                  | ("assocs",x)::xs ->
3433
                      loop xs
3434
                        (arg0, arg1,
3435
                          ((function
3436
                            | `List xs ->
3437
                                map_bind
3438
                                  (fun x  -> vhdl_assoc_element_t_of_yojson x)
3439
                                  [] xs
3440
                            | _ ->
3441
                                Result.Error
3442
                                  "Vhdl_ast.vhdl_sequential_stmt_t.assocs") x))
3443
                  | [] ->
3444
                      arg2 >>=
3445
                        ((fun arg2  ->
3446
                            arg1 >>=
3447
                              (fun arg1  ->
3448
                                 arg0 >>=
3449
                                   (fun arg0  ->
3450
                                      Result.Ok
3451
                                        (ProcedureCall
3452
                                           {
3453
                                             label = arg0;
3454
                                             name = arg1;
3455
                                             assocs = arg2
3456
                                           })))))
3457
                  | _::xs -> loop xs _state  in
3458
                loop xs
3459
                  ((Result.Ok NoName),
3460
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.name"),
3461
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.assocs"))
3462
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3463
      | `List ((`String "WAIT_STATEMENT")::[]) -> Result.Ok Wait
3464
      | `List ((`String "NULL_STATEMENT")::arg0::[]) ->
3465
          ((function
3466
            | `Assoc xs ->
3467
                let rec loop xs (arg0 as _state) =
3468
                  match xs with
3469
                  | ("label",x)::xs ->
3470
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
3471
                  | [] ->
3472
                      arg0 >>=
3473
                        ((fun arg0  -> Result.Ok (Null { label = arg0 })))
3474
                  | _::xs -> loop xs _state  in
3475
                loop xs (Result.Ok NoName)
3476
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3477
      | `List ((`String "RETURN_STATEMENT")::arg0::[]) ->
3478
          ((function
3479
            | `Assoc xs ->
3480
                let rec loop xs (arg0 as _state) =
3481
                  match xs with
3482
                  | ("label",x)::xs ->
3483
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
3484
                  | [] ->
3485
                      arg0 >>=
3486
                        ((fun arg0  -> Result.Ok (Return { label = arg0 })))
3487
                  | _::xs -> loop xs _state  in
3488
                loop xs (Result.Ok NoName)
3489
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3490
      | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")
3491
  [@ocaml.warning "-A"])
3492

    
3493
and (vhdl_if_case_t_to_yojson : vhdl_if_case_t -> Yojson.Safe.json) =
3494
  ((let open! Ppx_deriving_yojson_runtime in
3495
      fun x  ->
3496
        let fields = []  in
3497
        let fields =
3498
          ("if_block",
3499
            ((fun x  ->
3500
                `List
3501
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3502
               x.if_block))
3503
          :: fields  in
3504
        let fields =
3505
          ("if_cond", ((fun x  -> vhdl_expr_t_to_yojson x) x.if_cond)) ::
3506
          fields  in
3507
        `Assoc fields)
3508
  [@ocaml.warning "-A"])
3509

    
3510
and (vhdl_if_case_t_of_yojson :
3511
      Yojson.Safe.json -> vhdl_if_case_t Ppx_deriving_yojson_runtime.error_or)
3512
  =
3513
  ((let open! Ppx_deriving_yojson_runtime in
3514
      function
3515
      | `Assoc xs ->
3516
          let rec loop xs ((arg0,arg1) as _state) =
3517
            match xs with
3518
            | ("if_cond",x)::xs ->
3519
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
3520
            | ("if_block",x)::xs ->
3521
                loop xs
3522
                  (arg0,
3523
                    ((function
3524
                      | `List xs ->
3525
                          map_bind
3526
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3527
                            xs
3528
                      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t.if_block")
3529
                       x))
3530
            | [] ->
3531
                arg1 >>=
3532
                  ((fun arg1  ->
3533
                      arg0 >>=
3534
                        (fun arg0  ->
3535
                           Result.Ok { if_cond = arg0; if_block = arg1 })))
3536
            | _::xs -> loop xs _state  in
3537
          loop xs
3538
            ((Result.Error "Vhdl_ast.vhdl_if_case_t.if_cond"),
3539
              (Result.Error "Vhdl_ast.vhdl_if_case_t.if_block"))
3540
      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t")
3541
  [@ocaml.warning "-A"])
3542

    
3543
and (vhdl_case_item_t_to_yojson : vhdl_case_item_t -> Yojson.Safe.json) =
3544
  ((let open! Ppx_deriving_yojson_runtime in
3545
      fun x  ->
3546
        let fields = []  in
3547
        let fields =
3548
          ("when_stmt",
3549
            ((fun x  ->
3550
                `List
3551
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3552
               x.when_stmt))
3553
          :: fields  in
3554
        let fields =
3555
          ("when_cond",
3556
            ((fun x  ->
3557
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
3558
               x.when_cond))
3559
          :: fields  in
3560
        `Assoc fields)
3561
  [@ocaml.warning "-A"])
3562

    
3563
and (vhdl_case_item_t_of_yojson :
3564
      Yojson.Safe.json ->
3565
        vhdl_case_item_t Ppx_deriving_yojson_runtime.error_or)
3566
  =
3567
  ((let open! Ppx_deriving_yojson_runtime in
3568
      function
3569
      | `Assoc xs ->
3570
          let rec loop xs ((arg0,arg1) as _state) =
3571
            match xs with
3572
            | ("when_cond",x)::xs ->
3573
                loop xs
3574
                  (((function
3575
                     | `List xs ->
3576
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
3577
                     | _ ->
3578
                         Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond")
3579
                      x), arg1)
3580
            | ("when_stmt",x)::xs ->
3581
                loop xs
3582
                  (arg0,
3583
                    ((function
3584
                      | `List xs ->
3585
                          map_bind
3586
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3587
                            xs
3588
                      | _ ->
3589
                          Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt")
3590
                       x))
3591
            | [] ->
3592
                arg1 >>=
3593
                  ((fun arg1  ->
3594
                      arg0 >>=
3595
                        (fun arg0  ->
3596
                           Result.Ok { when_cond = arg0; when_stmt = arg1 })))
3597
            | _::xs -> loop xs _state  in
3598
          loop xs
3599
            ((Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond"),
3600
              (Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt"))
3601
      | _ -> Result.Error "Vhdl_ast.vhdl_case_item_t")
3602
  [@ocaml.warning "-A"])
3603

    
3604
type vhdl_declaration_t =
3605
  | VarDecl of
3606
  {
3607
  names: vhdl_name_t list ;
3608
  typ: vhdl_subtype_indication_t ;
3609
  init_val: vhdl_expr_t [@default IsNull]} [@name "VARIABLE_DECLARATION"]
3610
  | CstDecl of
3611
  {
3612
  names: vhdl_name_t list ;
3613
  typ: vhdl_subtype_indication_t ;
3614
  init_val: vhdl_expr_t } [@name "CONSTANT_DECLARATION"]
3615
  | SigDecl of
3616
  {
3617
  names: vhdl_name_t list ;
3618
  typ: vhdl_subtype_indication_t ;
3619
  init_val: vhdl_expr_t [@default IsNull]} [@name "SIGNAL_DECLARATION"]
3620
  | Subprogram of
3621
  {
3622
  name: vhdl_name_t [@default NoName];
3623
  kind: string [@default ""];
3624
  spec: vhdl_subprogram_spec_t
3625
    [@default
3626
      { name = ""; typeMark = NoName; parameters = []; isPure = false }];
3627
  decl_part: vhdl_declaration_t list [@default []];
3628
  stmts: vhdl_sequential_stmt_t list [@default []]} [@name "SUBPROGRAM_BODY"]
3629

    
3630
(* Needs adaptation for: SubProgram *)
3631
let rec pp_vhdl_declaration_t :
3632
  Format.formatter -> vhdl_declaration_t -> Ppx_deriving_runtime.unit =
3633
  let __12 () = pp_vhdl_sequential_stmt_t
3634
  
3635
  and __11 () = pp_vhdl_declaration_t
3636
  
3637
  and __10 () = pp_vhdl_subprogram_spec_t
3638
  
3639
  and __9 () = pp_vhdl_name_t
3640
  
3641
  and __8 () = pp_vhdl_expr_t
3642
  
3643
  and __7 () = pp_vhdl_subtype_indication_t
3644
  
3645
  and __6 () = pp_vhdl_name_t
3646
  
3647
  and __5 () = pp_vhdl_expr_t
3648
  
3649
  and __4 () = pp_vhdl_subtype_indication_t
3650
  
3651
  and __3 () = pp_vhdl_name_t
3652
  
3653
  and __2 () = pp_vhdl_expr_t
3654
  
3655
  and __1 () = pp_vhdl_subtype_indication_t
3656
  
3657
  and __0 () = pp_vhdl_name_t
3658
   in
3659
  ((let open! Ppx_deriving_runtime in
3660
      fun fmt  ->
3661
        function
3662
        | VarDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3663
            (Format.fprintf fmt "variable ";
3664
             ((((fun x  ->
3665
                    ignore
3666
                      (List.fold_left
3667
                         (fun sep  ->
3668
                            fun x  ->
3669
                              if sep then Format.fprintf fmt ",";
3670
                              ((__0 ()) fmt) x;
3671
                              true) false x);)) anames;
3672
               Format.fprintf fmt " : ";
3673
               ((__1 ()) fmt) atyp;
3674
               (match ainit_val with
3675
                | IsNull  -> Format.pp_print_string fmt ""
3676
                | _ ->
3677
                    (Format.fprintf fmt ":=";
3678
                     ((__2 ()) fmt) ainit_val;))));)
3679
        | CstDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3680
            (Format.fprintf fmt "constant ";
3681
             ((((fun x  ->
3682
                    ignore
3683
                      (List.fold_left
3684
                         (fun sep  ->
3685
                            fun x  ->
3686
                              if sep then Format.fprintf fmt ",";
3687
                              ((__3 ()) fmt) x;
3688
                              true) false x);)) anames;
3689
               Format.fprintf fmt " : ";
3690
               ((__4 ()) fmt) atyp;
3691
              Format.fprintf fmt ":=";
3692
              ((__5 ()) fmt) ainit_val)))
3693
        | SigDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3694
            (Format.fprintf fmt "signal ";
3695
            ((fun x  ->
3696
              ignore
3697
              (List.fold_left
3698
                (fun sep  ->
3699
                  fun x  ->
3700
                    if sep then Format.fprintf fmt ",";
3701
                                ((__6 ()) fmt) x;
3702
                                true) false x);
3703
              )) anames;
3704
            Format.fprintf fmt " : ";
3705
            ((__7 ()) fmt) atyp;
3706
            (match ainit_val with
3707
              | IsNull  -> Format.pp_print_string fmt ""
3708
              | _ ->
3709
                  (Format.fprintf fmt ":=";
3710
                  ((__8 ()) fmt) ainit_val;)))
3711
        | Subprogram
3712
            { name = aname; kind = akind; spec = aspec;
3713
              decl_part = adecl_part; stmts = astmts }
3714
            ->
3715
            (Format.fprintf fmt "@[<2>Subprogram {@,";
3716
             (((((Format.fprintf fmt "@[%s =@ " "name";
3717
                  ((__9 ()) fmt) aname;
3718
                  Format.fprintf fmt "@]");
3719
                 Format.fprintf fmt ";@ ";
3720
                 Format.fprintf fmt "@[%s =@ " "kind";
3721
                 (Format.fprintf fmt "%S") akind;
3722
                 Format.fprintf fmt "@]");
3723
                Format.fprintf fmt ";@ ";
3724
                Format.fprintf fmt "@[%s =@ " "spec";
3725
                ((__10 ()) fmt) aspec;
3726
                Format.fprintf fmt "@]");
3727
               Format.fprintf fmt ";@ ";
3728
               Format.fprintf fmt "@[%s =@ " "decl_part";
3729
               ((fun x  ->
3730
                   Format.fprintf fmt "@[<2>[";
3731
                   ignore
3732
                     (List.fold_left
3733
                        (fun sep  ->
3734
                           fun x  ->
3735
                             if sep then Format.fprintf fmt ";@ ";
3736
                             ((__11 ()) fmt) x;
3737
                             true) false x);
3738
                   Format.fprintf fmt "@,]@]")) adecl_part;
3739
               Format.fprintf fmt "@]");
3740
              Format.fprintf fmt ";@ ";
3741
              Format.fprintf fmt "@[%s =@ " "stmts";
3742
              ((fun x  ->
3743
                  Format.fprintf fmt "@[<2>[";
3744
                  ignore
3745
                    (List.fold_left
3746
                       (fun sep  ->
3747
                          fun x  ->
3748
                            if sep then Format.fprintf fmt ";@ ";
3749
                            ((__12 ()) fmt) x;
3750
                            true) false x);
3751
                  Format.fprintf fmt "@,]@]")) astmts;
3752
              Format.fprintf fmt "@]");
3753
             Format.fprintf fmt "@]}"))
3754
    [@ocaml.warning "-A"])
3755

    
3756
and show_vhdl_declaration_t :
3757
  vhdl_declaration_t -> Ppx_deriving_runtime.string =
3758
  fun x  -> Format.asprintf "%a" pp_vhdl_declaration_t x
3759

    
3760
let rec (vhdl_declaration_t_to_yojson :
3761
          vhdl_declaration_t -> Yojson.Safe.json)
3762
  =
3763
  ((let open! Ppx_deriving_yojson_runtime in
3764
      function
3765
      | VarDecl arg0 ->
3766
          `List
3767
            [`String "VARIABLE_DECLARATION";
3768
            (let fields = []  in
3769
             let fields =
3770
               if arg0.init_val = IsNull
3771
               then fields
3772
               else
3773
                 ("init_val",
3774
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.init_val))
3775
                 :: fields
3776
                in
3777
             let fields =
3778
               ("typ",
3779
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
3780
               :: fields  in
3781
             let fields =
3782
               ("names",
3783
                 ((fun x  ->
3784
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
3785
                    arg0.names))
3786
               :: fields  in
3787
             `Assoc fields)]
3788
      | CstDecl arg0 ->
3789
          `List
3790
            [`String "CONSTANT_DECLARATION";
3791
            (let fields = []  in
3792
             let fields =
3793
               ("init_val",
3794
                 ((fun x  -> vhdl_expr_t_to_yojson x) arg0.init_val))
3795
               :: fields  in
3796
             let fields =
3797
               ("typ",
3798
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
3799
               :: fields  in
3800
             let fields =
3801
               ("names",
3802
                 ((fun x  ->
3803
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
3804
                    arg0.names))
3805
               :: fields  in
3806
             `Assoc fields)]
3807
      | SigDecl arg0 ->
3808
          `List
3809
            [`String "SIGNAL_DECLARATION";
3810
            (let fields = []  in
3811
             let fields =
3812
               if arg0.init_val = IsNull
3813
               then fields
3814
               else
3815
                 ("init_val",
3816
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.init_val))
3817
                 :: fields
3818
                in
3819
             let fields =
3820
               ("typ",
3821
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
3822
               :: fields  in
3823
             let fields =
3824
               ("names",
3825
                 ((fun x  ->
3826
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
3827
                    arg0.names))
3828
               :: fields  in
3829
             `Assoc fields)]
3830
      | Subprogram arg0 ->
3831
          `List
3832
            [`String "SUBPROGRAM_BODY";
3833
            (let fields = []  in
3834
             let fields =
3835
               if arg0.stmts = []
3836
               then fields
3837
               else
3838
                 ("stmts",
3839
                   (((fun x  ->
3840
                        `List
3841
                          (List.map
3842
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
3843
                      arg0.stmts))
3844
                 :: fields
3845
                in
3846
             let fields =
3847
               if arg0.decl_part = []
3848
               then fields
3849
               else
3850
                 ("decl_part",
3851
                   (((fun x  ->
3852
                        `List
3853
                          (List.map
3854
                             (fun x  -> vhdl_declaration_t_to_yojson x) x)))
3855
                      arg0.decl_part))
3856
                 :: fields
3857
                in
3858
             let fields =
3859
               if
3860
                 arg0.spec =
3861
                   {
3862
                     name = "";
3863
                     typeMark = NoName;
3864
                     parameters = [];
3865
                     isPure = false
3866
                   }
3867
               then fields
3868
               else
3869
                 ("spec",
3870
                   (((fun x  -> vhdl_subprogram_spec_t_to_yojson x))
3871
                      arg0.spec))
3872
                 :: fields
3873
                in
3874
             let fields =
3875
               if arg0.kind = ""
3876
               then fields
3877
               else
3878
                 ("kind",
3879
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
3880
                      arg0.kind))
3881
                 :: fields
3882
                in
3883
             let fields =
3884
               if arg0.name = NoName
3885
               then fields
3886
               else
3887
                 ("name", (((fun x  -> vhdl_name_t_to_yojson x)) arg0.name))
3888
                 :: fields
3889
                in
3890
             `Assoc fields)])
3891
  [@ocaml.warning "-A"])
3892

    
3893
and (vhdl_declaration_t_of_yojson :
3894
      Yojson.Safe.json ->
3895
        vhdl_declaration_t Ppx_deriving_yojson_runtime.error_or)
3896
  =
3897
  ((let open! Ppx_deriving_yojson_runtime in
3898
      function
3899
      | `List ((`String "VARIABLE_DECLARATION")::arg0::[]) ->
3900
          ((function
3901
            | `Assoc xs ->
3902
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3903
                  match xs with
3904
                  | ("names",x)::xs ->
3905
                      loop xs
3906
                        (((function
3907
                           | `List xs ->
3908
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
3909
                                 [] xs
3910
                           | _ ->
3911
                               Result.Error
3912
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
3913
                          arg1, arg2)
3914
                  | ("typ",x)::xs ->
3915
                      loop xs
3916
                        (arg0,
3917
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
3918
                             x), arg2)
3919
                  | ("init_val",x)::xs ->
3920
                      loop xs
3921
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
3922
                  | [] ->
3923
                      arg2 >>=
3924
                        ((fun arg2  ->
3925
                            arg1 >>=
3926
                              (fun arg1  ->
3927
                                 arg0 >>=
3928
                                   (fun arg0  ->
3929
                                      Result.Ok
3930
                                        (VarDecl
3931
                                           {
3932
                                             names = arg0;
3933
                                             typ = arg1;
3934
                                             init_val = arg2
3935
                                           })))))
3936
                  | _::xs -> loop xs _state  in
3937
                loop xs
3938
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
3939
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
3940
                    (Result.Ok IsNull))
3941
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
3942
      | `List ((`String "CONSTANT_DECLARATION")::arg0::[]) ->
3943
          ((function
3944
            | `Assoc xs ->
3945
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3946
                  match xs with
3947
                  | ("names",x)::xs ->
3948
                      loop xs
3949
                        (((function
3950
                           | `List xs ->
3951
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
3952
                                 [] xs
3953
                           | _ ->
3954
                               Result.Error
3955
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
3956
                          arg1, arg2)
3957
                  | ("typ",x)::xs ->
3958
                      loop xs
3959
                        (arg0,
3960
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
3961
                             x), arg2)
3962
                  | ("init_val",x)::xs ->
3963
                      loop xs
3964
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
3965
                  | [] ->
3966
                      arg2 >>=
3967
                        ((fun arg2  ->
3968
                            arg1 >>=
3969
                              (fun arg1  ->
3970
                                 arg0 >>=
3971
                                   (fun arg0  ->
3972
                                      Result.Ok
3973
                                        (CstDecl
3974
                                           {
3975
                                             names = arg0;
3976
                                             typ = arg1;
3977
                                             init_val = arg2
3978
                                           })))))
3979
                  | _::xs -> loop xs _state  in
3980
                loop xs
3981
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
3982
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
3983
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.init_val"))
3984
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
3985
      | `List ((`String "SIGNAL_DECLARATION")::arg0::[]) ->
3986
          ((function
3987
            | `Assoc xs ->
3988
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3989
                  match xs with
3990
                  | ("names",x)::xs ->
3991
                      loop xs
3992
                        (((function
3993
                           | `List xs ->
3994
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
3995
                                 [] xs
3996
                           | _ ->
3997
                               Result.Error
3998
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
3999
                          arg1, arg2)
4000
                  | ("typ",x)::xs ->
4001
                      loop xs
4002
                        (arg0,
4003
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4004
                             x), arg2)
4005
                  | ("init_val",x)::xs ->
4006
                      loop xs
4007
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4008
                  | [] ->
4009
                      arg2 >>=
4010
                        ((fun arg2  ->
4011
                            arg1 >>=
4012
                              (fun arg1  ->
4013
                                 arg0 >>=
4014
                                   (fun arg0  ->
4015
                                      Result.Ok
4016
                                        (SigDecl
4017
                                           {
4018
                                             names = arg0;
4019
                                             typ = arg1;
4020
                                             init_val = arg2
4021
                                           })))))
4022
                  | _::xs -> loop xs _state  in
4023
                loop xs
4024
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4025
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4026
                    (Result.Ok IsNull))
4027
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4028
      | `List ((`String "SUBPROGRAM_BODY")::arg0::[]) ->
4029
          ((function
4030
            | `Assoc xs ->
4031
                let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
4032
                  match xs with
4033
                  | ("name",x)::xs ->
4034
                      loop xs
4035
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2,
4036
                          arg3, arg4)
4037
                  | ("kind",x)::xs ->
4038
                      loop xs
4039
                        (arg0,
4040
                          ((function
4041
                            | `String x -> Result.Ok x
4042
                            | _ ->
4043
                                Result.Error
4044
                                  "Vhdl_ast.vhdl_declaration_t.kind") x),
4045
                          arg2, arg3, arg4)
4046
                  | ("spec",x)::xs ->
4047
                      loop xs
4048
                        (arg0, arg1,
4049
                          ((fun x  -> vhdl_subprogram_spec_t_of_yojson x) x),
4050
                          arg3, arg4)
4051
                  | ("decl_part",x)::xs ->
4052
                      loop xs
4053
                        (arg0, arg1, arg2,
4054
                          ((function
4055
                            | `List xs ->
4056
                                map_bind
4057
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4058
                                  [] xs
4059
                            | _ ->
4060
                                Result.Error
4061
                                  "Vhdl_ast.vhdl_declaration_t.decl_part") x),
4062
                          arg4)
4063
                  | ("stmts",x)::xs ->
4064
                      loop xs
4065
                        (arg0, arg1, arg2, arg3,
4066
                          ((function
4067
                            | `List xs ->
4068
                                map_bind
4069
                                  (fun x  ->
4070
                                     vhdl_sequential_stmt_t_of_yojson x) []
4071
                                  xs
4072
                            | _ ->
4073
                                Result.Error
4074
                                  "Vhdl_ast.vhdl_declaration_t.stmts") x))
4075
                  | [] ->
4076
                      arg4 >>=
4077
                        ((fun arg4  ->
4078
                            arg3 >>=
4079
                              (fun arg3  ->
4080
                                 arg2 >>=
4081
                                   (fun arg2  ->
4082
                                      arg1 >>=
4083
                                        (fun arg1  ->
4084
                                           arg0 >>=
4085
                                             (fun arg0  ->
4086
                                                Result.Ok
4087
                                                  (Subprogram
4088
                                                     {
4089
                                                       name = arg0;
4090
                                                       kind = arg1;
4091
                                                       spec = arg2;
4092
                                                       decl_part = arg3;
4093
                                                       stmts = arg4
4094
                                                     })))))))
4095
                  | _::xs -> loop xs _state  in
4096
                loop xs
4097
                  ((Result.Ok NoName), (Result.Ok ""),
4098
                    (Result.Ok
4099
                       {
4100
                         name = "";
4101
                         typeMark = NoName;
4102
                         parameters = [];
4103
                         isPure = false
4104
                       }), (Result.Ok []), (Result.Ok []))
4105
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4106
      | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")
4107
  [@ocaml.warning "-A"])
4108

    
4109
type vhdl_signal_condition_t =
4110
  {
4111
  expr: vhdl_expr_t list ;
4112
  cond: vhdl_expr_t [@default IsNull]}
4113

    
4114
let rec pp_vhdl_signal_condition_t :
4115
  Format.formatter -> vhdl_signal_condition_t -> Ppx_deriving_runtime.unit =
4116
  let __1 () = pp_vhdl_expr_t
4117
  
4118
  and __0 () = pp_vhdl_expr_t
4119
   in
4120
  ((let open! Ppx_deriving_runtime in
4121
      fun fmt  ->
4122
        fun x  ->
4123
          ((fun x  ->
4124
              ignore
4125
                (List.fold_left
4126
                   (fun sep  ->
4127
                      fun x  ->
4128
                        if sep then Format.fprintf fmt ";@ ";
4129
                        ((__0 ()) fmt) x;
4130
                        true) false x))) x.expr;
4131
          (match x.cond with
4132
          | IsNull -> Format.fprintf fmt "";
4133
          | _ -> Format.fprintf fmt "when ";
4134
                 ((__1 ()) fmt) x.cond);)
4135
    [@ocaml.warning "-A"])
4136

    
4137
and show_vhdl_signal_condition_t :
4138
  vhdl_signal_condition_t -> Ppx_deriving_runtime.string =
4139
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_condition_t x
4140

    
4141
let rec (vhdl_signal_condition_t_to_yojson :
4142
          vhdl_signal_condition_t -> Yojson.Safe.json)
4143
  =
4144
  ((let open! Ppx_deriving_yojson_runtime in
4145
      fun x  ->
4146
        let fields = []  in
4147
        let fields =
4148
          if x.cond = IsNull
4149
          then fields
4150
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4151
            fields
4152
           in
4153
        let fields =
4154
          ("expr",
4155
            ((fun x  ->
4156
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
4157
               x.expr))
4158
          :: fields  in
4159
        `Assoc fields)
4160
  [@ocaml.warning "-A"])
4161

    
4162
and (vhdl_signal_condition_t_of_yojson :
4163
      Yojson.Safe.json ->
4164
        vhdl_signal_condition_t Ppx_deriving_yojson_runtime.error_or)
4165
  =
4166
  ((let open! Ppx_deriving_yojson_runtime in
4167
      function
4168
      | `Assoc xs ->
4169
          let rec loop xs ((arg0,arg1) as _state) =
4170
            match xs with
4171
            | ("expr",x)::xs ->
4172
                loop xs
4173
                  (((function
4174
                     | `List xs ->
4175
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4176
                     | _ ->
4177
                         Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr")
4178
                      x), arg1)
4179
            | ("cond",x)::xs ->
4180
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4181
            | [] ->
4182
                arg1 >>=
4183
                  ((fun arg1  ->
4184
                      arg0 >>=
4185
                        (fun arg0  -> Result.Ok { expr = arg0; cond = arg1 })))
4186
            | _::xs -> loop xs _state  in
4187
          loop xs
4188
            ((Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr"),
4189
              (Result.Ok IsNull))
4190
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_condition_t")
4191
  [@ocaml.warning "-A"])
4192

    
4193
type vhdl_signal_selection_t =
4194
  {
4195
  expr: vhdl_expr_t ;
4196
  when_sel: vhdl_expr_t list [@default []]}
4197

    
4198
(* TODO *)
4199
let rec pp_vhdl_signal_selection_t :
4200
  Format.formatter -> vhdl_signal_selection_t -> Ppx_deriving_runtime.unit =
4201
  let __1 () = pp_vhdl_expr_t
4202
  
4203
  and __0 () = pp_vhdl_expr_t
4204
   in
4205
  ((let open! Ppx_deriving_runtime in
4206
      fun fmt  ->
4207
        fun x  ->
4208
          Format.fprintf fmt "@[<2>{ ";
4209
          ((Format.fprintf fmt "@[%s =@ " "expr";
4210
            ((__0 ()) fmt) x.expr;
4211
            Format.fprintf fmt "@]");
4212
           Format.fprintf fmt ";@ ";
4213
           Format.fprintf fmt "@[%s =@ " "when_sel";
4214
           ((fun x  ->
4215
               Format.fprintf fmt "@[<2>[";
4216
               ignore
4217
                 (List.fold_left
4218
                    (fun sep  ->
4219
                       fun x  ->
4220
                         if sep then Format.fprintf fmt ";@ ";
4221
                         ((__1 ()) fmt) x;
4222
                         true) false x);
4223
               Format.fprintf fmt "@,]@]")) x.when_sel;
4224
           Format.fprintf fmt "@]");
4225
          Format.fprintf fmt "@ }@]")
4226
    [@ocaml.warning "-A"])
4227

    
4228
and show_vhdl_signal_selection_t :
4229
  vhdl_signal_selection_t -> Ppx_deriving_runtime.string =
4230
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_selection_t x
4231

    
4232
let rec (vhdl_signal_selection_t_to_yojson :
4233
          vhdl_signal_selection_t -> Yojson.Safe.json)
4234
  =
4235
  ((let open! Ppx_deriving_yojson_runtime in
4236
      fun x  ->
4237
        let fields = []  in
4238
        let fields =
4239
          if x.when_sel = []
4240
          then fields
4241
          else
4242
            ("when_sel",
4243
              (((fun x  ->
4244
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
4245
                 x.when_sel))
4246
            :: fields
4247
           in
4248
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
4249
          :: fields  in
4250
        `Assoc fields)
4251
  [@ocaml.warning "-A"])
4252

    
4253
and (vhdl_signal_selection_t_of_yojson :
4254
      Yojson.Safe.json ->
4255
        vhdl_signal_selection_t Ppx_deriving_yojson_runtime.error_or)
4256
  =
4257
  ((let open! Ppx_deriving_yojson_runtime in
4258
      function
4259
      | `Assoc xs ->
4260
          let rec loop xs ((arg0,arg1) as _state) =
4261
            match xs with
4262
            | ("expr",x)::xs ->
4263
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
4264
            | ("when_sel",x)::xs ->
4265
                loop xs
4266
                  (arg0,
4267
                    ((function
4268
                      | `List xs ->
4269
                          map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4270
                      | _ ->
4271
                          Result.Error
4272
                            "Vhdl_ast.vhdl_signal_selection_t.when_sel") x))
4273
            | [] ->
4274
                arg1 >>=
4275
                  ((fun arg1  ->
4276
                      arg0 >>=
4277
                        (fun arg0  ->
4278
                           Result.Ok { expr = arg0; when_sel = arg1 })))
4279
            | _::xs -> loop xs _state  in
4280
          loop xs
4281
            ((Result.Error "Vhdl_ast.vhdl_signal_selection_t.expr"),
4282
              (Result.Ok []))
4283
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_selection_t")
4284
  [@ocaml.warning "-A"])
4285

    
4286
type vhdl_conditional_signal_t =
4287
  {
4288
  postponed: bool [@default false];
4289
  label: vhdl_name_t [@default NoName];
4290
  lhs: vhdl_name_t ;
4291
  rhs: vhdl_signal_condition_t list ;
4292
  cond: vhdl_expr_t [@default IsNull];
4293
  delay: vhdl_expr_t [@default IsNull]}
4294

    
4295
let rec pp_vhdl_conditional_signal_t :
4296
  Format.formatter -> vhdl_conditional_signal_t -> Ppx_deriving_runtime.unit
4297
  =
4298
  let __4 () = pp_vhdl_expr_t
4299
  
4300
  and __3 () = pp_vhdl_expr_t
4301
  
4302
  and __2 () = pp_vhdl_signal_condition_t
4303
  
4304
  and __1 () = pp_vhdl_name_t
4305
  
4306
  and __0 () = pp_vhdl_name_t
4307
   in
4308
  ((let open! Ppx_deriving_runtime in
4309
      fun fmt  ->
4310
        fun x  ->
4311
          (match x.label with
4312
            | NoName -> Format.fprintf fmt "";
4313
            | _ -> (((__0 ()) fmt) x.label;
4314
                   Format.fprintf fmt ":@ ")
4315
          );
4316
          if (x.postponed) then Format.fprintf fmt "postponed@ ";
4317
          ((__1 ()) fmt) x.lhs;
4318
          Format.fprintf fmt " <= ";
4319
          (match x.delay with
4320
            | IsNull -> Format.fprintf fmt "";
4321
            | _ -> ((__4 ()) fmt) x.delay;
4322
                   Format.fprintf fmt " ");
4323
          ((fun x  ->
4324
             Format.fprintf fmt "@[";
4325
             ignore
4326
               (List.fold_left
4327
                 (fun sep  ->
4328
                   fun x  ->
4329
                     if sep then Format.fprintf fmt "";
4330
                      ((__2 ()) fmt) x;
4331
                      Format.fprintf fmt ";";
4332
                      true) false x);
4333
          Format.fprintf fmt "@]")) x.rhs;
4334
          (match x.cond with
4335
            | IsNull -> Format.fprintf fmt "";
4336
            | _ -> Format.fprintf fmt "when (";
4337
                   ((__3 ()) fmt) x.cond;
4338
                   Format.fprintf fmt ")"))
4339
   [@ocaml.warning "-A"])
4340

    
4341
and show_vhdl_conditional_signal_t :
4342
  vhdl_conditional_signal_t -> Ppx_deriving_runtime.string =
4343
  fun x  -> Format.asprintf "%a" pp_vhdl_conditional_signal_t x
4344

    
4345
let rec (vhdl_conditional_signal_t_to_yojson :
4346
          vhdl_conditional_signal_t -> Yojson.Safe.json)
4347
  =
4348
  ((let open! Ppx_deriving_yojson_runtime in
4349
      fun x  ->
4350
        let fields = []  in
4351
        let fields =
4352
          if x.delay = IsNull
4353
          then fields
4354
          else ("delay", (((fun x  -> vhdl_expr_t_to_yojson x)) x.delay)) ::
4355
            fields
4356
           in
4357
        let fields =
4358
          if x.cond = IsNull
4359
          then fields
4360
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4361
            fields
4362
           in
4363
        let fields =
4364
          ("rhs",
4365
            ((fun x  ->
4366
                `List
4367
                  (List.map (fun x  -> vhdl_signal_condition_t_to_yojson x) x))
4368
               x.rhs))
4369
          :: fields  in
4370
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4371
          fields  in
4372
        let fields =
4373
          if x.label = NoName
4374
          then fields
4375
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4376
            fields
4377
           in
4378
        let fields =
4379
          if x.postponed = false
4380
          then fields
4381
          else
4382
            ("postponed",
4383
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4384
                 x.postponed))
4385
            :: fields
4386
           in
4387
        `Assoc fields)
4388
  [@ocaml.warning "-A"])
4389

    
4390
and (vhdl_conditional_signal_t_of_yojson :
4391
      Yojson.Safe.json ->
4392
        vhdl_conditional_signal_t Ppx_deriving_yojson_runtime.error_or)
4393
  =
4394
  ((let open! Ppx_deriving_yojson_runtime in
4395
      function
4396
      | `Assoc xs ->
4397
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4398
            match xs with
4399
            | ("postponed",x)::xs ->
4400
                loop xs
4401
                  (((function
4402
                     | `Bool x -> Result.Ok x
4403
                     | _ ->
4404
                         Result.Error
4405
                           "Vhdl_ast.vhdl_conditional_signal_t.postponed") x),
4406
                    arg1, arg2, arg3, arg4, arg5)
4407
            | ("label",x)::xs ->
4408
                loop xs
4409
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4410
                    arg4, arg5)
4411
            | ("lhs",x)::xs ->
4412
                loop xs
4413
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4414
                    arg4, arg5)
4415
            | ("rhs",x)::xs ->
4416
                loop xs
4417
                  (arg0, arg1, arg2,
4418
                    ((function
4419
                      | `List xs ->
4420
                          map_bind
4421
                            (fun x  -> vhdl_signal_condition_t_of_yojson x)
4422
                            [] xs
4423
                      | _ ->
4424
                          Result.Error
4425
                            "Vhdl_ast.vhdl_conditional_signal_t.rhs") x),
4426
                    arg4, arg5)
4427
            | ("cond",x)::xs ->
4428
                loop xs
4429
                  (arg0, arg1, arg2, arg3,
4430
                    ((fun x  -> vhdl_expr_t_of_yojson x) x), arg5)
4431
            | ("delay",x)::xs ->
4432
                loop xs
4433
                  (arg0, arg1, arg2, arg3, arg4,
4434
                    ((fun x  -> vhdl_expr_t_of_yojson x) x))
4435
            | [] ->
4436
                arg5 >>=
4437
                  ((fun arg5  ->
4438
                      arg4 >>=
4439
                        (fun arg4  ->
4440
                           arg3 >>=
4441
                             (fun arg3  ->
4442
                                arg2 >>=
4443
                                  (fun arg2  ->
4444
                                     arg1 >>=
4445
                                       (fun arg1  ->
4446
                                          arg0 >>=
4447
                                            (fun arg0  ->
4448
                                               Result.Ok
4449
                                                 {
4450
                                                   postponed = arg0;
4451
                                                   label = arg1;
4452
                                                   lhs = arg2;
4453
                                                   rhs = arg3;
4454
                                                   cond = arg4;
4455
                                                   delay = arg5
4456
                                                 })))))))
4457
            | _::xs -> loop xs _state  in
4458
          loop xs
4459
            ((Result.Ok false), (Result.Ok NoName),
4460
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.lhs"),
4461
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.rhs"),
4462
              (Result.Ok IsNull), (Result.Ok IsNull))
4463
      | _ -> Result.Error "Vhdl_ast.vhdl_conditional_signal_t")
4464
  [@ocaml.warning "-A"])
4465

    
4466
type vhdl_process_t =
4467
  {
4468
  id: vhdl_name_t [@default NoName];
4469
  declarations: vhdl_declaration_t list option
4470
    [@key "PROCESS_DECLARATIVE_PART"][@default Some []];
4471
  active_sigs: vhdl_name_t list [@default []];
4472
  body: vhdl_sequential_stmt_t list
4473
    [@key "PROCESS_STATEMENT_PART"][@default []]}
4474

    
4475
let rec pp_vhdl_process_t :
4476
  Format.formatter -> vhdl_process_t -> Ppx_deriving_runtime.unit =
4477
  let __3 () = pp_vhdl_sequential_stmt_t
4478
  
4479
  and __2 () = pp_vhdl_name_t
4480
  
4481
  and __1 () = pp_vhdl_declaration_t
4482
  
4483
  and __0 () = pp_vhdl_name_t
4484
   in
4485
  ((let open! Ppx_deriving_runtime in
4486
      fun fmt  ->
4487
        fun x  ->
4488
          Format.fprintf fmt "@[<v>process ";
4489
          (match x.active_sigs with
4490
          | [] -> Format.fprintf fmt "";
4491
          | _ -> Format.fprintf fmt "(";
4492
                 ((fun x  ->
4493
                    ignore
4494
                      (List.fold_left
4495
                         (fun sep  ->
4496
                            fun x  ->
4497
                              if sep then Format.fprintf fmt ",";
4498
                              ((__2 ()) fmt) x;
4499
                              true) false x))) x.active_sigs;
4500
                 Format.fprintf fmt ")");
4501
          ((function
4502
             | None  -> Format.pp_print_string fmt ""
4503
             | Some x ->
4504
                  ((fun x  ->
4505
                      Format.fprintf fmt "@[<2>";
4506
                      ignore
4507
                        (List.fold_left
4508
                           (fun sep  ->
4509
                              fun x  ->
4510
                                if sep then Format.fprintf fmt "@;";
4511
                                ((__1 ()) fmt) x;
4512
                                true) false x);
4513
                      Format.fprintf fmt "@]")) x;)) x.declarations;
4514
          Format.fprintf fmt "@;@[<v 2>begin@;";
4515
          ((fun x  ->
4516
               ignore
4517
                 (List.fold_left
4518
                    (fun sep  ->
4519
                       fun x  ->
4520
                         if sep then Format.fprintf fmt "@;";
4521
                         ((__3 ()) fmt) x;
4522
                         true) false x);)) x.body;
4523
          Format.fprintf fmt "@]@;end process;@;";
4524
          Format.fprintf fmt "@]";)
4525
    [@ocaml.warning "-A"])
4526

    
4527
and show_vhdl_process_t : vhdl_process_t -> Ppx_deriving_runtime.string =
4528
  fun x  -> Format.asprintf "%a" pp_vhdl_process_t x
4529

    
4530
let rec (vhdl_process_t_to_yojson : vhdl_process_t -> Yojson.Safe.json) =
4531
  ((let open! Ppx_deriving_yojson_runtime in
4532
      fun x  ->
4533
        let fields = []  in
4534
        let fields =
4535
          if x.body = []
4536
          then fields
4537
          else
4538
            ("PROCESS_STATEMENT_PART",
4539
              (((fun x  ->
4540
                   `List
4541
                     (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x)
4542
                        x))) x.body))
4543
            :: fields
4544
           in
4545
        let fields =
4546
          if x.active_sigs = []
4547
          then fields
4548
          else
4549
            ("active_sigs",
4550
              (((fun x  ->
4551
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
4552
                 x.active_sigs))
4553
            :: fields
4554
           in
4555
        let fields =
4556
          if x.declarations = (Some [])
4557
          then fields
4558
          else
4559
            ("PROCESS_DECLARATIVE_PART",
4560
              (((function
4561
                 | None  -> `Null
4562
                 | Some x ->
4563
                     ((fun x  ->
4564
                         `List
4565
                           (List.map
4566
                              (fun x  -> vhdl_declaration_t_to_yojson x) x)))
4567
                       x)) x.declarations))
4568
            :: fields
4569
           in
4570
        let fields =
4571
          if x.id = NoName
4572
          then fields
4573
          else ("id", (((fun x  -> vhdl_name_t_to_yojson x)) x.id)) :: fields
4574
           in
4575
        `Assoc fields)
4576
  [@ocaml.warning "-A"])
4577

    
4578
and (vhdl_process_t_of_yojson :
4579
      Yojson.Safe.json -> vhdl_process_t Ppx_deriving_yojson_runtime.error_or)
4580
  =
4581
  ((let open! Ppx_deriving_yojson_runtime in
4582
      function
4583
      | `Assoc xs ->
4584
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
4585
            match xs with
4586
            | ("id",x)::xs ->
4587
                loop xs
4588
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3)
4589
            | ("PROCESS_DECLARATIVE_PART",x)::xs ->
4590
                loop xs
4591
                  (arg0,
4592
                    ((function
4593
                      | `Null -> Result.Ok None
4594
                      | x ->
4595
                          ((function
4596
                            | `List xs ->
4597
                                map_bind
4598
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4599
                                  [] xs
4600
                            | _ ->
4601
                                Result.Error
4602
                                  "Vhdl_ast.vhdl_process_t.declarations") x)
4603
                            >>= ((fun x  -> Result.Ok (Some x)))) x), arg2,
4604
                    arg3)
4605
            | ("active_sigs",x)::xs ->
4606
                loop xs
4607
                  (arg0, arg1,
4608
                    ((function
4609
                      | `List xs ->
4610
                          map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4611
                      | _ ->
4612
                          Result.Error "Vhdl_ast.vhdl_process_t.active_sigs")
4613
                       x), arg3)
4614
            | ("PROCESS_STATEMENT_PART",x)::xs ->
4615
                loop xs
4616
                  (arg0, arg1, arg2,
4617
                    ((function
4618
                      | `List xs ->
4619
                          map_bind
4620
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
4621
                            xs
4622
                      | _ -> Result.Error "Vhdl_ast.vhdl_process_t.body") x))
4623
            | [] ->
4624
                arg3 >>=
4625
                  ((fun arg3  ->
4626
                      arg2 >>=
4627
                        (fun arg2  ->
4628
                           arg1 >>=
4629
                             (fun arg1  ->
4630
                                arg0 >>=
4631
                                  (fun arg0  ->
4632
                                     Result.Ok
4633
                                       {
4634
                                         id = arg0;
4635
                                         declarations = arg1;
4636
                                         active_sigs = arg2;
4637
                                         body = arg3
4638
                                       })))))
4639
            | _::xs -> loop xs _state  in
4640
          loop xs
4641
            ((Result.Ok NoName), (Result.Ok (Some [])), (Result.Ok []),
4642
              (Result.Ok []))
4643
      | _ -> Result.Error "Vhdl_ast.vhdl_process_t")
4644
  [@ocaml.warning "-A"])
4645

    
4646
type vhdl_selected_signal_t =
4647
  {
4648
  postponed: bool [@default false];
4649
  label: vhdl_name_t [@default NoName];
4650
  lhs: vhdl_name_t ;
4651
  sel: vhdl_expr_t ;
4652
  branches: vhdl_signal_selection_t list [@default []];
4653
  delay: vhdl_expr_t option }
4654

    
4655
(* TODO *)
4656
let rec pp_vhdl_selected_signal_t :
4657
  Format.formatter -> vhdl_selected_signal_t -> Ppx_deriving_runtime.unit =
4658
  let __4 () = pp_vhdl_expr_t
4659
  
4660
  and __3 () = pp_vhdl_signal_selection_t
4661
  
4662
  and __2 () = pp_vhdl_expr_t
4663
  
4664
  and __1 () = pp_vhdl_name_t
4665
  
4666
  and __0 () = pp_vhdl_name_t
4667
   in
4668
  ((let open! Ppx_deriving_runtime in
4669
      fun fmt  ->
4670
        fun x  ->
4671
          Format.fprintf fmt "@[<2>{ ";
4672
          ((((((Format.fprintf fmt "@[%s =@ " "postponed";
4673
                (Format.fprintf fmt "%B") x.postponed;
4674
                Format.fprintf fmt "@]");
4675
               Format.fprintf fmt ";@ ";
4676
               Format.fprintf fmt "@[%s =@ " "label";
4677
               ((__0 ()) fmt) x.label;
4678
               Format.fprintf fmt "@]");
4679
              Format.fprintf fmt ";@ ";
4680
              Format.fprintf fmt "@[%s =@ " "lhs";
4681
              ((__1 ()) fmt) x.lhs;
4682
              Format.fprintf fmt "@]");
4683
             Format.fprintf fmt ";@ ";
4684
             Format.fprintf fmt "@[%s =@ " "sel";
4685
             ((__2 ()) fmt) x.sel;
4686
             Format.fprintf fmt "@]");
4687
            Format.fprintf fmt ";@ ";
4688
            Format.fprintf fmt "@[%s =@ " "branches";
4689
            ((fun x  ->
4690
                Format.fprintf fmt "@[<2>[";
4691
                ignore
4692
                  (List.fold_left
4693
                     (fun sep  ->
4694
                        fun x  ->
4695
                          if sep then Format.fprintf fmt ";@ ";
4696
                          ((__3 ()) fmt) x;
4697
                          true) false x);
4698
                Format.fprintf fmt "@,]@]")) x.branches;
4699
            Format.fprintf fmt "@]");
4700
           Format.fprintf fmt ";@ ";
4701
           Format.fprintf fmt "@[%s =@ " "delay";
4702
           ((function
4703
             | None  -> Format.pp_print_string fmt "None"
4704
             | Some x ->
4705
                 (Format.pp_print_string fmt "(Some ";
4706
                  ((__4 ()) fmt) x;
4707
                  Format.pp_print_string fmt ")"))) x.delay;
4708
           Format.fprintf fmt "@]");
4709
          Format.fprintf fmt "@ }@]")
4710
    [@ocaml.warning "-A"])
4711

    
4712
and show_vhdl_selected_signal_t :
4713
  vhdl_selected_signal_t -> Ppx_deriving_runtime.string =
4714
  fun x  -> Format.asprintf "%a" pp_vhdl_selected_signal_t x
4715

    
4716
let rec (vhdl_selected_signal_t_to_yojson :
4717
          vhdl_selected_signal_t -> Yojson.Safe.json)
4718
  =
4719
  ((let open! Ppx_deriving_yojson_runtime in
4720
      fun x  ->
4721
        let fields = []  in
4722
        let fields =
4723
          ("delay",
4724
            ((function
4725
              | None  -> `Null
4726
              | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x) x.delay))
4727
          :: fields  in
4728
        let fields =
4729
          if x.branches = []
4730
          then fields
4731
          else
4732
            ("branches",
4733
              (((fun x  ->
4734
                   `List
4735
                     (List.map
4736
                        (fun x  -> vhdl_signal_selection_t_to_yojson x) x)))
4737
                 x.branches))
4738
            :: fields
4739
           in
4740
        let fields = ("sel", ((fun x  -> vhdl_expr_t_to_yojson x) x.sel)) ::
4741
          fields  in
4742
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4743
          fields  in
4744
        let fields =
4745
          if x.label = NoName
4746
          then fields
4747
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4748
            fields
4749
           in
4750
        let fields =
4751
          if x.postponed = false
4752
          then fields
4753
          else
4754
            ("postponed",
4755
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4756
                 x.postponed))
4757
            :: fields
4758
           in
4759
        `Assoc fields)
4760
  [@ocaml.warning "-A"])
4761

    
4762
and (vhdl_selected_signal_t_of_yojson :
4763
      Yojson.Safe.json ->
4764
        vhdl_selected_signal_t Ppx_deriving_yojson_runtime.error_or)
4765
  =
4766
  ((let open! Ppx_deriving_yojson_runtime in
4767
      function
4768
      | `Assoc xs ->
4769
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4770
            match xs with
4771
            | ("postponed",x)::xs ->
4772
                loop xs
4773
                  (((function
4774
                     | `Bool x -> Result.Ok x
4775
                     | _ ->
4776
                         Result.Error
4777
                           "Vhdl_ast.vhdl_selected_signal_t.postponed") x),
4778
                    arg1, arg2, arg3, arg4, arg5)
4779
            | ("label",x)::xs ->
4780
                loop xs
4781
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4782
                    arg4, arg5)
4783
            | ("lhs",x)::xs ->
4784
                loop xs
4785
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4786
                    arg4, arg5)
4787
            | ("sel",x)::xs ->
4788
                loop xs
4789
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x),
4790
                    arg4, arg5)
4791
            | ("branches",x)::xs ->
4792
                loop xs
4793
                  (arg0, arg1, arg2, arg3,
4794
                    ((function
4795
                      | `List xs ->
4796
                          map_bind
4797
                            (fun x  -> vhdl_signal_selection_t_of_yojson x)
4798
                            [] xs
4799
                      | _ ->
4800
                          Result.Error
4801
                            "Vhdl_ast.vhdl_selected_signal_t.branches") x),
4802
                    arg5)
4803
            | ("delay",x)::xs ->
4804
                loop xs
4805
                  (arg0, arg1, arg2, arg3, arg4,
4806
                    ((function
4807
                      | `Null -> Result.Ok None
4808
                      | x ->
4809
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
4810
                            ((fun x  -> Result.Ok (Some x)))) x))
4811
            | [] ->
4812
                arg5 >>=
4813
                  ((fun arg5  ->
4814
                      arg4 >>=
4815
                        (fun arg4  ->
4816
                           arg3 >>=
4817
                             (fun arg3  ->
4818
                                arg2 >>=
4819
                                  (fun arg2  ->
4820
                                     arg1 >>=
4821
                                       (fun arg1  ->
4822
                                          arg0 >>=
4823
                                            (fun arg0  ->
4824
                                               Result.Ok
4825
                                                 {
4826
                                                   postponed = arg0;
4827
                                                   label = arg1;
4828
                                                   lhs = arg2;
4829
                                                   sel = arg3;
4830
                                                   branches = arg4;
4831
                                                   delay = arg5
4832
                                                 })))))))
4833
            | _::xs -> loop xs _state  in
4834
          loop xs
4835
            ((Result.Ok false), (Result.Ok NoName),
4836
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.lhs"),
4837
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.sel"),
4838
              (Result.Ok []),
4839
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.delay"))
4840
      | _ -> Result.Error "Vhdl_ast.vhdl_selected_signal_t")
4841
  [@ocaml.warning "-A"])
4842

    
4843
type vhdl_component_instantiation_t =
4844
  {
4845
  name: vhdl_name_t ;
4846
  inst_unit: vhdl_name_t ;
4847
  archi_name: vhdl_name_t option [@default None];
4848
  generic_map: vhdl_assoc_element_t option [@default None];
4849
  port_map: vhdl_assoc_element_t option [@default None]}[@@deriving
4850
                                                          ((show
4851
                                                              {
4852
                                                                with_path =
4853
                                                                  false
4854
                                                              }),
4855
                                                            (yojson
4856
                                                               {
4857
                                                                 strict =
4858
                                                                   false
4859
                                                               }))]
4860

    
4861
(* TODO *)
4862
let rec pp_vhdl_component_instantiation_t :
4863
  Format.formatter ->
4864
    vhdl_component_instantiation_t -> Ppx_deriving_runtime.unit
4865
  =
4866
  let __4 () = pp_vhdl_assoc_element_t
4867
  
4868
  and __3 () = pp_vhdl_assoc_element_t
4869
  
4870
  and __2 () = pp_vhdl_name_t
4871
  
4872
  and __1 () = pp_vhdl_name_t
4873
  
4874
  and __0 () = pp_vhdl_name_t
4875
   in
4876
  ((let open! Ppx_deriving_runtime in
4877
      fun fmt  ->
4878
        fun x  ->
4879
          ((__0 ()) fmt) x.name;
4880
          Format.fprintf fmt " : ";
4881
          ((__1 ()) fmt) x.inst_unit;
4882
          ((function
4883
             | None  -> Format.pp_print_string fmt ""
4884
             | Some x ->
4885
                 (Format.pp_print_string fmt "(";
4886
                 ((__2 ()) fmt) x;
4887
                 Format.pp_print_string fmt ")@;"))) x.archi_name;
4888
          ((function
4889
             | None  -> Format.pp_print_string fmt ""
4890
             | Some x ->
4891
                 (Format.pp_print_string fmt "(";
4892
                 ((__3 ()) fmt) x;
4893
                 Format.pp_print_string fmt ")@;"))) x.generic_map;
4894
          ((function
4895
             | None  -> Format.pp_print_string fmt "None"
4896
             | Some x ->
4897
                 (Format.pp_print_string fmt "(";
4898
                 ((__4 ()) fmt) x;
4899
                 Format.pp_print_string fmt ")@;"))) x.port_map;)
4900
    [@ocaml.warning "-A"])
4901

    
4902
and show_vhdl_component_instantiation_t :
4903
  vhdl_component_instantiation_t -> Ppx_deriving_runtime.string =
4904
  fun x  -> Format.asprintf "%a" pp_vhdl_component_instantiation_t x
4905

    
4906
let rec (vhdl_component_instantiation_t_to_yojson :
4907
          vhdl_component_instantiation_t -> Yojson.Safe.json)
4908
  =
4909
  ((let open! Ppx_deriving_yojson_runtime in
4910
      fun x  ->
4911
        let fields = []  in
4912
        let fields =
4913
          if x.port_map = None
4914
          then fields
4915
          else
4916
            ("port_map",
4917
              (((function
4918
                 | None  -> `Null
4919
                 | Some x -> ((fun x  -> vhdl_assoc_element_t_to_yojson x)) x))
4920
                 x.port_map))
4921
            :: fields
4922
           in
4923
        let fields =
4924
          if x.generic_map = None
4925
          then fields
4926
          else
4927
            ("generic_map",
4928
              (((function
4929
                 | None  -> `Null
4930
                 | Some x -> ((fun x  -> vhdl_assoc_element_t_to_yojson x)) x))
4931
                 x.generic_map))
4932
            :: fields
4933
           in
4934
        let fields =
4935
          if x.archi_name = None
4936
          then fields
4937
          else
4938
            ("archi_name",
4939
              (((function
4940
                 | None  -> `Null
4941
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
4942
                 x.archi_name))
4943
            :: fields
4944
           in
4945
        let fields =
4946
          ("inst_unit", ((fun x  -> vhdl_name_t_to_yojson x) x.inst_unit)) ::
4947
          fields  in
4948
        let fields = ("name", ((fun x  -> vhdl_name_t_to_yojson x) x.name))
4949
          :: fields  in
4950
        `Assoc fields)
4951
  [@ocaml.warning "-A"])
4952

    
4953
and (vhdl_component_instantiation_t_of_yojson :
4954
      Yojson.Safe.json ->
4955
        vhdl_component_instantiation_t Ppx_deriving_yojson_runtime.error_or)
4956
  =
4957
  ((let open! Ppx_deriving_yojson_runtime in
4958
      function
4959
      | `Assoc xs ->
4960
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
4961
            match xs with
4962
            | ("name",x)::xs ->
4963
                loop xs
4964
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3,
4965
                    arg4)
4966
            | ("inst_unit",x)::xs ->
4967
                loop xs
4968
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4969
                    arg4)
4970
            | ("archi_name",x)::xs ->
4971
                loop xs
4972
                  (arg0, arg1,
4973
                    ((function
4974
                      | `Null -> Result.Ok None
4975
                      | x ->
4976
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
4977
                            ((fun x  -> Result.Ok (Some x)))) x), arg3, arg4)
4978
            | ("generic_map",x)::xs ->
4979
                loop xs
4980
                  (arg0, arg1, arg2,
4981
                    ((function
4982
                      | `Null -> Result.Ok None
4983
                      | x ->
4984
                          ((fun x  -> vhdl_assoc_element_t_of_yojson x) x)
4985
                            >>= ((fun x  -> Result.Ok (Some x)))) x), arg4)
4986
            | ("port_map",x)::xs ->
4987
                loop xs
4988
                  (arg0, arg1, arg2, arg3,
4989
                    ((function
4990
                      | `Null -> Result.Ok None
4991
                      | x ->
4992
                          ((fun x  -> vhdl_assoc_element_t_of_yojson x) x)
4993
                            >>= ((fun x  -> Result.Ok (Some x)))) x))
4994
            | [] ->
4995
                arg4 >>=
4996
                  ((fun arg4  ->
4997
                      arg3 >>=
4998
                        (fun arg3  ->
4999
                           arg2 >>=
5000
                             (fun arg2  ->
5001
                                arg1 >>=
5002
                                  (fun arg1  ->
5003
                                     arg0 >>=
5004
                                       (fun arg0  ->
5005
                                          Result.Ok
5006
                                            {
5007
                                              name = arg0;
5008
                                              inst_unit = arg1;
5009
                                              archi_name = arg2;
5010
                                              generic_map = arg3;
5011
                                              port_map = arg4
5012
                                            }))))))
5013
            | _::xs -> loop xs _state  in
5014
          loop xs
5015
            ((Result.Error "Vhdl_ast.vhdl_component_instantiation_t.name"),
5016
              (Result.Error
5017
                 "Vhdl_ast.vhdl_component_instantiation_t.inst_unit"),
5018
              (Result.Ok None), (Result.Ok None), (Result.Ok None))
5019
      | _ -> Result.Error "Vhdl_ast.vhdl_component_instantiation_t")
5020
  [@ocaml.warning "-A"])
5021

    
5022
type vhdl_concurrent_stmt_t =
5023
  | SigAssign of vhdl_conditional_signal_t
5024
  [@name "CONDITIONAL_SIGNAL_ASSIGNMENT"]
5025
  | Process of vhdl_process_t [@name "PROCESS_STATEMENT"]
5026
  | SelectedSig of vhdl_selected_signal_t
5027
  [@name "SELECTED_SIGNAL_ASSIGNMENT"]
5028
  | ComponentInst of vhdl_component_instantiation_t
5029
  [@name "COMPONENT_INSTANTIATION_STATEMENT"]
5030

    
5031
let rec pp_vhdl_concurrent_stmt_t :
5032
  Format.formatter -> vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.unit =
5033
  let __3 () = pp_vhdl_component_instantiation_t
5034
  
5035
  and __2 () = pp_vhdl_selected_signal_t
5036
  
5037
  and __1 () = pp_vhdl_process_t
5038
  
5039
  and __0 () = pp_vhdl_conditional_signal_t
5040
   in
5041
  ((let open! Ppx_deriving_runtime in
5042
      fun fmt  ->
5043
        function
5044
        | SigAssign a0 ->
5045
             ((__0 ()) fmt) a0;
5046
        | Process a0 ->
5047
             ((__1 ()) fmt) a0;
5048
        | SelectedSig a0 ->
5049
             ((__2 ()) fmt) a0;
5050
        | ComponentInst a0 ->
5051
             ((__3 ()) fmt) a0;
5052
    )
5053
    [@ocaml.warning "-A"])
5054

    
5055
and show_vhdl_concurrent_stmt_t :
5056
  vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.string =
5057
  fun x  -> Format.asprintf "%a" pp_vhdl_concurrent_stmt_t x
5058

    
5059
let rec (vhdl_concurrent_stmt_t_to_yojson :
5060
          vhdl_concurrent_stmt_t -> Yojson.Safe.json)
5061
  =
5062
  ((let open! Ppx_deriving_yojson_runtime in
5063
      function
5064
      | SigAssign arg0 ->
5065
          `List
5066
            [`String "CONDITIONAL_SIGNAL_ASSIGNMENT";
5067
            ((fun x  -> vhdl_conditional_signal_t_to_yojson x)) arg0]
5068
      | Process arg0 ->
5069
          `List
5070
            [`String "PROCESS_STATEMENT";
5071
            ((fun x  -> vhdl_process_t_to_yojson x)) arg0]
5072
      | SelectedSig arg0 ->
5073
          `List
5074
            [`String "SELECTED_SIGNAL_ASSIGNMENT";
5075
            ((fun x  -> vhdl_selected_signal_t_to_yojson x)) arg0]
5076
      | ComponentInst arg0 ->
5077
          `List
5078
            [`String "COMPONENT_INSTANTIATION_STATEMENT";
5079
            ((fun x  -> vhdl_component_instantiation_t_to_yojson x)) arg0])
5080
  [@ocaml.warning "-A"])
5081

    
5082
and (vhdl_concurrent_stmt_t_of_yojson :
5083
      Yojson.Safe.json ->
5084
        vhdl_concurrent_stmt_t Ppx_deriving_yojson_runtime.error_or)
5085
  =
5086
  ((let open! Ppx_deriving_yojson_runtime in
5087
      function
5088
      | `List ((`String "CONDITIONAL_SIGNAL_ASSIGNMENT")::arg0::[]) ->
5089
          ((fun x  -> vhdl_conditional_signal_t_of_yojson x) arg0) >>=
5090
            ((fun arg0  -> Result.Ok (SigAssign arg0)))
5091
      | `List ((`String "PROCESS_STATEMENT")::arg0::[]) ->
5092
          ((fun x  -> vhdl_process_t_of_yojson x) arg0) >>=
5093
            ((fun arg0  -> Result.Ok (Process arg0)))
5094
      | `List ((`String "SELECTED_SIGNAL_ASSIGNMENT")::arg0::[]) ->
5095
          ((fun x  -> vhdl_selected_signal_t_of_yojson x) arg0) >>=
5096
            ((fun arg0  -> Result.Ok (SelectedSig arg0)))
5097
      | `List ((`String "COMPONENT_INSTANTIATION_STATEMENT")::arg0::[]) ->
5098
          ((fun x  -> vhdl_component_instantiation_t_of_yojson x) arg0) >>=
5099
            ((fun arg0  -> Result.Ok (ComponentInst arg0)))
5100
      | _ -> Result.Error "Vhdl_ast.vhdl_concurrent_stmt_t")
5101
  [@ocaml.warning "-A"])
5102

    
5103
type vhdl_port_mode_t =
5104
  | InPort [@name "in"]
5105
  | OutPort [@name "out"]
5106
  | InoutPort [@name "inout"]
5107
  | BufferPort [@name "buffer"]
5108

    
5109
let rec (pp_vhdl_port_mode_t :
5110
          Format.formatter -> vhdl_port_mode_t -> Ppx_deriving_runtime.unit)
5111
  =
5112
  ((let open! Ppx_deriving_runtime in
5113
      fun fmt  ->
5114
        function
5115
        | InPort  -> Format.pp_print_string fmt "in"
5116
        | OutPort  -> Format.pp_print_string fmt "out"
5117
        | InoutPort  -> Format.pp_print_string fmt "inout"
5118
        | BufferPort  -> Format.pp_print_string fmt "buffer")
5119
  [@ocaml.warning "-A"])
5120

    
5121
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string =
5122
  fun x  -> Format.asprintf "%a" pp_vhdl_port_mode_t x
5123

    
5124
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) =
5125
  ((let open! Ppx_deriving_yojson_runtime in
5126
      function
5127
      | InPort  -> `List [`String "in"]
5128
      | OutPort  -> `List [`String "out"]
5129
      | InoutPort  -> `List [`String "inout"]
5130
      | BufferPort  -> `List [`String "buffer"])
5131
  [@ocaml.warning "-A"])
5132

    
5133
and (vhdl_port_mode_t_of_yojson :
5134
      Yojson.Safe.json ->
5135
        vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or)
5136
  =
5137
  ((let open! Ppx_deriving_yojson_runtime in
5138
      function
5139
      | `List ((`String "in")::[]) -> Result.Ok InPort
5140
      | `List ((`String "out")::[]) -> Result.Ok OutPort
5141
      | `List ((`String "inout")::[]) -> Result.Ok InoutPort
5142
      | `List ((`String "buffer")::[]) -> Result.Ok BufferPort
5143
      | _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t")
5144
  [@ocaml.warning "-A"])
5145

    
5146
type vhdl_port_t =
5147
  {
5148
  names: vhdl_name_t list [@default []];
5149
  mode: vhdl_port_mode_t [@default InPort];
5150
  typ: vhdl_subtype_indication_t ;
5151
  expr: vhdl_expr_t [@default IsNull]}
5152

    
5153
let rec pp_vhdl_port_t :
5154
  Format.formatter -> vhdl_port_t -> Ppx_deriving_runtime.unit =
5155
  let __3 () = pp_vhdl_expr_t
5156
  
5157
  and __2 () = pp_vhdl_subtype_indication_t
5158
  
5159
  and __1 () = pp_vhdl_port_mode_t
5160
  
5161
  and __0 () = pp_vhdl_name_t
5162
   in
5163
  ((let open! Ppx_deriving_runtime in
5164
      fun fmt  ->
5165
        fun x  ->
5166
          Format.fprintf fmt "@[";
5167
          ((((
5168
              ((fun x  ->
5169
                  Format.fprintf fmt "@[";
5170
                  ignore
5171
                    (List.fold_left
5172
                       (fun sep  ->
5173
                          fun x  ->
5174
                            if sep then Format.fprintf fmt ",@ ";
5175
                            ((__0 ()) fmt) x;
5176
                            true) false x);
5177
                  Format.fprintf fmt "@,@]")) x.names;
5178
              );
5179
             Format.fprintf fmt ": ";
5180
             ((__1 ()) fmt) x.mode;
5181
             );
5182
             Format.fprintf fmt " ";
5183
            ((__2 ()) fmt) x.typ;
5184
            );
5185
          (match x.expr with
5186
           | IsNull -> Format.fprintf fmt "";
5187
           | _ -> (Format.fprintf fmt "@[:= ";
5188
                   ((__3 ()) fmt) x.expr;
5189
                   Format.fprintf fmt "@]"));
5190
          Format.fprintf fmt "@]"))
5191
    [@ocaml.warning "-A"])
5192

    
5193
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string =
5194
  fun x  -> Format.asprintf "%a" pp_vhdl_port_t x
5195

    
5196
let rec (vhdl_port_t_to_yojson : vhdl_port_t -> Yojson.Safe.json) =
5197
  ((let open! Ppx_deriving_yojson_runtime in
5198
      fun x  ->
5199
        let fields = []  in
5200
        let fields =
5201
          if x.expr = IsNull
5202
          then fields
5203
          else ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) x.expr)) ::
5204
            fields
5205
           in
5206
        let fields =
5207
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
5208
          :: fields  in
5209
        let fields =
5210
          if x.mode = InPort
5211
          then fields
5212
          else ("mode", (((fun x  -> vhdl_port_mode_t_to_yojson x)) x.mode))
5213
            :: fields
5214
           in
5215
        let fields =
5216
          if x.names = []
5217
          then fields
5218
          else
5219
            ("names",
5220
              (((fun x  ->
5221
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
5222
                 x.names))
5223
            :: fields
5224
           in
5225
        `Assoc fields)
5226
  [@ocaml.warning "-A"])
5227

    
5228
and (vhdl_port_t_of_yojson :
5229
      Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
5230
  =
5231
  ((let open! Ppx_deriving_yojson_runtime in
5232
      function
5233
      | `Assoc xs ->
5234
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
5235
            match xs with
5236
            | ("names",x)::xs ->
5237
                loop xs
5238
                  (((function
5239
                     | `List xs ->
5240
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5241
                     | _ -> Result.Error "Vhdl_ast.vhdl_port_t.names") x),
5242
                    arg1, arg2, arg3)
5243
            | ("mode",x)::xs ->
5244
                loop xs
5245
                  (arg0, ((fun x  -> vhdl_port_mode_t_of_yojson x) x), arg2,
5246
                    arg3)
5247
            | ("typ",x)::xs ->
5248
                loop xs
5249
                  (arg0, arg1,
5250
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
5251
                    arg3)
5252
            | ("expr",x)::xs ->
5253
                loop xs
5254
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x))
5255
            | [] ->
5256
                arg3 >>=
5257
                  ((fun arg3  ->
5258
                      arg2 >>=
5259
                        (fun arg2  ->
5260
                           arg1 >>=
5261
                             (fun arg1  ->
5262
                                arg0 >>=
5263
                                  (fun arg0  ->
5264
                                     Result.Ok
5265
                                       {
5266
                                         names = arg0;
5267
                                         mode = arg1;
5268
                                         typ = arg2;
5269
                                         expr = arg3
5270
                                       })))))
5271
            | _::xs -> loop xs _state  in
5272
          loop xs
5273
            ((Result.Ok []), (Result.Ok InPort),
5274
              (Result.Error "Vhdl_ast.vhdl_port_t.typ"), (Result.Ok IsNull))
5275
      | _ -> Result.Error "Vhdl_ast.vhdl_port_t")
5276
  [@ocaml.warning "-A"])
5277

    
5278
type vhdl_entity_t =
5279
  {
5280
  name: vhdl_name_t [@default NoName];
5281
  generics: vhdl_port_t list [@default []];
5282
  ports: vhdl_port_t list [@default []];
5283
  declaration: vhdl_declaration_t list
5284
    [@key "ENTITY_DECLARATIVE_PART"][@default []];
5285
  stmts: vhdl_concurrent_stmt_t list
5286
    [@key "ENTITY_STATEMENT_PART"][@default []]}
5287

    
5288
let rec pp_vhdl_entity_t :
5289
  Format.formatter -> vhdl_entity_t -> Ppx_deriving_runtime.unit =
5290
  let __4 () = pp_vhdl_concurrent_stmt_t
5291
  
5292
  and __3 () = pp_vhdl_declaration_t
5293
  
5294
  and __2 () = pp_vhdl_port_t
5295
  
5296
  and __1 () = pp_vhdl_port_t
5297
  
5298
  and __0 () = pp_vhdl_name_t
5299
   in
5300
  ((let open! Ppx_deriving_runtime in
5301
      fun fmt  ->
5302
        fun x  ->
5303
          (((((
5304
               ((__0 ()) fmt) x.name;
5305
               Format.fprintf fmt " is@ ");
5306
              Format.fprintf fmt "@[<v>";
5307
              ((fun x  ->
5308
                  ignore
5309
                    (List.fold_left
5310
                       (fun sep  ->
5311
                          fun x  ->
5312
                            if sep then Format.fprintf fmt ";@;";
5313
                            ((__1 ()) fmt) x;
5314
                            true) false x))) x.generics;
5315
              Format.fprintf fmt "@]");
5316
             Format.fprintf fmt "port (@[<v>";
5317
             ((fun x  ->
5318
                 ignore
5319
                   (List.fold_left
5320
                      (fun sep  ->
5321
                         fun x  ->
5322
                           if sep then Format.fprintf fmt ";@;";
5323
                           ((__2 ()) fmt) x;
5324
                           true) false x))) x.ports;
5325
             Format.fprintf fmt "@]);");
5326
            Format.fprintf fmt "@[<v>";
5327
            ((fun x  ->
5328
                Format.fprintf fmt "@[";
5329
                ignore
5330
                  (List.fold_left
5331
                     (fun sep  ->
5332
                        fun x  ->
5333
                          if sep then Format.fprintf fmt ";@ ";
5334
                          ((__3 ()) fmt) x;
5335
                          true) false x);
5336
                Format.fprintf fmt "@]")) x.declaration;
5337
            Format.fprintf fmt "@]");
5338
           Format.fprintf fmt "@[<v>";
5339
           ((fun x  ->
5340
               Format.fprintf fmt "@[";
5341
               ignore
5342
                 (List.fold_left
5343
                    (fun sep  ->
5344
                       fun x  ->
5345
                         if sep then Format.fprintf fmt ";@ ";
5346
                         ((__4 ()) fmt) x;
5347
                         true) false x);
5348
               Format.fprintf fmt "@]")) x.stmts;
5349
           Format.fprintf fmt "@]");
5350
          Format.fprintf fmt "@]")
5351
    [@ocaml.warning "-A"])
5352

    
5353
and show_vhdl_entity_t : vhdl_entity_t -> Ppx_deriving_runtime.string =
5354
  fun x  -> Format.asprintf "%a" pp_vhdl_entity_t x
5355

    
5356
let rec (vhdl_entity_t_to_yojson : vhdl_entity_t -> Yojson.Safe.json) =
5357
  ((let open! Ppx_deriving_yojson_runtime in
5358
      fun x  ->
5359
        let fields = []  in
5360
        let fields =
5361
          if x.stmts = []
5362
          then fields
5363
          else
5364
            ("ENTITY_STATEMENT_PART",
5365
              (((fun x  ->
5366
                   `List
5367
                     (List.map (fun x  -> vhdl_concurrent_stmt_t_to_yojson x)
5368
                        x))) x.stmts))
5369
            :: fields
5370
           in
5371
        let fields =
5372
          if x.declaration = []
5373
          then fields
5374
          else
5375
            ("ENTITY_DECLARATIVE_PART",
5376
              (((fun x  ->
5377
                   `List
5378
                     (List.map (fun x  -> vhdl_declaration_t_to_yojson x) x)))
5379
                 x.declaration))
5380
            :: fields
5381
           in
5382
        let fields =
5383
          if x.ports = []
5384
          then fields
5385
          else
5386
            ("ports",
5387
              (((fun x  ->
5388
                   `List (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
5389
                 x.ports))
5390
            :: fields
5391
           in
5392
        let fields =
5393
          if x.generics = []
5394
          then fields
5395
          else
5396
            ("generics",
5397
              (((fun x  ->
5398
                   `List (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
5399
                 x.generics))
5400
            :: fields
5401
           in
5402
        let fields =
5403
          if x.name = NoName
5404
          then fields
5405
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
5406
            fields
5407
           in
5408
        `Assoc fields)
5409
  [@ocaml.warning "-A"])
5410

    
5411
and (vhdl_entity_t_of_yojson :
5412
      Yojson.Safe.json -> vhdl_entity_t Ppx_deriving_yojson_runtime.error_or)
5413
  =
5414
  ((let open! Ppx_deriving_yojson_runtime in
5415
      function
5416
      | `Assoc xs ->
5417
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
5418
            match xs with
5419
            | ("name",x)::xs ->
5420
                loop xs
5421
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3,
5422
                    arg4)
5423
            | ("generics",x)::xs ->
5424
                loop xs
5425
                  (arg0,
5426
                    ((function
5427
                      | `List xs ->
5428
                          map_bind (fun x  -> vhdl_port_t_of_yojson x) [] xs
5429
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.generics")
5430
                       x), arg2, arg3, arg4)
5431
            | ("ports",x)::xs ->
5432
                loop xs
5433
                  (arg0, arg1,
5434
                    ((function
5435
                      | `List xs ->
5436
                          map_bind (fun x  -> vhdl_port_t_of_yojson x) [] xs
5437
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.ports") x),
5438
                    arg3, arg4)
5439
            | ("ENTITY_DECLARATIVE_PART",x)::xs ->
5440
                loop xs
5441
                  (arg0, arg1, arg2,
5442
                    ((function
5443
                      | `List xs ->
5444
                          map_bind (fun x  -> vhdl_declaration_t_of_yojson x)
5445
                            [] xs
5446
                      | _ ->
5447
                          Result.Error "Vhdl_ast.vhdl_entity_t.declaration")
5448
                       x), arg4)
5449
            | ("ENTITY_STATEMENT_PART",x)::xs ->
5450
                loop xs
5451
                  (arg0, arg1, arg2, arg3,
5452
                    ((function
5453
                      | `List xs ->
5454
                          map_bind
5455
                            (fun x  -> vhdl_concurrent_stmt_t_of_yojson x) []
5456
                            xs
5457
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.stmts") x))
5458
            | [] ->
5459
                arg4 >>=
5460
                  ((fun arg4  ->
5461
                      arg3 >>=
5462
                        (fun arg3  ->
5463
                           arg2 >>=
5464
                             (fun arg2  ->
5465
                                arg1 >>=
5466
                                  (fun arg1  ->
5467
                                     arg0 >>=
5468
                                       (fun arg0  ->
5469
                                          Result.Ok
5470
                                            {
5471
                                              name = arg0;
5472
                                              generics = arg1;
5473
                                              ports = arg2;
5474
                                              declaration = arg3;
5475
                                              stmts = arg4
5476
                                            }))))))
5477
            | _::xs -> loop xs _state  in
5478
          loop xs
5479
            ((Result.Ok NoName), (Result.Ok []), (Result.Ok []),
5480
              (Result.Ok []), (Result.Ok []))
5481
      | _ -> Result.Error "Vhdl_ast.vhdl_enti