Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / backends / VHDL / vhdl_ast_deriving.ml @ 40364f53

History | View | Annotate | Download (224 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 "(@[<2>CstInt@ ";
25
             (Format.fprintf fmt "%d") a0;
26
             Format.fprintf fmt "@])")
27
        | CstStdLogic a0 ->
28
            (Format.fprintf fmt "(@[<2>CstStdLogic@ ";
29
             (Format.fprintf fmt "%S") a0;
30
             Format.fprintf fmt "@])")
31
        | CstLiteral a0 ->
32
            (Format.fprintf fmt "(@[<2>CstLiteral@ ";
33
             (Format.fprintf fmt "%S") a0;
34
             Format.fprintf fmt "@])"))
35
  [@ocaml.warning "-A"])
36

    
37
and show_vhdl_cst_val_t : vhdl_cst_val_t -> Ppx_deriving_runtime.string =
38
  fun x  -> Format.asprintf "%a" pp_vhdl_cst_val_t x
39

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

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

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

    
182
let rec pp_vhdl_type_t :
183
  Format.formatter -> vhdl_type_t -> Ppx_deriving_runtime.unit =
184
  let __0 () = pp_vhdl_type_t  in
185
  ((let open! Ppx_deriving_runtime in
186
      fun fmt  ->
187
        function
188
        | Base a0 ->
189
            (Format.fprintf fmt "(@[<2>Base@ ";
190
             (Format.fprintf fmt "%S") a0;
191
             Format.fprintf fmt "@])")
192
        | Range (a0,a1,a2) ->
193
            (Format.fprintf fmt "(@[<2>Range (@,";
194
             ((((function
195
                 | None  -> Format.pp_print_string fmt "None"
196
                 | Some x ->
197
                     (Format.pp_print_string fmt "(Some ";
198
                      (Format.fprintf fmt "%S") x;
199
                      Format.pp_print_string fmt ")"))) a0;
200
               Format.fprintf fmt ",@ ";
201
               (Format.fprintf fmt "%d") a1);
202
              Format.fprintf fmt ",@ ";
203
              (Format.fprintf fmt "%d") a2);
204
             Format.fprintf fmt "@,))@]")
205
        | Bit_vector (a0,a1) ->
206
            (Format.fprintf fmt "(@[<2>Bit_vector (@,";
207
             ((Format.fprintf fmt "%d") a0;
208
              Format.fprintf fmt ",@ ";
209
              (Format.fprintf fmt "%d") a1);
210
             Format.fprintf fmt "@,))@]")
211
        | Array (a0,a1,a2) ->
212
            (Format.fprintf fmt "(@[<2>Array (@,";
213
             (((Format.fprintf fmt "%d") a0;
214
               Format.fprintf fmt ",@ ";
215
               (Format.fprintf fmt "%d") a1);
216
              Format.fprintf fmt ",@ ";
217
              ((__0 ()) fmt) a2);
218
             Format.fprintf fmt "@,))@]")
219
        | Enumerated a0 ->
220
            (Format.fprintf fmt "(@[<2>Enumerated@ ";
221
             ((fun x  ->
222
                 Format.fprintf fmt "@[<2>[";
223
                 ignore
224
                   (List.fold_left
225
                      (fun sep  ->
226
                         fun x  ->
227
                           if sep then Format.fprintf fmt ";@ ";
228
                           (Format.fprintf fmt "%S") x;
229
                           true) false x);
230
                 Format.fprintf fmt "@,]@]")) a0;
231
             Format.fprintf fmt "@])")
232
        | Void  -> Format.pp_print_string fmt "Void")
233
    [@ocaml.warning "-A"])
234

    
235
and show_vhdl_type_t : vhdl_type_t -> Ppx_deriving_runtime.string =
236
  fun x  -> Format.asprintf "%a" pp_vhdl_type_t x
237

    
238
and pp_vhdl_subtype_indication_t :
239
  Format.formatter -> vhdl_subtype_indication_t -> Ppx_deriving_runtime.unit
240
  =
241
  let __2 () = pp_vhdl_constraint_t
242
  
243
  and __1 () = pp_vhdl_name_t
244
  
245
  and __0 () = pp_vhdl_name_t
246
   in
247
  ((let open! Ppx_deriving_runtime in
248
      fun fmt  ->
249
        fun x  ->
250
          Format.fprintf fmt "@[<2>{ ";
251
          (((Format.fprintf fmt "@[%s =@ " "name";
252
             ((__0 ()) fmt) x.name;
253
             Format.fprintf fmt "@]");
254
            Format.fprintf fmt ";@ ";
255
            Format.fprintf fmt "@[%s =@ " "functionName";
256
            ((__1 ()) fmt) x.functionName;
257
            Format.fprintf fmt "@]");
258
           Format.fprintf fmt ";@ ";
259
           Format.fprintf fmt "@[%s =@ " "const";
260
           ((__2 ()) fmt) x.const;
261
           Format.fprintf fmt "@]");
262
          Format.fprintf fmt "@ }@]")
263
    [@ocaml.warning "-A"])
264

    
265
and show_vhdl_subtype_indication_t :
266
  vhdl_subtype_indication_t -> Ppx_deriving_runtime.string =
267
  fun x  -> Format.asprintf "%a" pp_vhdl_subtype_indication_t x
268

    
269
and pp_vhdl_discrete_range_t :
270
  Format.formatter -> vhdl_discrete_range_t -> Ppx_deriving_runtime.unit =
271
  let __3 () = pp_vhdl_expr_t
272
  
273
  and __2 () = pp_vhdl_expr_t
274
  
275
  and __1 () = pp_vhdl_name_t
276
  
277
  and __0 () = pp_vhdl_subtype_indication_t
278
   in
279
  ((let open! Ppx_deriving_runtime in
280
      fun fmt  ->
281
        function
282
        | SubDiscreteRange a0 ->
283
            (Format.fprintf fmt "(@[<2>SubDiscreteRange@ ";
284
             ((__0 ()) fmt) a0;
285
             Format.fprintf fmt "@])")
286
        | NamedRange a0 ->
287
            (Format.fprintf fmt "(@[<2>NamedRange@ ";
288
             ((__1 ()) fmt) a0;
289
             Format.fprintf fmt "@])")
290
        | DirectedRange { direction = adirection; from = afrom; _to = a_to }
291
            ->
292
            (Format.fprintf fmt "@[<2>DirectedRange {@,";
293
             (((Format.fprintf fmt "@[%s =@ " "direction";
294
                (Format.fprintf fmt "%S") adirection;
295
                Format.fprintf fmt "@]");
296
               Format.fprintf fmt ";@ ";
297
               Format.fprintf fmt "@[%s =@ " "from";
298
               ((__2 ()) fmt) afrom;
299
               Format.fprintf fmt "@]");
300
              Format.fprintf fmt ";@ ";
301
              Format.fprintf fmt "@[%s =@ " "_to";
302
              ((__3 ()) fmt) a_to;
303
              Format.fprintf fmt "@]");
304
             Format.fprintf fmt "@]}"))
305
    [@ocaml.warning "-A"])
306

    
307
and show_vhdl_discrete_range_t :
308
  vhdl_discrete_range_t -> Ppx_deriving_runtime.string =
309
  fun x  -> Format.asprintf "%a" pp_vhdl_discrete_range_t x
310

    
311
and pp_vhdl_constraint_t :
312
  Format.formatter -> vhdl_constraint_t -> Ppx_deriving_runtime.unit =
313
  let __4 () = pp_vhdl_constraint_t
314
  
315
  and __3 () = pp_vhdl_discrete_range_t
316
  
317
  and __2 () = pp_vhdl_discrete_range_t
318
  
319
  and __1 () = pp_vhdl_discrete_range_t
320
  
321
  and __0 () = pp_vhdl_name_t
322
   in
323
  ((let open! Ppx_deriving_runtime in
324
      fun fmt  ->
325
        function
326
        | RefConstraint { ref_name = aref_name } ->
327
            (Format.fprintf fmt "@[<2>RefConstraint {@,";
328
             (Format.fprintf fmt "@[%s =@ " "ref_name";
329
              ((__0 ()) fmt) aref_name;
330
              Format.fprintf fmt "@]");
331
             Format.fprintf fmt "@]}")
332
        | RangeConstraint { range = arange } ->
333
            (Format.fprintf fmt "@[<2>RangeConstraint {@,";
334
             (Format.fprintf fmt "@[%s =@ " "range";
335
              ((__1 ()) fmt) arange;
336
              Format.fprintf fmt "@]");
337
             Format.fprintf fmt "@]}")
338
        | IndexConstraint { ranges = aranges } ->
339
            (Format.fprintf fmt "@[<2>IndexConstraint {@,";
340
             (Format.fprintf fmt "@[%s =@ " "ranges";
341
              ((fun x  ->
342
                  Format.fprintf fmt "@[<2>[";
343
                  ignore
344
                    (List.fold_left
345
                       (fun sep  ->
346
                          fun x  ->
347
                            if sep then Format.fprintf fmt ";@ ";
348
                            ((__2 ()) fmt) x;
349
                            true) false x);
350
                  Format.fprintf fmt "@,]@]")) aranges;
351
              Format.fprintf fmt "@]");
352
             Format.fprintf fmt "@]}")
353
        | ArrayConstraint { ranges = aranges; sub = asub } ->
354
            (Format.fprintf fmt "@[<2>ArrayConstraint {@,";
355
             ((Format.fprintf fmt "@[%s =@ " "ranges";
356
               ((fun x  ->
357
                   Format.fprintf fmt "@[<2>[";
358
                   ignore
359
                     (List.fold_left
360
                        (fun sep  ->
361
                           fun x  ->
362
                             if sep then Format.fprintf fmt ";@ ";
363
                             ((__3 ()) fmt) x;
364
                             true) false x);
365
                   Format.fprintf fmt "@,]@]")) aranges;
366
               Format.fprintf fmt "@]");
367
              Format.fprintf fmt ";@ ";
368
              Format.fprintf fmt "@[%s =@ " "sub";
369
              ((__4 ()) fmt) asub;
370
              Format.fprintf fmt "@]");
371
             Format.fprintf fmt "@]}")
372
        | RecordConstraint  -> Format.pp_print_string fmt "RecordConstraint"
373
        | NoConstraint  -> Format.pp_print_string fmt "NoConstraint")
374
    [@ocaml.warning "-A"])
375

    
376
and show_vhdl_constraint_t : vhdl_constraint_t -> Ppx_deriving_runtime.string
377
  = fun x  -> Format.asprintf "%a" pp_vhdl_constraint_t x
378

    
379
and pp_vhdl_definition_t :
380
  Format.formatter -> vhdl_definition_t -> Ppx_deriving_runtime.unit =
381
  let __3 () = pp_vhdl_subtype_indication_t
382
  
383
  and __2 () = pp_vhdl_name_t
384
  
385
  and __1 () = pp_vhdl_type_t
386
  
387
  and __0 () = pp_vhdl_name_t
388
   in
389
  ((let open! Ppx_deriving_runtime in
390
      fun fmt  ->
391
        function
392
        | Type { name = aname; definition = adefinition } ->
393
            (Format.fprintf fmt "@[<2>Type {@,";
394
             ((Format.fprintf fmt "@[%s =@ " "name";
395
               ((__0 ()) fmt) aname;
396
               Format.fprintf fmt "@]");
397
              Format.fprintf fmt ";@ ";
398
              Format.fprintf fmt "@[%s =@ " "definition";
399
              ((__1 ()) fmt) adefinition;
400
              Format.fprintf fmt "@]");
401
             Format.fprintf fmt "@]}")
402
        | Subtype { name = aname; typ = atyp } ->
403
            (Format.fprintf fmt "@[<2>Subtype {@,";
404
             ((Format.fprintf fmt "@[%s =@ " "name";
405
               ((__2 ()) fmt) aname;
406
               Format.fprintf fmt "@]");
407
              Format.fprintf fmt ";@ ";
408
              Format.fprintf fmt "@[%s =@ " "typ";
409
              ((__3 ()) fmt) atyp;
410
              Format.fprintf fmt "@]");
411
             Format.fprintf fmt "@]}"))
412
    [@ocaml.warning "-A"])
413

    
414
and show_vhdl_definition_t : vhdl_definition_t -> Ppx_deriving_runtime.string
415
  = fun x  -> Format.asprintf "%a" pp_vhdl_definition_t x
416

    
417
and pp_vhdl_expr_t :
418
  Format.formatter -> vhdl_expr_t -> Ppx_deriving_runtime.unit =
419
  let __7 () = pp_vhdl_element_assoc_t
420
  
421
  and __6 () = pp_vhdl_suffix_selection_t
422
  
423
  and __5 () = pp_vhdl_expr_t
424
  
425
  and __4 () = pp_vhdl_signal_attributes_t
426
  
427
  and __3 () = pp_vhdl_name_t
428
  
429
  and __2 () = pp_vhdl_expr_t
430
  
431
  and __1 () = pp_vhdl_cst_val_t
432
  
433
  and __0 () = pp_vhdl_name_t
434
   in
435
  ((let open! Ppx_deriving_runtime in
436
      fun fmt  ->
437
        function
438
        | Call a0 ->
439
            (Format.fprintf fmt "(@[<2>Call@ ";
440
             ((__0 ()) fmt) a0;
441
             Format.fprintf fmt "@])")
442
        | Cst a0 ->
443
            (Format.fprintf fmt "(@[<2>Cst@ ";
444
             ((__1 ()) fmt) a0;
445
             Format.fprintf fmt "@])")
446
        | Op { id = aid; args = aargs } ->
447
            (Format.fprintf fmt "@[<2>Op {@,";
448
             ((Format.fprintf fmt "@[%s =@ " "id";
449
               (Format.fprintf fmt "%S") aid;
450
               Format.fprintf fmt "@]");
451
              Format.fprintf fmt ";@ ";
452
              Format.fprintf fmt "@[%s =@ " "args";
453
              ((fun x  ->
454
                  Format.fprintf fmt "@[<2>[";
455
                  ignore
456
                    (List.fold_left
457
                       (fun sep  ->
458
                          fun x  ->
459
                            if sep then Format.fprintf fmt ";@ ";
460
                            ((__2 ()) fmt) x;
461
                            true) false x);
462
                  Format.fprintf fmt "@,]@]")) aargs;
463
              Format.fprintf fmt "@]");
464
             Format.fprintf fmt "@]}")
465
        | IsNull  -> Format.pp_print_string fmt "IsNull"
466
        | Time { value = avalue; phy_unit = aphy_unit } ->
467
            (Format.fprintf fmt "@[<2>Time {@,";
468
             ((Format.fprintf fmt "@[%s =@ " "value";
469
               (Format.fprintf fmt "%d") avalue;
470
               Format.fprintf fmt "@]");
471
              Format.fprintf fmt ";@ ";
472
              Format.fprintf fmt "@[%s =@ " "phy_unit";
473
              (Format.fprintf fmt "%S") aphy_unit;
474
              Format.fprintf fmt "@]");
475
             Format.fprintf fmt "@]}")
476
        | Sig { name = aname; att = aatt } ->
477
            (Format.fprintf fmt "@[<2>Sig {@,";
478
             ((Format.fprintf fmt "@[%s =@ " "name";
479
               ((__3 ()) fmt) aname;
480
               Format.fprintf fmt "@]");
481
              Format.fprintf fmt ";@ ";
482
              Format.fprintf fmt "@[%s =@ " "att";
483
              ((function
484
                | None  -> Format.pp_print_string fmt "None"
485
                | Some x ->
486
                    (Format.pp_print_string fmt "(Some ";
487
                     ((__4 ()) fmt) x;
488
                     Format.pp_print_string fmt ")"))) aatt;
489
              Format.fprintf fmt "@]");
490
             Format.fprintf fmt "@]}")
491
        | SuffixMod { expr = aexpr; selection = aselection } ->
492
            (Format.fprintf fmt "@[<2>SuffixMod {@,";
493
             ((Format.fprintf fmt "@[%s =@ " "expr";
494
               ((__5 ()) fmt) aexpr;
495
               Format.fprintf fmt "@]");
496
              Format.fprintf fmt ";@ ";
497
              Format.fprintf fmt "@[%s =@ " "selection";
498
              ((__6 ()) fmt) aselection;
499
              Format.fprintf fmt "@]");
500
             Format.fprintf fmt "@]}")
501
        | Aggregate { elems = aelems } ->
502
            (Format.fprintf fmt "@[<2>Aggregate {@,";
503
             (Format.fprintf fmt "@[%s =@ " "elems";
504
              ((fun x  ->
505
                  Format.fprintf fmt "@[<2>[";
506
                  ignore
507
                    (List.fold_left
508
                       (fun sep  ->
509
                          fun x  ->
510
                            if sep then Format.fprintf fmt ";@ ";
511
                            ((__7 ()) fmt) x;
512
                            true) false x);
513
                  Format.fprintf fmt "@,]@]")) aelems;
514
              Format.fprintf fmt "@]");
515
             Format.fprintf fmt "@]}")
516
        | Others  -> Format.pp_print_string fmt "Others")
517
    [@ocaml.warning "-A"])
518

    
519
and show_vhdl_expr_t : vhdl_expr_t -> Ppx_deriving_runtime.string =
520
  fun x  -> Format.asprintf "%a" pp_vhdl_expr_t x
521

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

    
633
and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string =
634
  fun x  -> Format.asprintf "%a" pp_vhdl_name_t x
635

    
636
and pp_vhdl_assoc_element_t :
637
  Format.formatter -> vhdl_assoc_element_t -> Ppx_deriving_runtime.unit =
638
  let __4 () = pp_vhdl_expr_t
639
  
640
  and __3 () = pp_vhdl_name_t
641
  
642
  and __2 () = pp_vhdl_name_t
643
  
644
  and __1 () = pp_vhdl_name_t
645
  
646
  and __0 () = pp_vhdl_name_t
647
   in
648
  ((let open! Ppx_deriving_runtime in
649
      fun fmt  ->
650
        fun x  ->
651
          Format.fprintf fmt "@[<2>{ ";
652
          (((((Format.fprintf fmt "@[%s =@ " "formal_name";
653
               ((function
654
                 | None  -> Format.pp_print_string fmt "None"
655
                 | Some x ->
656
                     (Format.pp_print_string fmt "(Some ";
657
                      ((__0 ()) fmt) x;
658
                      Format.pp_print_string fmt ")"))) x.formal_name;
659
               Format.fprintf fmt "@]");
660
              Format.fprintf fmt ";@ ";
661
              Format.fprintf fmt "@[%s =@ " "formal_arg";
662
              ((function
663
                | None  -> Format.pp_print_string fmt "None"
664
                | Some x ->
665
                    (Format.pp_print_string fmt "(Some ";
666
                     ((__1 ()) fmt) x;
667
                     Format.pp_print_string fmt ")"))) x.formal_arg;
668
              Format.fprintf fmt "@]");
669
             Format.fprintf fmt ";@ ";
670
             Format.fprintf fmt "@[%s =@ " "actual_name";
671
             ((function
672
               | None  -> Format.pp_print_string fmt "None"
673
               | Some x ->
674
                   (Format.pp_print_string fmt "(Some ";
675
                    ((__2 ()) fmt) x;
676
                    Format.pp_print_string fmt ")"))) x.actual_name;
677
             Format.fprintf fmt "@]");
678
            Format.fprintf fmt ";@ ";
679
            Format.fprintf fmt "@[%s =@ " "actual_designator";
680
            ((function
681
              | None  -> Format.pp_print_string fmt "None"
682
              | Some x ->
683
                  (Format.pp_print_string fmt "(Some ";
684
                   ((__3 ()) fmt) x;
685
                   Format.pp_print_string fmt ")"))) x.actual_designator;
686
            Format.fprintf fmt "@]");
687
           Format.fprintf fmt ";@ ";
688
           Format.fprintf fmt "@[%s =@ " "actual_expr";
689
           ((function
690
             | None  -> Format.pp_print_string fmt "None"
691
             | Some x ->
692
                 (Format.pp_print_string fmt "(Some ";
693
                  ((__4 ()) fmt) x;
694
                  Format.pp_print_string fmt ")"))) x.actual_expr;
695
           Format.fprintf fmt "@]");
696
          Format.fprintf fmt "@ }@]")
697
    [@ocaml.warning "-A"])
698

    
699
and show_vhdl_assoc_element_t :
700
  vhdl_assoc_element_t -> Ppx_deriving_runtime.string =
701
  fun x  -> Format.asprintf "%a" pp_vhdl_assoc_element_t x
702

    
703
and pp_vhdl_element_assoc_t :
704
  Format.formatter -> vhdl_element_assoc_t -> Ppx_deriving_runtime.unit =
705
  let __1 () = pp_vhdl_expr_t
706
  
707
  and __0 () = pp_vhdl_expr_t
708
   in
709
  ((let open! Ppx_deriving_runtime in
710
      fun fmt  ->
711
        fun x  ->
712
          Format.fprintf fmt "@[<2>{ ";
713
          ((Format.fprintf fmt "@[%s =@ " "choices";
714
            ((fun x  ->
715
                Format.fprintf fmt "@[<2>[";
716
                ignore
717
                  (List.fold_left
718
                     (fun sep  ->
719
                        fun x  ->
720
                          if sep then Format.fprintf fmt ";@ ";
721
                          ((__0 ()) fmt) x;
722
                          true) false x);
723
                Format.fprintf fmt "@,]@]")) x.choices;
724
            Format.fprintf fmt "@]");
725
           Format.fprintf fmt ";@ ";
726
           Format.fprintf fmt "@[%s =@ " "expr";
727
           ((__1 ()) fmt) x.expr;
728
           Format.fprintf fmt "@]");
729
          Format.fprintf fmt "@ }@]")
730
    [@ocaml.warning "-A"])
731

    
732
and show_vhdl_element_assoc_t :
733
  vhdl_element_assoc_t -> Ppx_deriving_runtime.string =
734
  fun x  -> Format.asprintf "%a" pp_vhdl_element_assoc_t x
735

    
736
and (pp_vhdl_array_attributes_t :
737
      Format.formatter ->
738
        vhdl_array_attributes_t -> Ppx_deriving_runtime.unit)
739
  =
740
  ((let open! Ppx_deriving_runtime in
741
      fun fmt  ->
742
        function
743
        | AAttInt { id = aid; arg = aarg } ->
744
            (Format.fprintf fmt "@[<2>AAttInt {@,";
745
             ((Format.fprintf fmt "@[%s =@ " "id";
746
               (Format.fprintf fmt "%S") aid;
747
               Format.fprintf fmt "@]");
748
              Format.fprintf fmt ";@ ";
749
              Format.fprintf fmt "@[%s =@ " "arg";
750
              (Format.fprintf fmt "%d") aarg;
751
              Format.fprintf fmt "@]");
752
             Format.fprintf fmt "@]}")
753
        | AAttAscending  -> Format.pp_print_string fmt "AAttAscending")
754
  [@ocaml.warning "-A"])
755

    
756
and show_vhdl_array_attributes_t :
757
  vhdl_array_attributes_t -> Ppx_deriving_runtime.string =
758
  fun x  -> Format.asprintf "%a" pp_vhdl_array_attributes_t x
759

    
760
and (pp_vhdl_signal_attributes_t :
761
      Format.formatter ->
762
        vhdl_signal_attributes_t -> Ppx_deriving_runtime.unit)
763
  =
764
  ((let open! Ppx_deriving_runtime in
765
      fun fmt  ->
766
        function
767
        | SigAtt a0 ->
768
            (Format.fprintf fmt "(@[<2>SigAtt@ ";
769
             (Format.fprintf fmt "%S") a0;
770
             Format.fprintf fmt "@])"))
771
  [@ocaml.warning "-A"])
772

    
773
and show_vhdl_signal_attributes_t :
774
  vhdl_signal_attributes_t -> Ppx_deriving_runtime.string =
775
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_attributes_t x
776

    
777
and (pp_vhdl_string_attributes_t :
778
      Format.formatter ->
779
        vhdl_string_attributes_t -> Ppx_deriving_runtime.unit)
780
  =
781
  ((let open! Ppx_deriving_runtime in
782
      fun fmt  ->
783
        function
784
        | StringAtt a0 ->
785
            (Format.fprintf fmt "(@[<2>StringAtt@ ";
786
             (Format.fprintf fmt "%S") a0;
787
             Format.fprintf fmt "@])"))
788
  [@ocaml.warning "-A"])
789

    
790
and show_vhdl_string_attributes_t :
791
  vhdl_string_attributes_t -> Ppx_deriving_runtime.string =
792
  fun x  -> Format.asprintf "%a" pp_vhdl_string_attributes_t x
793

    
794
and (pp_vhdl_suffix_selection_t :
795
      Format.formatter ->
796
        vhdl_suffix_selection_t -> Ppx_deriving_runtime.unit)
797
  =
798
  ((let open! Ppx_deriving_runtime in
799
      fun fmt  ->
800
        function
801
        | Idx a0 ->
802
            (Format.fprintf fmt "(@[<2>Idx@ ";
803
             (Format.fprintf fmt "%d") a0;
804
             Format.fprintf fmt "@])")
805
        | SuffixRange (a0,a1) ->
806
            (Format.fprintf fmt "(@[<2>SuffixRange (@,";
807
             ((Format.fprintf fmt "%d") a0;
808
              Format.fprintf fmt ",@ ";
809
              (Format.fprintf fmt "%d") a1);
810
             Format.fprintf fmt "@,))@]"))
811
  [@ocaml.warning "-A"])
