Project

General

Profile

Download (215 KB) Statistics
| Branch: | Tag: | Revision:
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
(* Adapted *)
18
let rec (pp_vhdl_cst_val_t :
19
          Format.formatter -> vhdl_cst_val_t -> Ppx_deriving_runtime.unit)
20
  =
21
  ((let open! Ppx_deriving_runtime in
22
      fun fmt  ->
23
        function
24
        | CstInt a0 ->
25
             (Format.fprintf fmt "%d") a0;
26
        | CstStdLogic a0 ->
27
             (Format.fprintf fmt "%S") a0;
28
        | CstLiteral a0 ->
29
             (Format.fprintf fmt "%s") a0;)
30
  [@ocaml.warning "-A"])
31

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

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

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

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

    
177
let rec pp_vhdl_type_t :
178
  Format.formatter -> vhdl_type_t -> Ppx_deriving_runtime.unit =
179
  let __0 () = pp_vhdl_type_t  in
180
  ((let open! Ppx_deriving_runtime in
181
      fun fmt  ->
182
        function
183
        | Base a0 ->
184
             (Format.fprintf fmt "%s") a0;
185
        | Range (a0,a1,a2) ->
186
             ((
187
               (Format.fprintf fmt "%d") a1);
188
               ((function
189
                 | None  -> Format.pp_print_string fmt "None"
190
                 | Some x ->
191
                      (Format.fprintf fmt "%S") x;
192
                      )) a0;
193
              (Format.fprintf fmt "%d") a2);
194
        | Bit_vector (a0,a1) ->
195
             (Format.fprintf fmt "%d .. %d") a0 a1;
196
        | Array (a0,a1,a2) ->
197
             (((__0 ()) fmt) a2;
198
              (Format.fprintf fmt "[%d,%d]") a0 a1);
199
        | Enumerated a0 ->
200
             ((fun x  ->
201
                 Format.fprintf fmt "@[<2>[";
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);
209
                 Format.fprintf fmt "@,]@]")) a0;
210
        | Void  -> Format.pp_print_string fmt "Void")
211
    [@ocaml.warning "-A"])
212

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

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

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

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

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

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

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

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

    
359
and show_vhdl_definition_t : vhdl_definition_t -> Ppx_deriving_runtime.string
360
  = fun x  -> Format.asprintf "%a" pp_vhdl_definition_t x
361

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

    
471
and show_vhdl_expr_t : vhdl_expr_t -> Ppx_deriving_runtime.string =
472
  fun x  -> Format.asprintf "%a" pp_vhdl_expr_t x
473

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

    
559
and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string =
560
  fun x  -> Format.asprintf "%a" pp_vhdl_name_t x
561

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

    
607
and show_vhdl_assoc_element_t :
608
  vhdl_assoc_element_t -> Ppx_deriving_runtime.string =
609
  fun x  -> Format.asprintf "%a" pp_vhdl_assoc_element_t x
610

    
611
and pp_vhdl_element_assoc_t :
612
  Format.formatter -> vhdl_element_assoc_t -> Ppx_deriving_runtime.unit =
613
  let __1 () = pp_vhdl_expr_t
614
  
615
  and __0 () = pp_vhdl_expr_t
616
   in
617
  ((let open! Ppx_deriving_runtime in
618
      fun fmt  ->
619
        fun x  ->
620
          Format.fprintf fmt "@[<2>{ ";
621
          ((Format.fprintf fmt "@[%s =@ " "choices";
622
            ((fun x  ->
623
                Format.fprintf fmt "@[<2>[";
624
                ignore
625
                  (List.fold_left
626
                     (fun sep  ->
627
                        fun x  ->
628
                          if sep then Format.fprintf fmt ";@ ";
629
                          ((__0 ()) fmt) x;
630
                          true) false x);
631
                Format.fprintf fmt "@,]@]")) x.choices;
632
            Format.fprintf fmt "@]");
633
           Format.fprintf fmt ";@ ";
634
           Format.fprintf fmt "@[%s =@ " "expr";
635
           ((__1 ()) fmt) x.expr;
636
           Format.fprintf fmt "@]");
637
          Format.fprintf fmt "@ }@]")
638
    [@ocaml.warning "-A"])
639

    
640
and show_vhdl_element_assoc_t :
641
  vhdl_element_assoc_t -> Ppx_deriving_runtime.string =
642
  fun x  -> Format.asprintf "%a" pp_vhdl_element_assoc_t x
