Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / backends / VHDL / vhdl_ast_deriving.ml @ 389493d3

History | View | Annotate | Download (212 KB)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2583
let arith_funs = ["+"; "-"; "*"; "/"; "mod"; "rem"; "abs"; "**"; "&"] 
2584
let bool_funs = ["and"; "or"; "nand"; "nor"; "xor"; "not"] 
2585
let rel_funs =
2586
  ["<";
2587
  ">";
2588
  "<=";
2589
  ">=";
2590
  "/=";
2591
  "=";
2592
  "?=";
2593
  "?/=";
2594
  "?<";
2595
  "?<=";
2596
  "?>";
2597
  "?>=";
2598
  "??"] 
2599
let shift_funs = ["sll"; "srl"; "sla"; "sra"; "rol"; "ror"] 
2600
type vhdl_sequential_stmt_t =
2601
  | VarAssign of
2602
  {
2603
  label: vhdl_name_t [@default NoName];
2604
  lhs: vhdl_name_t ;
2605
  rhs: vhdl_expr_t } [@name "VARIABLE_ASSIGNMENT_STATEMENT"]
2606
  | SigSeqAssign of
2607
  {
2608
  label: vhdl_name_t [@default NoName];
2609
  lhs: vhdl_name_t ;
2610
  rhs: vhdl_expr_t list } [@name "SIGNAL_ASSIGNMENT_STATEMENT"]
2611
  | If of
2612
  {
2613
  label: vhdl_name_t [@default NoName];
2614
  if_cases: vhdl_if_case_t list ;
2615
  default: vhdl_sequential_stmt_t list [@default []]} [@name "IF_STATEMENT"]
2616
  | Case of
2617
  {
2618
  label: vhdl_name_t [@default NoName];
2619
  guard: vhdl_expr_t ;
2620
  branches: vhdl_case_item_t list } [@name "CASE_STATEMENT_TREE"]
2621
  | Exit of
2622
  {
2623
  label: vhdl_name_t [@default NoName];
2624
  loop_label: string option [@default Some ""];
2625
  condition: vhdl_expr_t option [@default Some IsNull]}
2626
  [@name "EXIT_STATEMENT"]
2627
  | Assert of
2628
  {
2629
  label: vhdl_name_t [@default NoName];
2630
  cond: vhdl_expr_t ;
2631
  report: vhdl_expr_t [@default IsNull];
2632
  severity: vhdl_expr_t [@default IsNull]} [@name "ASSERTION_STATEMENT"]
2633
  | 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 = arg2;
3362
                                                  severity = arg3
3363
                                                }))))))
3364
                  | _::xs -> loop xs _state  in
3365
                loop xs
3366
                  ((Result.Ok NoName),
3367
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.cond"),
3368
                    (Result.Ok IsNull), (Result.Ok IsNull))
3369
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3370
      | `List ((`String "WAIT_STATEMENT")::[]) -> Result.Ok Wait
3371
      | `List ((`String "NULL_STATEMENT")::arg0::[]) ->
