Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / backends / VHDL / vhdl_ast_deriving.ml @ d4c98bae

History | View | Annotate | Download (246 KB)

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

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

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

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

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

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

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

    
263
and show_vhdl_type_t : vhdl_type_t -> Ppx_deriving_runtime.string =
264
  fun x  -> Format.asprintf "%a" pp_vhdl_type_t x
265

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

    
288
and show_vhdl_element_declaration_t :
289
  vhdl_element_declaration_t -> Ppx_deriving_runtime.string =
290
  fun x  -> Format.asprintf "%a" pp_vhdl_element_declaration_t x
291

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

    
312
and show_vhdl_subtype_indication_t :
313
  vhdl_subtype_indication_t -> Ppx_deriving_runtime.string =
314
  fun x  -> Format.asprintf "%a" pp_vhdl_subtype_indication_t x
315

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

    
341
and show_vhdl_discrete_range_t :
342
  vhdl_discrete_range_t -> Ppx_deriving_runtime.string =
343
  fun x  -> Format.asprintf "%a" pp_vhdl_discrete_range_t x
344

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

    
403
and show_vhdl_constraint_t : vhdl_constraint_t -> Ppx_deriving_runtime.string
404
  = fun x  -> Format.asprintf "%a" pp_vhdl_constraint_t x
405

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

    
432
and show_vhdl_definition_t : vhdl_definition_t -> Ppx_deriving_runtime.string
433
  = fun x  -> Format.asprintf "%a" pp_vhdl_definition_t x
434

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

    
550
and show_vhdl_expr_t : vhdl_expr_t -> Ppx_deriving_runtime.string =
551
  fun x  -> Format.asprintf "%a" pp_vhdl_expr_t x
552

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

    
637
and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string =
638
  fun x  -> Format.asprintf "%a" pp_vhdl_name_t x
639

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

    
684
and show_vhdl_assoc_element_t :
685
  vhdl_assoc_element_t -> Ppx_deriving_runtime.string =
686
  fun x  -> Format.asprintf "%a" pp_vhdl_assoc_element_t x
687

    
688
and pp_vhdl_element_assoc_t :
689
  Format.formatter -> vhdl_element_assoc_t -> Ppx_deriving_runtime.unit =
690
  let __1 () = pp_vhdl_expr_t
691
  
692
  and __0 () = pp_vhdl_expr_t
693
   in
694
  ((let open! Ppx_deriving_runtime in
695
      fun fmt  ->
696
        fun x  ->
697
            (match x.choices with
698
            | [] -> Format.fprintf fmt "";
699
            | _ -> 
700
              (((fun x  ->
701
                ignore
702
                  (List.fold_left
703
                     (fun sep  ->
704
                        fun x  ->
705
                          if sep then Format.fprintf fmt "|@ ";
706
                          ((__0 ()) fmt) x;
707
                          true) false x))) x.choices;
708
              Format.fprintf fmt " => ";));
709
           ((__1 ()) fmt) x.expr)
710
    [@ocaml.warning "-A"])
711

    
712
and show_vhdl_element_assoc_t :
713
  vhdl_element_assoc_t -> Ppx_deriving_runtime.string =
714
  fun x  -> Format.asprintf "%a" pp_vhdl_element_assoc_t x
715

    
716
(* TODO *)
717
and (pp_vhdl_array_attributes_t :
718
      Format.formatter ->
719
        vhdl_array_attributes_t -> Ppx_deriving_runtime.unit)
720
  =
721
  ((let open! Ppx_deriving_runtime in
722
      fun fmt  ->
723
        function
724
        | AAttInt { id = aid; arg = aarg } ->
725
            (Format.fprintf fmt "@[<2>AAttInt {@,";
726
             ((Format.fprintf fmt "@[%s =@ " "id";
727
               (Format.fprintf fmt "%S") aid;
728
               Format.fprintf fmt "@]");
729
              Format.fprintf fmt ";@ ";
730
              Format.fprintf fmt "@[%s =@ " "arg";
731
              (Format.fprintf fmt "%d") aarg;
732
              Format.fprintf fmt "@]");
733
             Format.fprintf fmt "@]}")
734
        | AAttAscending  -> Format.pp_print_string fmt "AAttAscending")
735
  [@ocaml.warning "-A"])
736

    
737
and show_vhdl_array_attributes_t :
738
  vhdl_array_attributes_t -> Ppx_deriving_runtime.string =
739
  fun x  -> Format.asprintf "%a" pp_vhdl_array_attributes_t x
740

    
741
(* TODO *)
742
and (pp_vhdl_signal_attributes_t :
743
      Format.formatter ->
744
        vhdl_signal_attributes_t -> Ppx_deriving_runtime.unit)
745
  =
746
  ((let open! Ppx_deriving_runtime in
747
      fun fmt  ->
748
        function
749
        | SigAtt a0 ->
750
            (Format.fprintf fmt "(@[<2>SigAtt@ ";
751
             (Format.fprintf fmt "%S") a0;
752
             Format.fprintf fmt "@])"))
753
  [@ocaml.warning "-A"])
754

    
755
and show_vhdl_signal_attributes_t :
756
  vhdl_signal_attributes_t -> Ppx_deriving_runtime.string =
757
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_attributes_t x
758

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

    
773
and show_vhdl_string_attributes_t :
774
  vhdl_string_attributes_t -> Ppx_deriving_runtime.string =
775
  fun x  -> Format.asprintf "%a" pp_vhdl_string_attributes_t x
776

    
777
(* TODO *)
778
and (pp_vhdl_suffix_selection_t :
779
      Format.formatter ->
780
        vhdl_suffix_selection_t -> Ppx_deriving_runtime.unit)
781
  =
782
  ((let open! Ppx_deriving_runtime in
783
      fun fmt  ->
784
        function
785
        | Idx a0 ->
786
            (Format.fprintf fmt "(@[<2>Idx@ ";
787
             (Format.fprintf fmt "%d") a0;
788
             Format.fprintf fmt "@])")
789
        | SuffixRange (a0,a1) ->
790
            (Format.fprintf fmt "(@[<2>SuffixRange (@,";
791
             ((Format.fprintf fmt "%d") a0;
792
              Format.fprintf fmt ",@ ";
793
              (Format.fprintf fmt "%d") a1);
794
             Format.fprintf fmt "@,))@]"))
795
  [@ocaml.warning "-A"])
796

    
797
and show_vhdl_suffix_selection_t :
798
  vhdl_suffix_selection_t -> Ppx_deriving_runtime.string =
799
  fun x  -> Format.asprintf "%a" pp_vhdl_suffix_selection_t x
800

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

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

    
971
and (vhdl_element_declaration_t_to_yojson :
972
      vhdl_element_declaration_t -> Yojson.Safe.json)
973
  =
974
  ((let open! Ppx_deriving_yojson_runtime in
975
      fun x  ->
976
        let fields = []  in
977
        let fields =
978
          ("definition",
979
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.definition))
980
          :: fields  in
981
        let fields =
982
          ("names",
983
            ((fun x  ->
984
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
985
               x.names))
986
          :: fields  in
987
        `Assoc fields)
988
  [@ocaml.warning "-A"])
989

    
990
and (vhdl_element_declaration_t_of_yojson :
991
      Yojson.Safe.json ->
992
        vhdl_element_declaration_t Ppx_deriving_yojson_runtime.error_or)
993
  =
994
  ((let open! Ppx_deriving_yojson_runtime in
995
      function
996
      | `Assoc xs ->
997
          let rec loop xs ((arg0,arg1) as _state) =
998
            match xs with
999
            | ("names",x)::xs ->
1000
                loop xs
1001
                  (((function
1002
                     | `List xs ->
1003
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1004
                     | _ ->
1005
                         Result.Error
1006
                           "Vhdl_ast.vhdl_element_declaration_t.names") x),
1007
                    arg1)
1008
            | ("definition",x)::xs ->
1009
                loop xs
1010
                  (arg0,
1011
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x))
1012
            | [] ->
1013
                arg1 >>=
1014
                  ((fun arg1  ->
1015
                      arg0 >>=
1016
                        (fun arg0  ->
1017
                           Result.Ok { names = arg0; definition = arg1 })))
1018
            | _::xs -> loop xs _state  in
1019
          loop xs
1020
            ((Result.Error "Vhdl_ast.vhdl_element_declaration_t.names"),
1021
              (Result.Error "Vhdl_ast.vhdl_element_declaration_t.definition"))
1022
      | _ -> Result.Error "Vhdl_ast.vhdl_element_declaration_t")
1023
  [@ocaml.warning "-A"])
1024

    
1025
and (vhdl_subtype_indication_t_to_yojson :
1026
      vhdl_subtype_indication_t -> Yojson.Safe.json)
1027
  =
1028
  ((let open! Ppx_deriving_yojson_runtime in
1029
      fun x  ->
1030
        let fields = []  in
1031
        let fields =
1032
          if x.const = NoConstraint
1033
          then fields
1034
          else
1035
            ("const", (((fun x  -> vhdl_constraint_t_to_yojson x)) x.const))
1036
            :: fields
1037
           in
1038
        let fields =
1039
          if x.functionName = NoName
1040
          then fields
1041
          else
1042
            ("functionName",
1043
              (((fun x  -> vhdl_name_t_to_yojson x)) x.functionName))
1044
            :: fields
1045
           in
1046
        let fields =
1047
          if x.name = NoName
1048
          then fields
1049
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
1050
            fields
1051
           in
1052
        `Assoc fields)
1053
  [@ocaml.warning "-A"])
1054

    
1055
and (vhdl_subtype_indication_t_of_yojson :
1056
      Yojson.Safe.json ->
1057
        vhdl_subtype_indication_t Ppx_deriving_yojson_runtime.error_or)
1058
  =
1059
  ((let open! Ppx_deriving_yojson_runtime in
1060
      function
1061
      | `Assoc xs ->
1062
          let rec loop xs ((arg0,arg1,arg2) as _state) =
1063
            match xs with
1064
            | ("name",x)::xs ->
1065
                loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
1066
            | ("functionName",x)::xs ->
1067
                loop xs (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
1068
            | ("const",x)::xs ->
1069
                loop xs
1070
                  (arg0, arg1, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
1071
            | [] ->
1072
                arg2 >>=
1073
                  ((fun arg2  ->
1074
                      arg1 >>=
1075
                        (fun arg1  ->
1076
                           arg0 >>=
1077
                             (fun arg0  ->
1078
                                Result.Ok
1079
                                  {
1080
                                    name = arg0;
1081
                                    functionName = arg1;
1082
                                    const = arg2
1083
                                  }))))
1084
            | _::xs -> loop xs _state  in
1085
          loop xs
1086
            ((Result.Ok NoName), (Result.Ok NoName),
1087
              (Result.Ok NoConstraint))
1088
      | _ -> Result.Error "Vhdl_ast.vhdl_subtype_indication_t")
1089
  [@ocaml.warning "-A"])
1090

    
1091
and (vhdl_discrete_range_t_to_yojson :
1092
      vhdl_discrete_range_t -> Yojson.Safe.json)
1093
  =
1094
  ((let open! Ppx_deriving_yojson_runtime in
1095
      function
1096
      | SubDiscreteRange arg0 ->
1097
          `List
1098
            [`String "SUB_DISCRETE_RANGE";
1099
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x)) arg0]
1100
      | NamedRange arg0 ->
1101
          `List
1102
            [`String "NAMED_RANGE";
1103
            ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
1104
      | DirectedRange arg0 ->
1105
          `List
1106
            [`String "RANGE_WITH_DIRECTION";
1107
            (let fields = []  in
1108
             let fields =
1109
               ("_to", ((fun x  -> vhdl_expr_t_to_yojson x) arg0._to)) ::
1110
               fields  in
1111
             let fields =
1112
               ("from", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.from)) ::
1113
               fields  in
1114
             let fields =
1115
               ("direction",
1116
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
1117
                    arg0.direction))
1118
               :: fields  in
1119
             `Assoc fields)])
1120
  [@ocaml.warning "-A"])
1121

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

    
1176
and (vhdl_constraint_t_to_yojson : vhdl_constraint_t -> Yojson.Safe.json) =
1177
  ((let open! Ppx_deriving_yojson_runtime in
1178
      function
1179
      | RefConstraint arg0 ->
1180
          `List
1181
            [`String "RefConstraint";
1182
            (let fields = []  in
1183
             let fields =
1184
               ("ref_name",
1185
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.ref_name))
1186
               :: fields  in
1187
             `Assoc fields)]
1188
      | RangeConstraint arg0 ->
1189
          `List
1190
            [`String "RANGE_CONSTRAINT";
1191
            (let fields = []  in
1192
             let fields =
1193
               ("range",
1194
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
1195
               :: fields  in
1196
             `Assoc fields)]
1197
      | IndexConstraint arg0 ->
1198
          `List
1199
            [`String "INDEX_CONSTRAINT";
1200
            (let fields = []  in
1201
             let fields =
1202
               ("ranges",
1203
                 ((fun x  ->
1204
                     `List
1205
                       (List.map
1206
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1207
                    arg0.ranges))
1208
               :: fields  in
1209
             `Assoc fields)]
1210
      | ArrayConstraint arg0 ->
1211
          `List
1212
            [`String "ARRAY_CONSTRAINT";
1213
            (let fields = []  in
1214
             let fields =
1215
               ("sub", ((fun x  -> vhdl_constraint_t_to_yojson x) arg0.sub))
1216
               :: fields  in
1217
             let fields =
1218
               ("ranges",
1219
                 ((fun x  ->
1220
                     `List
1221
                       (List.map
1222
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1223
                    arg0.ranges))
1224
               :: fields  in
1225
             `Assoc fields)]
1226
      | RecordConstraint  -> `List [`String "RecordConstraint"]
1227
      | NoConstraint  -> `List [`String "NoConstraint"])
1228
  [@ocaml.warning "-A"])
1229

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

    
1325
and (vhdl_definition_t_to_yojson : vhdl_definition_t -> Yojson.Safe.json) =
1326
  ((let open! Ppx_deriving_yojson_runtime in
1327
      function
1328
      | Type arg0 ->
1329
          `List
1330
            [`String "TYPE_DECLARATION";
1331
            (let fields = []  in
1332
             let fields =
1333
               ("definition",
1334
                 ((fun x  -> vhdl_type_t_to_yojson x) arg0.definition))
1335
               :: fields  in
1336
             let fields =
1337
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1338
               fields  in
1339
             `Assoc fields)]
1340
      | Subtype arg0 ->
1341
          `List
1342
            [`String "SUBTYPE_DECLARATION";
1343
            (let fields = []  in
1344
             let fields =
1345
               ("typ",
1346
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
1347
               :: fields  in
1348
             let fields =
1349
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1350
               fields  in
1351
             `Assoc fields)])
1352
  [@ocaml.warning "-A"])
1353

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

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

    
1520
and (vhdl_expr_t_of_yojson :
1521
      Yojson.Safe.json -> vhdl_expr_t Ppx_deriving_yojson_runtime.error_or)
1522
  =
1523
  ((let open! Ppx_deriving_yojson_runtime in
1524
      function
1525
      | `List ((`String "CALL")::arg0::[]) ->
1526
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
1527
            ((fun arg0  -> Result.Ok (Call arg0)))
1528
      | `List ((`String "CONSTANT_VALUE")::arg0::[]) ->
1529
          ((function
1530
            | `Assoc xs ->
1531
                let rec loop xs ((arg0,arg1) as _state) =
1532
                  match xs with
1533
                  | ("value",x)::xs ->
1534
                      loop xs
1535
                        (((fun x  -> vhdl_cst_val_t_of_yojson x) x), arg1)
1536
                  | ("unit_name",x)::xs ->
1537
                      loop xs
1538
                        (arg0,
1539
                          ((function
1540
                            | `Null -> Result.Ok None
1541
                            | x ->
1542
                                ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1543
                                  ((fun x  -> Result.Ok (Some x)))) x))
1544
                  | [] ->
1545
                      arg1 >>=
1546
                        ((fun arg1  ->
1547
                            arg0 >>=
1548
                              (fun arg0  ->
1549
                                 Result.Ok
1550
                                   (Cst { value = arg0; unit_name = arg1 }))))
1551
                  | _::xs -> loop xs _state  in
1552
                loop xs
1553
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.value"),
1554
                    (Result.Ok None))
1555
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1556
      | `List ((`String "EXPRESSION")::arg0::[]) ->
