Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

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

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
              Format.fprintf fmt "(@[<v>";
225
              ((fun x  ->
226
                ignore
227
                (List.fold_left
228
                  (fun sep  ->
229
                    fun x  ->
230
                      if sep then Format.fprintf fmt ",@ ";
231
                      ((__0 ()) fmt) x;
232
                      Format.fprintf fmt " range <>";
233
                      true) false x)) aindexes);
234
              Format.fprintf fmt ")@]");
235
            (function
236
              | None  -> Format.pp_print_string fmt ""
237
              | Some x ->
238
                ((__1 ()) fmt) x) aconst;
239
            Format.fprintf fmt " of ";
240
            ((__2 ()) fmt) adefinition;
241
        | Record a0 ->
242
            Format.fprintf fmt "@[<v 2>record@;";
243
            (fun x  ->
244
              ignore
245
                (List.fold_left
246
                  (fun sep  ->
247
                    fun x  ->
248
                      if sep then Format.fprintf fmt ";@;";
249
                        ((__3 ()) fmt) x;
250
                        true) false x);
251
              Format.fprintf fmt "@]@;end record") a0;
252
        | Enumerated a0 ->
253
            (Format.fprintf fmt "(";
254
            ((fun x  ->
255
              ignore
256
              (List.fold_left
257
                (fun sep  ->
258
                  fun x  ->
259
                    if sep then Format.fprintf fmt ",@ ";
260
                      ((__4 ()) fmt) x;
261
                    true) false x))) a0;
262
             Format.fprintf fmt ")");
263
        | Void  -> Format.pp_print_string fmt "")
264
    [@ocaml.warning "-A"])
265

    
266
and show_vhdl_type_t : vhdl_type_t -> Ppx_deriving_runtime.string =
267
  fun x  -> Format.asprintf "%a" pp_vhdl_type_t x
268

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

    
291
and show_vhdl_element_declaration_t :
292
  vhdl_element_declaration_t -> Ppx_deriving_runtime.string =
293
  fun x  -> Format.asprintf "%a" pp_vhdl_element_declaration_t x
294

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

    
315
and show_vhdl_subtype_indication_t :
316
  vhdl_subtype_indication_t -> Ppx_deriving_runtime.string =
317
  fun x  -> Format.asprintf "%a" pp_vhdl_subtype_indication_t x
318

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

    
344
and show_vhdl_discrete_range_t :
345
  vhdl_discrete_range_t -> Ppx_deriving_runtime.string =
346
  fun x  -> Format.asprintf "%a" pp_vhdl_discrete_range_t x
347

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

    
406
and show_vhdl_constraint_t : vhdl_constraint_t -> Ppx_deriving_runtime.string
407
  = fun x  -> Format.asprintf "%a" pp_vhdl_constraint_t x
408

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

    
435
and show_vhdl_definition_t : vhdl_definition_t -> Ppx_deriving_runtime.string
436
  = fun x  -> Format.asprintf "%a" pp_vhdl_definition_t x
437

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

    
553
and show_vhdl_expr_t : vhdl_expr_t -> Ppx_deriving_runtime.string =
554
  fun x  -> Format.asprintf "%a" pp_vhdl_expr_t x
555

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

    
640
and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string =
641
  fun x  -> Format.asprintf "%a" pp_vhdl_name_t x
642

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

    
687
and show_vhdl_assoc_element_t :
688
  vhdl_assoc_element_t -> Ppx_deriving_runtime.string =
689
  fun x  -> Format.asprintf "%a" pp_vhdl_assoc_element_t x
690

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

    
715
and show_vhdl_element_assoc_t :
716
  vhdl_element_assoc_t -> Ppx_deriving_runtime.string =
717
  fun x  -> Format.asprintf "%a" pp_vhdl_element_assoc_t x
718

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

    
740
and show_vhdl_array_attributes_t :
741
  vhdl_array_attributes_t -> Ppx_deriving_runtime.string =
742
  fun x  -> Format.asprintf "%a" pp_vhdl_array_attributes_t x
743

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

    
758
and show_vhdl_signal_attributes_t :
759
  vhdl_signal_attributes_t -> Ppx_deriving_runtime.string =