643

    
644
and (pp_vhdl_array_attributes_t :
645
      Format.formatter ->
646
        vhdl_array_attributes_t -> Ppx_deriving_runtime.unit)
647
  =
648
  ((let open! Ppx_deriving_runtime in
649
      fun fmt  ->
650
        function
651
        | AAttInt { id = aid; arg = aarg } ->
652
            (Format.fprintf fmt "@[<2>AAttInt {@,";
653
             ((Format.fprintf fmt "@[%s =@ " "id";
654
               (Format.fprintf fmt "%S") aid;
655
               Format.fprintf fmt "@]");
656
              Format.fprintf fmt ";@ ";
657
              Format.fprintf fmt "@[%s =@ " "arg";
658
              (Format.fprintf fmt "%d") aarg;
659
              Format.fprintf fmt "@]");
660
             Format.fprintf fmt "@]}")
661
        | AAttAscending  -> Format.pp_print_string fmt "AAttAscending")
662
  [@ocaml.warning "-A"])
663

    
664
and show_vhdl_array_attributes_t :
665
  vhdl_array_attributes_t -> Ppx_deriving_runtime.string =
666
  fun x  -> Format.asprintf "%a" pp_vhdl_array_attributes_t x
667

    
668
and (pp_vhdl_signal_attributes_t :
669
      Format.formatter ->
670
        vhdl_signal_attributes_t -> Ppx_deriving_runtime.unit)
671
  =
672
  ((let open! Ppx_deriving_runtime in
673
      fun fmt  ->
674
        function
675
        | SigAtt a0 ->
676
            (Format.fprintf fmt "(@[<2>SigAtt@ ";
677
             (Format.fprintf fmt "%S") a0;
678
             Format.fprintf fmt "@])"))
679
  [@ocaml.warning "-A"])
680

    
681
and show_vhdl_signal_attributes_t :
682
  vhdl_signal_attributes_t -> Ppx_deriving_runtime.string =
683
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_attributes_t x
684

    
685
and (pp_vhdl_string_attributes_t :
686
      Format.formatter ->
687
        vhdl_string_attributes_t -> Ppx_deriving_runtime.unit)
688
  =
689
  ((let open! Ppx_deriving_runtime in
690
      fun fmt  ->
691
        function
692
        | StringAtt a0 ->
693
            (Format.fprintf fmt "(@[<2>StringAtt@ ";
694
             (Format.fprintf fmt "%S") a0;
695
             Format.fprintf fmt "@])"))
696
  [@ocaml.warning "-A"])
697

    
698
and show_vhdl_string_attributes_t :
699
  vhdl_string_attributes_t -> Ppx_deriving_runtime.string =
700
  fun x  -> Format.asprintf "%a" pp_vhdl_string_attributes_t x
701

    
702
and (pp_vhdl_suffix_selection_t :
703
      Format.formatter ->
704
        vhdl_suffix_selection_t -> Ppx_deriving_runtime.unit)
705
  =
706
  ((let open! Ppx_deriving_runtime in
707
      fun fmt  ->
708
        function
709
        | Idx a0 ->
710
            (Format.fprintf fmt "(@[<2>Idx@ ";
711
             (Format.fprintf fmt "%d") a0;
712
             Format.fprintf fmt "@])")
713
        | SuffixRange (a0,a1) ->
714
            (Format.fprintf fmt "(@[<2>SuffixRange (@,";
715
             ((Format.fprintf fmt "%d") a0;
716
              Format.fprintf fmt ",@ ";
717
              (Format.fprintf fmt "%d") a1);
718
             Format.fprintf fmt "@,))@]"))
719
  [@ocaml.warning "-A"])
720

    
721
and show_vhdl_suffix_selection_t :
722
  vhdl_suffix_selection_t -> Ppx_deriving_runtime.string =
723
  fun x  -> Format.asprintf "%a" pp_vhdl_suffix_selection_t x
724

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1810
and (vhdl_element_assoc_t_to_yojson :
1811
      vhdl_element_assoc_t -> Yojson.Safe.json)
1812
  =