3372
          ((function
3373
            | `Assoc xs ->
3374
                let rec loop xs (arg0 as _state) =
3375
                  match xs with
3376
                  | ("label",x)::xs ->
3377
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
3378
                  | [] ->
3379
                      arg0 >>=
3380
                        ((fun arg0  -> Result.Ok (Null { label = arg0 })))
3381
                  | _::xs -> loop xs _state  in
3382
                loop xs (Result.Ok NoName)
3383
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3384
      | `List ((`String "RETURN_STATEMENT")::arg0::[]) ->
3385
          ((function
3386
            | `Assoc xs ->
3387
                let rec loop xs (arg0 as _state) =
3388
                  match xs with
3389
                  | ("label",x)::xs ->
3390
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
3391
                  | [] ->
3392
                      arg0 >>=
3393
                        ((fun arg0  -> Result.Ok (Return { label = arg0 })))
3394
                  | _::xs -> loop xs _state  in
3395
                loop xs (Result.Ok NoName)
3396
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3397
      | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")
3398
  [@ocaml.warning "-A"])
3399

    
3400
and (vhdl_if_case_t_to_yojson : vhdl_if_case_t -> Yojson.Safe.json) =
3401
  ((let open! Ppx_deriving_yojson_runtime in
3402
      fun x  ->
3403
        let fields = []  in
3404
        let fields =
3405
          ("if_block",
3406
            ((fun x  ->
3407
                `List
3408
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3409
               x.if_block))
3410
          :: fields  in
3411
        let fields =
3412
          ("if_cond", ((fun x  -> vhdl_expr_t_to_yojson x) x.if_cond)) ::
3413
          fields  in
3414
        `Assoc fields)
3415
  [@ocaml.warning "-A"])
3416

    
3417
and (vhdl_if_case_t_of_yojson :
3418
      Yojson.Safe.json -> vhdl_if_case_t Ppx_deriving_yojson_runtime.error_or)
3419
  =
3420
  ((let open! Ppx_deriving_yojson_runtime in
3421
      function
3422
      | `Assoc xs ->
3423
          let rec loop xs ((arg0,arg1) as _state) =
3424
            match xs with
3425
            | ("if_cond",x)::xs ->
3426
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
3427
            | ("if_block",x)::xs ->
3428
                loop xs
3429
                  (arg0,
3430
                    ((function
3431
                      | `List xs ->
3432
                          map_bind
3433
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3434
                            xs
3435
                      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t.if_block")
3436
                       x))
3437
            | [] ->
3438
                arg1 >>=
3439
                  ((fun arg1  ->
3440
                      arg0 >>=
3441
                        (fun arg0  ->
3442
                           Result.Ok { if_cond = arg0; if_block = arg1 })))
3443
            | _::xs -> loop xs _state  in
3444
          loop xs
3445
            ((Result.Error "Vhdl_ast.vhdl_if_case_t.if_cond"),
3446
              (Result.Error "Vhdl_ast.vhdl_if_case_t.if_block"))
3447
      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t")
3448
  [@ocaml.warning "-A"])
3449

    
3450
and (vhdl_case_item_t_to_yojson : vhdl_case_item_t -> Yojson.Safe.json) =
3451
  ((let open! Ppx_deriving_yojson_runtime in
3452
      fun x  ->
3453
        let fields = []  in
3454
        let fields =
3455
          ("when_stmt",
3456
            ((fun x  ->
3457
                `List
3458
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3459
               x.when_stmt))
3460
          :: fields  in
3461
        let fields =
3462
          ("when_cond",
3463
            ((fun x  ->
3464
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
3465
               x.when_cond))
3466
          :: fields  in
3467
        `Assoc fields)
3468
  [@ocaml.warning "-A"])
3469

    
3470
and (vhdl_case_item_t_of_yojson :
3471
      Yojson.Safe.json ->
3472
        vhdl_case_item_t Ppx_deriving_yojson_runtime.error_or)
3473
  =
3474
  ((let open! Ppx_deriving_yojson_runtime in
3475
      function
3476
      | `Assoc xs ->
3477
          let rec loop xs ((arg0,arg1) as _state) =
3478
            match xs with
3479
            | ("when_cond",x)::xs ->
3480
                loop xs
3481
                  (((function
3482
                     | `List xs ->
3483
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
3484
                     | _ ->
3485
                         Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond")
3486
                      x), arg1)
3487
            | ("when_stmt",x)::xs ->
3488
                loop xs
3489
                  (arg0,
3490
                    ((function
3491
                      | `List xs ->
3492
                          map_bind
3493
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3494
                            xs
3495
                      | _ ->
3496
                          Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt")
3497
                       x))
3498
            | [] ->
3499
                arg1 >>=
3500
                  ((fun arg1  ->
3501
                      arg0 >>=
3502
                        (fun arg0  ->
3503
                           Result.Ok { when_cond = arg0; when_stmt = arg1 })))
3504
            | _::xs -> loop xs _state  in
3505
          loop xs
3506
            ((Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond"),
3507
              (Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt"))
3508
      | _ -> Result.Error "Vhdl_ast.vhdl_case_item_t")
3509
  [@ocaml.warning "-A"])
3510

    
3511
type vhdl_declaration_t =
3512
  | VarDecl of
3513
  {
3514
  names: vhdl_name_t list ;
3515
  typ: vhdl_subtype_indication_t ;
3516
  init_val: vhdl_expr_t [@default IsNull]} [@name "VARIABLE_DECLARATION"]
3517
  | CstDecl of
3518
  {
3519
  names: vhdl_name_t list ;
3520
  typ: vhdl_subtype_indication_t ;
3521
  init_val: vhdl_expr_t } [@name "CONSTANT_DECLARATION"]
3522
  | SigDecl of
3523
  {
3524
  names: vhdl_name_t list ;
3525
  typ: vhdl_subtype_indication_t ;
3526
  init_val: vhdl_expr_t [@default IsNull]} [@name "SIGNAL_DECLARATION"]
3527
  | Subprogram of
3528
  {
3529
  name: vhdl_name_t [@default NoName];
3530
  kind: string [@default ""];
3531
  spec: vhdl_subprogram_spec_t
3532
    [@default
3533
      { name = ""; typeMark = NoName; parameters = []; isPure = false }];
3534
  decl_part: vhdl_declaration_t list [@default []];
3535
  stmts: vhdl_sequential_stmt_t list [@default []]} [@name "SUBPROGRAM_BODY"]
3536

    
3537
(* Needs adaptation for: SubProgram *)
3538
let rec pp_vhdl_declaration_t :
3539
  Format.formatter -> vhdl_declaration_t -> Ppx_deriving_runtime.unit =
3540
  let __12 () = pp_vhdl_sequential_stmt_t
3541
  
3542
  and __11 () = pp_vhdl_declaration_t
3543
  
3544
  and __10 () = pp_vhdl_subprogram_spec_t
3545
  
3546
  and __9 () = pp_vhdl_name_t
3547
  
3548
  and __8 () = pp_vhdl_expr_t
3549
  
3550
  and __7 () = pp_vhdl_subtype_indication_t
3551
  
3552
  and __6 () = pp_vhdl_name_t
3553
  
3554
  and __5 () = pp_vhdl_expr_t
3555
  
3556
  and __4 () = pp_vhdl_subtype_indication_t
3557
  
3558
  and __3 () = pp_vhdl_name_t
3559
  
3560
  and __2 () = pp_vhdl_expr_t
3561
  
3562
  and __1 () = pp_vhdl_subtype_indication_t
3563
  
3564
  and __0 () = pp_vhdl_name_t
3565
   in
3566
  ((let open! Ppx_deriving_runtime in
3567
      fun fmt  ->
3568
        function
3569
        | VarDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3570
            (Format.fprintf fmt "variable ";
3571
             ((((fun x  ->
3572
                    ignore
3573
                      (List.fold_left
3574
                         (fun sep  ->
3575
                            fun x  ->
3576
                              if sep then Format.fprintf fmt ",";
3577
                              ((__0 ()) fmt) x;
3578
                              true) false x);)) anames;
3579
               Format.fprintf fmt " : ";
3580
               ((__1 ()) fmt) atyp;
3581
               (match ainit_val with
3582
                | IsNull  -> Format.pp_print_string fmt ""
3583
                | _ ->
3584
                    (Format.fprintf fmt ":=";
3585
                     ((__2 ()) fmt) ainit_val;))));)
3586
        | CstDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3587
            (Format.fprintf fmt "constant ";
3588
             ((((fun x  ->
3589
                    ignore
3590
                      (List.fold_left
3591
                         (fun sep  ->
3592
                            fun x  ->
3593
                              if sep then Format.fprintf fmt ",";
3594
                              ((__3 ()) fmt) x;
3595
                              true) false x);)) anames;
3596
               Format.fprintf fmt " : ";
3597
               ((__4 ()) fmt) atyp;
3598
              Format.fprintf fmt ":=";
3599
              ((__5 ()) fmt) ainit_val)))
3600
        | SigDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3601
            (Format.fprintf fmt "signal ";
3602
            ((fun x  ->
3603
              ignore
3604
              (List.fold_left
3605
                (fun sep  ->
3606
                  fun x  ->
3607
                    if sep then Format.fprintf fmt ",";
3608
                                ((__6 ()) fmt) x;
3609
                                true) false x);
3610
              )) anames;
3611
            Format.fprintf fmt " : ";
3612
            ((__7 ()) fmt) atyp;
3613
            (match ainit_val with
3614
              | IsNull  -> Format.pp_print_string fmt ""
3615
              | _ ->
3616
                  (Format.fprintf fmt ":=";
3617
                  ((__8 ()) fmt) ainit_val;)))
3618
        | Subprogram
3619
            { name = aname; kind = akind; spec = aspec;
3620
              decl_part = adecl_part; stmts = astmts }
3621
            ->
3622
            (Format.fprintf fmt "@[<2>Subprogram {@,";
3623
             (((((Format.fprintf fmt "@[%s =@ " "name";
3624
                  ((__9 ()) fmt) aname;
3625
                  Format.fprintf fmt "@]");
3626
                 Format.fprintf fmt ";@ ";
3627
                 Format.fprintf fmt "@[%s =@ " "kind";
3628
                 (Format.fprintf fmt "%S") akind;
3629
                 Format.fprintf fmt "@]");
3630
                Format.fprintf fmt ";@ ";
3631
                Format.fprintf fmt "@[%s =@ " "spec";
3632
                ((__10 ()) fmt) aspec;
3633
                Format.fprintf fmt "@]");
3634
               Format.fprintf fmt ";@ ";
3635
               Format.fprintf fmt "@[%s =@ " "decl_part";
3636
               ((fun x  ->
3637
                   Format.fprintf fmt "@[<2>[";
3638
                   ignore
3639
                     (List.fold_left
3640
                        (fun sep  ->
3641
                           fun x  ->
3642
                             if sep then Format.fprintf fmt ";@ ";
3643
                             ((__11 ()) fmt) x;
3644
                             true) false x);
3645
                   Format.fprintf fmt "@,]@]")) adecl_part;
3646
               Format.fprintf fmt "@]");
3647
              Format.fprintf fmt ";@ ";
3648
              Format.fprintf fmt "@[%s =@ " "stmts";
3649
              ((fun x  ->
3650
                  Format.fprintf fmt "@[<2>[";
3651
                  ignore
3652
                    (List.fold_left
3653
                       (fun sep  ->
3654
                          fun x  ->
3655
                            if sep then Format.fprintf fmt ";@ ";
3656
                            ((__12 ()) fmt) x;
3657
                            true) false x);
3658
                  Format.fprintf fmt "@,]@]")) astmts;
3659
              Format.fprintf fmt "@]");
3660
             Format.fprintf fmt "@]}"))
3661
    [@ocaml.warning "-A"])
3662

    
3663
and show_vhdl_declaration_t :
3664
  vhdl_declaration_t -> Ppx_deriving_runtime.string =
3665
  fun x  -> Format.asprintf "%a" pp_vhdl_declaration_t x
3666

    
3667
let rec (vhdl_declaration_t_to_yojson :
3668
          vhdl_declaration_t -> Yojson.Safe.json)
3669
  =
3670
  ((let open! Ppx_deriving_yojson_runtime in
3671
      function
3672
      | VarDecl arg0 ->
3673
          `List
3674
            [`String "VARIABLE_DECLARATION";
3675
            (let fields = []  in
3676
             let fields =
3677
               if arg0.init_val = IsNull
3678
               then fields
3679
               else
3680
                 ("init_val",
3681
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.init_val))
3682
                 :: fields
3683
                in
3684
             let fields =
3685
               ("typ",
3686
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
3687
               :: fields  in
3688
             let fields =
3689
               ("names",
3690
                 ((fun x  ->
3691
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
3692
                    arg0.names))
3693
               :: fields  in
3694
             `Assoc fields)]
3695
      | CstDecl arg0 ->
3696
          `List
3697
            [`String "CONSTANT_DECLARATION";
3698
            (let fields = []  in
3699
             let fields =
3700
               ("init_val",
3701
                 ((fun x  -> vhdl_expr_t_to_yojson x) arg0.init_val))
3702
               :: fields  in
3703
             let fields =
3704
               ("typ",
3705
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
3706
               :: fields  in
3707
             let fields =
3708
               ("names",
3709
                 ((fun x  ->
3710
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
3711
                    arg0.names))
3712
               :: fields  in
3713
             `Assoc fields)]
3714
      | SigDecl arg0 ->
3715
          `List
3716
            [`String "SIGNAL_DECLARATION";
3717
            (let fields = []  in
3718
             let fields =
3719
               if arg0.init_val = IsNull
3720
               then fields
3721
               else
3722
                 ("init_val",
3723
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.init_val))
3724
                 :: fields
3725
                in
3726
             let fields =
3727
               ("typ",
3728
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
3729
               :: fields  in
3730
             let fields =
3731
               ("names",
3732
                 ((fun x  ->
3733
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
3734
                    arg0.names))
3735
               :: fields  in
3736
             `Assoc fields)]
3737
      | Subprogram arg0 ->
3738
          `List
3739
            [`String "SUBPROGRAM_BODY";
3740
            (let fields = []  in
3741
             let fields =
3742
               if arg0.stmts = []
3743
               then fields
3744
               else
3745
                 ("stmts",
3746
                   (((fun x  ->
3747
                        `List
3748
                          (List.map
3749
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
3750
                      arg0.stmts))
3751
                 :: fields
3752
                in
3753
             let fields =
3754
               if arg0.decl_part = []
3755
               then fields
3756
               else
3757
                 ("decl_part",
3758
                   (((fun x  ->
3759
                        `List
3760
                          (List.map
3761
                             (fun x  -> vhdl_declaration_t_to_yojson x) x)))
3762
                      arg0.decl_part))
3763
                 :: fields
3764
                in
3765
             let fields =
3766
               if
3767
                 arg0.spec =
3768
                   {
3769
                     name = "";
3770
                     typeMark = NoName;
3771
                     parameters = [];
3772
                     isPure = false
3773
                   }
3774
               then fields
3775
               else
3776
                 ("spec",
3777
                   (((fun x  -> vhdl_subprogram_spec_t_to_yojson x))
3778
                      arg0.spec))
3779
                 :: fields
3780
                in
3781
             let fields =
3782
               if arg0.kind = ""
3783
               then fields
3784
               else
3785
                 ("kind",
3786
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
3787
                      arg0.kind))
3788
                 :: fields
3789
                in
3790
             let fields =
3791
               if arg0.name = NoName
3792
               then fields
3793
               else
3794
                 ("name", (((fun x  -> vhdl_name_t_to_yojson x)) arg0.name))
3795
                 :: fields
3796
                in
3797
             `Assoc fields)])
3798
  [@ocaml.warning "-A"])
3799

    
3800
and (vhdl_declaration_t_of_yojson :
3801
      Yojson.Safe.json ->
3802
        vhdl_declaration_t Ppx_deriving_yojson_runtime.error_or)
3803
  =
3804
  ((let open! Ppx_deriving_yojson_runtime in
3805
      function
3806
      | `List ((`String "VARIABLE_DECLARATION")::arg0::[]) ->
3807
          ((function
3808
            | `Assoc xs ->
3809
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3810
                  match xs with
3811
                  | ("names",x)::xs ->
3812
                      loop xs
3813
                        (((function
3814
                           | `List xs ->
3815
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
3816
                                 [] xs
3817
                           | _ ->
3818
                               Result.Error
3819
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
3820
                          arg1, arg2)
3821
                  | ("typ",x)::xs ->
3822
                      loop xs
3823
                        (arg0,
3824
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
3825
                             x), arg2)
3826
                  | ("init_val",x)::xs ->
3827
                      loop xs
3828
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
3829
                  | [] ->
3830
                      arg2 >>=
3831
                        ((fun arg2  ->
3832
                            arg1 >>=
3833
                              (fun arg1  ->
3834
                                 arg0 >>=
3835
                                   (fun arg0  ->
3836
                                      Result.Ok
3837
                                        (VarDecl
3838
                                           {
3839
                                             names = arg0;
3840
                                             typ = arg1;
3841
                                             init_val = arg2
3842
                                           })))))
3843
                  | _::xs -> loop xs _state  in
3844
                loop xs
3845
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
3846
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
3847
                    (Result.Ok IsNull))
3848
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
3849
      | `List ((`String "CONSTANT_DECLARATION")::arg0::[]) ->
3850
          ((function
3851
            | `Assoc xs ->
3852
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3853
                  match xs with
3854
                  | ("names",x)::xs ->
3855
                      loop xs
3856
                        (((function
3857
                           | `List xs ->
3858
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
3859
                                 [] xs
3860
                           | _ ->
3861
                               Result.Error
3862
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
3863
                          arg1, arg2)
3864
                  | ("typ",x)::xs ->
3865
                      loop xs
3866
                        (arg0,
3867
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
3868
                             x), arg2)
3869
                  | ("init_val",x)::xs ->
3870
                      loop xs
3871
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
3872
                  | [] ->
3873
                      arg2 >>=
3874
                        ((fun arg2  ->
3875
                            arg1 >>=
3876
                              (fun arg1  ->
3877
                                 arg0 >>=
3878
                                   (fun arg0  ->
3879
                                      Result.Ok
3880
                                        (CstDecl
3881
                                           {
3882
                                             names = arg0;
3883
                                             typ = arg1;
3884
                                             init_val = arg2
3885
                                           })))))
3886
                  | _::xs -> loop xs _state  in
3887
                loop xs
3888
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
3889
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
3890
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.init_val"))
3891
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
3892
      | `List ((`String "SIGNAL_DECLARATION")::arg0::[]) ->
3893
          ((function
3894
            | `Assoc xs ->
3895
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3896
                  match xs with
3897
                  | ("names",x)::xs ->
3898
                      loop xs
3899
                        (((function
3900
                           | `List xs ->
3901
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
3902
                                 [] xs
3903
                           | _ ->
3904
                               Result.Error
3905
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
3906
                          arg1, arg2)
3907
                  | ("typ",x)::xs ->
3908
                      loop xs
3909
                        (arg0,
3910
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
3911
                             x), arg2)
3912
                  | ("init_val",x)::xs ->
3913
                      loop xs
3914
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
3915
                  | [] ->
3916
                      arg2 >>=
3917
                        ((fun arg2  ->
3918
                            arg1 >>=
3919
                              (fun arg1  ->
3920
                                 arg0 >>=
3921
                                   (fun arg0  ->
3922
                                      Result.Ok
3923
                                        (SigDecl
3924
                                           {
3925
                                             names = arg0;
3926
                                             typ = arg1;
3927
                                             init_val = arg2
3928
                                           })))))
3929
                  | _::xs -> loop xs _state  in
3930
                loop xs
3931
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
3932
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
3933
                    (Result.Ok IsNull))
3934
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
3935
      | `List ((`String "SUBPROGRAM_BODY")::arg0::[]) ->
3936
          ((function
3937
            | `Assoc xs ->
3938
                let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
3939
                  match xs with
3940
                  | ("name",x)::xs ->
3941
                      loop xs
3942
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2,
3943
                          arg3, arg4)
3944
                  | ("kind",x)::xs ->
3945
                      loop xs
3946
                        (arg0,
3947
                          ((function
3948
                            | `String x -> Result.Ok x
3949
                            | _ ->
3950
                                Result.Error
3951
                                  "Vhdl_ast.vhdl_declaration_t.kind") x),
3952
                          arg2, arg3, arg4)
3953
                  | ("spec",x)::xs ->
3954
                      loop xs
3955
                        (arg0, arg1,
3956
                          ((fun x  -> vhdl_subprogram_spec_t_of_yojson x) x),
3957
                          arg3, arg4)
3958
                  | ("decl_part",x)::xs ->
3959
                      loop xs
3960
                        (arg0, arg1, arg2,
3961
                          ((function
3962
                            | `List xs ->
3963
                                map_bind
3964
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
3965
                                  [] xs
3966
                            | _ ->
3967
                                Result.Error
3968
                                  "Vhdl_ast.vhdl_declaration_t.decl_part") x),
3969
                          arg4)
3970
                  | ("stmts",x)::xs ->
3971
                      loop xs
3972
                        (arg0, arg1, arg2, arg3,
3973
                          ((function
3974
                            | `List xs ->
3975
                                map_bind
3976
                                  (fun x  ->
3977
                                     vhdl_sequential_stmt_t_of_yojson x) []
3978
                                  xs
3979
                            | _ ->
3980
                                Result.Error
3981
                                  "Vhdl_ast.vhdl_declaration_t.stmts") x))
3982
                  | [] ->
3983
                      arg4 >>=
3984
                        ((fun arg4  ->
3985
                            arg3 >>=
3986
                              (fun arg3  ->
3987
                                 arg2 >>=
3988
                                   (fun arg2  ->
3989
                                      arg1 >>=
3990
                                        (fun arg1  ->
3991
                                           arg0 >>=
3992
                                             (fun arg0  ->
3993
                                                Result.Ok
3994
                                                  (Subprogram
3995
                                                     {
3996
                                                       name = arg0;
3997
                                                       kind = arg1;
3998
                                                       spec = arg2;
3999
                                                       decl_part = arg3;
4000
                                                       stmts = arg4
4001
                                                     })))))))
4002
                  | _::xs -> loop xs _state  in
4003
                loop xs
4004
                  ((Result.Ok NoName), (Result.Ok ""),
4005
                    (Result.Ok
4006
                       {
4007
                         name = "";
4008
                         typeMark = NoName;
4009
                         parameters = [];
4010
                         isPure = false
4011
                       }), (Result.Ok []), (Result.Ok []))
4012
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4013
      | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")
4014
  [@ocaml.warning "-A"])
4015

    
4016
type vhdl_signal_condition_t =
4017
  {
4018
  expr: vhdl_expr_t list ;
4019
  cond: vhdl_expr_t [@default IsNull]}
4020

    
4021
let rec pp_vhdl_signal_condition_t :
4022
  Format.formatter -> vhdl_signal_condition_t -> Ppx_deriving_runtime.unit =
4023
  let __1 () = pp_vhdl_expr_t
4024
  
4025
  and __0 () = pp_vhdl_expr_t
4026
   in
4027
  ((let open! Ppx_deriving_runtime in
4028
      fun fmt  ->
4029
        fun x  ->
4030
          ((fun x  ->
4031
              ignore
4032
                (List.fold_left
4033
                   (fun sep  ->
4034
                      fun x  ->
4035
                        if sep then Format.fprintf fmt ";@ ";
4036
                        ((__0 ()) fmt) x;
4037
                        true) false x))) x.expr;
4038
          (match x.cond with
4039
          | IsNull -> Format.fprintf fmt "";
4040
          | _ -> Format.fprintf fmt "when ";
4041
                 ((__1 ()) fmt) x.cond);)
4042
    [@ocaml.warning "-A"])
4043

    
4044
and show_vhdl_signal_condition_t :
4045
  vhdl_signal_condition_t -> Ppx_deriving_runtime.string =
4046
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_condition_t x
4047

    
4048
let rec (vhdl_signal_condition_t_to_yojson :
4049
          vhdl_signal_condition_t -> Yojson.Safe.json)
4050
  =
4051
  ((let open! Ppx_deriving_yojson_runtime in
4052
      fun x  ->
4053
        let fields = []  in
4054
        let fields =
4055
          if x.cond = IsNull
4056
          then fields
4057
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4058
            fields
4059
           in
4060
        let fields =
4061
          ("expr",
4062
            ((fun x  ->
4063
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
4064
               x.expr))
4065
          :: fields  in
4066
        `Assoc fields)
4067
  [@ocaml.warning "-A"])
4068

    
4069
and (vhdl_signal_condition_t_of_yojson :
4070
      Yojson.Safe.json ->
4071
        vhdl_signal_condition_t Ppx_deriving_yojson_runtime.error_or)
4072
  =
4073
  ((let open! Ppx_deriving_yojson_runtime in
4074
      function
4075
      | `Assoc xs ->
4076
          let rec loop xs ((arg0,arg1) as _state) =
4077
            match xs with
4078
            | ("expr",x)::xs ->
4079
                loop xs
4080
                  (((function
4081
                     | `List xs ->
4082
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4083
                     | _ ->
4084
                         Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr")
4085
                      x), arg1)
4086
            | ("cond",x)::xs ->
4087
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4088
            | [] ->
4089
                arg1 >>=
4090
                  ((fun arg1  ->
4091
                      arg0 >>=
4092
                        (fun arg0  -> Result.Ok { expr = arg0; cond = arg1 })))
4093
            | _::xs -> loop xs _state  in
4094
          loop xs
4095
            ((Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr"),
4096
              (Result.Ok IsNull))
4097
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_condition_t")
4098
  [@ocaml.warning "-A"])
4099

    
4100
type vhdl_signal_selection_t =
4101
  {
4102
  expr: vhdl_expr_t ;
4103
  when_sel: vhdl_expr_t list [@default []]}
4104

    
4105
(* TODO *)
4106
let rec pp_vhdl_signal_selection_t :
4107
  Format.formatter -> vhdl_signal_selection_t -> Ppx_deriving_runtime.unit =
4108
  let __1 () = pp_vhdl_expr_t
4109
  
4110
  and __0 () = pp_vhdl_expr_t
4111
   in
4112
  ((let open! Ppx_deriving_runtime in
4113
      fun fmt  ->
4114
        fun x  ->
4115
          Format.fprintf fmt "@[<2>{ ";
4116
          ((Format.fprintf fmt "@[%s =@ " "expr";
4117
            ((__0 ()) fmt) x.expr;
4118
            Format.fprintf fmt "@]");
4119
           Format.fprintf fmt ";@ ";
4120
           Format.fprintf fmt "@[%s =@ " "when_sel";
4121
           ((fun x  ->
4122
               Format.fprintf fmt "@[<2>[";
4123
               ignore
4124
                 (List.fold_left
4125
                    (fun sep  ->
4126
                       fun x  ->
4127
                         if sep then Format.fprintf fmt ";@ ";
4128
                         ((__1 ()) fmt) x;
4129
                         true) false x);
4130
               Format.fprintf fmt "@,]@]")) x.when_sel;
4131
           Format.fprintf fmt "@]");
4132
          Format.fprintf fmt "@ }@]")
4133
    [@ocaml.warning "-A"])
4134

    
4135
and show_vhdl_signal_selection_t :
4136
  vhdl_signal_selection_t -> Ppx_deriving_runtime.string =
4137
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_selection_t x
4138

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

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

    
4193
type vhdl_conditional_signal_t =
4194
  {
4195
  postponed: bool [@default false];
4196
  label: vhdl_name_t [@default NoName];
4197
  lhs: vhdl_name_t ;
4198
  rhs: vhdl_signal_condition_t list ;
4199
  cond: vhdl_expr_t [@default IsNull];
4200
  delay: vhdl_expr_t [@default IsNull]}
4201

    
4202
let rec pp_vhdl_conditional_signal_t :
4203
  Format.formatter -> vhdl_conditional_signal_t -> Ppx_deriving_runtime.unit
4204
  =
4205
  let __4 () = pp_vhdl_expr_t
4206
  
4207
  and __3 () = pp_vhdl_expr_t
4208
  
4209
  and __2 () = pp_vhdl_signal_condition_t
4210
  
4211
  and __1 () = pp_vhdl_name_t
4212
  
4213
  and __0 () = pp_vhdl_name_t
4214
   in
4215
  ((let open! Ppx_deriving_runtime in
4216
      fun fmt  ->
4217
        fun x  ->
4218
          (match x.label with
4219
            | NoName -> Format.fprintf fmt "";
4220
            | _ -> (((__0 ()) fmt) x.label;
4221
                   Format.fprintf fmt ":@ ")
4222
          );
4223
          if (x.postponed) then Format.fprintf fmt "postponed@ ";
4224
          ((__1 ()) fmt) x.lhs;
4225
          Format.fprintf fmt " <= ";
4226
          (match x.delay with
4227
            | IsNull -> Format.fprintf fmt "";
4228
            | _ -> ((__4 ()) fmt) x.delay;
4229
                   Format.fprintf fmt " ");
4230
          ((fun x  ->
4231
             Format.fprintf fmt "@[";
4232
             ignore
4233
               (List.fold_left
4234
                 (fun sep  ->
4235
                   fun x  ->
4236
                     if sep then Format.fprintf fmt "";
4237
                      ((__2 ()) fmt) x;
4238
                      Format.fprintf fmt ";";
4239
                      true) false x);
4240
          Format.fprintf fmt "@]")) x.rhs;
4241
          (match x.cond with
4242
            | IsNull -> Format.fprintf fmt "";
4243
            | _ -> Format.fprintf fmt "when (";
4244
                   ((__3 ()) fmt) x.cond;
4245
                   Format.fprintf fmt ")"))
4246
   [@ocaml.warning "-A"])
4247

    
4248
and show_vhdl_conditional_signal_t :
4249
  vhdl_conditional_signal_t -> Ppx_deriving_runtime.string =
4250
  fun x  -> Format.asprintf "%a" pp_vhdl_conditional_signal_t x
4251

    
4252
let rec (vhdl_conditional_signal_t_to_yojson :
4253
          vhdl_conditional_signal_t -> Yojson.Safe.json)
4254
  =
4255
  ((let open! Ppx_deriving_yojson_runtime in
4256
      fun x  ->
4257
        let fields = []  in
4258
        let fields =
4259
          if x.delay = IsNull
4260
          then fields
4261
          else ("delay", (((fun x  -> vhdl_expr_t_to_yojson x)) x.delay)) ::
4262
            fields
4263
           in
4264
        let fields =
4265
          if x.cond = IsNull
4266
          then fields
4267
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4268
            fields
4269
           in
4270
        let fields =
4271
          ("rhs",
4272
            ((fun x  ->
4273
                `List
4274
                  (List.map (fun x  -> vhdl_signal_condition_t_to_yojson x) x))
4275
               x.rhs))
4276
          :: fields  in
4277
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4278
          fields  in
4279
        let fields =
4280
          if x.label = NoName
4281
          then fields
4282
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4283
            fields
4284
           in
4285
        let fields =
4286
          if x.postponed = false
4287
          then fields
4288
          else
4289
            ("postponed",
4290
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4291
                 x.postponed))
4292
            :: fields
4293
           in
4294
        `Assoc fields)
4295
  [@ocaml.warning "-A"])
4296

    
4297
and (vhdl_conditional_signal_t_of_yojson :
4298
      Yojson.Safe.json ->
4299
        vhdl_conditional_signal_t Ppx_deriving_yojson_runtime.error_or)
4300
  =
4301
  ((let open! Ppx_deriving_yojson_runtime in
4302
      function
4303
      | `Assoc xs ->
4304
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4305
            match xs with
4306
            | ("postponed",x)::xs ->
4307
                loop xs
4308
                  (((function
4309
                     | `Bool x -> Result.Ok x
4310
                     | _ ->
4311
                         Result.Error
4312
                           "Vhdl_ast.vhdl_conditional_signal_t.postponed") x),
4313
                    arg1, arg2, arg3, arg4, arg5)
4314
            | ("label",x)::xs ->
4315
                loop xs
4316
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4317
                    arg4, arg5)
4318
            | ("lhs",x)::xs ->
4319
                loop xs
4320
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4321
                    arg4, arg5)
4322
            | ("rhs",x)::xs ->
4323
                loop xs
4324
                  (arg0, arg1, arg2,
4325
                    ((function
4326
                      | `List xs ->
4327
                          map_bind
4328
                            (fun x  -> vhdl_signal_condition_t_of_yojson x)
4329
                            [] xs
4330
                      | _ ->
4331
                          Result.Error
4332
                            "Vhdl_ast.vhdl_conditional_signal_t.rhs") x),
4333
                    arg4, arg5)
4334
            | ("cond",x)::xs ->
4335
                loop xs
4336
                  (arg0, arg1, arg2, arg3,
4337
                    ((fun x  -> vhdl_expr_t_of_yojson x) x), arg5)
4338
            | ("delay",x)::xs ->
4339
                loop xs
4340
                  (arg0, arg1, arg2, arg3, arg4,
4341
                    ((fun x  -> vhdl_expr_t_of_yojson x) x))
4342
            | [] ->
4343
                arg5 >>=
4344
                  ((fun arg5  ->
4345
                      arg4 >>=
4346
                        (fun arg4  ->
4347
                           arg3 >>=
4348
                             (fun arg3  ->
4349
                                arg2 >>=
4350
                                  (fun arg2  ->
4351
                                     arg1 >>=
4352
                                       (fun arg1  ->
4353
                                          arg0 >>=
4354
                                            (fun arg0  ->
4355
                                               Result.Ok
4356
                                                 {
4357
                                                   postponed = arg0;
4358
                                                   label = arg1;
4359
                                                   lhs = arg2;
4360
                                                   rhs = arg3;
4361
                                                   cond = arg4;
4362
                                                   delay = arg5
4363
                                                 })))))))
4364
            | _::xs -> loop xs _state  in
4365
          loop xs
4366
            ((Result.Ok false), (Result.Ok NoName),
4367
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.lhs"),
4368
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.rhs"),
4369
              (Result.Ok IsNull), (Result.Ok IsNull))
4370
      | _ -> Result.Error "Vhdl_ast.vhdl_conditional_signal_t")
4371
  [@ocaml.warning "-A"])
4372

    
4373
type vhdl_process_t =
4374
  {
4375
  id: vhdl_name_t [@default NoName];
4376
  declarations: vhdl_declaration_t list option
4377
    [@key "PROCESS_DECLARATIVE_PART"][@default Some []];
4378
  active_sigs: vhdl_name_t list [@default []];
4379
  body: vhdl_sequential_stmt_t list
4380
    [@key "PROCESS_STATEMENT_PART"][@default []]}
4381

    
4382
let rec pp_vhdl_process_t :
4383
  Format.formatter -> vhdl_process_t -> Ppx_deriving_runtime.unit =
4384
  let __3 () = pp_vhdl_sequential_stmt_t
4385
  
4386
  and __2 () = pp_vhdl_name_t
4387
  
4388
  and __1 () = pp_vhdl_declaration_t
4389
  
4390
  and __0 () = pp_vhdl_name_t
4391
   in
4392
  ((let open! Ppx_deriving_runtime in
4393
      fun fmt  ->
4394
        fun x  ->
4395
          Format.fprintf fmt "@[<v>process ";
4396
          (match x.active_sigs with
4397
          | [] -> Format.fprintf fmt "";
4398
          | _ -> Format.fprintf fmt "(";
4399
                 ((fun x  ->
4400
                    ignore
4401
                      (List.fold_left
4402
                         (fun sep  ->
4403
                            fun x  ->
4404
                              if sep then Format.fprintf fmt ",";
4405
                              ((__2 ()) fmt) x;
4406
                              true) false x))) x.active_sigs;
4407
                 Format.fprintf fmt ")");
4408
          ((function
4409
             | None  -> Format.pp_print_string fmt ""
4410
             | Some x ->
4411
                  ((fun x  ->
4412
                      Format.fprintf fmt "@[<2>";
4413
                      ignore
4414
                        (List.fold_left
4415
                           (fun sep  ->
4416
                              fun x  ->
4417
                                if sep then Format.fprintf fmt "@;";
4418
                                ((__1 ()) fmt) x;
4419
                                true) false x);
4420
                      Format.fprintf fmt "@]")) x;)) x.declarations;
4421
          Format.fprintf fmt "@;@[<v 2>begin@;";
4422
          ((fun x  ->
4423
               ignore
4424
                 (List.fold_left
4425
                    (fun sep  ->
4426
                       fun x  ->
4427
                         if sep then Format.fprintf fmt "@;";
4428
                         ((__3 ()) fmt) x;
4429
                         true) false x);)) x.body;
4430
          Format.fprintf fmt "@]@;end process;@;";
4431
          Format.fprintf fmt "@]";)
4432
    [@ocaml.warning "-A"])
4433

    
4434
and show_vhdl_process_t : vhdl_process_t -> Ppx_deriving_runtime.string =
4435
  fun x  -> Format.asprintf "%a" pp_vhdl_process_t x
4436

    
4437
let rec (vhdl_process_t_to_yojson : vhdl_process_t -> Yojson.Safe.json) =
4438
  ((let open! Ppx_deriving_yojson_runtime in
4439
      fun x  ->
4440
        let fields = []  in
4441
        let fields =
4442
          if x.body = []
4443
          then fields
4444
          else
4445
            ("PROCESS_STATEMENT_PART",
4446
              (((fun x  ->
4447
                   `List
4448
                     (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x)
4449
                        x))) x.body))
4450
            :: fields
4451
           in
4452
        let fields =
4453
          if x.active_sigs = []
4454
          then fields
4455
          else
4456
            ("active_sigs",
4457
              (((fun x  ->
4458
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
4459
                 x.active_sigs))
4460
            :: fields
4461
           in
4462
        let fields =
4463
          if x.declarations = (Some [])
4464
          then fields
4465
          else
4466
            ("PROCESS_DECLARATIVE_PART",
4467
              (((function
4468
                 | None  -> `Null
4469
                 | Some x ->
4470
                     ((fun x  ->
4471
                         `List
4472
                           (List.map
4473
                              (fun x  -> vhdl_declaration_t_to_yojson x) x)))
4474
                       x)) x.declarations))
4475
            :: fields
4476
           in
4477
        let fields =
4478
          if x.id = NoName
4479
          then fields
4480
          else ("id", (((fun x  -> vhdl_name_t_to_yojson x)) x.id)) :: fields
4481
           in
4482
        `Assoc fields)
4483
  [@ocaml.warning "-A"])
4484

    
4485
and (vhdl_process_t_of_yojson :
4486
      Yojson.Safe.json -> vhdl_process_t Ppx_deriving_yojson_runtime.error_or)
4487
  =
4488
  ((let open! Ppx_deriving_yojson_runtime in
4489
      function
4490
      | `Assoc xs ->
4491
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
4492
            match xs with
4493
            | ("id",x)::xs ->
4494
                loop xs
4495
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3)
4496
            | ("PROCESS_DECLARATIVE_PART",x)::xs ->
4497
                loop xs
4498
                  (arg0,
4499
                    ((function
4500
                      | `Null -> Result.Ok None
4501
                      | x ->
4502
                          ((function
4503
                            | `List xs ->
4504
                                map_bind
4505
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4506
                                  [] xs
4507
                            | _ ->
4508
                                Result.Error
4509
                                  "Vhdl_ast.vhdl_process_t.declarations") x)
4510
                            >>= ((fun x  -> Result.Ok (Some x)))) x), arg2,
4511
                    arg3)
4512
            | ("active_sigs",x)::xs ->
4513
                loop xs
4514
                  (arg0, arg1,
4515
                    ((function
4516
                      | `List xs ->
4517
                          map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4518
                      | _ ->
4519
                          Result.Error "Vhdl_ast.vhdl_process_t.active_sigs")
4520
                       x), arg3)
4521
            | ("PROCESS_STATEMENT_PART",x)::xs ->
4522
                loop xs
4523
                  (arg0, arg1, arg2,
4524
                    ((function
4525
                      | `List xs ->
4526
                          map_bind
4527
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
4528
                            xs
4529
                      | _ -> Result.Error "Vhdl_ast.vhdl_process_t.body") x))
4530
            | [] ->
4531
                arg3 >>=
4532
                  ((fun arg3  ->
4533
                      arg2 >>=
4534
                        (fun arg2  ->
4535
                           arg1 >>=
4536
                             (fun arg1  ->
4537
                                arg0 >>=
4538
                                  (fun arg0  ->
4539
                                     Result.Ok
4540
                                       {
4541
                                         id = arg0;
4542
                                         declarations = arg1;
4543
                                         active_sigs = arg2;
4544
                                         body = arg3
4545
                                       })))))
4546
            | _::xs -> loop xs _state  in
4547
          loop xs
4548
            ((Result.Ok NoName), (Result.Ok (Some [])), (Result.Ok []),
4549
              (Result.Ok []))
4550
      | _ -> Result.Error "Vhdl_ast.vhdl_process_t")
4551
  [@ocaml.warning "-A"])
4552

    
4553
type vhdl_selected_signal_t =
4554
  {
4555
  postponed: bool [@default false];
4556
  label: vhdl_name_t [@default NoName];
4557
  lhs: vhdl_name_t ;
4558
  sel: vhdl_expr_t ;
4559
  branches: vhdl_signal_selection_t list [@default []];
4560
  delay: vhdl_expr_t option }
4561

    
4562
(* TODO *)
4563
let rec pp_vhdl_selected_signal_t :
4564
  Format.formatter -> vhdl_selected_signal_t -> Ppx_deriving_runtime.unit =
4565
  let __4 () = pp_vhdl_expr_t
4566
  
4567
  and __3 () = pp_vhdl_signal_selection_t
4568
  
4569
  and __2 () = pp_vhdl_expr_t
4570
  
4571
  and __1 () = pp_vhdl_name_t
4572
  
4573
  and __0 () = pp_vhdl_name_t
4574
   in
4575
  ((let open! Ppx_deriving_runtime in
4576
      fun fmt  ->
4577
        fun x  ->
4578
          Format.fprintf fmt "@[<2>{ ";
4579
          ((((((Format.fprintf fmt "@[%s =@ " "postponed";
4580
                (Format.fprintf fmt "%B") x.postponed;
4581
                Format.fprintf fmt "@]");
4582
               Format.fprintf fmt ";@ ";
4583
               Format.fprintf fmt "@[%s =@ " "label";
4584
               ((__0 ()) fmt) x.label;
4585
               Format.fprintf fmt "@]");
4586
              Format.fprintf fmt ";@ ";
4587
              Format.fprintf fmt "@[%s =@ " "lhs";
4588
              ((__1 ()) fmt) x.lhs;
4589
              Format.fprintf fmt "@]");
4590
             Format.fprintf fmt ";@ ";
4591
             Format.fprintf fmt "@[%s =@ " "sel";
4592
             ((__2 ()) fmt) x.sel;
4593
             Format.fprintf fmt "@]");
4594
            Format.fprintf fmt ";@ ";
4595
            Format.fprintf fmt "@[%s =@ " "branches";
4596
            ((fun x  ->
4597
                Format.fprintf fmt "@[<2>[";
4598
                ignore
4599
                  (List.fold_left
4600
                     (fun sep  ->
4601
                        fun x  ->
4602
                          if sep then Format.fprintf fmt ";@ ";
4603
                          ((__3 ()) fmt) x;
4604
                          true) false x);
4605
                Format.fprintf fmt "@,]@]")) x.branches;
4606
            Format.fprintf fmt "@]");
4607
           Format.fprintf fmt ";@ ";
4608
           Format.fprintf fmt "@[%s =@ " "delay";
4609
           ((function
4610
             | None  -> Format.pp_print_string fmt "None"
4611
             | Some x ->
4612
                 (Format.pp_print_string fmt "(Some ";
4613
                  ((__4 ()) fmt) x;
4614
                  Format.pp_print_string fmt ")"))) x.delay;
4615
           Format.fprintf fmt "@]");
4616
          Format.fprintf fmt "@ }@]")
4617
    [@ocaml.warning "-A"])
4618

    
4619
and show_vhdl_selected_signal_t :
4620
  vhdl_selected_signal_t -> Ppx_deriving_runtime.string =
4621
  fun x  -> Format.asprintf "%a" pp_vhdl_selected_signal_t x
4622

    
4623
let rec (vhdl_selected_signal_t_to_yojson :
4624
          vhdl_selected_signal_t -> Yojson.Safe.json)
4625
  =
4626
  ((let open! Ppx_deriving_yojson_runtime in
4627
      fun x  ->
4628
        let fields = []  in
4629
        let fields =
4630
          ("delay",
4631
            ((function
4632
              | None  -> `Null
4633
              | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x) x.delay))
4634
          :: fields  in
4635
        let fields =
4636
          if x.branches = []
4637
          then fields
4638
          else
4639
            ("branches",
4640
              (((fun x  ->
4641
                   `List
4642
                     (List.map
4643
                        (fun x  -> vhdl_signal_selection_t_to_yojson x) x)))
4644
                 x.branches))
4645
            :: fields
4646
           in
4647
        let fields = ("sel", ((fun x  -> vhdl_expr_t_to_yojson x) x.sel)) ::
4648
          fields  in
4649
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4650
          fields  in
4651
        let fields =
4652
          if x.label = NoName
4653
          then fields
4654
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4655
            fields
4656
           in
4657
        let fields =
4658
          if x.postponed = false
4659
          then fields
4660
          else
4661
            ("postponed",
4662
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4663
                 x.postponed))
4664
            :: fields
4665
           in
4666
        `Assoc fields)
4667
  [@ocaml.warning "-A"])
4668

    
4669
and (vhdl_selected_signal_t_of_yojson :
4670
      Yojson.Safe.json ->
4671
        vhdl_selected_signal_t Ppx_deriving_yojson_runtime.error_or)
4672
  =
4673
  ((let open! Ppx_deriving_yojson_runtime in
4674
      function
4675
      | `Assoc xs ->
4676
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4677
            match xs with
4678
            | ("postponed",x)::xs ->
4679
                loop xs
4680
                  (((function
4681
                     | `Bool x -> Result.Ok x
4682
                     | _ ->
4683
                         Result.Error
4684
                           "Vhdl_ast.vhdl_selected_signal_t.postponed") x),
4685
                    arg1, arg2, arg3, arg4, arg5)
4686
            | ("label",x)::xs ->
4687
                loop xs
4688
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4689
                    arg4, arg5)
4690
            | ("lhs",x)::xs ->
4691
                loop xs
4692
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4693
                    arg4, arg5)
4694
            | ("sel",x)::xs ->
4695
                loop xs
4696
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x),
4697
                    arg4, arg5)
4698
            | ("branches",x)::xs ->
4699
                loop xs
4700
                  (arg0, arg1, arg2, arg3,
4701
                    ((function
4702
                      | `List xs ->
4703
                          map_bind
4704
                            (fun x  -> vhdl_signal_selection_t_of_yojson x)
4705
                            [] xs
4706
                      | _ ->
4707
                          Result.Error
4708
                            "Vhdl_ast.vhdl_selected_signal_t.branches") x),
4709
                    arg5)
4710
            | ("delay",x)::xs ->
4711
                loop xs
4712
                  (arg0, arg1, arg2, arg3, arg4,
4713
                    ((function
4714
                      | `Null -> Result.Ok None
4715
                      | x ->
4716
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
4717
                            ((fun x  -> Result.Ok (Some x)))) x))
4718
            | [] ->
4719
                arg5 >>=
4720
                  ((fun arg5  ->
4721
                      arg4 >>=
4722
                        (fun arg4  ->
4723
                           arg3 >>=
4724
                             (fun arg3  ->
4725
                                arg2 >>=
4726
                                  (fun arg2  ->
4727
                                     arg1 >>=
4728
                                       (fun arg1  ->
4729
                                          arg0 >>=
4730
                                            (fun arg0  ->
4731
                                               Result.Ok
4732
                                                 {
4733
                                                   postponed = arg0;
4734
                                                   label = arg1;
4735
                                                   lhs = arg2;
4736
                                                   sel = arg3;
4737
                                                   branches = arg4;
4738
                                                   delay = arg5
4739
                                                 })))))))
4740
            | _::xs -> loop xs _state  in
4741
          loop xs
4742
            ((Result.Ok false), (Result.Ok NoName),
4743
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.lhs"),
4744
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.sel"),
4745
              (Result.Ok []),
4746
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.delay"))
4747
      | _ -> Result.Error "Vhdl_ast.vhdl_selected_signal_t")
4748
  [@ocaml.warning "-A"])
4749

    
4750
type vhdl_concurrent_stmt_t =
4751
  | SigAssign of vhdl_conditional_signal_t
4752
  [@name "CONDITIONAL_SIGNAL_ASSIGNMENT"]
4753
  | Process of vhdl_process_t [@name "PROCESS_STATEMENT"]
4754
  | SelectedSig of vhdl_selected_signal_t
4755
  [@name "SELECTED_SIGNAL_ASSIGNMENT"]
4756

    
4757
let rec pp_vhdl_concurrent_stmt_t :
4758
  Format.formatter -> vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.unit =
4759
  let __2 () = pp_vhdl_selected_signal_t
4760
  
4761
  and __1 () = pp_vhdl_process_t
4762
  
4763
  and __0 () = pp_vhdl_conditional_signal_t
4764
   in
4765
  ((let open! Ppx_deriving_runtime in
4766
      fun fmt  ->
4767
        function
4768
        | SigAssign a0 ->
4769
             ((__0 ()) fmt) a0;
4770
        | Process a0 ->
4771
             ((__1 ()) fmt) a0;
4772
        | SelectedSig a0 ->
4773
             ((__2 ()) fmt) a0;
4774
    )
4775
    [@ocaml.warning "-A"])
4776

    
4777
and show_vhdl_concurrent_stmt_t :
4778
  vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.string =
4779
  fun x  -> Format.asprintf "%a" pp_vhdl_concurrent_stmt_t x
4780

    
4781
let rec (vhdl_concurrent_stmt_t_to_yojson :
4782
          vhdl_concurrent_stmt_t -> Yojson.Safe.json)
4783
  =
4784
  ((let open! Ppx_deriving_yojson_runtime in
4785
      function
4786
      | SigAssign arg0 ->
4787
          `List
4788
            [`String "CONDITIONAL_SIGNAL_ASSIGNMENT";
4789
            ((fun x  -> vhdl_conditional_signal_t_to_yojson x)) arg0]
4790
      | Process arg0 ->
4791
          `List
4792
            [`String "PROCESS_STATEMENT";
4793
            ((fun x  -> vhdl_process_t_to_yojson x)) arg0]
4794
      | SelectedSig arg0 ->
4795
          `List
4796
            [`String "SELECTED_SIGNAL_ASSIGNMENT";
4797
            ((fun x  -> vhdl_selected_signal_t_to_yojson x)) arg0])
4798
  [@ocaml.warning "-A"])
4799

    
4800
and (vhdl_concurrent_stmt_t_of_yojson :
4801
      Yojson.Safe.json ->
4802
        vhdl_concurrent_stmt_t Ppx_deriving_yojson_runtime.error_or)
4803
  =
4804
  ((let open! Ppx_deriving_yojson_runtime in
4805
      function
4806
      | `List ((`String "CONDITIONAL_SIGNAL_ASSIGNMENT")::arg0::[]) ->
4807
          ((fun x  -> vhdl_conditional_signal_t_of_yojson x) arg0) >>=
4808
            ((fun arg0  -> Result.Ok (SigAssign arg0)))
4809
      | `List ((`String "PROCESS_STATEMENT")::arg0::[]) ->
4810
          ((fun x  -> vhdl_process_t_of_yojson x) arg0) >>=
4811
            ((fun arg0  -> Result.Ok (Process arg0)))
4812
      | `List ((`String "SELECTED_SIGNAL_ASSIGNMENT")::arg0::[]) ->
4813
          ((fun x  -> vhdl_selected_signal_t_of_yojson x) arg0) >>=
4814
            ((fun arg0  -> Result.Ok (SelectedSig arg0)))
4815
      | _ -> Result.Error "Vhdl_ast.vhdl_concurrent_stmt_t")
4816
  [@ocaml.warning "-A"])
4817

    
4818
type vhdl_port_mode_t =
4819
  | InPort [@name "in"]
4820
  | OutPort [@name "out"]
4821
  | InoutPort [@name "inout"]
4822
  | BufferPort [@name "buffer"]
4823

    
4824
let rec (pp_vhdl_port_mode_t :
4825
          Format.formatter -> vhdl_port_mode_t -> Ppx_deriving_runtime.unit)
4826
  =
4827
  ((let open! Ppx_deriving_runtime in
4828
      fun fmt  ->
4829
        function
4830
        | InPort  -> Format.pp_print_string fmt "in"
4831
        | OutPort  -> Format.pp_print_string fmt "out"
4832
        | InoutPort  -> Format.pp_print_string fmt "inout"
4833
        | BufferPort  -> Format.pp_print_string fmt "buffer")
4834
  [@ocaml.warning "-A"])
4835

    
4836
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string =
4837
  fun x  -> Format.asprintf "%a" pp_vhdl_port_mode_t x
4838

    
4839
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) =
4840
  ((let open! Ppx_deriving_yojson_runtime in
4841
      function
4842
      | InPort  -> `List [`String "in"]
4843
      | OutPort  -> `List [`String "out"]
4844
      | InoutPort  -> `List [`String "inout"]
4845
      | BufferPort  -> `List [`String "buffer"])
4846
  [@ocaml.warning "-A"])
4847

    
4848
and (vhdl_port_mode_t_of_yojson :
4849
      Yojson.Safe.json ->
4850
        vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or)
4851
  =
4852
  ((let open! Ppx_deriving_yojson_runtime in
4853
      function
4854
      | `List ((`String "in")::[]) -> Result.Ok InPort
4855
      | `List ((`String "out")::[]) -> Result.Ok OutPort
4856
      | `List ((`String "inout")::[]) -> Result.Ok InoutPort
4857
      | `List ((`String "buffer")::[]) -> Result.Ok BufferPort
4858
      | _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t")
4859
  [@ocaml.warning "-A"])
4860

    
4861
type vhdl_port_t =
4862
  {
4863
  names: vhdl_name_t list [@default []];
4864
  mode: vhdl_port_mode_t [@default InPort];
4865
  typ: vhdl_subtype_indication_t ;
4866
  expr: vhdl_expr_t [@default IsNull]}
4867

    
4868
let rec pp_vhdl_port_t :
4869
  Format.formatter -> vhdl_port_t -> Ppx_deriving_runtime.unit =
4870
  let __3 () = pp_vhdl_expr_t
4871
  
4872
  and __2 () = pp_vhdl_subtype_indication_t
4873
  
4874
  and __1 () = pp_vhdl_port_mode_t
4875
  
4876
  and __0 () = pp_vhdl_name_t
4877
   in
4878
  ((let open! Ppx_deriving_runtime in
4879
      fun fmt  ->
4880
        fun x  ->
4881
          Format.fprintf fmt "@[";
4882
          ((((
4883
              ((fun x  ->
4884
                  Format.fprintf fmt "@[";
4885
                  ignore
4886
                    (List.fold_left
4887
                       (fun sep  ->
4888
                          fun x  ->
4889
                            if sep then Format.fprintf fmt ",@ ";
4890
                            ((__0 ()) fmt) x;
4891
                            true) false x);
4892
                  Format.fprintf fmt "@,@]")) x.names;
4893
              );
4894
             Format.fprintf fmt ": ";
4895
             ((__1 ()) fmt) x.mode;
4896
             );
4897
             Format.fprintf fmt " ";
4898
            ((__2 ()) fmt) x.typ;
4899
            );
4900
          (match x.expr with
4901
           | IsNull -> Format.fprintf fmt "";
4902
           | _ -> (Format.fprintf fmt "@[:= ";
4903
                   ((__3 ()) fmt) x.expr;
4904
                   Format.fprintf fmt "@]"));
4905
          Format.fprintf fmt "@]"))
4906
    [@ocaml.warning "-A"])
4907

    
4908
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string =
4909
  fun x  -> Format.asprintf "%a" pp_vhdl_port_t x
4910

    
4911
let rec (vhdl_port_t_to_yojson : vhdl_port_t -> Yojson.Safe.json) =
4912
  ((let open! Ppx_deriving_yojson_runtime in
4913
      fun x  ->
4914
        let fields = []  in
4915
        let fields =
4916
          if x.expr = IsNull
4917
          then fields
4918
          else ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) x.expr)) ::
4919
            fields
4920
           in
4921
        let fields =
4922
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
4923
          :: fields  in
4924
        let fields =
4925
          if x.mode = InPort
4926
          then fields
4927
          else ("mode", (((fun x  -> vhdl_port_mode_t_to_yojson x)) x.mode))
4928
            :: fields
4929
           in
4930
        let fields =
4931
          if x.names = []
4932
          then fields
4933
          else
4934
            ("names",
4935
              (((fun x  ->
4936
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
4937
                 x.names))
4938
            :: fields
4939
           in
4940
        `Assoc fields)
4941
  [@ocaml.warning "-A"])
4942

    
4943
and (vhdl_port_t_of_yojson :
4944
      Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
4945
  =
4946
  ((let open! Ppx_deriving_yojson_runtime in
4947
      function
4948
      | `Assoc xs ->
4949
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
4950
            match xs with
4951
            | ("names",x)::xs ->
4952
                loop xs
4953
                  (((function
4954
                     | `List xs ->
4955
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4956
                     | _ -> Result.Error "Vhdl_ast.vhdl_port_t.names") x),
4957
                    arg1, arg2, arg3)
4958
            | ("mode",x)::xs ->
4959
                loop xs
4960
                  (arg0, ((fun x  -> vhdl_port_mode_t_of_yojson x) x), arg2,
4961
                    arg3)
4962
            | ("typ",x)::xs ->
4963
                loop xs
4964
                  (arg0, arg1,
4965
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
4966
                    arg3)
4967
            | ("expr",x)::xs ->
4968
                loop xs
4969
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4970
            | [] ->
4971
                arg3 >>=
4972
                  ((fun arg3  ->
4973
                      arg2 >>=
4974
                        (fun arg2  ->
4975
                           arg1 >>=
4976
                             (fun arg1  ->
4977
                                arg0 >>=
4978
                                  (fun arg0  ->
4979
                                     Result.Ok
4980
                                       {
4981
                                         names = arg0;
4982
                                         mode = arg1;
4983
                                         typ = arg2;
4984
                                         expr = arg3
4985
                                       })))))
4986
            | _::xs -> loop xs _state  in
4987
          loop xs
4988
            ((Result.Ok []), (Result.Ok InPort),
4989
              (Result.Error "Vhdl_ast.vhdl_port_t.typ"), (Result.Ok IsNull))
4990
      | _ -> Result.Error "Vhdl_ast.vhdl_port_t")
4991
  [@ocaml.warning "-A"])
4992

    
4993
type vhdl_entity_t =
4994
  {
4995
  name: vhdl_name_t [@default NoName];
4996
  generics: vhdl_port_t list [@default []];
4997
  ports: vhdl_port_t list [@default []];
4998
  declaration: vhdl_declaration_t list
4999
    [@key "ENTITY_DECLARATIVE_PART"][@default []];
5000
  stmts: vhdl_concurrent_stmt_t list
5001
    [@key "ENTITY_STATEMENT_PART"][@default []]}
5002

    
5003
let rec pp_vhdl_entity_t :
5004
  Format.formatter -> vhdl_entity_t -> Ppx_deriving_runtime.unit =
5005
  let __4 () = pp_vhdl_concurrent_stmt_t
5006
  
5007
  and __3 () = pp_vhdl_declaration_t
5008
  
5009
  and __2 () = pp_vhdl_port_t
5010
  
5011
  and __1 () = pp_vhdl_port_t
5012
  
5013
  and __0 () = pp_vhdl_name_t
5014
   in
5015
  ((let open! Ppx_deriving_runtime in
5016
      fun fmt  ->
5017
        fun x  ->
5018
          (((((
5019
               ((__0 ()) fmt) x.name;
5020
               Format.fprintf fmt " is@ ");
5021
              Format.fprintf fmt "@[<v>";
5022
              ((fun x  ->
5023
                  ignore
5024
                    (List.fold_left
5025
                       (fun sep  ->
5026
                          fun x  ->
5027
                            if sep then Format.fprintf fmt ";@;";
5028
                            ((__1 ()) fmt) x;
5029
                            true) false x))) x.generics;
5030
              Format.fprintf fmt "@]");
5031
             Format.fprintf fmt "port (@[<v>";
5032
             ((fun x  ->
5033
                 ignore
5034
                   (List.fold_left
5035
                      (fun sep  ->
5036
                         fun x  ->
5037
                           if sep then Format.fprintf fmt ";@;";
5038
                           ((__2 ()) fmt) x;
5039
                           true) false x))) x.ports;
5040
             Format.fprintf fmt "@]);");
5041
            Format.fprintf fmt "@[<v>";
5042
            ((fun x  ->
5043
                Format.fprintf fmt "@[";
5044
                ignore
5045
                  (List.fold_left
5046
                     (fun sep  ->
5047
                        fun x  ->
5048
                          if sep then Format.fprintf fmt ";@ ";
5049
                          ((__3 ()) fmt) x;
5050
                          true) false x);
5051
                Format.fprintf fmt "@]")) x.declaration;
5052
            Format.fprintf fmt "@]");
5053
           Format.fprintf fmt "@[<v>";
5054
           ((fun x  ->
5055
               Format.fprintf fmt "@[";
5056
               ignore
5057
                 (List.fold_left
5058
                    (fun sep  ->
5059
                       fun x  ->
5060
                         if sep then Format.fprintf fmt ";@ ";
5061
                         ((__4 ()) fmt) x;
5062
                         true) false x);
5063
               Format.fprintf fmt "@]")) x.stmts;
5064
           Format.fprintf fmt "@]");
5065
          Format.fprintf fmt "@]")
5066
    [@ocaml.warning "-A"])
5067

    
5068
and show_vhdl_entity_t : vhdl_entity_t -> Ppx_deriving_runtime.string =
5069
  fun x  -> Format.asprintf "%a" pp_vhdl_entity_t x
5070

    
5071
let rec (vhdl_entity_t_to_yojson : vhdl_entity_t -> Yojson.Safe.json) =
5072
  ((let open! Ppx_deriving_yojson_runtime in
5073
      fun x  ->
5074
        let fields = []  in
5075
        let fields =
5076
          if x.stmts = []
5077
          then fields
5078
          else
5079
            ("ENTITY_STATEMENT_PART",
5080
              (((fun x  ->
5081
                   `List
5082
                     (List.map (fun x  -> vhdl_concurrent_stmt_t_to_yojson x)
5083
                        x))) x.stmts))
5084
            :: fields
5085
           in
5086
        let fields =
5087
          if x.declaration = []
5088
          then fields
5089
          else
5090
            ("ENTITY_DECLARATIVE_PART",
5091
              (((fun x  ->
5092
                   `List
5093
                     (List.map (fun x  -> vhdl_declaration_t_to_yojson x) x)))
5094
                 x.declaration))
5095
            :: fields
5096
           in
5097
        let fields =
5098
          if x.ports = []
5099
          then fields
5100
          else
5101
            ("ports",
5102
              (((fun x  ->
5103
                   `List (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
5104
                 x.ports))
5105
            :: fields
5106
           in
5107
        let fields =
5108
          if x.generics = []
5109
          then fields
5110
          else
5111
            ("generics",
5112
              (((fun x  ->
5113
                   `List (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
5114
                 x.generics))
5115
            :: fields
5116
           in
5117
        let fields =
5118
          if x.name = NoName
5119
          then fields
5120
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
5121
            fields
5122
           in
5123
        `Assoc fields)
5124
  [@ocaml.warning "-A"])
5125

    
5126
and (vhdl_entity_t_of_yojson :
5127
      Yojson.Safe.json -> vhdl_entity_t Ppx_deriving_yojson_runtime.error_or)
5128
  =
5129
  ((let open! Ppx_deriving_yojson_runtime in
5130
      function
5131
      | `Assoc xs ->
5132
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
5133
            match xs with
5134
            | ("name",x)::xs ->
5135
                loop xs
5136
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3,
5137
                    arg4)
5138
            | ("generics",x)::xs ->
5139
                loop xs
5140
                  (arg0,
5141
                    ((function
5142
                      | `List xs ->
5143
                          map_bind (fun x  -> vhdl_port_t_of_yojson x) [] xs
5144
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.generics")
5145
                       x), arg2, arg3, arg4)
5146
            | ("ports",x)::xs ->
5147
                loop xs
5148
                  (arg0, arg1,
5149
                    ((function
5150
                      | `List xs ->
5151
                          map_bind (fun x  -> vhdl_port_t_of_yojson x) [] xs
5152
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.ports") x),
5153
                    arg3, arg4)
5154
            | ("ENTITY_DECLARATIVE_PART",x)::xs ->
5155
                loop xs
5156
                  (arg0, arg1, arg2,
5157
                    ((function
5158
                      | `List xs ->
5159
                          map_bind (fun x  -> vhdl_declaration_t_of_yojson x)
5160
                            [] xs
5161
                      | _ ->
5162
                          Result.Error "Vhdl_ast.vhdl_entity_t.declaration")
5163
                       x), arg4)
5164
            | ("ENTITY_STATEMENT_PART",x)::xs ->
5165
                loop xs
5166
                  (arg0, arg1, arg2, arg3,
5167
                    ((function
5168
                      | `List xs ->
5169
                          map_bind
5170
                            (fun x  -> vhdl_concurrent_stmt_t_of_yojson x) []
5171
                            xs
5172
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.stmts") x))
5173
            | [] ->
5174
                arg4 >>=
5175
                  ((fun arg4  ->
5176
                      arg3 >>=
5177
                        (fun arg3  ->
5178
                           arg2 >>=
5179
                             (fun arg2  ->
5180
                                arg1 >>=
5181
                                  (fun arg1  ->
5182
                                     arg0 >>=
5183
                                       (fun arg0  ->
5184
                                          Result.Ok
5185
                                            {
5186
                                              name = arg0;
5187
                                              generics = arg1;
5188
                                              ports = arg2;
5189
                                              declaration = arg3;
5190
                                              stmts = arg4
5191
                                            }))))))
5192
            | _::xs -> loop xs _state  in
5193
          loop xs
5194
            ((Result.Ok NoName), (Result.Ok []), (Result.Ok []),
5195
              (Result.Ok []), (Result.Ok []))
5196
      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t")
5197
  [@ocaml.warning "-A"])
5198

    
5199
type vhdl_package_t =
5200
  {
5201
  name: vhdl_name_t [@default NoName];
5202
  shared_defs: vhdl_definition_t list [@default []]}
5203

    
5204
let rec pp_vhdl_package_t :
5205
  Format.formatter -> vhdl_package_t -> Ppx_deriving_runtime.unit =
5206
  let __1 () = pp_vhdl_definition_t
5207
  
5208
  and __0 () = pp_vhdl_name_t
5209
   in
5210
  ((let open! Ppx_deriving_runtime in
5211
      fun fmt  ->
5212
        fun x  ->
5213
          ((__0 ()) fmt) x.name;
5214
          Format.fprintf fmt " is@;";
5215
          ((fun x  ->
5216
             ignore
5217
               (List.fold_left
5218
                  (fun sep  ->
5219
                     fun x  ->
5220
                       if sep then Format.fprintf fmt "";
5221
                       ((__1 ()) fmt) x;
5222
                       Format.fprintf fmt ";";
5223
                       true) false x))) x.shared_defs;)
5224
    [@ocaml.warning "-A"])
5225

    
5226
and show_vhdl_package_t : vhdl_package_t -> Ppx_deriving_runtime.string =
5227
  fun x  -> Format.asprintf "%a" pp_vhdl_package_t x
5228

    
5229
let rec (vhdl_package_t_to_yojson : vhdl_package_t -> Yojson.Safe.json) =
5230
  ((let open! Ppx_deriving_yojson_runtime in
5231
      fun x  ->
5232
        let fields = []  in
5233
        let fields =
5234
          if x.shared_defs = []
5235
          then fields
5236
          else
5237
            ("shared_defs",
5238
              (((fun x  ->
5239
                   `List
5240
                     (List.map (fun x  -> vhdl_definition_t_to_yojson x) x)))
5241
                 x.shared_defs))
5242
            :: fields
5243
           in
5244
        let fields =
5245
          if x.name = NoName
5246
          then fields
5247
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
5248
            fields
5249
           in
5250
        `Assoc fields)
5251
  [@ocaml.warning "-A"])
5252

    
5253
and (vhdl_package_t_of_yojson :
5254
      Yojson.Safe.json -> vhdl_package_t Ppx_deriving_yojson_runtime.error_or)
5255
  =
5256
  ((let open! Ppx_deriving_yojson_runtime in
5257
      function
5258
      | `Assoc xs ->
5259
          let rec loop xs ((arg0,arg1) as _state) =
5260
            match xs with
5261
            | ("name",x)::xs ->
5262
                loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
5263
            | ("shared_defs",x)::xs ->
5264
                loop xs
5265
                  (arg0,
5266
                    ((function
5267
                      | `List xs ->
5268
                          map_bind (fun x  -> vhdl_definition_t_of_yojson x)
5269
                            [] xs
5270
                      | _ ->
5271
                          Result.Error "Vhdl_ast.vhdl_package_t.shared_defs")
5272
                       x))
5273
            | [] ->
5274
                arg1 >>=
5275
                  ((fun arg1  ->
5276
                      arg0 >>=
5277
                        (fun arg0  ->
5278
                           Result.Ok { name = arg0; shared_defs = arg1 })))
5279
            | _::xs -> loop xs _state  in
5280
          loop xs ((Result.Ok NoName), (Result.Ok []))
5281
      | _ -> Result.Error "Vhdl_ast.vhdl_package_t")
5282
  [@ocaml.warning "-A"])
5283

    
5284
type vhdl_load_t =
5285
  | Library of vhdl_name_t list [@name "LIBRARY_CLAUSE"][@default []]
5286
  | Use of vhdl_name_t list [@name "USE_CLAUSE"][@default []]
5287

    
5288
(* Adapted. TODO: check indentation *)
5289
let rec pp_vhdl_load_t :
5290
  Format.formatter -> vhdl_load_t -> Ppx_deriving_runtime.unit =
5291
  let __1 () = pp_vhdl_name_t
5292
  
5293
  and __0 () = pp_vhdl_name_t
5294
   in
5295
  ((let open! Ppx_deriving_runtime in
5296
      fun fmt  ->
5297
        function
5298
        | Library a0 ->
5299
            (Format.fprintf fmt "library ";
5300
             ((fun x  ->
5301
                 ignore
5302
                   (List.fold_left
5303
                      (fun sep  ->
5304
                         fun x  ->
5305
                           if sep then Format.fprintf fmt ".";
5306
                           ((__0 ()) fmt) x;
5307
                           true) false x))) a0;
5308
             Format.fprintf fmt ":")
5309
        | Use a0 ->
5310
            (Format.fprintf fmt "use ";
5311
             ((fun x  ->
5312
                 ignore
5313
                   (List.fold_left
5314
                      (fun sep  ->
5315
                         fun x  ->
5316
                           if sep then Format.fprintf fmt ".";
5317
                           ((__1 ()) fmt) x;
5318
                           true) false x))) a0;
5319
             Format.fprintf fmt ";"))
5320
    [@ocaml.warning "-A"])
5321

    
5322
and show_vhdl_load_t : vhdl_load_t -> Ppx_deriving_runtime.string =
5323
  fun x  -> Format.asprintf "%a" pp_vhdl_load_t x
5324

    
5325
let rec (vhdl_load_t_to_yojson : vhdl_load_t -> Yojson.Safe.json) =
5326
  ((let open! Ppx_deriving_yojson_runtime in
5327
      function
5328
      | Library arg0 ->
5329
          `List
5330
            [`String "LIBRARY_CLAUSE";
5331
            ((fun x  ->
5332
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
5333
      | Use arg0 ->
5334
          `List
5335
            [`String "USE_CLAUSE";
5336
            ((fun x  ->
5337
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0])
5338
  [@ocaml.warning "-A"])
5339

    
5340
and (vhdl_load_t_of_yojson :
5341
      Yojson.Safe.json -> vhdl_load_t Ppx_deriving_yojson_runtime.error_or)
5342
  =
5343
  ((let open! Ppx_deriving_yojson_runtime in
5344
      function
5345
      | `List ((`String "LIBRARY_CLAUSE")::arg0::[]) ->
5346
          ((function
5347
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5348
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
5349
            ((fun arg0  -> Result.Ok (Library arg0)))
5350
      | `List ((`String "USE_CLAUSE")::arg0::[]) ->
5351
          ((function
5352
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5353
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
5354
            ((fun arg0  -> Result.Ok (Use arg0)))
5355
      | _ -> Result.Error "Vhdl_ast.vhdl_load_t")
5356
  [@ocaml.warning "-A"])
5357

    
5358
type vhdl_architecture_t =
5359
  {
5360
  name: vhdl_name_t [@default NoName];
5361
  entity: vhdl_name_t [@default NoName];
5362
  declarations: vhdl_declaration_t list
5363
    [@key "ARCHITECTURE_DECLARATIVE_PART"][@default []];
5364
  body: vhdl_concurrent_stmt_t list
5365
    [@key "ARCHITECTURE_STATEMENT_PART"][@default []]}
5366

    
5367
let rec pp_vhdl_architecture_t :
5368
  Format.formatter -> vhdl_architecture_t -> Ppx_deriving_runtime.unit =
5369
  let __3 () = pp_vhdl_concurrent_stmt_t
5370
  
5371
  and __2 () = pp_vhdl_declaration_t
5372
  
5373
  and __1 () = pp_vhdl_name_t
5374
  
5375
  and __0 () = pp_vhdl_name_t
5376
   in
5377
  ((let open! Ppx_deriving_runtime in
5378
      fun fmt  ->
5379
        fun x  ->
5380
          ((__0 ()) fmt) x.name;
5381
          Format.fprintf fmt " of ";
5382
          ((__1 ()) fmt) x.entity;
5383
          Format.fprintf fmt " is@;";
5384
          ((fun x  ->
5385
             ignore
5386
               (List.fold_left
5387
                  (fun sep  ->
5388
                     fun x  ->
5389
                       if sep then Format.fprintf fmt "@;";
5390
                       ((__2 ()) fmt) x;
5391
                       Format.fprintf fmt ";";
5392
                       true) false x))) x.declarations;
5393
          Format.fprintf fmt "@;";
5394
          (match x.body with
5395
            | [] -> Format.fprintf fmt "";
5396
            | _ -> Format.fprintf fmt "@[<v 2>begin@;";
5397
          ((fun x  ->
5398
               ignore
5399
                 (List.fold_left
5400
                    (fun sep  ->
5401
                       fun x  ->
5402
                         if sep then Format.fprintf fmt "";
5403
                         ((__3 ()) fmt) x;
5404
                         true) false x))) x.body;
5405
          Format.fprintf fmt "@]@;end;"))
5406
    [@ocaml.warning "-A"])
5407

    
5408
and show_vhdl_architecture_t :
5409
  vhdl_architecture_t -> Ppx_deriving_runtime.string =
5410
  fun x  -> Format.asprintf "%a" pp_vhdl_architecture_t x
5411

    
5412
let rec (vhdl_architecture_t_to_yojson :
5413
          vhdl_architecture_t -> Yojson.Safe.json)
5414
  =
5415
  ((let open! Ppx_deriving_yojson_runtime in
5416
      fun x  ->
5417
        let fields = []  in
5418
        let fields =
5419
          if x.body = []
5420
          then fields
5421
          else
5422
            ("ARCHITECTURE_STATEMENT_PART",
5423
              (((fun x  ->
5424
                   `List
5425
                     (List.map (fun x  -> vhdl_concurrent_stmt_t_to_yojson x)
5426
                        x))) x.body))
5427
            :: fields
5428
           in
5429
        let fields =
5430
          if x.declarations = []
5431
          then fields
5432
          else
5433
            ("ARCHITECTURE_DECLARATIVE_PART",
5434
              (((fun x  ->
5435
                   `List
5436
                     (List.map (fun x  -> vhdl_declaration_t_to_yojson x) x)))
5437
                 x.declarations))
5438
            :: fields
5439
           in
5440
        let fields =
5441
          if x.entity = NoName
5442
          then fields
5443
          else ("entity", (((fun x  -> vhdl_name_t_to_yojson x)) x.entity))
5444
            :: fields
5445
           in
5446
        let fields =
5447
          if x.name = NoName
5448
          then fields
5449
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
5450
            fields
5451
           in
5452
        `Assoc fields)
5453
  [@ocaml.warning "-A"])
5454

    
5455
and (vhdl_architecture_t_of_yojson :
5456
      Yojson.Safe.json ->
5457
        vhdl_architecture_t Ppx_deriving_yojson_runtime.error_or)
5458
  =
5459
  ((let open! Ppx_deriving_yojson_runtime in
5460
      function
5461
      | `Assoc xs ->
5462
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
5463
            match xs with
5464
            | ("name",x)::xs ->
5465
                loop xs
5466
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3)
5467
            | ("entity",x)::xs ->
5468
                loop xs
5469
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3)
5470
            | ("ARCHITECTURE_DECLARATIVE_PART",x)::xs ->
5471
                loop xs
5472
                  (arg0, arg1,
5473
                    ((function
5474
                      | `List xs ->
5475
                          map_bind (fun x  -> vhdl_declaration_t_of_yojson x)
5476
                            [] xs
5477
                      | _ ->
5478
                          Result.Error
5479
                            "Vhdl_ast.vhdl_architecture_t.declarations") x),
5480
                    arg3)
5481
            | ("ARCHITECTURE_STATEMENT_PART",x)::xs ->
5482
                loop xs
5483
                  (arg0, arg1, arg2,
5484
                    ((function
5485
                      | `List xs ->
5486
                          map_bind
5487
                            (fun x  -> vhdl_concurrent_stmt_t_of_yojson x) []
5488
                            xs
5489
                      | _