1557
          ((function
1558
            | `Assoc xs ->
1559
                let rec loop xs ((arg0,arg1) as _state) =
1560
                  match xs with
1561
                  | ("id",x)::xs ->
1562
                      loop xs
1563
                        (((function
1564
                           | `String x -> Result.Ok x
1565
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.id") x),
1566
                          arg1)
1567
                  | ("args",x)::xs ->
1568
                      loop xs
1569
                        (arg0,
1570
                          ((function
1571
                            | `List xs ->
1572
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1573
                                  [] xs
1574
                            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.args")
1575
                             x))
1576
                  | [] ->
1577
                      arg1 >>=
1578
                        ((fun arg1  ->
1579
                            arg0 >>=
1580
                              (fun arg0  ->
1581
                                 Result.Ok (Op { id = arg0; args = arg1 }))))
1582
                  | _::xs -> loop xs _state  in
1583
                loop xs ((Result.Ok ""), (Result.Ok []))
1584
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1585
      | `List ((`String "IsNull")::[]) -> Result.Ok IsNull
1586
      | `List ((`String "Time")::arg0::[]) ->
1587
          ((function
1588
            | `Assoc xs ->
1589
                let rec loop xs ((arg0,arg1) as _state) =
1590
                  match xs with
1591
                  | ("value",x)::xs ->
1592
                      loop xs
1593
                        (((function
1594
                           | `Int x -> Result.Ok x
1595
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.value")
1596
                            x), arg1)
1597
                  | ("phy_unit",x)::xs ->
1598
                      loop xs
1599
                        (arg0,
1600
                          ((function
1601
                            | `String x -> Result.Ok x
1602
                            | _ ->
1603
                                Result.Error "Vhdl_ast.vhdl_expr_t.phy_unit")
1604
                             x))
1605
                  | [] ->
1606
                      arg1 >>=
1607
                        ((fun arg1  ->
1608
                            arg0 >>=
1609
                              (fun arg0  ->
1610
                                 Result.Ok
1611
                                   (Time { value = arg0; phy_unit = arg1 }))))
1612
                  | _::xs -> loop xs _state  in
1613
                loop xs
1614
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.value"),
1615
                    (Result.Ok ""))
1616
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1617
      | `List ((`String "Sig")::arg0::[]) ->
1618
          ((function
1619
            | `Assoc xs ->
1620
                let rec loop xs ((arg0,arg1) as _state) =
1621
                  match xs with
1622
                  | ("name",x)::xs ->
1623
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1624
                  | ("att",x)::xs ->
1625
                      loop xs
1626
                        (arg0,
1627
                          ((function
1628
                            | `Null -> Result.Ok None
1629
                            | x ->
1630
                                ((fun x  ->
1631
                                    vhdl_signal_attributes_t_of_yojson x) x)
1632
                                  >>= ((fun x  -> Result.Ok (Some x)))) x))
1633
                  | [] ->
1634
                      arg1 >>=
1635
                        ((fun arg1  ->
1636
                            arg0 >>=
1637
                              (fun arg0  ->
1638
                                 Result.Ok (Sig { name = arg0; att = arg1 }))))
1639
                  | _::xs -> loop xs _state  in
1640
                loop xs
1641
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.name"),
1642
                    (Result.Error "Vhdl_ast.vhdl_expr_t.att"))
1643
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1644
      | `List ((`String "SuffixMod")::arg0::[]) ->
1645
          ((function
1646
            | `Assoc xs ->
1647
                let rec loop xs ((arg0,arg1) as _state) =
1648
                  match xs with
1649
                  | ("expr",x)::xs ->
1650
                      loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
1651
                  | ("selection",x)::xs ->
1652
                      loop xs
1653
                        (arg0,
1654
                          ((fun x  -> vhdl_suffix_selection_t_of_yojson x) x))
1655
                  | [] ->
1656
                      arg1 >>=
1657
                        ((fun arg1  ->
1658
                            arg0 >>=
1659
                              (fun arg0  ->
1660
                                 Result.Ok
1661
                                   (SuffixMod
1662
                                      { expr = arg0; selection = arg1 }))))
1663
                  | _::xs -> loop xs _state  in
1664
                loop xs
1665
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.expr"),
1666
                    (Result.Error "Vhdl_ast.vhdl_expr_t.selection"))
1667
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1668
      | `List ((`String "AGGREGATE")::arg0::[]) ->
1669
          ((function
1670
            | `Assoc xs ->
1671
                let rec loop xs (arg0 as _state) =
1672
                  match xs with
1673
                  | ("elems",x)::xs ->
1674
                      loop xs
1675
                        ((function
1676
                          | `List xs ->
1677
                              map_bind
1678
                                (fun x  -> vhdl_element_assoc_t_of_yojson x)
1679
                                [] xs
1680
                          | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.elems") x)
1681
                  | [] ->
1682
                      arg0 >>=
1683
                        ((fun arg0  -> Result.Ok (Aggregate { elems = arg0 })))
1684
                  | _::xs -> loop xs _state  in
1685
                loop xs (Result.Error "Vhdl_ast.vhdl_expr_t.elems")
1686
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1687
      | `List ((`String "OTHERS")::[]) -> Result.Ok Others
1688
      | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")
1689
  [@ocaml.warning "-A"])
1690

    
1691
and (vhdl_name_t_to_yojson : vhdl_name_t -> Yojson.Safe.json) =
1692
  ((let open! Ppx_deriving_yojson_runtime in
1693
      function
1694
      | Simple arg0 ->
1695
          `List
1696
            [`String "SIMPLE_NAME";
1697
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1698
      | Identifier arg0 ->
1699
          `List
1700
            [`String "IDENTIFIER";
1701
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1702
      | Selected arg0 ->
1703
          `List
1704
            [`String "SELECTED_NAME";
1705
            ((fun x  ->
1706
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
1707
      | Index arg0 ->
1708
          `List
1709
            [`String "INDEXED_NAME";
1710
            (let fields = []  in
1711
             let fields =
1712
               ("exprs",
1713
                 ((fun x  ->
1714
                     `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
1715
                    arg0.exprs))
1716
               :: fields  in
1717
             let fields =
1718
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1719
               fields  in
1720
             `Assoc fields)]
1721
      | Slice arg0 ->
1722
          `List
1723
            [`String "SLICE_NAME";
1724
            (let fields = []  in
1725
             let fields =
1726
               ("range",
1727
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
1728
               :: fields  in
1729
             let fields =
1730
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1731
               fields  in
1732
             `Assoc fields)]
1733
      | Attribute arg0 ->
1734
          `List
1735
            [`String "ATTRIBUTE_NAME";
1736
            (let fields = []  in
1737
             let fields =
1738
               if arg0.expr = IsNull
1739
               then fields
1740
               else
1741
                 ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.expr))
1742
                 :: fields
1743
                in
1744
             let fields =
1745
               ("designator",
1746
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.designator))
1747
               :: fields  in
1748
             let fields =
1749
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1750
               fields  in
1751
             `Assoc fields)]
1752
      | Function arg0 ->
1753
          `List
1754
            [`String "FUNCTION_CALL";
1755
            (let fields = []  in
1756
             let fields =
1757
               ("assoc_list",
1758
                 ((fun x  ->
1759
                     `List
1760
                       (List.map (fun x  -> vhdl_assoc_element_t_to_yojson x)
1761
                          x)) arg0.assoc_list))
1762
               :: fields  in
1763
             let fields =
1764
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1765
               fields  in
1766
             `Assoc fields)]
1767
      | NoName  -> `List [`String "NoName"])
1768
  [@ocaml.warning "-A"])
1769

    
1770
and (vhdl_name_t_of_yojson :
1771
      Yojson.Safe.json -> vhdl_name_t Ppx_deriving_yojson_runtime.error_or)
1772
  =
1773
  ((let open! Ppx_deriving_yojson_runtime in
1774
      function
1775
      | `List ((`String "SIMPLE_NAME")::arg0::[]) ->
1776
          ((function
1777
            | `String x -> Result.Ok x
1778
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1779
            ((fun arg0  -> Result.Ok (Simple arg0)))
1780
      | `List ((`String "IDENTIFIER")::arg0::[]) ->
1781
          ((function
1782
            | `String x -> Result.Ok x
1783
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1784
            ((fun arg0  -> Result.Ok (Identifier arg0)))
1785
      | `List ((`String "SELECTED_NAME")::arg0::[]) ->
1786
          ((function
1787
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1788
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1789
            ((fun arg0  -> Result.Ok (Selected arg0)))
1790
      | `List ((`String "INDEXED_NAME")::arg0::[]) ->
1791
          ((function
1792
            | `Assoc xs ->
1793
                let rec loop xs ((arg0,arg1) as _state) =
1794
                  match xs with
1795
                  | ("id",x)::xs ->
1796
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1797
                  | ("exprs",x)::xs ->
1798
                      loop xs
1799
                        (arg0,
1800
                          ((function
1801
                            | `List xs ->
1802
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1803
                                  [] xs
1804
                            | _ -> Result.Error "Vhdl_ast.vhdl_name_t.exprs")
1805
                             x))
1806
                  | [] ->
1807
                      arg1 >>=
1808
                        ((fun arg1  ->
1809
                            arg0 >>=
1810
                              (fun arg0  ->
1811
                                 Result.Ok
1812
                                   (Index { id = arg0; exprs = arg1 }))))
1813
                  | _::xs -> loop xs _state  in
1814
                loop xs
1815
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1816
                    (Result.Error "Vhdl_ast.vhdl_name_t.exprs"))
1817
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1818
      | `List ((`String "SLICE_NAME")::arg0::[]) ->
1819
          ((function
1820
            | `Assoc xs ->
1821
                let rec loop xs ((arg0,arg1) as _state) =
1822
                  match xs with
1823
                  | ("id",x)::xs ->
1824
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1825
                  | ("range",x)::xs ->
1826
                      loop xs
1827
                        (arg0,
1828
                          ((fun x  -> vhdl_discrete_range_t_of_yojson x) x))
1829
                  | [] ->
1830
                      arg1 >>=
1831
                        ((fun arg1  ->
1832
                            arg0 >>=
1833
                              (fun arg0  ->
1834
                                 Result.Ok
1835
                                   (Slice { id = arg0; range = arg1 }))))
1836
                  | _::xs -> loop xs _state  in
1837
                loop xs
1838
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1839
                    (Result.Error "Vhdl_ast.vhdl_name_t.range"))
1840
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1841
      | `List ((`String "ATTRIBUTE_NAME")::arg0::[]) ->
1842
          ((function
1843
            | `Assoc xs ->
1844
                let rec loop xs ((arg0,arg1,arg2) as _state) =
1845
                  match xs with
1846
                  | ("id",x)::xs ->
1847
                      loop xs
1848
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
1849
                  | ("designator",x)::xs ->
1850
                      loop xs
1851
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
1852
                  | ("expr",x)::xs ->
1853
                      loop xs
1854
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1855
                  | [] ->
1856
                      arg2 >>=
1857
                        ((fun arg2  ->
1858
                            arg1 >>=
1859
                              (fun arg1  ->
1860
                                 arg0 >>=
1861
                                   (fun arg0  ->
1862
                                      Result.Ok
1863
                                        (Attribute
1864
                                           {
1865
                                             id = arg0;
1866
                                             designator = arg1;
1867
                                             expr = arg2
1868
                                           })))))
1869
                  | _::xs -> loop xs _state  in
1870
                loop xs
1871
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1872
                    (Result.Error "Vhdl_ast.vhdl_name_t.designator"),
1873
                    (Result.Ok IsNull))
1874
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1875
      | `List ((`String "FUNCTION_CALL")::arg0::[]) ->
1876
          ((function
1877
            | `Assoc xs ->
1878
                let rec loop xs ((arg0,arg1) as _state) =
1879
                  match xs with
1880
                  | ("id",x)::xs ->
1881
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1882
                  | ("assoc_list",x)::xs ->
1883
                      loop xs
1884
                        (arg0,
1885
                          ((function
1886
                            | `List xs ->
1887
                                map_bind
1888
                                  (fun x  -> vhdl_assoc_element_t_of_yojson x)
1889
                                  [] xs
1890
                            | _ ->
1891
                                Result.Error
1892
                                  "Vhdl_ast.vhdl_name_t.assoc_list") x))
1893
                  | [] ->
1894
                      arg1 >>=
1895
                        ((fun arg1  ->
1896
                            arg0 >>=
1897
                              (fun arg0  ->
1898
                                 Result.Ok
1899
                                   (Function { id = arg0; assoc_list = arg1 }))))
1900
                  | _::xs -> loop xs _state  in
1901
                loop xs
1902
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1903
                    (Result.Error "Vhdl_ast.vhdl_name_t.assoc_list"))
1904
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1905
      | `List ((`String "NoName")::[]) -> Result.Ok NoName
1906
      | _ -> Result.Error "Vhdl_ast.vhdl_name_t")
1907
  [@ocaml.warning "-A"])
1908

    
1909
and (vhdl_assoc_element_t_to_yojson :
1910
      vhdl_assoc_element_t -> Yojson.Safe.json)
1911
  =
1912
  ((let open! Ppx_deriving_yojson_runtime in
1913
      fun x  ->
1914
        let fields = []  in
1915
        let fields =
1916
          if x.actual_expr = None
1917
          then fields
1918
          else
1919
            ("actual_expr",
1920
              (((function
1921
                 | None  -> `Null
1922
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
1923
                 x.actual_expr))
1924
            :: fields
1925
           in
1926
        let fields =
1927
          if x.actual_designator = None
1928
          then fields
1929
          else
1930
            ("actual_designator",
1931
              (((function
1932
                 | None  -> `Null
1933
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1934
                 x.actual_designator))
1935
            :: fields
1936
           in
1937
        let fields =
1938
          if x.actual_name = None
1939
          then fields
1940
          else
1941
            ("actual_name",
1942
              (((function
1943
                 | None  -> `Null
1944
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1945
                 x.actual_name))
1946
            :: fields
1947
           in
1948
        let fields =
1949
          if x.formal_arg = None
1950
          then fields
1951
          else
1952
            ("formal_arg",
1953
              (((function
1954
                 | None  -> `Null
1955
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1956
                 x.formal_arg))
1957
            :: fields
1958
           in
1959
        let fields =
1960
          if x.formal_name = None
1961
          then fields
1962
          else
1963
            ("formal_name",
1964
              (((function
1965
                 | None  -> `Null
1966
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1967
                 x.formal_name))
1968
            :: fields
1969
           in
1970
        `Assoc fields)
1971
  [@ocaml.warning "-A"])
1972

    
1973
and (vhdl_assoc_element_t_of_yojson :
1974
      Yojson.Safe.json ->
1975
        vhdl_assoc_element_t Ppx_deriving_yojson_runtime.error_or)
1976
  =
1977
  ((let open! Ppx_deriving_yojson_runtime in
1978
      function
1979
      | `Assoc xs ->
1980
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
1981
            match xs with
1982
            | ("formal_name",x)::xs ->
1983
                loop xs
1984
                  (((function
1985
                     | `Null -> Result.Ok None
1986
                     | x ->
1987
                         ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1988
                           ((fun x  -> Result.Ok (Some x)))) x), arg1, arg2,
1989
                    arg3, arg4)
1990
            | ("formal_arg",x)::xs ->
1991
                loop xs
1992
                  (arg0,
1993
                    ((function
1994
                      | `Null -> Result.Ok None
1995
                      | x ->
1996
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1997
                            ((fun x  -> Result.Ok (Some x)))) x), arg2, arg3,
1998
                    arg4)
1999
            | ("actual_name",x)::xs ->
2000
                loop xs
2001
                  (arg0, arg1,
2002
                    ((function
2003
                      | `Null -> Result.Ok None
2004
                      | x ->
2005
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
2006
                            ((fun x  -> Result.Ok (Some x)))) x), arg3, arg4)
2007
            | ("actual_designator",x)::xs ->
2008
                loop xs
2009
                  (arg0, arg1, arg2,
2010
                    ((function
2011
                      | `Null -> Result.Ok None
2012
                      | x ->
2013
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
2014
                            ((fun x  -> Result.Ok (Some x)))) x), arg4)
2015
            | ("actual_expr",x)::xs ->
2016
                loop xs
2017
                  (arg0, arg1, arg2, arg3,
2018
                    ((function
2019
                      | `Null -> Result.Ok None
2020
                      | x ->
2021
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
2022
                            ((fun x  -> Result.Ok (Some x)))) x))
2023
            | [] ->
2024
                arg4 >>=
2025
                  ((fun arg4  ->
2026
                      arg3 >>=
2027
                        (fun arg3  ->
2028
                           arg2 >>=
2029
                             (fun arg2  ->
2030
                                arg1 >>=
2031
                                  (fun arg1  ->
2032
                                     arg0 >>=
2033
                                       (fun arg0  ->
2034
                                          Result.Ok
2035
                                            {
2036
                                              formal_name = arg0;
2037
                                              formal_arg = arg1;
2038
                                              actual_name = arg2;
2039
                                              actual_designator = arg3;
2040
                                              actual_expr = arg4
2041
                                            }))))))
2042
            | _::xs -> loop xs _state  in
2043
          loop xs
2044
            ((Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
2045
              (Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
2046
              (Result.Ok (Some IsNull)))
2047
      | _ -> Result.Error "Vhdl_ast.vhdl_assoc_element_t")
2048
  [@ocaml.warning "-A"])
2049

    
2050
and (vhdl_element_assoc_t_to_yojson :
2051
      vhdl_element_assoc_t -> Yojson.Safe.json)
2052
  =
2053
  ((let open! Ppx_deriving_yojson_runtime in
2054
      fun x  ->
2055
        let fields = []  in
2056
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
2057
          :: fields  in
2058
        let fields =
2059
          if x.choices = []
2060
          then fields
2061
          else
2062
            ("choices",
2063
              (((fun x  ->
2064
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
2065
                 x.choices))
2066
            :: fields
2067
           in
2068
        `Assoc fields)
2069
  [@ocaml.warning "-A"])
2070

    
2071
and (vhdl_element_assoc_t_of_yojson :
2072
      Yojson.Safe.json ->
2073
        vhdl_element_assoc_t Ppx_deriving_yojson_runtime.error_or)
2074
  =
2075
  ((let open! Ppx_deriving_yojson_runtime in
2076
      function
2077
      | `Assoc xs ->
2078
          let rec loop xs ((arg0,arg1) as _state) =
2079
            match xs with
2080
            | ("choices",x)::xs ->
2081
                loop xs
2082
                  (((function
2083
                     | `List xs ->
2084
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
2085
                     | _ ->
2086
                         Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices")
2087
                      x), arg1)
2088
            | ("expr",x)::xs ->
2089
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
2090
            | [] ->
2091
                arg1 >>=
2092
                  ((fun arg1  ->
2093
                      arg0 >>=
2094
                        (fun arg0  ->
2095
                           Result.Ok { choices = arg0; expr = arg1 })))
2096
            | _::xs -> loop xs _state  in
2097
          loop xs
2098
            ((Result.Ok []),
2099
              (Result.Error "Vhdl_ast.vhdl_element_assoc_t.expr"))
2100
      | _ -> Result.Error "Vhdl_ast.vhdl_element_assoc_t")
2101
  [@ocaml.warning "-A"])
2102

    
2103
and (vhdl_array_attributes_t_to_yojson :
2104
      vhdl_array_attributes_t -> Yojson.Safe.json)
2105
  =
2106
  ((let open! Ppx_deriving_yojson_runtime in
2107
      function
2108
      | AAttInt arg0 ->
2109
          `List
2110
            [`String "AAttInt";
2111
            (let fields = []  in
2112
             let fields =
2113
               ("arg",
2114
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
2115
               :: fields  in
2116
             let fields =
2117
               ("id",
2118
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2119
                    arg0.id))
2120
               :: fields  in
2121
             `Assoc fields)]
2122
      | AAttAscending  -> `List [`String "AAttAscending"])
2123
  [@ocaml.warning "-A"])
2124

    
2125
and (vhdl_array_attributes_t_of_yojson :
2126
      Yojson.Safe.json ->
2127
        vhdl_array_attributes_t Ppx_deriving_yojson_runtime.error_or)
2128
  =
2129
  ((let open! Ppx_deriving_yojson_runtime in
2130
      function
2131
      | `List ((`String "AAttInt")::arg0::[]) ->
2132
          ((function
2133
            | `Assoc xs ->
2134
                let rec loop xs ((arg0,arg1) as _state) =
2135
                  match xs with
2136
                  | ("id",x)::xs ->
2137
                      loop xs
2138
                        (((function
2139
                           | `String x -> Result.Ok x
2140
                           | _ ->
2141
                               Result.Error
2142
                                 "Vhdl_ast.vhdl_array_attributes_t.id") x),
2143
                          arg1)
2144
                  | ("arg",x)::xs ->
2145
                      loop xs
2146
                        (arg0,
2147
                          ((function
2148
                            | `Int x -> Result.Ok x
2149
                            | _ ->
2150
                                Result.Error
2151
                                  "Vhdl_ast.vhdl_array_attributes_t.arg") x))
2152
                  | [] ->
2153
                      arg1 >>=
2154
                        ((fun arg1  ->
2155
                            arg0 >>=
2156
                              (fun arg0  ->
2157
                                 Result.Ok
2158
                                   (AAttInt { id = arg0; arg = arg1 }))))
2159
                  | _::xs -> loop xs _state  in
2160
                loop xs
2161
                  ((Result.Error "Vhdl_ast.vhdl_array_attributes_t.id"),
2162
                    (Result.Error "Vhdl_ast.vhdl_array_attributes_t.arg"))
2163
            | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")) arg0
2164
      | `List ((`String "AAttAscending")::[]) -> Result.Ok AAttAscending
2165
      | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")
2166
  [@ocaml.warning "-A"])
2167

    
2168
and (vhdl_signal_attributes_t_to_yojson :
2169
      vhdl_signal_attributes_t -> Yojson.Safe.json)
2170
  =
2171
  ((let open! Ppx_deriving_yojson_runtime in
2172
      function
2173
      | SigAtt arg0 ->
2174
          `List
2175
            [`String "SigAtt";
2176
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
2177
  [@ocaml.warning "-A"])
2178

    
2179
and (vhdl_signal_attributes_t_of_yojson :
2180
      Yojson.Safe.json ->
2181
        vhdl_signal_attributes_t Ppx_deriving_yojson_runtime.error_or)
2182
  =
2183
  ((let open! Ppx_deriving_yojson_runtime in
2184
      function
2185
      | `List ((`String "SigAtt")::arg0::[]) ->
2186
          ((function
2187
            | `String x -> Result.Ok x
2188
            | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t") arg0)
2189
            >>= ((fun arg0  -> Result.Ok (SigAtt arg0)))
2190
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t")
2191
  [@ocaml.warning "-A"])
2192

    
2193
and (vhdl_string_attributes_t_to_yojson :
2194
      vhdl_string_attributes_t -> Yojson.Safe.json)
2195
  =
2196
  ((let open! Ppx_deriving_yojson_runtime in
2197
      function
2198
      | StringAtt arg0 ->
2199
          `List
2200
            [`String "StringAtt";
2201
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
2202
  [@ocaml.warning "-A"])
2203

    
2204
and (vhdl_string_attributes_t_of_yojson :
2205
      Yojson.Safe.json ->
2206
        vhdl_string_attributes_t Ppx_deriving_yojson_runtime.error_or)
2207
  =
2208
  ((let open! Ppx_deriving_yojson_runtime in
2209
      function
2210
      | `List ((`String "StringAtt")::arg0::[]) ->
2211
          ((function
2212
            | `String x -> Result.Ok x
2213
            | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t") arg0)
2214
            >>= ((fun arg0  -> Result.Ok (StringAtt arg0)))
2215
      | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t")
2216
  [@ocaml.warning "-A"])
2217

    
2218
and (vhdl_suffix_selection_t_to_yojson :
2219
      vhdl_suffix_selection_t -> Yojson.Safe.json)
2220
  =
2221
  ((let open! Ppx_deriving_yojson_runtime in
2222
      function
2223
      | Idx arg0 ->
2224
          `List
2225
            [`String "Idx";
2226
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0]
2227
      | SuffixRange (arg0,arg1) ->
2228
          `List
2229
            [`String "SuffixRange";
2230
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
2231
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1])
2232
  [@ocaml.warning "-A"])
2233

    
2234
and (vhdl_suffix_selection_t_of_yojson :
2235
      Yojson.Safe.json ->
2236
        vhdl_suffix_selection_t Ppx_deriving_yojson_runtime.error_or)
2237
  =
2238
  ((let open! Ppx_deriving_yojson_runtime in
2239
      function
2240
      | `List ((`String "Idx")::arg0::[]) ->
2241
          ((function
2242
            | `Int x -> Result.Ok x
2243
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg0) >>=
2244
            ((fun arg0  -> Result.Ok (Idx arg0)))
2245
      | `List ((`String "SuffixRange")::arg0::arg1::[]) ->
2246
          ((function
2247
            | `Int x -> Result.Ok x
2248
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg1) >>=
2249
            ((fun arg1  ->
2250
                ((function
2251
                  | `Int x -> Result.Ok x
2252
                  | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2253
                   arg0)
2254
                  >>= (fun arg0  -> Result.Ok (SuffixRange (arg0, arg1)))))
2255
      | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2256
  [@ocaml.warning "-A"])
2257

    
2258
type 'basetype vhdl_type_attributes_t =
2259
  | TAttNoArg of {
2260
  id: string } 
2261
  | TAttIntArg of {
2262
  id: string ;
2263
  arg: int } 
2264
  | TAttValArg of {
2265
  id: string ;
2266
  arg: 'basetype } 
2267
  | TAttStringArg of {
2268
  id: string ;
2269
  arg: string } 
2270

    
2271
(* TODO *)
2272
let rec pp_vhdl_type_attributes_t
2273
  =
2274
  ((let open! Ppx_deriving_runtime in
2275
      fun poly_basetype  ->
2276
        fun fmt  ->
2277
          function
2278
          | TAttNoArg { id = aid } ->
2279
              (Format.fprintf fmt "@[<2>TAttNoArg {@,";
2280
               (Format.fprintf fmt "@[%s =@ " "id";
2281
                (Format.fprintf fmt "%S") aid;
2282
                Format.fprintf fmt "@]");
2283
               Format.fprintf fmt "@]}")
2284
          | TAttIntArg { id = aid; arg = aarg } ->
2285
              (Format.fprintf fmt "@[<2>TAttIntArg {@,";
2286
               ((Format.fprintf fmt "@[%s =@ " "id";
2287
                 (Format.fprintf fmt "%S") aid;
2288
                 Format.fprintf fmt "@]");
2289
                Format.fprintf fmt ";@ ";
2290
                Format.fprintf fmt "@[%s =@ " "arg";
2291
                (Format.fprintf fmt "%d") aarg;
2292
                Format.fprintf fmt "@]");
2293
               Format.fprintf fmt "@]}")
2294
          | TAttValArg { id = aid; arg = aarg } ->
2295
              (Format.fprintf fmt "@[<2>TAttValArg {@,";
2296
               ((Format.fprintf fmt "@[%s =@ " "id";
2297
                 (Format.fprintf fmt "%S") aid;
2298
                 Format.fprintf fmt "@]");
2299
                Format.fprintf fmt ";@ ";
2300
                Format.fprintf fmt "@[%s =@ " "arg";
2301
                (poly_basetype fmt) aarg;
2302
                Format.fprintf fmt "@]");
2303
               Format.fprintf fmt "@]}")
2304
          | TAttStringArg { id = aid; arg = aarg } ->
2305
              (Format.fprintf fmt "@[<2>TAttStringArg {@,";
2306
               ((Format.fprintf fmt "@[%s =@ " "id";
2307
                 (Format.fprintf fmt "%S") aid;
2308
                 Format.fprintf fmt "@]");
2309
                Format.fprintf fmt ";@ ";
2310
                Format.fprintf fmt "@[%s =@ " "arg";
2311
                (Format.fprintf fmt "%S") aarg;
2312
                Format.fprintf fmt "@]");
2313
               Format.fprintf fmt "@]}"))
2314
  [@ocaml.warning "-A"])
2315

    
2316
and show_vhdl_type_attributes_t  =
2317
  fun poly_basetype  ->
2318
    fun x  ->
2319
      Format.asprintf "%a" (pp_vhdl_type_attributes_t poly_basetype) x
2320

    
2321
let rec vhdl_type_attributes_t_to_yojson :
2322
  'basetype .
2323
    ('basetype -> Yojson.Safe.json) ->
2324
      'basetype vhdl_type_attributes_t -> Yojson.Safe.json
2325
  =
2326
  fun poly_basetype  ->
2327
    ((let open! Ppx_deriving_yojson_runtime in
2328
        function
2329
        | TAttNoArg arg0 ->
2330
            `List
2331
              [`String "TAttNoArg";
2332
              (let fields = []  in
2333
               let fields =
2334
                 ("id",
2335
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2336
                      arg0.id))
2337
                 :: fields  in
2338
               `Assoc fields)]
2339
        | TAttIntArg arg0 ->
2340
            `List
2341
              [`String "TAttIntArg";
2342
              (let fields = []  in
2343
               let fields =
2344
                 ("arg",
2345
                   ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
2346
                 :: fields  in
2347
               let fields =
2348
                 ("id",
2349
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2350
                      arg0.id))
2351
                 :: fields  in
2352
               `Assoc fields)]
2353
        | TAttValArg arg0 ->
2354
            `List
2355
              [`String "TAttValArg";
2356
              (let fields = []  in
2357
               let fields =
2358
                 ("arg", ((poly_basetype : _ -> Yojson.Safe.json) arg0.arg))
2359
                 :: fields  in
2360
               let fields =
2361
                 ("id",
2362
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2363
                      arg0.id))
2364
                 :: fields  in
2365
               `Assoc fields)]
2366
        | TAttStringArg arg0 ->
2367
            `List
2368
              [`String "TAttStringArg";
2369
              (let fields = []  in
2370
               let fields =
2371
                 ("arg",
2372
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2373
                      arg0.arg))
2374
                 :: fields  in
2375
               let fields =
2376
                 ("id",
2377
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2378
                      arg0.id))
2379
                 :: fields  in
2380
               `Assoc fields)])
2381
    [@ocaml.warning "-A"])
2382

    
2383
and vhdl_type_attributes_t_of_yojson :
2384
  'basetype .
2385
    (Yojson.Safe.json -> 'basetype Ppx_deriving_yojson_runtime.error_or) ->
2386
      Yojson.Safe.json ->
2387
        'basetype vhdl_type_attributes_t Ppx_deriving_yojson_runtime.error_or
2388
  =
2389
  fun poly_basetype  ->
2390
    ((let open! Ppx_deriving_yojson_runtime in
2391
        function
2392
        | `List ((`String "TAttNoArg")::arg0::[]) ->
2393
            ((function
2394
              | `Assoc xs ->
2395
                  let rec loop xs (arg0 as _state) =
2396
                    match xs with
2397
                    | ("id",x)::xs ->
2398
                        loop xs
2399
                          ((function
2400
                            | `String x -> Result.Ok x
2401
                            | _ ->
2402
                                Result.Error
2403
                                  "Vhdl_ast.vhdl_type_attributes_t.id") x)
2404
                    | [] ->
2405
                        arg0 >>=
2406
                          ((fun arg0  -> Result.Ok (TAttNoArg { id = arg0 })))
2407
                    | _::xs -> loop xs _state  in
2408
                  loop xs (Result.Error "Vhdl_ast.vhdl_type_attributes_t.id")
2409
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2410
        | `List ((`String "TAttIntArg")::arg0::[]) ->
2411
            ((function
2412
              | `Assoc xs ->
2413
                  let rec loop xs ((arg0,arg1) as _state) =
2414
                    match xs with
2415
                    | ("id",x)::xs ->
2416
                        loop xs
2417
                          (((function
2418
                             | `String x -> Result.Ok x
2419
                             | _ ->
2420
                                 Result.Error
2421
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2422
                            arg1)
2423
                    | ("arg",x)::xs ->
2424
                        loop xs
2425
                          (arg0,
2426
                            ((function
2427
                              | `Int x -> Result.Ok x
2428
                              | _ ->
2429
                                  Result.Error
2430
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2431
                    | [] ->
2432
                        arg1 >>=
2433
                          ((fun arg1  ->
2434
                              arg0 >>=
2435
                                (fun arg0  ->
2436
                                   Result.Ok
2437
                                     (TAttIntArg { id = arg0; arg = arg1 }))))
2438
                    | _::xs -> loop xs _state  in
2439
                  loop xs
2440
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2441
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2442
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2443
        | `List ((`String "TAttValArg")::arg0::[]) ->
2444
            ((function
2445
              | `Assoc xs ->
2446
                  let rec loop xs ((arg0,arg1) as _state) =
2447
                    match xs with
2448
                    | ("id",x)::xs ->
2449
                        loop xs
2450
                          (((function
2451
                             | `String x -> Result.Ok x
2452
                             | _ ->
2453
                                 Result.Error
2454
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2455
                            arg1)
2456
                    | ("arg",x)::xs ->
2457
                        loop xs
2458
                          (arg0,
2459
                            ((poly_basetype : Yojson.Safe.json -> _ error_or)
2460
                               x))
2461
                    | [] ->
2462
                        arg1 >>=
2463
                          ((fun arg1  ->
2464
                              arg0 >>=
2465
                                (fun arg0  ->
2466
                                   Result.Ok
2467
                                     (TAttValArg { id = arg0; arg = arg1 }))))
2468
                    | _::xs -> loop xs _state  in
2469
                  loop xs
2470
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2471
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2472
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2473
        | `List ((`String "TAttStringArg")::arg0::[]) ->
2474
            ((function
2475
              | `Assoc xs ->
2476
                  let rec loop xs ((arg0,arg1) as _state) =
2477
                    match xs with
2478
                    | ("id",x)::xs ->
2479
                        loop xs
2480
                          (((function
2481
                             | `String x -> Result.Ok x
2482
                             | _ ->
2483
                                 Result.Error
2484
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2485
                            arg1)
2486
                    | ("arg",x)::xs ->
2487
                        loop xs
2488
                          (arg0,
2489
                            ((function
2490
                              | `String x -> Result.Ok x
2491
                              | _ ->
2492
                                  Result.Error
2493
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2494
                    | [] ->
2495
                        arg1 >>=
2496
                          ((fun arg1  ->
2497
                              arg0 >>=
2498
                                (fun arg0  ->
2499
                                   Result.Ok
2500
                                     (TAttStringArg { id = arg0; arg = arg1 }))))
2501
                    | _::xs -> loop xs _state  in
2502
                  loop xs
2503
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2504
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2505
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2506
        | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")
2507
    [@ocaml.warning "-A"])
2508

    
2509
let typ_att_noarg = ["base"; "left"; "right"; "high"; "low"] 
2510
let typ_att_intarg = ["pos"; "val"; "succ"; "pred"; "leftof"; "rightof"] 
2511
let typ_att_valarg = ["image"] 
2512
let typ_att_stringarg = ["value"] 
2513
let array_att_intarg =
2514
  ["left"; "right"; "high"; "low"; "range"; "reverse_range"; "length"] 
2515
type vhdl_parameter_t =
2516
  {
2517
  names: vhdl_name_t list ;
2518
  mode: string list [@default []];
2519
  typ: vhdl_subtype_indication_t ;
2520
  init_val: vhdl_cst_val_t option [@default None]}
2521

    
2522
(* TODO *)
2523
let rec pp_vhdl_parameter_t :
2524
  Format.formatter -> vhdl_parameter_t -> Ppx_deriving_runtime.unit =
2525
  let __2 () = pp_vhdl_cst_val_t
2526
  
2527
  and __1 () = pp_vhdl_subtype_indication_t
2528
  
2529
  and __0 () = pp_vhdl_name_t
2530
   in
2531
  ((let open! Ppx_deriving_runtime in
2532
      fun fmt  ->
2533
        fun x  ->
2534
          Format.fprintf fmt "@[<2>{ ";
2535
          ((((Format.fprintf fmt "@[%s =@ " "names";
2536
              ((fun x  ->
2537
                  Format.fprintf fmt "@[<2>[";
2538
                  ignore
2539
                    (List.fold_left
2540
                       (fun sep  ->
2541
                          fun x  ->
2542
                            if sep then Format.fprintf fmt ";@ ";
2543
                            ((__0 ()) fmt) x;
2544
                            true) false x);
2545
                  Format.fprintf fmt "@,]@]")) x.names;
2546
              Format.fprintf fmt "@]");
2547
             Format.fprintf fmt ";@ ";
2548
             Format.fprintf fmt "@[%s =@ " "mode";
2549
             ((fun x  ->
2550
                 Format.fprintf fmt "@[<2>[";
2551
                 ignore
2552
                   (List.fold_left
2553
                      (fun sep  ->
2554
                         fun x  ->
2555
                           if sep then Format.fprintf fmt ";@ ";
2556
                           (Format.fprintf fmt "%S") x;
2557
                           true) false x);
2558
                 Format.fprintf fmt "@,]@]")) x.mode;
2559
             Format.fprintf fmt "@]");
2560
            Format.fprintf fmt ";@ ";
2561
            Format.fprintf fmt "@[%s =@ " "typ";
2562
            ((__1 ()) fmt) x.typ;
2563
            Format.fprintf fmt "@]");
2564
           Format.fprintf fmt ";@ ";
2565
           Format.fprintf fmt "@[%s =@ " "init_val";
2566
           ((function
2567
             | None  -> Format.pp_print_string fmt "None"
2568
             | Some x ->
2569
                 (Format.pp_print_string fmt "(Some ";
2570
                  ((__2 ()) fmt) x;
2571
                  Format.pp_print_string fmt ")"))) x.init_val;
2572
           Format.fprintf fmt "@]");
2573
          Format.fprintf fmt "@ }@]")
2574
    [@ocaml.warning "-A"])
2575

    
2576
and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string =
2577
  fun x  -> Format.asprintf "%a" pp_vhdl_parameter_t x
2578

    
2579
let rec (vhdl_parameter_t_to_yojson : vhdl_parameter_t -> Yojson.Safe.json) =
2580
  ((let open! Ppx_deriving_yojson_runtime in
2581
      fun x  ->
2582
        let fields = []  in
2583
        let fields =
2584
          if x.init_val = None
2585
          then fields
2586
          else
2587
            ("init_val",
2588
              (((function
2589
                 | None  -> `Null
2590
                 | Some x -> ((fun x  -> vhdl_cst_val_t_to_yojson x)) x))
2591
                 x.init_val))
2592
            :: fields
2593
           in
2594
        let fields =
2595
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
2596
          :: fields  in
2597
        let fields =
2598
          if x.mode = []
2599
          then fields
2600
          else
2601
            ("mode",
2602
              (((fun x  ->
2603
                   `List
2604
                     (List.map
2605
                        (fun (x : Ppx_deriving_runtime.string)  -> `String x)
2606
                        x))) x.mode))
2607
            :: fields
2608
           in
2609
        let fields =
2610
          ("names",
2611
            ((fun x  ->
2612
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
2613
               x.names))
2614
          :: fields  in
2615
        `Assoc fields)
2616
  [@ocaml.warning "-A"])
2617

    
2618
and (vhdl_parameter_t_of_yojson :
2619
      Yojson.Safe.json ->
2620
        vhdl_parameter_t Ppx_deriving_yojson_runtime.error_or)
2621
  =
2622
  ((let open! Ppx_deriving_yojson_runtime in
2623
      function
2624
      | `Assoc xs ->
2625
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2626
            match xs with
2627
            | ("names",x)::xs ->
2628
                loop xs
2629
                  (((function
2630
                     | `List xs ->
2631
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
2632
                     | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.names") x),
2633
                    arg1, arg2, arg3)
2634
            | ("mode",x)::xs ->
2635
                loop xs
2636
                  (arg0,
2637
                    ((function
2638
                      | `List xs ->
2639
                          map_bind
2640
                            (function
2641
                             | `String x -> Result.Ok x
2642
                             | _ ->
2643
                                 Result.Error
2644
                                   "Vhdl_ast.vhdl_parameter_t.mode") [] xs
2645
                      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.mode") x),
2646
                    arg2, arg3)
2647
            | ("typ",x)::xs ->
2648
                loop xs
2649
                  (arg0, arg1,
2650
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
2651
                    arg3)
2652
            | ("init_val",x)::xs ->
2653
                loop xs
2654
                  (arg0, arg1, arg2,
2655
                    ((function
2656
                      | `Null -> Result.Ok None
2657
                      | x ->
2658
                          ((fun x  -> vhdl_cst_val_t_of_yojson x) x) >>=
2659
                            ((fun x  -> Result.Ok (Some x)))) x))
2660
            | [] ->
2661
                arg3 >>=
2662
                  ((fun arg3  ->
2663
                      arg2 >>=
2664
                        (fun arg2  ->
2665
                           arg1 >>=
2666
                             (fun arg1  ->
2667
                                arg0 >>=
2668
                                  (fun arg0  ->
2669
                                     Result.Ok
2670
                                       {
2671
                                         names = arg0;
2672
                                         mode = arg1;
2673
                                         typ = arg2;
2674
                                         init_val = arg3
2675
                                       })))))
2676
            | _::xs -> loop xs _state  in
2677
          loop xs
2678
            ((Result.Error "Vhdl_ast.vhdl_parameter_t.names"),
2679
              (Result.Ok []), (Result.Error "Vhdl_ast.vhdl_parameter_t.typ"),
2680
              (Result.Ok (Some (CstInt 0))))
2681
      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t")
2682
  [@ocaml.warning "-A"])
2683

    
2684
type vhdl_subprogram_spec_t =
2685
  {
2686
  name: string [@default ""];
2687
  subprogram_type: string [@default ""];
2688
  typeMark: vhdl_name_t [@default NoName];
2689
  parameters: vhdl_parameter_t list ;
2690
  isPure: bool [@default false]}
2691

    
2692
(* TODO *)
2693
let rec pp_vhdl_subprogram_spec_t :
2694
  Format.formatter -> vhdl_subprogram_spec_t -> Ppx_deriving_runtime.unit =
2695
  let __1 () = pp_vhdl_parameter_t
2696
  
2697
  and __0 () = pp_vhdl_name_t
2698
   in
2699
  ((let open! Ppx_deriving_runtime in
2700
      fun fmt  ->
2701
        fun x  ->
2702
          (match x.subprogram_type with
2703
          | "function" -> 
2704
              if (x.isPure) then
2705
                Format.fprintf fmt "pure %s" x.subprogram_type
2706
              else
2707
                Format.fprintf fmt "impure %s" x.subprogram_type
2708
          | "procedure" ->
2709
              Format.fprintf fmt "%s %s" x.subprogram_type x.name);
2710
          (match x.parameters with
2711
          | [] -> Format.fprintf fmt "";
2712
          | _ -> 
2713
            Format.fprintf fmt "(@[";
2714
            ((fun x  ->
2715
                ignore
2716
                  (List.fold_left
2717
                     (fun sep  ->
2718
                        fun x  ->
2719
                          if sep then Format.fprintf fmt ",@ ";
2720
                          ((__1 ()) fmt) x;
2721
                          true) false x))) x.parameters;
2722
            Format.fprintf fmt "@])");
2723
          (match x.typeMark with
2724
          | NoName -> Format.fprintf fmt "";
2725
          | _ -> 
2726
              Format.fprintf fmt "returns ";
2727
              ((__0 ()) fmt) x.typeMark))
2728
   [@ocaml.warning "-A"])
2729

    
2730
and show_vhdl_subprogram_spec_t :
2731
  vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string =
2732
  fun x  -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x
2733

    
2734
let rec (vhdl_subprogram_spec_t_to_yojson :
2735
          vhdl_subprogram_spec_t -> Yojson.Safe.json)
2736
  =
2737
  ((let open! Ppx_deriving_yojson_runtime in
2738
      fun x  ->
2739
        let fields = []  in
2740
        let fields =
2741
          if x.isPure = false
2742
          then fields
2743
          else
2744
            ("isPure",
2745
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x)) x.isPure))
2746
            :: fields
2747
           in
2748
        let fields =
2749
          if x.parameters = []
2750
          then fields
2751
          else
2752
            ("parameters",
2753
              (((fun x  ->
2754
                   `List
2755
                     (List.map (fun x  -> vhdl_parameter_t_to_yojson x) x)))
2756
                 x.parameters))
2757
            :: fields
2758
           in
2759
        let fields =
2760
          if x.typeMark = NoName
2761
          then fields
2762
          else
2763
            ("typeMark", (((fun x  -> vhdl_name_t_to_yojson x)) x.typeMark))
2764
            :: fields
2765
           in
2766
        let fields =
2767
          if x.subprogram_type = ""
2768
          then fields
2769
          else
2770
            ("subprogram_type",
2771
              (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
2772
                 x.subprogram_type))
2773
            :: fields
2774
           in
2775
        let fields =
2776
          if x.name = ""
2777
          then fields
2778
          else
2779
            ("name",
2780
              (((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x.name))
2781
            :: fields
2782
           in
2783
        `Assoc fields)
2784
  [@ocaml.warning "-A"])
2785

    
2786
and (vhdl_subprogram_spec_t_of_yojson :
2787
      Yojson.Safe.json ->
2788
        vhdl_subprogram_spec_t Ppx_deriving_yojson_runtime.error_or)
2789
  =
2790
  ((let open! Ppx_deriving_yojson_runtime in
2791
      function
2792
      | `Assoc xs ->
2793
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
2794
            match xs with
2795
            | ("name",x)::xs ->
2796
                loop xs
2797
                  (((function
2798
                     | `String x -> Result.Ok x
2799
                     | _ ->
2800
                         Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.name")
2801
                      x), arg1, arg2, arg3, arg4)
2802
            | ("subprogram_type",x)::xs ->
2803
                loop xs
2804
                  (arg0,
2805
                    ((function
2806
                      | `String x -> Result.Ok x
2807
                      | _ ->
2808
                          Result.Error
2809
                            "Vhdl_ast.vhdl_subprogram_spec_t.subprogram_type")
2810
                       x), arg2, arg3, arg4)
2811
            | ("typeMark",x)::xs ->
2812
                loop xs
2813
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
2814
                    arg4)
2815
            | ("parameters",x)::xs ->
2816
                loop xs
2817
                  (arg0, arg1, arg2,
2818
                    ((function
2819
                      | `List xs ->
2820
                          map_bind (fun x  -> vhdl_parameter_t_of_yojson x)
2821
                            [] xs
2822
                      | _ ->
2823
                          Result.Error
2824
                            "Vhdl_ast.vhdl_subprogram_spec_t.parameters") x),
2825
                    arg4)
2826
            | ("isPure",x)::xs ->
2827
                loop xs
2828
                  (arg0, arg1, arg2, arg3,
2829
                    ((function
2830
                      | `Bool x -> Result.Ok x
2831
                      | _ ->
2832
                          Result.Error
2833
                            "Vhdl_ast.vhdl_subprogram_spec_t.isPure") x))
2834
            | [] ->
2835
                arg4 >>=
2836
                  ((fun arg4  ->
2837
                      arg3 >>=
2838
                        (fun arg3  ->
2839
                           arg2 >>=
2840
                             (fun arg2  ->
2841
                                arg1 >>=
2842
                                  (fun arg1  ->
2843
                                     arg0 >>=
2844
                                       (fun arg0  ->
2845
                                          Result.Ok
2846
                                            {
2847
                                              name = arg0;
2848
                                              subprogram_type = arg1;
2849
                                              typeMark = arg2;
2850
                                              parameters = arg3;
2851
                                              isPure = arg4
2852
                                            }))))))
2853
            | _::xs -> loop xs _state  in
2854
          loop xs
2855
            ((Result.Ok ""), (Result.Ok ""), (Result.Ok NoName),
2856
              (Result.Ok []), (Result.Ok false))
2857
      | _ -> Result.Error "Vhdl_ast.vhdl_subprogram_spec_t")
2858
  [@ocaml.warning "-A"])
2859

    
2860
let arith_funs = ["+"; "-"; "*"; "/"; "mod"; "rem"; "abs"; "**"; "&"] 
2861
let bool_funs = ["and"; "or"; "nand"; "nor"; "xor"; "not"] 
2862
let rel_funs =
2863
  ["<";
2864
  ">";
2865
  "<=";
2866
  ">=";
2867
  "/=";
2868
  "=";
2869
  "?=";
2870
  "?/=";
2871
  "?<";
2872
  "?<=";
2873
  "?>";
2874
  "?>=";
2875
  "??"] 
2876
let shift_funs = ["sll"; "srl"; "sla"; "sra"; "rol"; "ror"] 
2877

    
2878
type vhdl_waveform_element_t =
2879
  {
2880
  value: vhdl_expr_t option [@default None];
2881
  delay: vhdl_expr_t option [@default None]}[@@deriving
2882
                                              ((show { with_path = false }),
2883
                                                (yojson { strict = false }))]
2884

    
2885
let rec pp_vhdl_waveform_element_t :
2886
  Format.formatter -> vhdl_waveform_element_t -> Ppx_deriving_runtime.unit =
2887
  let __1 () = pp_vhdl_expr_t
2888
  
2889
  and __0 () = pp_vhdl_expr_t
2890
   in
2891
  ((let open! Ppx_deriving_runtime in
2892
      fun fmt  ->
2893
        fun x  ->
2894
          (match x.value with
2895
          | None -> Format.fprintf fmt "";
2896
          | Some IsNull -> Format.fprintf fmt "null";
2897
          | Some v -> ((__0 ()) fmt) v);
2898
          (match x.delay with
2899
          | None -> Format.fprintf fmt "";
2900
          | Some v -> 
2901
              Format.fprintf fmt " after ";
2902
              ((__1 ()) fmt) v))
2903
    [@ocaml.warning "-A"])
2904

    
2905
and show_vhdl_waveform_element_t :
2906
  vhdl_waveform_element_t -> Ppx_deriving_runtime.string =
2907
  fun x  -> Format.asprintf "%a" pp_vhdl_waveform_element_t x
2908

    
2909
let rec (vhdl_waveform_element_t_to_yojson :
2910
          vhdl_waveform_element_t -> Yojson.Safe.json)
2911
  =
2912
  ((let open! Ppx_deriving_yojson_runtime in
2913
      fun x  ->
2914
        let fields = []  in
2915
        let fields =
2916
          if x.delay = None
2917
          then fields
2918
          else
2919
            ("delay",
2920
              (((function
2921
                 | None  -> `Null
2922
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
2923
                 x.delay))
2924
            :: fields
2925
           in
2926
        let fields =
2927
          if x.value = None
2928
          then fields
2929
          else
2930
            ("value",
2931
              (((function
2932
                 | None  -> `Null
2933
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
2934
                 x.value))
2935
            :: fields
2936
           in
2937
        `Assoc fields)
2938
  [@ocaml.warning "-A"])
2939

    
2940
and (vhdl_waveform_element_t_of_yojson :
2941
      Yojson.Safe.json ->
2942
        vhdl_waveform_element_t Ppx_deriving_yojson_runtime.error_or)
2943
  =
2944
  ((let open! Ppx_deriving_yojson_runtime in
2945
      function
2946
      | `Assoc xs ->
2947
          let rec loop xs ((arg0,arg1) as _state) =
2948
            match xs with
2949
            | ("value",x)::xs ->
2950
                loop xs
2951
                  (((function
2952
                     | `Null -> Result.Ok None
2953
                     | x ->
2954
                         ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
2955
                           ((fun x  -> Result.Ok (Some x)))) x), arg1)
2956
            | ("delay",x)::xs ->
2957
                loop xs
2958
                  (arg0,
2959
                    ((function
2960
                      | `Null -> Result.Ok None
2961
                      | x ->
2962
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
2963
                            ((fun x  -> Result.Ok (Some x)))) x))
2964
            | [] ->
2965
                arg1 >>=
2966
                  ((fun arg1  ->
2967
                      arg0 >>=
2968
                        (fun arg0  ->
2969
                           Result.Ok { value = arg0; delay = arg1 })))
2970
            | _::xs -> loop xs _state  in
2971
          loop xs ((Result.Ok None), (Result.Ok None))
2972
      | _ -> Result.Error "Vhdl_ast.vhdl_waveform_element_t")
2973
  [@ocaml.warning "-A"])
2974

    
2975
type vhdl_sequential_stmt_t =
2976
  | VarAssign of
2977
  {
2978
  label: vhdl_name_t [@default NoName];
2979
  lhs: vhdl_name_t ;
2980
  rhs: vhdl_expr_t } [@name "VARIABLE_ASSIGNMENT_STATEMENT"]
2981
  | SigSeqAssign of
2982
  {
2983
  label: vhdl_name_t [@default NoName];
2984
  lhs: vhdl_name_t ;
2985
  rhs: vhdl_waveform_element_t list } [@name "SIGNAL_ASSIGNMENT_STATEMENT"]
2986
  | If of
2987
  {
2988
  label: vhdl_name_t [@default NoName];
2989
  if_cases: vhdl_if_case_t list ;
2990
  default: vhdl_sequential_stmt_t list [@default []]} [@name "IF_STATEMENT"]
2991
  | Case of
2992
  {
2993
  label: vhdl_name_t [@default NoName];
2994
  guard: vhdl_expr_t ;
2995
  branches: vhdl_case_item_t list } [@name "CASE_STATEMENT_TREE"]
2996
  | Exit of
2997
  {
2998
  label: vhdl_name_t [@default NoName];
2999
  loop_label: string option [@default Some ""];
3000
  condition: vhdl_expr_t option [@default Some IsNull]}
3001
  [@name "EXIT_STATEMENT"]
3002
  | Assert of
3003
  {
3004
  label: vhdl_name_t [@default NoName];
3005
  cond: vhdl_expr_t ;
3006
  report: vhdl_expr_t [@default IsNull];
3007
  severity: vhdl_expr_t [@default IsNull]} [@name "ASSERTION_STATEMENT"]
3008
  | ProcedureCall of
3009
  {
3010
  label: vhdl_name_t [@default NoName];
3011
  name: vhdl_name_t ;
3012
  assocs: vhdl_assoc_element_t list } [@name "PROCEDURE_CALL_STATEMENT"]
3013
  | Wait [@name "WAIT_STATEMENT"]
3014
  | Null of {
3015
  label: vhdl_name_t [@default NoName]} [@name "NULL_STATEMENT"]
3016
  | Return of {
3017
  label: vhdl_name_t [@default NoName]} [@name "RETURN_STATEMENT"]
3018
and vhdl_if_case_t =
3019
  {
3020
  if_cond: vhdl_expr_t ;
3021
  if_block: vhdl_sequential_stmt_t list }
3022
and vhdl_case_item_t =
3023
  {
3024
  when_cond: vhdl_expr_t list ;
3025
  when_stmt: vhdl_sequential_stmt_t list }
3026

    
3027
let rec pp_vhdl_sequential_stmt_t :
3028
  Format.formatter -> vhdl_sequential_stmt_t -> Ppx_deriving_runtime.unit =
3029
  let __22 () = pp_vhdl_name_t
3030
  
3031
  and __21 () = pp_vhdl_name_t
3032
  
3033
  and __20 () = pp_vhdl_assoc_element_t
3034
  
3035
  and __19 () = pp_vhdl_name_t
3036
  
3037
  and __18 () = pp_vhdl_name_t
3038
  
3039
  and __17 () = pp_vhdl_expr_t
3040
  
3041
  and __16 () = pp_vhdl_expr_t
3042
  
3043
  and __15 () = pp_vhdl_expr_t
3044
  
3045
  and __14 () = pp_vhdl_name_t
3046
  
3047
  and __13 () = pp_vhdl_expr_t
3048
  
3049
  and __12 () = pp_vhdl_name_t
3050
  
3051
  and __11 () = pp_vhdl_case_item_t
3052
  
3053
  and __10 () = pp_vhdl_expr_t
3054
  
3055
  and __9 () = pp_vhdl_name_t
3056
  
3057
  and __8 () = pp_vhdl_sequential_stmt_t
3058
  
3059
  and __7 () = pp_vhdl_if_case_t
3060
  
3061
  and __6 () = pp_vhdl_name_t
3062
  
3063
  and __5 () = pp_vhdl_waveform_element_t
3064
  
3065
  and __4 () = pp_vhdl_name_t
3066
  
3067
  and __3 () = pp_vhdl_name_t
3068
  
3069
  and __2 () = pp_vhdl_expr_t
3070
  
3071
  and __1 () = pp_vhdl_name_t
3072
  
3073
  and __0 () = pp_vhdl_name_t
3074
   in
3075
  ((let open! Ppx_deriving_runtime in
3076
      fun fmt  ->
3077
        function
3078
        | VarAssign { label = alabel; lhs = alhs; rhs = arhs } ->
3079
            (match alabel with
3080
              | NoName -> Format.fprintf fmt "";
3081
              | _ -> (((__0 ()) fmt) alabel;
3082
                     Format.fprintf fmt ": ")
3083
            );
3084
            ((__1 ()) fmt) alhs;
3085
            Format.fprintf fmt " := ";
3086
            ((__2 ()) fmt) arhs;
3087
(* TODO: Check
3088
            (Format.fprintf fmt "@[<2>VarAssign {@,";
3089
             (((Format.fprintf fmt "@[%s =@ " "label";
3090
                ((__0 ()) fmt) alabel;
3091
                Format.fprintf fmt "@]");
3092
               Format.fprintf fmt ";@ ";
3093
               Format.fprintf fmt "@[%s =@ " "lhs";
3094
               ((__1 ()) fmt) alhs;
3095
               Format.fprintf fmt "@]");
3096
              Format.fprintf fmt ";@ ";
3097
              Format.fprintf fmt "@[%s =@ " "rhs";
3098
              ((__2 ()) fmt) arhs;
3099
              Format.fprintf fmt "@]");
3100
             Format.fprintf fmt "@]}") *)
3101
        | SigSeqAssign { label = alabel; lhs = alhs; rhs = arhs } ->
3102
            (match alabel with
3103
              | NoName -> Format.fprintf fmt "";
3104
              | _ -> (((__3 ()) fmt) alabel;
3105
                     Format.fprintf fmt ":@ ")
3106
            );
3107
            Format.fprintf fmt "@[<2>";
3108
            ((__4 ()) fmt) alhs;
3109
            Format.fprintf fmt "@ <=@ ";
3110
            ((fun x  ->
3111
               Format.fprintf fmt "@[";
3112
               ignore
3113
                 (List.fold_left
3114
                   (fun sep  ->
3115
                     fun x  ->
3116
                       if sep then Format.fprintf fmt "";
3117
                        ((__5 ()) fmt) x;
3118
                        true) false x);
3119
            Format.fprintf fmt "@]@]")) arhs;
3120
        | If { label = alabel; if_cases = aif_cases; default = adefault } ->
3121
            (match alabel with
3122
              | NoName -> Format.fprintf fmt "";
3123
              | _ -> (((__6 ()) fmt) alabel;
3124
                     Format.fprintf fmt ":@ ")
3125
            );
3126
            Format.fprintf fmt "@[<v>if";
3127
            ((fun x ->
3128
               ignore
3129
               (List.fold_left
3130
                 (fun sep  ->
3131
                   fun x  ->
3132
                           if sep then Format.fprintf fmt "@;elseif";
3133
                                ((__7 ()) fmt) x;
3134
                                true
3135
                 ) false x);
3136
             )) aif_cases;
3137
             (match adefault with
3138
              | [] -> Format.fprintf fmt "";
3139
              | _  -> (Format.fprintf fmt "@;else";
3140
                      ((fun x  ->
3141
                          Format.fprintf fmt "@;<0 2>";
3142
                          ignore
3143
                            (List.fold_left
3144
                              (fun sep  ->
3145
                                fun x  ->
3146
                                        if sep then Format.fprintf fmt "";
3147
                          ((__8 ()) fmt) x;
3148
                          true) false x))) adefault));
3149
            Format.fprintf fmt "@;end if@]"
3150
        | Case { label = alabel; guard = aguard; branches = abranches } ->
3151
            (match alabel with
3152
              | NoName -> Format.fprintf fmt "";
3153
              | _ -> (((__9 ()) fmt) alabel;
3154
                     Format.fprintf fmt ":@ ")
3155
            );
3156
            Format.fprintf fmt "@[<v>case ";
3157
            ((__10 ()) fmt) aguard;
3158
            Format.fprintf fmt " is";
3159
            ((fun x  ->
3160
                ignore
3161
                  (List.fold_left
3162
                     (fun sep  ->
3163
                        fun x  ->
3164
                          if sep then Format.fprintf fmt "";
3165
                          ((__11 ()) fmt) x;
3166
                          true) false x);)) abranches;
3167
            Format.fprintf fmt "@;end case@]";
3168
        | Exit
3169
            { label = alabel; loop_label = aloop_label;
3170
              condition = acondition }
3171
            ->
3172
            (match alabel with
3173
              | NoName -> Format.fprintf fmt "";
3174
              | _ -> (((__12 ()) fmt) alabel;
3175
                     Format.fprintf fmt ":@ ")
3176
            );
3177
            Format.fprintf fmt "exit";
3178
            (match aloop_label with
3179
               | None  -> Format.pp_print_string fmt ""
3180
               | Some x -> (Format.fprintf fmt "@ %s@ ") x);
3181
            ((function
3182
               | None  -> Format.pp_print_string fmt ""
3183
               | Some x ->
3184
                   (Format.pp_print_string fmt "when@ ";
3185
                    ((__13 ()) fmt) x;))) acondition;
3186
        | Assert
3187
            { label = alabel; cond = acond; report = areport;
3188
              severity = aseverity }
3189
            ->
3190
            Format.fprintf fmt "@[<v 2>";
3191
            (match alabel with
3192
              | NoName -> Format.fprintf fmt "";
3193
              | _ -> (((__14 ()) fmt) alabel;
3194
                     Format.fprintf fmt ":@ ")
3195
            );
3196
            Format.fprintf fmt "assert ";
3197
            ((__15 ()) fmt) acond;
3198
            (match areport with
3199
            | IsNull -> Format.fprintf fmt "";
3200
            | _ -> 
3201
                Format.fprintf fmt "@;report ";
3202
                ((__16 ()) fmt) areport);
3203
            (match aseverity with
3204
            | IsNull -> Format.fprintf fmt "";
3205
            | _ -> 
3206
                Format.fprintf fmt "@;severity ";
3207
                ((__17 ()) fmt) aseverity);
3208
            Format.fprintf fmt "@]";
3209
        | ProcedureCall { label = alabel; name = aname; assocs = aassocs } ->
3210
            (match alabel with
3211
              | NoName -> Format.fprintf fmt "";
3212
              | _ -> (((__18 ()) fmt) alabel;
3213
                     Format.fprintf fmt ":@ ")
3214
            );
3215
            ((__19 ()) fmt) aname;
3216
            (match aassocs with
3217
            | [] -> Format.fprintf fmt "";
3218
            | _ ->
3219
               ((fun x  ->
3220
                Format.fprintf fmt "(";
3221
                ignore
3222
                  (List.fold_left
3223
                     (fun sep  ->
3224
                        fun x  ->
3225
                          if sep then Format.fprintf fmt ",@ ";
3226
                          ((__20 ()) fmt) x;
3227
                          true) false x);
3228
              Format.fprintf fmt ")")) aassocs);
3229
        | Wait  -> Format.pp_print_string fmt "wait"
3230
        | Null { label = alabel } ->
3231
            (match alabel with
3232
              | NoName -> Format.fprintf fmt "";
3233
              | _ -> (((__18 ()) fmt) alabel;
3234
                     Format.fprintf fmt ":@ ")
3235
            );
3236
            Format.fprintf fmt "null";
3237
        | Return { label = alabel } ->
3238
            (match alabel with
3239
              | NoName -> Format.fprintf fmt "";
3240
              | _ -> (((__19 ()) fmt) alabel;
3241
                     Format.fprintf fmt ":@ ")
3242
            );
3243
            Format.fprintf fmt "return";)
3244
    [@ocaml.warning "-A"])
3245

    
3246
and show_vhdl_sequential_stmt_t :
3247
  vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string =
3248
  fun x  -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x
3249

    
3250
and pp_vhdl_if_case_t :
3251
  Format.formatter -> vhdl_if_case_t -> Ppx_deriving_runtime.unit =
3252
  let __1 () = pp_vhdl_sequential_stmt_t
3253
  
3254
  and __0 () = pp_vhdl_expr_t
3255
   in
3256
  ((let open! Ppx_deriving_runtime in
3257
      fun fmt  ->
3258
        fun x  ->
3259
          Format.fprintf fmt " (";
3260
          ((__0 ()) fmt) x.if_cond;
3261
          Format.fprintf fmt ") then@;<0 2>";
3262
          ((fun x  ->
3263
             ignore
3264
               (List.fold_left
3265
                  (fun sep  ->
3266
                     fun x  ->
3267
                             if sep then Format.fprintf fmt "@;<0 2>";
3268
                       ((__1 ()) fmt) x;
3269
                       true) false x);
3270
          )) x.if_block;)
3271
    [@ocaml.warning "-A"])
3272

    
3273
and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string =
3274
  fun x  -> Format.asprintf "%a" pp_vhdl_if_case_t x
3275

    
3276
and pp_vhdl_case_item_t :
3277
  Format.formatter -> vhdl_case_item_t -> Ppx_deriving_runtime.unit =
3278
  let __1 () = pp_vhdl_sequential_stmt_t
3279
  
3280
  and __0 () = pp_vhdl_expr_t
3281
   in
3282
  ((let open! Ppx_deriving_runtime in
3283
      fun fmt  ->
3284
        fun x  ->
3285
                Format.fprintf fmt "@;@[<v 2>when ";
3286
            ((fun x  ->
3287
                ignore
3288
                  (List.fold_left
3289
                     (fun sep  ->
3290
                        fun x  ->
3291
                          if sep then Format.fprintf fmt "@ |@ ";
3292
                          ((__0 ()) fmt) x;
3293
                          true) false x);)) x.when_cond;
3294
           Format.fprintf fmt " => ";
3295
           (fun x  ->
3296
               ignore
3297
                 (List.fold_left
3298
                    (fun sep  ->
3299
                       fun x  ->
3300
                         if sep then Format.fprintf fmt "@;";
3301
                         ((__1 ()) fmt) x;
3302
                         Format.fprintf fmt ";";
3303
                         true) ((List.length x) > 1) x);) x.when_stmt;
3304
           Format.fprintf fmt "@]")
3305
    [@ocaml.warning "-A"])
3306

    
3307
and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string =
3308
  fun x  -> Format.asprintf "%a" pp_vhdl_case_item_t x
3309

    
3310
let rec (vhdl_sequential_stmt_t_to_yojson :
3311
          vhdl_sequential_stmt_t -> Yojson.Safe.json)
3312
  =
3313
  ((let open! Ppx_deriving_yojson_runtime in
3314
      function
3315
      | VarAssign arg0 ->
3316
          `List
3317
            [`String "VARIABLE_ASSIGNMENT_STATEMENT";
3318
            (let fields = []  in
3319
             let fields =
3320
               ("rhs", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.rhs)) ::
3321
               fields  in
3322
             let fields =
3323
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
3324
               fields  in
3325
             let fields =
3326
               if arg0.label = NoName
3327
               then fields
3328
               else
3329
                 ("label",
3330
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3331
                 :: fields
3332
                in
3333
             `Assoc fields)]
3334
      | SigSeqAssign arg0 ->
3335
          `List
3336
            [`String "SIGNAL_ASSIGNMENT_STATEMENT";
3337
            (let fields = []  in
3338
             let fields =
3339
               ("rhs",
3340
                 ((fun x  ->
3341
                     `List
3342
                       (List.map
3343
                          (fun x  -> vhdl_waveform_element_t_to_yojson x) x))
3344
                    arg0.rhs))
3345
               :: fields  in
3346
             let fields =
3347
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
3348
               fields  in
3349
             let fields =
3350
               if arg0.label = NoName
3351
               then fields
3352
               else
3353
                 ("label",
3354
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3355
                 :: fields
3356
                in
3357
             `Assoc fields)]
3358
      | If arg0 ->
3359
          `List
3360
            [`String "IF_STATEMENT";
3361
            (let fields = []  in
3362
             let fields =
3363
               if arg0.default = []
3364
               then fields
3365
               else
3366
                 ("default",
3367
                   (((fun x  ->
3368
                        `List
3369
                          (List.map
3370
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
3371
                      arg0.default))
3372
                 :: fields
3373
                in
3374
             let fields =
3375
               ("if_cases",
3376
                 ((fun x  ->
3377
                     `List
3378
                       (List.map (fun x  -> vhdl_if_case_t_to_yojson x) x))
3379
                    arg0.if_cases))
3380
               :: fields  in
3381
             let fields =
3382
               if arg0.label = NoName
3383
               then fields
3384
               else
3385
                 ("label",
3386
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3387
                 :: fields
3388
                in
3389
             `Assoc fields)]
3390
      | Case arg0 ->
3391
          `List
3392
            [`String "CASE_STATEMENT_TREE";
3393
            (let fields = []  in
3394
             let fields =
3395
               ("branches",
3396
                 ((fun x  ->
3397
                     `List
3398
                       (List.map (fun x  -> vhdl_case_item_t_to_yojson x) x))
3399
                    arg0.branches))
3400
               :: fields  in
3401
             let fields =
3402
               ("guard", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.guard)) ::
3403
               fields  in
3404
             let fields =
3405
               if arg0.label = NoName
3406
               then fields
3407
               else
3408
                 ("label",
3409
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3410
                 :: fields
3411
                in
3412
             `Assoc fields)]
3413
      | Exit arg0 ->
3414
          `List
3415
            [`String "EXIT_STATEMENT";
3416
            (let fields = []  in
3417
             let fields =
3418
               if arg0.condition = (Some IsNull)
3419
               then fields
3420
               else
3421
                 ("condition",
3422
                   (((function
3423
                      | None  -> `Null
3424
                      | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
3425
                      arg0.condition))
3426
                 :: fields
3427
                in
3428
             let fields =
3429
               if arg0.loop_label = (Some "")
3430
               then fields
3431
               else
3432
                 ("loop_label",
3433
                   (((function
3434
                      | None  -> `Null
3435
                      | Some x ->
3436
                          ((fun (x : Ppx_deriving_runtime.string)  ->
3437
                              `String x)) x)) arg0.loop_label))
3438
                 :: fields
3439
                in
3440
             let fields =
3441
               if arg0.label = NoName
3442
               then fields
3443
               else
3444
                 ("label",
3445
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3446
                 :: fields
3447
                in
3448
             `Assoc fields)]
3449
      | Assert arg0 ->
3450
          `List
3451
            [`String "ASSERTION_STATEMENT";
3452
            (let fields = []  in
3453
             let fields =
3454
               if arg0.severity = IsNull
3455
               then fields
3456
               else
3457
                 ("severity",
3458
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.severity))
3459
                 :: fields
3460
                in
3461
             let fields =
3462
               if arg0.report = IsNull
3463
               then fields
3464
               else
3465
                 ("report",
3466
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.report))
3467
                 :: fields
3468
                in
3469
             let fields =
3470
               ("cond", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.cond)) ::
3471
               fields  in
3472
             let fields =
3473
               if arg0.label = NoName
3474
               then fields
3475
               else
3476
                 ("label",
3477
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3478
                 :: fields
3479
                in
3480
             `Assoc fields)]
3481
      | ProcedureCall arg0 ->
3482
          `List
3483
            [`String "PROCEDURE_CALL_STATEMENT";
3484
            (let fields = []  in
3485
             let fields =
3486
               if arg0.assocs = []
3487
               then fields
3488
               else
3489
                 ("assocs",
3490
                   (((fun x  ->
3491
                        `List
3492
                          (List.map
3493
                             (fun x  -> vhdl_assoc_element_t_to_yojson x) x)))
3494
                      arg0.assocs))
3495
                 :: fields
3496
                in
3497
             let fields =
3498
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
3499
               fields  in
3500
             let fields =
3501
               if arg0.label = NoName
3502
               then fields
3503
               else
3504
                 ("label",
3505
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3506
                 :: fields
3507
                in
3508
             `Assoc fields)]
3509
      | Wait  -> `List [`String "WAIT_STATEMENT"]
3510
      | Null arg0 ->
3511
          `List
3512
            [`String "NULL_STATEMENT";
3513
            (let fields = []  in
3514
             let fields =
3515
               if arg0.label = NoName
3516
               then fields
3517
               else
3518
                 ("label",
3519
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3520
                 :: fields
3521
                in
3522
             `Assoc fields)]
3523
      | Return arg0 ->
3524
          `List
3525
            [`String "RETURN_STATEMENT";
3526
            (let fields = []  in
3527
             let fields =
3528
               if arg0.label = NoName
3529
               then fields
3530
               else
3531
                 ("label",
3532
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3533
                 :: fields
3534
                in
3535
             `Assoc fields)])
3536
  [@ocaml.warning "-A"])
3537

    
3538
and (vhdl_sequential_stmt_t_of_yojson :
3539
      Yojson.Safe.json ->
3540
        vhdl_sequential_stmt_t Ppx_deriving_yojson_runtime.error_or)
3541
  =
3542
  ((let open! Ppx_deriving_yojson_runtime in
3543
      function
3544
      | `List ((`String "VARIABLE_ASSIGNMENT_STATEMENT")::arg0::[]) ->
3545
          ((function
3546
            | `Assoc xs ->
3547
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3548
                  match xs with
3549
                  | ("label",x)::xs ->
3550
                      loop xs
3551
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3552
                  | ("lhs",x)::xs ->
3553
                      loop xs
3554
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3555
                  | ("rhs",x)::xs ->
3556
                      loop xs
3557
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
3558
                  | [] ->
3559
                      arg2 >>=
3560
                        ((fun arg2  ->
3561
                            arg1 >>=
3562
                              (fun arg1  ->
3563
                                 arg0 >>=
3564
                                   (fun arg0  ->
3565
                                      Result.Ok
3566
                                        (VarAssign
3567
                                           {
3568
                                             label = arg0;
3569
                                             lhs = arg1;
3570
                                             rhs = arg2
3571
                                           })))))
3572
                  | _::xs -> loop xs _state  in
3573
                loop xs
3574
                  ((Result.Ok NoName),
3575
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
3576
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
3577
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3578
      | `List ((`String "SIGNAL_ASSIGNMENT_STATEMENT")::arg0::[]) ->
3579
          ((function
3580
            | `Assoc xs ->
3581
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3582
                  match xs with
3583
                  | ("label",x)::xs ->
3584
                      loop xs
3585
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3586
                  | ("lhs",x)::xs ->
3587
                      loop xs
3588
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3589
                  | ("rhs",x)::xs ->
3590
                      loop xs
3591
                        (arg0, arg1,
3592
                          ((function
3593
                            | `List xs ->
3594
                                map_bind
3595
                                  (fun x  ->
3596
                                     vhdl_waveform_element_t_of_yojson x) []
3597
                                  xs
3598
                            | _ ->
3599
                                Result.Error
3600
                                  "Vhdl_ast.vhdl_sequential_stmt_t.rhs") x))
3601
                  | [] ->
3602
                      arg2 >>=
3603
                        ((fun arg2  ->
3604
                            arg1 >>=
3605
                              (fun arg1  ->
3606
                                 arg0 >>=
3607
                                   (fun arg0  ->
3608
                                      Result.Ok
3609
                                        (SigSeqAssign
3610
                                           {
3611
                                             label = arg0;
3612
                                             lhs = arg1;
3613
                                             rhs = arg2
3614
                                           })))))
3615
                  | _::xs -> loop xs _state  in
3616
                loop xs
3617
                  ((Result.Ok NoName),
3618
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
3619
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
3620
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3621
      | `List ((`String "IF_STATEMENT")::arg0::[]) ->
3622
          ((function
3623
            | `Assoc xs ->
3624
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3625
                  match xs with
3626
                  | ("label",x)::xs ->
3627
                      loop xs
3628
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3629
                  | ("if_cases",x)::xs ->
3630
                      loop xs
3631
                        (arg0,
3632
                          ((function
3633
                            | `List xs ->
3634
                                map_bind
3635
                                  (fun x  -> vhdl_if_case_t_of_yojson x) []
3636
                                  xs
3637
                            | _ ->
3638
                                Result.Error
3639
                                  "Vhdl_ast.vhdl_sequential_stmt_t.if_cases")
3640
                             x), arg2)
3641
                  | ("default",x)::xs ->
3642
                      loop xs
3643
                        (arg0, arg1,
3644
                          ((function
3645
                            | `List xs ->
3646
                                map_bind
3647
                                  (fun x  ->
3648
                                     vhdl_sequential_stmt_t_of_yojson x) []
3649
                                  xs
3650
                            | _ ->
3651
                                Result.Error
3652
                                  "Vhdl_ast.vhdl_sequential_stmt_t.default")
3653
                             x))
3654
                  | [] ->
3655
                      arg2 >>=
3656
                        ((fun arg2  ->
3657
                            arg1 >>=
3658
                              (fun arg1  ->
3659
                                 arg0 >>=
3660
                                   (fun arg0  ->
3661
                                      Result.Ok
3662
                                        (If
3663
                                           {
3664
                                             label = arg0;
3665
                                             if_cases = arg1;
3666
                                             default = arg2
3667
                                           })))))
3668
                  | _::xs -> loop xs _state  in
3669
                loop xs
3670
                  ((Result.Ok NoName),
3671
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.if_cases"),
3672
                    (Result.Ok []))
3673
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3674
      | `List ((`String "CASE_STATEMENT_TREE")::arg0::[]) ->
3675
          ((function
3676
            | `Assoc xs ->
3677
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3678
                  match xs with
3679
                  | ("label",x)::xs ->
3680
                      loop xs
3681
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3682
                  | ("guard",x)::xs ->
3683
                      loop xs
3684
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
3685
                  | ("branches",x)::xs ->
3686
                      loop xs
3687
                        (arg0, arg1,
3688
                          ((function
3689
                            | `List xs ->
3690
                                map_bind
3691
                                  (fun x  -> vhdl_case_item_t_of_yojson x) []
3692
                                  xs
3693
                            | _ ->
3694
                                Result.Error
3695
                                  "Vhdl_ast.vhdl_sequential_stmt_t.branches")
3696
                             x))
3697
                  | [] ->
3698
                      arg2 >>=
3699
                        ((fun arg2  ->
3700
                            arg1 >>=
3701
                              (fun arg1  ->
3702
                                 arg0 >>=
3703
                                   (fun arg0  ->
3704
                                      Result.Ok
3705
                                        (Case
3706
                                           {
3707
                                             label = arg0;
3708
                                             guard = arg1;
3709
                                             branches = arg2
3710
                                           })))))
3711
                  | _::xs -> loop xs _state  in
3712
                loop xs
3713
                  ((Result.Ok NoName),
3714
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.guard"),
3715
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.branches"))
3716
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3717
      | `List ((`String "EXIT_STATEMENT")::arg0::[]) ->
3718
          ((function
3719
            | `Assoc xs ->
3720
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3721
                  match xs with
3722
                  | ("label",x)::xs ->
3723
                      loop xs
3724
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3725
                  | ("loop_label",x)::xs ->
3726
                      loop xs
3727
                        (arg0,
3728
                          ((function
3729
                            | `Null -> Result.Ok None
3730
                            | x ->
3731
                                ((function
3732
                                  | `String x -> Result.Ok x
3733
                                  | _ ->
3734
                                      Result.Error
3735
                                        "Vhdl_ast.vhdl_sequential_stmt_t.loop_label")
3736
                                   x)
3737
                                  >>= ((fun x  -> Result.Ok (Some x)))) x),
3738
                          arg2)
3739
                  | ("condition",x)::xs ->
3740
                      loop xs
3741
                        (arg0, arg1,
3742
                          ((function
3743
                            | `Null -> Result.Ok None
3744
                            | x ->
3745
                                ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
3746
                                  ((fun x  -> Result.Ok (Some x)))) x))
3747
                  | [] ->
3748
                      arg2 >>=
3749
                        ((fun arg2  ->
3750
                            arg1 >>=
3751
                              (fun arg1  ->
3752
                                 arg0 >>=
3753
                                   (fun arg0  ->
3754
                                      Result.Ok
3755
                                        (Exit
3756
                                           {
3757
                                             label = arg0;
3758
                                             loop_label = arg1;
3759
                                             condition = arg2
3760
                                           })))))
3761
                  | _::xs -> loop xs _state  in
3762
                loop xs
3763
                  ((Result.Ok NoName), (Result.Ok (Some "")),
3764
                    (Result.Ok (Some IsNull)))
3765
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3766
      | `List ((`String "ASSERTION_STATEMENT")::arg0::[]) ->
3767
          ((function
3768
            | `Assoc xs ->
3769
                let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
3770
                  match xs with
3771
                  | ("label",x)::xs ->
3772
                      loop xs
3773
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2,
3774
                          arg3)
3775
                  | ("cond",x)::xs ->
3776
                      loop xs
3777
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2,
3778
                          arg3)
3779
                  | ("report",x)::xs ->
3780
                      loop xs
3781
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x),
3782
                          arg3)
3783
                  | ("severity",x)::xs ->
3784
                      loop xs
3785
                        (arg0, arg1, arg2,
3786
                          ((fun x  -> vhdl_expr_t_of_yojson x) x))
3787
                  | [] ->
3788
                      arg3 >>=
3789
                        ((fun arg3  ->
3790
                            arg2 >>=
3791
                              (fun arg2  ->
3792
                                 arg1 >>=
3793
                                   (fun arg1  ->
3794
                                      arg0 >>=
3795
                                        (fun arg0  ->
3796
                                           Result.Ok
3797
                                             (Assert
3798
                                                {
3799
                                                  label = arg0;
3800
                                                  cond = arg1;
3801
                                                  report = arg2;
3802
                                                  severity = arg3
3803
                                                }))))))
3804
                  | _::xs -> loop xs _state  in
3805
                loop xs
3806
                  ((Result.Ok NoName),
3807
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.cond"),
3808
                    (Result.Ok IsNull), (Result.Ok IsNull))
3809
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3810
      | `List ((`String "PROCEDURE_CALL_STATEMENT")::arg0::[]) ->
3811
          ((function
3812
            | `Assoc xs ->
3813
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3814
                  match xs with
3815
                  | ("label",x)::xs ->
3816
                      loop xs
3817
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3818
                  | ("name",x)::xs ->
3819
                      loop xs
3820
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3821
                  | ("assocs",x)::xs ->
3822
                      loop xs
3823
                        (arg0, arg1,
3824
                          ((function
3825
                            | `List xs ->
3826
                                map_bind
3827
                                  (fun x  -> vhdl_assoc_element_t_of_yojson x)
3828
                                  [] xs
3829
                            | _ ->
3830
                                Result.Error
3831
                                  "Vhdl_ast.vhdl_sequential_stmt_t.assocs") x))
3832
                  | [] ->
3833
                      arg2 >>=
3834
                        ((fun arg2  ->
3835
                            arg1 >>=
3836
                              (fun arg1  ->
3837
                                 arg0 >>=
3838
                                   (fun arg0  ->
3839
                                      Result.Ok
3840
                                        (ProcedureCall
3841
                                           {
3842
                                             label = arg0;
3843
                                             name = arg1;
3844
                                             assocs = arg2
3845
                                           })))))
3846
                  | _::xs -> loop xs _state  in
3847
                loop xs
3848
                  ((Result.Ok NoName),
3849
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.name"),
3850
                    (Result.Ok []))
3851
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3852
      | `List ((`String "WAIT_STATEMENT")::[]) -> Result.Ok Wait
3853
      | `List ((`String "NULL_STATEMENT")::arg0::[]) ->
3854
          ((function
3855
            | `Assoc xs ->
3856
                let rec loop xs (arg0 as _state) =
3857
                  match xs with
3858
                  | ("label",x)::xs ->
3859
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
3860
                  | [] ->
3861
                      arg0 >>=
3862
                        ((fun arg0  -> Result.Ok (Null { label = arg0 })))
3863
                  | _::xs -> loop xs _state  in
3864
                loop xs (Result.Ok NoName)
3865
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3866
      | `List ((`String "RETURN_STATEMENT")::arg0::[]) ->
3867
          ((function
3868
            | `Assoc xs ->
3869
                let rec loop xs (arg0 as _state) =
3870
                  match xs with
3871
                  | ("label",x)::xs ->
3872
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
3873
                  | [] ->
3874
                      arg0 >>=
3875
                        ((fun arg0  -> Result.Ok (Return { label = arg0 })))
3876
                  | _::xs -> loop xs _state  in
3877
                loop xs (Result.Ok NoName)
3878
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3879
      | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")
3880
  [@ocaml.warning "-A"])
3881

    
3882
and (vhdl_if_case_t_to_yojson : vhdl_if_case_t -> Yojson.Safe.json) =
3883
  ((let open! Ppx_deriving_yojson_runtime in
3884
      fun x  ->
3885
        let fields = []  in
3886
        let fields =
3887
          ("if_block",
3888
            ((fun x  ->
3889
                `List
3890
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3891
               x.if_block))
3892
          :: fields  in
3893
        let fields =
3894
          ("if_cond", ((fun x  -> vhdl_expr_t_to_yojson x) x.if_cond)) ::
3895
          fields  in
3896
        `Assoc fields)
3897
  [@ocaml.warning "-A"])
3898

    
3899
and (vhdl_if_case_t_of_yojson :
3900
      Yojson.Safe.json -> vhdl_if_case_t Ppx_deriving_yojson_runtime.error_or)
3901
  =
3902
  ((let open! Ppx_deriving_yojson_runtime in
3903
      function
3904
      | `Assoc xs ->
3905
          let rec loop xs ((arg0,arg1) as _state) =
3906
            match xs with
3907
            | ("if_cond",x)::xs ->
3908
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
3909
            | ("if_block",x)::xs ->
3910
                loop xs
3911
                  (arg0,
3912
                    ((function
3913
                      | `List xs ->
3914
                          map_bind
3915
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3916
                            xs
3917
                      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t.if_block")
3918
                       x))
3919
            | [] ->
3920
                arg1 >>=
3921
                  ((fun arg1  ->
3922
                      arg0 >>=
3923
                        (fun arg0  ->
3924
                           Result.Ok { if_cond = arg0; if_block = arg1 })))
3925
            | _::xs -> loop xs _state  in
3926
          loop xs
3927
            ((Result.Error "Vhdl_ast.vhdl_if_case_t.if_cond"),
3928
              (Result.Error "Vhdl_ast.vhdl_if_case_t.if_block"))
3929
      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t")
3930
  [@ocaml.warning "-A"])
3931

    
3932
and (vhdl_case_item_t_to_yojson : vhdl_case_item_t -> Yojson.Safe.json) =
3933
  ((let open! Ppx_deriving_yojson_runtime in
3934
      fun x  ->
3935
        let fields = []  in
3936
        let fields =
3937
          ("when_stmt",
3938
            ((fun x  ->
3939
                `List
3940
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
3941
               x.when_stmt))
3942
          :: fields  in
3943
        let fields =
3944
          ("when_cond",
3945
            ((fun x  ->
3946
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
3947
               x.when_cond))
3948
          :: fields  in
3949
        `Assoc fields)
3950
  [@ocaml.warning "-A"])
3951

    
3952
and (vhdl_case_item_t_of_yojson :
3953
      Yojson.Safe.json ->
3954
        vhdl_case_item_t Ppx_deriving_yojson_runtime.error_or)
3955
  =
3956
  ((let open! Ppx_deriving_yojson_runtime in
3957
      function
3958
      | `Assoc xs ->
3959
          let rec loop xs ((arg0,arg1) as _state) =
3960
            match xs with
3961
            | ("when_cond",x)::xs ->
3962
                loop xs
3963
                  (((function
3964
                     | `List xs ->
3965
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
3966
                     | _ ->
3967
                         Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond")
3968
                      x), arg1)
3969
            | ("when_stmt",x)::xs ->
3970
                loop xs
3971
                  (arg0,
3972
                    ((function
3973
                      | `List xs ->
3974
                          map_bind
3975
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
3976
                            xs
3977
                      | _ ->
3978
                          Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt")
3979
                       x))
3980
            | [] ->
3981
                arg1 >>=
3982
                  ((fun arg1  ->
3983
                      arg0 >>=
3984
                        (fun arg0  ->
3985
                           Result.Ok { when_cond = arg0; when_stmt = arg1 })))
3986
            | _::xs -> loop xs _state  in
3987
          loop xs
3988
            ((Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond"),
3989
              (Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt"))
3990
      | _ -> Result.Error "Vhdl_ast.vhdl_case_item_t")
3991
  [@ocaml.warning "-A"])
3992

    
3993
type vhdl_port_mode_t =
3994
  | InPort [@name "in"]
3995
  | OutPort [@name "out"]
3996
  | InoutPort [@name "inout"]
3997
  | BufferPort [@name "buffer"]
3998

    
3999
let rec (pp_vhdl_port_mode_t :
4000
          Format.formatter -> vhdl_port_mode_t -> Ppx_deriving_runtime.unit)
4001
  =
4002
  ((let open! Ppx_deriving_runtime in
4003
      fun fmt  ->
4004
        function
4005
        | InPort  -> Format.pp_print_string fmt "in"
4006
        | OutPort  -> Format.pp_print_string fmt "out"
4007
        | InoutPort  -> Format.pp_print_string fmt "inout"
4008
        | BufferPort  -> Format.pp_print_string fmt "buffer")
4009
  [@ocaml.warning "-A"])
4010

    
4011
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string =
4012
  fun x  -> Format.asprintf "%a" pp_vhdl_port_mode_t x
4013

    
4014
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) =
4015
  ((let open! Ppx_deriving_yojson_runtime in
4016
      function
4017
      | InPort  -> `List [`String "in"]
4018
      | OutPort  -> `List [`String "out"]
4019
      | InoutPort  -> `List [`String "inout"]
4020
      | BufferPort  -> `List [`String "buffer"])
4021
  [@ocaml.warning "-A"])
4022

    
4023
and (vhdl_port_mode_t_of_yojson :
4024
      Yojson.Safe.json ->
4025
        vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or)
4026
  =
4027
  ((let open! Ppx_deriving_yojson_runtime in
4028
      function
4029
      | `List ((`String "in")::[]) -> Result.Ok InPort
4030
      | `List ((`String "out")::[]) -> Result.Ok OutPort
4031
      | `List ((`String "inout")::[]) -> Result.Ok InoutPort
4032
      | `List ((`String "buffer")::[]) -> Result.Ok BufferPort
4033
      | _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t")
4034
  [@ocaml.warning "-A"])
4035

    
4036
type vhdl_port_t =
4037
  {
4038
  names: vhdl_name_t list [@default []];
4039
  mode: vhdl_port_mode_t [@default InPort];
4040
  typ: vhdl_subtype_indication_t ;
4041
  expr: vhdl_expr_t [@default IsNull]}
4042

    
4043
let rec pp_vhdl_port_t :
4044
  Format.formatter -> vhdl_port_t -> Ppx_deriving_runtime.unit =
4045
  let __3 () = pp_vhdl_expr_t
4046
  
4047
  and __2 () = pp_vhdl_subtype_indication_t
4048
  
4049
  and __1 () = pp_vhdl_port_mode_t
4050
  
4051
  and __0 () = pp_vhdl_name_t
4052
   in
4053
  ((let open! Ppx_deriving_runtime in
4054
      fun fmt  ->
4055
        fun x  ->
4056
          Format.fprintf fmt "@[";
4057
          ((((
4058
              ((fun x  ->
4059
                  Format.fprintf fmt "@[";
4060
                  ignore
4061
                    (List.fold_left
4062
                       (fun sep  ->
4063
                          fun x  ->
4064
                            if sep then Format.fprintf fmt ",@ ";
4065
                            ((__0 ()) fmt) x;
4066
                            true) false x);
4067
                  Format.fprintf fmt "@,@]")) x.names;
4068
              );
4069
             Format.fprintf fmt ": ";
4070
             ((__1 ()) fmt) x.mode;
4071
             );
4072
             Format.fprintf fmt " ";
4073
            ((__2 ()) fmt) x.typ;
4074
            );
4075
          (match x.expr with
4076
           | IsNull -> Format.fprintf fmt "";
4077
           | _ -> (Format.fprintf fmt "@[:= ";
4078
                   ((__3 ()) fmt) x.expr;
4079
                   Format.fprintf fmt "@]"));
4080
          Format.fprintf fmt "@]"))
4081
    [@ocaml.warning "-A"])
4082

    
4083
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string =
4084
  fun x  -> Format.asprintf "%a" pp_vhdl_port_t x
4085

    
4086
let rec (vhdl_port_t_to_yojson : vhdl_port_t -> Yojson.Safe.json) =
4087
  ((let open! Ppx_deriving_yojson_runtime in
4088
      fun x  ->
4089
        let fields = []  in
4090
        let fields =
4091
          if x.expr = IsNull
4092
          then fields
4093
          else ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) x.expr)) ::
4094
            fields
4095
           in
4096
        let fields =
4097
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
4098
          :: fields  in
4099
        let fields =
4100
          if x.mode = InPort
4101
          then fields
4102
          else ("mode", (((fun x  -> vhdl_port_mode_t_to_yojson x)) x.mode))
4103
            :: fields
4104
           in
4105
        let fields =
4106
          if x.names = []
4107
          then fields
4108
          else
4109
            ("names",
4110
              (((fun x  ->
4111
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
4112
                 x.names))
4113
            :: fields
4114
           in
4115
        `Assoc fields)
4116
  [@ocaml.warning "-A"])
4117

    
4118
and (vhdl_port_t_of_yojson :
4119
      Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
4120
  =
4121
  ((let open! Ppx_deriving_yojson_runtime in
4122
      function
4123
      | `Assoc xs ->
4124
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
4125
            match xs with
4126
            | ("names",x)::xs ->
4127
                loop xs
4128
                  (((function
4129
                     | `List xs ->
4130
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4131
                     | _ -> Result.Error "Vhdl_ast.vhdl_port_t.names") x),
4132
                    arg1, arg2, arg3)
4133
            | ("mode",x)::xs ->
4134
                loop xs
4135
                  (arg0, ((fun x  -> vhdl_port_mode_t_of_yojson x) x), arg2,
4136
                    arg3)
4137
            | ("typ",x)::xs ->
4138
                loop xs
4139
                  (arg0, arg1,
4140
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
4141
                    arg3)
4142
            | ("expr",x)::xs ->
4143
                loop xs
4144
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4145
            | [] ->
4146
                arg3 >>=
4147
                  ((fun arg3  ->
4148
                      arg2 >>=
4149
                        (fun arg2  ->
4150
                           arg1 >>=
4151
                             (fun arg1  ->
4152
                                arg0 >>=
4153
                                  (fun arg0  ->
4154
                                     Result.Ok
4155
                                       {
4156
                                         names = arg0;
4157
                                         mode = arg1;
4158
                                         typ = arg2;
4159
                                         expr = arg3
4160
                                       })))))
4161
            | _::xs -> loop xs _state  in
4162
          loop xs
4163
            ((Result.Ok []), (Result.Ok InPort),
4164
              (Result.Error "Vhdl_ast.vhdl_port_t.typ"), (Result.Ok IsNull))
4165
      | _ -> Result.Error "Vhdl_ast.vhdl_port_t")
4166
  [@ocaml.warning "-A"])
4167
type vhdl_declaration_t =
4168
  | VarDecl of
4169
  {
4170
  names: vhdl_name_t list ;
4171
  typ: vhdl_subtype_indication_t ;
4172
  init_val: vhdl_expr_t [@default IsNull]} [@name "VARIABLE_DECLARATION"]
4173
  | CstDecl of
4174
  {
4175
  names: vhdl_name_t list ;
4176
  typ: vhdl_subtype_indication_t ;
4177
  init_val: vhdl_expr_t } [@name "CONSTANT_DECLARATION"]
4178
  | SigDecl of
4179
  {
4180
  names: vhdl_name_t list ;
4181
  typ: vhdl_subtype_indication_t ;
4182
  init_val: vhdl_expr_t [@default IsNull]} [@name "SIGNAL_DECLARATION"]
4183
  | ComponentDecl of
4184
  {
4185
  name: vhdl_name_t [@default NoName];
4186
  generics: vhdl_port_t list [@default []];
4187
  ports: vhdl_port_t list [@default []]} [@name "COMPONENT_DECLARATION"]
4188
  | Subprogram of
4189
  {
4190
  spec: vhdl_subprogram_spec_t ;
4191
  decl_part: vhdl_declaration_t list [@default []];
4192
  stmts: vhdl_sequential_stmt_t list [@default []]} [@name "SUBPROGRAM_BODY"]
4193

    
4194
let rec pp_vhdl_declaration_t :
4195
  Format.formatter -> vhdl_declaration_t -> Ppx_deriving_runtime.unit =
4196
  let __14 () = pp_vhdl_sequential_stmt_t
4197
  
4198
  and __13 () = pp_vhdl_declaration_t
4199
  
4200
  and __12 () = pp_vhdl_subprogram_spec_t
4201

    
4202
  and __11 () = pp_vhdl_port_t
4203
  
4204
  and __10 () = pp_vhdl_port_t
4205
  
4206
  and __9 () = pp_vhdl_name_t
4207
  
4208
  and __8 () = pp_vhdl_expr_t
4209
  
4210
  and __7 () = pp_vhdl_subtype_indication_t
4211
  
4212
  and __6 () = pp_vhdl_name_t
4213
  
4214
  and __5 () = pp_vhdl_expr_t
4215
  
4216
  and __4 () = pp_vhdl_subtype_indication_t
4217
  
4218
  and __3 () = pp_vhdl_name_t
4219
  
4220
  and __2 () = pp_vhdl_expr_t
4221
  
4222
  and __1 () = pp_vhdl_subtype_indication_t
4223
  
4224
  and __0 () = pp_vhdl_name_t
4225
   in
4226
  ((let open! Ppx_deriving_runtime in
4227
      fun fmt  ->
4228
        function
4229
        | VarDecl { names = anames; typ = atyp; init_val = ainit_val } ->
4230
            (Format.fprintf fmt "variable ";
4231
             ((((fun x  ->
4232
                    ignore
4233
                      (List.fold_left
4234
                         (fun sep  ->
4235
                            fun x  ->
4236
                              if sep then Format.fprintf fmt ",";
4237
                              ((__0 ()) fmt) x;
4238
                              true) false x);)) anames;
4239
               Format.fprintf fmt " : ";
4240
               ((__1 ()) fmt) atyp;
4241
               (match ainit_val with
4242
                | IsNull  -> Format.pp_print_string fmt ""
4243
                | _ ->
4244
                    (Format.fprintf fmt ":=";
4245
                     ((__2 ()) fmt) ainit_val;))));)
4246
        | CstDecl { names = anames; typ = atyp; init_val = ainit_val } ->
4247
            (Format.fprintf fmt "constant ";
4248
             ((((fun x  ->
4249
                    ignore
4250
                      (List.fold_left
4251
                         (fun sep  ->
4252
                            fun x  ->
4253
                              if sep then Format.fprintf fmt ",";
4254
                              ((__3 ()) fmt) x;
4255
                              true) false x);)) anames;
4256
               Format.fprintf fmt " : ";
4257
               ((__4 ()) fmt) atyp;
4258
              Format.fprintf fmt ":=";
4259
              ((__5 ()) fmt) ainit_val)))
4260
        | SigDecl { names = anames; typ = atyp; init_val = ainit_val } ->
4261
            (Format.fprintf fmt "signal ";
4262
            ((fun x  ->
4263
              ignore
4264
              (List.fold_left
4265
                (fun sep  ->
4266
                  fun x  ->
4267
                    if sep then Format.fprintf fmt ",";
4268
                                ((__6 ()) fmt) x;
4269
                                true) false x);
4270
              )) anames;
4271
            Format.fprintf fmt " : ";
4272
            ((__7 ()) fmt) atyp;
4273
            (match ainit_val with
4274
              | IsNull  -> Format.pp_print_string fmt ""
4275
              | _ ->
4276
                  (Format.fprintf fmt ":=";
4277
                  ((__8 ()) fmt) ainit_val;)))
4278
        | ComponentDecl
4279
            { name = aname; generics = agenerics; ports = aports } ->
4280
            Format.fprintf fmt "@[<v 2>component ";
4281
            ((__9 ()) fmt) aname;
4282
            Format.fprintf fmt " is@;";
4283
            ((fun x  ->
4284
              ignore
4285
                (List.fold_left
4286
                  (fun sep  ->
4287
                    fun x  ->
4288
                      if sep then Format.fprintf fmt "@;";
4289
                        ((__10 ()) fmt) x;
4290
                        true) false x))) agenerics;
4291
            ((fun x  ->
4292
              ignore
4293
                (List.fold_left
4294
                  (fun sep  ->
4295
                    fun x  ->
4296
                      if sep then Format.fprintf fmt "@;";
4297
                        ((__11 ()) fmt) x;
4298
                        true) false x))) aports;
4299
            Format.fprintf fmt "@]@;end component";
4300
        | Subprogram
4301
            { spec = aspec; decl_part = adecl_part; stmts = astmts }
4302
            ->
4303
              Format.fprintf fmt "@[<v 2>";
4304
              ((__12 ()) fmt) aspec;
4305
              Format.fprintf fmt " is";
4306
              (match adecl_part with
4307
              | [] -> Format.fprintf fmt "";
4308
              | _ ->
4309
                ((fun x  ->
4310
                  ignore
4311
                    (List.fold_left
4312
                      (fun sep  ->
4313
                         fun x  ->
4314
                           if sep then Format.fprintf fmt "";
4315
                             Format.fprintf fmt "@;";
4316
                             ((__13 ()) fmt) x;
4317
                             Format.fprintf fmt ";";
4318
                             true) false x))) adecl_part);
4319
              Format.fprintf fmt "@]@;";
4320
              Format.fprintf fmt "@[<v 2>begin@;";
4321
              ((fun x  ->
4322
                  ignore
4323
                    (List.fold_left
4324
                       (fun sep  ->
4325
                          fun x  ->
4326
                            if sep then Format.fprintf fmt "@;";
4327
                            ((__14 ()) fmt) x;
4328
                            Format.fprintf fmt ";";
4329
                            true) false x))) astmts;
4330
              Format.fprintf fmt "@]@;end";)
4331
    [@ocaml.warning "-A"])
4332

    
4333
and show_vhdl_declaration_t :
4334
  vhdl_declaration_t -> Ppx_deriving_runtime.string =
4335
  fun x  -> Format.asprintf "%a" pp_vhdl_declaration_t x
4336

    
4337
let rec (vhdl_declaration_t_to_yojson :
4338
          vhdl_declaration_t -> Yojson.Safe.json)
4339
  =
4340
  ((let open! Ppx_deriving_yojson_runtime in
4341
      function
4342
      | VarDecl arg0 ->
4343
          `List
4344
            [`String "VARIABLE_DECLARATION";
4345
            (let fields = []  in
4346
             let fields =
4347
               if arg0.init_val = IsNull
4348
               then fields
4349
               else
4350
                 ("init_val",
4351
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.init_val))
4352
                 :: fields
4353
                in
4354
             let fields =
4355
               ("typ",
4356
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
4357
               :: fields  in
4358
             let fields =
4359
               ("names",
4360
                 ((fun x  ->
4361
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
4362
                    arg0.names))
4363
               :: fields  in
4364
             `Assoc fields)]
4365
      | CstDecl arg0 ->
4366
          `List
4367
            [`String "CONSTANT_DECLARATION";
4368
            (let fields = []  in
4369
             let fields =
4370
               ("init_val",
4371
                 ((fun x  -> vhdl_expr_t_to_yojson x) arg0.init_val))
4372
               :: fields  in
4373
             let fields =
4374
               ("typ",
4375
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
4376
               :: fields  in
4377
             let fields =
4378
               ("names",
4379
                 ((fun x  ->
4380
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
4381
                    arg0.names))
4382
               :: fields  in
4383
             `Assoc fields)]
4384
      | SigDecl arg0 ->
4385
          `List
4386
            [`String "SIGNAL_DECLARATION";
4387
            (let fields = []  in
4388
             let fields =
4389
               if arg0.init_val = IsNull
4390
               then fields
4391
               else
4392
                 ("init_val",
4393
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.init_val))
4394
                 :: fields
4395
                in
4396
             let fields =
4397
               ("typ",
4398
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
4399
               :: fields  in
4400
             let fields =
4401
               ("names",
4402
                 ((fun x  ->
4403
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
4404
                    arg0.names))
4405
               :: fields  in
4406
             `Assoc fields)]
4407
      | ComponentDecl arg0 ->
4408
          `List
4409
            [`String "COMPONENT_DECLARATION";
4410
            (let fields = []  in
4411
             let fields =
4412
               if arg0.ports = []
4413
               then fields
4414
               else
4415
                 ("ports",
4416
                   (((fun x  ->
4417
                        `List
4418
                          (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
4419
                      arg0.ports))
4420
                 :: fields
4421
                in
4422
             let fields =
4423
               if arg0.generics = []
4424
               then fields
4425
               else
4426
                 ("generics",
4427
                   (((fun x  ->
4428
                        `List
4429
                          (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
4430
                      arg0.generics))
4431
                 :: fields
4432
                in
4433
             let fields =
4434
               if arg0.name = NoName
4435
               then fields
4436
               else
4437
                 ("name", (((fun x  -> vhdl_name_t_to_yojson x)) arg0.name))
4438
                 :: fields
4439
                in
4440
             `Assoc fields)]
4441
      | Subprogram arg0 ->
4442
          `List
4443
            [`String "SUBPROGRAM_BODY";
4444
            (let fields = []  in
4445
             let fields =
4446
               if arg0.stmts = []
4447
               then fields
4448
               else
4449
                 ("stmts",
4450
                   (((fun x  ->
4451
                        `List
4452
                          (List.map
4453
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
4454
                      arg0.stmts))
4455
                 :: fields
4456
                in
4457
             let fields =
4458
               if arg0.decl_part = []
4459
               then fields
4460
               else
4461
                 ("decl_part",
4462
                   (((fun x  ->
4463
                        `List
4464
                          (List.map
4465
                             (fun x  -> vhdl_declaration_t_to_yojson x) x)))
4466
                      arg0.decl_part))
4467
                 :: fields
4468
                in
4469
             let fields =
4470
               ("spec",
4471
                 ((fun x  -> vhdl_subprogram_spec_t_to_yojson x) arg0.spec))
4472
               :: fields  in
4473
             `Assoc fields)])
4474
  [@ocaml.warning "-A"])
4475

    
4476
and (vhdl_declaration_t_of_yojson :
4477
      Yojson.Safe.json ->
4478
        vhdl_declaration_t Ppx_deriving_yojson_runtime.error_or)
4479
  =
4480
  ((let open! Ppx_deriving_yojson_runtime in
4481
      function
4482
      | `List ((`String "VARIABLE_DECLARATION")::arg0::[]) ->
4483
          ((function
4484
            | `Assoc xs ->
4485
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4486
                  match xs with
4487
                  | ("names",x)::xs ->
4488
                      loop xs
4489
                        (((function
4490
                           | `List xs ->
4491
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4492
                                 [] xs
4493
                           | _ ->
4494
                               Result.Error
4495
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4496
                          arg1, arg2)
4497
                  | ("typ",x)::xs ->
4498
                      loop xs
4499
                        (arg0,
4500
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4501
                             x), arg2)
4502
                  | ("init_val",x)::xs ->
4503
                      loop xs
4504
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4505
                  | [] ->
4506
                      arg2 >>=
4507
                        ((fun arg2  ->
4508
                            arg1 >>=
4509
                              (fun arg1  ->
4510
                                 arg0 >>=
4511
                                   (fun arg0  ->
4512
                                      Result.Ok
4513
                                        (VarDecl
4514
                                           {
4515
                                             names = arg0;
4516
                                             typ = arg1;
4517
                                             init_val = arg2
4518
                                           })))))
4519
                  | _::xs -> loop xs _state  in
4520
                loop xs
4521
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4522
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4523
                    (Result.Ok IsNull))
4524
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4525
      | `List ((`String "CONSTANT_DECLARATION")::arg0::[]) ->
4526
          ((function
4527
            | `Assoc xs ->
4528
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4529
                  match xs with
4530
                  | ("names",x)::xs ->
4531
                      loop xs
4532
                        (((function
4533
                           | `List xs ->
4534
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4535
                                 [] xs
4536
                           | _ ->
4537
                               Result.Error
4538
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4539
                          arg1, arg2)
4540
                  | ("typ",x)::xs ->
4541
                      loop xs
4542
                        (arg0,
4543
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4544
                             x), arg2)
4545
                  | ("init_val",x)::xs ->
4546
                      loop xs
4547
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4548
                  | [] ->
4549
                      arg2 >>=
4550
                        ((fun arg2  ->
4551
                            arg1 >>=
4552
                              (fun arg1  ->
4553
                                 arg0 >>=
4554
                                   (fun arg0  ->
4555
                                      Result.Ok
4556
                                        (CstDecl
4557
                                           {
4558
                                             names = arg0;
4559
                                             typ = arg1;
4560
                                             init_val = arg2
4561
                                           })))))
4562
                  | _::xs -> loop xs _state  in
4563
                loop xs
4564
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4565
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4566
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.init_val"))
4567
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4568
      | `List ((`String "SIGNAL_DECLARATION")::arg0::[]) ->
4569
          ((function
4570
            | `Assoc xs ->
4571
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4572
                  match xs with
4573
                  | ("names",x)::xs ->
4574
                      loop xs
4575
                        (((function
4576
                           | `List xs ->
4577
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4578
                                 [] xs
4579
                           | _ ->
4580
                               Result.Error
4581
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4582
                          arg1, arg2)
4583
                  | ("typ",x)::xs ->
4584
                      loop xs
4585
                        (arg0,
4586
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4587
                             x), arg2)
4588
                  | ("init_val",x)::xs ->
4589
                      loop xs
4590
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4591
                  | [] ->
4592
                      arg2 >>=
4593
                        ((fun arg2  ->
4594
                            arg1 >>=
4595
                              (fun arg1  ->
4596
                                 arg0 >>=
4597
                                   (fun arg0  ->
4598
                                      Result.Ok
4599
                                        (SigDecl
4600
                                           {
4601
                                             names = arg0;
4602
                                             typ = arg1;
4603
                                             init_val = arg2
4604
                                           })))))
4605
                  | _::xs -> loop xs _state  in
4606
                loop xs
4607
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4608
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4609
                    (Result.Ok IsNull))
4610
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4611
      | `List ((`String "COMPONENT_DECLARATION")::arg0::[]) ->
4612
          ((function
4613
            | `Assoc xs ->
4614
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4615
                  match xs with
4616
                  | ("name",x)::xs ->
4617
                      loop xs
4618
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
4619
                  | ("generics",x)::xs ->
4620
                      loop xs
4621
                        (arg0,
4622
                          ((function
4623
                            | `List xs ->
4624
                                map_bind (fun x  -> vhdl_port_t_of_yojson x)
4625
                                  [] xs
4626
                            | _ ->
4627
                                Result.Error
4628
                                  "Vhdl_ast.vhdl_declaration_t.generics") x),
4629
                          arg2)
4630
                  | ("ports",x)::xs ->
4631
                      loop xs
4632
                        (arg0, arg1,
4633
                          ((function
4634
                            | `List xs ->
4635
                                map_bind (fun x  -> vhdl_port_t_of_yojson x)
4636
                                  [] xs
4637
                            | _ ->
4638
                                Result.Error
4639
                                  "Vhdl_ast.vhdl_declaration_t.ports") x))
4640
                  | [] ->
4641
                      arg2 >>=
4642
                        ((fun arg2  ->
4643
                            arg1 >>=
4644
                              (fun arg1  ->
4645
                                 arg0 >>=
4646
                                   (fun arg0  ->
4647
                                      Result.Ok
4648
                                        (ComponentDecl
4649
                                           {
4650
                                             name = arg0;
4651
                                             generics = arg1;
4652
                                             ports = arg2
4653
                                           })))))
4654
                  | _::xs -> loop xs _state  in
4655
                loop xs ((Result.Ok NoName), (Result.Ok []), (Result.Ok []))
4656
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4657
      | `List ((`String "SUBPROGRAM_BODY")::arg0::[]) ->
4658
          ((function
4659
            | `Assoc xs ->
4660
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4661
                  match xs with
4662
                  | ("spec",x)::xs ->
4663
                      loop xs
4664
                        (((fun x  -> vhdl_subprogram_spec_t_of_yojson x) x),
4665
                          arg1, arg2)
4666
                  | ("decl_part",x)::xs ->
4667
                      loop xs
4668
                        (arg0,
4669
                          ((function
4670
                            | `List xs ->
4671
                                map_bind
4672
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4673
                                  [] xs
4674
                            | _ ->
4675
                                Result.Error
4676
                                  "Vhdl_ast.vhdl_declaration_t.decl_part") x),
4677
                          arg2)
4678
                  | ("stmts",x)::xs ->
4679
                      loop xs
4680
                        (arg0, arg1,
4681
                          ((function
4682
                            | `List xs ->
4683
                                map_bind
4684
                                  (fun x  ->
4685
                                     vhdl_sequential_stmt_t_of_yojson x) []
4686
                                  xs
4687
                            | _ ->
4688
                                Result.Error
4689
                                  "Vhdl_ast.vhdl_declaration_t.stmts") x))
4690
                  | [] ->
4691
                      arg2 >>=
4692
                        ((fun arg2  ->
4693
                            arg1 >>=
4694
                              (fun arg1  ->
4695
                                 arg0 >>=
4696
                                   (fun arg0  ->
4697
                                      Result.Ok
4698
                                        (Subprogram
4699
                                           {
4700
                                             spec = arg0;
4701
                                             decl_part = arg1;
4702
                                             stmts = arg2
4703
                                           })))))
4704
                  | _::xs -> loop xs _state  in
4705
                loop xs
4706
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.spec"),
4707
                    (Result.Ok []), (Result.Ok []))
4708
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4709
      | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")
4710
  [@ocaml.warning "-A"])
4711

    
4712
type vhdl_load_t =
4713
  | Library of vhdl_name_t list [@name "LIBRARY_CLAUSE"][@default []]
4714
  | Use of vhdl_name_t list [@name "USE_CLAUSE"][@default []]
4715

    
4716
(* Adapted. TODO: check indentation *)
4717
let rec pp_vhdl_load_t :
4718
  Format.formatter -> vhdl_load_t -> Ppx_deriving_runtime.unit =
4719
  let __1 () = pp_vhdl_name_t
4720
  
4721
  and __0 () = pp_vhdl_name_t
4722
   in
4723
  ((let open! Ppx_deriving_runtime in
4724
      fun fmt  ->
4725
        function
4726
        | Library a0 ->
4727
            (Format.fprintf fmt "library ";
4728
             ((fun x  ->
4729
                 ignore
4730
                   (List.fold_left
4731
                      (fun sep  ->
4732
                         fun x  ->
4733
                           if sep then Format.fprintf fmt ".";
4734
                           ((__0 ()) fmt) x;
4735
                           true) false x))) a0;
4736
             Format.fprintf fmt ":")
4737
        | Use a0 ->
4738
            (Format.fprintf fmt "use ";
4739
             ((fun x  ->
4740
                 ignore
4741
                   (List.fold_left
4742
                      (fun sep  ->
4743
                         fun x  ->
4744
                           if sep then Format.fprintf fmt ".";
4745
                           ((__1 ()) fmt) x;
4746
                           true) false x))) a0;
4747
             Format.fprintf fmt ";"))
4748
    [@ocaml.warning "-A"])
4749

    
4750
and show_vhdl_load_t : vhdl_load_t -> Ppx_deriving_runtime.string =
4751
  fun x  -> Format.asprintf "%a" pp_vhdl_load_t x
4752

    
4753
let rec (vhdl_load_t_to_yojson : vhdl_load_t -> Yojson.Safe.json) =
4754
  ((let open! Ppx_deriving_yojson_runtime in
4755
      function
4756
      | Library arg0 ->
4757
          `List
4758
            [`String "LIBRARY_CLAUSE";
4759
            ((fun x  ->
4760
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
4761
      | Use arg0 ->
4762
          `List
4763
            [`String "USE_CLAUSE";
4764
            ((fun x  ->
4765
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0])
4766
  [@ocaml.warning "-A"])
4767

    
4768
and (vhdl_load_t_of_yojson :
4769
      Yojson.Safe.json -> vhdl_load_t Ppx_deriving_yojson_runtime.error_or)
4770
  =
4771
  ((let open! Ppx_deriving_yojson_runtime in
4772
      function
4773
      | `List ((`String "LIBRARY_CLAUSE")::arg0::[]) ->
4774
          ((function
4775
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4776
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
4777
            ((fun arg0  -> Result.Ok (Library arg0)))
4778
      | `List ((`String "USE_CLAUSE")::arg0::[]) ->
4779
          ((function
4780
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4781
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
4782
            ((fun arg0  -> Result.Ok (Use arg0)))
4783
      | _ -> Result.Error "Vhdl_ast.vhdl_load_t")
4784
  [@ocaml.warning "-A"])
4785

    
4786
type vhdl_declarative_item_t =
4787
  {
4788
  use_clause: vhdl_load_t option [@default None];
4789
  declaration: vhdl_declaration_t option [@default None];
4790
  definition: vhdl_definition_t option [@default None]}[@@deriving
4791
                                                         ((show
4792
                                                             {
4793
                                                               with_path =
4794
                                                                 false
4795
                                                             }),
4796
                                                           (yojson
4797
                                                              {
4798
                                                                strict =
4799
                                                                  false
4800
                                                              }))]
4801
let rec pp_vhdl_declarative_item_t :
4802
  Format.formatter -> vhdl_declarative_item_t -> Ppx_deriving_runtime.unit =
4803
  let __2 () = pp_vhdl_definition_t
4804
  
4805
  and __1 () = pp_vhdl_declaration_t
4806
  
4807
  and __0 () = pp_vhdl_load_t
4808
   in
4809
  ((let open! Ppx_deriving_runtime in
4810
      fun fmt  ->
4811
        fun x  ->
4812
          (match x.use_clause with
4813
          | None -> Format.fprintf fmt "";
4814
          | Some e -> ((__0 ()) fmt) e);
4815
          (match x.declaration with
4816
          | None -> Format.fprintf fmt "";
4817
          | Some e -> ((__1 ()) fmt) e);
4818
          (match x.definition with
4819
          | None -> Format.fprintf fmt "";
4820
          | Some e -> ((__2 ()) fmt) e);)
4821
    [@ocaml.warning "-A"])
4822

    
4823
and show_vhdl_declarative_item_t :
4824
  vhdl_declarative_item_t -> Ppx_deriving_runtime.string =
4825
  fun x  -> Format.asprintf "%a" pp_vhdl_declarative_item_t x
4826

    
4827
let rec (vhdl_declarative_item_t_to_yojson :
4828
          vhdl_declarative_item_t -> Yojson.Safe.json)
4829
  =
4830
  ((let open! Ppx_deriving_yojson_runtime in
4831
      fun x  ->
4832
        let fields = []  in
4833
        let fields =
4834
          if x.definition = None
4835
          then fields
4836
          else
4837
            ("definition",
4838
              (((function
4839
                 | None  -> `Null
4840
                 | Some x -> ((fun x  -> vhdl_definition_t_to_yojson x)) x))
4841
                 x.definition))
4842
            :: fields
4843
           in
4844
        let fields =
4845
          if x.declaration = None
4846
          then fields
4847
          else
4848
            ("declaration",
4849
              (((function
4850
                 | None  -> `Null
4851
                 | Some x -> ((fun x  -> vhdl_declaration_t_to_yojson x)) x))
4852
                 x.declaration))
4853
            :: fields
4854
           in
4855
        let fields =
4856
          if x.use_clause = None
4857
          then fields
4858
          else
4859
            ("use_clause",
4860
              (((function
4861
                 | None  -> `Null
4862
                 | Some x -> ((fun x  -> vhdl_load_t_to_yojson x)) x))
4863
                 x.use_clause))
4864
            :: fields
4865
           in
4866
        `Assoc fields)
4867
  [@ocaml.warning "-A"])
4868

    
4869
and (vhdl_declarative_item_t_of_yojson :
4870
      Yojson.Safe.json ->
4871
        vhdl_declarative_item_t Ppx_deriving_yojson_runtime.error_or)
4872
  =
4873
  ((let open! Ppx_deriving_yojson_runtime in
4874
      function
4875
      | `Assoc xs ->
4876
          let rec loop xs ((arg0,arg1,arg2) as _state) =
4877
            match xs with
4878
            | ("use_clause",x)::xs ->
4879
                loop xs
4880
                  (((function
4881
                     | `Null -> Result.Ok None
4882
                     | x ->
4883
                         ((fun x  -> vhdl_load_t_of_yojson x) x) >>=
4884
                           ((fun x  -> Result.Ok (Some x)))) x), arg1, arg2)
4885
            | ("declaration",x)::xs ->
4886
                loop xs
4887
                  (arg0,
4888
                    ((function
4889
                      | `Null -> Result.Ok None
4890
                      | x ->
4891
                          ((fun x  -> vhdl_declaration_t_of_yojson x) x) >>=
4892
                            ((fun x  -> Result.Ok (Some x)))) x), arg2)
4893
            | ("definition",x)::xs ->
4894
                loop xs
4895
                  (arg0, arg1,
4896
                    ((function
4897
                      | `Null -> Result.Ok None
4898
                      | x ->
4899
                          ((fun x  -> vhdl_definition_t_of_yojson x) x) >>=
4900
                            ((fun x  -> Result.Ok (Some x)))) x))
4901
            | [] ->
4902
                arg2 >>=
4903
                  ((fun arg2  ->
4904
                      arg1 >>=
4905
                        (fun arg1  ->
4906
                           arg0 >>=
4907
                             (fun arg0  ->
4908
                                Result.Ok
4909
                                  {
4910
                                    use_clause = arg0;
4911
                                    declaration = arg1;
4912
                                    definition = arg2
4913
                                  }))))
4914
            | _::xs -> loop xs _state  in
4915
          loop xs ((Result.Ok None), (Result.Ok None), (Result.Ok None))
4916
      | _ -> Result.Error "Vhdl_ast.vhdl_declarative_item_t")
4917
  [@ocaml.warning "-A"])
4918

    
4919
type vhdl_signal_condition_t =
4920
  {
4921
  expr: vhdl_waveform_element_t list [@default []];
4922
  cond: vhdl_expr_t [@default IsNull]}[@@deriving
4923
                                        ((show { with_path = false }),
4924
                                          (yojson { strict = false }))]
4925

    
4926
let rec pp_vhdl_signal_condition_t :
4927
  Format.formatter -> vhdl_signal_condition_t -> Ppx_deriving_runtime.unit =
4928
  let __1 () = pp_vhdl_expr_t
4929
  
4930
  and __0 () = pp_vhdl_waveform_element_t
4931
   in
4932
  ((let open! Ppx_deriving_runtime in
4933
      fun fmt  ->
4934
        fun x  ->
4935
          ((fun x  ->
4936
              ignore
4937
                (List.fold_left
4938
                   (fun sep  ->
4939
                      fun x  ->
4940
                        if sep then Format.fprintf fmt ";@ ";
4941
                        ((__0 ()) fmt) x;
4942
                        true) false x))) x.expr;
4943
          (match x.cond with
4944
          | IsNull -> Format.fprintf fmt "";
4945
          | _ -> Format.fprintf fmt "when ";
4946
                 ((__1 ()) fmt) x.cond);)
4947
    [@ocaml.warning "-A"])
4948

    
4949
and show_vhdl_signal_condition_t :
4950
  vhdl_signal_condition_t -> Ppx_deriving_runtime.string =
4951
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_condition_t x
4952

    
4953
let rec (vhdl_signal_condition_t_to_yojson :
4954
          vhdl_signal_condition_t -> Yojson.Safe.json)
4955
  =
4956
  ((let open! Ppx_deriving_yojson_runtime in
4957
      fun x  ->
4958
        let fields = []  in
4959
        let fields =
4960
          if x.cond = IsNull
4961
          then fields
4962
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
4963
            fields
4964
           in
4965
        let fields =
4966
          if x.expr = []
4967
          then fields
4968
          else
4969
            ("expr",
4970
              (((fun x  ->
4971
                   `List
4972
                     (List.map
4973
                        (fun x  -> vhdl_waveform_element_t_to_yojson x) x)))
4974
                 x.expr))
4975
            :: fields
4976
           in
4977
        `Assoc fields)
4978
  [@ocaml.warning "-A"])
4979

    
4980
and (vhdl_signal_condition_t_of_yojson :
4981
      Yojson.Safe.json ->
4982
        vhdl_signal_condition_t Ppx_deriving_yojson_runtime.error_or)
4983
  =
4984
  ((let open! Ppx_deriving_yojson_runtime in
4985
      function
4986
      | `Assoc xs ->
4987
          let rec loop xs ((arg0,arg1) as _state) =
4988
            match xs with
4989
            | ("expr",x)::xs ->
4990
                loop xs
4991
                  (((function
4992
                     | `List xs ->
4993
                         map_bind
4994
                           (fun x  -> vhdl_waveform_element_t_of_yojson x) []
4995
                           xs
4996
                     | _ ->
4997
                         Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr")
4998
                      x), arg1)
4999
            | ("cond",x)::xs ->
5000
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
5001
            | [] ->
5002
                arg1 >>=
5003
                  ((fun arg1  ->
5004
                      arg0 >>=
5005
                        (fun arg0  -> Result.Ok { expr = arg0; cond = arg1 })))
5006
            | _::xs -> loop xs _state  in
5007
          loop xs ((Result.Ok []), (Result.Ok IsNull))
5008
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_condition_t")
5009
  [@ocaml.warning "-A"])
5010

    
5011
type vhdl_signal_selection_t =
5012
  {
5013
  expr: vhdl_waveform_element_t list [@default []];
5014
  when_sel: vhdl_expr_t list [@default []]}[@@deriving
5015
                                             ((show { with_path = false }),
5016
                                               (yojson { strict = false }))]
5017

    
5018
let rec pp_vhdl_signal_selection_t :
5019
  Format.formatter -> vhdl_signal_selection_t -> Ppx_deriving_runtime.unit =
5020
  let __1 () = pp_vhdl_expr_t
5021
  
5022
  and __0 () = pp_vhdl_waveform_element_t
5023
   in
5024
  ((let open! Ppx_deriving_runtime in
5025
      fun fmt  ->
5026
        fun x  ->
5027
          ((fun x  ->
5028
            ignore
5029
              (List.fold_left
5030
                (fun sep  ->
5031
                  fun x  ->
5032
                    if sep then Format.fprintf fmt "@ ";
5033
                      ((__0 ()) fmt) x;
5034
                      true) false x))) x.expr;
5035
          Format.fprintf fmt " when ";
5036
          ((fun x  ->
5037
            ignore
5038
              (List.fold_left
5039
                (fun sep  ->
5040
                  fun x  ->
5041
                    if sep then Format.fprintf fmt "|@ ";
5042
                      ((__1 ()) fmt) x;
5043
                      true) false x))) x.when_sel)
5044
    [@ocaml.warning "-A"])
5045

    
5046
and show_vhdl_signal_selection_t :
5047
  vhdl_signal_selection_t -> Ppx_deriving_runtime.string =
5048
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_selection_t x
5049

    
5050
let rec (vhdl_signal_selection_t_to_yojson :
5051
          vhdl_signal_selection_t -> Yojson.Safe.json)
5052
  =
5053
  ((let open! Ppx_deriving_yojson_runtime in
5054
      fun x  ->
5055
        let fields = []  in
5056
        let fields =
5057
          if x.when_sel = []
5058
          then fields
5059
          else
5060
            ("when_sel",
5061
              (((fun x  ->
5062
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
5063
                 x.when_sel))
5064
            :: fields
5065
           in
5066
        let fields =
5067
          if x.expr = []
5068
          then fields
5069
          else
5070
            ("expr",
5071
              (((fun x  ->
5072
                   `List
5073
                     (List.map
5074
                        (fun x  -> vhdl_waveform_element_t_to_yojson x) x)))
5075
                 x.expr))
5076
            :: fields
5077
           in
5078
        `Assoc fields)
5079
  [@ocaml.warning "-A"])
5080

    
5081
and (vhdl_signal_selection_t_of_yojson :
5082
      Yojson.Safe.json ->
5083
        vhdl_signal_selection_t Ppx_deriving_yojson_runtime.error_or)
5084
  =
5085
  ((let open! Ppx_deriving_yojson_runtime in
5086
      function
5087
      | `Assoc xs ->
5088
          let rec loop xs ((arg0,arg1) as _state) =
5089
            match xs with
5090
            | ("expr",x)::xs ->
5091
                loop xs
5092
                  (((function
5093
                     | `List xs ->
5094
                         map_bind
5095
                           (fun x  -> vhdl_waveform_element_t_of_yojson x) []
5096
                           xs
5097
                     | _ ->
5098
                         Result.Error "Vhdl_ast.vhdl_signal_selection_t.expr")
5099
                      x), arg1)
5100
            | ("when_sel",x)::xs ->
5101
                loop xs
5102
                  (arg0,
5103
                    ((function
5104
                      | `List xs ->
5105
                          map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
5106
                      | _ ->
5107
                          Result.Error
5108
                            "Vhdl_ast.vhdl_signal_selection_t.when_sel") x))
5109
            | [] ->
5110
                arg1 >>=
5111
                  ((fun arg1  ->
5112
                      arg0 >>=
5113
                        (fun arg0  ->
5114
                           Result.Ok { expr = arg0; when_sel = arg1 })))
5115
            | _::xs -> loop xs _state  in
5116
          loop xs ((Result.Ok []), (Result.Ok []))
5117
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_selection_t")
5118
  [@ocaml.warning "-A"])
5119

    
5120
type vhdl_conditional_signal_t =
5121
  {
5122
  postponed: bool [@default false];
5123
  label: vhdl_name_t [@default NoName];
5124
  lhs: vhdl_name_t ;
5125
  rhs: vhdl_signal_condition_t list ;
5126
  cond: vhdl_expr_t [@default IsNull];
5127
  delay: vhdl_expr_t [@default IsNull]}
5128

    
5129
let rec pp_vhdl_conditional_signal_t :
5130
  Format.formatter -> vhdl_conditional_signal_t -> Ppx_deriving_runtime.unit
5131
  =
5132
  let __4 () = pp_vhdl_expr_t
5133
  
5134
  and __3 () = pp_vhdl_expr_t
5135
  
5136
  and __2 () = pp_vhdl_signal_condition_t
5137
  
5138
  and __1 () = pp_vhdl_name_t
5139
  
5140
  and __0 () = pp_vhdl_name_t
5141
   in
5142
  ((let open! Ppx_deriving_runtime in
5143
      fun fmt  ->
5144
        fun x  ->
5145
          (match x.label with
5146
            | NoName -> Format.fprintf fmt "";
5147
            | _ -> (((__0 ()) fmt) x.label;
5148
                   Format.fprintf fmt ":@ ")
5149
          );
5150
          if (x.postponed) then Format.fprintf fmt "postponed@ ";
5151
          ((__1 ()) fmt) x.lhs;
5152
          Format.fprintf fmt " <= ";
5153
          (match x.delay with
5154
            | IsNull -> Format.fprintf fmt "";
5155
            | _ -> ((__4 ()) fmt) x.delay;
5156
                   Format.fprintf fmt " ");
5157
          ((fun x  ->
5158
             Format.fprintf fmt "@[";
5159
             ignore
5160
               (List.fold_left
5161
                 (fun sep  ->
5162
                   fun x  ->
5163
                     if sep then Format.fprintf fmt "";
5164
                      ((__2 ()) fmt) x;
5165
                      Format.fprintf fmt ";";
5166
                      true) false x);
5167
          Format.fprintf fmt "@]")) x.rhs;
5168
          (match x.cond with
5169
            | IsNull -> Format.fprintf fmt "";
5170
            | _ -> Format.fprintf fmt "when (";
5171
                   ((__3 ()) fmt) x.cond;
5172
                   Format.fprintf fmt ")"))
5173
   [@ocaml.warning "-A"])
5174

    
5175
and show_vhdl_conditional_signal_t :
5176
  vhdl_conditional_signal_t -> Ppx_deriving_runtime.string =
5177
  fun x  -> Format.asprintf "%a" pp_vhdl_conditional_signal_t x
5178

    
5179
let rec (vhdl_conditional_signal_t_to_yojson :
5180
          vhdl_conditional_signal_t -> Yojson.Safe.json)
5181
  =
5182
  ((let open! Ppx_deriving_yojson_runtime in
5183
      fun x  ->
5184
        let fields = []  in
5185
        let fields =
5186
          if x.delay = IsNull
5187
          then fields
5188
          else ("delay", (((fun x  -> vhdl_expr_t_to_yojson x)) x.delay)) ::
5189
            fields
5190
           in
5191
        let fields =
5192
          if x.cond = IsNull
5193
          then fields
5194
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
5195
            fields
5196
           in
5197
        let fields =
5198
          ("rhs",
5199
            ((fun x  ->
5200
                `List
5201
                  (List.map (fun x  -> vhdl_signal_condition_t_to_yojson x) x))
5202
               x.rhs))
5203
          :: fields  in
5204
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
5205
          fields  in
5206
        let fields =
5207
          if x.label = NoName
5208
          then fields
5209
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
5210
            fields
5211
           in
5212
        let fields =
5213
          if x.postponed = false
5214
          then fields
5215
          else
5216
            ("postponed",
5217
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
5218
                 x.postponed))
5219
            :: fields
5220
           in
5221
        `Assoc fields)
5222
  [@ocaml.warning "-A"])
5223

    
5224
and (vhdl_conditional_signal_t_of_yojson :
5225
      Yojson.Safe.json ->
5226
        vhdl_conditional_signal_t Ppx_deriving_yojson_runtime.error_or)
5227
  =
5228
  ((let open! Ppx_deriving_yojson_runtime in
5229
      function
5230
      | `Assoc xs ->
5231
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
5232
            match xs with
5233
            | ("postponed",x)::xs ->
5234
                loop xs
5235
                  (((function
5236
                     | `Bool x -> Result.Ok x
5237
                     | _ ->
5238
                         Result.Error
5239
                           "Vhdl_ast.vhdl_conditional_signal_t.postponed") x),
5240
                    arg1, arg2, arg3, arg4, arg5)
5241
            | ("label",x)::xs ->
5242
                loop xs
5243
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
5244
                    arg4, arg5)
5245
            | ("lhs",x)::xs ->
5246
                loop xs
5247
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
5248
                    arg4, arg5)
5249
            | ("rhs",x)::xs ->
5250
                loop xs
5251
                  (arg0, arg1, arg2,
5252
                    ((function
5253
                      | `List xs ->
5254
                          map_bind
5255
                            (fun x  -> vhdl_signal_condition_t_of_yojson x)
5256
                            [] xs
5257
                      | _ ->
5258
                          Result.Error
5259
                            "Vhdl_ast.vhdl_conditional_signal_t.rhs") x),
5260
                    arg4, arg5)
5261
            | ("cond",x)::xs ->
5262
                loop xs
5263
                  (arg0, arg1, arg2, arg3,
5264
                    ((fun x  -> vhdl_expr_t_of_yojson x) x), arg5)
5265
            | ("delay",x)::xs ->
5266
                loop xs
5267
                  (arg0, arg1, arg2, arg3, arg4,
5268
                    ((fun x  -> vhdl_expr_t_of_yojson x) x))
5269
            | [] ->
5270
                arg5 >>=
5271
                  ((fun arg5  ->
5272
                      arg4 >>=
5273
                        (fun arg4  ->
5274
                           arg3 >>=
5275
                             (fun arg3  ->
5276
                                arg2 >>=
5277
                                  (fun arg2  ->
5278
                                     arg1 >>=
5279
                                       (fun arg1  ->
5280
                                          arg0 >>=
5281
                                            (fun arg0  ->
5282
                                               Result.Ok
5283
                                                 {
5284
                                                   postponed = arg0;
5285
                                                   label = arg1;
5286
                                                   lhs = arg2;
5287
                                                   rhs = arg3;
5288
                                                   cond = arg4;
5289
                                                   delay = arg5
5290
                                                 })))))))
5291
            | _::xs -> loop xs _state  in
5292
          loop xs
5293
            ((Result.Ok false), (Result.Ok NoName),
5294
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.lhs"),
5295
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.rhs"),
5296
              (Result.Ok IsNull), (Result.Ok IsNull))
5297
      | _ -> Result.Error "Vhdl_ast.vhdl_conditional_signal_t")
5298
  [@ocaml.warning "-A"])
5299

    
5300
type vhdl_process_t =
5301
  {
5302
  id: vhdl_name_t [@default NoName];
5303
  declarations: vhdl_declarative_item_t list
5304
    [@key "PROCESS_DECLARATIVE_PART"][@default Some []];
5305
  active_sigs: vhdl_name_t list [@default []];
5306
  body: vhdl_sequential_stmt_t list
5307
    [@key "PROCESS_STATEMENT_PART"][@default []]}
5308

    
5309
let rec pp_vhdl_process_t :
5310
  Format.formatter -> vhdl_process_t -> Ppx_deriving_runtime.unit =
5311
  let __3 () = pp_vhdl_sequential_stmt_t
5312
  
5313
  and __2 () = pp_vhdl_name_t
5314
  
5315
  and __1 () = pp_vhdl_declarative_item_t
5316
  
5317
  and __0 () = pp_vhdl_name_t
5318
   in
5319
  ((let open! Ppx_deriving_runtime in
5320
      fun fmt  ->
5321
        fun x  ->
5322
          Format.fprintf fmt "@[<v 2>";
5323
          (match x.id with
5324
          | NoName -> Format.fprintf fmt "";
5325
          | _ -> 
5326
              ((__0 ()) fmt) x.id;
5327
              Format.fprintf fmt ": ");
5328
          Format.fprintf fmt "process ";
5329
          (match x.active_sigs with
5330
          | [] -> Format.fprintf fmt "";
5331
          | _ -> Format.fprintf fmt "(";
5332
                 ((fun x  ->
5333
                    ignore
5334
                      (List.fold_left
5335
                         (fun sep  ->
5336
                            fun x  ->
5337
                              if sep then Format.fprintf fmt ",";
5338
                              ((__2 ()) fmt) x;
5339
                              true) false x))) x.active_sigs;
5340
                 Format.fprintf fmt ")");
5341
          Format.fprintf fmt " is@;";
5342
          ((fun x  ->
5343
            ignore
5344
            (List.fold_left
5345
              (fun sep  ->
5346
                fun x  ->
5347
                  if sep then Format.fprintf fmt "@;";
5348
                    ((__1 ()) fmt) x;
5349
                    Format.fprintf fmt ";";
5350
                    true) false x))) x.declarations;
5351
          Format.fprintf fmt "@]@;@[<v 2>begin@;";
5352
          ((fun x  ->
5353
               ignore
5354
                 (List.fold_left
5355
                    (fun sep  ->
5356
                       fun x  ->
5357
                         if sep then Format.fprintf fmt "@;";
5358
                         ((__3 ()) fmt) x;
5359
                         Format.fprintf fmt ";";
5360
                         true) false x);)) x.body;
5361
          Format.fprintf fmt "@]@;end process;@;";
5362
          Format.fprintf fmt "@]";)
5363
    [@ocaml.warning "-A"])
5364

    
5365
and show_vhdl_process_t : vhdl_process_t -> Ppx_deriving_runtime.string =
5366
  fun x  -> Format.asprintf "%a" pp_vhdl_process_t x
5367

    
5368
let rec (vhdl_process_t_to_yojson : vhdl_process_t -> Yojson.Safe.json) =
5369
  ((let open! Ppx_deriving_yojson_runtime in
5370
      fun x  ->
5371
        let fields = []  in
5372
        let fields =
5373
          if x.body = []
5374
          then fields
5375
          else
5376
            ("PROCESS_STATEMENT_PART",
5377
              (((fun x  ->
5378
                   `List
5379
                     (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x)
5380
                        x))) x.body))
5381
            :: fields
5382
           in
5383
        let fields =
5384
          if x.active_sigs = []
5385
          then fields
5386
          else
5387
            ("active_sigs",
5388
              (((fun x  ->
5389
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
5390
                 x.active_sigs))
5391
            :: fields
5392
           in
5393
        let fields =
5394
          if x.declarations = []
5395
          then fields
5396
          else
5397
            ("PROCESS_DECLARATIVE_PART",
5398
              (((fun x  ->
5399
                   `List
5400
                     (List.map
5401
                        (fun x  -> vhdl_declarative_item_t_to_yojson x) x)))
5402
                 x.declarations))
5403
            :: fields
5404
           in
5405
        let fields =
5406
          if x.id = NoName
5407
          then fields
5408
          else ("id", (((fun x  -> vhdl_name_t_to_yojson x)) x.id)) :: fields
5409
           in
5410
        `Assoc fields)
5411
  [@ocaml.warning "-A"])
5412

    
5413
and (vhdl_process_t_of_yojson :
5414
      Yojson.Safe.json -> vhdl_process_t Ppx_deriving_yojson_runtime.error_or)
5415
  =
5416
  ((let open! Ppx_deriving_yojson_runtime in
5417
      function
5418
      | `Assoc xs ->
5419
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
5420
            match xs with
5421
            | ("id",x)::xs ->
5422
                loop xs
5423
                  (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2, arg3)
5424
            | ("PROCESS_DECLARATIVE_PART",x)::xs ->
5425
                loop xs
5426
                  (arg0,
5427
                    ((function
5428
                      | `List xs ->
5429
                          map_bind
5430
                            (fun x  -> vhdl_declarative_item_t_of_yojson x)
5431
                            [] xs
5432
                      | _ ->
5433
                          Result.Error "Vhdl_ast.vhdl_process_t.declarations")
5434
                       x), arg2, arg3)
5435
            | ("active_sigs",x)::xs ->
5436
                loop xs
5437
                  (arg0, arg1,
5438
                    ((function
5439
                      | `List xs ->
5440
                          map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
5441
                      | _ ->
5442
                          Result.Error "Vhdl_ast.vhdl_process_t.active_sigs")
5443
                       x), arg3)
5444
            | ("PROCESS_STATEMENT_PART",x)::xs ->
5445
                loop xs
5446
                  (arg0, arg1, arg2,
5447
                    ((function
5448
                      | `List xs ->
5449
                          map_bind
5450
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
5451
                            xs
5452
                      | _ -> Result.Error "Vhdl_ast.vhdl_process_t.body") x))
5453
            | [] ->
5454
                arg3 >>=
5455
                  ((fun arg3  ->
5456
                      arg2 >>=
5457
                        (fun arg2  ->
5458
                           arg1 >>=
5459
                             (fun arg1  ->
5460
                                arg0 >>=
5461
                                  (fun arg0  ->
5462
                                     Result.Ok
5463
                                       {
5464
                                         id = arg0;
5465
                                         declarations = arg1;
5466
                                         active_sigs = arg2;
5467
                                         body = arg3
5468
                                       })))))
5469
            | _::xs -> loop xs _state  in
5470
          loop xs
5471
            ((Result.Ok NoName), (Result.Ok []), (Result.Ok []),
5472
              (Result.Ok []))
5473
      | _ -> Result.Error "Vhdl_ast.vhdl_process_t")
5474
  [@ocaml.warning "-A"])
5475

    
5476
type vhdl_selected_signal_t =
5477
  {
5478
  postponed: bool [@default false];
5479
  label: vhdl_name_t [@default NoName];
5480
  lhs: vhdl_name_t ;
5481
  sel: vhdl_expr_t ;
5482
  branches: vhdl_signal_selection_t list [@default []];
5483
  delay: vhdl_expr_t option [@default None]}[@@deriving
5484
                                              ((show { with_path = false }),
5485
                                                (yojson { strict = false }))]
5486

    
5487
let rec pp_vhdl_selected_signal_t :
5488
  Format.formatter -> vhdl_selected_signal_t -> Ppx_deriving_runtime.unit =
5489
  let __4 () = pp_vhdl_expr_t
5490
  
5491
  and __3 () = pp_vhdl_signal_selection_t
5492
  
5493
  and __2 () = pp_vhdl_expr_t