Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / backends / VHDL / vhdl_ast_deriving.ml @ 248eb65e

History | View | Annotate | Download (231 KB)

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

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

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

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

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

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

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

    
260
and show_vhdl_type_t : vhdl_type_t -> Ppx_deriving_runtime.string =
261
  fun x  -> Format.asprintf "%a" pp_vhdl_type_t x
262

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

    
285
and show_vhdl_element_declaration_t :
286
  vhdl_element_declaration_t -> Ppx_deriving_runtime.string =
287
  fun x  -> Format.asprintf "%a" pp_vhdl_element_declaration_t x
288

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

    
309
and show_vhdl_subtype_indication_t :
310
  vhdl_subtype_indication_t -> Ppx_deriving_runtime.string =
311
  fun x  -> Format.asprintf "%a" pp_vhdl_subtype_indication_t x
312

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

    
338
and show_vhdl_discrete_range_t :
339
  vhdl_discrete_range_t -> Ppx_deriving_runtime.string =
340
  fun x  -> Format.asprintf "%a" pp_vhdl_discrete_range_t x
341

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

    
400
and show_vhdl_constraint_t : vhdl_constraint_t -> Ppx_deriving_runtime.string
401
  = fun x  -> Format.asprintf "%a" pp_vhdl_constraint_t x
402

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

    
429
and show_vhdl_definition_t : vhdl_definition_t -> Ppx_deriving_runtime.string
430
  = fun x  -> Format.asprintf "%a" pp_vhdl_definition_t x
431

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

    
541
and show_vhdl_expr_t : vhdl_expr_t -> Ppx_deriving_runtime.string =
542
  fun x  -> Format.asprintf "%a" pp_vhdl_expr_t x
543

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

    
628
and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string =
629
  fun x  -> Format.asprintf "%a" pp_vhdl_name_t x
630

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

    
675
and show_vhdl_assoc_element_t :
676
  vhdl_assoc_element_t -> Ppx_deriving_runtime.string =
677
  fun x  -> Format.asprintf "%a" pp_vhdl_assoc_element_t x
678

    
679
and pp_vhdl_element_assoc_t :
680
  Format.formatter -> vhdl_element_assoc_t -> Ppx_deriving_runtime.unit =
681
  let __1 () = pp_vhdl_expr_t
682
  
683
  and __0 () = pp_vhdl_expr_t
684
   in
685
  ((let open! Ppx_deriving_runtime in
686
      fun fmt  ->
687
        fun x  ->
688
            (match x.choices with
689
            | [] -> Format.fprintf fmt "";
690
            | _ -> 
691
              (((fun x  ->
692
                Format.fprintf fmt "@[<2>[";
693
                ignore
694
                  (List.fold_left
695
                     (fun sep  ->
696
                        fun x  ->
697
                          if sep then Format.fprintf fmt "|@ ";
698
                          ((__0 ()) fmt) x;
699
                          true) false x))) x.choices;
700
              Format.fprintf fmt " => ";));
701
           ((__1 ()) fmt) x.expr)
702
    [@ocaml.warning "-A"])
703

    
704
and show_vhdl_element_assoc_t :
705
  vhdl_element_assoc_t -> Ppx_deriving_runtime.string =
706
  fun x  -> Format.asprintf "%a" pp_vhdl_element_assoc_t x
707

    
708
(* TODO *)
709
and (pp_vhdl_array_attributes_t :
710
      Format.formatter ->
711
        vhdl_array_attributes_t -> Ppx_deriving_runtime.unit)
712
  =
713
  ((let open! Ppx_deriving_runtime in
714
      fun fmt  ->
715
        function
716
        | AAttInt { id = aid; arg = aarg } ->
717
            (Format.fprintf fmt "@[<2>AAttInt {@,";
718
             ((Format.fprintf fmt "@[%s =@ " "id";
719
               (Format.fprintf fmt "%S") aid;
720
               Format.fprintf fmt "@]");
721
              Format.fprintf fmt ";@ ";
722
              Format.fprintf fmt "@[%s =@ " "arg";
723
              (Format.fprintf fmt "%d") aarg;
724
              Format.fprintf fmt "@]");
725
             Format.fprintf fmt "@]}")
726
        | AAttAscending  -> Format.pp_print_string fmt "AAttAscending")
727
  [@ocaml.warning "-A"])
728

    
729
and show_vhdl_array_attributes_t :
730
  vhdl_array_attributes_t -> Ppx_deriving_runtime.string =
731
  fun x  -> Format.asprintf "%a" pp_vhdl_array_attributes_t x
732

    
733
(* TODO *)
734
and (pp_vhdl_signal_attributes_t :
735
      Format.formatter ->
736
        vhdl_signal_attributes_t -> Ppx_deriving_runtime.unit)
737
  =
738
  ((let open! Ppx_deriving_runtime in
739
      fun fmt  ->
740
        function
741
        | SigAtt a0 ->
742
            (Format.fprintf fmt "(@[<2>SigAtt@ ";
743
             (Format.fprintf fmt "%S") a0;
744
             Format.fprintf fmt "@])"))
745
  [@ocaml.warning "-A"])
746

    
747
and show_vhdl_signal_attributes_t :
748
  vhdl_signal_attributes_t -> Ppx_deriving_runtime.string =
749
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_attributes_t x
750

    
751
(* TODO *)
752
and (pp_vhdl_string_attributes_t :
753
      Format.formatter ->
754
        vhdl_string_attributes_t -> Ppx_deriving_runtime.unit)
755
  =
756
  ((let open! Ppx_deriving_runtime in
757
      fun fmt  ->
758
        function
759
        | StringAtt a0 ->
760
            (Format.fprintf fmt "(@[<2>StringAtt@ ";
761
             (Format.fprintf fmt "%S") a0;
762
             Format.fprintf fmt "@])"))
763
  [@ocaml.warning "-A"])
764

    
765
and show_vhdl_string_attributes_t :
766
  vhdl_string_attributes_t -> Ppx_deriving_runtime.string =
767
  fun x  -> Format.asprintf "%a" pp_vhdl_string_attributes_t x
768

    
769
(* TODO *)
770
and (pp_vhdl_suffix_selection_t :
771
      Format.formatter ->
772
        vhdl_suffix_selection_t -> Ppx_deriving_runtime.unit)
773
  =
774
  ((let open! Ppx_deriving_runtime in
775
      fun fmt  ->
776
        function
777
        | Idx a0 ->
778
            (Format.fprintf fmt "(@[<2>Idx@ ";
779
             (Format.fprintf fmt "%d") a0;
780
             Format.fprintf fmt "@])")
781
        | SuffixRange (a0,a1) ->
782
            (Format.fprintf fmt "(@[<2>SuffixRange (@,";
783
             ((Format.fprintf fmt "%d") a0;
784
              Format.fprintf fmt ",@ ";
785
              (Format.fprintf fmt "%d") a1);
786
             Format.fprintf fmt "@,))@]"))
787
  [@ocaml.warning "-A"])
788

    
789
and show_vhdl_suffix_selection_t :
790
  vhdl_suffix_selection_t -> Ppx_deriving_runtime.string =
791
  fun x  -> Format.asprintf "%a" pp_vhdl_suffix_selection_t x
792

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

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

    
959
and (vhdl_element_declaration_t_to_yojson :
960
      vhdl_element_declaration_t -> Yojson.Safe.json)
961
  =
962
  ((let open! Ppx_deriving_yojson_runtime in
963
      fun x  ->
964
        let fields = []  in
965
        let fields =
966
          ("definition",
967
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.definition))
968
          :: fields  in
969
        let fields =
970
          ("names",
971
            ((fun x  ->
972
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
973
               x.names))
974
          :: fields  in
975
        `Assoc fields)
976
  [@ocaml.warning "-A"])
977

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

    
1013
and (vhdl_subtype_indication_t_to_yojson :
1014
      vhdl_subtype_indication_t -> Yojson.Safe.json)
1015
  =
1016
  ((let open! Ppx_deriving_yojson_runtime in
1017
      fun x  ->
1018
        let fields = []  in
1019
        let fields =
1020
          if x.const = NoConstraint
1021
          then fields
1022
          else
1023
            ("const", (((fun x  -> vhdl_constraint_t_to_yojson x)) x.const))
1024
            :: fields
1025
           in
1026
        let fields =
1027
          if x.functionName = NoName
1028
          then fields
1029
          else
1030
            ("functionName",
1031
              (((fun x  -> vhdl_name_t_to_yojson x)) x.functionName))
1032
            :: fields
1033
           in
1034
        let fields =
1035
          if x.name = NoName
1036
          then fields
1037
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
1038
            fields
1039
           in
1040
        `Assoc fields)
1041
  [@ocaml.warning "-A"])
1042

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

    
1079
and (vhdl_discrete_range_t_to_yojson :
1080
      vhdl_discrete_range_t -> Yojson.Safe.json)
1081
  =
1082
  ((let open! Ppx_deriving_yojson_runtime in
1083
      function
1084
      | SubDiscreteRange arg0 ->
1085
          `List
1086
            [`String "SUB_DISCRETE_RANGE";
1087
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x)) arg0]
1088
      | NamedRange arg0 ->
1089
          `List
1090
            [`String "NAMED_RANGE";
1091
            ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
1092
      | DirectedRange arg0 ->
1093
          `List
1094
            [`String "RANGE_WITH_DIRECTION";
1095
            (let fields = []  in
1096
             let fields =
1097
               ("_to", ((fun x  -> vhdl_expr_t_to_yojson x) arg0._to)) ::
1098
               fields  in
1099
             let fields =
1100
               ("from", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.from)) ::
1101
               fields  in
1102
             let fields =
1103
               ("direction",
1104
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
1105
                    arg0.direction))
1106
               :: fields  in
1107
             `Assoc fields)])
1108
  [@ocaml.warning "-A"])
1109

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

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

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

    
1313
and (vhdl_definition_t_to_yojson : vhdl_definition_t -> Yojson.Safe.json) =
1314
  ((let open! Ppx_deriving_yojson_runtime in
1315
      function
1316
      | Type arg0 ->
1317
          `List
1318
            [`String "TYPE_DECLARATION";
1319
            (let fields = []  in
1320
             let fields =
1321
               ("definition",
1322
                 ((fun x  -> vhdl_type_t_to_yojson x) arg0.definition))
1323
               :: fields  in
1324
             let fields =
1325
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1326
               fields  in
1327
             `Assoc fields)]
1328
      | Subtype arg0 ->
1329
          `List
1330
            [`String "SUBTYPE_DECLARATION";
