Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2840
and show_vhdl_sequential_stmt_t :
2841
  vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string =
2842
  fun x  -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x
2843

    
2844
and pp_vhdl_if_case_t :
2845
  Format.formatter -> vhdl_if_case_t -> Ppx_deriving_runtime.unit =
2846
  let __1 () = pp_vhdl_sequential_stmt_t
2847
  
2848
  and __0 () = pp_vhdl_expr_t
2849
   in
2850
  ((let open! Ppx_deriving_runtime in
2851
      fun fmt  ->
2852
        fun x  ->
2853
          Format.fprintf fmt " (";
2854
          ((__0 ()) fmt) x.if_cond;
2855
          Format.fprintf fmt ") then@;<0 2>";
2856
          ((fun x  ->
2857
             ignore
2858
               (List.fold_left
2859
                  (fun sep  ->
2860
                     fun x  ->
2861
                             if sep then Format.fprintf fmt "@;<0 2>";
2862
                       ((__1 ()) fmt) x;
2863
                       true) false x);
2864
          )) x.if_block;)
2865
    [@ocaml.warning "-A"])
2866

    
2867
and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string =
2868
  fun x  -> Format.asprintf "%a" pp_vhdl_if_case_t x
2869

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

    
2899
and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string =
2900
  fun x  -> Format.asprintf "%a" pp_vhdl_case_item_t x
2901

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

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