1813
  ((let open! Ppx_deriving_yojson_runtime in
1814
      fun x  ->
1815
        let fields = []  in
1816
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
1817
          :: fields  in
1818
        let fields =
1819
          ("choices",
1820
            ((fun x  ->
1821
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
1822
               x.choices))
1823
          :: fields  in
1824
        `Assoc fields)
1825
  [@ocaml.warning "-A"])
1826

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

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

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

    
1924
and (vhdl_signal_attributes_t_to_yojson :
1925
      vhdl_signal_attributes_t -> Yojson.Safe.json)
1926
  =
1927
  ((let open! Ppx_deriving_yojson_runtime in
1928
      function
1929
      | SigAtt arg0 ->
1930
          `List
1931
            [`String "SigAtt";
1932
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
1933
  [@ocaml.warning "-A"])
1934

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

    
1949
and (vhdl_string_attributes_t_to_yojson :
1950
      vhdl_string_attributes_t -> Yojson.Safe.json)
1951
  =
1952
  ((let open! Ppx_deriving_yojson_runtime in
1953
      function
1954
      | StringAtt arg0 ->
1955
          `List
1956
            [`String "StringAtt";
1957
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
1958
  [@ocaml.warning "-A"])
1959

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

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

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

    
2014
type 'basetype vhdl_type_attributes_t =
2015
  | TAttNoArg of {
2016
  id: string } 
2017
  | TAttIntArg of {
2018
  id: string ;
2019
  arg: int } 
2020
  | TAttValArg of {
2021
  id: string ;
2022
  arg: 'basetype } 
2023
  | TAttStringArg of {
2024
  id: string ;
2025
  arg: string } 
2026

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

    
2071
and show_vhdl_type_attributes_t  =
2072
  fun poly_basetype  ->
2073
    fun x  ->
2074
      Format.asprintf "%a" (pp_vhdl_type_attributes_t poly_basetype) x
2075

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

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

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

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

    
2330
and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string =
2331
  fun x  -> Format.asprintf "%a" pp_vhdl_parameter_t x
2332

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

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

    
2438
type vhdl_subprogram_spec_t =
2439
  {
2440
  name: string [@default ""];
2441
  typeMark: vhdl_name_t [@default NoName];
2442
  parameters: vhdl_parameter_t list ;
2443
  isPure: bool [@default false]}
2444

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

    
2482
and show_vhdl_subprogram_spec_t :
2483
  vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string =
2484
  fun x  -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x
2485

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

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

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

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

    
2851
and show_vhdl_sequential_stmt_t :
2852
  vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string =
2853
  fun x  -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x
2854

    
2855
(* Adapted *)
2856
and pp_vhdl_if_case_t :
2857
  Format.formatter -> vhdl_if_case_t -> Ppx_deriving_runtime.unit =
2858
  let __1 () = pp_vhdl_sequential_stmt_t
2859
  
2860
  and __0 () = pp_vhdl_expr_t
2861
   in
2862
  ((let open! Ppx_deriving_runtime in
2863
      fun fmt  ->
2864
        fun x  ->
2865
          Format.fprintf fmt " (";
2866
          ((__0 ()) fmt) x.if_cond;
2867
          Format.fprintf fmt ") then@;<0 2>";
2868
          ((fun x  ->
2869
             ignore
2870
               (List.fold_left
2871
                  (fun sep  ->
2872
                     fun x  ->
2873
                             if sep then Format.fprintf fmt "@;<0 2>";
2874
                       ((__1 ()) fmt) x;
2875
                       true) false x);
2876
          )) x.if_block;)
2877
    [@ocaml.warning "-A"])
2878

    
2879
and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string =
2880
  fun x  -> Format.asprintf "%a" pp_vhdl_if_case_t x
2881

    
2882
and pp_vhdl_case_item_t :
2883
  Format.formatter -> vhdl_case_item_t -> Ppx_deriving_runtime.unit =
2884
  let __1 () = pp_vhdl_sequential_stmt_t
2885
  
2886
  and __0 () = pp_vhdl_expr_t
2887
   in
2888
  ((let open! Ppx_deriving_runtime in
2889
      fun fmt  ->
2890
        fun x  ->
2891
                Format.fprintf fmt "@;<0 2>when ";
2892
            ((fun x  ->
2893
                ignore
2894
                  (List.fold_left
2895
                     (fun sep  ->
2896
                        fun x  ->
2897
                          if sep then Format.fprintf fmt "@ |@ ";
2898
                          ((__0 ()) fmt) x;
2899
                          true) false x);)) x.when_cond;
2900
           Format.fprintf fmt " => ";
2901
           ((fun x  ->
2902
               ignore
2903
                 (List.fold_left
2904
                    (fun sep  ->
2905
                       fun x  ->
2906
                         if sep then Format.fprintf fmt "";
2907
                         ((__1 ()) fmt) x;
2908
                         true) false x);)) x.when_stmt)
2909
    [@ocaml.warning "-A"])
2910

    
2911
and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string =
2912
  fun x  -> Format.asprintf "%a" pp_vhdl_case_item_t x
2913

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

    
3112
and (vhdl_sequential_stmt_t_of_yojson :
3113
      Yojson.Safe.json ->
3114
        vhdl_sequential_stmt_t Ppx_deriving_yojson_runtime.error_or)
3115
  =
3116
  ((let open! Ppx_deriving_yojson_runtime in
3117
      function
3118
      | `List ((`String "VARIABLE_ASSIGNMENT_STATEMENT")::arg0::[]) ->
3119
          ((function
3120
            | `Assoc xs ->
3121
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3122
                  match xs with
3123
                  | ("label",x)::xs ->
3124
                      loop xs
3125
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3126
                  | ("lhs",x)::xs ->
3127
                      loop xs
3128
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3129
                  | ("rhs",x)::xs ->
3130
                      loop xs
3131
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
3132
                  | [] ->
3133
                      arg2 >>=
3134
                        ((fun arg2  ->
3135
                            arg1 >>=
3136
                              (fun arg1  ->
3137
                                 arg0 >>=
3138
                                   (fun arg0  ->
3139
                                      Result.Ok
3140
                                        (VarAssign
3141
                                           {
3142
                                             label = arg0;
3143
                                             lhs = arg1;
3144
                                             rhs = arg2
3145
                                           })))))
3146
                  | _::xs -> loop xs _state  in
3147
                loop xs
3148
                  ((Result.Ok NoName),
3149
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
3150
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
3151
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3152
      | `List ((`String "SIGNAL_ASSIGNMENT_STATEMENT")::arg0::[]) ->
3153
          ((function
3154
            | `Assoc xs ->
3155
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3156
                  match xs with
3157
                  | ("label",x)::xs ->
3158
                      loop xs
3159
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3160
                  | ("lhs",x)::xs ->
3161
                      loop xs
3162
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3163
                  | ("rhs",x)::xs ->
3164
                      loop xs
3165
                        (arg0, arg1,
3166
                          ((function
3167
                            | `List xs ->
3168
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
3169
                                  [] xs
3170
                            | _ ->
3171
                                Result.Error
3172
                                  "Vhdl_ast.vhdl_sequential_stmt_t.rhs") x))
3173
                  | [] ->
3174
                      arg2 >>=
3175
                        ((fun arg2  ->
3176
                            arg1 >>=
3177
                              (fun arg1  ->
3178
                                 arg0 >>=
3179
                                   (fun arg0  ->
3180
                                      Result.Ok
3181
                                        (SigSeqAssign
3182
                                           {
3183
                                             label = arg0;
3184
                                             lhs = arg1;
3185
                                             rhs = arg2
3186
                                           })))))
3187
                  | _::xs -> loop xs _state  in
3188
                loop xs
3189
                  ((Result.Ok NoName),
3190
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
3191
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
3192
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3193
      | `List ((`String "IF_STATEMENT")::arg0::[]) ->
3194
          ((function
3195
            | `Assoc xs ->
3196
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3197
                  match xs with
3198
                  | ("label",x)::xs ->
3199
                      loop xs
3200
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3201
                  | ("if_cases",x)::xs ->
3202
                      loop xs
3203
                        (arg0,
3204
                          ((function
3205
                            | `List xs ->
3206
                                map_bind
3207
                                  (fun x  -> vhdl_if_case_t_of_yojson x) []
3208
                                  xs
3209
                            | _ ->
3210
                                Result.Error
3211
                                  "Vhdl_ast.vhdl_sequential_stmt_t.if_cases")
3212
                             x), arg2)
3213
                  | ("default",x)::xs ->
3214
                      loop xs
3215
                        (arg0, arg1,
3216
                          ((function
3217
                            | `List xs ->
3218
                                map_bind
3219
                                  (fun x  ->
3220
                                     vhdl_sequential_stmt_t_of_yojson x) []
3221
                                  xs
3222
                            | _ ->
3223
                                Result.Error
3224
                                  "Vhdl_ast.vhdl_sequential_stmt_t.default")
3225
                             x))
3226
                  | [] ->
3227
                      arg2 >>=
3228
                        ((fun arg2  ->
3229
                            arg1 >>=
3230
                              (fun arg1  ->
3231
                                 arg0 >>=
3232
                                   (fun arg0  ->
3233
                                      Result.Ok
3234
                                        (If
3235
                                           {
3236
                                             label = arg0;
3237
                                             if_cases = arg1;
3238
                                             default = arg2
3239
                                           })))))
3240
                  | _::xs -> loop xs _state  in
3241
                loop xs
3242
                  ((Result.Ok NoName),
3243
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.if_cases"),
3244
                    (Result.Ok []))
3245
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3246
      | `List ((`String "CASE_STATEMENT_TREE")::arg0::[]) ->
3247
          ((function
3248
            | `Assoc xs ->
3249
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3250
                  match xs with
3251
                  | ("label",x)::xs ->
3252
                      loop xs
3253
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3254
                  | ("guard",x)::xs ->
3255
                      loop xs
3256
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
3257
                  | ("branches",x)::xs ->
3258
                      loop xs
3259
                        (arg0, arg1,
3260
                          ((function
3261
                            | `List xs ->
3262
                                map_bind
3263
                                  (fun x  -> vhdl_case_item_t_of_yojson x) []
3264
                                  xs
3265
                            | _ ->
3266
                                Result.Error
3267
                                  "Vhdl_ast.vhdl_sequential_stmt_t.branches")
3268
                             x))
3269
                  | [] ->
3270
                      arg2 >>=
3271
                        ((fun arg2  ->
3272
                            arg1 >>=
3273
                              (fun arg1  ->
3274
                                 arg0 >>=
3275
                                   (fun arg0  ->
3276
                                      Result.Ok
3277
                                        (Case
3278
                                           {
3279
                                             label = arg0;
3280
                                             guard = arg1;
3281
                                             branches = arg2
3282
                                           })))))
3283
                  | _::xs -> loop xs _state  in
3284
                loop xs
3285
                  ((Result.Ok NoName),
3286
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.guard"),
3287
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.branches"))
3288
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3289
      | `List ((`String "EXIT_STATEMENT")::arg0::[]) ->
3290
          ((function
3291
            | `Assoc xs ->
3292
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3293
                  match xs with
3294
                  | ("label",x)::xs ->
3295
                      loop xs
3296
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3297
                  | ("loop_label",x)::xs ->
3298
                      loop xs
3299
                        (arg0,
3300
                          ((function
3301
                            | `Null -> Result.Ok None
3302
                            | x ->
3303
                                ((function
3304
                                  | `String x -> Result.Ok x
3305
                                  | _ ->
3306
                                      Result.Error
3307
                                        "Vhdl_ast.vhdl_sequential_stmt_t.loop_label")
3308
                                   x)
3309
                                  >>= ((fun x  -> Result.Ok (Some x)))) x),
3310
                          arg2)
3311
                  | ("condition",x)::xs ->
3312
                      loop xs
3313
                        (arg0, arg1,
3314
                          ((function
3315
                            | `Null -> Result.Ok None
3316
                            | x ->
3317
                                ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
3318
                                  ((fun x  -> Result.Ok (Some x)))) x))
3319
                  | [] ->
3320
                      arg2 >>=
3321
                        ((fun arg2  ->
3322
                            arg1 >>=
3323
                              (fun arg1  ->
3324
                                 arg0 >>=
3325
                                   (fun arg0  ->
3326
                                      Result.Ok
3327
                                        (Exit
3328
                                           {
3329
                                             label = arg0;
3330
                                             loop_label = arg1;
3331
                                             condition = arg2
3332
                                           })))))
3333
                  | _::xs -> loop xs _state  in
3334
                loop xs
3335
                  ((Result.Ok NoName), (Result.Ok (Some "")),
3336
                    (Result.Ok (Some IsNull)))
3337
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3338
      | `List ((`String "ASSERTION_STATEMENT")::arg0::[]) ->
3339
          ((function
3340
            | `Assoc xs ->
3341
                let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
3342
                  match xs with
3343
                  | ("label",x)::xs ->
3344
                      loop xs
3345
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2,
3346
                          arg3)
3347
                  | ("cond",x)::xs ->
3348
                      loop xs
3349
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2,
3350
                          arg3)
3351
                  | ("report",x)::xs ->
3352
                      loop xs
3353
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x),
3354
                          arg3)
3355
                  | ("severity",x)::xs ->
3356
                      loop xs
<