1331
            (let fields = []  in
1332
             let fields =
1333
               ("typ",
1334
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
1335
               :: fields  in
1336
             let fields =
1337
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1338
               fields  in
1339
             `Assoc fields)])
1340
  [@ocaml.warning "-A"])
1341

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

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

    
1493
and (vhdl_expr_t_of_yojson :
1494
      Yojson.Safe.json -> vhdl_expr_t Ppx_deriving_yojson_runtime.error_or)
1495
  =
1496
  ((let open! Ppx_deriving_yojson_runtime in
1497
      function
1498
      | `List ((`String "CALL")::arg0::[]) ->
1499
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
1500
            ((fun arg0  -> Result.Ok (Call arg0)))
1501
      | `List ((`String "CONSTANT_VALUE")::arg0::[]) ->
1502
          ((fun x  -> vhdl_cst_val_t_of_yojson x) arg0) >>=
1503
            ((fun arg0  -> Result.Ok (Cst arg0)))
1504
      | `List ((`String "EXPRESSION")::arg0::[]) ->
1505
          ((function
1506
            | `Assoc xs ->
1507
                let rec loop xs ((arg0,arg1) as _state) =
1508
                  match xs with
1509
                  | ("id",x)::xs ->
1510
                      loop xs
1511
                        (((function
1512
                           | `String x -> Result.Ok x
1513
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.id") x),
1514
                          arg1)
1515
                  | ("args",x)::xs ->
1516
                      loop xs
1517
                        (arg0,
1518
                          ((function
1519
                            | `List xs ->
1520
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1521
                                  [] xs
1522
                            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.args")
1523
                             x))
1524
                  | [] ->
1525
                      arg1 >>=
1526
                        ((fun arg1  ->
1527
                            arg0 >>=
1528
                              (fun arg0  ->
1529
                                 Result.Ok (Op { id = arg0; args = arg1 }))))
1530
                  | _::xs -> loop xs _state  in
1531
                loop xs ((Result.Ok ""), (Result.Ok []))
1532
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1533
      | `List ((`String "IsNull")::[]) -> Result.Ok IsNull
1534
      | `List ((`String "Time")::arg0::[]) ->
1535
          ((function
1536
            | `Assoc xs ->
1537
                let rec loop xs ((arg0,arg1) as _state) =
1538
                  match xs with
1539
                  | ("value",x)::xs ->
1540
                      loop xs
1541
                        (((function
1542
                           | `Int x -> Result.Ok x
1543
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.value")
1544
                            x), arg1)
1545
                  | ("phy_unit",x)::xs ->
1546
                      loop xs
1547
                        (arg0,
1548
                          ((function
1549
                            | `String x -> Result.Ok x
1550
                            | _ ->
1551
                                Result.Error "Vhdl_ast.vhdl_expr_t.phy_unit")
1552
                             x))
1553
                  | [] ->
1554
                      arg1 >>=
1555
                        ((fun arg1  ->
1556
                            arg0 >>=
1557
                              (fun arg0  ->
1558
                                 Result.Ok
1559
                                   (Time { value = arg0; phy_unit = arg1 }))))
1560
                  | _::xs -> loop xs _state  in
1561
                loop xs
1562
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.value"),
1563
                    (Result.Ok ""))
1564
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1565
      | `List ((`String "Sig")::arg0::[]) ->
1566
          ((function
1567
            | `Assoc xs ->
1568
                let rec loop xs ((arg0,arg1) as _state) =
1569
                  match xs with
1570
                  | ("name",x)::xs ->
1571
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1572
                  | ("att",x)::xs ->
1573
                      loop xs
1574
                        (arg0,
1575
                          ((function
1576
                            | `Null -> Result.Ok None
1577
                            | x ->
1578
                                ((fun x  ->
1579
                                    vhdl_signal_attributes_t_of_yojson x) x)
1580
                                  >>= ((fun x  -> Result.Ok (Some x)))) x))
1581
                  | [] ->
1582
                      arg1 >>=
1583
                        ((fun arg1  ->
1584
                            arg0 >>=
1585
                              (fun arg0  ->
1586
                                 Result.Ok (Sig { name = arg0; att = arg1 }))))
1587
                  | _::xs -> loop xs _state  in
1588
                loop xs
1589
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.name"),
1590
                    (Result.Error "Vhdl_ast.vhdl_expr_t.att"))
1591
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1592
      | `List ((`String "SuffixMod")::arg0::[]) ->
1593
          ((function
1594
            | `Assoc xs ->
1595
                let rec loop xs ((arg0,arg1) as _state) =
1596
                  match xs with
1597
                  | ("expr",x)::xs ->
1598
                      loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
1599
                  | ("selection",x)::xs ->
1600
                      loop xs
1601
                        (arg0,
1602
                          ((fun x  -> vhdl_suffix_selection_t_of_yojson x) x))
1603
                  | [] ->
1604
                      arg1 >>=
1605
                        ((fun arg1  ->
1606
                            arg0 >>=
1607
                              (fun arg0  ->
1608
                                 Result.Ok
1609
                                   (SuffixMod
1610
                                      { expr = arg0; selection = arg1 }))))
1611
                  | _::xs -> loop xs _state  in
1612
                loop xs
1613
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.expr"),
1614
                    (Result.Error "Vhdl_ast.vhdl_expr_t.selection"))
1615
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1616
      | `List ((`String "AGGREGATE")::arg0::[]) ->
1617
          ((function
1618
            | `Assoc xs ->
1619
                let rec loop xs (arg0 as _state) =
1620
                  match xs with
1621
                  | ("elems",x)::xs ->
1622
                      loop xs
1623
                        ((function
1624
                          | `List xs ->
1625
                              map_bind
1626
                                (fun x  -> vhdl_element_assoc_t_of_yojson x)
1627
                                [] xs
1628
                          | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.elems") x)
1629
                  | [] ->
1630
                      arg0 >>=
1631
                        ((fun arg0  -> Result.Ok (Aggregate { elems = arg0 })))
1632
                  | _::xs -> loop xs _state  in
1633
                loop xs (Result.Error "Vhdl_ast.vhdl_expr_t.elems")
1634
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1635
      | `List ((`String "OTHERS")::[]) -> Result.Ok Others
1636
      | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")
1637
  [@ocaml.warning "-A"])
1638

    
1639
and (vhdl_name_t_to_yojson : vhdl_name_t -> Yojson.Safe.json) =
1640
  ((let open! Ppx_deriving_yojson_runtime in
1641
      function
1642
      | Simple arg0 ->
1643
          `List
1644
            [`String "SIMPLE_NAME";
1645
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1646
      | Identifier arg0 ->
1647
          `List
1648
            [`String "IDENTIFIER";
1649
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1650
      | Selected arg0 ->
1651
          `List
1652
            [`String "SELECTED_NAME";
1653
            ((fun x  ->
1654
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
1655
      | Index arg0 ->
1656
          `List
1657
            [`String "INDEXED_NAME";
1658
            (let fields = []  in
1659
             let fields =
1660
               ("exprs",
1661
                 ((fun x  ->
1662
                     `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
1663
                    arg0.exprs))
1664
               :: fields  in
1665
             let fields =
1666
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1667
               fields  in
1668
             `Assoc fields)]
1669
      | Slice arg0 ->
1670
          `List
1671
            [`String "SLICE_NAME";
1672
            (let fields = []  in
1673
             let fields =
1674
               ("range",
1675
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
1676
               :: fields  in
1677
             let fields =
1678
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1679
               fields  in
1680
             `Assoc fields)]
1681
      | Attribute arg0 ->
1682
          `List
1683
            [`String "ATTRIBUTE_NAME";
1684
            (let fields = []  in
1685
             let fields =
1686
               if arg0.expr = IsNull
1687
               then fields
1688
               else
1689
                 ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.expr))
1690
                 :: fields
1691
                in
1692
             let fields =
1693
               ("designator",
1694
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.designator))
1695
               :: fields  in
1696
             let fields =
1697
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1698
               fields  in
1699
             `Assoc fields)]
1700
      | Function arg0 ->
1701
          `List
1702
            [`String "FUNCTION_CALL";
1703
            (let fields = []  in
1704
             let fields =
1705
               ("assoc_list",
1706
                 ((fun x  ->
1707
                     `List
1708
                       (List.map (fun x  -> vhdl_assoc_element_t_to_yojson x)
1709
                          x)) arg0.assoc_list))
1710
               :: fields  in
1711
             let fields =
1712
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1713
               fields  in
1714
             `Assoc fields)]
1715
      | NoName  -> `List [`String "NoName"])
1716
  [@ocaml.warning "-A"])
1717

    
1718
and (vhdl_name_t_of_yojson :
1719
      Yojson.Safe.json -> vhdl_name_t Ppx_deriving_yojson_runtime.error_or)
1720
  =
1721
  ((let open! Ppx_deriving_yojson_runtime in
1722
      function
1723
      | `List ((`String "SIMPLE_NAME")::arg0::[]) ->
1724
          ((function
1725
            | `String x -> Result.Ok x
1726
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1727
            ((fun arg0  -> Result.Ok (Simple arg0)))
1728
      | `List ((`String "IDENTIFIER")::arg0::[]) ->
1729
          ((function
1730
            | `String x -> Result.Ok x
1731
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1732
            ((fun arg0  -> Result.Ok (Identifier arg0)))
1733
      | `List ((`String "SELECTED_NAME")::arg0::[]) ->
1734
          ((function
1735
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1736
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1737
            ((fun arg0  -> Result.Ok (Selected arg0)))
1738
      | `List ((`String "INDEXED_NAME")::arg0::[]) ->
1739
          ((function
1740
            | `Assoc xs ->
1741
                let rec loop xs ((arg0,arg1) as _state) =
1742
                  match xs with
1743
                  | ("id",x)::xs ->
1744
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1745
                  | ("exprs",x)::xs ->
1746
                      loop xs
1747
                        (arg0,
1748
                          ((function
1749
                            | `List xs ->
1750
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1751
                                  [] xs
1752
                            | _ -> Result.Error "Vhdl_ast.vhdl_name_t.exprs")
1753
                             x))
1754
                  | [] ->
1755
                      arg1 >>=
1756
                        ((fun arg1  ->
1757
                            arg0 >>=
1758
                              (fun arg0  ->
1759
                                 Result.Ok
1760
                                   (Index { id = arg0; exprs = arg1 }))))
1761
                  | _::xs -> loop xs _state  in
1762
                loop xs
1763
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1764
                    (Result.Error "Vhdl_ast.vhdl_name_t.exprs"))
1765
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1766
      | `List ((`String "SLICE_NAME")::arg0::[]) ->
1767
          ((function
1768
            | `Assoc xs ->
1769
                let rec loop xs ((arg0,arg1) as _state) =
1770
                  match xs with
1771
                  | ("id",x)::xs ->
1772
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1773
                  | ("range",x)::xs ->
1774
                      loop xs
1775
                        (arg0,
1776
                          ((fun x  -> vhdl_discrete_range_t_of_yojson x) x))
1777
                  | [] ->
1778
                      arg1 >>=
1779
                        ((fun arg1  ->
1780
                            arg0 >>=
1781
                              (fun arg0  ->
1782
                                 Result.Ok
1783
                                   (Slice { id = arg0; range = arg1 }))))
1784
                  | _::xs -> loop xs _state  in
1785
                loop xs
1786
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1787
                    (Result.Error "Vhdl_ast.vhdl_name_t.range"))
1788
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1789
      | `List ((`String "ATTRIBUTE_NAME")::arg0::[]) ->
1790
          ((function
1791
            | `Assoc xs ->
1792
                let rec loop xs ((arg0,arg1,arg2) as _state) =
1793
                  match xs with
1794
                  | ("id",x)::xs ->
1795
                      loop xs
1796
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
1797
                  | ("designator",x)::xs ->
1798
                      loop xs
1799
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
1800
                  | ("expr",x)::xs ->
1801
                      loop xs
1802
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1803
                  | [] ->
1804
                      arg2 >>=
1805
                        ((fun arg2  ->
1806
                            arg1 >>=
1807
                              (fun arg1  ->
1808
                                 arg0 >>=
1809
                                   (fun arg0  ->
1810
                                      Result.Ok
1811
                                        (Attribute
1812
                                           {
1813
                                             id = arg0;
1814
                                             designator = arg1;
1815
                                             expr = arg2
1816
                                           })))))
1817
                  | _::xs -> loop xs _state  in
1818
                loop xs
1819
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1820
                    (Result.Error "Vhdl_ast.vhdl_name_t.designator"),
1821
                    (Result.Ok IsNull))
1822
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1823
      | `List ((`String "FUNCTION_CALL")::arg0::[]) ->
1824
          ((function
1825
            | `Assoc xs ->
1826
                let rec loop xs ((arg0,arg1) as _state) =
1827
                  match xs with
1828
                  | ("id",x)::xs ->
1829
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1830
                  | ("assoc_list",x)::xs ->
1831
                      loop xs
1832
                        (arg0,
1833
                          ((function
1834
                            | `List xs ->
1835
                                map_bind
1836
                                  (fun x  -> vhdl_assoc_element_t_of_yojson x)
1837
                                  [] xs
1838
                            | _ ->
1839
                                Result.Error
1840
                                  "Vhdl_ast.vhdl_name_t.assoc_list") x))
1841
                  | [] ->
1842
                      arg1 >>=
1843
                        ((fun arg1  ->
1844
                            arg0 >>=
1845
                              (fun arg0  ->
1846
                                 Result.Ok
1847
                                   (Function { id = arg0; assoc_list = arg1 }))))
1848
                  | _::xs -> loop xs _state  in
1849
                loop xs
1850
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1851
                    (Result.Error "Vhdl_ast.vhdl_name_t.assoc_list"))
1852
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1853
      | `List ((`String "NoName")::[]) -> Result.Ok NoName
1854
      | _ -> Result.Error "Vhdl_ast.vhdl_name_t")
1855
  [@ocaml.warning "-A"])
1856

    
1857
and (vhdl_assoc_element_t_to_yojson :
1858
      vhdl_assoc_element_t -> Yojson.Safe.json)
1859
  =
1860
  ((let open! Ppx_deriving_yojson_runtime in
1861
      fun x  ->
1862
        let fields = []  in
1863
        let fields =
1864
          if x.actual_expr = None
1865
          then fields
1866
          else
1867
            ("actual_expr",
1868
              (((function
1869
                 | None  -> `Null
1870
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
1871
                 x.actual_expr))
1872
            :: fields
1873
           in
1874
        let fields =
1875
          if x.actual_designator = None
1876
          then fields
1877
          else
1878
            ("actual_designator",
1879
              (((function
1880
                 | None  -> `Null
1881
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1882
                 x.actual_designator))
1883
            :: fields
1884
           in
1885
        let fields =
1886
          if x.actual_name = None
1887
          then fields
1888
          else
1889
            ("actual_name",
1890
              (((function
1891
                 | None  -> `Null
1892
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1893
                 x.actual_name))
1894
            :: fields
1895
           in
1896
        let fields =
1897
          if x.formal_arg = None
1898
          then fields
1899
          else
1900
            ("formal_arg",
1901
              (((function
1902
                 | None  -> `Null
1903
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1904
                 x.formal_arg))
1905
            :: fields
1906
           in
1907
        let fields =
1908
          if x.formal_name = None
1909
          then fields
1910
          else
1911
            ("formal_name",
1912
              (((function
1913
                 | None  -> `Null
1914
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1915
                 x.formal_name))
1916
            :: fields
1917
           in
1918
        `Assoc fields)
1919
  [@ocaml.warning "-A"])
1920

    
1921
and (vhdl_assoc_element_t_of_yojson :
1922
      Yojson.Safe.json ->
1923
        vhdl_assoc_element_t Ppx_deriving_yojson_runtime.error_or)
1924
  =
1925
  ((let open! Ppx_deriving_yojson_runtime in
1926
      function
1927
      | `Assoc xs ->
1928
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
1929
            match xs with
1930
            | ("formal_name",x)::xs ->
1931
                loop xs
1932
                  (((function
1933
                     | `Null -> Result.Ok None
1934
                     | x ->
1935
                         ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1936
                           ((fun x  -> Result.Ok (Some x)))) x), arg1, arg2,
1937
                    arg3, arg4)
1938
            | ("formal_arg",x)::xs ->
1939
                loop xs
1940
                  (arg0,
1941
                    ((function
1942
                      | `Null -> Result.Ok None
1943
                      | x ->
1944
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1945
                            ((fun x  -> Result.Ok (Some x)))) x), arg2, arg3,
1946
                    arg4)
1947
            | ("actual_name",x)::xs ->
1948
                loop xs
1949
                  (arg0, arg1,
1950
                    ((function
1951
                      | `Null -> Result.Ok None
1952
                      | x ->
1953
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1954
                            ((fun x  -> Result.Ok (Some x)))) x), arg3, arg4)
1955
            | ("actual_designator",x)::xs ->
1956
                loop xs
1957
                  (arg0, arg1, arg2,
1958
                    ((function
1959
                      | `Null -> Result.Ok None
1960
                      | x ->
1961
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1962
                            ((fun x  -> Result.Ok (Some x)))) x), arg4)
1963
            | ("actual_expr",x)::xs ->
1964
                loop xs
1965
                  (arg0, arg1, arg2, arg3,
1966
                    ((function
1967
                      | `Null -> Result.Ok None
1968
                      | x ->
1969
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
1970
                            ((fun x  -> Result.Ok (Some x)))) x))
1971
            | [] ->
1972
                arg4 >>=
1973
                  ((fun arg4  ->
1974
                      arg3 >>=
1975
                        (fun arg3  ->
1976
                           arg2 >>=
1977
                             (fun arg2  ->
1978
                                arg1 >>=
1979
                                  (fun arg1  ->
1980
                                     arg0 >>=
1981
                                       (fun arg0  ->
1982
                                          Result.Ok
1983
                                            {
1984
                                              formal_name = arg0;
1985
                                              formal_arg = arg1;
1986
                                              actual_name = arg2;
1987
                                              actual_designator = arg3;
1988
                                              actual_expr = arg4
1989
                                            }))))))
1990
            | _::xs -> loop xs _state  in
1991
          loop xs
1992
            ((Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
1993
              (Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
1994
              (Result.Ok (Some IsNull)))
1995
      | _ -> Result.Error "Vhdl_ast.vhdl_assoc_element_t")
1996
  [@ocaml.warning "-A"])
1997

    
1998
and (vhdl_element_assoc_t_to_yojson :
1999
      vhdl_element_assoc_t -> Yojson.Safe.json)
2000
  =
2001
  ((let open! Ppx_deriving_yojson_runtime in
2002
      fun x  ->
2003
        let fields = []  in
2004
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
2005
          :: fields  in
2006
        let fields =
2007
          ("choices",
2008
            ((fun x  ->
2009
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
2010
               x.choices))
2011
          :: fields  in
2012
        `Assoc fields)
2013
  [@ocaml.warning "-A"])
2014

    
2015
and (vhdl_element_assoc_t_of_yojson :
2016
      Yojson.Safe.json ->
2017
        vhdl_element_assoc_t Ppx_deriving_yojson_runtime.error_or)
2018
  =
2019
  ((let open! Ppx_deriving_yojson_runtime in
2020
      function
2021
      | `Assoc xs ->
2022
          let rec loop xs ((arg0,arg1) as _state) =
2023
            match xs with
2024
            | ("choices",x)::xs ->
2025
                loop xs
2026
                  (((function
2027
                     | `List xs ->
2028
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
2029
                     | _ ->
2030
                         Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices")
2031
                      x), arg1)
2032
            | ("expr",x)::xs ->
2033
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
2034
            | [] ->
2035
                arg1 >>=
2036
                  ((fun arg1  ->
2037
                      arg0 >>=
2038
                        (fun arg0  ->
2039
                           Result.Ok { choices = arg0; expr = arg1 })))
2040
            | _::xs -> loop xs _state  in
2041
          loop xs
2042
            ((Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices"),
2043
              (Result.Error "Vhdl_ast.vhdl_element_assoc_t.expr"))
2044
      | _ -> Result.Error "Vhdl_ast.vhdl_element_assoc_t")
2045
  [@ocaml.warning "-A"])
2046

    
2047
and (vhdl_array_attributes_t_to_yojson :
2048
      vhdl_array_attributes_t -> Yojson.Safe.json)
2049
  =
2050
  ((let open! Ppx_deriving_yojson_runtime in
2051
      function
2052
      | AAttInt arg0 ->
2053
          `List
2054
            [`String "AAttInt";
2055
            (let fields = []  in
2056
             let fields =
2057
               ("arg",
2058
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
2059
               :: fields  in
2060
             let fields =
2061
               ("id",
2062
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2063
                    arg0.id))
2064
               :: fields  in
2065
             `Assoc fields)]
2066
      | AAttAscending  -> `List [`String "AAttAscending"])
2067
  [@ocaml.warning "-A"])
2068

    
2069
and (vhdl_array_attributes_t_of_yojson :
2070
      Yojson.Safe.json ->
2071
        vhdl_array_attributes_t Ppx_deriving_yojson_runtime.error_or)
2072
  =
2073
  ((let open! Ppx_deriving_yojson_runtime in
2074
      function
2075
      | `List ((`String "AAttInt")::arg0::[]) ->
2076
          ((function
2077
            | `Assoc xs ->
2078
                let rec loop xs ((arg0,arg1) as _state) =
2079
                  match xs with
2080
                  | ("id",x)::xs ->
2081
                      loop xs
2082
                        (((function
2083
                           | `String x -> Result.Ok x
2084
                           | _ ->
2085
                               Result.Error
2086
                                 "Vhdl_ast.vhdl_array_attributes_t.id") x),
2087
                          arg1)
2088
                  | ("arg",x)::xs ->
2089
                      loop xs
2090
                        (arg0,
2091
                          ((function
2092
                            | `Int x -> Result.Ok x
2093
                            | _ ->
2094
                                Result.Error
2095
                                  "Vhdl_ast.vhdl_array_attributes_t.arg") x))
2096
                  | [] ->
2097
                      arg1 >>=
2098
                        ((fun arg1  ->
2099
                            arg0 >>=
2100
                              (fun arg0  ->
2101
                                 Result.Ok
2102
                                   (AAttInt { id = arg0; arg = arg1 }))))
2103
                  | _::xs -> loop xs _state  in
2104
                loop xs
2105
                  ((Result.Error "Vhdl_ast.vhdl_array_attributes_t.id"),
2106
                    (Result.Error "Vhdl_ast.vhdl_array_attributes_t.arg"))
2107
            | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")) arg0
2108
      | `List ((`String "AAttAscending")::[]) -> Result.Ok AAttAscending
2109
      | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")
2110
  [@ocaml.warning "-A"])
2111

    
2112
and (vhdl_signal_attributes_t_to_yojson :
2113
      vhdl_signal_attributes_t -> Yojson.Safe.json)
2114
  =
2115
  ((let open! Ppx_deriving_yojson_runtime in
2116
      function
2117
      | SigAtt arg0 ->
2118
          `List
2119
            [`String "SigAtt";
2120
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
2121
  [@ocaml.warning "-A"])
2122

    
2123
and (vhdl_signal_attributes_t_of_yojson :
2124
      Yojson.Safe.json ->
2125
        vhdl_signal_attributes_t Ppx_deriving_yojson_runtime.error_or)
2126
  =
2127
  ((let open! Ppx_deriving_yojson_runtime in
2128
      function
2129
      | `List ((`String "SigAtt")::arg0::[]) ->
2130
          ((function
2131
            | `String x -> Result.Ok x
2132
            | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t") arg0)
2133
            >>= ((fun arg0  -> Result.Ok (SigAtt arg0)))
2134
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t")
2135
  [@ocaml.warning "-A"])
2136

    
2137
and (vhdl_string_attributes_t_to_yojson :
2138
      vhdl_string_attributes_t -> Yojson.Safe.json)
2139
  =
2140
  ((let open! Ppx_deriving_yojson_runtime in
2141
      function
2142
      | StringAtt arg0 ->
2143
          `List
2144
            [`String "StringAtt";
2145
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
2146
  [@ocaml.warning "-A"])
2147

    
2148
and (vhdl_string_attributes_t_of_yojson :
2149
      Yojson.Safe.json ->
2150
        vhdl_string_attributes_t Ppx_deriving_yojson_runtime.error_or)
2151
  =
2152
  ((let open! Ppx_deriving_yojson_runtime in
2153
      function
2154
      | `List ((`String "StringAtt")::arg0::[]) ->
2155
          ((function
2156
            | `String x -> Result.Ok x
2157
            | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t") arg0)
2158
            >>= ((fun arg0  -> Result.Ok (StringAtt arg0)))
2159
      | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t")
2160
  [@ocaml.warning "-A"])
2161

    
2162
and (vhdl_suffix_selection_t_to_yojson :
2163
      vhdl_suffix_selection_t -> Yojson.Safe.json)
2164
  =
2165
  ((let open! Ppx_deriving_yojson_runtime in
2166
      function
2167
      | Idx arg0 ->
2168
          `List
2169
            [`String "Idx";
2170
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0]
2171
      | SuffixRange (arg0,arg1) ->
2172
          `List
2173
            [`String "SuffixRange";
2174
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
2175
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1])
2176
  [@ocaml.warning "-A"])
2177

    
2178
and (vhdl_suffix_selection_t_of_yojson :
2179
      Yojson.Safe.json ->
2180
        vhdl_suffix_selection_t Ppx_deriving_yojson_runtime.error_or)
2181
  =
2182
  ((let open! Ppx_deriving_yojson_runtime in
2183
      function
2184
      | `List ((`String "Idx")::arg0::[]) ->
2185
          ((function
2186
            | `Int x -> Result.Ok x
2187
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg0) >>=
2188
            ((fun arg0  -> Result.Ok (Idx arg0)))
2189
      | `List ((`String "SuffixRange")::arg0::arg1::[]) ->
2190
          ((function
2191
            | `Int x -> Result.Ok x
2192
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg1) >>=
2193
            ((fun arg1  ->
2194
                ((function
2195
                  | `Int x -> Result.Ok x
2196
                  | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2197
                   arg0)
2198
                  >>= (fun arg0  -> Result.Ok (SuffixRange (arg0, arg1)))))
2199
      | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2200
  [@ocaml.warning "-A"])
2201

    
2202
type 'basetype vhdl_type_attributes_t =
2203
  | TAttNoArg of {
2204
  id: string } 
2205
  | TAttIntArg of {
2206
  id: string ;
2207
  arg: int } 
2208
  | TAttValArg of {
2209
  id: string ;
2210
  arg: 'basetype } 
2211
  | TAttStringArg of {
2212
  id: string ;
2213
  arg: string } 
2214

    
2215
(* TODO *)
2216
let rec pp_vhdl_type_attributes_t
2217
  =
2218
  ((let open! Ppx_deriving_runtime in
2219
      fun poly_basetype  ->
2220
        fun fmt  ->
2221
          function
2222
          | TAttNoArg { id = aid } ->
2223
              (Format.fprintf fmt "@[<2>TAttNoArg {@,";
2224
               (Format.fprintf fmt "@[%s =@ " "id";
2225
                (Format.fprintf fmt "%S") aid;
2226
                Format.fprintf fmt "@]");
2227
               Format.fprintf fmt "@]}")
2228
          | TAttIntArg { id = aid; arg = aarg } ->
2229
              (Format.fprintf fmt "@[<2>TAttIntArg {@,";
2230
               ((Format.fprintf fmt "@[%s =@ " "id";
2231
                 (Format.fprintf fmt "%S") aid;
2232
                 Format.fprintf fmt "@]");
2233
                Format.fprintf fmt ";@ ";
2234
                Format.fprintf fmt "@[%s =@ " "arg";
2235
                (Format.fprintf fmt "%d") aarg;
2236
                Format.fprintf fmt "@]");
2237
               Format.fprintf fmt "@]}")
2238
          | TAttValArg { id = aid; arg = aarg } ->
2239
              (Format.fprintf fmt "@[<2>TAttValArg {@,";
2240
               ((Format.fprintf fmt "@[%s =@ " "id";
2241
                 (Format.fprintf fmt "%S") aid;
2242
                 Format.fprintf fmt "@]");
2243
                Format.fprintf fmt ";@ ";
2244
                Format.fprintf fmt "@[%s =@ " "arg";
2245
                (poly_basetype fmt) aarg;
2246
                Format.fprintf fmt "@]");
2247
               Format.fprintf fmt "@]}")
2248
          | TAttStringArg { id = aid; arg = aarg } ->
2249
              (Format.fprintf fmt "@[<2>TAttStringArg {@,";
2250
               ((Format.fprintf fmt "@[%s =@ " "id";
2251
                 (Format.fprintf fmt "%S") aid;
2252
                 Format.fprintf fmt "@]");
2253
                Format.fprintf fmt ";@ ";
2254
                Format.fprintf fmt "@[%s =@ " "arg";
2255
                (Format.fprintf fmt "%S") aarg;
2256
                Format.fprintf fmt "@]");
2257
               Format.fprintf fmt "@]}"))
2258
  [@ocaml.warning "-A"])
2259

    
2260
and show_vhdl_type_attributes_t  =
2261
  fun poly_basetype  ->
2262
    fun x  ->
2263
      Format.asprintf "%a" (pp_vhdl_type_attributes_t poly_basetype) x
2264

    
2265
let rec vhdl_type_attributes_t_to_yojson :
2266
  'basetype .
2267
    ('basetype -> Yojson.Safe.json) ->
2268
      'basetype vhdl_type_attributes_t -> Yojson.Safe.json
2269
  =
2270
  fun poly_basetype  ->
2271
    ((let open! Ppx_deriving_yojson_runtime in
2272
        function
2273
        | TAttNoArg arg0 ->
2274
            `List
2275
              [`String "TAttNoArg";
2276
              (let fields = []  in
2277
               let fields =
2278
                 ("id",
2279
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2280
                      arg0.id))
2281
                 :: fields  in
2282
               `Assoc fields)]
2283
        | TAttIntArg arg0 ->
2284
            `List
2285
              [`String "TAttIntArg";
2286
              (let fields = []  in
2287
               let fields =
2288
                 ("arg",
2289
                   ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
2290
                 :: fields  in
2291
               let fields =
2292
                 ("id",
2293
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2294
                      arg0.id))
2295
                 :: fields  in
2296
               `Assoc fields)]
2297
        | TAttValArg arg0 ->
2298
            `List
2299
              [`String "TAttValArg";
2300
              (let fields = []  in
2301
               let fields =
2302
                 ("arg", ((poly_basetype : _ -> Yojson.Safe.json) arg0.arg))
2303
                 :: fields  in
2304
               let fields =
2305
                 ("id",
2306
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2307
                      arg0.id))
2308
                 :: fields  in
2309
               `Assoc fields)]
2310
        | TAttStringArg arg0 ->
2311
            `List
2312
              [`String "TAttStringArg";
2313
              (let fields = []  in
2314
               let fields =
2315
                 ("arg",
2316
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2317
                      arg0.arg))
2318
                 :: fields  in
2319
               let fields =
2320
                 ("id",
2321
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2322
                      arg0.id))
2323
                 :: fields  in
2324
               `Assoc fields)])
2325
    [@ocaml.warning "-A"])
2326

    
2327
and vhdl_type_attributes_t_of_yojson :
2328
  'basetype .
2329
    (Yojson.Safe.json -> 'basetype Ppx_deriving_yojson_runtime.error_or) ->
2330
      Yojson.Safe.json ->
2331
        'basetype vhdl_type_attributes_t Ppx_deriving_yojson_runtime.error_or
2332
  =
2333
  fun poly_basetype  ->
2334
    ((let open! Ppx_deriving_yojson_runtime in
2335
        function
2336
        | `List ((`String "TAttNoArg")::arg0::[]) ->
2337
            ((function
2338
              | `Assoc xs ->
2339
                  let rec loop xs (arg0 as _state) =
2340
                    match xs with
2341
                    | ("id",x)::xs ->
2342
                        loop xs
2343
                          ((function
2344
                            | `String x -> Result.Ok x
2345
                            | _ ->
2346
                                Result.Error
2347
                                  "Vhdl_ast.vhdl_type_attributes_t.id") x)
2348
                    | [] ->
2349
                        arg0 >>=
2350
                          ((fun arg0  -> Result.Ok (TAttNoArg { id = arg0 })))
2351
                    | _::xs -> loop xs _state  in
2352
                  loop xs (Result.Error "Vhdl_ast.vhdl_type_attributes_t.id")
2353
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2354
        | `List ((`String "TAttIntArg")::arg0::[]) ->
2355
            ((function
2356
              | `Assoc xs ->
2357
                  let rec loop xs ((arg0,arg1) as _state) =
2358
                    match xs with
2359
                    | ("id",x)::xs ->
2360
                        loop xs
2361
                          (((function
2362
                             | `String x -> Result.Ok x
2363
                             | _ ->
2364
                                 Result.Error
2365
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2366
                            arg1)
2367
                    | ("arg",x)::xs ->
2368
                        loop xs
2369
                          (arg0,
2370
                            ((function
2371
                              | `Int x -> Result.Ok x
2372
                              | _ ->
2373
                                  Result.Error
2374
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2375
                    | [] ->
2376
                        arg1 >>=
2377
                          ((fun arg1  ->
2378
                              arg0 >>=
2379
                                (fun arg0  ->
2380
                                   Result.Ok
2381
                                     (TAttIntArg { id = arg0; arg = arg1 }))))
2382
                    | _::xs -> loop xs _state  in
2383
                  loop xs
2384
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2385
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2386
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2387
        | `List ((`String "TAttValArg")::arg0::[]) ->
2388
            ((function
2389
              | `Assoc xs ->
2390
                  let rec loop xs ((arg0,arg1) as _state) =
2391
                    match xs with
2392
                    | ("id",x)::xs ->
2393
                        loop xs
2394
                          (((function
2395
                             | `String x -> Result.Ok x
2396
                             | _ ->
2397
                                 Result.Error
2398
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2399
                            arg1)
2400
                    | ("arg",x)::xs ->
2401
                        loop xs
2402
                          (arg0,
2403
                            ((poly_basetype : Yojson.Safe.json -> _ error_or)
2404
                               x))
2405
                    | [] ->
2406
                        arg1 >>=
2407
                          ((fun arg1  ->
2408
                              arg0 >>=
2409
                                (fun arg0  ->
2410
                                   Result.Ok
2411
                                     (TAttValArg { id = arg0; arg = arg1 }))))
2412
                    | _::xs -> loop xs _state  in
2413
                  loop xs
2414
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2415
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2416
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2417
        | `List ((`String "TAttStringArg")::arg0::[]) ->
2418
            ((function
2419
              | `Assoc xs ->
2420
                  let rec loop xs ((arg0,arg1) as _state) =
2421
                    match xs with
2422
                    | ("id",x)::xs ->
2423
                        loop xs
2424
                          (((function
2425
                             | `String x -> Result.Ok x
2426
                             | _ ->
2427
                                 Result.Error
2428
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2429
                            arg1)
2430
                    | ("arg",x)::xs ->
2431
                        loop xs
2432
                          (arg0,
2433
                            ((function
2434
                              | `String x -> Result.Ok x
2435
                              | _ ->
2436
                                  Result.Error
2437
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2438
                    | [] ->
2439
                        arg1 >>=
2440
                          ((fun arg1  ->
2441
                              arg0 >>=
2442
                                (fun arg0  ->
2443
                                   Result.Ok
2444
                                     (TAttStringArg { id = arg0; arg = arg1 }))))
2445
                    | _::xs -> loop xs _state  in
2446
                  loop xs
2447
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2448
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2449
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2450
        | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")
2451
    [@ocaml.warning "-A"])
2452

    
2453
let typ_att_noarg = ["base"; "left"; "right"; "high"; "low"] 
2454
let typ_att_intarg = ["pos"; "val"; "succ"; "pred"; "leftof"; "rightof"] 
2455
let typ_att_valarg = ["image"] 
2456
let typ_att_stringarg = ["value"] 
2457
let array_att_intarg =
2458
  ["left"; "right"; "high"; "low"; "range"; "reverse_range"; "length"] 
2459
type vhdl_parameter_t =
2460
  {
2461
  names: vhdl_name_t list ;
2462
  mode: string list [@default []];
2463
  typ: vhdl_subtype_indication_t ;
2464
  init_val: vhdl_cst_val_t option [@default None]}
2465

    
2466
(* TODO *)
2467
let rec pp_vhdl_parameter_t :
2468
  Format.formatter -> vhdl_parameter_t -> Ppx_deriving_runtime.unit =
2469
  let __2 () = pp_vhdl_cst_val_t
2470
  
2471
  and __1 () = pp_vhdl_subtype_indication_t
2472
  
2473
  and __0 () = pp_vhdl_name_t
2474
   in
2475
  ((let open! Ppx_deriving_runtime in
2476
      fun fmt  ->
2477
        fun x  ->
2478
          Format.fprintf fmt "@[<2>{ ";
2479
          ((((Format.fprintf fmt "@[%s =@ " "names";
2480
              ((fun x  ->
2481
                  Format.fprintf fmt "@[<2>[";
2482
                  ignore
2483
                    (List.fold_left
2484
                       (fun sep  ->
2485
                          fun x  ->
2486
                            if sep then Format.fprintf fmt ";@ ";
2487
                            ((__0 ()) fmt) x;
2488
                            true) false x);
2489
                  Format.fprintf fmt "@,]@]")) x.names;
2490
              Format.fprintf fmt "@]");
2491
             Format.fprintf fmt ";@ ";
2492
             Format.fprintf fmt "@[%s =@ " "mode";
2493
             ((fun x  ->
2494
                 Format.fprintf fmt "@[<2>[";
2495
                 ignore
2496
                   (List.fold_left
2497
                      (fun sep  ->
2498
                         fun x  ->
2499
                           if sep then Format.fprintf fmt ";@ ";
2500
                           (Format.fprintf fmt "%S") x;
2501
                           true) false x);
2502
                 Format.fprintf fmt "@,]@]")) x.mode;
2503
             Format.fprintf fmt "@]");
2504
            Format.fprintf fmt ";@ ";
2505
            Format.fprintf fmt "@[%s =@ " "typ";
2506
            ((__1 ()) fmt) x.typ;
2507
            Format.fprintf fmt "@]");
2508
           Format.fprintf fmt ";@ ";
2509
           Format.fprintf fmt "@[%s =@ " "init_val";
2510
           ((function
2511
             | None  -> Format.pp_print_string fmt "None"
2512
             | Some x ->
2513
                 (Format.pp_print_string fmt "(Some ";
2514
                  ((__2 ()) fmt) x;
2515
                  Format.pp_print_string fmt ")"))) x.init_val;
2516
           Format.fprintf fmt "@]");
2517
          Format.fprintf fmt "@ }@]")
2518
    [@ocaml.warning "-A"])
2519

    
2520
and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string =
2521
  fun x  -> Format.asprintf "%a" pp_vhdl_parameter_t x
2522

    
2523
let rec (vhdl_parameter_t_to_yojson : vhdl_parameter_t -> Yojson.Safe.json) =
2524
  ((let open! Ppx_deriving_yojson_runtime in
2525
      fun x  ->
2526
        let fields = []  in
2527
        let fields =
2528
          if x.init_val = None
2529
          then fields
2530
          else
2531
            ("init_val",
2532
              (((function
2533
                 | None  -> `Null
2534
                 | Some x -> ((fun x  -> vhdl_cst_val_t_to_yojson x)) x))
2535
                 x.init_val))
2536
            :: fields
2537
           in
2538
        let fields =
2539
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
2540
          :: fields  in
2541
        let fields =
2542
          if x.mode = []
2543
          then fields
2544
          else
2545
            ("mode",
2546
              (((fun x  ->
2547
                   `List
2548
                     (List.map
2549
                        (fun (x : Ppx_deriving_runtime.string)  -> `String x)
2550
                        x))) x.mode))
2551
            :: fields
2552
           in
2553
        let fields =
2554
          ("names",
2555
            ((fun x  ->
2556
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
2557
               x.names))
2558
          :: fields  in
2559
        `Assoc fields)
2560
  [@ocaml.warning "-A"])
2561

    
2562
and (vhdl_parameter_t_of_yojson :
2563
      Yojson.Safe.json ->
2564
        vhdl_parameter_t Ppx_deriving_yojson_runtime.error_or)
2565
  =
2566
  ((let open! Ppx_deriving_yojson_runtime in
2567
      function
2568
      | `Assoc xs ->
2569
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2570
            match xs with
2571
            | ("names",x)::xs ->
2572
                loop xs
2573
                  (((function
2574
                     | `List xs ->
2575
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
2576
                     | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.names") x),
2577
                    arg1, arg2, arg3)
2578
            | ("mode",x)::xs ->
2579
                loop xs
2580
                  (arg0,
2581
                    ((function
2582
                      | `List xs ->
2583
                          map_bind
2584
                            (function
2585
                             | `String x -> Result.Ok x
2586
                             | _ ->
2587
                                 Result.Error
2588
                                   "Vhdl_ast.vhdl_parameter_t.mode") [] xs
2589
                      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.mode") x),
2590
                    arg2, arg3)
2591
            | ("typ",x)::xs ->
2592
                loop xs
2593
                  (arg0, arg1,
2594
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
2595
                    arg3)
2596
            | ("init_val",x)::xs ->
2597
                loop xs
2598
                  (arg0, arg1, arg2,
2599
                    ((function
2600
                      | `Null -> Result.Ok None
2601
                      | x ->
2602
                          ((fun x  -> vhdl_cst_val_t_of_yojson x) x) >>=
2603
                            ((fun x  -> Result.Ok (Some x)))) x))
2604
            | [] ->
2605
                arg3 >>=
2606
                  ((fun arg3  ->
2607
                      arg2 >>=
2608
                        (fun arg2  ->
2609
                           arg1 >>=
2610
                             (fun arg1  ->
2611
                                arg0 >>=
2612
                                  (fun arg0  ->
2613
                                     Result.Ok
2614
                                       {
2615
                                         names = arg0;
2616
                                         mode = arg1;
2617
                                         typ = arg2;
2618
                                         init_val = arg3
2619
                                       })))))
2620
            | _::xs -> loop xs _state  in
2621
          loop xs
2622
            ((Result.Error "Vhdl_ast.vhdl_parameter_t.names"),
2623
              (Result.Ok []), (Result.Error "Vhdl_ast.vhdl_parameter_t.typ"),
2624
              (Result.Ok (Some (CstInt 0))))
2625
      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t")
2626
  [@ocaml.warning "-A"])
2627

    
2628
type vhdl_subprogram_spec_t =
2629
  {
2630
  name: string [@default ""];
2631
  typeMark: vhdl_name_t [@default NoName];
2632
  parameters: vhdl_parameter_t list ;
2633
  isPure: bool [@default false]}
2634

    
2635
(* TODO *)
2636
let rec pp_vhdl_subprogram_spec_t :
2637
  Format.formatter -> vhdl_subprogram_spec_t -> Ppx_deriving_runtime.unit =
2638
  let __1 () = pp_vhdl_parameter_t
2639
  
2640
  and __0 () = pp_vhdl_name_t
2641
   in
2642
  ((let open! Ppx_deriving_runtime in
2643
      fun fmt  ->
2644
        fun x  ->
2645
          Format.fprintf fmt "@[<2>{ ";
2646
          ((((Format.fprintf fmt "@[%s =@ " "name";
2647
              (Format.fprintf fmt "%S") x.name;
2648
              Format.fprintf fmt "@]");
2649
             Format.fprintf fmt ";@ ";
2650
             Format.fprintf fmt "@[%s =@ " "typeMark";
2651
             ((__0 ()) fmt) x.typeMark;
2652
             Format.fprintf fmt "@]");
2653
            Format.fprintf fmt ";@ ";
2654
            Format.fprintf fmt "@[%s =@ " "parameters";
2655
            ((fun x  ->
2656
                Format.fprintf fmt "@[<2>[";
2657
                ignore
2658
                  (List.fold_left
2659
                     (fun sep  ->
2660
                        fun x  ->
2661
                          if sep then Format.fprintf fmt ";@ ";
2662
                          ((__1 ()) fmt) x;
2663
                          true) false x);
2664
                Format.fprintf fmt "@,]@]")) x.parameters;
2665
            Format.fprintf fmt "@]");
2666
           Format.fprintf fmt ";@ ";
2667
           Format.fprintf fmt "@[%s =@ " "isPure";
2668
           (Format.fprintf fmt "%B") x.isPure;
2669
           Format.fprintf fmt "@]");
2670
          Format.fprintf fmt "@ }@]")
2671
    [@ocaml.warning "-A"])
2672

    
2673
and show_vhdl_subprogram_spec_t :
2674
  vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string =
2675
  fun x  -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x
2676

    
2677
let rec (vhdl_subprogram_spec_t_to_yojson :
2678
          vhdl_subprogram_spec_t -> Yojson.Safe.json)
2679
  =
2680
  ((let open! Ppx_deriving_yojson_runtime in
2681
      fun x  ->
2682
        let fields = []  in
2683
        let fields =
2684
          if x.isPure = false
2685
          then fields
2686
          else
2687
            ("isPure",
2688
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x)) x.isPure))
2689
            :: fields
2690
           in
2691
        let fields =
2692
          ("parameters",
2693
            ((fun x  ->
2694
                `List (List.map (fun x  -> vhdl_parameter_t_to_yojson x) x))
2695
               x.parameters))
2696
          :: fields  in
2697
        let fields =
2698
          if x.typeMark = NoName
2699
          then fields
2700
          else
2701
            ("typeMark", (((fun x  -> vhdl_name_t_to_yojson x)) x.typeMark))
2702
            :: fields
2703
           in
2704
        let fields =
2705
          if x.name = ""
2706
          then fields
2707
          else
2708
            ("name",
2709
              (((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x.name))
2710
            :: fields
2711
           in
2712
        `Assoc fields)
2713
  [@ocaml.warning "-A"])
2714

    
2715
and (vhdl_subprogram_spec_t_of_yojson :
2716
      Yojson.Safe.json ->
2717
        vhdl_subprogram_spec_t Ppx_deriving_yojson_runtime.error_or)
2718
  =
2719
  ((let open! Ppx_deriving_yojson_runtime in
2720
      function
2721
      | `Assoc xs ->
2722
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2723
            match xs with
2724
            | ("name",x)::xs ->
2725
                loop xs
2726
                  (((function
2727
                     | `String x -> Result.Ok x
2728
                     | _ ->
2729
                         Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.name")
2730
                      x), arg1, arg2, arg3)
2731
            | ("typeMark",x)::xs ->
2732
                loop xs
2733
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3)
2734
            | ("parameters",x)::xs ->
2735
                loop xs
2736
                  (arg0, arg1,
2737
                    ((function
2738
                      | `List xs ->
2739
                          map_bind (fun x  -> vhdl_parameter_t_of_yojson x)
2740
                            [] xs
2741
                      | _ ->
2742
                          Result.Error
2743
                            "Vhdl_ast.vhdl_subprogram_spec_t.parameters") x),
2744
                    arg3)
2745
            | ("isPure",x)::xs ->
2746
                loop xs
2747
                  (arg0, arg1, arg2,
2748
                    ((function
2749
                      | `Bool x -> Result.Ok x
2750
                      | _ ->
2751
                          Result.Error
2752
                            "Vhdl_ast.vhdl_subprogram_spec_t.isPure") x))
2753
            | [] ->
2754
                arg3 >>=
2755
                  ((fun arg3  ->
2756
                      arg2 >>=
2757
                        (fun arg2  ->
2758
                           arg1 >>=
2759
                             (fun arg1  ->
2760
                                arg0 >>=
2761
                                  (fun arg0  ->
2762
                                     Result.Ok
2763
                                       {
2764
                                         name = arg0;
2765
                                         typeMark = arg1;
2766
                                         parameters = arg2;
2767
                                         isPure = arg3
2768
                                       })))))
2769
            | _::xs -> loop xs _state  in
2770
          loop xs
2771
            ((Result.Ok ""), (Result.Ok NoName),
2772
              (Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.parameters"),
2773
              (Result.Ok false))
2774
      | _ -> Result.Error "Vhdl_ast.vhdl_subprogram_spec_t")
2775
  [@ocaml.warning "-A"])
2776

    
2777
let arith_funs = ["+"; "-"; "*"; "/"; "mod"; "rem"; "abs"; "**"; "&"] 
2778
let bool_funs = ["and"; "or"; "nand"; "nor"; "xor"; "not"] 
2779
let rel_funs =
2780
  ["<";
2781
  ">";
2782
  "<=";
2783
  ">=";
2784
  "/=";
2785
  "=";
2786
  "?=";
2787
  "?/=";
2788
  "?<";
2789
  "?<=";
2790
  "?>";
2791
  "?>=";
2792
  "??"] 
2793
let shift_funs = ["sll"; "srl"; "sla"; "sra"; "rol"; "ror"] 
2794
type vhdl_sequential_stmt_t =
2795
  | VarAssign of
2796
  {
2797
  label: vhdl_name_t [@default NoName];
2798
  lhs: vhdl_name_t ;
2799
  rhs: vhdl_expr_t } [@name "VARIABLE_ASSIGNMENT_STATEMENT"]
2800
  | SigSeqAssign of
2801
  {
2802
  label: vhdl_name_t [@default NoName];
2803
  lhs: vhdl_name_t ;
2804
  rhs: vhdl_expr_t list } [@name "SIGNAL_ASSIGNMENT_STATEMENT"]
2805
  | If of
2806
  {
2807
  label: vhdl_name_t [@default NoName];
2808
  if_cases: vhdl_if_case_t list ;
2809
  default: vhdl_sequential_stmt_t list [@default []]} [@name "IF_STATEMENT"]
2810
  | Case of
2811
  {
2812
  label: vhdl_name_t [@default NoName];
2813
  guard: vhdl_expr_t ;
2814
  branches: vhdl_case_item_t list } [@name "CASE_STATEMENT_TREE"]
2815
  | Exit of
2816
  {
2817
  label: vhdl_name_t [@default NoName];
2818
  loop_label: string option [@default Some ""];
2819
  condition: vhdl_expr_t option [@default Some IsNull]}
2820
  [@name "EXIT_STATEMENT"]
2821
  | Assert of
2822
  {
2823
  label: vhdl_name_t [@default NoName];
2824
  cond: vhdl_expr_t ;
2825
  report: vhdl_expr_t [@default IsNull];
2826
  severity: vhdl_expr_t [@default IsNull]} [@name "ASSERTION_STATEMENT"]
2827
  | ProcedureCall of
2828
  {
2829
  label: vhdl_name_t [@default NoName];
2830
  name: vhdl_name_t ;
2831
  assocs: vhdl_assoc_element_t list } [@name "PROCEDURE_CALL_STATEMENT"]
2832
  | Wait [@name "WAIT_STATEMENT"]
2833
  | Null of {
2834
  label: vhdl_name_t [@default NoName]} [@name "NULL_STATEMENT"]
2835
  | Return of {
2836
  label: vhdl_name_t [@default NoName]} [@name "RETURN_STATEMENT"]
2837
and vhdl_if_case_t =
2838
  {
2839
  if_cond: vhdl_expr_t ;
2840
  if_block: vhdl_sequential_stmt_t list }
2841
and vhdl_case_item_t =
2842
  {
2843
  when_cond: vhdl_expr_t list ;
2844
  when_stmt: vhdl_sequential_stmt_t list }
2845

    
2846
(* TODO Adapt for: Assert, ProcedureCall *)
2847
let rec pp_vhdl_sequential_stmt_t :
2848
  Format.formatter -> vhdl_sequential_stmt_t -> Ppx_deriving_runtime.unit =
2849
  let __22 () = pp_vhdl_name_t
2850
  
2851
  and __21 () = pp_vhdl_name_t
2852
  
2853
  and __20 () = pp_vhdl_assoc_element_t
2854
  
2855
  and __19 () = pp_vhdl_name_t
2856
  
2857
  and __18 () = pp_vhdl_name_t
2858
  
2859
  and __17 () = pp_vhdl_expr_t
2860
  
2861
  and __16 () = pp_vhdl_expr_t
2862
  
2863
  and __15 () = pp_vhdl_expr_t
2864
  
2865
  and __14 () = pp_vhdl_name_t
2866
  
2867
  and __13 () = pp_vhdl_expr_t
2868
  
2869
  and __12 () = pp_vhdl_name_t
2870
  
2871
  and __11 () = pp_vhdl_case_item_t
2872
  
2873
  and __10 () = pp_vhdl_expr_t
2874
  
2875
  and __9 () = pp_vhdl_name_t
2876
  
2877
  and __8 () = pp_vhdl_sequential_stmt_t
2878
  
2879
  and __7 () = pp_vhdl_if_case_t
2880
  
2881
  and __6 () = pp_vhdl_name_t
2882
  
2883
  and __5 () = pp_vhdl_expr_t
2884
  
2885
  and __4 () = pp_vhdl_name_t
2886
  
2887
  and __3 () = pp_vhdl_name_t
2888
  
2889
  and __2 () = pp_vhdl_expr_t
2890
  
2891
  and __1 () = pp_vhdl_name_t
2892
  
2893
  and __0 () = pp_vhdl_name_t
2894
   in
2895
  ((let open! Ppx_deriving_runtime in
2896
      fun fmt  ->
2897
        function
2898
        | VarAssign { label = alabel; lhs = alhs; rhs = arhs } ->
2899
            (match alabel with
2900
              | NoName -> Format.fprintf fmt "";
2901
              | _ -> (((__0 ()) fmt) alabel;
2902
                     Format.fprintf fmt ":@ ")
2903
            );
2904
            ((__1 ()) fmt) alhs;
2905
            Format.fprintf fmt "@ :=@ ";
2906
            ((__2 ()) fmt) arhs;
2907
(* TODO: Check
2908
            (Format.fprintf fmt "@[<2>VarAssign {@,";
2909
             (((Format.fprintf fmt "@[%s =@ " "label";
2910
                ((__0 ()) fmt) alabel;
2911
                Format.fprintf fmt "@]");
2912
               Format.fprintf fmt ";@ ";
2913
               Format.fprintf fmt "@[%s =@ " "lhs";
2914
               ((__1 ()) fmt) alhs;
2915
               Format.fprintf fmt "@]");
2916
              Format.fprintf fmt ";@ ";
2917
              Format.fprintf fmt "@[%s =@ " "rhs";
2918
              ((__2 ()) fmt) arhs;
2919
              Format.fprintf fmt "@]");
2920
             Format.fprintf fmt "@]}") *)
2921
        | SigSeqAssign { label = alabel; lhs = alhs; rhs = arhs } ->
2922
            (match alabel with
2923
              | NoName -> Format.fprintf fmt "";
2924
              | _ -> (((__3 ()) fmt) alabel;
2925
                     Format.fprintf fmt ":@ ")
2926
            );
2927
            Format.fprintf fmt "@[<2>";
2928
            ((__4 ()) fmt) alhs;
2929
            Format.fprintf fmt "@ <=@ ";
2930
            ((fun x  ->
2931
               Format.fprintf fmt "@[";
2932
               ignore
2933
                 (List.fold_left
2934
                   (fun sep  ->
2935
                     fun x  ->
2936
                       if sep then Format.fprintf fmt "";
2937
                        ((__5 ()) fmt) x;
2938
                        Format.fprintf fmt ";";
2939
                        true) false x);
2940
            Format.fprintf fmt "@]@]")) arhs;
2941
        | If { label = alabel; if_cases = aif_cases; default = adefault } ->
2942
            (match alabel with
2943
              | NoName -> Format.fprintf fmt "";
2944
              | _ -> (((__6 ()) fmt) alabel;
2945
                     Format.fprintf fmt ":@ ")
2946
            );
2947
            Format.fprintf fmt "@[<v>if";
2948
            ((fun x ->
2949
               ignore
2950
               (List.fold_left
2951
                 (fun sep  ->
2952
                   fun x  ->
2953
                           if sep then Format.fprintf fmt "@;elseif";
2954
                                ((__7 ()) fmt) x;
2955
                                true
2956
                 ) false x);
2957
             )) aif_cases;
2958
             (match adefault with
2959
              | [] -> Format.fprintf fmt "";
2960
              | _  -> (Format.fprintf fmt "@;else";
2961
                      ((fun x  ->
2962
                          Format.fprintf fmt "@;<0 2>";
2963
                          ignore
2964
                            (List.fold_left
2965
                              (fun sep  ->
2966
                                fun x  ->
2967
                                        if sep then Format.fprintf fmt "";
2968
                          ((__8 ()) fmt) x;
2969
                          true) false x))) adefault));
2970
            Format.fprintf fmt "@;end if;@]"
2971
        | Case { label = alabel; guard = aguard; branches = abranches } ->
2972
            (match alabel with
2973
              | NoName -> Format.fprintf fmt "";
2974
              | _ -> (((__9 ()) fmt) alabel;
2975
                     Format.fprintf fmt ":@ ")
2976
            );
2977
            Format.fprintf fmt "@[<v>case ";
2978
            ((__10 ()) fmt) aguard;
2979
            Format.fprintf fmt " is";
2980
            ((fun x  ->
2981
                ignore
2982
                  (List.fold_left
2983
                     (fun sep  ->
2984
                        fun x  ->
2985
                          if sep then Format.fprintf fmt "";
2986
                          ((__11 ()) fmt) x;
2987
                          true) false x);)) abranches;
2988
            Format.fprintf fmt "@;end case;@]";
2989
        | Exit
2990
            { label = alabel; loop_label = aloop_label;
2991
              condition = acondition }
2992
            ->
2993
            (match alabel with
2994
              | NoName -> Format.fprintf fmt "";
2995
              | _ -> (((__12 ()) fmt) alabel;
2996
                     Format.fprintf fmt ":@ ")
2997
            );
2998
            Format.fprintf fmt "exit";
2999
            (match aloop_label with
3000
               | None  -> Format.pp_print_string fmt ""
3001
               | Some x -> (Format.fprintf fmt "@ %s@ ") x);
3002
            ((function
3003
               | None  -> Format.pp_print_string fmt ""
3004
               | Some x ->
3005
                   (Format.pp_print_string fmt "when@ ";
3006
                    ((__13 ()) fmt) x;))) acondition;
3007
        | Assert
3008
            { label = alabel; cond = acond; report = areport;
3009
              severity = aseverity }
3010
            ->
3011
            (Format.fprintf fmt "@[<2>Assert {@,";
3012
             ((((Format.fprintf fmt "@[%s =@ " "label";
3013
                 ((__14 ()) fmt) alabel;
3014
                 Format.fprintf fmt "@]");
3015
                Format.fprintf fmt ";@ ";
3016
                Format.fprintf fmt "@[%s =@ " "cond";
3017
                ((__15 ()) fmt) acond;
3018
                Format.fprintf fmt "@]");
3019
               Format.fprintf fmt ";@ ";
3020
               Format.fprintf fmt "@[%s =@ " "report";
3021
               ((__16 ()) fmt) areport;
3022
               Format.fprintf fmt "@]");
3023
              Format.fprintf fmt ";@ ";
3024
              Format.fprintf fmt "@[%s =@ " "severity";
3025
              ((__17 ()) fmt) aseverity;
3026
              Format.fprintf fmt "@]");
3027
             Format.fprintf fmt "@]}")
3028
        | ProcedureCall { label = alabel; name = aname; assocs = aassocs } ->
3029
            (match alabel with
3030
              | NoName -> Format.fprintf fmt "";
3031
              | _ -> (((__18 ()) fmt) alabel;
3032
                     Format.fprintf fmt ":@ ")
3033
            );
3034
            ((__19 ()) fmt) aname;
3035
            ((fun x  ->
3036
                Format.fprintf fmt "(";
3037
                ignore
3038
                  (List.fold_left
3039
                     (fun sep  ->
3040
                        fun x  ->
3041
                          if sep then Format.fprintf fmt ",@ ";
3042
                          ((__20 ()) fmt) x;
3043
                          true) false x);
3044
            Format.fprintf fmt ")")) aassocs;
3045
        | Wait  -> Format.pp_print_string fmt "wait"
3046
        | Null { label = alabel } ->
3047
            (match alabel with
3048
              | NoName -> Format.fprintf fmt "";
3049
              | _ -> (((__18 ()) fmt) alabel;
3050
                     Format.fprintf fmt ":@ ")
3051
            );
3052
            Format.fprintf fmt "null";
3053
        | Return { label = alabel } ->
3054
            (match alabel with
3055
              | NoName -> Format.fprintf fmt "";
3056
              | _ -> (((__19 ()) fmt) alabel;
3057
                     Format.fprintf fmt ":@ ")
3058
            );
3059
            Format.fprintf fmt "return";)
3060
    [@ocaml.warning "-A"])
3061

    
3062
and show_vhdl_sequential_stmt_t :
3063
  vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string =
3064
  fun x  -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x
3065

    
3066
and pp_vhdl_if_case_t :
3067
  Format.formatter -> vhdl_if_case_t -> Ppx_deriving_runtime.unit =
3068
  let __1 () = pp_vhdl_sequential_stmt_t
3069
  
3070
  and __0 () = pp_vhdl_expr_t
3071
   in
3072
  ((let open! Ppx_deriving_runtime in
3073
      fun fmt  ->
3074
        fun x  ->
3075
          Format.fprintf fmt " (";
3076
          ((__0 ()) fmt) x.if_cond;
3077
          Format.fprintf fmt ") then@;<0 2>";
3078
          ((fun x  ->
3079
             ignore
3080
               (List.fold_left
3081
                  (fun sep  ->
3082
                     fun x  ->
3083
                             if sep then Format.fprintf fmt "@;<0 2>";
3084
                       ((__1 ()) fmt) x;
3085
                       true) false x);
3086
          )) x.if_block;)
3087
    [@ocaml.warning "-A"])
3088

    
3089
and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string =
3090
  fun x  -> Format.asprintf "%a" pp_vhdl_if_case_t x
3091

    
3092
and pp_vhdl_case_item_t :
3093
  Format.formatter -> vhdl_case_item_t -> Ppx_deriving_runtime.unit =
3094
  let __1 () = pp_vhdl_sequential_stmt_t
3095
  
3096
  and __0 () = pp_vhdl_expr_t
3097
   in
3098
  ((let open! Ppx_deriving_runtime in
3099
      fun fmt  ->
3100
        fun x  ->
3101
                Format.fprintf fmt "@;<0 2>when ";
3102
            ((fun x  ->
3103
                ignore
3104
                  (List.fold_left
3105
                     (fun sep  ->
3106
                        fun x  ->
3107
                          if sep then Format.fprintf fmt "@ |@ ";
3108
                          ((__0 ()) fmt) x;
3109
                          true) false x);)) x.when_cond;
3110
           Format.fprintf fmt " => ";
3111
           ((fun x  ->
3112
               ignore
3113
                 (List.fold_left
3114
                    (fun sep  ->
3115
                       fun x  ->
3116
                         if sep then Format.fprintf fmt "";
3117
                         ((__1 ()) fmt) x;
3118
                         true) false x);)) x.when_stmt)
3119
    [@ocaml.warning "-A"])
3120

    
3121
and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string =
3122
  fun x  -> Format.asprintf "%a" pp_vhdl_case_item_t x
3123

    
3124
let rec (vhdl_sequential_stmt_t_to_yojson :
3125
          vhdl_sequential_stmt_t -> Yojson.Safe.json)
3126
  =
3127
  ((let open! Ppx_deriving_yojson_runtime in
3128
      function
3129
      | VarAssign arg0 ->
3130
          `List
3131
            [`String "VARIABLE_ASSIGNMENT_STATEMENT";
3132
            (let fields = []  in
3133
             let fields =
3134
               ("rhs", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.rhs)) ::
3135
               fields  in
3136
             let fields =
3137
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
3138
               fields  in
3139
             let fields =
3140
               if arg0.label = NoName
3141
               then fields
3142
               else
3143
                 ("label",
3144
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3145
                 :: fields
3146
                in
3147
             `Assoc fields)]
3148
      | SigSeqAssign arg0 ->
3149
          `List
3150
            [`String "SIGNAL_ASSIGNMENT_STATEMENT";
3151
            (let fields = []  in
3152
             let fields =
3153
               ("rhs",
3154
                 ((fun x  ->
3155
                     `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
3156
                    arg0.rhs))
3157
               :: fields  in
3158
             let fields =
3159
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
3160
               fields  in
3161
             let fields =
3162
               if arg0.label = NoName
3163
               then fields
3164
               else
3165
                 ("label",
3166
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3167
                 :: fields
3168
                in
3169
             `Assoc fields)]
3170
      | If arg0 ->
3171
          `List
3172
            [`String "IF_STATEMENT";
3173
            (let fields = []  in
3174
             let fields =
3175
               if arg0.default = []
3176
               then fields
3177
               else
3178
                 ("default",
3179
                   (((fun x  ->
3180
                        `List
3181
                          (List.map
3182
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
3183
                      arg0.default))
3184
                 :: fields
3185
                in
3186
             let fields =
3187
               ("if_cases",
3188
                 ((fun x  ->
3189
                     `List
3190
                       (List.map (fun x  -> vhdl_if_case_t_to_yojson x) x))
3191
                    arg0.if_cases))
3192
               :: fields  in
3193
             let fields =
3194
               if arg0.label = NoName
3195
               then fields
3196
               else
3197
                 ("label",
3198
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3199
                 :: fields
3200
                in
3201
             `Assoc fields)]
3202
      | Case arg0 ->
3203
          `List
3204
            [`String "CASE_STATEMENT_TREE";
3205
            (let fields = []  in
3206
             let fields =
3207
               ("branches",
3208
                 ((fun x  ->
3209
                     `List
3210
                       (List.map (fun x  -> vhdl_case_item_t_to_yojson x) x))
3211
                    arg0.branches))
3212
               :: fields  in
3213
             let fields =
3214
               ("guard", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.guard)) ::
3215
               fields  in
3216
             let fields =
3217
               if arg0.label = NoName
3218
               then fields
3219
               else
3220
                 ("label",
3221
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3222
                 :: fields
3223
                in
3224
             `Assoc fields)]
3225
      | Exit arg0 ->
3226
          `List
3227
            [`String "EXIT_STATEMENT";
3228
            (let fields = []  in
3229
             let fields =
3230
               if arg0.condition = (Some IsNull)
3231
               then fields
3232
               else
3233
                 ("condition",
3234
                   (((function
3235
                      | None  -> `Null
3236
                      | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
3237
                      arg0.condition))
3238
                 :: fields
3239
                in
3240
             let fields =
3241
               if arg0.loop_label = (Some "")
3242
               then fields
3243
               else
3244
                 ("loop_label",
3245
                   (((function
3246
                      | None  -> `Null
3247
                      | Some x ->
3248
                          ((fun (x : Ppx_deriving_runtime.string)  ->
3249
                              `String x)) x)) arg0.loop_label))
3250
                 :: fields
3251
                in
3252
             let fields =
3253
               if arg0.label = NoName
3254
               then fields
3255
               else
3256
                 ("label",
3257
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3258
                 :: fields
3259
                in
3260
             `Assoc fields)]
3261
      | Assert arg0 ->
3262
          `List
3263
            [`String "ASSERTION_STATEMENT";
3264
            (let fields = []  in
3265
             let fields =
3266
               if arg0.severity = IsNull
3267
               then fields
3268
               else
3269
                 ("severity",
3270
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.severity))
3271
                 :: fields
3272
                in
3273
             let fields =
3274
               if arg0.report = IsNull
3275
               then fields
3276
               else
3277
                 ("report",
3278
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.report))
3279
                 :: fields
3280
                in
3281
             let fields =
3282
               ("cond", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.cond)) ::
3283
               fields  in
3284
             let fields =
3285
               if arg0.label = NoName
3286
               then fields
3287
               else
3288
                 ("label",
3289
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3290
                 :: fields
3291
                in
3292
             `Assoc fields)]
3293
      | ProcedureCall arg0 ->
3294
          `List
3295
            [`String "PROCEDURE_CALL_STATEMENT";
3296
            (let fields = []  in
3297
             let fields =
3298
               ("assocs",
3299
                 ((fun x  ->
3300
                     `List
3301
                       (List.map (fun x  -> vhdl_assoc_element_t_to_yojson x)
3302
                          x)) arg0.assocs))
3303
               :: fields  in
3304
             let fields =
3305
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
3306
               fields  in
3307
             let fields =
3308
               if arg0.label = NoName
3309
               then fields
3310
               else
3311
                 ("label",
3312
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3313
                 :: fields
3314
                in
3315
             `Assoc fields)]
3316
      | Wait  -> `List [`String "WAIT_STATEMENT"]
3317
      | Null arg0 ->
3318
          `List
3319
            [`String "NULL_STATEMENT";
3320
            (let fields = []  in
3321
             let fields =
3322
               if arg0.label = NoName
3323
               then fields
3324
               else
3325
                 ("label",
3326
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3327
                 :: fields
3328
                in
3329
             `Assoc fields)]
3330
      | Return arg0 ->
3331
          `List
3332
            [`String "RETURN_STATEMENT";
3333
            (let fields = []  in
3334
             let fields =
3335
               if arg0.label = NoName
3336
               then fields
3337
               else
3338
                 ("label",
3339
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3340
                 :: fields
3341
                in
3342
             `Assoc fields)])
3343
  [@ocaml.warning "-A"])
3344

    
3345
and (vhdl_sequential_stmt_t_of_yojson :
3346
      Yojson.Safe.json ->
3347
        vhdl_sequential_stmt_t Ppx_deriving_yojson_runtime.error_or)
3348
  =
3349
  ((let open! Ppx_deriving_yojson_runtime in
3350
      function
3351
      | `List ((`String "VARIABLE_ASSIGNMENT_STATEMENT")::arg0::[]) ->
3352
          ((function
3353
            | `Assoc xs ->
3354
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3355
                  match xs with
3356
                  | ("label",x)::xs ->
3357
                      loop xs
3358
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3359
                  | ("lhs",x)::xs ->
3360
                      loop xs
3361
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3362
                  | ("rhs",x)::xs ->
3363
                      loop xs
3364
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
3365
                  | [] ->
3366
                      arg2 >>=
3367
                        ((fun arg2  ->
3368
                            arg1 >>=
3369
                              (fun arg1  ->
3370
                                 arg0 >>=
3371
                                   (fun arg0  ->
3372
                                      Result.Ok
3373
                                        (VarAssign
3374
                                           {
3375
                                             label = arg0;
3376
                                             lhs = arg1;
3377
                                             rhs = arg2
3378
                                           })))))
3379
                  | _::xs -> loop xs _state  in
3380
                loop xs
3381
                  ((Result.Ok NoName),
3382
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
3383
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
3384
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3385
      | `List ((`String "SIGNAL_ASSIGNMENT_STATEMENT")::arg0::[]) ->
3386
          ((function
3387
            | `Assoc xs ->
3388
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3389
                  match xs with
3390
                  | ("label",x)::xs ->
3391
                      loop xs
3392
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3393
                  | ("lhs",x)::xs ->
3394
                      loop xs
3395
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3396
                  | ("rhs",x)::xs ->
3397
                      loop xs
3398
                        (arg0, arg1,
3399
                          ((function
3400
                            | `List xs ->
3401
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
3402
                                  [] xs
3403
                            | _ ->
3404
                                Result.Error
3405
                                  "Vhdl_ast.vhdl_sequential_stmt_t.rhs") x))
3406
                  | [] ->
3407
                      arg2 >>=
3408
                        ((fun arg2  ->
3409
                            arg1 >>=
3410
                              (fun arg1  ->
3411
                                 arg0 >>=
3412
                                   (fun arg0  ->
3413
                                      Result.Ok
3414
                                        (SigSeqAssign
3415
                                           {
3416
                                             label = arg0;
3417
                                             lhs = arg1;
3418
                                             rhs = arg2
3419
                                           })))))
3420
                  | _::xs -> loop xs _state  in
3421
                loop xs
3422
                  ((Result.Ok NoName),
3423
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
3424
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
3425
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3426
      | `List ((`String "IF_STATEMENT")::arg0::[]) ->
3427
          ((function
3428
            | `Assoc xs ->
3429
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3430
                  match xs with
3431
                  | ("label",x)::xs ->
3432
                      loop xs
3433
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3434
                  | ("if_cases",x)::xs ->
3435
                      loop xs
3436
                        (arg0,
3437
                          ((function
3438
                            | `List xs ->
3439
                                map_bind
3440
                                  (fun x  -> vhdl_if_case_t_of_yojson x) []
3441
                                  xs
3442
                            | _ ->
3443
                                Result.Error
3444
                                  "Vhdl_ast.vhdl_sequential_stmt_t.if_cases")
3445
                             x), arg2)
3446
                  | ("default",x)::xs ->
3447
                      loop xs
3448
                        (arg0, arg1,
3449
                          ((function
3450
                            | `List xs ->
3451
                                map_bind
3452
                                  (fun x  ->
3453
                                     vhdl_sequential_stmt_t_of_yojson x) []
3454
                                  xs
3455
                            | _ ->
3456
                                Result.Error
3457
                                  "Vhdl_ast.vhdl_sequential_stmt_t.default")
3458
                             x))
3459
                  | [] ->
3460
                      arg2 >>=
3461
                        ((fun arg2  ->
3462
                            arg1 >>=
3463
                              (fun arg1  ->
3464
                                 arg0 >>=
3465
                                   (fun arg0  ->
3466
                                      Result.Ok
3467
                                        (If
3468
                                           {
3469
                                             label = arg0;
3470
                                             if_cases = arg1;
3471
                                             default = arg2
3472
                                           })))))
3473
                  | _::xs -> loop xs _state  in
3474
                loop xs
3475
                  ((Result.Ok NoName),
3476
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.if_cases"),
3477
                    (Result.Ok []))
3478
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3479
      | `List ((`String "CASE_STATEMENT_TREE")::arg0::[]) ->
3480
          ((function
3481
            | `Assoc xs ->
3482
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3483
                  match xs with
3484
                  | ("label",x)::xs ->
3485
                      loop xs
3486
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3487
                  | ("guard",x)::xs ->
3488
                      loop xs
3489
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
3490
                  | ("branches",x)::xs ->
3491
                      loop xs
3492
                        (arg0, arg1,
3493
                          ((function
3494
                            | `List xs ->
3495
                                map_bind
3496
                                  (fun x  -> vhdl_case_item_t_of_yojson x) []
3497
                                  xs
3498
                            | _ ->
3499
                                Result.Error
3500
                                  "Vhdl_ast.vhdl_sequential_stmt_t.branches")
3501
                             x))
3502
                  | [] ->
3503
                      arg2 >>=
3504
                        ((fun arg2  ->
3505
                            arg1 >>=
3506
                              (fun arg1  ->
3507
                                 arg0 >>=
3508
                                   (fun arg0  ->
3509
                                      Result.Ok
3510
                                        (Case
3511
                                           {
3512
                                             label = arg0;
3513
                                             guard = arg1;
3514
                                             branches = arg2
3515
                                           })))))
3516
                  | _::xs -> loop xs _state  in
3517
                loop xs
3518
                  ((Result.Ok NoName),
3519
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.guard"),
3520
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.branches"))
3521
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3522
      | `List ((`String "EXIT_STATEMENT")::arg0::[]) ->
3523
          ((function
3524
            | `Assoc xs ->
3525
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3526
                  match xs with
3527
                  | ("label",x)::xs ->
3528
                      loop xs
3529
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3530
                  | ("loop_label",x)::xs ->
3531
                      loop xs
3532
                        (arg0,
3533
                          ((function
3534
                            | `Null -> Result.Ok None
3535
                            | x ->
3536
                                ((function
3537
                                  | `String x -> Result.Ok x
3538
                                  | _ ->
3539
                                      Result.Error
3540
                                        "Vhdl_ast.vhdl_sequential_stmt_t.loop_label")
3541
                                   x)
3542
                                  >>= ((fun x  -> Result.Ok (Some x)))) x),
3543
                          arg2)
3544
                  | ("condition",x)::xs ->
3545
                      loop xs
3546
                        (arg0, arg1,
3547
                          ((function
3548
                            | `Null -> Result.Ok None
3549
                            | x ->
3550
                                ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
3551
                                  ((fun x  -> Result.Ok (Some x)))) x))
3552
                  | [] ->
3553
                      arg2 >>=
3554
                        ((fun arg2  ->
3555
                            arg1 >>=
3556
                              (fun arg1  ->
3557
                                 arg0 >>=
3558
                                   (fun arg0  ->
3559
                                      Result.Ok
3560
                                        (Exit
3561
                                           {
3562
                                             label = arg0;
3563
                                             loop_label = arg1;
3564
                                             condition = arg2
3565
                                           })))))
3566
                  | _::xs -> loop xs _state  in
3567
                loop xs
3568
                  ((Result.Ok NoName), (Result.Ok (Some "")),
3569
                    (Result.Ok (Some IsNull)))
3570
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3571
      | `List ((`String "ASSERTION_STATEMENT")::arg0::[]) ->
3572
          ((function
3573
            | `Assoc xs ->
3574
                let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
3575
                  match xs with
3576
                  | ("label",x)::xs ->
3577
                      loop xs
3578
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2,
3579
                          arg3)
3580
                  | ("cond",x)::xs ->
3581
                      loop xs
3582
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2,
3583
                          arg3)
3584
                  | ("report",x)::xs ->
3585
                      loop xs
3586
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x),
3587
                          arg3)
3588
                  | ("severity",x)::xs ->
3589
                      loop xs
3590
                        (arg0, arg1, arg2,
3591
                          ((fun x  -> vhdl_expr_t_of_yojson x) x))
3592
                  | [] ->
3593
                      arg3 >>=
3594
                        ((fun arg3  ->
3595
                            arg2 >>=
3596
                              (fun arg2  ->
3597
                                 arg1 >>=
3598
                                   (fun arg1  ->
3599
                                      arg0 >>=
3600
                                        (fun arg0  ->
3601
                                           Result.Ok
3602
                                             (Assert
3603
                                                {
3604
                                                  label = arg0;
3605
                                                  cond = arg1;
3606
                                                  report = arg2;
3607
                                                  severity = arg3
3608
                                                }))))))
3609
                  | _::xs -> loop xs _state  in
3610
                loop xs
3611
                  ((Result.Ok NoName),
3612
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.cond"),
3613
                    (Result.Ok IsNull), (Result.Ok IsNull))
3614
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3615
      | `List ((`String "PROCEDURE_CALL_STATEMENT")::arg0::[]) ->
3616
          ((function
3617
            | `Assoc xs ->
3618
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3619
                  match xs with
3620
                  | ("label",x)::xs ->
3621
                      loop xs
3622
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3623
                  | ("name",x)::xs ->
3624
                      loop xs
3625
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3626
                  | ("assocs",x)::xs ->
3627
                      loop xs
3628
                        (arg0, arg1,
3629
                          ((function
3630
                            | `List xs ->
3631
                                map_bind
3632
                                  (fun x  -> vhdl_assoc_element_t_of_yojson x)
3633
                                  [] xs
3634
                            | _ ->
3635
                                Result.Error
3636
                                  "Vhdl_ast.vhdl_sequential_stmt_t.assocs") x))
3637
                  | [] ->
3638
                      arg2 >>=
3639
                        ((fun arg2  ->
3640
                            arg1 >>=
3641
                              (fun arg1  ->
3642
                                 arg0 >>=
3643
                                   (fun arg0  ->
3644
                                      Result.Ok
3645
                                        (ProcedureCall
3646
                                           {
3647
                                             label = arg0;
3648
                                             name = arg1;
3649
                                             assocs = arg2
3650
                                           })))))
3651
                  | _::xs -> loop xs _state  in
3652
                loop xs
3653
                  ((Result.Ok NoName),
3654
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.name"),
3655
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.assocs"))
3656
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3657
      | `List ((`String "WAIT_STATEMENT")::[]) -> Result.Ok Wait
3658
      | `List ((`String "NULL_STATEMENT")::arg0::[]) ->
3659
          ((function
3660
            | `Assoc xs ->
3661
                let rec loop xs (arg0 as _state) =
3662
                  match xs with
3663
                  | ("label",x)::xs ->
3664
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
3665
                  | [] ->
3666
                      arg0 >>=
3667
                        ((fun arg0  -> Result.Ok (Null { label = arg0 })))
3668
                  | _::xs -> loop xs _state  in
3669
                loop xs (Result.Ok NoName)
3670
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3671
      | `List ((`String "RETURN_STATEMENT")::arg0::[]) ->
3672
          ((function
3673
            | `Assoc xs ->
3674
                let rec loop xs (arg0 as _state) =
3675
                  match xs with
3676
                  | ("label",x)::xs ->
3677
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
3678
                  | [] ->
3679
                      arg0 >>=
3680
                        ((fun arg0  -> Result.Ok (Return { label = arg0 })))
3681
                  | _::xs -> loop xs _state  in
3682
                loop xs (Result.Ok NoName)
3683
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3684
      | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")
3685
  [@ocaml.warning "-A"])
3686

    
3687
and (vhdl_if_case_t_to_yojson : vhdl_if_case_t -> Yojson.Safe.json) =
3688
  ((let open! Ppx_deriving_yojson_runtime in
3689
      fun x  ->
3690
        let fields = []  in
3691
        let fields =
3692
          ("if_block",
3693
            ((fun x  ->
3694
                `List
3695
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3696
               x.if_block))
3697
          :: fields  in
3698
        let fields =
3699
          ("if_cond", ((fun x  -> vhdl_expr_t_to_yojson x) x.if_cond)) ::
3700
          fields  in
3701
        `Assoc fields)
3702
  [@ocaml.warning "-A"])
3703

    
3704
and (vhdl_if_case_t_of_yojson :
3705
      Yojson.Safe.json -> vhdl_if_case_t Ppx_deriving_yojson_runtime.error_or)
3706
  =
3707
  ((let open! Ppx_deriving_yojson_runtime in
3708
      function
3709
      | `Assoc xs ->
3710
          let rec loop xs ((arg0,arg1) as _state) =
3711
            match xs with
3712
            | ("if_cond",x)::xs ->
3713
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
3714
            | ("if_block",x)::xs ->
3715
                loop xs
3716
                  (arg0,
3717
                    ((function
3718
                      | `List xs ->
3719
                          map_bind
3720
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3721
                            xs
3722
                      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t.if_block")
3723
                       x))
3724
            | [] ->
3725
                arg1 >>=
3726
                  ((fun arg1  ->
3727
                      arg0 >>=
3728
                        (fun arg0  ->
3729
                           Result.Ok { if_cond = arg0; if_block = arg1 })))
3730
            | _::xs -> loop xs _state  in
3731
          loop xs
3732
            ((Result.Error "Vhdl_ast.vhdl_if_case_t.if_cond"),
3733
              (Result.Error "Vhdl_ast.vhdl_if_case_t.if_block"))
3734
      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t")
3735
  [@ocaml.warning "-A"])
3736

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

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

    
3798
type vhdl_declaration_t =
3799
  | VarDecl of
3800
  {
3801
  names: vhdl_name_t list ;
3802
  typ: vhdl_subtype_indication_t ;
3803
  init_val: vhdl_expr_t [@default IsNull]} [@name "VARIABLE_DECLARATION"]
3804
  | CstDecl of
3805
  {
3806
  names: vhdl_name_t list ;
3807
  typ: vhdl_subtype_indication_t ;
3808
  init_val: vhdl_expr_t } [@name "CONSTANT_DECLARATION"]
3809
  | SigDecl of
3810
  {
3811
  names: vhdl_name_t list ;
3812
  typ: vhdl_subtype_indication_t ;
3813
  init_val: vhdl_expr_t [@default IsNull]} [@name "SIGNAL_DECLARATION"]
3814
  | Subprogram of
3815
  {
3816
  name: vhdl_name_t [@default NoName];
3817
  kind: string [@default ""];
3818
  spec: vhdl_subprogram_spec_t
3819
    [@default
3820
      { name = ""; typeMark = NoName; parameters = []; isPure = false }];
3821
  decl_part: vhdl_declaration_t list [@default []];
3822
  stmts: vhdl_sequential_stmt_t list [@default []]} [@name "SUBPROGRAM_BODY"]
3823

    
3824
(* Needs adaptation for: SubProgram *)
3825
let rec pp_vhdl_declaration_t :
3826
  Format.formatter -> vhdl_declaration_t -> Ppx_deriving_runtime.unit =
3827
  let __12 () = pp_vhdl_sequential_stmt_t
3828
  
3829
  and __11 () = pp_vhdl_declaration_t
3830
  
3831
  and __10 () = pp_vhdl_subprogram_spec_t
3832
  
3833
  and __9 () = pp_vhdl_name_t
3834
  
3835
  and __8 () = pp_vhdl_expr_t
3836
  
3837
  and __7 () = pp_vhdl_subtype_indication_t
3838
  
3839
  and __6 () = pp_vhdl_name_t
3840
  
3841
  and __5 () = pp_vhdl_expr_t
3842
  
3843
  and __4 () = pp_vhdl_subtype_indication_t
3844
  
3845
  and __3 () = pp_vhdl_name_t
3846
  
3847
  and __2 () = pp_vhdl_expr_t
3848
  
3849
  and __1 () = pp_vhdl_subtype_indication_t
3850
  
3851
  and __0 () = pp_vhdl_name_t
3852
   in
3853
  ((let open! Ppx_deriving_runtime in
3854
      fun fmt  ->
3855
        function
3856
        | VarDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3857
            (Format.fprintf fmt "variable ";
3858
             ((((fun x  ->
3859
                    ignore
3860
                      (List.fold_left
3861
                         (fun sep  ->
3862
                            fun x  ->
3863
                              if sep then Format.fprintf fmt ",";
3864
                              ((__0 ()) fmt) x;
3865
                              true) false x);)) anames;
3866
               Format.fprintf fmt " : ";
3867
               ((__1 ()) fmt) atyp;
3868
               (match ainit_val with
3869
                | IsNull  -> Format.pp_print_string fmt ""
3870
                | _ ->
3871
                    (Format.fprintf fmt ":=";
3872
                     ((__2 ()) fmt) ainit_val;))));)
3873
        | CstDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3874
            (Format.fprintf fmt "constant ";
3875
             ((((fun x  ->
3876
                    ignore
3877
                      (List.fold_left
3878
                         (fun sep  ->
3879
                            fun x  ->
3880
                              if sep then Format.fprintf fmt ",";
3881
                              ((__3 ()) fmt) x;
3882
                              true) false x);)) anames;
3883
               Format.fprintf fmt " : ";
3884
               ((__4 ()) fmt) atyp;
3885
              Format.fprintf fmt ":=";
3886
              ((__5 ()) fmt) ainit_val)))
3887
        | SigDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3888
            (Format.fprintf fmt "signal ";
3889
            ((fun x  ->
3890
              ignore
3891
              (List.fold_left
3892
                (fun sep  ->
3893
                  fun x  ->
3894
                    if sep then Format.fprintf fmt ",";
3895
                                ((__6 ()) fmt) x;
3896
                                true) false x);
3897
              )) anames;
3898
            Format.fprintf fmt " : ";
3899
            ((__7 ()) fmt) atyp;
3900
            (match ainit_val with
3901
              | IsNull  -> Format.pp_print_string fmt ""
3902
              | _ ->
3903
                  (Format.fprintf fmt ":=";
3904
                  ((__8 ()) fmt) ainit_val;)))
3905
        | Subprogram
3906
            { name = aname; kind = akind; spec = aspec;
3907
              decl_part = adecl_part; stmts = astmts }
3908
            ->
3909
            (Format.fprintf fmt "@[<2>Subprogram {@,";
3910
             (((((Format.fprintf fmt "@[%s =@ " "name";
3911
                  ((__9 ()) fmt) aname;
3912
                  Format.fprintf fmt "@]");
3913
                 Format.fprintf fmt ";@ ";
3914
                 Format.fprintf fmt "@[%s =@ " "kind";
3915
                 (Format.fprintf fmt "%S") akind;
3916
                 Format.fprintf fmt "@]");
3917
                Format.fprintf fmt ";@ ";
3918
                Format.fprintf fmt "@[%s =@ " "spec";
3919
                ((__10 ()) fmt) aspec;
3920
                Format.fprintf fmt "@]");
3921
               Format.fprintf fmt ";@ ";
3922
               Format.fprintf fmt "@[%s =@ " "decl_part";
3923
               ((fun x  ->
3924
                   Format.fprintf fmt "@[<2>[";
3925
                   ignore
3926
                     (List.fold_left
3927
                        (fun sep  ->
3928
                           fun x  ->
3929
                             if sep then Format.fprintf fmt ";@ ";
3930
                             ((__11 ()) fmt) x;
3931
                             true) false x);
3932
                   Format.fprintf fmt "@,]@]")) adecl_part;
3933
               Format.fprintf fmt "@]");
3934
              Format.fprintf fmt ";@ ";
3935
              Format.fprintf fmt "@[%s =@ " "stmts";
3936
              ((fun x  ->
3937
                  Format.fprintf fmt "@[<2>[";
3938
                  ignore
3939
                    (List.fold_left
3940
                       (fun sep  ->
3941
                          fun x  ->
3942
                            if sep then Format.fprintf fmt ";@ ";
3943
                            ((__12 ()) fmt) x;
3944
                            true) false x);
3945
                  Format.fprintf fmt "@,]@]")) astmts;
3946
              Format.fprintf fmt "@]");
3947
             Format.fprintf fmt "@]}"))
3948
    [@ocaml.warning "-A"])
3949

    
3950
and show_vhdl_declaration_t :
3951
  vhdl_declaration_t -> Ppx_deriving_runtime.string =
3952
  fun x  -> Format.asprintf "%a" pp_vhdl_declaration_t x
3953

    
3954
let rec (vhdl_declaration_t_to_yojson :
3955
          vhdl_declaration_t -> Yojson.Safe.json)
3956
  =
3957
  ((let open! Ppx_deriving_yojson_runtime in
3958
      function
3959
      | VarDecl arg0 ->
3960
          `List
3961
            [`String "VARIABLE_DECLARATION";
3962
            (let fields = []  in
3963
             let fields =
3964
               if arg0.init_val = IsNull
3965
               then fields
3966
               else
3967
                 ("init_val",
3968
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.init_val))
3969
                 :: fields
3970
                in
3971
             let fields =
3972
               ("typ",
3973
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
3974
               :: fields  in
3975
             let fields =
3976
               ("names",
3977
                 ((fun x  ->
3978
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
3979
                    arg0.names))
3980
               :: fields  in
3981
             `Assoc fields)]
3982
      | CstDecl arg0 ->
3983
          `List
3984
            [`String "CONSTANT_DECLARATION";
3985
            (let fields = []  in
3986
             let fields =
3987
               ("init_val",
3988
                 ((fun x  -> vhdl_expr_t_to_yojson x) arg0.init_val))
3989
               :: fields  in
3990
             let fields =
3991
               ("typ",
3992
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
3993
               :: fields  in
3994
             let fields =
3995
               ("names",
3996
                 ((fun x  ->
3997
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
3998
                    arg0.names))
3999
               :: fields  in
4000
             `Assoc fields)]
4001
      | SigDecl arg0 ->
4002
          `List
4003
            [`String "SIGNAL_DECLARATION";
4004
            (let fields = []  in
4005
             let fields =
4006
               if arg0.init_val = IsNull
4007
               then fields
4008
               else
4009
                 ("init_val",
4010
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.init_val))
4011
                 :: fields
4012
                in
4013
             let fields =
4014
               ("typ",
4015
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
4016
               :: fields  in
4017
             let fields =
4018
               ("names",
4019
                 ((fun x  ->
4020
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
4021
                    arg0.names))
4022
               :: fields  in
4023
             `Assoc fields)]
4024
      | Subprogram arg0 ->
4025
          `List
4026
            [`String "SUBPROGRAM_BODY";
4027
            (let fields = []  in
4028
             let fields =
4029
               if arg0.stmts = []
4030
               then fields
4031
               else
4032
                 ("stmts",
4033
                   (((fun x  ->
4034
                        `List
4035
                          (List.map
4036
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
4037
                      arg0.stmts))
4038
                 :: fields
4039
                in
4040
             let fields =
4041
               if arg0.decl_part = []
4042
               then fields
4043
               else
4044
                 ("decl_part",
4045
                   (((fun x  ->
4046
                        `List
4047
                          (List.map
4048
                             (fun x  -> vhdl_declaration_t_to_yojson x) x)))
4049
                      arg0.decl_part))
4050
                 :: fields
4051
                in
4052
             let fields =
4053
               if
4054
                 arg0.spec =
4055
                   {
4056
                     name = "";
4057
                     typeMark = NoName;
4058
                     parameters = [];
4059
                     isPure = false
4060
                   }
4061
               then fields
4062
               else
4063
                 ("spec",
4064
                   (((fun x  -> vhdl_subprogram_spec_t_to_yojson x))
4065
                      arg0.spec))
4066
                 :: fields
4067
                in
4068
             let fields =
4069
               if arg0.kind = ""
4070
               then fields
4071
               else
4072
                 ("kind",
4073
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
4074
                      arg0.kind))
4075
                 :: fields
4076
                in
4077
             let fields =
4078
               if arg0.name = NoName
4079
               then fields
4080
               else
4081
                 ("name", (((fun x  -> vhdl_name_t_to_yojson x)) arg0.name))
4082
                 :: fields
4083
                in
4084
             `Assoc fields)])
4085
  [@ocaml.warning "-A"])
4086

    
4087
and (vhdl_declaration_t_of_yojson :
4088
      Yojson.Safe.json ->
4089
        vhdl_declaration_t Ppx_deriving_yojson_runtime.error_or)
4090
  =
4091
  ((let open! Ppx_deriving_yojson_runtime in
4092
      function
4093
      | `List ((`String "VARIABLE_DECLARATION")::arg0::[]) ->
4094
          ((function
4095
            | `Assoc xs ->
4096
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4097
                  match xs with
4098
                  | ("names",x)::xs ->
4099
                      loop xs
4100
                        (((function
4101
                           | `List xs ->
4102
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4103
                                 [] xs
4104
                           | _ ->
4105
                               Result.Error
4106
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4107
                          arg1, arg2)
4108
                  | ("typ",x)::xs ->
4109
                      loop xs
4110
                        (arg0,
4111
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4112
                             x), arg2)
4113
                  | ("init_val",x)::xs ->
4114
                      loop xs
4115
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4116
                  | [] ->
4117
                      arg2 >>=
4118
                        ((fun arg2  ->
4119
                            arg1 >>=
4120
                              (fun arg1  ->
4121
                                 arg0 >>=
4122
                                   (fun arg0  ->
4123
                                      Result.Ok
4124
                                        (VarDecl
4125
                                           {
4126
                                             names = arg0;
4127
                                             typ = arg1;
4128
                                             init_val = arg2
4129
                                           })))))
4130
                  | _::xs -> loop xs _state  in
4131
                loop xs
4132
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4133
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4134
                    (Result.Ok IsNull))
4135
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4136
      | `List ((`String "CONSTANT_DECLARATION")::arg0::[]) ->
4137
          ((function
4138
            | `Assoc xs ->
4139
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4140
                  match xs with
4141
                  | ("names",x)::xs ->
4142
                      loop xs
4143
                        (((function
4144
                           | `List xs ->
4145
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4146
                                 [] xs
4147
                           | _ ->
4148
                               Result.Error
4149
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4150
                          arg1, arg2)
4151
                  | ("typ",x)::xs ->
4152
                      loop xs
4153
                        (arg0,
4154
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4155
                             x), arg2)
4156
                  | ("init_val",x)::xs ->
4157
                      loop xs
4158
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4159
                  | [] ->
4160
                      arg2 >>=
4161
                        ((fun arg2  ->
4162
                            arg1 >>=
4163
                              (fun arg1  ->
4164
                                 arg0 >>=
4165
                                   (fun arg0  ->
4166
                                      Result.Ok
4167
                                        (CstDecl
4168
                                           {
4169
                                             names = arg0;
4170
                                             typ = arg1;
4171
                                             init_val = arg2
4172
                                           })))))
4173
                  | _::xs -> loop xs _state  in
4174
                loop xs
4175
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4176
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4177
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.init_val"))
4178
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4179
      | `List ((`String "SIGNAL_DECLARATION")::arg0::[]) ->
4180
          ((function
4181
            | `Assoc xs ->
4182
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4183
                  match xs with
4184
                  | ("names",x)::xs ->
4185
                      loop xs
4186
                        (((function
4187
                           | `List xs ->
4188
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4189
                                 [] xs
4190
                           | _ ->
4191
                               Result.Error
4192
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4193
                          arg1, arg2)
4194
                  | ("typ",x)::xs ->
4195
                      loop xs
4196
                        (arg0,
4197
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4198
                             x), arg2)
4199
                  | ("init_val",x)::xs ->
4200
                      loop xs
4201
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4202
                  | [] ->
4203
                      arg2 >>=
4204
                        ((fun arg2  ->
4205
                            arg1 >>=
4206
                              (fun arg1  ->
4207
                                 arg0 >>=
4208
                                   (fun arg0  ->
4209
                                      Result.Ok
4210
                                        (SigDecl
4211
                                           {
4212
                                             names = arg0;
4213
                                             typ = arg1;
4214
                                             init_val = arg2
4215
                                           })))))
4216
                  | _::xs -> loop xs _state  in
4217
                loop xs
4218
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4219
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4220
                    (Result.Ok IsNull))
4221
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4222
      | `List ((`String "SUBPROGRAM_BODY")::arg0::[]) ->
4223
          ((function
4224
            | `Assoc xs ->
4225
                let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
4226
                  match xs with
4227
                  | ("name",x)::xs ->
4228
                      loop xs
4229
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2,
4230
                          arg3, arg4)
4231
                  | ("kind",x)::xs ->
4232
                      loop xs
4233
                        (arg0,
4234
                          ((function
4235
                            | `String x -> Result.Ok x
4236
                            | _ ->
4237
                                Result.Error
4238
                                  "Vhdl_ast.vhdl_declaration_t.kind") x),
4239
                          arg2, arg3, arg4)
4240
                  | ("spec",x)::xs ->
4241
                      loop xs
4242
                        (arg0, arg1,
4243
                          ((fun x  -> vhdl_subprogram_spec_t_of_yojson x) x),
4244
                          arg3, arg4)
4245
                  | ("decl_part",x)::xs ->
4246
                      loop xs
4247
                        (arg0, arg1, arg2,
4248
                          ((function
4249
                            | `List xs ->
4250
                                map_bind
4251
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4252
                                  [] xs
4253
                            | _ ->
4254
                                Result.Error
4255
                                  "Vhdl_ast.vhdl_declaration_t.decl_part") x),
4256
                          arg4)
4257
                  | ("stmts",x)::xs ->
4258
                      loop xs
4259
                        (arg0, arg1, arg2, arg3,
4260
                          ((function
4261
                            | `List xs ->
4262
                                map_bind
4263
                                  (fun x  ->
4264
                                     vhdl_sequential_stmt_t_of_yojson x) []
4265
                                  xs
4266
                            | _ ->
4267
                                Result.Error
4268
                                  "Vhdl_ast.vhdl_declaration_t.stmts") x))
4269
                  | [] ->
4270
                      arg4 >>=
4271
                        ((fun arg4  ->
4272
                            arg3 >>=
4273
                              (fun arg3  ->
4274
                                 arg2 >>=
4275
                                   (fun arg2  ->
4276
                                      arg1 >>=
4277
                                        (fun arg1  ->
4278
                                           arg0 >>=
4279
                                             (fun arg0  ->
4280
                                                Result.Ok
4281
                                                  (Subprogram
4282
                                                     {
4283
                                                       name = arg0;
4284
                                                       kind = arg1;
4285
                                                       spec = arg2;
4286
                                                       decl_part = arg3;
4287
                                                       stmts = arg4
4288
                                                     })))))))
4289
                  | _::xs -> loop xs _state  in
4290
                loop xs
4291
                  ((Result.Ok NoName), (Result.Ok ""),
4292
                    (Result.Ok
4293
                       {
4294
                         name = "";
4295
                         typeMark = NoName;
4296
                         parameters = [];
4297
                         isPure = false
4298
                       }), (Result.Ok []), (Result.Ok []))
4299
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4300
      | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")
4301
  [@ocaml.warning "-A"])
4302

    
4303
type vhdl_signal_condition_t =
4304
  {
4305
  expr: vhdl_expr_t list ;
4306
  cond: vhdl_expr_t [@default IsNull]}
4307

    
4308
let rec pp_vhdl_signal_condition_t :
4309
  Format.formatter -> vhdl_signal_condition_t -> Ppx_deriving_runtime.unit =
4310
  let __1 () = pp_vhdl_expr_t
4311
  
4312
  and __0 () = pp_vhdl_expr_t
4313
   in
4314
  ((let open! Ppx_deriving_runtime in
4315
      fun fmt  ->
4316
        fun x  ->
4317
          ((fun x  ->
4318
              ignore
4319
                (List.fold_left
4320
                   (fun sep  ->
4321
                      fun x  ->
4322
                        if sep then Format.fprintf fmt ";@ ";
4323
                        ((__0 ()) fmt) x;
4324
                        true) false x))) x.expr;
4325
          (match x.cond with
4326
          | IsNull -> Format.fprintf fmt "";
4327
          | _ -> Format.fprintf fmt "when ";
4328
                 ((__1 ()) fmt) x.cond);)
4329
    [@ocaml.warning "-A"])
4330

    
4331
and show_vhdl_signal_condition_t :
4332
  vhdl_signal_condition_t -> Ppx_deriving_runtime.string =
4333
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_condition_t x
4334

    
4335
let rec (vhdl_signal_condition_t_to_yojson :
4336
          vhdl_signal_condition_t -> Yojson.Safe.json)
4337
  =
4338
  ((let open! Ppx_deriving_yojson_runtime in
4339
      fun x  ->
4340
        let fields = []  in
4341
        let fields =
4342
          if x.cond = IsNull
4343
          then fields
4344
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4345
            fields
4346
           in
4347
        let fields =
4348
          ("expr",
4349
            ((fun x  ->
4350
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
4351
               x.expr))
4352
          :: fields  in
4353
        `Assoc fields)
4354
  [@ocaml.warning "-A"])
4355

    
4356
and (vhdl_signal_condition_t_of_yojson :
4357
      Yojson.Safe.json ->
4358
        vhdl_signal_condition_t Ppx_deriving_yojson_runtime.error_or)
4359
  =
4360
  ((let open! Ppx_deriving_yojson_runtime in
4361
      function
4362
      | `Assoc xs ->
4363
          let rec loop xs ((arg0,arg1) as _state) =
4364
            match xs with
4365
            | ("expr",x)::xs ->
4366
                loop xs
4367
                  (((function
4368
                     | `List xs ->
4369
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4370
                     | _ ->
4371
                         Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr")
4372
                      x), arg1)
4373
            | ("cond",x)::xs ->
4374
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4375
            | [] ->
4376
                arg1 >>=
4377
                  ((fun arg1  ->
4378
                      arg0 >>=
4379
                        (fun arg0  -> Result.Ok { expr = arg0; cond = arg1 })))
4380
            | _::xs -> loop xs _state  in
4381
          loop xs
4382
            ((Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr"),
4383
              (Result.Ok IsNull))
4384
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_condition_t")
4385
  [@ocaml.warning "-A"])
4386

    
4387
type vhdl_signal_selection_t =
4388
  {
4389
  expr: vhdl_expr_t ;
4390
  when_sel: vhdl_expr_t list [@default []]}
4391

    
4392
(* TODO *)
4393
let rec pp_vhdl_signal_selection_t :
4394
  Format.formatter -> vhdl_signal_selection_t -> Ppx_deriving_runtime.unit =
4395
  let __1 () = pp_vhdl_expr_t
4396
  
4397
  and __0 () = pp_vhdl_expr_t
4398
   in
4399
  ((let open! Ppx_deriving_runtime in
4400
      fun fmt  ->
4401
        fun x  ->
4402
          Format.fprintf fmt "@[<2>{ ";
4403
          ((Format.fprintf fmt "@[%s =@ " "expr";
4404
            ((__0 ()) fmt) x.expr;
4405
            Format.fprintf fmt "@]");
4406
           Format.fprintf fmt ";@ ";
4407
           Format.fprintf fmt "@[%s =@ " "when_sel";
4408
           ((fun x  ->
4409
               Format.fprintf fmt "@[<2>[";
4410
               ignore
4411
                 (List.fold_left
4412
                    (fun sep  ->
4413
                       fun x  ->
4414
                         if sep then Format.fprintf fmt ";@ ";
4415
                         ((__1 ()) fmt) x;
4416
                         true) false x);
4417
               Format.fprintf fmt "@,]@]")) x.when_sel;
4418
           Format.fprintf fmt "@]");
4419
          Format.fprintf fmt "@ }@]")
4420
    [@ocaml.warning "-A"])
4421

    
4422
and show_vhdl_signal_selection_t :
4423
  vhdl_signal_selection_t -> Ppx_deriving_runtime.string =
4424
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_selection_t x
4425

    
4426
let rec (vhdl_signal_selection_t_to_yojson :
4427
          vhdl_signal_selection_t -> Yojson.Safe.json)
4428
  =
4429
  ((let open! Ppx_deriving_yojson_runtime in
4430
      fun x  ->
4431
        let fields = []  in
4432
        let fields =
4433
          if x.when_sel = []
4434
          then fields
4435
          else
4436
            ("when_sel",
4437
              (((fun x  ->
4438
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
4439
                 x.when_sel))
4440
            :: fields
4441
           in
4442
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
4443
          :: fields  in
4444
        `Assoc fields)
4445
  [@ocaml.warning "-A"])
4446

    
4447
and (vhdl_signal_selection_t_of_yojson :
4448
      Yojson.Safe.json ->
4449
        vhdl_signal_selection_t Ppx_deriving_yojson_runtime.error_or)
4450
  =
4451
  ((let open! Ppx_deriving_yojson_runtime in
4452
      function
4453
      | `Assoc xs ->
4454
          let rec loop xs ((arg0,arg1) as _state) =
4455
            match xs with
4456
            | ("expr",x)::xs ->
4457
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
4458
            | ("when_sel",x)::xs ->
4459
                loop xs
4460
                  (arg0,
4461
                    ((function
4462
                      | `List xs ->
4463
                          map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4464
                      | _ ->
4465
                          Result.Error
4466
                            "Vhdl_ast.vhdl_signal_selection_t.when_sel") x))
4467
            | [] ->
4468
                arg1 >>=
4469
                  ((fun arg1  ->
4470
                      arg0 >>=
4471
                        (fun arg0  ->
4472
                           Result.Ok { expr = arg0; when_sel = arg1 })))
4473
            | _::xs -> loop xs _state  in
4474
          loop xs
4475
            ((Result.Error "Vhdl_ast.vhdl_signal_selection_t.expr"),
4476
              (Result.Ok []))
4477
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_selection_t")
4478
  [@ocaml.warning "-A"])
4479

    
4480
type vhdl_conditional_signal_t =
4481
  {
4482
  postponed: bool [@default false];
4483
  label: vhdl_name_t [@default NoName];
4484
  lhs: vhdl_name_t ;
4485
  rhs: vhdl_signal_condition_t list ;
4486
  cond: vhdl_expr_t [@default IsNull];
4487
  delay: vhdl_expr_t [@default IsNull]}
4488

    
4489
let rec pp_vhdl_conditional_signal_t :
4490
  Format.formatter -> vhdl_conditional_signal_t -> Ppx_deriving_runtime.unit
4491
  =
4492
  let __4 () = pp_vhdl_expr_t
4493
  
4494
  and __3 () = pp_vhdl_expr_t
4495
  
4496
  and __2 () = pp_vhdl_signal_condition_t
4497
  
4498
  and __1 () = pp_vhdl_name_t
4499
  
4500
  and __0 () = pp_vhdl_name_t
4501
   in
4502
  ((let open! Ppx_deriving_runtime in
4503
      fun fmt  ->
4504
        fun x  ->
4505
          (match x.label with
4506
            | NoName -> Format.fprintf fmt "";
4507
            | _ -> (((__0 ()) fmt) x.label;
4508
                   Format.fprintf fmt ":@ ")
4509
          );
4510
          if (x.postponed) then Format.fprintf fmt "postponed@ ";
4511
          ((__1 ()) fmt) x.lhs;
4512
          Format.fprintf fmt " <= ";
4513
          (match x.delay with
4514
            | IsNull -> Format.fprintf fmt "";
4515
            | _ -> ((__4 ()) fmt) x.delay;
4516
                   Format.fprintf fmt " ");
4517
          ((fun x  ->
4518
             Format.fprintf fmt "@[";
4519
             ignore
4520
               (List.fold_left
4521
                 (fun sep  ->
4522
                   fun x  ->
4523
                     if sep then Format.fprintf fmt "";
4524
                      ((__2 ()) fmt) x;
4525
                      Format.fprintf fmt ";";
4526
                      true) false x);
4527
          Format.fprintf fmt "@]")) x.rhs;
4528
          (match x.cond with
4529
            | IsNull -> Format.fprintf fmt "";
4530
            | _ -> Format.fprintf fmt "when (";
4531
                   ((__3 ()) fmt) x.cond;
4532
                   Format.fprintf fmt ")"))
4533
   [@ocaml.warning "-A"])
4534

    
4535
and show_vhdl_conditional_signal_t :
4536
  vhdl_conditional_signal_t -> Ppx_deriving_runtime.string =
4537
  fun x  -> Format.asprintf "%a" pp_vhdl_conditional_signal_t x
4538

    
4539
let rec (vhdl_conditional_signal_t_to_yojson :
4540
          vhdl_conditional_signal_t -> Yojson.Safe.json)
4541
  =
4542
  ((let open! Ppx_deriving_yojson_runtime in
4543
      fun x  ->
4544
        let fields = []  in
4545
        let fields =
4546
          if x.delay = IsNull
4547
          then fields
4548
          else ("delay", (((fun x  -> vhdl_expr_t_to_yojson x)) x.delay)) ::
4549
            fields
4550
           in
4551
        let fields =
4552
          if x.cond = IsNull
4553
          then fields
4554
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4555
            fields
4556
           in
4557
        let fields =
4558
          ("rhs",
4559
            ((fun x  ->
4560
                `List
4561
                  (List.map (fun x  -> vhdl_signal_condition_t_to_yojson x) x))
4562
               x.rhs))
4563
          :: fields  in
4564
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4565
          fields  in
4566
        let fields =
4567
          if x.label = NoName
4568
          then fields
4569
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4570
            fields
4571
           in
4572
        let fields =
4573
          if x.postponed = false
4574
          then fields
4575
          else
4576
            ("postponed",
4577
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4578
                 x.postponed))
4579
            :: fields
4580
           in
4581
        `Assoc fields)
4582
  [@ocaml.warning "-A"])
4583

    
4584
and (vhdl_conditional_signal_t_of_yojson :
4585
      Yojson.Safe.json ->
4586
        vhdl_conditional_signal_t Ppx_deriving_yojson_runtime.error_or)
4587
  =
4588
  ((let open! Ppx_deriving_yojson_runtime in
4589
      function
4590
      | `Assoc xs ->
4591
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4592
            match xs with
4593
            | ("postponed",x)::xs ->
4594
                loop xs
4595
                  (((function
4596
                     | `Bool x -> Result.Ok x
4597
                     | _ ->
4598
                         Result.Error
4599
                           "Vhdl_ast.vhdl_conditional_signal_t.postponed") x),
4600
                    arg1, arg2, arg3, arg4, arg5)
4601
            | ("label",x)::xs ->
4602
                loop xs
4603
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4604
                    arg4, arg5)
4605
            | ("lhs",x)::xs ->
4606
                loop xs
4607
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4608
                    arg4, arg5)
4609
            | ("rhs",x)::xs ->
4610
                loop xs
4611
                  (arg0, arg1, arg2,
4612
                    ((function
4613
                      | `List xs ->
4614
                          map_bind
4615
                            (fun x  -> vhdl_signal_condition_t_of_yojson x)
4616
                            [] xs
4617
                      | _ ->
4618
                          Result.Error
4619
                            "Vhdl_ast.vhdl_conditional_signal_t.rhs") x),
4620
                    arg4, arg5)
4621
            | ("cond",x)::xs ->
4622
                loop xs
4623
                  (arg0, arg1, arg2, arg3,
4624
                    ((fun x  -> vhdl_expr_t_of_yojson x) x), arg5)
4625
            | ("delay",x)::xs ->
4626
                loop xs
4627
                  (arg0, arg1, arg2, arg3, arg4,
4628
                    ((fun x  -> vhdl_expr_t_of_yojson x) x))
4629
            | [] ->
4630
                arg5 >>=
4631
                  ((fun arg5  ->
4632
                      arg4 >>=
4633
                        (fun arg4  ->
4634
                           arg3 >>=
4635
                             (fun arg3  ->
4636
                                arg2 >>=
4637
                                  (fun arg2  ->
4638
                                     arg1 >>=
4639
                                       (fun arg1  ->
4640
                                          arg0 >>=
4641
                                            (fun arg0  ->
4642
                                               Result.Ok
4643
                                                 {
4644
                                                   postponed = arg0;
4645
                                                   label = arg1;
4646
                                                   lhs = arg2;
4647
                                                   rhs = arg3;
4648
                                                   cond = arg4;
4649
                                                   delay = arg5
4650
                                                 })))))))
4651
            | _::xs -> loop xs _state  in
4652
          loop xs
4653
            ((Result.Ok false), (Result.Ok NoName),
4654
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.lhs"),
4655
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.rhs"),
4656
              (Result.Ok IsNull), (Result.Ok IsNull))
4657
      | _ -> Result.Error "Vhdl_ast.vhdl_conditional_signal_t")
4658
  [@ocaml.warning "-A"])
4659

    
4660
type vhdl_process_t =
4661
  {
4662
  id: vhdl_name_t [@default NoName];
4663
  declarations: vhdl_declaration_t list option
4664
    [@key "PROCESS_DECLARATIVE_PART"][@default Some []];
4665
  active_sigs: vhdl_name_t list [@default []];
4666
  body: vhdl_sequential_stmt_t list
4667
    [@key "PROCESS_STATEMENT_PART"][@default []]}
4668

    
4669
let rec pp_vhdl_process_t :
4670
  Format.formatter -> vhdl_process_t -> Ppx_deriving_runtime.unit =
4671
  let __3 () = pp_vhdl_sequential_stmt_t
4672
  
4673
  and __2 () = pp_vhdl_name_t
4674
  
4675
  and __1 () = pp_vhdl_declaration_t
4676
  
4677
  and __0 () = pp_vhdl_name_t
4678
   in
4679
  ((let open! Ppx_deriving_runtime in
4680
      fun fmt  ->
4681
        fun x  ->
4682
          Format.fprintf fmt "@[<v>process ";
4683
          (match x.active_sigs with
4684
          | [] -> Format.fprintf fmt "";
4685
          | _ -> Format.fprintf fmt "(";
4686
                 ((fun x  ->
4687
                    ignore
4688
                      (List.fold_left
4689
                         (fun sep  ->
4690
                            fun x  ->
4691
                              if sep then Format.fprintf fmt ",";
4692
                              ((__2 ()) fmt) x;
4693
                              true) false x))) x.active_sigs;
4694
                 Format.fprintf fmt ")");
4695
          ((function
4696
             | None  -> Format.pp_print_string fmt ""
4697
             | Some x ->
4698
                  ((fun x  ->
4699
                      Format.fprintf fmt "@[<2>";
4700
                      ignore
4701
                        (List.fold_left
4702
                           (fun sep  ->
4703
                              fun x  ->
4704
                                if sep then Format.fprintf fmt "@;";
4705
                                ((__1 ()) fmt) x;
4706
                                true) false x);
4707
                      Format.fprintf fmt "@]")) x;)) x.declarations;
4708
          Format.fprintf fmt "@;@[<v 2>begin@;";
4709
          ((fun x  ->
4710
               ignore
4711
                 (List.fold_left
4712
                    (fun sep  ->
4713
                       fun x  ->
4714
                         if sep then Format.fprintf fmt "@;";
4715
                         ((__3 ()) fmt) x;
4716
                         true) false x);)) x.body;
4717
          Format.fprintf fmt "@]@;end process;@;";
4718
          Format.fprintf fmt "@]";)
4719
    [@ocaml.warning "-A"])
4720

    
4721
and show_vhdl_process_t : vhdl_process_t -> Ppx_deriving_runtime.string =
4722
  fun x  -> Format.asprintf "%a" pp_vhdl_process_t x
4723

    
4724
let rec (vhdl_process_t_to_yojson : vhdl_process_t -> Yojson.Safe.json) =
4725
  ((let open! Ppx_deriving_yojson_runtime in
4726
      fun x  ->
4727
        let fields = []  in
4728
        let fields =
4729
          if x.body = []
4730
          then fields
4731
          else
4732
            ("PROCESS_STATEMENT_PART",
4733
              (((fun x  ->
4734
                   `List
4735
                     (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x)
4736
                        x))) x.body))
4737
            :: fields
4738
           in
4739
        let fields =
4740
          if x.active_sigs = []
4741
          then fields
4742
          else
4743
            ("active_sigs",
4744
              (((fun x  ->
4745
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
4746
                 x.active_sigs))
4747
            :: fields
4748
           in
4749
        let fields =
4750
          if x.declarations = (Some [])
4751
          then fields
4752
          else
4753
            ("PROCESS_DECLARATIVE_PART",
4754
              (((function
4755
                 | None  -> `Null
4756
                 | Some x ->
4757
                     ((fun x  ->
4758
                         `List
4759
                           (List.map
4760
                              (fun x  -> vhdl_declaration_t_to_yojson x) x)))
4761
                       x)) x.declarations))
4762
            :: fields
4763
           in
4764
        let fields =
4765
          if x.id = NoName
4766
          then fields
4767
          else ("id", (((fun x  -> vhdl_name_t_to_yojson x)) x.id)) :: fields
4768
           in
4769
        `Assoc fields)
4770
  [@ocaml.warning "-A"])
4771

    
4772
and (vhdl_process_t_of_yojson :
4773
      Yojson.Safe.json -> vhdl_process_t Ppx_deriving_yojson_runtime.error_or)
4774
  =
4775
  ((let open! Ppx_deriving_yojson_runtime in
4776
      function
4777
      | `Assoc xs ->
4778
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
4779
            match xs with
4780
            | ("id",x)::xs ->
4781
                loop xs
4782
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3)
4783
            | ("PROCESS_DECLARATIVE_PART",x)::xs ->
4784
                loop xs
4785
                  (arg0,
4786
                    ((function
4787
                      | `Null -> Result.Ok None
4788
                      | x ->
4789
                          ((function
4790
                            | `List xs ->
4791
                                map_bind
4792
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4793
                                  [] xs
4794
                            | _ ->
4795
                                Result.Error
4796
                                  "Vhdl_ast.vhdl_process_t.declarations") x)
4797
                            >>= ((fun x  -> Result.Ok (Some x)))) x), arg2,
4798
                    arg3)
4799
            | ("active_sigs",x)::xs ->
4800
                loop xs
4801
                  (arg0, arg1,
4802
                    ((function
4803
                      | `List xs ->
4804
                          map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4805
                      | _ ->
4806
                          Result.Error "Vhdl_ast.vhdl_process_t.active_sigs")
4807
                       x), arg3)
4808
            | ("PROCESS_STATEMENT_PART",x)::xs ->
4809
                loop xs
4810
                  (arg0, arg1, arg2,
4811
                    ((function
4812
                      | `List xs ->
4813
                          map_bind
4814
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
4815
                            xs
4816
                      | _ -> Result.Error "Vhdl_ast.vhdl_process_t.body") x))
4817
            | [] ->
4818
                arg3 >>=
4819
                  ((fun arg3  ->
4820
                      arg2 >>=
4821
                        (fun arg2  ->
4822
                           arg1 >>=
4823
                             (fun arg1  ->
4824
                                arg0 >>=
4825
                                  (fun arg0  ->
4826
                                     Result.Ok
4827
                                       {
4828
                                         id = arg0;
4829
                                         declarations = arg1;
4830
                                         active_sigs = arg2;
4831
                                         body = arg3
4832
                                       })))))
4833
            | _::xs -> loop xs _state  in
4834
          loop xs
4835
            ((Result.Ok NoName), (Result.Ok (Some [])), (Result.Ok []),
4836
              (Result.Ok []))
4837
      | _ -> Result.Error "Vhdl_ast.vhdl_process_t")
4838
  [@ocaml.warning "-A"])
4839

    
4840
type vhdl_selected_signal_t =
4841
  {
4842
  postponed: bool [@default false];
4843
  label: vhdl_name_t [@default NoName];
4844
  lhs: vhdl_name_t ;
4845
  sel: vhdl_expr_t ;
4846
  branches: vhdl_signal_selection_t list [@default []];
4847
  delay: vhdl_expr_t option }
4848

    
4849
(* TODO *)
4850
let rec pp_vhdl_selected_signal_t :
4851
  Format.formatter -> vhdl_selected_signal_t -> Ppx_deriving_runtime.unit =
4852
  let __4 () = pp_vhdl_expr_t
4853
  
4854
  and __3 () = pp_vhdl_signal_selection_t
4855
  
4856
  and __2 () = pp_vhdl_expr_t
4857
  
4858
  and __1 () = pp_vhdl_name_t
4859
  
4860
  and __0 () = pp_vhdl_name_t
4861
   in
4862
  ((let open! Ppx_deriving_runtime in
4863
      fun fmt  ->
4864
        fun x  ->
4865
          Format.fprintf fmt "@[<2>{ ";
4866
          ((((((Format.fprintf fmt "@[%s =@ " "postponed";
4867
                (Format.fprintf fmt "%B") x.postponed;
4868
                Format.fprintf fmt "@]");
4869
               Format.fprintf fmt ";@ ";
4870
               Format.fprintf fmt "@[%s =@ " "label";
4871
               ((__0 ()) fmt) x.label;
4872
               Format.fprintf fmt "@]");
4873
              Format.fprintf fmt ";@ ";
4874
              Format.fprintf fmt "@[%s =@ " "lhs";
4875
              ((__1 ()) fmt) x.lhs;
4876
              Format.fprintf fmt "@]");
4877
             Format.fprintf fmt ";@ ";
4878
             Format.fprintf fmt "@[%s =@ " "sel";
4879
             ((__2 ()) fmt) x.sel;
4880
             Format.fprintf fmt "@]");
4881
            Format.fprintf fmt ";@ ";
4882
            Format.fprintf fmt "@[%s =@ " "branches";
4883
            ((fun x  ->
4884
                Format.fprintf fmt "@[<2>[";
4885
                ignore
4886
                  (List.fold_left
4887
                     (fun sep  ->
4888
                        fun x  ->
4889
                          if sep then Format.fprintf fmt ";@ ";
4890
                          ((__3 ()) fmt) x;
4891
                          true) false x);
4892
                Format.fprintf fmt "@,]@]")) x.branches;
4893
            Format.fprintf fmt "@]");
4894
           Format.fprintf fmt ";@ ";
4895
           Format.fprintf fmt "@[%s =@ " "delay";
4896
           ((function
4897
             | None  -> Format.pp_print_string fmt "None"
4898
             | Some x ->
4899
                 (Format.pp_print_string fmt "(Some ";
4900
                  ((__4 ()) fmt) x;
4901
                  Format.pp_print_string fmt ")"))) x.delay;
4902
           Format.fprintf fmt "@]");
4903
          Format.fprintf fmt "@ }@]")
4904
    [@ocaml.warning "-A"])
4905

    
4906
and show_vhdl_selected_signal_t :
4907
  vhdl_selected_signal_t -> Ppx_deriving_runtime.string =
4908
  fun x  -> Format.asprintf "%a" pp_vhdl_selected_signal_t x
4909

    
4910
let rec (vhdl_selected_signal_t_to_yojson :
4911
          vhdl_selected_signal_t -> Yojson.Safe.json)
4912
  =
4913
  ((let open! Ppx_deriving_yojson_runtime in
4914
      fun x  ->
4915
        let fields = []  in
4916
        let fields =
4917
          ("delay",
4918
            ((function
4919
              | None  -> `Null
4920
              | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x) x.delay))
4921
          :: fields  in
4922
        let fields =
4923
          if x.branches = []
4924
          then fields
4925
          else
4926
            ("branches",
4927
              (((fun x  ->
4928
                   `List
4929
                     (List.map
4930
                        (fun x  -> vhdl_signal_selection_t_to_yojson x) x)))
4931
                 x.branches))
4932
            :: fields
4933
           in
4934
        let fields = ("sel", ((fun x  -> vhdl_expr_t_to_yojson x) x.sel)) ::
4935
          fields  in
4936
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4937
          fields  in
4938
        let fields =
4939
          if x.label = NoName
4940
          then fields
4941
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4942
            fields
4943
           in
4944
        let fields =
4945
          if x.postponed = false
4946
          then fields
4947
          else
4948
            ("postponed",
4949
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4950
                 x.postponed))
4951
            :: fields
4952
           in
4953
        `Assoc fields)
4954
  [@ocaml.warning "-A"])
4955

    
4956
and (vhdl_selected_signal_t_of_yojson :
4957
      Yojson.Safe.json ->
4958
        vhdl_selected_signal_t Ppx_deriving_yojson_runtime.error_or)
4959
  =
4960
  ((let open! Ppx_deriving_yojson_runtime in
4961
      function
4962
      | `Assoc xs ->
4963
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4964
            match xs with
4965
            | ("postponed",x)::xs ->
4966
                loop xs
4967
                  (((function
4968
                     | `Bool x -> Result.Ok x
4969
                     | _ ->
4970
                         Result.Error
4971
                           "Vhdl_ast.vhdl_selected_signal_t.postponed") x),
4972
                    arg1, arg2, arg3, arg4, arg5)
4973
            | ("label",x)::xs ->
4974
                loop xs
4975
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4976
                    arg4, arg5)
4977
            | ("lhs",x)::xs ->
4978
                loop xs
4979
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4980
                    arg4, arg5)
4981
            | ("sel",x)::xs ->
4982
                loop xs
4983
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x),
4984
                    arg4, arg5)
4985
            | ("branches",x)::xs ->
4986
                loop xs
4987
                  (arg0, arg1, arg2, arg3,
4988
                    ((function
4989
                      | `List xs ->
4990
                          map_bind
4991
                            (fun x  -> vhdl_signal_selection_t_of_yojson x)
4992
                            [] xs
4993
                      | _ ->
4994
                          Result.Error
4995
                            "Vhdl_ast.vhdl_selected_signal_t.branches") x),
4996
                    arg5)
4997
            | ("delay",x)::xs ->
4998
                loop xs
4999
                  (arg0, arg1, arg2, arg3, arg4,
5000
                    ((function
5001
                      | `Null -> Result.Ok None
5002
                      | x ->
5003
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
5004
                            ((fun x  -> Result.Ok (Some x)))) x))
5005
            | [] ->
5006
                arg5 >>=
5007
                  ((fun arg5  ->
5008
                      arg4 >>=
5009
                        (fun arg4  ->
5010
                           arg3 >>=
5011
                             (fun arg3  ->
5012
                                arg2 >>=
5013
                                  (fun arg2  ->
5014
                                     arg1 >>=
5015
                                       (fun arg1  ->
5016
                                          arg0 >>=
5017
                                            (fun arg0  ->
5018
                                               Result.Ok
5019
                                                 {
5020
                                                   postponed = arg0;
5021
                                                   label = arg1;
5022
                                                   lhs = arg2;
5023
                                                   sel = arg3;
5024
                                                   branches = arg4;
5025
                                                   delay = arg5
5026
                                                 })))))))
5027
            | _::xs -> loop xs _state  in
5028
          loop xs
5029
            ((Result.Ok false), (Result.Ok NoName),
5030
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.lhs"),
5031
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.sel"),
5032
              (Result.Ok []),
5033
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.delay"))
5034
      | _ -> Result.Error "Vhdl_ast.vhdl_selected_signal_t")
5035
  [@ocaml.warning "-A"])
5036

    
5037
type vhdl_component_instantiation_t =
5038
  {
5039
  name: vhdl_name_t ;
5040
  inst_unit: vhdl_name_t ;
5041
  archi_name: vhdl_name_t option [@default None];
5042
  generic_map: vhdl_assoc_element_t option [@default None];
5043
  port_map: vhdl_assoc_element_t option [@default None]}[@@deriving
5044
                                                          ((show
5045
                                                              {
5046
                                                                with_path =
5047
                                                                  false
5048
                                                              }),
5049
                                                            (yojson
5050
                                                               {
5051
                                                                 strict =
5052
                                                                   false
5053
                                                               }))]
5054

    
5055
(* TODO *)
5056
let rec pp_vhdl_component_instantiation_t :
5057
  Format.formatter ->
5058
    vhdl_component_instantiation_t -> Ppx_deriving_runtime.unit
5059
  =
5060
  let __4 () = pp_vhdl_assoc_element_t
5061
  
5062
  and __3 () = pp_vhdl_assoc_element_t
5063
  
5064
  and __2 () = pp_vhdl_name_t
5065
  
5066
  and __1 () = pp_vhdl_name_t
5067
  
5068
  and __0 () = pp_vhdl_name_t
5069
   in
5070
  ((let open! Ppx_deriving_runtime in
5071
      fun fmt  ->
5072
        fun x  ->
5073
          ((__0 ()) fmt) x.name;
5074
          Format.fprintf fmt " : ";
5075
          ((__1 ()) fmt) x.inst_unit;
5076
          ((function
5077
             | None  -> Format.pp_print_string fmt ""
5078
             | Some x ->
5079
                 (Format.pp_print_string fmt "(";
5080
                 ((__2 ()) fmt) x;
5081
                 Format.pp_print_string fmt ")@;"))) x.archi_name;
5082
          ((function
5083
             | None  -> Format.pp_print_string fmt ""
5084
             | Some x ->
5085
                 (Format.pp_print_string fmt "(";
5086
                 ((__3 ()) fmt) x;
5087
                 Format.pp_print_string fmt ")@;"))) x.generic_map;
5088
          ((function
5089
             | None  -> Format.pp_print_string fmt "None"
5090
             | Some x ->
5091
                 (Format.pp_print_string fmt "(";
5092
                 ((__4 ()) fmt) x;
5093
                 Format.pp_print_string fmt ")@;"))) x.port_map;)
5094
    [@ocaml.warning "-A"])
5095

    
5096
and show_vhdl_component_instantiation_t :
5097
  vhdl_component_instantiation_t -> Ppx_deriving_runtime.string =
5098
  fun x  -> Format.asprintf "%a" pp_vhdl_component_instantiation_t x
5099

    
5100
let rec (vhdl_component_instantiation_t_to_yojson :
5101
          vhdl_component_instantiation_t -> Yojson.Safe.json)
5102
  =
5103
  ((let open! Ppx_deriving_yojson_runtime in
5104
      fun x  ->
5105
        let fields = []  in
5106
        let fields =
5107
          if x.port_map = None
5108
          then fields
5109
          else
5110
            ("port_map",
5111
              (((function
5112
                 | None  -> `Null
5113
                 | Some x -> ((fun x  -> vhdl_assoc_element_t_to_yojson x)) x))
5114
                 x.port_map))
5115
            :: fields
5116
           in
5117
        let fields =
5118
          if x.generic_map = None
5119
          then fields
5120
          else
5121
            ("generic_map",
5122
              (((function
5123
                 | None  -> `Null
5124
                 | Some x -> ((fun x  -> vhdl_assoc_element_t_to_yojson x)) x))
5125
                 x.generic_map))
5126
            :: fields
5127
           in
5128
        let fields =
5129
          if x.archi_name = None
5130
          then fields
5131
          else
5132
            ("archi_name",
5133
              (((function
5134
                 | None  -> `Null
5135
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
5136
                 x.archi_name))
5137
            :: fields
5138
           in
5139
        let fields =
5140
          ("inst_unit", ((fun x  -> vhdl_name_t_to_yojson x) x.inst_unit)) ::
5141
          fields  in
5142
        let fields = ("name", ((fun x  -> vhdl_name_t_to_yojson x) x.name))
5143
          :: fields  in
5144
        `Assoc fields)
5145
  [@ocaml.warning "-A"])
5146

    
5147
and (vhdl_component_instantiation_t_of_yojson :
5148
      Yojson.Safe.json ->
5149
        vhdl_component_instantiation_t Ppx_deriving_yojson_runtime.error_or)
5150
  =
5151
  ((let open! Ppx_deriving_yojson_runtime in
5152
      function
5153
      | `Assoc xs ->
5154
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
5155
            match xs with
5156
            | ("name",x)::xs ->
5157
                loop xs
5158
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3,
5159
                    arg4)
5160
            | ("inst_unit",x)::xs ->
5161
                loop xs
5162
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
5163
                    arg4)
5164
            | ("archi_name",x)::xs ->
5165
                loop xs
5166
                  (arg0, arg1,
5167
                    ((function
5168
                      | `Null -> Result.Ok None
5169
                      | x ->
5170
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
5171
                            ((fun x  -> Result.Ok (Some x)))) x), arg3, arg4)
5172
            | ("generic_map",x)::xs ->
5173
                loop xs
5174
                  (arg0, arg1, arg2,
5175
                    ((function
5176
                      | `Null -> Result.Ok None
5177
                      | x ->
5178
                          ((fun x  -> vhdl_assoc_element_t_of_yojson x) x)
5179
                            >>= ((fun x  -> Result.Ok (Some x)))) x), arg4)
5180
            | ("port_map",x)::xs ->
5181
                loop xs
5182
                  (arg0, arg1, arg2, arg3,
5183
                    ((function
5184
                      | `Null -> Result.Ok None
5185
                      | x ->
5186
                          ((fun x  -> vhdl_assoc_element_t_of_yojson x) x)
5187
                            >>= ((fun x  -> Result.Ok (Some x)))) x))
5188
            | [] ->
5189
                arg4 >>=
5190
                  ((fun arg4  ->
5191
                      arg3 >>=
5192
                        (fun arg3  ->
5193
                           arg2 >>=
5194
                             (fun arg2  ->
5195
                                arg1 >>=
5196
                                  (fun arg1  ->
5197
                                     arg0 >>=
5198
                                       (fun arg0  ->
5199
                                          Result.Ok
5200
                                            {
5201
                                              name = arg0;
5202
                                              inst_unit = arg1;
5203
                                              archi_name = arg2;
5204
                                              generic_map = arg3;
5205
                                              port_map = arg4
5206
                                            }))))))
5207
            | _::xs -> loop xs _state  in
5208
          loop xs
5209
            ((Result.Error "Vhdl_ast.vhdl_component_instantiation_t.name"),
5210
              (Result.Error
5211
                 "Vhdl_ast.vhdl_component_instantiation_t.inst_unit"),
5212
              (Result.Ok None), (Result.Ok None), (Result.Ok None))
5213
      | _ -> Result.Error "Vhdl_ast.vhdl_component_instantiation_t")
5214
  [@ocaml.warning "-A"])
5215

    
5216
type vhdl_concurrent_stmt_t =
5217
  | SigAssign of vhdl_conditional_signal_t
5218
  [@name "CONDITIONAL_SIGNAL_ASSIGNMENT"]
5219
  | Process of vhdl_process_t [@name "PROCESS_STATEMENT"]
5220
  | SelectedSig of vhdl_selected_signal_t
5221
  [@name "SELECTED_SIGNAL_ASSIGNMENT"]
5222
  | ComponentInst of vhdl_component_instantiation_t
5223
  [@name "COMPONENT_INSTANTIATION_STATEMENT"]
5224

    
5225
let rec pp_vhdl_concurrent_stmt_t :
5226
  Format.formatter -> vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.unit =
5227
  let __3 () = pp_vhdl_component_instantiation_t
5228
  
5229
  and __2 () = pp_vhdl_selected_signal_t
5230
  
5231
  and __1 () = pp_vhdl_process_t
5232
  
5233
  and __0 () = pp_vhdl_conditional_signal_t
5234
   in
5235
  ((let open! Ppx_deriving_runtime in
5236
      fun fmt  ->
5237
        function
5238
        | SigAssign a0 ->
5239
             ((__0 ()) fmt) a0;
5240
        | Process a0 ->
5241
             ((__1 ()) fmt) a0;
5242
        | SelectedSig a0 ->
5243
             ((__2 ()) fmt) a0;
5244
        | ComponentInst a0 ->
5245
             ((__3 ()) fmt) a0;
5246
    )
5247
    [@ocaml.warning "-A"])
5248

    
5249
and show_vhdl_concurrent_stmt_t :
5250
  vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.string =
5251
  fun x  -> Format.asprintf "%a" pp_vhdl_concurrent_stmt_t x
5252

    
5253
let rec (vhdl_concurrent_stmt_t_to_yojson :
5254
          vhdl_concurrent_stmt_t -> Yojson.Safe.json)
5255
  =
5256
  ((let open! Ppx_deriving_yojson_runtime in
5257
      function
5258
      | SigAssign arg0 ->
5259
          `List
5260
            [`String "CONDITIONAL_SIGNAL_ASSIGNMENT";
5261
            ((fun x  -> vhdl_conditional_signal_t_to_yojson x)) arg0]
5262
      | Process arg0 ->
5263
          `List
5264
            [`String "PROCESS_STATEMENT";
5265
            ((fun x  -> vhdl_process_t_to_yojson x)) arg0]
5266
      | SelectedSig arg0 ->
5267
          `List
5268
            [`String "SELECTED_SIGNAL_ASSIGNMENT";
5269
            ((fun x  -> vhdl_selected_signal_t_to_yojson x)) arg0]
5270
      | ComponentInst arg0 ->
5271
          `List
5272
            [`String "COMPONENT_INSTANTIATION_STATEMENT";
5273
            ((fun x  -> vhdl_component_instantiation_t_to_yojson x)) arg0])
5274
  [@ocaml.warning "-A"])
5275

    
5276
and (vhdl_concurrent_stmt_t_of_yojson :
5277
      Yojson.Safe.json ->
5278
        vhdl_concurrent_stmt_t Ppx_deriving_yojson_runtime.error_or)
5279
  =
5280
  ((let open! Ppx_deriving_yojson_runtime in
5281
      function
5282
      | `List ((`String "CONDITIONAL_SIGNAL_ASSIGNMENT")::arg0::[]) ->
5283
          ((fun x  -> vhdl_conditional_signal_t_of_yojson x) arg0) >>=
5284
            ((fun arg0  -> Result.Ok (SigAssign arg0)))
5285
      | `List ((`String "PROCESS_STATEMENT")::arg0::[]) ->
5286
          ((fun x  -> vhdl_process_t_of_yojson x) arg0) >>=
5287
            ((fun arg0  -> Result.Ok (Process arg0)))
5288
      | `List ((`String "SELECTED_SIGNAL_ASSIGNMENT")::arg0::[]) ->
5289
          ((fun x  -> vhdl_selected_signal_t_of_yojson x) arg0) >>=
5290
            ((fun arg0  -> Result.Ok (SelectedSig arg0)))
5291
      | `List ((`String "COMPONENT_INSTANTIATION_STATEMENT")::arg0::[]) ->
5292
          ((fun x  -> vhdl_component_instantiation_t_of_yojson x) arg0) >>=
5293
            ((fun arg0  -> Result.Ok (ComponentInst arg0)))
5294
      | _ -> Result.Error "Vhdl_ast.vhdl_concurrent_stmt_t")
5295
  [@ocaml.warning "-A"])
5296

    
5297
type vhdl_port_mode_t =
5298
  | InPort [@name "in"]
5299
  | OutPort [@name "out"]
5300
  | InoutPort [@name "inout"]
5301
  | BufferPort [@name "buffer"]
5302

    
5303
let rec (pp_vhdl_port_mode_t :
5304
          Format.formatter -> vhdl_port_mode_t -> Ppx_deriving_runtime.unit)
5305
  =
5306
  ((let open! Ppx_deriving_runtime in
5307
      fun fmt  ->
5308
        function
5309
        | InPort  -> Format.pp_print_string fmt "in"
5310
        | OutPort  -> Format.pp_print_string fmt "out"
5311
        | InoutPort  -> Format.pp_print_string fmt "inout"
5312
        | BufferPort  -> Format.pp_print_string fmt "buffer")
5313
  [@ocaml.warning "-A"])
5314

    
5315
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string =
5316
  fun x  -> Format.asprintf "%a" pp_vhdl_port_mode_t x
5317

    
5318
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) =
5319
  ((let open! Ppx_deriving_yojson_runtime in
5320
      function
5321
      | InPort  -> `List [`String "in"]
5322
      | OutPort  -> `List [`String "out"]
5323
      | InoutPort  -> `List [`String "inout"]
5324
      | BufferPort  -> `List [`String "buffer"])
5325
  [@ocaml.warning "-A"])
5326

    
5327
and (vhdl_port_mode_t_of_yojson :
5328
      Yojson.Safe.json ->
5329
        vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or)
5330
  =
5331
  ((let open! Ppx_deriving_yojson_runtime in
5332
      function
5333
      | `List ((`String "in")::[]) -> Result.Ok InPort
5334
      | `List ((`String "out")::[]) -> Result.Ok OutPort
5335
      | `List ((`String "inout")::[]) -> Result.Ok InoutPort
5336
      | `List ((`String "buffer")::[]) -> Result.Ok BufferPort
5337
      | _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t")
5338
  [@ocaml.warning "-A"])
5339

    
5340
type vhdl_port_t =
5341
  {
5342
  names: vhdl_name_t list [@default []];
5343
  mode: vhdl_port_mode_t [@default InPort];
5344
  typ: vhdl_subtype_indication_t ;
5345
  expr: vhdl_expr_t [@default IsNull]}
5346

    
5347
let rec pp_vhdl_port_t :
5348
  Format.formatter -> vhdl_port_t -> Ppx_deriving_runtime.unit =
5349
  let __3 () = pp_vhdl_expr_t
5350
  
5351
  and __2 () = pp_vhdl_subtype_indication_t
5352
  
5353
  and __1 () = pp_vhdl_port_mode_t
5354
  
5355
  and __0 () = pp_vhdl_name_t
5356
   in
5357
  ((let open! Ppx_deriving_runtime in
5358
      fun fmt  ->
5359
        fun x  ->
5360
          Format.fprintf fmt "@[";
5361
          ((((
5362
              ((fun x  ->
5363
                  Format.fprintf fmt "@[";
5364
                  ignore
5365
                    (List.fold_left
5366
                       (fun sep  ->
5367
                          fun x  ->
5368
                            if sep then Format.fprintf fmt ",@ ";
5369
                            ((__0 ()) fmt) x;
5370
                            true) false x);
5371
                  Format.fprintf fmt "@,@]")) x.names;
5372
              );
5373
             Format.fprintf fmt ": ";
5374
             ((__1 ()) fmt) x.mode;
5375
             );
5376
             Format.fprintf fmt " ";
5377
            ((__2 ()) fmt) x.typ;
5378
            );
5379
          (match x.expr with
5380
           | IsNull -> Format.fprintf fmt "";
5381
           | _ -> (Format.fprintf fmt "@[:= ";
5382
                   ((__3 ()) fmt) x.expr;
5383
                   Format.fprintf fmt "@]"));
5384
          Format.fprintf fmt "@]"))
5385
    [@ocaml.warning "-A"])
5386

    
5387
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string =
5388
  fun x  -> Format.asprintf "%a" pp_vhdl_port_t x
5389

    
5390
let rec (vhdl_port_t_to_yojson : vhdl_port_t -> Yojson.Safe.json) =
5391
  ((let open! Ppx_deriving_yojson_runtime in
5392
      fun x  ->
5393
        let fields = []  in
5394
        let fields =
5395
          if x.expr = IsNull
5396
          then fields
5397
          else ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) x.expr)) ::
5398
            fields
5399
           in
5400
        let fields =
5401
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
5402
          :: fields  in
5403
        let fields =
5404
          if x.mode = InPort
5405
          then fields
5406
          else ("mode", (((fun x  -> vhdl_port_mode_t_to_yojson x)) x.mode))
5407
            :: fields
5408
           in
5409
        let fields =
5410
          if x.names = []
5411
          then fields
5412
          else
5413
            ("names",
5414
              (((fun x  ->
5415
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
5416
                 x.names))
5417
            :: fields
5418
           in
5419
        `Assoc fields)
5420
  [@ocaml.warning "-A"])
5421

    
5422
and (vhdl_port_t_of_yojson :
5423
      Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
5424
  =
5425
  ((let open! Ppx_deriving_yojson_runtime in
5426
      function
5427
      | `Assoc xs ->
5428
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
5429
            match xs with
5430
            | ("names",x)::xs ->
5431
                loop xs
5432
                  (((function
5433
                     | `List xs ->
5434
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5435
                     | _ -> Result.Error "Vhdl_ast.vhdl_port_t.names") x),
5436
                    arg1, arg2, arg3)
5437
            | ("mode",x)::xs ->
5438
                loop xs
5439
                  (arg0, ((fun x  -> vhdl_port_mode_t_of_yojson x) x), arg2,
5440
                    arg3)
5441
            | ("typ",x)::xs ->
5442
                loop xs
5443
                  (arg0, arg1,
5444
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
5445
                    arg3)
5446
            | ("expr",x)::xs ->
5447
                loop xs
5448
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x))
5449
            | [] ->
5450
                arg3 >>=
5451
                  ((fun arg3  ->
5452
                      arg2 >>=
5453
                        (fun arg2  ->
5454
                           arg1 >>=
5455
                             (fun arg1  ->
5456
                                arg0 >>=
5457
                                  (fun arg0  ->
5458
                                     Result.Ok
5459
                                       {
5460
                                         names = arg0;
5461
                                         mode = arg1;
5462
                                         typ = arg2;
5463
                                         expr = arg3
5464
                                       })))))
5465
            | _::xs -> loop xs _state  in
5466
          loop xs
5467
            ((Result.Ok []), (Result.Ok InPort),
5468
              (Result.Error "Vhdl_ast.vhdl_port_t.typ"), (Result.Ok IsNull))
5469
      | _ -> Result.Error "Vhdl_ast.vhdl_port_t")
5470
  [@ocaml.warning "-A"])
5471

    
5472
type vhdl_entity_t =
5473
  {
5474
  name: vhdl_name_t [@default NoName];
5475
  generics: vhdl_port_t list [@default []];
5476
  ports: vhdl_port_t list [@default []];
5477
  declaration: vhdl_declaration_t list
5478
    [@key "ENTITY_DECLARATIVE_PART"][@default []];
5479
  stmts: vhdl_concurrent_stmt_t list
5480
    [@key "ENTITY_STATEMENT_PART"][@default []]}
5481