812

    
813
and show_vhdl_suffix_selection_t :
814
  vhdl_suffix_selection_t -> Ppx_deriving_runtime.string =
815
  fun x  -> Format.asprintf "%a" pp_vhdl_suffix_selection_t x
816

    
817
let rec (vhdl_type_t_to_yojson : vhdl_type_t -> Yojson.Safe.json) =
818
  ((let open! Ppx_deriving_yojson_runtime in
819
      function
820
      | Base arg0 ->
821
          `List
822
            [`String "Base";
823
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
824
      | Range (arg0,arg1,arg2) ->
825
          `List
826
            [`String "Range";
827
            ((function
828
              | None  -> `Null
829
              | Some x ->
830
                  ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x))
831
              arg0;
832
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1;
833
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg2]
834
      | Bit_vector (arg0,arg1) ->
835
          `List
836
            [`String "Bit_vector";
837
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
838
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1]
839
      | Array (arg0,arg1,arg2) ->
840
          `List
841
            [`String "Array";
842
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
843
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1;
844
            ((fun x  -> vhdl_type_t_to_yojson x)) arg2]
845
      | Enumerated arg0 ->
846
          `List
847
            [`String "Enumerated";
848
            ((fun x  ->
849
                `List
850
                  (List.map
851
                     (fun (x : Ppx_deriving_runtime.string)  -> `String x) x)))
852
              arg0]
853
      | Void  -> `List [`String "Void"])
854
  [@ocaml.warning "-A"])
855

    
856
and (vhdl_type_t_of_yojson :
857
      Yojson.Safe.json -> vhdl_type_t Ppx_deriving_yojson_runtime.error_or)
858
  =
859
  ((let open! Ppx_deriving_yojson_runtime in
860
      function
861
      | `List ((`String "Base")::arg0::[]) ->
862
          ((function
863
            | `String x -> Result.Ok x
864
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
865
            ((fun arg0  -> Result.Ok (Base arg0)))
866
      | `List ((`String "Range")::arg0::arg1::arg2::[]) ->
867
          ((function
868
            | `Int x -> Result.Ok x
869
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg2) >>=
870
            ((fun arg2  ->
871
                ((function
872
                  | `Int x -> Result.Ok x
873
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
874
                  (fun arg1  ->
875
                     ((function
876
                       | `Null -> Result.Ok None
877
                       | x ->
878
                           ((function
879
                             | `String x -> Result.Ok x
880
                             | _ -> Result.Error "Vhdl_ast.vhdl_type_t") x)
881
                             >>= ((fun x  -> Result.Ok (Some x)))) arg0)
882
                       >>=
883
                       (fun arg0  -> Result.Ok (Range (arg0, arg1, arg2))))))
884
      | `List ((`String "Bit_vector")::arg0::arg1::[]) ->
885
          ((function
886
            | `Int x -> Result.Ok x
887
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
888
            ((fun arg1  ->
889
                ((function
890
                  | `Int x -> Result.Ok x
891
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
892
                  (fun arg0  -> Result.Ok (Bit_vector (arg0, arg1)))))
893
      | `List ((`String "Array")::arg0::arg1::arg2::[]) ->
894
          ((fun x  -> vhdl_type_t_of_yojson x) arg2) >>=
895
            ((fun arg2  ->
896
                ((function
897
                  | `Int x -> Result.Ok x
898
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
899
                  (fun arg1  ->
900
                     ((function
901
                       | `Int x -> Result.Ok x
902
                       | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
903
                       (fun arg0  -> Result.Ok (Array (arg0, arg1, arg2))))))
904
      | `List ((`String "Enumerated")::arg0::[]) ->
905
          ((function
906
            | `List xs ->
907
                map_bind
908
                  (function
909
                   | `String x -> Result.Ok x
910
                   | _ -> Result.Error "Vhdl_ast.vhdl_type_t") [] xs
911
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
912
            ((fun arg0  -> Result.Ok (Enumerated arg0)))
913
      | `List ((`String "Void")::[]) -> Result.Ok Void
914
      | _ -> Result.Error "Vhdl_ast.vhdl_type_t")
915
  [@ocaml.warning "-A"])
916

    
917
and (vhdl_subtype_indication_t_to_yojson :
918
      vhdl_subtype_indication_t -> Yojson.Safe.json)
919
  =
920
  ((let open! Ppx_deriving_yojson_runtime in
921
      fun x  ->
922
        let fields = []  in
923
        let fields =
924
          if x.const = NoConstraint
925
          then fields
926
          else
927
            ("const", (((fun x  -> vhdl_constraint_t_to_yojson x)) x.const))
928
            :: fields
929
           in
930
        let fields =
931
          if x.functionName = NoName
932
          then fields
933
          else
934
            ("functionName",
935
              (((fun x  -> vhdl_name_t_to_yojson x)) x.functionName))
936
            :: fields
937
           in
938
        let fields =
939
          if x.name = NoName
940
          then fields
941
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
942
            fields
943
           in
944
        `Assoc fields)
945
  [@ocaml.warning "-A"])
946

    
947
and (vhdl_subtype_indication_t_of_yojson :
948
      Yojson.Safe.json ->
949
        vhdl_subtype_indication_t Ppx_deriving_yojson_runtime.error_or)
950
  =
951
  ((let open! Ppx_deriving_yojson_runtime in
952
      function
953
      | `Assoc xs ->
954
          let rec loop xs ((arg0,arg1,arg2) as _state) =
955
            match xs with
956
            | ("name",x)::xs ->
957
                loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
958
            | ("functionName",x)::xs ->
959
                loop xs (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
960
            | ("const",x)::xs ->
961
                loop xs
962
                  (arg0, arg1, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
963
            | [] ->
964
                arg2 >>=
965
                  ((fun arg2  ->
966
                      arg1 >>=
967
                        (fun arg1  ->
968
                           arg0 >>=
969
                             (fun arg0  ->
970
                                Result.Ok
971
                                  {
972
                                    name = arg0;
973
                                    functionName = arg1;
974
                                    const = arg2
975
                                  }))))
976
            | _::xs -> loop xs _state  in
977
          loop xs
978
            ((Result.Ok NoName), (Result.Ok NoName),
979
              (Result.Ok NoConstraint))
980
      | _ -> Result.Error "Vhdl_ast.vhdl_subtype_indication_t")
981
  [@ocaml.warning "-A"])
982

    
983
and (vhdl_discrete_range_t_to_yojson :
984
      vhdl_discrete_range_t -> Yojson.Safe.json)
985
  =
986
  ((let open! Ppx_deriving_yojson_runtime in
987
      function
988
      | SubDiscreteRange arg0 ->
989
          `List
990
            [`String "SUB_DISCRETE_RANGE";
991
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x)) arg0]
992
      | NamedRange arg0 ->
993
          `List
994
            [`String "NAMED_RANGE";
995
            ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
996
      | DirectedRange arg0 ->
997
          `List
998
            [`String "RANGE_WITH_DIRECTION";
999
            (let fields = []  in
1000
             let fields =
1001
               ("_to", ((fun x  -> vhdl_expr_t_to_yojson x) arg0._to)) ::
1002
               fields  in
1003
             let fields =
1004
               ("from", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.from)) ::
1005
               fields  in
1006
             let fields =
1007
               ("direction",
1008
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
1009
                    arg0.direction))
1010
               :: fields  in