760
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_attributes_t x
761

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

    
776
and show_vhdl_string_attributes_t :
777
  vhdl_string_attributes_t -> Ppx_deriving_runtime.string =
778
  fun x  -> Format.asprintf "%a" pp_vhdl_string_attributes_t x
779

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

    
800
and show_vhdl_suffix_selection_t :
801
  vhdl_suffix_selection_t -> Ppx_deriving_runtime.string =
802
  fun x  -> Format.asprintf "%a" pp_vhdl_suffix_selection_t x
803

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2319
and show_vhdl_type_attributes_t  =
2320
  fun poly_basetype  ->
2321
    fun x  ->
2322
      Format.asprintf "%a" (pp_vhdl_type_attributes_t poly_basetype) x
2323

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

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

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

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

    
2579
and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string =
2580
  fun x  -> Format.asprintf "%a" pp_vhdl_parameter_t x
2581

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

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

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

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

    
2733
and show_vhdl_subprogram_spec_t :
2734
  vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string =
2735
  fun x  -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x
2736

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

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

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

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

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

    
2908
and show_vhdl_waveform_element_t :
2909
  vhdl_waveform_element_t -> Ppx_deriving_runtime.string =
2910
  fun x  -> Format.asprintf "%a" pp_vhdl_waveform_element_t x
2911

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

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

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

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

    
3249
and show_vhdl_sequential_stmt_t :
3250
  vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string =
3251
  fun x  -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x
3252

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

    
3276
and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string =
3277
  fun x  -> Format.asprintf "%a" pp_vhdl_if_case_t x
3278

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

    
3310
and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string =
3311
  fun x  -> Format.asprintf "%a" pp_vhdl_case_item_t x
3312

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

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

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

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

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

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

    
3996
type vhdl_port_mode_t =
3997
  | InPort [@name "in"]
3998
  | OutPort [@name "out"]
3999
  | InoutPort [@name "inout"]
4000
  | BufferPort [@name "buffer"]
4001

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

    
4014
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string =
4015
  fun x  -> Format.asprintf "%a" pp_vhdl_port_mode_t x
4016

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

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

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

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

    
4086
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string =
4087
  fun x  -> Format.asprintf "%a" pp_vhdl_port_t x
4088

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

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

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

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

    
4336
and show_vhdl_declaration_t :
4337
  vhdl_declaration_t -> Ppx_deriving_runtime.string =
4338
  fun x  -> Format.asprintf "%a" pp_vhdl_declaration_t x
4339

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

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

    
4715
type vhdl_load_t =
4716
  | Library of vhdl_name_t list [@name "LIBRARY_CLAUSE"][@default []]
4717
  | Use of vhdl_name_t list [@name "USE_CLAUSE"][@default []]
4718

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

    
4753
and show_vhdl_load_t : vhdl_load_t -> Ppx_deriving_runtime.string =
4754
  fun x  -> Format.asprintf "%a" pp_vhdl_load_t x
4755

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

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

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

    
4826
and show_vhdl_declarative_item_t :
4827
  vhdl_declarative_item_t -> Ppx_deriving_runtime.string =
4828
  fun x  -> Format.asprintf "%a" pp_vhdl_declarative_item_t x
4829

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

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

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

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

    
4952
and show_vhdl_signal_condition_t :
4953
  vhdl_signal_condition_t -> Ppx_deriving_runtime.string =
4954
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_condition_t x
4955

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

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

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

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

    
5049
and show_vhdl_signal_selection_t :
5050
  vhdl_signal_selection_t -> Ppx_deriving_runtime.string =
5051
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_selection_t x
5052

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

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

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

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

    
5178
and show_vhdl_conditional_signal_t :
5179
  vhdl_conditional_signal_t -> Ppx_deriving_runtime.string =
5180
  fun x  -> Format.asprintf "%a" pp_vhdl_conditional_signal_t x
5181

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

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

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

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

    
5368
and show_vhdl_process_t : vhdl_process_t -> Ppx_deriving_runtime.string =
5369
  fun x  -> Format.asprintf "%a" pp_vhdl_process_t x
5370

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

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

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

    
5490
let rec pp_vhdl_selected_signal_t :
5491
  Format.formatter -> vhdl_selected_signal_t -> Ppx_deriving_runtime.unit =
5492
  let __4 () = pp_vhdl_expr_t