1011
             `Assoc fields)])
1012
  [@ocaml.warning "-A"])
1013

    
1014
and (vhdl_discrete_range_t_of_yojson :
1015
      Yojson.Safe.json ->
1016
        vhdl_discrete_range_t Ppx_deriving_yojson_runtime.error_or)
1017
  =
1018
  ((let open! Ppx_deriving_yojson_runtime in
1019
      function
1020
      | `List ((`String "SUB_DISCRETE_RANGE")::arg0::[]) ->
1021
          ((fun x  -> vhdl_subtype_indication_t_of_yojson x) arg0) >>=
1022
            ((fun arg0  -> Result.Ok (SubDiscreteRange arg0)))
1023
      | `List ((`String "NAMED_RANGE")::arg0::[]) ->
1024
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
1025
            ((fun arg0  -> Result.Ok (NamedRange arg0)))
1026
      | `List ((`String "RANGE_WITH_DIRECTION")::arg0::[]) ->
1027
          ((function
1028
            | `Assoc xs ->
1029
                let rec loop xs ((arg0,arg1,arg2) as _state) =
1030
                  match xs with
1031
                  | ("direction",x)::xs ->
1032
                      loop xs
1033
                        (((function
1034
                           | `String x -> Result.Ok x
1035
                           | _ ->
1036
                               Result.Error
1037
                                 "Vhdl_ast.vhdl_discrete_range_t.direction")
1038
                            x), arg1, arg2)
1039
                  | ("from",x)::xs ->
1040
                      loop xs
1041
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
1042
                  | ("_to",x)::xs ->
1043
                      loop xs
1044
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1045
                  | [] ->
1046
                      arg2 >>=
1047
                        ((fun arg2  ->
1048
                            arg1 >>=
1049
                              (fun arg1  ->
1050
                                 arg0 >>=
1051
                                   (fun arg0  ->
1052
                                      Result.Ok
1053
                                        (DirectedRange
1054
                                           {
1055
                                             direction = arg0;
1056
                                             from = arg1;
1057
                                             _to = arg2
1058
                                           })))))
1059
                  | _::xs -> loop xs _state  in
1060
                loop xs
1061
                  ((Result.Error "Vhdl_ast.vhdl_discrete_range_t.direction"),
1062
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t.from"),
1063
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t._to"))
1064
            | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")) arg0
1065
      | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")
1066
  [@ocaml.warning "-A"])
1067

    
1068
and (vhdl_constraint_t_to_yojson : vhdl_constraint_t -> Yojson.Safe.json) =
1069
  ((let open! Ppx_deriving_yojson_runtime in
1070
      function
1071
      | RefConstraint arg0 ->
1072
          `List
1073
            [`String "RefConstraint";
1074
            (let fields = []  in
1075
             let fields =
1076
               ("ref_name",
1077
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.ref_name))
1078
               :: fields  in
1079
             `Assoc fields)]
1080
      | RangeConstraint arg0 ->
1081
          `List
1082
            [`String "RANGE_CONSTRAINT";
1083
            (let fields = []  in
1084
             let fields =
1085
               ("range",
1086
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
1087
               :: fields  in
1088
             `Assoc fields)]
1089
      | IndexConstraint arg0 ->
1090
          `List
1091
            [`String "INDEX_CONSTRAINT";
1092
            (let fields = []  in
1093
             let fields =
1094
               ("ranges",
1095
                 ((fun x  ->
1096
                     `List
1097
                       (List.map
1098
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1099
                    arg0.ranges))
1100
               :: fields  in
1101
             `Assoc fields)]
1102
      | ArrayConstraint arg0 ->
1103
          `List
1104
            [`String "ARRAY_CONSTRAINT";
1105
            (let fields = []  in
1106
             let fields =
1107
               ("sub", ((fun x  -> vhdl_constraint_t_to_yojson x) arg0.sub))
1108
               :: fields  in
1109
             let fields =
1110
               ("ranges",
1111
                 ((fun x  ->
1112
                     `List
1113
                       (List.map
1114
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1115
                    arg0.ranges))
1116
               :: fields  in
1117
             `Assoc fields)]
1118
      | RecordConstraint  -> `List [`String "RecordConstraint"]
1119
      | NoConstraint  -> `List [`String "NoConstraint"])
1120
  [@ocaml.warning "-A"])
1121

    
1122
and (vhdl_constraint_t_of_yojson :
1123
      Yojson.Safe.json ->
1124
        vhdl_constraint_t Ppx_deriving_yojson_runtime.error_or)
1125
  =
1126
  ((let open! Ppx_deriving_yojson_runtime in
1127
      function
1128
      | `List ((`String "RefConstraint")::arg0::[]) ->
1129
          ((function
1130
            | `Assoc xs ->
1131
                let rec loop xs (arg0 as _state) =
1132
                  match xs with
1133
                  | ("ref_name",x)::xs ->
1134
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
1135
                  | [] ->
1136
                      arg0 >>=
1137
                        ((fun arg0  ->
1138
                            Result.Ok (RefConstraint { ref_name = arg0 })))
1139
                  | _::xs -> loop xs _state  in
1140
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ref_name")
1141
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1142
      | `List ((`String "RANGE_CONSTRAINT")::arg0::[]) ->
1143
          ((function
1144
            | `Assoc xs ->
1145
                let rec loop xs (arg0 as _state) =
1146
                  match xs with
1147
                  | ("range",x)::xs ->
1148
                      loop xs
1149
                        ((fun x  -> vhdl_discrete_range_t_of_yojson x) x)
1150
                  | [] ->
1151
                      arg0 >>=
1152
                        ((fun arg0  ->
1153
                            Result.Ok (RangeConstraint { range = arg0 })))
1154
                  | _::xs -> loop xs _state  in
1155
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.range")
1156
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1157
      | `List ((`String "INDEX_CONSTRAINT")::arg0::[]) ->
1158
          ((function
1159
            | `Assoc xs ->
1160
                let rec loop xs (arg0 as _state) =
1161
                  match xs with
1162
                  | ("ranges",x)::xs ->
1163
                      loop xs
1164
                        ((function
1165
                          | `List xs ->
1166
                              map_bind
1167
                                (fun x  -> vhdl_discrete_range_t_of_yojson x)
1168
                                [] xs
1169
                          | _ ->
1170
                              Result.Error
1171
                                "Vhdl_ast.vhdl_constraint_t.ranges") x)
1172
                  | [] ->
1173
                      arg0 >>=
1174
                        ((fun arg0  ->
1175
                            Result.Ok (IndexConstraint { ranges = arg0 })))
1176
                  | _::xs -> loop xs _state  in
1177
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ranges")
1178
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1179
      | `List ((`String "ARRAY_CONSTRAINT")::arg0::[]) ->
1180
          ((function
1181
            | `Assoc xs ->
1182
                let rec loop xs ((arg0,arg1) as _state) =
1183
                  match xs with
1184
                  | ("ranges",x)::xs ->
1185
                      loop xs
1186
                        (((function
1187
                           | `List xs ->
1188
                               map_bind
1189
                                 (fun x  -> vhdl_discrete_range_t_of_yojson x)
1190
                                 [] xs
1191
                           | _ ->
1192
                               Result.Error
1193
                                 "Vhdl_ast.vhdl_constraint_t.ranges") x),
1194
                          arg1)
1195
                  | ("sub",x)::xs ->
1196
                      loop xs
1197
                        (arg0, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
1198
                  | [] ->
1199
                      arg1 >>=
1200
                        ((fun arg1  ->
1201
                            arg0 >>=
1202
                              (fun arg0  ->
1203
                                 Result.Ok
1204
                                   (ArrayConstraint
1205
                                      { ranges = arg0; sub = arg1 }))))
1206
                  | _::xs -> loop xs _state  in
1207
                loop xs
1208
                  ((Result.Error "Vhdl_ast.vhdl_constraint_t.ranges"),
1209
                    (Result.Error "Vhdl_ast.vhdl_constraint_t.sub"))
1210
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1211
      | `List ((`String "RecordConstraint")::[]) ->
1212
          Result.Ok RecordConstraint
1213
      | `List ((`String "NoConstraint")::[]) -> Result.Ok NoConstraint
1214
      | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")
1215
  [@ocaml.warning "-A"])
1216

    
1217
and (vhdl_definition_t_to_yojson : vhdl_definition_t -> Yojson.Safe.json) =
1218
  ((let open! Ppx_deriving_yojson_runtime in
1219
      function
1220
      | Type arg0 ->
1221
          `List
1222
            [`String "TYPE_DECLARATION";
1223
            (let fields = []  in
1224
             let fields =
1225
               ("definition",
1226
                 ((fun x  -> vhdl_type_t_to_yojson x) arg0.definition))
1227
               :: fields  in
1228
             let fields =
1229
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1230
               fields  in
1231
             `Assoc fields)]
1232
      | Subtype arg0 ->
1233
          `List
1234
            [`String "SUBTYPE_DECLARATION";
1235
            (let fields = []  in
1236
             let fields =
1237
               ("typ",
1238
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
1239
               :: fields  in
1240
             let fields =
1241
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1242
               fields  in
1243
             `Assoc fields)])
1244
  [@ocaml.warning "-A"])
1245

    
1246
and (vhdl_definition_t_of_yojson :
1247
      Yojson.Safe.json ->
1248
        vhdl_definition_t Ppx_deriving_yojson_runtime.error_or)
1249
  =
1250
  ((let open! Ppx_deriving_yojson_runtime in
1251
      function
1252
      | `List ((`String "TYPE_DECLARATION")::arg0::[]) ->
1253
          ((function
1254
            | `Assoc xs ->
1255
                let rec loop xs ((arg0,arg1) as _state) =
1256
                  match xs with
1257
                  | ("name",x)::xs ->
1258
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1259
                  | ("definition",x)::xs ->
1260
                      loop xs (arg0, ((fun x  -> vhdl_type_t_of_yojson x) x))
1261
                  | [] ->
1262
                      arg1 >>=
1263
                        ((fun arg1  ->
1264
                            arg0 >>=
1265
                              (fun arg0  ->
1266
                                 Result.Ok
1267
                                   (Type { name = arg0; definition = arg1 }))))
1268
                  | _::xs -> loop xs _state  in
1269
                loop xs
1270
                  ((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
1271
                    (Result.Error "Vhdl_ast.vhdl_definition_t.definition"))
1272
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
1273
      | `List ((`String "SUBTYPE_DECLARATION")::arg0::[]) ->
1274
          ((function
1275
            | `Assoc xs ->
1276
                let rec loop xs ((arg0,arg1) as _state) =
1277
                  match xs with
1278
                  | ("name",x)::xs ->
1279
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1280
                  | ("typ",x)::xs ->
1281
                      loop xs
1282
                        (arg0,
1283
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
1284
                             x))
1285
                  | [] ->
1286
                      arg1 >>=
1287
                        ((fun arg1  ->
1288
                            arg0 >>=
1289
                              (fun arg0  ->
1290
                                 Result.Ok
1291
                                   (Subtype { name = arg0; typ = arg1 }))))
1292
                  | _::xs -> loop xs _state  in
1293
                loop xs
1294
                  ((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
1295
                    (Result.Error "Vhdl_ast.vhdl_definition_t.typ"))
1296
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
1297
      | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")
1298
  [@ocaml.warning "-A"])
1299

    
1300
and (vhdl_expr_t_to_yojson : vhdl_expr_t -> Yojson.Safe.json) =
1301
  ((let open! Ppx_deriving_yojson_runtime in
1302
      function
1303
      | Call arg0 ->
1304
          `List [`String "CALL"; ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
1305
      | Cst arg0 ->
1306
          `List
1307
            [`String "CONSTANT_VALUE";
1308
            ((fun x  -> vhdl_cst_val_t_to_yojson x)) arg0]
1309
      | Op arg0 ->
1310
          `List
1311
            [`String "EXPRESSION";
1312
            (let fields = []  in
1313
             let fields =
1314
               if arg0.args = []
1315
               then fields
1316
               else
1317
                 ("args",
1318
                   (((fun x  ->
1319
                        `List
1320
                          (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
1321
                      arg0.args))
1322
                 :: fields
1323
                in
1324
             let fields =
1325
               if arg0.id = ""
1326
               then fields
1327
               else
1328
                 ("id",
1329
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
1330
                      arg0.id))
1331
                 :: fields
1332
                in
1333
             `Assoc fields)]
1334
      | IsNull  -> `List [`String "IsNull"]
1335
      | Time arg0 ->
1336
          `List
1337
            [`String "Time";
1338
            (let fields = []  in
1339
             let fields =
1340
               if arg0.phy_unit = ""
1341
               then fields
1342
               else
1343
                 ("phy_unit",
1344
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
1345
                      arg0.phy_unit))
1346
                 :: fields
1347
                in
1348
             let fields =
1349
               ("value",
1350
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.value))
1351
               :: fields  in
1352
             `Assoc fields)]
1353
      | Sig arg0 ->
1354
          `List
1355
            [`String "Sig";
1356
            (let fields = []  in
1357
             let fields =
1358
               ("att",
1359
                 ((function
1360
                   | None  -> `Null
1361
                   | Some x ->
1362
                       ((fun x  -> vhdl_signal_attributes_t_to_yojson x)) x)
1363
                    arg0.att))
1364
               :: fields  in
1365
             let fields =
1366
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1367
               fields  in
1368
             `Assoc fields)]
1369
      | SuffixMod arg0 ->
1370
          `List
1371
            [`String "SuffixMod";
1372
            (let fields = []  in
1373
             let fields =
1374
               ("selection",
1375
                 ((fun x  -> vhdl_suffix_selection_t_to_yojson x)
1376
                    arg0.selection))
1377
               :: fields  in
1378
             let fields =
1379
               ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.expr)) ::
1380
               fields  in
1381
             `Assoc fields)]
1382
      | Aggregate arg0 ->
1383
          `List
1384
            [`String "AGGREGATE";
1385
            (let fields = []  in
1386
             let fields =
1387
               ("elems",
1388
                 ((fun x  ->
1389
                     `List
1390
                       (List.map (fun x  -> vhdl_element_assoc_t_to_yojson x)
1391
                          x)) arg0.elems))
1392
               :: fields  in
1393
             `Assoc fields)]
1394
      | Others  -> `List [`String "OTHERS"])
1395
  [@ocaml.warning "-A"])
1396

    
1397
and (vhdl_expr_t_of_yojson :
1398
      Yojson.Safe.json -> vhdl_expr_t Ppx_deriving_yojson_runtime.error_or)
1399
  =
1400
  ((let open! Ppx_deriving_yojson_runtime in
1401
      function
1402
      | `List ((`String "CALL")::arg0::[]) ->
1403
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
1404
            ((fun arg0  -> Result.Ok (Call arg0)))
1405
      | `List ((`String "CONSTANT_VALUE")::arg0::[]) ->
1406
          ((fun x  -> vhdl_cst_val_t_of_yojson x) arg0) >>=
1407
            ((fun arg0  -> Result.Ok (Cst arg0)))
1408
      | `List ((`String "EXPRESSION")::arg0::[]) ->
1409
          ((function
1410
            | `Assoc xs ->
1411
                let rec loop xs ((arg0,arg1) as _state) =
1412
                  match xs with
1413
                  | ("id",x)::xs ->
1414
                      loop xs
1415
                        (((function
1416
                           | `String x -> Result.Ok x
1417
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.id") x),
1418
                          arg1)
1419
                  | ("args",x)::xs ->
1420
                      loop xs
1421
                        (arg0,
1422
                          ((function
1423
                            | `List xs ->
1424
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1425
                                  [] xs
1426
                            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.args")
1427
                             x))
1428
                  | [] ->
1429
                      arg1 >>=
1430
                        ((fun arg1  ->
1431
                            arg0 >>=
1432
                              (fun arg0  ->
1433
                                 Result.Ok (Op { id = arg0; args = arg1 }))))
1434
                  | _::xs -> loop xs _state  in
1435
                loop xs ((Result.Ok ""), (Result.Ok []))
1436
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1437
      | `List ((`String "IsNull")::[]) -> Result.Ok IsNull
1438
      | `List ((`String "Time")::arg0::[]) ->
1439
          ((function
1440
            | `Assoc xs ->
1441
                let rec loop xs ((arg0,arg1) as _state) =
1442
                  match xs with
1443
                  | ("value",x)::xs ->
1444
                      loop xs
1445
                        (((function
1446
                           | `Int x -> Result.Ok x
1447
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.value")
1448
                            x), arg1)
1449
                  | ("phy_unit",x)::xs ->
1450
                      loop xs
1451
                        (arg0,
1452
                          ((function
1453
                            | `String x -> Result.Ok x
1454
                            | _ ->
1455
                                Result.Error "Vhdl_ast.vhdl_expr_t.phy_unit")
1456
                             x))
1457
                  | [] ->
1458
                      arg1 >>=
1459
                        ((fun arg1  ->
1460
                            arg0 >>=
1461
                              (fun arg0  ->
1462
                                 Result.Ok
1463
                                   (Time { value = arg0; phy_unit = arg1 }))))
1464
                  | _::xs -> loop xs _state  in
1465
                loop xs
1466
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.value"),
1467
                    (Result.Ok ""))
1468
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1469
      | `List ((`String "Sig")::arg0::[]) ->
1470
          ((function
1471
            | `Assoc xs ->
1472
                let rec loop xs ((arg0,arg1) as _state) =
1473
                  match xs with
1474
                  | ("name",x)::xs ->
1475
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1476
                  | ("att",x)::xs ->
1477
                      loop xs
1478
                        (arg0,
1479
                          ((function
1480
                            | `Null -> Result.Ok None
1481
                            | x ->
1482
                                ((fun x  ->
1483
                                    vhdl_signal_attributes_t_of_yojson x) x)
1484
                                  >>= ((fun x  -> Result.Ok (Some x)))) x))
1485
                  | [] ->
1486
                      arg1 >>=
1487
                        ((fun arg1  ->
1488
                            arg0 >>=
1489
                              (fun arg0  ->
1490
                                 Result.Ok (Sig { name = arg0; att = arg1 }))))
1491
                  | _::xs -> loop xs _state  in
1492
                loop xs
1493
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.name"),
1494
                    (Result.Error "Vhdl_ast.vhdl_expr_t.att"))
1495
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1496
      | `List ((`String "SuffixMod")::arg0::[]) ->
1497
          ((function
1498
            | `Assoc xs ->
1499
                let rec loop xs ((arg0,arg1) as _state) =
1500
                  match xs with
1501
                  | ("expr",x)::xs ->
1502
                      loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
1503
                  | ("selection",x)::xs ->
1504
                      loop xs
1505
                        (arg0,
1506
                          ((fun x  -> vhdl_suffix_selection_t_of_yojson x) x))
1507
                  | [] ->
1508
                      arg1 >>=
1509
                        ((fun arg1  ->
1510
                            arg0 >>=
1511
                              (fun arg0  ->
1512
                                 Result.Ok
1513
                                   (SuffixMod
1514
                                      { expr = arg0; selection = arg1 }))))
1515
                  | _::xs -> loop xs _state  in
1516
                loop xs
1517
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.expr"),
1518
                    (Result.Error "Vhdl_ast.vhdl_expr_t.selection"))
1519
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1520
      | `List ((`String "AGGREGATE")::arg0::[]) ->
1521
          ((function
1522
            | `Assoc xs ->
1523
                let rec loop xs (arg0 as _state) =
1524
                  match xs with
1525
                  | ("elems",x)::xs ->
1526
                      loop xs
1527
                        ((function
1528
                          | `List xs ->
1529
                              map_bind
1530
                                (fun x  -> vhdl_element_assoc_t_of_yojson x)
1531
                                [] xs
1532
                          | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.elems") x)
1533
                  | [] ->
1534
                      arg0 >>=
1535
                        ((fun arg0  -> Result.Ok (Aggregate { elems = arg0 })))
1536
                  | _::xs -> loop xs _state  in
1537
                loop xs (Result.Error "Vhdl_ast.vhdl_expr_t.elems")
1538
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1539
      | `List ((`String "OTHERS")::[]) -> Result.Ok Others
1540
      | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")
1541
  [@ocaml.warning "-A"])
1542

    
1543
and (vhdl_name_t_to_yojson : vhdl_name_t -> Yojson.Safe.json) =
1544
  ((let open! Ppx_deriving_yojson_runtime in
1545
      function
1546
      | Simple arg0 ->
1547
          `List
1548
            [`String "SIMPLE_NAME";
1549
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1550
      | Identifier arg0 ->
1551
          `List
1552
            [`String "IDENTIFIER";
1553
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1554
      | Selected arg0 ->
1555
          `List
1556
            [`String "SELECTED_NAME";
1557
            ((fun x  ->
1558
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
1559
      | Index arg0 ->
1560
          `List
1561
            [`String "INDEXED_NAME";
1562
            (let fields = []  in
1563
             let fields =
1564
               ("exprs",
1565
                 ((fun x  ->
1566
                     `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
1567
                    arg0.exprs))
1568
               :: fields  in
1569
             let fields =
1570
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1571
               fields  in
1572
             `Assoc fields)]
1573
      | Slice arg0 ->
1574
          `List
1575
            [`String "SLICE_NAME";
1576
            (let fields = []  in
1577
             let fields =
1578
               ("range",
1579
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
1580
               :: fields  in
1581
             let fields =
1582
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1583
               fields  in
1584
             `Assoc fields)]
1585
      | Attribute arg0 ->
1586
          `List
1587
            [`String "ATTRIBUTE_NAME";
1588
            (let fields = []  in
1589
             let fields =
1590
               if arg0.expr = IsNull
1591
               then fields
1592
               else
1593
                 ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.expr))
1594
                 :: fields
1595
                in
1596
             let fields =
1597
               ("designator",
1598
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.designator))
1599
               :: fields  in
1600
             let fields =
1601
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1602
               fields  in
1603
             `Assoc fields)]
1604
      | Function arg0 ->
1605
          `List
1606
            [`String "FUNCTION_CALL";
1607
            (let fields = []  in
1608
             let fields =
1609
               ("assoc_list",
1610
                 ((fun x  ->
1611
                     `List
1612
                       (List.map (fun x  -> vhdl_assoc_element_t_to_yojson x)
1613
                          x)) arg0.assoc_list))
1614
               :: fields  in
1615
             let fields =
1616
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1617
               fields  in
1618
             `Assoc fields)]
1619
      | NoName  -> `List [`String "NoName"])
1620
  [@ocaml.warning "-A"])
1621

    
1622
and (vhdl_name_t_of_yojson :
1623
      Yojson.Safe.json -> vhdl_name_t Ppx_deriving_yojson_runtime.error_or)
1624
  =
1625
  ((let open! Ppx_deriving_yojson_runtime in
1626
      function
1627
      | `List ((`String "SIMPLE_NAME")::arg0::[]) ->
1628
          ((function
1629
            | `String x -> Result.Ok x
1630
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1631
            ((fun arg0  -> Result.Ok (Simple arg0)))
1632
      | `List ((`String "IDENTIFIER")::arg0::[]) ->
1633
          ((function
1634
            | `String x -> Result.Ok x
1635
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1636
            ((fun arg0  -> Result.Ok (Identifier arg0)))
1637
      | `List ((`String "SELECTED_NAME")::arg0::[]) ->
1638
          ((function
1639
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1640
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1641
            ((fun arg0  -> Result.Ok (Selected arg0)))
1642
      | `List ((`String "INDEXED_NAME")::arg0::[]) ->
1643
          ((function
1644
            | `Assoc xs ->
1645
                let rec loop xs ((arg0,arg1) as _state) =
1646
                  match xs with
1647
                  | ("id",x)::xs ->
1648
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1649
                  | ("exprs",x)::xs ->
1650
                      loop xs
1651
                        (arg0,
1652
                          ((function
1653
                            | `List xs ->
1654
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1655
                                  [] xs
1656
                            | _ -> Result.Error "Vhdl_ast.vhdl_name_t.exprs")
1657
                             x))
1658
                  | [] ->
1659
                      arg1 >>=
1660
                        ((fun arg1  ->
1661
                            arg0 >>=
1662
                              (fun arg0  ->
1663
                                 Result.Ok
1664
                                   (Index { id = arg0; exprs = arg1 }))))
1665
                  | _::xs -> loop xs _state  in
1666
                loop xs
1667
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1668
                    (Result.Error "Vhdl_ast.vhdl_name_t.exprs"))
1669
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1670
      | `List ((`String "SLICE_NAME")::arg0::[]) ->
1671
          ((function
1672
            | `Assoc xs ->
1673
                let rec loop xs ((arg0,arg1) as _state) =
1674
                  match xs with
1675
                  | ("id",x)::xs ->
1676
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1677
                  | ("range",x)::xs ->
1678
                      loop xs
1679
                        (arg0,
1680
                          ((fun x  -> vhdl_discrete_range_t_of_yojson x) x))
1681
                  | [] ->
1682
                      arg1 >>=
1683
                        ((fun arg1  ->
1684
                            arg0 >>=
1685
                              (fun arg0  ->
1686
                                 Result.Ok
1687
                                   (Slice { id = arg0; range = arg1 }))))
1688
                  | _::xs -> loop xs _state  in
1689
                loop xs
1690
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1691
                    (Result.Error "Vhdl_ast.vhdl_name_t.range"))
1692
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1693
      | `List ((`String "ATTRIBUTE_NAME")::arg0::[]) ->
1694
          ((function
1695
            | `Assoc xs ->
1696
                let rec loop xs ((arg0,arg1,arg2) as _state) =
1697
                  match xs with
1698
                  | ("id",x)::xs ->
1699
                      loop xs
1700
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
1701
                  | ("designator",x)::xs ->
1702
                      loop xs
1703
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
1704
                  | ("expr",x)::xs ->
1705
                      loop xs
1706
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1707
                  | [] ->
1708
                      arg2 >>=
1709
                        ((fun arg2  ->
1710
                            arg1 >>=
1711
                              (fun arg1  ->
1712
                                 arg0 >>=
1713
                                   (fun arg0  ->
1714
                                      Result.Ok
1715
                                        (Attribute
1716
                                           {
1717
                                             id = arg0;
1718
                                             designator = arg1;
1719
                                             expr = arg2
1720
                                           })))))
1721
                  | _::xs -> loop xs _state  in
1722
                loop xs
1723
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1724
                    (Result.Error "Vhdl_ast.vhdl_name_t.designator"),
1725
                    (Result.Ok IsNull))
1726
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1727
      | `List ((`String "FUNCTION_CALL")::arg0::[]) ->
1728
          ((function
1729
            | `Assoc xs ->
1730
                let rec loop xs ((arg0,arg1) as _state) =
1731
                  match xs with
1732
                  | ("id",x)::xs ->
1733
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1734
                  | ("assoc_list",x)::xs ->
1735
                      loop xs
1736
                        (arg0,
1737
                          ((function
1738
                            | `List xs ->
1739
                                map_bind
1740
                                  (fun x  -> vhdl_assoc_element_t_of_yojson x)
1741
                                  [] xs
1742
                            | _ ->
1743
                                Result.Error
1744
                                  "Vhdl_ast.vhdl_name_t.assoc_list") x))
1745
                  | [] ->
1746
                      arg1 >>=
1747
                        ((fun arg1  ->
1748
                            arg0 >>=
1749
                              (fun arg0  ->
1750
                                 Result.Ok
1751
                                   (Function { id = arg0; assoc_list = arg1 }))))
1752
                  | _::xs -> loop xs _state  in
1753
                loop xs
1754
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1755
                    (Result.Error "Vhdl_ast.vhdl_name_t.assoc_list"))
1756
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1757
      | `List ((`String "NoName")::[]) -> Result.Ok NoName
1758
      | _ -> Result.Error "Vhdl_ast.vhdl_name_t")
1759
  [@ocaml.warning "-A"])
1760

    
1761
and (vhdl_assoc_element_t_to_yojson :
1762
      vhdl_assoc_element_t -> Yojson.Safe.json)
1763
  =
1764
  ((let open! Ppx_deriving_yojson_runtime in
1765
      fun x  ->
1766
        let fields = []  in
1767
        let fields =
1768
          if x.actual_expr = (Some IsNull)
1769
          then fields
1770
          else
1771
            ("actual_expr",
1772
              (((function
1773
                 | None  -> `Null
1774
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
1775
                 x.actual_expr))
1776
            :: fields
1777
           in
1778
        let fields =
1779
          if x.actual_designator = (Some NoName)
1780
          then fields
1781
          else
1782
            ("actual_designator",
1783
              (((function
1784
                 | None  -> `Null
1785
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1786
                 x.actual_designator))
1787
            :: fields
1788
           in
1789
        let fields =
1790
          if x.actual_name = (Some NoName)
1791
          then fields
1792
          else
1793
            ("actual_name",
1794
              (((function
1795
                 | None  -> `Null
1796
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1797
                 x.actual_name))
1798
            :: fields
1799
           in
1800
        let fields =
1801
          if x.formal_arg = (Some NoName)
1802
          then fields
1803
          else
1804
            ("formal_arg",
1805
              (((function
1806
                 | None  -> `Null
1807
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1808
                 x.formal_arg))
1809
            :: fields
1810
           in
1811
        let fields =
1812
          if x.formal_name = (Some NoName)
1813
          then fields
1814
          else
1815
            ("formal_name",
1816
              (((function
1817
                 | None  -> `Null
1818
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1819
                 x.formal_name))
1820
            :: fields
1821
           in
1822
        `Assoc fields)
1823
  [@ocaml.warning "-A"])
1824

    
1825
and (vhdl_assoc_element_t_of_yojson :
1826
      Yojson.Safe.json ->
1827
        vhdl_assoc_element_t Ppx_deriving_yojson_runtime.error_or)
1828
  =
1829
  ((let open! Ppx_deriving_yojson_runtime in
1830
      function
1831
      | `Assoc xs ->
1832
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
1833
            match xs with
1834
            | ("formal_name",x)::xs ->
1835
                loop xs
1836
                  (((function
1837
                     | `Null -> Result.Ok None
1838
                     | x ->
1839
                         ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1840
                           ((fun x  -> Result.Ok (Some x)))) x), arg1, arg2,
1841
                    arg3, arg4)
1842
            | ("formal_arg",x)::xs ->
1843
                loop xs
1844
                  (arg0,
1845
                    ((function
1846
                      | `Null -> Result.Ok None
1847
                      | x ->
1848
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1849
                            ((fun x  -> Result.Ok (Some x)))) x), arg2, arg3,
1850
                    arg4)
1851
            | ("actual_name",x)::xs ->
1852
                loop xs
1853
                  (arg0, arg1,
1854
                    ((function
1855
                      | `Null -> Result.Ok None
1856
                      | x ->
1857
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1858
                            ((fun x  -> Result.Ok (Some x)))) x), arg3, arg4)
1859
            | ("actual_designator",x)::xs ->
1860
                loop xs
1861
                  (arg0, arg1, arg2,
1862
                    ((function
1863
                      | `Null -> Result.Ok None
1864
                      | x ->
1865
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1866
                            ((fun x  -> Result.Ok (Some x)))) x), arg4)
1867
            | ("actual_expr",x)::xs ->
1868
                loop xs
1869
                  (arg0, arg1, arg2, arg3,
1870
                    ((function
1871
                      | `Null -> Result.Ok None
1872
                      | x ->
1873
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
1874
                            ((fun x  -> Result.Ok (Some x)))) x))
1875
            | [] ->
1876
                arg4 >>=
1877
                  ((fun arg4  ->
1878
                      arg3 >>=
1879
                        (fun arg3  ->
1880
                           arg2 >>=
1881
                             (fun arg2  ->
1882
                                arg1 >>=
1883
                                  (fun arg1  ->
1884
                                     arg0 >>=
1885
                                       (fun arg0  ->
1886
                                          Result.Ok
1887
                                            {
1888
                                              formal_name = arg0;
1889
                                              formal_arg = arg1;
1890
                                              actual_name = arg2;
1891
                                              actual_designator = arg3;
1892
                                              actual_expr = arg4
1893
                                            }))))))
1894
            | _::xs -> loop xs _state  in
1895
          loop xs
1896
            ((Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
1897
              (Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
1898
              (Result.Ok (Some IsNull)))
1899
      | _ -> Result.Error "Vhdl_ast.vhdl_assoc_element_t")
1900
  [@ocaml.warning "-A"])
1901

    
1902
and (vhdl_element_assoc_t_to_yojson :
1903
      vhdl_element_assoc_t -> Yojson.Safe.json)
1904
  =
1905
  ((let open! Ppx_deriving_yojson_runtime in
1906
      fun x  ->
1907
        let fields = []  in
1908
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
1909
          :: fields  in
1910
        let fields =
1911
          ("choices",
1912
            ((fun x  ->
1913
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
1914
               x.choices))
1915
          :: fields  in
1916
        `Assoc fields)
1917
  [@ocaml.warning "-A"])
1918

    
1919
and (vhdl_element_assoc_t_of_yojson :
1920
      Yojson.Safe.json ->
1921
        vhdl_element_assoc_t Ppx_deriving_yojson_runtime.error_or)
1922
  =
1923
  ((let open! Ppx_deriving_yojson_runtime in
1924
      function
1925
      | `Assoc xs ->
1926
          let rec loop xs ((arg0,arg1) as _state) =
1927
            match xs with
1928
            | ("choices",x)::xs ->
1929
                loop xs
1930
                  (((function
1931
                     | `List xs ->
1932
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
1933
                     | _ ->
1934
                         Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices")
1935
                      x), arg1)
1936
            | ("expr",x)::xs ->
1937
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1938
            | [] ->
1939
                arg1 >>=
1940
                  ((fun arg1  ->
1941
                      arg0 >>=
1942
                        (fun arg0  ->
1943
                           Result.Ok { choices = arg0; expr = arg1 })))
1944
            | _::xs -> loop xs _state  in
1945
          loop xs
1946
            ((Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices"),
1947
              (Result.Error "Vhdl_ast.vhdl_element_assoc_t.expr"))
1948
      | _ -> Result.Error "Vhdl_ast.vhdl_element_assoc_t")
1949
  [@ocaml.warning "-A"])
1950

    
1951
and (vhdl_array_attributes_t_to_yojson :
1952
      vhdl_array_attributes_t -> Yojson.Safe.json)
1953
  =
1954
  ((let open! Ppx_deriving_yojson_runtime in
1955
      function
1956
      | AAttInt arg0 ->
1957
          `List
1958
            [`String "AAttInt";
1959
            (let fields = []  in
1960
             let fields =
1961
               ("arg",
1962
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
1963
               :: fields  in
1964
             let fields =
1965
               ("id",
1966
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
1967
                    arg0.id))
1968
               :: fields  in
1969
             `Assoc fields)]
1970
      | AAttAscending  -> `List [`String "AAttAscending"])
1971
  [@ocaml.warning "-A"])
1972

    
1973
and (vhdl_array_attributes_t_of_yojson :
1974
      Yojson.Safe.json ->
1975
        vhdl_array_attributes_t Ppx_deriving_yojson_runtime.error_or)
1976
  =
1977
  ((let open! Ppx_deriving_yojson_runtime in
1978
      function
1979
      | `List ((`String "AAttInt")::arg0::[]) ->
1980
          ((function
1981
            | `Assoc xs ->
1982
                let rec loop xs ((arg0,arg1) as _state) =
1983
                  match xs with
1984
                  | ("id",x)::xs ->
1985
                      loop xs
1986
                        (((function
1987
                           | `String x -> Result.Ok x
1988
                           | _ ->
1989
                               Result.Error
1990
                                 "Vhdl_ast.vhdl_array_attributes_t.id") x),
1991
                          arg1)
1992
                  | ("arg",x)::xs ->
1993
                      loop xs
1994
                        (arg0,
1995
                          ((function
1996
                            | `Int x -> Result.Ok x
1997
                            | _ ->
1998
                                Result.Error
1999
                                  "Vhdl_ast.vhdl_array_attributes_t.arg") x))
2000
                  | [] ->
2001
                      arg1 >>=
2002
                        ((fun arg1  ->
2003
                            arg0 >>=
2004
                              (fun arg0  ->
2005
                                 Result.Ok
2006
                                   (AAttInt { id = arg0; arg = arg1 }))))
2007
                  | _::xs -> loop xs _state  in
2008
                loop xs
2009
                  ((Result.Error "Vhdl_ast.vhdl_array_attributes_t.id"),
2010
                    (Result.Error "Vhdl_ast.vhdl_array_attributes_t.arg"))
2011
            | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")) arg0
2012
      | `List ((`String "AAttAscending")::[]) -> Result.Ok AAttAscending
2013
      | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")
2014
  [@ocaml.warning "-A"])
2015

    
2016
and (vhdl_signal_attributes_t_to_yojson :
2017
      vhdl_signal_attributes_t -> Yojson.Safe.json)
2018
  =
2019
  ((let open! Ppx_deriving_yojson_runtime in
2020
      function
2021
      | SigAtt arg0 ->
2022
          `List
2023
            [`String "SigAtt";
2024
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
2025
  [@ocaml.warning "-A"])
2026

    
2027
and (vhdl_signal_attributes_t_of_yojson :
2028
      Yojson.Safe.json ->
2029
        vhdl_signal_attributes_t Ppx_deriving_yojson_runtime.error_or)
2030
  =
2031
  ((let open! Ppx_deriving_yojson_runtime in
2032
      function
2033
      | `List ((`String "SigAtt")::arg0::[]) ->
2034
          ((function
2035
            | `String x -> Result.Ok x
2036
            | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t") arg0)
2037
            >>= ((fun arg0  -> Result.Ok (SigAtt arg0)))
2038
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t")
2039
  [@ocaml.warning "-A"])
2040

    
2041
and (vhdl_string_attributes_t_to_yojson :
2042
      vhdl_string_attributes_t -> Yojson.Safe.json)
2043
  =
2044
  ((let open! Ppx_deriving_yojson_runtime in
2045
      function
2046
      | StringAtt arg0 ->
2047
          `List
2048
            [`String "StringAtt";
2049
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
2050
  [@ocaml.warning "-A"])
2051

    
2052
and (vhdl_string_attributes_t_of_yojson :
2053
      Yojson.Safe.json ->
2054
        vhdl_string_attributes_t Ppx_deriving_yojson_runtime.error_or)
2055
  =
2056
  ((let open! Ppx_deriving_yojson_runtime in
2057
      function
2058
      | `List ((`String "StringAtt")::arg0::[]) ->
2059
          ((function
2060
            | `String x -> Result.Ok x
2061
            | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t") arg0)
2062
            >>= ((fun arg0  -> Result.Ok (StringAtt arg0)))
2063
      | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t")
2064
  [@ocaml.warning "-A"])
2065

    
2066
and (vhdl_suffix_selection_t_to_yojson :
2067
      vhdl_suffix_selection_t -> Yojson.Safe.json)
2068
  =
2069
  ((let open! Ppx_deriving_yojson_runtime in
2070
      function
2071
      | Idx arg0 ->
2072
          `List
2073
            [`String "Idx";
2074
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0]
2075
      | SuffixRange (arg0,arg1) ->
2076
          `List
2077
            [`String "SuffixRange";
2078
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
2079
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1])
2080
  [@ocaml.warning "-A"])
2081

    
2082
and (vhdl_suffix_selection_t_of_yojson :
2083
      Yojson.Safe.json ->
2084
        vhdl_suffix_selection_t Ppx_deriving_yojson_runtime.error_or)
2085
  =
2086
  ((let open! Ppx_deriving_yojson_runtime in
2087
      function
2088
      | `List ((`String "Idx")::arg0::[]) ->
2089
          ((function
2090
            | `Int x -> Result.Ok x
2091
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg0) >>=
2092
            ((fun arg0  -> Result.Ok (Idx arg0)))
2093
      | `List ((`String "SuffixRange")::arg0::arg1::[]) ->
2094
          ((function
2095
            | `Int x -> Result.Ok x
2096
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg1) >>=
2097
            ((fun arg1  ->
2098
                ((function
2099
                  | `Int x -> Result.Ok x
2100
                  | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2101
                   arg0)
2102
                  >>= (fun arg0  -> Result.Ok (SuffixRange (arg0, arg1)))))
2103
      | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2104
  [@ocaml.warning "-A"])
2105

    
2106
type 'basetype vhdl_type_attributes_t =
2107
  | TAttNoArg of {
2108
  id: string } 
2109
  | TAttIntArg of {
2110
  id: string ;
2111
  arg: int } 
2112
  | TAttValArg of {
2113
  id: string ;
2114
  arg: 'basetype } 
2115
  | TAttStringArg of {
2116
  id: string ;
2117
  arg: string } 
2118

    
2119
let rec pp_vhdl_type_attributes_t
2120
  =
2121
  ((let open! Ppx_deriving_runtime in
2122
      fun poly_basetype  ->
2123
        fun fmt  ->
2124
          function
2125
          | TAttNoArg { id = aid } ->
2126
              (Format.fprintf fmt "@[<2>TAttNoArg {@,";
2127
               (Format.fprintf fmt "@[%s =@ " "id";
2128
                (Format.fprintf fmt "%S") aid;
2129
                Format.fprintf fmt "@]");
2130
               Format.fprintf fmt "@]}")
2131
          | TAttIntArg { id = aid; arg = aarg } ->
2132
              (Format.fprintf fmt "@[<2>TAttIntArg {@,";
2133
               ((Format.fprintf fmt "@[%s =@ " "id";
2134
                 (Format.fprintf fmt "%S") aid;
2135
                 Format.fprintf fmt "@]");
2136
                Format.fprintf fmt ";@ ";
2137
                Format.fprintf fmt "@[%s =@ " "arg";
2138
                (Format.fprintf fmt "%d") aarg;
2139
                Format.fprintf fmt "@]");
2140
               Format.fprintf fmt "@]}")
2141
          | TAttValArg { id = aid; arg = aarg } ->
2142
              (Format.fprintf fmt "@[<2>TAttValArg {@,";
2143
               ((Format.fprintf fmt "@[%s =@ " "id";
2144
                 (Format.fprintf fmt "%S") aid;
2145
                 Format.fprintf fmt "@]");
2146
                Format.fprintf fmt ";@ ";
2147
                Format.fprintf fmt "@[%s =@ " "arg";
2148
                (poly_basetype fmt) aarg;
2149
                Format.fprintf fmt "@]");
2150
               Format.fprintf fmt "@]}")
2151
          | TAttStringArg { id = aid; arg = aarg } ->
2152
              (Format.fprintf fmt "@[<2>TAttStringArg {@,";
2153
               ((Format.fprintf fmt "@[%s =@ " "id";
2154
                 (Format.fprintf fmt "%S") aid;
2155
                 Format.fprintf fmt "@]");
2156
                Format.fprintf fmt ";@ ";
2157
                Format.fprintf fmt "@[%s =@ " "arg";
2158
                (Format.fprintf fmt "%S") aarg;
2159
                Format.fprintf fmt "@]");
2160
               Format.fprintf fmt "@]}"))
2161
  [@ocaml.warning "-A"])
2162

    
2163
and show_vhdl_type_attributes_t  =
2164
  fun poly_basetype  ->
2165
    fun x  ->
2166
      Format.asprintf "%a" (pp_vhdl_type_attributes_t poly_basetype) x
2167

    
2168
let rec vhdl_type_attributes_t_to_yojson :
2169
  'basetype .
2170
    ('basetype -> Yojson.Safe.json) ->
2171
      'basetype vhdl_type_attributes_t -> Yojson.Safe.json
2172
  =
2173
  fun poly_basetype  ->
2174
    ((let open! Ppx_deriving_yojson_runtime in
2175
        function
2176
        | TAttNoArg arg0 ->
2177
            `List
2178
              [`String "TAttNoArg";
2179
              (let fields = []  in
2180
               let fields =
2181
                 ("id",
2182
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2183
                      arg0.id))
2184
                 :: fields  in
2185
               `Assoc fields)]
2186
        | TAttIntArg arg0 ->
2187
            `List
2188
              [`String "TAttIntArg";
2189
              (let fields = []  in
2190
               let fields =
2191
                 ("arg",
2192
                   ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
2193
                 :: fields  in
2194
               let fields =
2195
                 ("id",
2196
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2197
                      arg0.id))
2198
                 :: fields  in
2199
               `Assoc fields)]
2200
        | TAttValArg arg0 ->
2201
            `List
2202
              [`String "TAttValArg";
2203
              (let fields = []  in
2204
               let fields =
2205
                 ("arg", ((poly_basetype : _ -> Yojson.Safe.json) arg0.arg))
2206
                 :: fields  in
2207
               let fields =
2208
                 ("id",
2209
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2210
                      arg0.id))
2211
                 :: fields  in
2212
               `Assoc fields)]
2213
        | TAttStringArg arg0 ->
2214
            `List
2215
              [`String "TAttStringArg";
2216
              (let fields = []  in
2217
               let fields =
2218
                 ("arg",
2219
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2220
                      arg0.arg))
2221
                 :: fields  in
2222
               let fields =
2223
                 ("id",
2224
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2225
                      arg0.id))
2226
                 :: fields  in
2227
               `Assoc fields)])
2228
    [@ocaml.warning "-A"])
2229

    
2230
and vhdl_type_attributes_t_of_yojson :
2231
  'basetype .
2232
    (Yojson.Safe.json -> 'basetype Ppx_deriving_yojson_runtime.error_or) ->
2233
      Yojson.Safe.json ->
2234
        'basetype vhdl_type_attributes_t Ppx_deriving_yojson_runtime.error_or
2235
  =
2236
  fun poly_basetype  ->
2237
    ((let open! Ppx_deriving_yojson_runtime in
2238
        function
2239
        | `List ((`String "TAttNoArg")::arg0::[]) ->
2240
            ((function
2241
              | `Assoc xs ->
2242
                  let rec loop xs (arg0 as _state) =
2243
                    match xs with
2244
                    | ("id",x)::xs ->
2245
                        loop xs
2246
                          ((function
2247
                            | `String x -> Result.Ok x
2248
                            | _ ->
2249
                                Result.Error
2250
                                  "Vhdl_ast.vhdl_type_attributes_t.id") x)
2251
                    | [] ->
2252
                        arg0 >>=
2253
                          ((fun arg0  -> Result.Ok (TAttNoArg { id = arg0 })))
2254
                    | _::xs -> loop xs _state  in
2255
                  loop xs (Result.Error "Vhdl_ast.vhdl_type_attributes_t.id")
2256
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2257
        | `List ((`String "TAttIntArg")::arg0::[]) ->
2258
            ((function
2259
              | `Assoc xs ->
2260
                  let rec loop xs ((arg0,arg1) as _state) =
2261
                    match xs with
2262
                    | ("id",x)::xs ->
2263
                        loop xs
2264
                          (((function
2265
                             | `String x -> Result.Ok x
2266
                             | _ ->
2267
                                 Result.Error
2268
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2269
                            arg1)
2270
                    | ("arg",x)::xs ->
2271
                        loop xs
2272
                          (arg0,
2273
                            ((function
2274
                              | `Int x -> Result.Ok x
2275
                              | _ ->
2276
                                  Result.Error
2277
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2278
                    | [] ->
2279
                        arg1 >>=
2280
                          ((fun arg1  ->
2281
                              arg0 >>=
2282
                                (fun arg0  ->
2283
                                   Result.Ok
2284
                                     (TAttIntArg { id = arg0; arg = arg1 }))))
2285
                    | _::xs -> loop xs _state  in
2286
                  loop xs
2287
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2288
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2289
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2290
        | `List ((`String "TAttValArg")::arg0::[]) ->
2291
            ((function
2292
              | `Assoc xs ->
2293
                  let rec loop xs ((arg0,arg1) as _state) =
2294
                    match xs with
2295
                    | ("id",x)::xs ->
2296
                        loop xs
2297
                          (((function
2298
                             | `String x -> Result.Ok x
2299
                             | _ ->
2300
                                 Result.Error
2301
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2302
                            arg1)
2303
                    | ("arg",x)::xs ->
2304
                        loop xs
2305
                          (arg0,
2306
                            ((poly_basetype : Yojson.Safe.json -> _ error_or)
2307
                               x))
2308
                    | [] ->
2309
                        arg1 >>=
2310
                          ((fun arg1  ->
2311
                              arg0 >>=
2312
                                (fun arg0  ->
2313
                                   Result.Ok
2314
                                     (TAttValArg { id = arg0; arg = arg1 }))))
2315
                    | _::xs -> loop xs _state  in
2316
                  loop xs
2317
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2318
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2319
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2320
        | `List ((`String "TAttStringArg")::arg0::[]) ->
2321
            ((function
2322
              | `Assoc xs ->
2323
                  let rec loop xs ((arg0,arg1) as _state) =
2324
                    match xs with
2325
                    | ("id",x)::xs ->
2326
                        loop xs
2327
                          (((function
2328
                             | `String x -> Result.Ok x
2329
                             | _ ->
2330
                                 Result.Error
2331
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2332
                            arg1)
2333
                    | ("arg",x)::xs ->
2334
                        loop xs
2335
                          (arg0,
2336
                            ((function
2337
                              | `String x -> Result.Ok x
2338
                              | _ ->
2339
                                  Result.Error
2340
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2341
                    | [] ->
2342
                        arg1 >>=
2343
                          ((fun arg1  ->
2344
                              arg0 >>=
2345
                                (fun arg0  ->
2346
                                   Result.Ok
2347
                                     (TAttStringArg { id = arg0; arg = arg1 }))))
2348
                    | _::xs -> loop xs _state  in
2349
                  loop xs
2350
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2351
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2352
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2353
        | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")
2354
    [@ocaml.warning "-A"])
2355

    
2356
let typ_att_noarg = ["base"; "left"; "right"; "high"; "low"] 
2357
let typ_att_intarg = ["pos"; "val"; "succ"; "pred"; "leftof"; "rightof"] 
2358
let typ_att_valarg = ["image"] 
2359
let typ_att_stringarg = ["value"] 
2360
let array_att_intarg =
2361
  ["left"; "right"; "high"; "low"; "range"; "reverse_range"; "length"] 
2362
type vhdl_parameter_t =
2363
  {
2364
  names: vhdl_name_t list ;
2365
  mode: string list [@default []];
2366
  typ: vhdl_subtype_indication_t ;
2367
  init_val: vhdl_cst_val_t option [@default Some (CstInt 0)]}
2368

    
2369
let rec pp_vhdl_parameter_t :
2370
  Format.formatter -> vhdl_parameter_t -> Ppx_deriving_runtime.unit =
2371
  let __2 () = pp_vhdl_cst_val_t
2372
  
2373
  and __1 () = pp_vhdl_subtype_indication_t
2374
  
2375
  and __0 () = pp_vhdl_name_t
2376
   in
2377
  ((let open! Ppx_deriving_runtime in
2378
      fun fmt  ->
2379
        fun x  ->
2380
          Format.fprintf fmt "@[<2>{ ";
2381
          ((((Format.fprintf fmt "@[%s =@ " "names";
2382
              ((fun x  ->
2383
                  Format.fprintf fmt "@[<2>[";
2384
                  ignore
2385
                    (List.fold_left
2386
                       (fun sep  ->
2387
                          fun x  ->
2388
                            if sep then Format.fprintf fmt ";@ ";
2389
                            ((__0 ()) fmt) x;
2390
                            true) false x);
2391
                  Format.fprintf fmt "@,]@]")) x.names;
2392
              Format.fprintf fmt "@]");
2393
             Format.fprintf fmt ";@ ";
2394
             Format.fprintf fmt "@[%s =@ " "mode";
2395
             ((fun x  ->
2396
                 Format.fprintf fmt "@[<2>[";
2397
                 ignore
2398
                   (List.fold_left
2399
                      (fun sep  ->
2400
                         fun x  ->
2401
                           if sep then Format.fprintf fmt ";@ ";
2402
                           (Format.fprintf fmt "%S") x;
2403
                           true) false x);
2404
                 Format.fprintf fmt "@,]@]")) x.mode;
2405
             Format.fprintf fmt "@]");
2406
            Format.fprintf fmt ";@ ";
2407
            Format.fprintf fmt "@[%s =@ " "typ";
2408
            ((__1 ()) fmt) x.typ;
2409
            Format.fprintf fmt "@]");
2410
           Format.fprintf fmt ";@ ";
2411
           Format.fprintf fmt "@[%s =@ " "init_val";
2412
           ((function
2413
             | None  -> Format.pp_print_string fmt "None"
2414
             | Some x ->
2415
                 (Format.pp_print_string fmt "(Some ";
2416
                  ((__2 ()) fmt) x;
2417
                  Format.pp_print_string fmt ")"))) x.init_val;
2418
           Format.fprintf fmt "@]");
2419
          Format.fprintf fmt "@ }@]")
2420
    [@ocaml.warning "-A"])
2421

    
2422
and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string =
2423
  fun x  -> Format.asprintf "%a" pp_vhdl_parameter_t x
2424

    
2425
let rec (vhdl_parameter_t_to_yojson : vhdl_parameter_t -> Yojson.Safe.json) =
2426
  ((let open! Ppx_deriving_yojson_runtime in
2427
      fun x  ->
2428
        let fields = []  in
2429
        let fields =
2430
          if x.init_val = (Some (CstInt 0))
2431
          then fields
2432
          else
2433
            ("init_val",
2434
              (((function
2435
                 | None  -> `Null
2436
                 | Some x -> ((fun x  -> vhdl_cst_val_t_to_yojson x)) x))
2437
                 x.init_val))
2438
            :: fields
2439
           in
2440
        let fields =
2441
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
2442
          :: fields  in
2443
        let fields =
2444
          if x.mode = []
2445
          then fields
2446
          else
2447
            ("mode",
2448
              (((fun x  ->
2449
                   `List
2450
                     (List.map
2451
                        (fun (x : Ppx_deriving_runtime.string)  -> `String x)
2452
                        x))) x.mode))
2453
            :: fields
2454
           in
2455
        let fields =
2456
          ("names",
2457
            ((fun x  ->
2458
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
2459
               x.names))
2460
          :: fields  in
2461
        `Assoc fields)
2462
  [@ocaml.warning "-A"])
2463

    
2464
and (vhdl_parameter_t_of_yojson :
2465
      Yojson.Safe.json ->
2466
        vhdl_parameter_t Ppx_deriving_yojson_runtime.error_or)
2467
  =
2468
  ((let open! Ppx_deriving_yojson_runtime in
2469
      function
2470
      | `Assoc xs ->
2471
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2472
            match xs with
2473
            | ("names",x)::xs ->
2474
                loop xs
2475
                  (((function
2476
                     | `List xs ->
2477
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
2478
                     | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.names") x),
2479
                    arg1, arg2, arg3)
2480
            | ("mode",x)::xs ->
2481
                loop xs
2482
                  (arg0,
2483
                    ((function
2484
                      | `List xs ->
2485
                          map_bind
2486
                            (function
2487
                             | `String x -> Result.Ok x
2488
                             | _ ->
2489
                                 Result.Error
2490
                                   "Vhdl_ast.vhdl_parameter_t.mode") [] xs
2491
                      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.mode") x),
2492
                    arg2, arg3)
2493
            | ("typ",x)::xs ->
2494
                loop xs
2495
                  (arg0, arg1,
2496
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
2497
                    arg3)
2498
            | ("init_val",x)::xs ->
2499
                loop xs
2500
                  (arg0, arg1, arg2,
2501
                    ((function
2502
                      | `Null -> Result.Ok None
2503
                      | x ->
2504
                          ((fun x  -> vhdl_cst_val_t_of_yojson x) x) >>=
2505
                            ((fun x  -> Result.Ok (Some x)))) x))
2506
            | [] ->
2507
                arg3 >>=
2508
                  ((fun arg3  ->
2509
                      arg2 >>=
2510
                        (fun arg2  ->
2511
                           arg1 >>=
2512
                             (fun arg1  ->
2513
                                arg0 >>=
2514
                                  (fun arg0  ->
2515
                                     Result.Ok
2516
                                       {
2517
                                         names = arg0;
2518
                                         mode = arg1;
2519
                                         typ = arg2;
2520
                                         init_val = arg3
2521
                                       })))))
2522
            | _::xs -> loop xs _state  in
2523
          loop xs
2524
            ((Result.Error "Vhdl_ast.vhdl_parameter_t.names"),
2525
              (Result.Ok []), (Result.Error "Vhdl_ast.vhdl_parameter_t.typ"),
2526
              (Result.Ok (Some (CstInt 0))))
2527
      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t")
2528
  [@ocaml.warning "-A"])
2529

    
2530
type vhdl_subprogram_spec_t =
2531
  {
2532
  name: string [@default ""];
2533
  typeMark: vhdl_name_t [@default NoName];
2534
  parameters: vhdl_parameter_t list ;
2535
  isPure: bool [@default false]}
2536

    
2537
let rec pp_vhdl_subprogram_spec_t :
2538
  Format.formatter -> vhdl_subprogram_spec_t -> Ppx_deriving_runtime.unit =
2539
  let __1 () = pp_vhdl_parameter_t
2540
  
2541
  and __0 () = pp_vhdl_name_t
2542
   in
2543
  ((let open! Ppx_deriving_runtime in
2544
      fun fmt  ->
2545
        fun x  ->
2546
          Format.fprintf fmt "@[<2>{ ";
2547
          ((((Format.fprintf fmt "@[%s =@ " "name";
2548
              (Format.fprintf fmt "%S") x.name;
2549
              Format.fprintf fmt "@]");
2550
             Format.fprintf fmt ";@ ";
2551
             Format.fprintf fmt "@[%s =@ " "typeMark";
2552
             ((__0 ()) fmt) x.typeMark;
2553
             Format.fprintf fmt "@]");
2554
            Format.fprintf fmt ";@ ";
2555
            Format.fprintf fmt "@[%s =@ " "parameters";
2556
            ((fun x  ->
2557
                Format.fprintf fmt "@[<2>[";
2558
                ignore
2559
                  (List.fold_left
2560
                     (fun sep  ->
2561
                        fun x  ->
2562
                          if sep then Format.fprintf fmt ";@ ";
2563
                          ((__1 ()) fmt) x;
2564
                          true) false x);
2565
                Format.fprintf fmt "@,]@]")) x.parameters;
2566
            Format.fprintf fmt "@]");
2567
           Format.fprintf fmt ";@ ";
2568
           Format.fprintf fmt "@[%s =@ " "isPure";
2569
           (Format.fprintf fmt "%B") x.isPure;
2570
           Format.fprintf fmt "@]");
2571
          Format.fprintf fmt "@ }@]")
2572
    [@ocaml.warning "-A"])
2573

    
2574
and show_vhdl_subprogram_spec_t :
2575
  vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string =
2576
  fun x  -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x
2577

    
2578
let rec (vhdl_subprogram_spec_t_to_yojson :
2579
          vhdl_subprogram_spec_t -> Yojson.Safe.json)
2580
  =
2581
  ((let open! Ppx_deriving_yojson_runtime in
2582
      fun x  ->
2583
        let fields = []  in
2584
        let fields =
2585
          if x.isPure = false
2586
          then fields
2587
          else
2588
            ("isPure",
2589
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x)) x.isPure))
2590
            :: fields
2591
           in
2592
        let fields =
2593
          ("parameters",
2594
            ((fun x  ->
2595
                `List (List.map (fun x  -> vhdl_parameter_t_to_yojson x) x))
2596
               x.parameters))
2597
          :: fields  in
2598
        let fields =
2599
          if x.typeMark = NoName
2600
          then fields
2601
          else
2602
            ("typeMark", (((fun x  -> vhdl_name_t_to_yojson x)) x.typeMark))
2603
            :: fields
2604
           in
2605
        let fields =
2606
          if x.name = ""
2607
          then fields
2608
          else
2609
            ("name",
2610
              (((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x.name))
2611
            :: fields
2612
           in
2613
        `Assoc fields)
2614
  [@ocaml.warning "-A"])
2615

    
2616
and (vhdl_subprogram_spec_t_of_yojson :
2617
      Yojson.Safe.json ->
2618
        vhdl_subprogram_spec_t Ppx_deriving_yojson_runtime.error_or)
2619
  =
2620
  ((let open! Ppx_deriving_yojson_runtime in
2621
      function
2622
      | `Assoc xs ->
2623
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2624
            match xs with
2625
            | ("name",x)::xs ->
2626
                loop xs
2627
                  (((function
2628
                     | `String x -> Result.Ok x
2629
                     | _ ->
2630
                         Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.name")
2631
                      x), arg1, arg2, arg3)
2632
            | ("typeMark",x)::xs ->
2633
                loop xs
2634
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3)
2635
            | ("parameters",x)::xs ->
2636
                loop xs
2637
                  (arg0, arg1,
2638
                    ((function
2639
                      | `List xs ->
2640
                          map_bind (fun x  -> vhdl_parameter_t_of_yojson x)
2641
                            [] xs
2642
                      | _ ->
2643
                          Result.Error
2644
                            "Vhdl_ast.vhdl_subprogram_spec_t.parameters") x),
2645
                    arg3)
2646
            | ("isPure",x)::xs ->
2647
                loop xs
2648
                  (arg0, arg1, arg2,
2649
                    ((function
2650
                      | `Bool x -> Result.Ok x
2651
                      | _ ->
2652
                          Result.Error
2653
                            "Vhdl_ast.vhdl_subprogram_spec_t.isPure") x))
2654
            | [] ->
2655
                arg3 >>=
2656
                  ((fun arg3  ->
2657
                      arg2 >>=
2658
                        (fun arg2  ->
2659
                           arg1 >>=
2660
                             (fun arg1  ->
2661
                                arg0 >>=
2662
                                  (fun arg0  ->
2663
                                     Result.Ok
2664
                                       {
2665
                                         name = arg0;
2666
                                         typeMark = arg1;
2667
                                         parameters = arg2;
2668
                                         isPure = arg3
2669
                                       })))))
2670
            | _::xs -> loop xs _state  in
2671
          loop xs
2672
            ((Result.Ok ""), (Result.Ok NoName),
2673
              (Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.parameters"),
2674
              (Result.Ok false))
2675
      | _ -> Result.Error "Vhdl_ast.vhdl_subprogram_spec_t")
2676
  [@ocaml.warning "-A"])
2677

    
2678
let arith_funs = ["+"; "-"; "*"; "/"; "mod"; "rem"; "abs"; "**"; "&"] 
2679
let bool_funs = ["and"; "or"; "nand"; "nor"; "xor"; "not"] 
2680
let rel_funs =
2681
  ["<";
2682
  ">";
2683
  "<=";
2684
  ">=";
2685
  "/=";
2686
  "=";
2687
  "?=";
2688
  "?/=";
2689
  "?<";
2690
  "?<=";
2691
  "?>";
2692
  "?>=";
2693
  "??"] 
2694
let shift_funs = ["sll"; "srl"; "sla"; "sra"; "rol"; "ror"] 
2695
type vhdl_sequential_stmt_t =
2696
  | VarAssign of
2697
  {
2698
  label: vhdl_name_t [@default NoName];
2699
  lhs: vhdl_name_t ;
2700
  rhs: vhdl_expr_t } [@name "VARIABLE_ASSIGNMENT_STATEMENT"]
2701
  | SigSeqAssign of
2702
  {
2703
  label: vhdl_name_t [@default NoName];
2704
  lhs: vhdl_name_t ;
2705
  rhs: vhdl_expr_t list } [@name "SIGNAL_ASSIGNMENT_STATEMENT"]
2706
  | If of
2707
  {
2708
  label: vhdl_name_t [@default NoName];
2709
  if_cases: vhdl_if_case_t list ;
2710
  default: vhdl_sequential_stmt_t list [@default []]} [@name "IF_STATEMENT"]
2711
  | Case of
2712
  {
2713
  label: vhdl_name_t [@default NoName];
2714
  guard: vhdl_expr_t ;
2715
  branches: vhdl_case_item_t list } [@name "CASE_STATEMENT_TREE"]
2716
  | Exit of
2717
  {
2718
  label: vhdl_name_t [@default NoName];
2719
  loop_label: string option [@default Some ""];
2720
  condition: vhdl_expr_t option [@default Some IsNull]}
2721
  [@name "EXIT_STATEMENT"]
2722
  | Assert of
2723
  {
2724
  label: vhdl_name_t [@default NoName];
2725
  cond: vhdl_expr_t ;
2726
  report: vhdl_expr_t [@default IsNull];
2727
  severity: vhdl_expr_t [@default IsNull]} [@name "ASSERTION_STATEMENT"]
2728
  | Wait [@name "WAIT_STATEMENT"]
2729
  | Null of {
2730
  label: vhdl_name_t [@default NoName]} [@name "NULL_STATEMENT"]
2731
  | Return of {
2732
  label: vhdl_name_t [@default NoName]} [@name "RETURN_STATEMENT"]
2733
and vhdl_if_case_t =
2734
  {
2735
  if_cond: vhdl_expr_t ;
2736
  if_block: vhdl_sequential_stmt_t list }
2737
and vhdl_case_item_t =
2738
  {
2739
  when_cond: vhdl_expr_t list ;
2740
  when_stmt: vhdl_sequential_stmt_t list }
2741

    
2742
let rec pp_vhdl_sequential_stmt_t :
2743
  Format.formatter -> vhdl_sequential_stmt_t -> Ppx_deriving_runtime.unit =
2744
  let __19 () = pp_vhdl_name_t
2745
  
2746
  and __18 () = pp_vhdl_name_t
2747
  
2748
  and __17 () = pp_vhdl_expr_t
2749
  
2750
  and __16 () = pp_vhdl_expr_t
2751
  
2752
  and __15 () = pp_vhdl_expr_t
2753
  
2754
  and __14 () = pp_vhdl_name_t
2755
  
2756
  and __13 () = pp_vhdl_expr_t
2757
  
2758
  and __12 () = pp_vhdl_name_t
2759
  
2760
  and __11 () = pp_vhdl_case_item_t
2761
  
2762
  and __10 () = pp_vhdl_expr_t
2763
  
2764
  and __9 () = pp_vhdl_name_t
2765
  
2766
  and __8 () = pp_vhdl_sequential_stmt_t
2767
  
2768
  and __7 () = pp_vhdl_if_case_t
2769
  
2770
  and __6 () = pp_vhdl_name_t
2771
  
2772
  and __5 () = pp_vhdl_expr_t
2773
  
2774
  and __4 () = pp_vhdl_name_t
2775
  
2776
  and __3 () = pp_vhdl_name_t
2777
  
2778
  and __2 () = pp_vhdl_expr_t
2779
  
2780
  and __1 () = pp_vhdl_name_t
2781
  
2782
  and __0 () = pp_vhdl_name_t
2783
   in
2784
  ((let open! Ppx_deriving_runtime in
2785
      fun fmt  ->
2786
        function
2787
        | VarAssign { label = alabel; lhs = alhs; rhs = arhs } ->
2788
            (Format.fprintf fmt "@[<2>VarAssign {@,";
2789
             (((Format.fprintf fmt "@[%s =@ " "label";
2790
                ((__0 ()) fmt) alabel;
2791
                Format.fprintf fmt "@]");
2792
               Format.fprintf fmt ";@ ";
2793
               Format.fprintf fmt "@[%s =@ " "lhs";
2794
               ((__1 ()) fmt) alhs;
2795
               Format.fprintf fmt "@]");
2796
              Format.fprintf fmt ";@ ";
2797
              Format.fprintf fmt "@[%s =@ " "rhs";
2798
              ((__2 ()) fmt) arhs;
2799
              Format.fprintf fmt "@]");
2800
             Format.fprintf fmt "@]}")
2801
        | SigSeqAssign { label = alabel; lhs = alhs; rhs = arhs } ->
2802
            (Format.fprintf fmt "@[<2>SigSeqAssign {@,";
2803
             (((Format.fprintf fmt "@[%s =@ " "label";
2804
                ((__3 ()) fmt) alabel;
2805
                Format.fprintf fmt "@]");
2806
               Format.fprintf fmt ";@ ";
2807
               Format.fprintf fmt "@[%s =@ " "lhs";
2808
               ((__4 ()) fmt) alhs;
2809
               Format.fprintf fmt "@]");
2810
              Format.fprintf fmt ";@ ";
2811
              Format.fprintf fmt "@[%s =@ " "rhs";
2812
              ((fun x  ->
2813
                  Format.fprintf fmt "@[<2>[";
2814
                  ignore
2815
                    (List.fold_left
2816
                       (fun sep  ->
2817
                          fun x  ->
2818
                            if sep then Format.fprintf fmt ";@ ";
2819
                            ((__5 ()) fmt) x;
2820
                            true) false x);
2821
                  Format.fprintf fmt "@,]@]")) arhs;
2822
              Format.fprintf fmt "@]");
2823
             Format.fprintf fmt "@]}")
2824
        | If { label = alabel; if_cases = aif_cases; default = adefault } ->
2825
            (Format.fprintf fmt "@[<2>If {@,";
2826
             (((Format.fprintf fmt "@[%s =@ " "label";
2827
                ((__6 ()) fmt) alabel;
2828
                Format.fprintf fmt "@]");
2829
               Format.fprintf fmt ";@ ";
2830
               Format.fprintf fmt "@[%s =@ " "if_cases";
2831
               ((fun x  ->
2832
                   Format.fprintf fmt "@[<2>[";
2833
                   ignore
2834
                     (List.fold_left
2835
                        (fun sep  ->
2836
                           fun x  ->
2837
                             if sep then Format.fprintf fmt ";@ ";
2838
                             ((__7 ()) fmt) x;
2839
                             true) false x);
2840
                   Format.fprintf fmt "@,]@]")) aif_cases;
2841
               Format.fprintf fmt "@]");
2842
              Format.fprintf fmt ";@ ";
2843
              Format.fprintf fmt "@[%s =@ " "default";
2844
              ((fun x  ->
2845
                  Format.fprintf fmt "@[<2>[";
2846
                  ignore
2847
                    (List.fold_left
2848
                       (fun sep  ->
2849
                          fun x  ->
2850
                            if sep then Format.fprintf fmt ";@ ";
2851
                            ((__8 ()) fmt) x;
2852
                            true) false x);
2853
                  Format.fprintf fmt "@,]@]")) adefault;
2854
              Format.fprintf fmt "@]");
2855
             Format.fprintf fmt "@]}")
2856
        | Case { label = alabel; guard = aguard; branches = abranches } ->
2857
            (Format.fprintf fmt "@[<2>Case {@,";
2858
             (((Format.fprintf fmt "@[%s =@ " "label";
2859
                ((__9 ()) fmt) alabel;
2860
                Format.fprintf fmt "@]");
2861
               Format.fprintf fmt ";@ ";
2862
               Format.fprintf fmt "@[%s =@ " "guard";
2863
               ((__10 ()) fmt) aguard;
2864
               Format.fprintf fmt "@]");
2865
              Format.fprintf fmt ";@ ";
2866
              Format.fprintf fmt "@[%s =@ " "branches";
2867
              ((fun x  ->
2868
                  Format.fprintf fmt "@[<2>[";
2869
                  ignore
2870
                    (List.fold_left
2871
                       (fun sep  ->
2872
                          fun x  ->
2873
                            if sep then Format.fprintf fmt ";@ ";
2874
                            ((__11 ()) fmt) x;
2875
                            true) false x);
2876
                  Format.fprintf fmt "@,]@]")) abranches;
2877
              Format.fprintf fmt "@]");
2878
             Format.fprintf fmt "@]}")
2879
        | Exit
2880
            { label = alabel; loop_label = aloop_label;
2881
              condition = acondition }
2882
            ->
2883
            (Format.fprintf fmt "@[<2>Exit {@,";
2884
             (((Format.fprintf fmt "@[%s =@ " "label";
2885
                ((__12 ()) fmt) alabel;
2886
                Format.fprintf fmt "@]");
2887
               Format.fprintf fmt ";@ ";
2888
               Format.fprintf fmt "@[%s =@ " "loop_label";
2889
               ((function
2890
                 | None  -> Format.pp_print_string fmt "None"
2891
                 | Some x ->
2892
                     (Format.pp_print_string fmt "(Some ";
2893
                      (Format.fprintf fmt "%S") x;
2894
                      Format.pp_print_string fmt ")"))) aloop_label;
2895
               Format.fprintf fmt "@]");
2896
              Format.fprintf fmt ";@ ";
2897
              Format.fprintf fmt "@[%s =@ " "condition";
2898
              ((function
2899
                | None  -> Format.pp_print_string fmt "None"
2900
                | Some x ->
2901
                    (Format.pp_print_string fmt "(Some ";
2902
                     ((__13 ()) fmt) x;
2903
                     Format.pp_print_string fmt ")"))) acondition;
2904
              Format.fprintf fmt "@]");
2905
             Format.fprintf fmt "@]}")
2906
        | Assert
2907
            { label = alabel; cond = acond; report = areport;
2908
              severity = aseverity }
2909
            ->
2910
            (Format.fprintf fmt "@[<2>Assert {@,";
2911
             ((((Format.fprintf fmt "@[%s =@ " "label";
2912
                 ((__14 ()) fmt) alabel;
2913
                 Format.fprintf fmt "@]");
2914
                Format.fprintf fmt ";@ ";
2915
                Format.fprintf fmt "@[%s =@ " "cond";
2916
                ((__15 ()) fmt) acond;
2917
                Format.fprintf fmt "@]");
2918
               Format.fprintf fmt ";@ ";
2919
               Format.fprintf fmt "@[%s =@ " "report";
2920
               ((__16 ()) fmt) areport;
2921
               Format.fprintf fmt "@]");
2922
              Format.fprintf fmt ";@ ";
2923
              Format.fprintf fmt "@[%s =@ " "severity";
2924
              ((__17 ()) fmt) aseverity;
2925
              Format.fprintf fmt "@]");
2926
             Format.fprintf fmt "@]}")
2927
        | Wait  -> Format.pp_print_string fmt "Wait"
2928
        | Null { label = alabel } ->
2929
            (Format.fprintf fmt "@[<2>Null {@,";
2930
             (Format.fprintf fmt "@[%s =@ " "label";
2931
              ((__18 ()) fmt) alabel;
2932
              Format.fprintf fmt "@]");
2933
             Format.fprintf fmt "@]}")
2934
        | Return { label = alabel } ->
2935
            (Format.fprintf fmt "@[<2>Return {@,";
2936
             (Format.fprintf fmt "@[%s =@ " "label";
2937
              ((__19 ()) fmt) alabel;
2938
              Format.fprintf fmt "@]");
2939
             Format.fprintf fmt "@]}"))
2940
    [@ocaml.warning "-A"])
2941

    
2942
and show_vhdl_sequential_stmt_t :
2943
  vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string =
2944
  fun x  -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x
2945

    
2946
and pp_vhdl_if_case_t :
2947
  Format.formatter -> vhdl_if_case_t -> Ppx_deriving_runtime.unit =
2948
  let __1 () = pp_vhdl_sequential_stmt_t
2949
  
2950
  and __0 () = pp_vhdl_expr_t
2951
   in
2952
  ((let open! Ppx_deriving_runtime in
2953
      fun fmt  ->
2954
        fun x  ->
2955
          Format.fprintf fmt "@[<2>{ ";
2956
          ((Format.fprintf fmt "@[%s =@ " "if_cond";
2957
            ((__0 ()) fmt) x.if_cond;
2958
            Format.fprintf fmt "@]");
2959
           Format.fprintf fmt ";@ ";
2960
           Format.fprintf fmt "@[%s =@ " "if_block";
2961
           ((fun x  ->
2962
               Format.fprintf fmt "@[<2>[";
2963
               ignore
2964
                 (List.fold_left
2965
                    (fun sep  ->
2966
                       fun x  ->
2967
                         if sep then Format.fprintf fmt ";@ ";
2968
                         ((__1 ()) fmt) x;
2969
                         true) false x);
2970
               Format.fprintf fmt "@,]@]")) x.if_block;
2971
           Format.fprintf fmt "@]");
2972
          Format.fprintf fmt "@ }@]")
2973
    [@ocaml.warning "-A"])
2974

    
2975
and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string =
2976
  fun x  -> Format.asprintf "%a" pp_vhdl_if_case_t x
2977

    
2978
and pp_vhdl_case_item_t :
2979
  Format.formatter -> vhdl_case_item_t -> Ppx_deriving_runtime.unit =
2980
  let __1 () = pp_vhdl_sequential_stmt_t
2981
  
2982
  and __0 () = pp_vhdl_expr_t
2983
   in
2984
  ((let open! Ppx_deriving_runtime in
2985
      fun fmt  ->
2986
        fun x  ->
2987
          Format.fprintf fmt "@[<2>{ ";
2988
          ((Format.fprintf fmt "@[%s =@ " "when_cond";
2989
            ((fun x  ->
2990
                Format.fprintf fmt "@[<2>[";
2991
                ignore
2992
                  (List.fold_left
2993
                     (fun sep  ->
2994
                        fun x  ->
2995
                          if sep then Format.fprintf fmt ";@ ";
2996
                          ((__0 ()) fmt) x;
2997
                          true) false x);
2998
                Format.fprintf fmt "@,]@]")) x.when_cond;
2999
            Format.fprintf fmt "@]");
3000
           Format.fprintf fmt ";@ ";
3001
           Format.fprintf fmt "@[%s =@ " "when_stmt";
3002
           ((fun x  ->
3003
               Format.fprintf fmt "@[<2>[";
3004
               ignore
3005
                 (List.fold_left
3006
                    (fun sep  ->
3007
                       fun x  ->
3008
                         if sep then Format.fprintf fmt ";@ ";
3009
                         ((__1 ()) fmt) x;
3010
                         true) false x);
3011
               Format.fprintf fmt "@,]@]")) x.when_stmt;
3012
           Format.fprintf fmt "@]");
3013
          Format.fprintf fmt "@ }@]")
3014
    [@ocaml.warning "-A"])
3015

    
3016
and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string =
3017
  fun x  -> Format.asprintf "%a" pp_vhdl_case_item_t x
3018

    
3019
let rec (vhdl_sequential_stmt_t_to_yojson :
3020
          vhdl_sequential_stmt_t -> Yojson.Safe.json)
3021
  =
3022
  ((let open! Ppx_deriving_yojson_runtime in
3023
      function
3024
      | VarAssign arg0 ->
3025
          `List
3026
            [`String "VARIABLE_ASSIGNMENT_STATEMENT";
3027
            (let fields = []  in
3028
             let fields =
3029
               ("rhs", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.rhs)) ::
3030
               fields  in
3031
             let fields =
3032
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
3033
               fields  in
3034
             let fields =
3035
               if arg0.label = NoName
3036
               then fields
3037
               else
3038
                 ("label",
3039
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3040
                 :: fields
3041
                in
3042
             `Assoc fields)]
3043
      | SigSeqAssign arg0 ->
3044
          `List
3045
            [`String "SIGNAL_ASSIGNMENT_STATEMENT";
3046
            (let fields = []  in
3047
             let fields =
3048
               ("rhs",
3049
                 ((fun x  ->
3050
                     `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
3051
                    arg0.rhs))
3052
               :: fields  in
3053
             let fields =
3054
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
3055
               fields  in
3056
             let fields =
3057
               if arg0.label = NoName
3058
               then fields
3059
               else
3060
                 ("label",
3061
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3062
                 :: fields
3063
                in
3064
             `Assoc fields)]
3065
      | If arg0 ->
3066
          `List
3067
            [`String "IF_STATEMENT";
3068
            (let fields = []  in
3069
             let fields =
3070
               if arg0.default = []
3071
               then fields
3072
               else
3073
                 ("default",
3074
                   (((fun x  ->
3075
                        `List
3076
                          (List.map
3077
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
3078
                      arg0.default))
3079
                 :: fields
3080
                in
3081
             let fields =
3082
               ("if_cases",
3083
                 ((fun x  ->
3084
                     `List
3085
                       (List.map (fun x  -> vhdl_if_case_t_to_yojson x) x))
3086
                    arg0.if_cases))
3087
               :: fields  in
3088
             let fields =
3089
               if arg0.label = NoName
3090
               then fields
3091
               else
3092
                 ("label",
3093
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3094
                 :: fields
3095
                in
3096
             `Assoc fields)]
3097
      | Case arg0 ->
3098
          `List
3099
            [`String "CASE_STATEMENT_TREE";
3100
            (let fields = []  in
3101
             let fields =
3102
               ("branches",
3103
                 ((fun x  ->
3104
                     `List
3105
                       (List.map (fun x  -> vhdl_case_item_t_to_yojson x) x))
3106
                    arg0.branches))
3107
               :: fields  in
3108
             let fields =
3109
               ("guard", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.guard)) ::
3110
               fields  in
3111
             let fields =
3112
               if arg0.label = NoName
3113
               then fields
3114
               else
3115
                 ("label",
3116
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3117
                 :: fields
3118
                in
3119
             `Assoc fields)]
3120
      | Exit arg0 ->
3121
          `List
3122
            [`String "EXIT_STATEMENT";
3123
            (let fields = []  in
3124
             let fields =
3125
               if arg0.condition = (Some IsNull)
3126
               then fields
3127
               else
3128
                 ("condition",
3129
                   (((function
3130
                      | None  -> `Null
3131
                      | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
3132
                      arg0.condition))
3133
                 :: fields
3134
                in
3135
             let fields =
3136
               if arg0.loop_label = (Some "")
3137
               then fields
3138
               else
3139
                 ("loop_label",
3140
                   (((function
3141
                      | None  -> `Null
3142
                      | Some x ->
3143
                          ((fun (x : Ppx_deriving_runtime.string)  ->
3144
                              `String x)) x)) arg0.loop_label))
3145
                 :: fields
3146
                in
3147
             let fields =
3148
               if arg0.label = NoName
3149
               then fields
3150
               else
3151
                 ("label",
3152
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3153
                 :: fields
3154
                in
3155
             `Assoc fields)]
3156
      | Assert arg0 ->
3157
          `List
3158
            [`String "ASSERTION_STATEMENT";
3159
            (let fields = []  in
3160
             let fields =
3161
               if arg0.severity = IsNull
3162
               then fields
3163
               else
3164
                 ("severity",
3165
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.severity))
3166
                 :: fields
3167
                in
3168
             let fields =
3169
               if arg0.report = IsNull
3170
               then fields
3171
               else
3172
                 ("report",
3173
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.report))
3174
                 :: fields
3175
                in
3176
             let fields =
3177
               ("cond", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.cond)) ::
3178
               fields  in
3179
             let fields =
3180
               if arg0.label = NoName
3181
               then fields
3182
               else
3183
                 ("label",
3184
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3185
                 :: fields
3186
                in
3187
             `Assoc fields)]
3188
      | Wait  -> `List [`String "WAIT_STATEMENT"]
3189
      | Null arg0 ->
3190
          `List
3191
            [`String "NULL_STATEMENT";
3192
            (let 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
      | Return arg0 ->
3203
          `List
3204
            [`String "RETURN_STATEMENT";
3205
            (let fields = []  in
3206
             let fields =
3207
               if arg0.label = NoName
3208
               then fields
3209
               else
3210
                 ("label",
3211
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3212
                 :: fields
3213
                in
3214
             `Assoc fields)])
3215
  [@ocaml.warning "-A"])
3216

    
3217
and (vhdl_sequential_stmt_t_of_yojson :
3218
      Yojson.Safe.json ->
3219
        vhdl_sequential_stmt_t Ppx_deriving_yojson_runtime.error_or)
3220
  =
3221
  ((let open! Ppx_deriving_yojson_runtime in
3222
      function
3223
      | `List ((`String "VARIABLE_ASSIGNMENT_STATEMENT")::arg0::[]) ->
3224
          ((function
3225
            | `Assoc xs ->
3226
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3227
                  match xs with
3228
                  | ("label",x)::xs ->
3229
                      loop xs
3230
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3231
                  | ("lhs",x)::xs ->
3232
                      loop xs
3233
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3234
                  | ("rhs",x)::xs ->
3235
                      loop xs
3236
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
3237
                  | [] ->
3238
                      arg2 >>=
3239
                        ((fun arg2  ->
3240
                            arg1 >>=
3241
                              (fun arg1  ->
3242
                                 arg0 >>=
3243
                                   (fun arg0  ->
3244
                                      Result.Ok
3245
                                        (VarAssign
3246
                                           {
3247
                                             label = arg0;
3248
                                             lhs = arg1;
3249
                                             rhs = arg2
3250
                                           })))))
3251
                  | _::xs -> loop xs _state  in
3252
                loop xs
3253
                  ((Result.Ok NoName),
3254
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
3255
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
3256
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3257
      | `List ((`String "SIGNAL_ASSIGNMENT_STATEMENT")::arg0::[]) ->
3258
          ((function
3259
            | `Assoc xs ->
3260
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3261
                  match xs with
3262
                  | ("label",x)::xs ->
3263
                      loop xs
3264
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3265
                  | ("lhs",x)::xs ->
3266
                      loop xs
3267
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3268
                  | ("rhs",x)::xs ->
3269
                      loop xs
3270
                        (arg0, arg1,
3271
                          ((function
3272
                            | `List xs ->
3273
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
3274
                                  [] xs
3275
                            | _ ->
3276
                                Result.Error
3277
                                  "Vhdl_ast.vhdl_sequential_stmt_t.rhs") x))
3278
                  | [] ->
3279
                      arg2 >>=
3280
                        ((fun arg2  ->
3281
                            arg1 >>=
3282
                              (fun arg1  ->
3283
                                 arg0 >>=
3284
                                   (fun arg0  ->
3285
                                      Result.Ok
3286
                                        (SigSeqAssign
3287
                                           {
3288
                                             label = arg0;
3289
                                             lhs = arg1;
3290
                                             rhs = arg2
3291
                                           })))))
3292
                  | _::xs -> loop xs _state  in
3293
                loop xs
3294
                  ((Result.Ok NoName),
3295
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
3296
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
3297
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3298
      | `List ((`String "IF_STATEMENT")::arg0::[]) ->
3299
          ((function
3300
            | `Assoc xs ->
3301
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3302
                  match xs with
3303
                  | ("label",x)::xs ->
3304
                      loop xs
3305
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3306
                  | ("if_cases",x)::xs ->
3307
                      loop xs
3308
                        (arg0,
3309
                          ((function
3310
                            | `List xs ->
3311
                                map_bind
3312
                                  (fun x  -> vhdl_if_case_t_of_yojson x) []
3313
                                  xs
3314
                            | _ ->
3315
                                Result.Error
3316
                                  "Vhdl_ast.vhdl_sequential_stmt_t.if_cases")
3317
                             x), arg2)
3318
                  | ("default",x)::xs ->
3319
                      loop xs
3320
                        (arg0, arg1,
3321
                          ((function
3322
                            | `List xs ->
3323
                                map_bind
3324
                                  (fun x  ->
3325
                                     vhdl_sequential_stmt_t_of_yojson x) []
3326
                                  xs
3327
                            | _ ->
3328
                                Result.Error
3329
                                  "Vhdl_ast.vhdl_sequential_stmt_t.default")
3330
                             x))
3331
                  | [] ->
3332
                      arg2 >>=
3333
                        ((fun arg2  ->
3334
                            arg1 >>=
3335
                              (fun arg1  ->
3336
                                 arg0 >>=
3337
                                   (fun arg0  ->
3338
                                      Result.Ok
3339
                                        (If
3340
                                           {
3341
                                             label = arg0;
3342
                                             if_cases = arg1;
3343
                                             default = arg2
3344
                                           })))))
3345
                  | _::xs -> loop xs _state  in
3346
                loop xs
3347
                  ((Result.Ok NoName),
3348
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.if_cases"),
3349
                    (Result.Ok []))
3350
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3351
      | `List ((`String "CASE_STATEMENT_TREE")::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
                  | ("guard",x)::xs ->
3360
                      loop xs
3361
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
3362
                  | ("branches",x)::xs ->
3363
                      loop xs
3364
                        (arg0, arg1,
3365
                          ((function
3366
                            | `List xs ->
3367
                                map_bind
3368
                                  (fun x  -> vhdl_case_item_t_of_yojson x) []
3369
                                  xs
3370
                            | _ ->
3371
                                Result.Error
3372
                                  "Vhdl_ast.vhdl_sequential_stmt_t.branches")
3373
                             x))
3374
                  | [] ->
3375
                      arg2 >>=
3376
                        ((fun arg2  ->
3377
                            arg1 >>=
3378
                              (fun arg1  ->
3379
                                 arg0 >>=
3380
                                   (fun arg0  ->
3381
                                      Result.Ok
3382
                                        (Case
3383
                                           {
3384
                                             label = arg0;
3385
                                             guard = arg1;
3386
                                             branches = arg2
3387
                                           })))))
3388
                  | _::xs -> loop xs _state  in
3389
                loop xs
3390
                  ((Result.Ok NoName),
3391
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.guard"),
3392
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.branches"))
3393
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3394
      | `List ((`String "EXIT_STATEMENT")::arg0::[]) ->
3395
          ((function
3396
            | `Assoc xs ->
3397
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3398
                  match xs with
3399
                  | ("label",x)::xs ->
3400
                      loop xs
3401
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3402
                  | ("loop_label",x)::xs ->
3403
                      loop xs
3404
                        (arg0,
3405
                          ((function
3406
                            | `Null -> Result.Ok None
3407
                            | x ->
3408
                                ((function
3409
                                  | `String x -> Result.Ok x
3410
                                  | _ ->
3411
                                      Result.Error
3412
                                        "Vhdl_ast.vhdl_sequential_stmt_t.loop_label")
3413
                                   x)
3414
                                  >>= ((fun x  -> Result.Ok (Some x)))) x),
3415
                          arg2)
3416
                  | ("condition",x)::xs ->
3417
                      loop xs
3418
                        (arg0, arg1,
3419
                          ((function
3420
                            | `Null -> Result.Ok None
3421
                            | x ->
3422
                                ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
3423
                                  ((fun x  -> Result.Ok (Some x)))) x))
3424
                  | [] ->
3425
                      arg2 >>=
3426
                        ((fun arg2  ->
3427
                            arg1 >>=
3428
                              (fun arg1  ->
3429
                                 arg0 >>=
3430
                                   (fun arg0  ->
3431
                                      Result.Ok
3432
                                        (Exit
3433
                                           {
3434
                                             label = arg0;
3435
                                             loop_label = arg1;
3436
                                             condition = arg2
3437
                                           })))))
3438
                  | _::xs -> loop xs _state  in
3439
                loop xs
3440
                  ((Result.Ok NoName), (Result.Ok (Some "")),
3441
                    (Result.Ok (Some IsNull)))
3442
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3443
      | `List ((`String "ASSERTION_STATEMENT")::arg0::[]) ->
3444
          ((function
3445
            | `Assoc xs ->
3446
                let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
3447
                  match xs with
3448
                  | ("label",x)::xs ->
3449
                      loop xs
3450
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2,
3451
                          arg3)
3452
                  | ("cond",x)::xs ->
3453
                      loop xs
3454
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2,
3455
                          arg3)
3456
                  | ("report",x)::xs ->
3457
                      loop xs
3458
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x),
3459
                          arg3)
3460
                  | ("severity",x)::xs ->
3461
                      loop xs
3462
                        (arg0, arg1, arg2,
3463
                          ((fun x  -> vhdl_expr_t_of_yojson x) x))
3464
                  | [] ->
3465
                      arg3 >>=
3466
                        ((fun arg3  ->
3467
                            arg2 >>=
3468
                              (fun arg2  ->
3469
                                 arg1 >>=
3470
                                   (fun arg1  ->
3471
                                      arg0 >>=
3472
                                        (fun arg0  ->
3473
                                           Result.Ok
3474
                                             (Assert
3475
                                                {
3476
                                                  label = arg0;
3477
                                                  cond = arg1;
3478
                                                  report = arg2;
3479
                                                  severity = arg3
3480
                                                }))))))
3481
                  | _::xs -> loop xs _state  in
3482
                loop xs
3483
                  ((Result.Ok NoName),
3484
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.cond"),
3485
                    (Result.Ok IsNull), (Result.Ok IsNull))
3486
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3487
      | `List ((`String "WAIT_STATEMENT")::[]) -> Result.Ok Wait
3488
      | `List ((`String "NULL_STATEMENT")::arg0::[]) ->
3489
          ((function
3490
            | `Assoc xs ->
3491
                let rec loop xs (arg0 as _state) =
3492
                  match xs with
3493
                  | ("label",x)::xs ->
3494
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
3495
                  | [] ->
3496
                      arg0 >>=
3497
                        ((fun arg0  -> Result.Ok (Null { label = arg0 })))
3498
                  | _::xs -> loop xs _state  in
3499
                loop xs (Result.Ok NoName)
3500
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3501
      | `List ((`String "RETURN_STATEMENT")::arg0::[]) ->
3502
          ((function
3503
            | `Assoc xs ->
3504
                let rec loop xs (arg0 as _state) =
3505
                  match xs with
3506
                  | ("label",x)::xs ->
3507
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
3508
                  | [] ->
3509
                      arg0 >>=
3510
                        ((fun arg0  -> Result.Ok (Return { label = arg0 })))
3511
                  | _::xs -> loop xs _state  in
3512
                loop xs (Result.Ok NoName)
3513
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3514
      | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")
3515
  [@ocaml.warning "-A"])
3516

    
3517
and (vhdl_if_case_t_to_yojson : vhdl_if_case_t -> Yojson.Safe.json) =
3518
  ((let open! Ppx_deriving_yojson_runtime in
3519
      fun x  ->
3520
        let fields = []  in
3521
        let fields =
3522
          ("if_block",
3523
            ((fun x  ->
3524
                `List
3525
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3526
               x.if_block))
3527
          :: fields  in
3528
        let fields =
3529
          ("if_cond", ((fun x  -> vhdl_expr_t_to_yojson x) x.if_cond)) ::
3530
          fields  in
3531
        `Assoc fields)
3532
  [@ocaml.warning "-A"])
3533

    
3534
and (vhdl_if_case_t_of_yojson :
3535
      Yojson.Safe.json -> vhdl_if_case_t Ppx_deriving_yojson_runtime.error_or)
3536
  =
3537
  ((let open! Ppx_deriving_yojson_runtime in
3538
      function
3539
      | `Assoc xs ->
3540
          let rec loop xs ((arg0,arg1) as _state) =
3541
            match xs with
3542
            | ("if_cond",x)::xs ->
3543
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
3544
            | ("if_block",x)::xs ->
3545
                loop xs
3546
                  (arg0,
3547
                    ((function
3548
                      | `List xs ->
3549
                          map_bind
3550
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3551
                            xs
3552
                      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t.if_block")
3553
                       x))
3554
            | [] ->
3555
                arg1 >>=
3556
                  ((fun arg1  ->
3557
                      arg0 >>=
3558
                        (fun arg0  ->
3559
                           Result.Ok { if_cond = arg0; if_block = arg1 })))
3560
            | _::xs -> loop xs _state  in
3561
          loop xs
3562
            ((Result.Error "Vhdl_ast.vhdl_if_case_t.if_cond"),
3563
              (Result.Error "Vhdl_ast.vhdl_if_case_t.if_block"))
3564
      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t")
3565
  [@ocaml.warning "-A"])
3566

    
3567
and (vhdl_case_item_t_to_yojson : vhdl_case_item_t -> Yojson.Safe.json) =
3568
  ((let open! Ppx_deriving_yojson_runtime in
3569
      fun x  ->
3570
        let fields = []  in
3571
        let fields =
3572
          ("when_stmt",
3573
            ((fun x  ->
3574
                `List
3575
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3576
               x.when_stmt))
3577
          :: fields  in
3578
        let fields =
3579
          ("when_cond",
3580
            ((fun x  ->
3581
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
3582
               x.when_cond))
3583
          :: fields  in
3584
        `Assoc fields)
3585
  [@ocaml.warning "-A"])
3586

    
3587
and (vhdl_case_item_t_of_yojson :
3588
      Yojson.Safe.json ->
3589
        vhdl_case_item_t Ppx_deriving_yojson_runtime.error_or)
3590
  =
3591
  ((let open! Ppx_deriving_yojson_runtime in
3592
      function
3593
      | `Assoc xs ->
3594
          let rec loop xs ((arg0,arg1) as _state) =
3595
            match xs with
3596
            | ("when_cond",x)::xs ->
3597
                loop xs
3598
                  (((function
3599
                     | `List xs ->
3600
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
3601
                     | _ ->
3602
                         Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond")
3603
                      x), arg1)
3604
            | ("when_stmt",x)::xs ->
3605
                loop xs
3606
                  (arg0,
3607
                    ((function
3608
                      | `List xs ->
3609
                          map_bind
3610
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3611
                            xs
3612
                      | _ ->
3613
                          Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt")
3614
                       x))
3615
            | [] ->
3616
                arg1 >>=
3617
                  ((fun arg1  ->
3618
                      arg0 >>=
3619
                        (fun arg0  ->
3620
                           Result.Ok { when_cond = arg0; when_stmt = arg1 })))
3621
            | _::xs -> loop xs _state  in
3622
          loop xs
3623
            ((Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond"),
3624
              (Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt"))
3625
      | _ -> Result.Error "Vhdl_ast.vhdl_case_item_t")
3626
  [@ocaml.warning "-A"])
3627

    
3628
type vhdl_declaration_t =
3629
  | VarDecl of
3630
  {
3631
  names: vhdl_name_t list ;
3632
  typ: vhdl_subtype_indication_t ;
3633
  init_val: vhdl_cst_val_t option [@default Some (CstInt 0)]}
3634
  [@name "VARIABLE_DECLARATION"]
3635
  | CstDecl of
3636
  {
3637
  names: vhdl_name_t list ;
3638
  typ: vhdl_subtype_indication_t ;
3639
  init_val: vhdl_cst_val_t } [@name "CONSTANT_DECLARATION"]
3640
  | SigDecl of
3641
  {
3642
  names: vhdl_name_t list ;
3643
  typ: vhdl_subtype_indication_t ;
3644
  init_val: vhdl_cst_val_t option [@default Some (CstInt 0)]}
3645
  [@name "SIGNAL_DECLARATION"]
3646
  | Subprogram of
3647
  {
3648
  name: vhdl_name_t [@default NoName];
3649
  kind: string [@default ""];
3650
  spec: vhdl_subprogram_spec_t
3651
    [@default
3652
      { name = ""; typeMark = NoName; parameters = []; isPure = false }];
3653
  decl_part: vhdl_declaration_t list [@default []];
3654
  stmts: vhdl_sequential_stmt_t list [@default []]} [@name "SUBPROGRAM_BODY"]
3655

    
3656
let rec pp_vhdl_declaration_t :
3657
  Format.formatter -> vhdl_declaration_t -> Ppx_deriving_runtime.unit =
3658
  let __12 () = pp_vhdl_sequential_stmt_t
3659
  
3660
  and __11 () = pp_vhdl_declaration_t
3661
  
3662
  and __10 () = pp_vhdl_subprogram_spec_t
3663
  
3664
  and __9 () = pp_vhdl_name_t
3665
  
3666
  and __8 () = pp_vhdl_cst_val_t
3667
  
3668
  and __7 () = pp_vhdl_subtype_indication_t
3669
  
3670
  and __6 () = pp_vhdl_name_t
3671
  
3672
  and __5 () = pp_vhdl_cst_val_t
3673
  
3674
  and __4 () = pp_vhdl_subtype_indication_t
3675
  
3676
  and __3 () = pp_vhdl_name_t
3677
  
3678
  and __2 () = pp_vhdl_cst_val_t
3679
  
3680
  and __1 () = pp_vhdl_subtype_indication_t
3681
  
3682
  and __0 () = pp_vhdl_name_t
3683
   in
3684
  ((let open! Ppx_deriving_runtime in
3685
      fun fmt  ->
3686
        function
3687
        | VarDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3688
            (Format.fprintf fmt "@[<2>VarDecl {@,";
3689
             (((Format.fprintf fmt "@[%s =@ " "names";
3690
                ((fun x  ->
3691
                    Format.fprintf fmt "@[<2>[";
3692
                    ignore
3693
                      (List.fold_left
3694
                         (fun sep  ->
3695
                            fun x  ->
3696
                              if sep then Format.fprintf fmt ";@ ";
3697
                              ((__0 ()) fmt) x;
3698
                              true) false x);
3699
                    Format.fprintf fmt "@,]@]")) anames;
3700
                Format.fprintf fmt "@]");
3701
               Format.fprintf fmt ";@ ";
3702
               Format.fprintf fmt "@[%s =@ " "typ";
3703
               ((__1 ()) fmt) atyp;
3704
               Format.fprintf fmt "@]");
3705
              Format.fprintf fmt ";@ ";
3706
              Format.fprintf fmt "@[%s =@ " "init_val";
3707
              ((function
3708
                | None  -> Format.pp_print_string fmt "None"
3709
                | Some x ->
3710
                    (Format.pp_print_string fmt "(Some ";
3711
                     ((__2 ()) fmt) x;
3712
                     Format.pp_print_string fmt ")"))) ainit_val;
3713
              Format.fprintf fmt "@]");
3714
             Format.fprintf fmt "@]}")
3715
        | CstDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3716
            (Format.fprintf fmt "@[<2>CstDecl {@,";
3717
             (((Format.fprintf fmt "@[%s =@ " "names";
3718
                ((fun x  ->
3719
                    Format.fprintf fmt "@[<2>[";
3720
                    ignore
3721
                      (List.fold_left
3722
                         (fun sep  ->
3723
                            fun x  ->
3724
                              if sep then Format.fprintf fmt ";@ ";
3725
                              ((__3 ()) fmt) x;
3726
                              true) false x);
3727
                    Format.fprintf fmt "@,]@]")) anames;
3728
                Format.fprintf fmt "@]");
3729
               Format.fprintf fmt ";@ ";
3730
               Format.fprintf fmt "@[%s =@ " "typ";
3731
               ((__4 ()) fmt) atyp;
3732
               Format.fprintf fmt "@]");
3733
              Format.fprintf fmt ";@ ";
3734
              Format.fprintf fmt "@[%s =@ " "init_val";
3735
              ((__5 ()) fmt) ainit_val;
3736
              Format.fprintf fmt "@]");
3737
             Format.fprintf fmt "@]}")
3738
        | SigDecl { names = anames; typ = atyp; init_val = ainit_val } ->
3739
            (Format.fprintf fmt "@[<2>SigDecl {@,";
3740
             (((Format.fprintf fmt "@[%s =@ " "names";
3741
                ((fun x  ->
3742
                    Format.fprintf fmt "@[<2>[";
3743
                    ignore
3744
                      (List.fold_left
3745
                         (fun sep  ->
3746
                            fun x  ->
3747
                              if sep then Format.fprintf fmt ";@ ";
3748
                              ((__6 ()) fmt) x;
3749
                              true) false x);
3750
                    Format.fprintf fmt "@,]@]")) anames;
3751
                Format.fprintf fmt "@]");
3752
               Format.fprintf fmt ";@ ";
3753
               Format.fprintf fmt "@[%s =@ " "typ";
3754
               ((__7 ()) fmt) atyp;
3755
               Format.fprintf fmt "@]");
3756
              Format.fprintf fmt ";@ ";
3757
              Format.fprintf fmt "@[%s =@ " "init_val";
3758
              ((function
3759
                | None  -> Format.pp_print_string fmt "None"
3760
                | Some x ->
3761
                    (Format.pp_print_string fmt "(Some ";
3762
                     ((__8 ()) fmt) x;
3763
                     Format.pp_print_string fmt ")"))) ainit_val;
3764
              Format.fprintf fmt "@]");
3765
             Format.fprintf fmt "@]}")
3766
        | Subprogram
3767
            { name = aname; kind = akind; spec = aspec;
3768
              decl_part = adecl_part; stmts = astmts }
3769
            ->
3770
            (Format.fprintf fmt "@[<2>Subprogram {@,";
3771
             (((((Format.fprintf fmt "@[%s =@ " "name";
3772
                  ((__9 ()) fmt) aname;
3773
                  Format.fprintf fmt "@]");
3774
                 Format.fprintf fmt ";@ ";
3775
                 Format.fprintf fmt "@[%s =@ " "kind";
3776
                 (Format.fprintf fmt "%S") akind;
3777
                 Format.fprintf fmt "@]");
3778
                Format.fprintf fmt ";@ ";
3779
                Format.fprintf fmt "@[%s =@ " "spec";
3780
                ((__10 ()) fmt) aspec;
3781
                Format.fprintf fmt "@]");
3782
               Format.fprintf fmt ";@ ";
3783
               Format.fprintf fmt "@[%s =@ " "decl_part";
3784
               ((fun x  ->
3785
                   Format.fprintf fmt "@[<2>[";
3786
                   ignore
3787
                     (List.fold_left
3788
                        (fun sep  ->
3789
                           fun x  ->
3790
                             if sep then Format.fprintf fmt ";@ ";
3791
                             ((__11 ()) fmt) x;
3792
                             true) false x);
3793
                   Format.fprintf fmt "@,]@]")) adecl_part;
3794
               Format.fprintf fmt "@]");
3795
              Format.fprintf fmt ";@ ";
3796
              Format.fprintf fmt "@[%s =@ " "stmts";
3797
              ((fun x  ->
3798
                  Format.fprintf fmt "@[<2>[";
3799
                  ignore
3800
                    (List.fold_left
3801
                       (fun sep  ->
3802
                          fun x  ->
3803
                            if sep then Format.fprintf fmt ";@ ";
3804
                            ((__12 ()) fmt) x;
3805
                            true) false x);
3806
                  Format.fprintf fmt "@,]@]")) astmts;
3807
              Format.fprintf fmt "@]");
3808
             Format.fprintf fmt "@]}"))
3809
    [@ocaml.warning "-A"])
3810

    
3811
and show_vhdl_declaration_t :
3812
  vhdl_declaration_t -> Ppx_deriving_runtime.string =
3813
  fun x  -> Format.asprintf "%a" pp_vhdl_declaration_t x
3814

    
3815
let rec (vhdl_declaration_t_to_yojson :
3816
          vhdl_declaration_t -> Yojson.Safe.json)
3817
  =
3818
  ((let open! Ppx_deriving_yojson_runtime in
3819
      function
3820
      | VarDecl arg0 ->
3821
          `List
3822
            [`String "VARIABLE_DECLARATION";
3823
            (let fields = []  in
3824
             let fields =
3825
               if arg0.init_val = (Some (CstInt 0))
3826
               then fields
3827
               else
3828
                 ("init_val",
3829
                   (((function
3830
                      | None  -> `Null
3831
                      | Some x -> ((fun x  -> vhdl_cst_val_t_to_yojson x)) x))
3832
                      arg0.init_val))
3833
                 :: fields
3834
                in
3835
             let fields =
3836
               ("typ",
3837
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
3838
               :: fields  in
3839
             let fields =
3840
               ("names",
3841
                 ((fun x  ->
3842
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
3843
                    arg0.names))
3844
               :: fields  in
3845
             `Assoc fields)]
3846
      | CstDecl arg0 ->
3847
          `List
3848
            [`String "CONSTANT_DECLARATION";
3849
            (let fields = []  in
3850
             let fields =
3851
               ("init_val",
3852
                 ((fun x  -> vhdl_cst_val_t_to_yojson x) arg0.init_val))
3853
               :: fields  in
3854
             let fields =
3855
               ("typ",
3856
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
3857
               :: fields  in
3858
             let fields =
3859
               ("names",
3860
                 ((fun x  ->
3861
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
3862
                    arg0.names))
3863
               :: fields  in
3864
             `Assoc fields)]
3865
      | SigDecl arg0 ->
3866
          `List
3867
            [`String "SIGNAL_DECLARATION";
3868
            (let fields = []  in
3869
             let fields =
3870
               if arg0.init_val = (Some (CstInt 0))
3871
               then fields
3872
               else
3873
                 ("init_val",
3874
                   (((function
3875
                      | None  -> `Null
3876
                      | Some x -> ((fun x  -> vhdl_cst_val_t_to_yojson x)) x))
3877
                      arg0.init_val))
3878
                 :: fields
3879
                in
3880
             let fields =
3881
               ("typ",
3882
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
3883
               :: fields  in
3884
             let fields =
3885
               ("names",
3886
                 ((fun x  ->
3887
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
3888
                    arg0.names))
3889
               :: fields  in
3890
             `Assoc fields)]
3891
      | Subprogram arg0 ->
3892
          `List
3893
            [`String "SUBPROGRAM_BODY";
3894
            (let fields = []  in
3895
             let fields =
3896
               if arg0.stmts = []
3897
               then fields
3898
               else
3899
                 ("stmts",
3900
                   (((fun x  ->
3901
                        `List
3902
                          (List.map
3903
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
3904
                      arg0.stmts))
3905
                 :: fields
3906
                in
3907
             let fields =
3908
               if arg0.decl_part = []
3909
               then fields
3910
               else
3911
                 ("decl_part",
3912
                   (((fun x  ->
3913
                        `List
3914
                          (List.map
3915
                             (fun x  -> vhdl_declaration_t_to_yojson x) x)))
3916
                      arg0.decl_part))
3917
                 :: fields
3918
                in
3919
             let fields =
3920
               if
3921
                 arg0.spec =
3922
                   {
3923
                     name = "";
3924
                     typeMark = NoName;
3925
                     parameters = [];
3926
                     isPure = false
3927
                   }
3928
               then fields
3929
               else
3930
                 ("spec",
3931
                   (((fun x  -> vhdl_subprogram_spec_t_to_yojson x))
3932
                      arg0.spec))
3933
                 :: fields
3934
                in
3935
             let fields =
3936
               if arg0.kind = ""
3937
               then fields
3938
               else
3939
                 ("kind",
3940
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
3941
                      arg0.kind))
3942
                 :: fields
3943
                in
3944
             let fields =
3945
               if arg0.name = NoName
3946
               then fields
3947
               else
3948
                 ("name", (((fun x  -> vhdl_name_t_to_yojson x)) arg0.name))
3949
                 :: fields
3950
                in
3951
             `Assoc fields)])
3952
  [@ocaml.warning "-A"])
3953

    
3954
and (vhdl_declaration_t_of_yojson :
3955
      Yojson.Safe.json ->
3956
        vhdl_declaration_t Ppx_deriving_yojson_runtime.error_or)
3957
  =
3958
  ((let open! Ppx_deriving_yojson_runtime in
3959
      function
3960
      | `List ((`String "VARIABLE_DECLARATION")::arg0::[]) ->
3961
          ((function
3962
            | `Assoc xs ->
3963
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3964
                  match xs with
3965
                  | ("names",x)::xs ->
3966
                      loop xs
3967
                        (((function
3968
                           | `List xs ->
3969
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
3970
                                 [] xs
3971
                           | _ ->
3972
                               Result.Error
3973
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
3974
                          arg1, arg2)
3975
                  | ("typ",x)::xs ->
3976
                      loop xs
3977
                        (arg0,
3978
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
3979
                             x), arg2)
3980
                  | ("init_val",x)::xs ->
3981
                      loop xs
3982
                        (arg0, arg1,
3983
                          ((function
3984
                            | `Null -> Result.Ok None
3985
                            | x ->
3986
                                ((fun x  -> vhdl_cst_val_t_of_yojson x) x)
3987
                                  >>= ((fun x  -> Result.Ok (Some x)))) x))
3988
                  | [] ->
3989
                      arg2 >>=
3990
                        ((fun arg2  ->
3991
                            arg1 >>=
3992
                              (fun arg1  ->
3993
                                 arg0 >>=
3994
                                   (fun arg0  ->
3995
                                      Result.Ok
3996
                                        (VarDecl
3997
                                           {
3998
                                             names = arg0;
3999
                                             typ = arg1;
4000
                                             init_val = arg2
4001
                                           })))))
4002
                  | _::xs -> loop xs _state  in
4003
                loop xs
4004
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4005
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4006
                    (Result.Ok (Some (CstInt 0))))
4007
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4008
      | `List ((`String "CONSTANT_DECLARATION")::arg0::[]) ->
4009
          ((function
4010
            | `Assoc xs ->
4011
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4012
                  match xs with
4013
                  | ("names",x)::xs ->
4014
                      loop xs
4015
                        (((function
4016
                           | `List xs ->
4017
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4018
                                 [] xs
4019
                           | _ ->
4020
                               Result.Error
4021
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4022
                          arg1, arg2)
4023
                  | ("typ",x)::xs ->
4024
                      loop xs
4025
                        (arg0,
4026
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4027
                             x), arg2)
4028
                  | ("init_val",x)::xs ->
4029
                      loop xs
4030
                        (arg0, arg1,
4031
                          ((fun x  -> vhdl_cst_val_t_of_yojson x) x))
4032
                  | [] ->
4033
                      arg2 >>=
4034
                        ((fun arg2  ->
4035
                            arg1 >>=
4036
                              (fun arg1  ->
4037
                                 arg0 >>=
4038
                                   (fun arg0  ->
4039
                                      Result.Ok
4040
                                        (CstDecl
4041
                                           {
4042
                                             names = arg0;
4043
                                             typ = arg1;
4044
                                             init_val = arg2
4045
                                           })))))
4046
                  | _::xs -> loop xs _state  in
4047
                loop xs
4048
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4049
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4050
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.init_val"))
4051
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4052
      | `List ((`String "SIGNAL_DECLARATION")::arg0::[]) ->
4053
          ((function
4054
            | `Assoc xs ->
4055
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4056
                  match xs with
4057
                  | ("names",x)::xs ->
4058
                      loop xs
4059
                        (((function
4060
                           | `List xs ->
4061
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4062
                                 [] xs
4063
                           | _ ->
4064
                               Result.Error
4065
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4066
                          arg1, arg2)
4067
                  | ("typ",x)::xs ->
4068
                      loop xs
4069
                        (arg0,
4070
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4071
                             x), arg2)
4072
                  | ("init_val",x)::xs ->
4073
                      loop xs
4074
                        (arg0, arg1,
4075
                          ((function
4076
                            | `Null -> Result.Ok None
4077
                            | x ->
4078
                                ((fun x  -> vhdl_cst_val_t_of_yojson x) x)
4079
                                  >>= ((fun x  -> Result.Ok (Some x)))) x))
4080
                  | [] ->
4081
                      arg2 >>=
4082
                        ((fun arg2  ->
4083
                            arg1 >>=
4084
                              (fun arg1  ->
4085
                                 arg0 >>=
4086
                                   (fun arg0  ->
4087
                                      Result.Ok
4088
                                        (SigDecl
4089
                                           {
4090
                                             names = arg0;
4091
                                             typ = arg1;
4092
                                             init_val = arg2
4093
                                           })))))
4094
                  | _::xs -> loop xs _state  in
4095
                loop xs
4096
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4097
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4098
                    (Result.Ok (Some (CstInt 0))))
4099
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4100
      | `List ((`String "SUBPROGRAM_BODY")::arg0::[]) ->
4101
          ((function
4102
            | `Assoc xs ->
4103
                let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
4104
                  match xs with
4105
                  | ("name",x)::xs ->
4106
                      loop xs
4107
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2,
4108
                          arg3, arg4)
4109
                  | ("kind",x)::xs ->
4110
                      loop xs
4111
                        (arg0,
4112
                          ((function
4113
                            | `String x -> Result.Ok x
4114
                            | _ ->
4115
                                Result.Error
4116
                                  "Vhdl_ast.vhdl_declaration_t.kind") x),
4117
                          arg2, arg3, arg4)
4118
                  | ("spec",x)::xs ->
4119
                      loop xs
4120
                        (arg0, arg1,
4121
                          ((fun x  -> vhdl_subprogram_spec_t_of_yojson x) x),
4122
                          arg3, arg4)
4123
                  | ("decl_part",x)::xs ->
4124
                      loop xs
4125
                        (arg0, arg1, arg2,
4126
                          ((function
4127
                            | `List xs ->
4128
                                map_bind
4129
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4130
                                  [] xs
4131
                            | _ ->
4132
                                Result.Error
4133
                                  "Vhdl_ast.vhdl_declaration_t.decl_part") x),
4134
                          arg4)
4135
                  | ("stmts",x)::xs ->
4136
                      loop xs
4137
                        (arg0, arg1, arg2, arg3,
4138
                          ((function
4139
                            | `List xs ->
4140
                                map_bind
4141
                                  (fun x  ->
4142
                                     vhdl_sequential_stmt_t_of_yojson x) []
4143
                                  xs
4144
                            | _ ->
4145
                                Result.Error
4146
                                  "Vhdl_ast.vhdl_declaration_t.stmts") x))
4147
                  | [] ->
4148
                      arg4 >>=
4149
                        ((fun arg4  ->
4150
                            arg3 >>=
4151
                              (fun arg3  ->
4152
                                 arg2 >>=
4153
                                   (fun arg2  ->
4154
                                      arg1 >>=
4155
                                        (fun arg1  ->
4156
                                           arg0 >>=
4157
                                             (fun arg0  ->
4158
                                                Result.Ok
4159
                                                  (Subprogram
4160
                                                     {
4161
                                                       name = arg0;
4162
                                                       kind = arg1;
4163
                                                       spec = arg2;
4164
                                                       decl_part = arg3;
4165
                                                       stmts = arg4
4166
                                                     })))))))
4167
                  | _::xs -> loop xs _state  in
4168
                loop xs
4169
                  ((Result.Ok NoName), (Result.Ok ""),
4170
                    (Result.Ok
4171
                       {
4172
                         name = "";
4173
                         typeMark = NoName;
4174
                         parameters = [];
4175
                         isPure = false
4176
                       }), (Result.Ok []), (Result.Ok []))
4177
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4178
      | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")
4179
  [@ocaml.warning "-A"])
4180

    
4181
type vhdl_signal_condition_t =
4182
  {
4183
  expr: vhdl_expr_t list ;
4184
  cond: vhdl_expr_t [@default IsNull]}
4185

    
4186
let rec pp_vhdl_signal_condition_t :
4187
  Format.formatter -> vhdl_signal_condition_t -> Ppx_deriving_runtime.unit =
4188
  let __1 () = pp_vhdl_expr_t
4189
  
4190
  and __0 () = pp_vhdl_expr_t
4191
   in
4192
  ((let open! Ppx_deriving_runtime in
4193
      fun fmt  ->
4194
        fun x  ->
4195
          Format.fprintf fmt "@[<2>{ ";
4196
          ((Format.fprintf fmt "@[%s =@ " "expr";
4197
            ((fun x  ->
4198
                Format.fprintf fmt "@[<2>[";
4199
                ignore
4200
                  (List.fold_left
4201
                     (fun sep  ->
4202
                        fun x  ->
4203
                          if sep then Format.fprintf fmt ";@ ";
4204
                          ((__0 ()) fmt) x;
4205
                          true) false x);
4206
                Format.fprintf fmt "@,]@]")) x.expr;
4207
            Format.fprintf fmt "@]");
4208
           Format.fprintf fmt ";@ ";
4209
           Format.fprintf fmt "@[%s =@ " "cond";
4210
           ((__1 ()) fmt) x.cond;
4211
           Format.fprintf fmt "@]");
4212
          Format.fprintf fmt "@ }@]")
4213
    [@ocaml.warning "-A"])
4214

    
4215
and show_vhdl_signal_condition_t :
4216
  vhdl_signal_condition_t -> Ppx_deriving_runtime.string =
4217
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_condition_t x
4218

    
4219
let rec (vhdl_signal_condition_t_to_yojson :
4220
          vhdl_signal_condition_t -> Yojson.Safe.json)
4221
  =
4222
  ((let open! Ppx_deriving_yojson_runtime in
4223
      fun x  ->
4224
        let fields = []  in
4225
        let fields =
4226
          if x.cond = IsNull
4227
          then fields
4228
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4229
            fields
4230
           in
4231
        let fields =
4232
          ("expr",
4233
            ((fun x  ->
4234
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
4235
               x.expr))
4236
          :: fields  in
4237
        `Assoc fields)
4238
  [@ocaml.warning "-A"])
4239

    
4240
and (vhdl_signal_condition_t_of_yojson :
4241
      Yojson.Safe.json ->
4242
        vhdl_signal_condition_t Ppx_deriving_yojson_runtime.error_or)
4243
  =
4244
  ((let open! Ppx_deriving_yojson_runtime in
4245
      function
4246
      | `Assoc xs ->
4247
          let rec loop xs ((arg0,arg1) as _state) =
4248
            match xs with
4249
            | ("expr",x)::xs ->
4250
                loop xs
4251
                  (((function
4252
                     | `List xs ->
4253
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4254
                     | _ ->
4255
                         Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr")
4256
                      x), arg1)
4257
            | ("cond",x)::xs ->
4258
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4259
            | [] ->
4260
                arg1 >>=
4261
                  ((fun arg1  ->
4262
                      arg0 >>=
4263
                        (fun arg0  -> Result.Ok { expr = arg0; cond = arg1 })))
4264
            | _::xs -> loop xs _state  in
4265
          loop xs
4266
            ((Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr"),
4267
              (Result.Ok IsNull))
4268
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_condition_t")
4269
  [@ocaml.warning "-A"])
4270

    
4271
type vhdl_signal_selection_t =
4272
  {
4273
  expr: vhdl_expr_t ;
4274
  when_sel: vhdl_expr_t list [@default []]}
4275

    
4276
let rec pp_vhdl_signal_selection_t :
4277
  Format.formatter -> vhdl_signal_selection_t -> Ppx_deriving_runtime.unit =
4278
  let __1 () = pp_vhdl_expr_t
4279
  
4280
  and __0 () = pp_vhdl_expr_t
4281
   in
4282
  ((let open! Ppx_deriving_runtime in
4283
      fun fmt  ->
4284
        fun x  ->
4285
          Format.fprintf fmt "@[<2>{ ";
4286
          ((Format.fprintf fmt "@[%s =@ " "expr";
4287
            ((__0 ()) fmt) x.expr;
4288
            Format.fprintf fmt "@]");
4289
           Format.fprintf fmt ";@ ";
4290
           Format.fprintf fmt "@[%s =@ " "when_sel";
4291
           ((fun x  ->
4292
               Format.fprintf fmt "@[<2>[";
4293
               ignore
4294
                 (List.fold_left
4295
                    (fun sep  ->
4296
                       fun x  ->
4297
                         if sep then Format.fprintf fmt ";@ ";
4298
                         ((__1 ()) fmt) x;
4299
                         true) false x);
4300
               Format.fprintf fmt "@,]@]")) x.when_sel;
4301
           Format.fprintf fmt "@]");
4302
          Format.fprintf fmt "@ }@]")
4303
    [@ocaml.warning "-A"])
4304

    
4305
and show_vhdl_signal_selection_t :
4306
  vhdl_signal_selection_t -> Ppx_deriving_runtime.string =
4307
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_selection_t x
4308

    
4309
let rec (vhdl_signal_selection_t_to_yojson :
4310
          vhdl_signal_selection_t -> Yojson.Safe.json)
4311
  =
4312
  ((let open! Ppx_deriving_yojson_runtime in
4313
      fun x  ->
4314
        let fields = []  in
4315
        let fields =
4316
          if x.when_sel = []
4317
          then fields
4318
          else
4319
            ("when_sel",
4320
              (((fun x  ->
4321
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
4322
                 x.when_sel))
4323
            :: fields
4324
           in
4325
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
4326
          :: fields  in
4327
        `Assoc fields)
4328
  [@ocaml.warning "-A"])
4329

    
4330
and (vhdl_signal_selection_t_of_yojson :
4331
      Yojson.Safe.json ->
4332
        vhdl_signal_selection_t Ppx_deriving_yojson_runtime.error_or)
4333
  =
4334
  ((let open! Ppx_deriving_yojson_runtime in
4335
      function
4336
      | `Assoc xs ->
4337
          let rec loop xs ((arg0,arg1) as _state) =
4338
            match xs with
4339
            | ("expr",x)::xs ->
4340
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
4341
            | ("when_sel",x)::xs ->
4342
                loop xs
4343
                  (arg0,
4344
                    ((function
4345
                      | `List xs ->
4346
                          map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4347
                      | _ ->
4348
                          Result.Error
4349
                            "Vhdl_ast.vhdl_signal_selection_t.when_sel") x))
4350
            | [] ->
4351
                arg1 >>=
4352
                  ((fun arg1  ->
4353
                      arg0 >>=
4354
                        (fun arg0  ->
4355
                           Result.Ok { expr = arg0; when_sel = arg1 })))
4356
            | _::xs -> loop xs _state  in
4357
          loop xs
4358
            ((Result.Error "Vhdl_ast.vhdl_signal_selection_t.expr"),
4359
              (Result.Ok []))
4360
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_selection_t")
4361
  [@ocaml.warning "-A"])
4362

    
4363
type vhdl_conditional_signal_t =
4364
  {
4365
  postponed: bool [@default false];
4366
  label: vhdl_name_t [@default NoName];
4367
  lhs: vhdl_name_t ;
4368
  rhs: vhdl_signal_condition_t list ;
4369
  cond: vhdl_expr_t [@default IsNull];
4370
  delay: vhdl_expr_t [@default IsNull]}
4371

    
4372
let rec pp_vhdl_conditional_signal_t :
4373
  Format.formatter -> vhdl_conditional_signal_t -> Ppx_deriving_runtime.unit
4374
  =
4375
  let __4 () = pp_vhdl_expr_t
4376
  
4377
  and __3 () = pp_vhdl_expr_t
4378
  
4379
  and __2 () = pp_vhdl_signal_condition_t
4380
  
4381
  and __1 () = pp_vhdl_name_t
4382
  
4383
  and __0 () = pp_vhdl_name_t
4384
   in
4385
  ((let open! Ppx_deriving_runtime in
4386
      fun fmt  ->
4387
        fun x  ->
4388
          Format.fprintf fmt "@[<2>{ ";
4389
          ((((((Format.fprintf fmt "@[%s =@ " "postponed";
4390
                (Format.fprintf fmt "%B") x.postponed;
4391
                Format.fprintf fmt "@]");
4392
               Format.fprintf fmt ";@ ";
4393
               Format.fprintf fmt "@[%s =@ " "label";
4394
               ((__0 ()) fmt) x.label;
4395
               Format.fprintf fmt "@]");
4396
              Format.fprintf fmt ";@ ";
4397
              Format.fprintf fmt "@[%s =@ " "lhs";
4398
              ((__1 ()) fmt) x.lhs;
4399
              Format.fprintf fmt "@]");
4400
             Format.fprintf fmt ";@ ";
4401
             Format.fprintf fmt "@[%s =@ " "rhs";
4402
             ((fun x  ->
4403
                 Format.fprintf fmt "@[<2>[";
4404
                 ignore
4405
                   (List.fold_left
4406
                      (fun sep  ->
4407
                         fun x  ->
4408
                           if sep then Format.fprintf fmt ";@ ";
4409
                           ((__2 ()) fmt) x;
4410
                           true) false x);
4411
                 Format.fprintf fmt "@,]@]")) x.rhs;
4412
             Format.fprintf fmt "@]");
4413
            Format.fprintf fmt ";@ ";
4414
            Format.fprintf fmt "@[%s =@ " "cond";
4415
            ((__3 ()) fmt) x.cond;
4416
            Format.fprintf fmt "@]");
4417
           Format.fprintf fmt ";@ ";
4418
           Format.fprintf fmt "@[%s =@ " "delay";
4419
           ((__4 ()) fmt) x.delay;
4420
           Format.fprintf fmt "@]");
4421
          Format.fprintf fmt "@ }@]")
4422
    [@ocaml.warning "-A"])
4423

    
4424
and show_vhdl_conditional_signal_t :
4425
  vhdl_conditional_signal_t -> Ppx_deriving_runtime.string =
4426
  fun x  -> Format.asprintf "%a" pp_vhdl_conditional_signal_t x
4427

    
4428
let rec (vhdl_conditional_signal_t_to_yojson :
4429
          vhdl_conditional_signal_t -> Yojson.Safe.json)
4430
  =
4431
  ((let open! Ppx_deriving_yojson_runtime in
4432
      fun x  ->
4433
        let fields = []  in
4434
        let fields =
4435
          if x.delay = IsNull
4436
          then fields
4437
          else ("delay", (((fun x  -> vhdl_expr_t_to_yojson x)) x.delay)) ::
4438
            fields
4439
           in
4440
        let fields =
4441
          if x.cond = IsNull
4442
          then fields
4443
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4444
            fields
4445
           in
4446
        let fields =
4447
          ("rhs",
4448
            ((fun x  ->
4449
                `List
4450
                  (List.map (fun x  -> vhdl_signal_condition_t_to_yojson x) x))
4451
               x.rhs))
4452
          :: fields  in
4453
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4454
          fields  in
4455
        let fields =
4456
          if x.label = NoName
4457
          then fields
4458
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4459
            fields
4460
           in
4461
        let fields =
4462
          if x.postponed = false
4463
          then fields
4464
          else
4465
            ("postponed",
4466
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4467
                 x.postponed))
4468
            :: fields
4469
           in
4470
        `Assoc fields)
4471
  [@ocaml.warning "-A"])
4472

    
4473
and (vhdl_conditional_signal_t_of_yojson :
4474
      Yojson.Safe.json ->
4475
        vhdl_conditional_signal_t Ppx_deriving_yojson_runtime.error_or)
4476
  =
4477
  ((let open! Ppx_deriving_yojson_runtime in
4478
      function
4479
      | `Assoc xs ->
4480
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4481
            match xs with
4482
            | ("postponed",x)::xs ->
4483
                loop xs
4484
                  (((function
4485
                     | `Bool x -> Result.Ok x
4486
                     | _ ->
4487
                         Result.Error
4488
                           "Vhdl_ast.vhdl_conditional_signal_t.postponed") x),
4489
                    arg1, arg2, arg3, arg4, arg5)
4490
            | ("label",x)::xs ->
4491
                loop xs
4492
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4493
                    arg4, arg5)
4494
            | ("lhs",x)::xs ->
4495
                loop xs
4496
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4497
                    arg4, arg5)
4498
            | ("rhs",x)::xs ->
4499
                loop xs
4500
                  (arg0, arg1, arg2,
4501
                    ((function
4502
                      | `List xs ->
4503
                          map_bind
4504
                            (fun x  -> vhdl_signal_condition_t_of_yojson x)
4505
                            [] xs
4506
                      | _ ->
4507
                          Result.Error
4508
                            "Vhdl_ast.vhdl_conditional_signal_t.rhs") x),
4509
                    arg4, arg5)
4510
            | ("cond",x)::xs ->
4511
                loop xs
4512
                  (arg0, arg1, arg2, arg3,
4513
                    ((fun x  -> vhdl_expr_t_of_yojson x) x), arg5)
4514
            | ("delay",x)::xs ->
4515
                loop xs
4516
                  (arg0, arg1, arg2, arg3, arg4,
4517
                    ((fun x  -> vhdl_expr_t_of_yojson x) x))
4518
            | [] ->
4519
                arg5 >>=
4520
                  ((fun arg5  ->
4521
                      arg4 >>=
4522
                        (fun arg4  ->
4523
                           arg3 >>=
4524
                             (fun arg3  ->
4525
                                arg2 >>=
4526
                                  (fun arg2  ->
4527
                                     arg1 >>=
4528
                                       (fun arg1  ->
4529
                                          arg0 >>=
4530
                                            (fun arg0  ->
4531
                                               Result.Ok
4532
                                                 {
4533
                                                   postponed = arg0;
4534
                                                   label = arg1;
4535
                                                   lhs = arg2;
4536
                                                   rhs = arg3;
4537
                                                   cond = arg4;
4538
                                                   delay = arg5
4539
                                                 })))))))
4540
            | _::xs -> loop xs _state  in
4541
          loop xs
4542
            ((Result.Ok false), (Result.Ok NoName),
4543
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.lhs"),
4544
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.rhs"),
4545
              (Result.Ok IsNull), (Result.Ok IsNull))
4546
      | _ -> Result.Error "Vhdl_ast.vhdl_conditional_signal_t")
4547
  [@ocaml.warning "-A"])
4548

    
4549
type vhdl_process_t =
4550
  {
4551
  id: vhdl_name_t [@default NoName];
4552
  declarations: vhdl_declaration_t list option
4553
    [@key "PROCESS_DECLARATIVE_PART"][@default Some []];
4554
  active_sigs: vhdl_name_t list [@default []];
4555
  body: vhdl_sequential_stmt_t list
4556
    [@key "PROCESS_STATEMENT_PART"][@default []]}
4557

    
4558
let rec pp_vhdl_process_t :
4559
  Format.formatter -> vhdl_process_t -> Ppx_deriving_runtime.unit =
4560
  let __3 () = pp_vhdl_sequential_stmt_t
4561
  
4562
  and __2 () = pp_vhdl_name_t
4563
  
4564
  and __1 () = pp_vhdl_declaration_t
4565
  
4566
  and __0 () = pp_vhdl_name_t
4567
   in
4568
  ((let open! Ppx_deriving_runtime in
4569
      fun fmt  ->
4570
        fun x  ->
4571
          Format.fprintf fmt "@[<2>{ ";
4572
          ((((Format.fprintf fmt "@[%s =@ " "id";
4573
              ((__0 ()) fmt) x.id;
4574
              Format.fprintf fmt "@]");
4575
             Format.fprintf fmt ";@ ";
4576
             Format.fprintf fmt "@[%s =@ " "declarations";
4577
             ((function
4578
               | None  -> Format.pp_print_string fmt "None"
4579
               | Some x ->
4580
                   (Format.pp_print_string fmt "(Some ";
4581
                    ((fun x  ->
4582
                        Format.fprintf fmt "@[<2>[";
4583
                        ignore
4584
                          (List.fold_left
4585
                             (fun sep  ->
4586
                                fun x  ->
4587
                                  if sep then Format.fprintf fmt ";@ ";
4588
                                  ((__1 ()) fmt) x;
4589
                                  true) false x);
4590
                        Format.fprintf fmt "@,]@]")) x;
4591
                    Format.pp_print_string fmt ")"))) x.declarations;
4592
             Format.fprintf fmt "@]");
4593
            Format.fprintf fmt ";@ ";
4594
            Format.fprintf fmt "@[%s =@ " "active_sigs";
4595
            ((fun x  ->
4596
                Format.fprintf fmt "@[<2>[";
4597
                ignore
4598
                  (List.fold_left
4599
                     (fun sep  ->
4600
                        fun x  ->
4601
                          if sep then Format.fprintf fmt ";@ ";
4602
                          ((__2 ()) fmt) x;
4603
                          true) false x);
4604
                Format.fprintf fmt "@,]@]")) x.active_sigs;
4605
            Format.fprintf fmt "@]");
4606
           Format.fprintf fmt ";@ ";
4607
           Format.fprintf fmt "@[%s =@ " "body";
4608
           ((fun x  ->
4609
               Format.fprintf fmt "@[<2>[";
4610
               ignore
4611
                 (List.fold_left
4612
                    (fun sep  ->
4613
                       fun x  ->
4614
                         if sep then Format.fprintf fmt ";@ ";
4615
                         ((__3 ()) fmt) x;
4616
                         true) false x);
4617
               Format.fprintf fmt "@,]@]")) x.body;
4618
           Format.fprintf fmt "@]");
4619
          Format.fprintf fmt "@ }@]")
4620
    [@ocaml.warning "-A"])
4621

    
4622
and show_vhdl_process_t : vhdl_process_t -> Ppx_deriving_runtime.string =
4623
  fun x  -> Format.asprintf "%a" pp_vhdl_process_t x
4624

    
4625
let rec (vhdl_process_t_to_yojson : vhdl_process_t -> Yojson.Safe.json) =
4626
  ((let open! Ppx_deriving_yojson_runtime in
4627
      fun x  ->
4628
        let fields = []  in
4629
        let fields =
4630
          if x.body = []
4631
          then fields
4632
          else
4633
            ("PROCESS_STATEMENT_PART",
4634
              (((fun x  ->
4635
                   `List
4636
                     (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x)
4637
                        x))) x.body))
4638
            :: fields
4639
           in
4640
        let fields =
4641
          if x.active_sigs = []
4642
          then fields
4643
          else
4644
            ("active_sigs",
4645
              (((fun x  ->
4646
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
4647
                 x.active_sigs))
4648
            :: fields
4649
           in
4650
        let fields =
4651
          if x.declarations = (Some [])
4652
          then fields
4653
          else
4654
            ("PROCESS_DECLARATIVE_PART",
4655
              (((function
4656
                 | None  -> `Null
4657
                 | Some x ->
4658
                     ((fun x  ->
4659
                         `List
4660
                           (List.map
4661
                              (fun x  -> vhdl_declaration_t_to_yojson x) x)))
4662
                       x)) x.declarations))
4663
            :: fields
4664
           in
4665
        let fields =
4666
          if x.id = NoName
4667
          then fields
4668
          else ("id", (((fun x  -> vhdl_name_t_to_yojson x)) x.id)) :: fields
4669
           in
4670
        `Assoc fields)
4671
  [@ocaml.warning "-A"])
4672

    
4673
and (vhdl_process_t_of_yojson :
4674
      Yojson.Safe.json -> vhdl_process_t Ppx_deriving_yojson_runtime.error_or)
4675
  =
4676
  ((let open! Ppx_deriving_yojson_runtime in
4677
      function
4678
      | `Assoc xs ->
4679
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
4680
            match xs with
4681
            | ("id",x)::xs ->
4682
                loop xs
4683
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3)
4684
            | ("PROCESS_DECLARATIVE_PART",x)::xs ->
4685
                loop xs
4686
                  (arg0,
4687
                    ((function
4688
                      | `Null -> Result.Ok None
4689
                      | x ->
4690
                          ((function
4691
                            | `List xs ->
4692
                                map_bind
4693
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4694
                                  [] xs
4695
                            | _ ->
4696
                                Result.Error
4697
                                  "Vhdl_ast.vhdl_process_t.declarations") x)
4698
                            >>= ((fun x  -> Result.Ok (Some x)))) x), arg2,
4699
                    arg3)
4700
            | ("active_sigs",x)::xs ->
4701
                loop xs
4702
                  (arg0, arg1,
4703
                    ((function
4704
                      | `List xs ->
4705
                          map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4706
                      | _ ->
4707
                          Result.Error "Vhdl_ast.vhdl_process_t.active_sigs")
4708
                       x), arg3)
4709
            | ("PROCESS_STATEMENT_PART",x)::xs ->
4710
                loop xs
4711
                  (arg0, arg1, arg2,
4712
                    ((function
4713
                      | `List xs ->
4714
                          map_bind
4715
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
4716
                            xs
4717
                      | _ -> Result.Error "Vhdl_ast.vhdl_process_t.body") x))
4718
            | [] ->
4719
                arg3 >>=
4720
                  ((fun arg3  ->
4721
                      arg2 >>=
4722
                        (fun arg2  ->
4723
                           arg1 >>=
4724
                             (fun arg1  ->
4725
                                arg0 >>=
4726
                                  (fun arg0  ->
4727
                                     Result.Ok
4728
                                       {
4729
                                         id = arg0;
4730
                                         declarations = arg1;
4731
                                         active_sigs = arg2;
4732
                                         body = arg3
4733
                                       })))))
4734
            | _::xs -> loop xs _state  in
4735
          loop xs
4736
            ((Result.Ok NoName), (Result.Ok (Some [])), (Result.Ok []),
4737
              (Result.Ok []))
4738
      | _ -> Result.Error "Vhdl_ast.vhdl_process_t")
4739
  [@ocaml.warning "-A"])
4740

    
4741
type vhdl_selected_signal_t =
4742
  {
4743
  postponed: bool [@default false];
4744
  label: vhdl_name_t [@default NoName];
4745
  lhs: vhdl_name_t ;
4746
  sel: vhdl_expr_t ;
4747
  branches: vhdl_signal_selection_t list [@default []];
4748
  delay: vhdl_expr_t option }
4749

    
4750
let rec pp_vhdl_selected_signal_t :
4751
  Format.formatter -> vhdl_selected_signal_t -> Ppx_deriving_runtime.unit =
4752
  let __4 () = pp_vhdl_expr_t
4753
  
4754
  and __3 () = pp_vhdl_signal_selection_t
4755
  
4756
  and __2 () = pp_vhdl_expr_t
4757
  
4758
  and __1 () = pp_vhdl_name_t
4759
  
4760
  and __0 () = pp_vhdl_name_t
4761
   in
4762
  ((let open! Ppx_deriving_runtime in
4763
      fun fmt  ->
4764
        fun x  ->
4765
          Format.fprintf fmt "@[<2>{ ";
4766
          ((((((Format.fprintf fmt "@[%s =@ " "postponed";
4767
                (Format.fprintf fmt "%B") x.postponed;
4768
                Format.fprintf fmt "@]");
4769
               Format.fprintf fmt ";@ ";
4770
               Format.fprintf fmt "@[%s =@ " "label";
4771
               ((__0 ()) fmt) x.label;
4772
               Format.fprintf fmt "@]");
4773
              Format.fprintf fmt ";@ ";
4774
              Format.fprintf fmt "@[%s =@ " "lhs";
4775
              ((__1 ()) fmt) x.lhs;
4776
              Format.fprintf fmt "@]");
4777
             Format.fprintf fmt ";@ ";
4778
             Format.fprintf fmt "@[%s =@ " "sel";
4779
             ((__2 ()) fmt) x.sel;
4780
             Format.fprintf fmt "@]");
4781
            Format.fprintf fmt ";@ ";
4782
            Format.fprintf fmt "@[%s =@ " "branches";
4783
            ((fun x  ->
4784
                Format.fprintf fmt "@[<2>[";
4785
                ignore
4786
                  (List.fold_left
4787
                     (fun sep  ->
4788
                        fun x  ->
4789
                          if sep then Format.fprintf fmt ";@ ";
4790
                          ((__3 ()) fmt) x;
4791
                          true) false x);
4792
                Format.fprintf fmt "@,]@]")) x.branches;
4793
            Format.fprintf fmt "@]");
4794
           Format.fprintf fmt ";@ ";
4795
           Format.fprintf fmt "@[%s =@ " "delay";
4796
           ((function
4797
             | None  -> Format.pp_print_string fmt "None"
4798
             | Some x ->
4799
                 (Format.pp_print_string fmt "(Some ";
4800
                  ((__4 ()) fmt) x;
4801
                  Format.pp_print_string fmt ")"))) x.delay;
4802
           Format.fprintf fmt "@]");
4803
          Format.fprintf fmt "@ }@]")
4804
    [@ocaml.warning "-A"])
4805

    
4806
and show_vhdl_selected_signal_t :
4807
  vhdl_selected_signal_t -> Ppx_deriving_runtime.string =
4808
  fun x  -> Format.asprintf "%a" pp_vhdl_selected_signal_t x
4809

    
4810
let rec (vhdl_selected_signal_t_to_yojson :
4811
          vhdl_selected_signal_t -> Yojson.Safe.json)
4812
  =
4813
  ((let open! Ppx_deriving_yojson_runtime in
4814
      fun x  ->
4815
        let fields = []  in
4816
        let fields =
4817
          ("delay",
4818
            ((function
4819
              | None  -> `Null
4820
              | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x) x.delay))
4821
          :: fields  in
4822
        let fields =
4823
          if x.branches = []
4824
          then fields
4825
          else
4826
            ("branches",
4827
              (((fun x  ->
4828
                   `List
4829
                     (List.map
4830
                        (fun x  -> vhdl_signal_selection_t_to_yojson x) x)))
4831
                 x.branches))
4832
            :: fields
4833
           in
4834
        let fields = ("sel", ((fun x  -> vhdl_expr_t_to_yojson x) x.sel)) ::
4835
          fields  in
4836
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
4837
          fields  in
4838
        let fields =
4839
          if x.label = NoName
4840
          then fields
4841
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
4842
            fields
4843
           in
4844
        let fields =
4845
          if x.postponed = false
4846
          then fields
4847
          else
4848
            ("postponed",
4849
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
4850
                 x.postponed))
4851
            :: fields
4852
           in
4853
        `Assoc fields)
4854
  [@ocaml.warning "-A"])
4855

    
4856
and (vhdl_selected_signal_t_of_yojson :
4857
      Yojson.Safe.json ->
4858
        vhdl_selected_signal_t Ppx_deriving_yojson_runtime.error_or)
4859
  =
4860
  ((let open! Ppx_deriving_yojson_runtime in
4861
      function
4862
      | `Assoc xs ->
4863
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
4864
            match xs with
4865
            | ("postponed",x)::xs ->
4866
                loop xs
4867
                  (((function
4868
                     | `Bool x -> Result.Ok x
4869
                     | _ ->
4870
                         Result.Error
4871
                           "Vhdl_ast.vhdl_selected_signal_t.postponed") x),
4872
                    arg1, arg2, arg3, arg4, arg5)
4873
            | ("label",x)::xs ->
4874
                loop xs
4875
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
4876
                    arg4, arg5)
4877
            | ("lhs",x)::xs ->
4878
                loop xs
4879
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
4880
                    arg4, arg5)
4881
            | ("sel",x)::xs ->
4882
                loop xs
4883
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x),
4884
                    arg4, arg5)
4885
            | ("branches",x)::xs ->
4886
                loop xs
4887
                  (arg0, arg1, arg2, arg3,
4888
                    ((function
4889
                      | `List xs ->
4890
                          map_bind
4891
                            (fun x  -> vhdl_signal_selection_t_of_yojson x)
4892
                            [] xs
4893
                      | _ ->
4894
                          Result.Error
4895
                            "Vhdl_ast.vhdl_selected_signal_t.branches") x),
4896
                    arg5)
4897
            | ("delay",x)::xs ->
4898
                loop xs
4899
                  (arg0, arg1, arg2, arg3, arg4,
4900
                    ((function
4901
                      | `Null -> Result.Ok None
4902
                      | x ->
4903
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
4904
                            ((fun x  -> Result.Ok (Some x)))) x))
4905
            | [] ->
4906
                arg5 >>=
4907
                  ((fun arg5  ->
4908
                      arg4 >>=
4909
                        (fun arg4  ->
4910
                           arg3 >>=
4911
                             (fun arg3  ->
4912
                                arg2 >>=
4913
                                  (fun arg2  ->
4914
                                     arg1 >>=
4915
                                       (fun arg1  ->
4916
                                          arg0 >>=
4917
                                            (fun arg0  ->
4918
                                               Result.Ok
4919
                                                 {
4920
                                                   postponed = arg0;
4921
                                                   label = arg1;
4922
                                                   lhs = arg2;
4923
                                                   sel = arg3;
4924
                                                   branches = arg4;
4925
                                                   delay = arg5
4926
                                                 })))))))
4927
            | _::xs -> loop xs _state  in
4928
          loop xs
4929
            ((Result.Ok false), (Result.Ok NoName),
4930
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.lhs"),
4931
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.sel"),
4932
              (Result.Ok []),
4933
              (Result.Error "Vhdl_ast.vhdl_selected_signal_t.delay"))
4934
      | _ -> Result.Error "Vhdl_ast.vhdl_selected_signal_t")
4935
  [@ocaml.warning "-A"])
4936

    
4937
type vhdl_concurrent_stmt_t =
4938
  | SigAssign of vhdl_conditional_signal_t
4939
  [@name "CONDITIONAL_SIGNAL_ASSIGNMENT"]
4940
  | Process of vhdl_process_t [@name "PROCESS_STATEMENT"]
4941
  | SelectedSig of vhdl_selected_signal_t
4942
  [@name "SELECTED_SIGNAL_ASSIGNMENT"]
4943

    
4944
let rec pp_vhdl_concurrent_stmt_t :
4945
  Format.formatter -> vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.unit =
4946
  let __2 () = pp_vhdl_selected_signal_t
4947
  
4948
  and __1 () = pp_vhdl_process_t
4949
  
4950
  and __0 () = pp_vhdl_conditional_signal_t
4951
   in
4952
  ((let open! Ppx_deriving_runtime in
4953
      fun fmt  ->
4954
        function
4955
        | SigAssign a0 ->
4956
            (Format.fprintf fmt "(@[<2>SigAssign@ ";
4957
             ((__0 ()) fmt) a0;
4958
             Format.fprintf fmt "@])")
4959
        | Process a0 ->
4960
            (Format.fprintf fmt "(@[<2>Process@ ";
4961
             ((__1 ()) fmt) a0;
4962
             Format.fprintf fmt "@])")
4963
        | SelectedSig a0 ->
4964
            (Format.fprintf fmt "(@[<2>SelectedSig@ ";
4965
             ((__2 ()) fmt) a0;
4966
             Format.fprintf fmt "@])"))
4967
    [@ocaml.warning "-A"])
4968

    
4969
and show_vhdl_concurrent_stmt_t :
4970
  vhdl_concurrent_stmt_t -> Ppx_deriving_runtime.string =
4971
  fun x  -> Format.asprintf "%a" pp_vhdl_concurrent_stmt_t x
4972

    
4973
let rec (vhdl_concurrent_stmt_t_to_yojson :
4974
          vhdl_concurrent_stmt_t -> Yojson.Safe.json)
4975
  =
4976
  ((let open! Ppx_deriving_yojson_runtime in
4977
      function
4978
      | SigAssign arg0 ->
4979
          `List
4980
            [`String "CONDITIONAL_SIGNAL_ASSIGNMENT";
4981
            ((fun x  -> vhdl_conditional_signal_t_to_yojson x)) arg0]
4982
      | Process arg0 ->
4983
          `List
4984
            [`String "PROCESS_STATEMENT";
4985
            ((fun x  -> vhdl_process_t_to_yojson x)) arg0]
4986
      | SelectedSig arg0 ->
4987
          `List
4988
            [`String "SELECTED_SIGNAL_ASSIGNMENT";
4989
            ((fun x  -> vhdl_selected_signal_t_to_yojson x)) arg0])
4990
  [@ocaml.warning "-A"])
4991

    
4992
and (vhdl_concurrent_stmt_t_of_yojson :
4993
      Yojson.Safe.json ->
4994
        vhdl_concurrent_stmt_t Ppx_deriving_yojson_runtime.error_or)
4995
  =
4996
  ((let open! Ppx_deriving_yojson_runtime in
4997
      function
4998
      | `List ((`String "CONDITIONAL_SIGNAL_ASSIGNMENT")::arg0::[]) ->
4999
          ((fun x  -> vhdl_conditional_signal_t_of_yojson x) arg0) >>=
5000
            ((fun arg0  -> Result.Ok (SigAssign arg0)))
5001
      | `List ((`String "PROCESS_STATEMENT")::arg0::[]) ->
5002
          ((fun x  -> vhdl_process_t_of_yojson x) arg0) >>=
5003
            ((fun arg0  -> Result.Ok (Process arg0)))
5004
      | `List ((`String "SELECTED_SIGNAL_ASSIGNMENT")::arg0::[]) ->
5005
          ((fun x  -> vhdl_selected_signal_t_of_yojson x) arg0) >>=
5006
            ((fun arg0  -> Result.Ok (SelectedSig arg0)))
5007
      | _ -> Result.Error "Vhdl_ast.vhdl_concurrent_stmt_t")
5008
  [@ocaml.warning "-A"])
5009

    
5010
type vhdl_port_mode_t =
5011
  | InPort [@name "in"]
5012
  | OutPort [@name "out"]
5013
  | InoutPort [@name "inout"]
5014
  | BufferPort [@name "buffer"]
5015

    
5016
let rec (pp_vhdl_port_mode_t :
5017
          Format.formatter -> vhdl_port_mode_t -> Ppx_deriving_runtime.unit)
5018
  =
5019
  ((let open! Ppx_deriving_runtime in
5020
      fun fmt  ->
5021
        function
5022
        | InPort  -> Format.pp_print_string fmt "InPort"
5023
        | OutPort  -> Format.pp_print_string fmt "OutPort"
5024
        | InoutPort  -> Format.pp_print_string fmt "InoutPort"
5025
        | BufferPort  -> Format.pp_print_string fmt "BufferPort")
5026
  [@ocaml.warning "-A"])
5027

    
5028
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string =
5029
  fun x  -> Format.asprintf "%a" pp_vhdl_port_mode_t x
5030

    
5031
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) =
5032
  ((let open! Ppx_deriving_yojson_runtime in
5033
      function
5034
      | InPort  -> `List [`String "in"]
5035
      | OutPort  -> `List [`String "out"]
5036
      | InoutPort  -> `List [`String "inout"]
5037
      | BufferPort  -> `List [`String "buffer"])
5038
  [@ocaml.warning "-A"])
5039

    
5040
and (vhdl_port_mode_t_of_yojson :
5041
      Yojson.Safe.json ->
5042
        vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or)
5043
  =
5044
  ((let open! Ppx_deriving_yojson_runtime in
5045
      function
5046
      | `List ((`String "in")::[]) -> Result.Ok InPort
5047
      | `List ((`String "out")::[]) -> Result.Ok OutPort
5048
      | `List ((`String "inout")::[]) -> Result.Ok InoutPort
5049
      | `List ((`String "buffer")::[]) -> Result.Ok BufferPort
5050
      | _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t")
5051
  [@ocaml.warning "-A"])
5052

    
5053
type vhdl_port_t =
5054
  {
5055
  names: vhdl_name_t list [@default []];
5056
  mode: vhdl_port_mode_t [@default InPort];
5057
  typ: vhdl_subtype_indication_t ;
5058
  expr: vhdl_expr_t [@default IsNull]}
5059

    
5060
let rec pp_vhdl_port_t :
5061
  Format.formatter -> vhdl_port_t -> Ppx_deriving_runtime.unit =
5062
  let __3 () = pp_vhdl_expr_t
5063
  
5064
  and __2 () = pp_vhdl_subtype_indication_t
5065
  
5066
  and __1 () = pp_vhdl_port_mode_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
          Format.fprintf fmt "@[<2>{ ";
5074
          ((((Format.fprintf fmt "@[%s =@ " "names";
5075
              ((fun x  ->
5076
                  Format.fprintf fmt "@[<2>[";
5077
                  ignore
5078
                    (List.fold_left
5079
                       (fun sep  ->
5080
                          fun x  ->
5081
                            if sep then Format.fprintf fmt ";@ ";
5082
                            ((__0 ()) fmt) x;
5083
                            true) false x);
5084
                  Format.fprintf fmt "@,]@]")) x.names;
5085
              Format.fprintf fmt "@]");
5086
             Format.fprintf fmt ";@ ";
5087
             Format.fprintf fmt "@[%s =@ " "mode";
5088
             ((__1 ()) fmt) x.mode;
5089
             Format.fprintf fmt "@]");
5090
            Format.fprintf fmt ";@ ";
5091
            Format.fprintf fmt "@[%s =@ " "typ";
5092
            ((__2 ()) fmt) x.typ;
5093
            Format.fprintf fmt "@]");
5094
           Format.fprintf fmt ";@ ";
5095
           Format.fprintf fmt "@[%s =@ " "expr";
5096
           ((__3 ()) fmt) x.expr;
5097
           Format.fprintf fmt "@]");
5098
          Format.fprintf fmt "@ }@]")
5099
    [@ocaml.warning "-A"])
5100

    
5101
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string =
5102
  fun x  -> Format.asprintf "%a" pp_vhdl_port_t x
5103

    
5104
let rec (vhdl_port_t_to_yojson : vhdl_port_t -> Yojson.Safe.json) =
5105
  ((let open! Ppx_deriving_yojson_runtime in
5106
      fun x  ->
5107
        let fields = []  in
5108
        let fields =
5109
          if x.expr = IsNull
5110
          then fields
5111
          else ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) x.expr)) ::
5112
            fields
5113
           in
5114
        let fields =
5115
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
5116
          :: fields  in
5117
        let fields =
5118
          if x.mode = InPort
5119
          then fields
5120
          else ("mode", (((fun x  -> vhdl_port_mode_t_to_yojson x)) x.mode))
5121
            :: fields
5122
           in
5123
        let fields =
5124
          if x.names = []
5125
          then fields
5126
          else
5127
            ("names",
5128
              (((fun x  ->
5129
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
5130
                 x.names))
5131
            :: fields
5132
           in
5133
        `Assoc fields)
5134
  [@ocaml.warning "-A"])
5135

    
5136
and (vhdl_port_t_of_yojson :
5137
      Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
5138
  =
5139
  ((let open! Ppx_deriving_yojson_runtime in
5140
      function
5141
      | `Assoc xs ->
5142
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
5143
            match xs with
5144
            | ("names",x)::xs ->
5145
                loop xs
5146
                  (((function
5147
                     | `List xs ->
5148
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5149
                     | _ -> Result.Error "Vhdl_ast.vhdl_port_t.names") x),
5150
                    arg1, arg2, arg3)
5151
            | ("mode",x)::xs ->
5152
                loop xs
5153
                  (arg0, ((fun x  -> vhdl_port_mode_t_of_yojson x) x), arg2,
5154
                    arg3)
5155
            | ("typ",x)::xs ->
5156
                loop xs
5157
                  (arg0, arg1,
5158
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
5159
                    arg3)
5160
            | ("expr",x)::xs ->
5161
                loop xs
5162
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x))
5163
            | [] ->
5164
                arg3 >>=
5165
                  ((fun arg3  ->
5166
                      arg2 >>=
5167
                        (fun arg2  ->
5168
                           arg1 >>=
5169
                             (fun arg1  ->
5170
                                arg0 >>=
5171
                                  (fun arg0  ->
5172
                                     Result.Ok
5173
                                       {
5174
                                         names = arg0;
5175
                                         mode = arg1;
5176
                                         typ = arg2;
5177
                                         expr = arg3
5178
                                       })))))
5179
            | _::xs -> loop xs _state  in
5180
          loop xs
5181
            ((Result.Ok []), (Result.Ok InPort),
5182
              (Result.Error "Vhdl_ast.vhdl_port_t.typ"), (Result.Ok IsNull))
5183
      | _ -> Result.Error "Vhdl_ast.vhdl_port_t")
5184
  [@ocaml.warning "-A"])
5185

    
5186
type vhdl_entity_t =
5187
  {
5188
  name: vhdl_name_t [@default NoName];
5189
  generics: vhdl_port_t list [@default []];
5190
  ports: vhdl_port_t list [@default []];
5191
  declaration: vhdl_declaration_t list
5192
    [@key "ENTITY_DECLARATIVE_PART"][@default []];
5193
  stmts: vhdl_concurrent_stmt_t list
5194
    [@key "ENTITY_STATEMENT_PART"][@default []]}
5195

    
5196
let rec pp_vhdl_entity_t :
5197
  Format.formatter -> vhdl_entity_t -> Ppx_deriving_runtime.unit =
5198
  let __4 () = pp_vhdl_concurrent_stmt_t
5199
  
5200
  and __3 () = pp_vhdl_declaration_t
5201
  
5202
  and __2 () = pp_vhdl_port_t
5203
  
5204
  and __1 () = pp_vhdl_port_t
5205
  
5206
  and __0 () = pp_vhdl_name_t
5207
   in
5208
  ((let open! Ppx_deriving_runtime in
5209
      fun fmt  ->
5210
        fun x  ->
5211
          Format.fprintf fmt "@[<2>{ ";
5212
          (((((Format.fprintf fmt "@[%s =@ " "name";
5213
               ((__0 ()) fmt) x.name;
5214
               Format.fprintf fmt "@]");
5215
              Format.fprintf fmt ";@ ";
5216
              Format.fprintf fmt "@[%s =@ " "generics";
5217
              ((fun x  ->
5218
                  Format.fprintf fmt "@[<2>[";
5219
                  ignore
5220
                    (List.fold_left
5221
                       (fun sep  ->
5222
                          fun x  ->
5223
                            if sep then Format.fprintf fmt ";@ ";
5224
                            ((__1 ()) fmt) x;
5225
                            true) false x);
5226
                  Format.fprintf fmt "@,]@]")) x.generics;
5227
              Format.fprintf fmt "@]");
5228
             Format.fprintf fmt ";@ ";
5229
             Format.fprintf fmt "@[%s =@ " "ports";
5230
             ((fun x  ->
5231
                 Format.fprintf fmt "@[<2>[";
5232
                 ignore
5233
                   (List.fold_left
5234
                      (fun sep  ->
5235
                         fun x  ->
5236
                           if sep then Format.fprintf fmt ";@ ";
5237
                           ((__2 ()) fmt) x;
5238
                           true) false x);
5239
                 Format.fprintf fmt "@,]@]")) x.ports;
5240
             Format.fprintf fmt "@]");
5241
            Format.fprintf fmt ";@ ";
5242
            Format.fprintf fmt "@[%s =@ " "declaration";
5243
            ((fun x  ->
5244
                Format.fprintf fmt "@[<2>[";
5245
                ignore
5246
                  (List.fold_left
5247
                     (fun sep  ->
5248
                        fun x  ->
5249
                          if sep then Format.fprintf fmt ";@ ";
5250
                          ((__3 ()) fmt) x;
5251
                          true) false x);
5252
                Format.fprintf fmt "@,]@]")) x.declaration;
5253
            Format.fprintf fmt "@]");
5254
           Format.fprintf fmt ";@ ";
5255
           Format.fprintf fmt "@[%s =@ " "stmts";
5256
           ((fun x  ->
5257
               Format.fprintf fmt "@[<2>[";
5258
               ignore
5259
                 (List.fold_left
5260
                    (fun sep  ->
5261
                       fun x  ->
5262
                         if sep then Format.fprintf fmt ";@ ";
5263
                         ((__4 ()) fmt) x;
5264
                         true) false x);
5265
               Format.fprintf fmt "@,]@]")) x.stmts;
5266
           Format.fprintf fmt "@]");
5267
          Format.fprintf fmt "@ }@]")
5268
    [@ocaml.warning "-A"])
5269

    
5270
and show_vhdl_entity_t : vhdl_entity_t -> Ppx_deriving_runtime.string =
5271
  fun x  -> Format.asprintf "%a" pp_vhdl_entity_t x
5272

    
5273
let rec (vhdl_entity_t_to_yojson : vhdl_entity_t -> Yojson.Safe.json) =
5274
  ((let open! Ppx_deriving_yojson_runtime in
5275
      fun x  ->
5276
        let fields = []  in
5277
        let fields =
5278
          if x.stmts = []
5279
          then fields
5280
          else
5281
            ("ENTITY_STATEMENT_PART",
5282
              (((fun x  ->
5283
                   `List
5284
                     (List.map (fun x  -> vhdl_concurrent_stmt_t_to_yojson x)
5285
                        x))) x.stmts))
5286
            :: fields
5287
           in
5288
        let fields =
5289
          if x.declaration = []
5290
          then fields
5291
          else
5292
            ("ENTITY_DECLARATIVE_PART",
5293
              (((fun x  ->
5294
                   `List
5295
                     (List.map (fun x  -> vhdl_declaration_t_to_yojson x) x)))
5296
                 x.declaration))
5297
            :: fields
5298
           in
5299
        let fields =
5300
          if x.ports = []
5301
          then fields
5302
          else
5303
            ("ports",
5304
              (((fun x  ->
5305
                   `List (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
5306
                 x.ports))
5307
            :: fields
5308
           in
5309
        let fields =
5310
          if x.generics = []
5311
          then fields
5312
          else
5313
            ("generics",
5314
              (((fun x  ->
5315
                   `List (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
5316
                 x.generics))
5317
            :: fields
5318
           in
5319
        let fields =
5320
          if x.name = NoName
5321
          then fields
5322
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
5323
            fields
5324
           in
5325
        `Assoc fields)
5326
  [@ocaml.warning "-A"])
5327

    
5328
and (vhdl_entity_t_of_yojson :
5329
      Yojson.Safe.json -> vhdl_entity_t Ppx_deriving_yojson_runtime.error_or)
5330
  =
5331
  ((let open! Ppx_deriving_yojson_runtime in
5332
      function
5333
      | `Assoc xs ->
5334
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
5335
            match xs with
5336
            | ("name",x)::xs ->
5337
                loop xs
5338
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3,
5339
                    arg4)
5340
            | ("generics",x)::xs ->
5341
                loop xs
5342
                  (arg0,
5343
                    ((function
5344
                      | `List xs ->
5345
                          map_bind (fun x  -> vhdl_port_t_of_yojson x) [] xs
5346
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.generics")
5347
                       x), arg2, arg3, arg4)
5348
            | ("ports",x)::xs ->
5349
                loop xs
5350
                  (arg0, arg1,
5351
                    ((function
5352
                      | `List xs ->
5353
                          map_bind (fun x  -> vhdl_port_t_of_yojson x) [] xs
5354
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.ports") x),
5355
                    arg3, arg4)
5356
            | ("ENTITY_DECLARATIVE_PART",x)::xs ->
5357
                loop xs
5358
                  (arg0, arg1, arg2,
5359
                    ((function
5360
                      | `List xs ->
5361
                          map_bind (fun x  -> vhdl_declaration_t_of_yojson x)
5362
                            [] xs
5363
                      | _ ->
5364
                          Result.Error "Vhdl_ast.vhdl_entity_t.declaration")
5365
                       x), arg4)
5366
            | ("ENTITY_STATEMENT_PART",x)::xs ->
5367
                loop xs
5368
                  (arg0, arg1, arg2, arg3,
5369
                    ((function
5370
                      | `List xs ->
5371
                          map_bind
5372
                            (fun x  -> vhdl_concurrent_stmt_t_of_yojson x) []
5373
                            xs
5374
                      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t.stmts") x))
5375
            | [] ->
5376
                arg4 >>=
5377
                  ((fun arg4  ->
5378
                      arg3 >>=
5379
                        (fun arg3  ->
5380
                           arg2 >>=
5381
                             (fun arg2  ->
5382
                                arg1 >>=
5383
                                  (fun arg1  ->
5384
                                     arg0 >>=
5385
                                       (fun arg0  ->
5386
                                          Result.Ok
5387
                                            {
5388
                                              name = arg0;
5389
                                              generics = arg1;
5390
                                              ports = arg2;
5391
                                              declaration = arg3;
5392
                                              stmts = arg4
5393
                                            }))))))
5394
            | _::xs -> loop xs _state  in
5395
          loop xs
5396
            ((Result.Ok NoName), (Result.Ok []), (Result.Ok []),
5397
              (Result.Ok []), (Result.Ok []))
5398
      | _ -> Result.Error "Vhdl_ast.vhdl_entity_t")
5399
  [@ocaml.warning "-A"])
5400

    
5401
type vhdl_package_t =
5402
  {
5403
  name: vhdl_name_t [@default NoName];
5404
  shared_defs: vhdl_definition_t list [@default []]}
5405

    
5406
let rec pp_vhdl_package_t :
5407
  Format.formatter -> vhdl_package_t -> Ppx_deriving_runtime.unit =
5408
  let __1 () = pp_vhdl_definition_t
5409
  
5410
  and __0 () = pp_vhdl_name_t
5411
   in
5412
  ((let open! Ppx_deriving_runtime in
5413
      fun fmt  ->
5414
        fun x  ->
5415
          Format.fprintf fmt "@[<2>{ ";
5416
          ((Format.fprintf fmt "@[%s =@ " "name";
5417
            ((__0 ()) fmt) x.name;
5418
            Format.fprintf fmt "@]");
5419
           Format.fprintf fmt ";@ ";
5420
           Format.fprintf fmt "@[%s =@ " "shared_defs";
5421
           ((fun x  ->
5422
               Format.fprintf fmt "@[<2>[";
5423
               ignore
5424
                 (List.fold_left
5425
                    (fun sep  ->
5426
                       fun x  ->
5427
                         if sep then Format.fprintf fmt ";@ ";
5428
                         ((__1 ()) fmt) x;
5429
                         true) false x);
5430
               Format.fprintf fmt "@,]@]")) x.shared_defs;
5431
           Format.fprintf fmt "@]");
5432
          Format.fprintf fmt "@ }@]")
5433
    [@ocaml.warning "-A"])
5434

    
5435
and show_vhdl_package_t : vhdl_package_t -> Ppx_deriving_runtime.string =
5436
  fun x  -> Format.asprintf "%a" pp_vhdl_package_t x
5437

    
5438
let rec (vhdl_package_t_to_yojson : vhdl_package_t -> Yojson.Safe.json) =
5439
  ((let open! Ppx_deriving_yojson_runtime in
5440
      fun x  ->
5441
        let fields = []  in
5442
        let fields =
5443
          if x.shared_defs = []
5444
          then fields
5445
          else
5446
            ("shared_defs",
5447
              (((fun x  ->
5448
                   `List
5449
                     (List.map (fun x  -> vhdl_definition_t_to_yojson x) x)))
5450 </