Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (251 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
  | QualifiedExpression of
147
  {
148
  type_mark: vhdl_name_t ;
149
  aggregate: vhdl_element_assoc_t list ;
150
  expression: vhdl_expr_t option } [@name "QUALIFIED_EXPRESSION"]
151
  | Others [@name "OTHERS"]
152
and vhdl_name_t =
153
  | Simple of string [@name "SIMPLE_NAME"]
154
  | Identifier of string [@name "IDENTIFIER"]
155
  | Selected of vhdl_name_t list [@name "SELECTED_NAME"]
156
  | Index of {
157
  id: vhdl_name_t ;
158
  exprs: vhdl_expr_t list } [@name "INDEXED_NAME"]
159
  | Slice of {
160
  id: vhdl_name_t ;
161
  range: vhdl_discrete_range_t } [@name "SLICE_NAME"]
162
  | Attribute of
163
  {
164
  id: vhdl_name_t ;
165
  designator: vhdl_name_t ;
166
  expr: vhdl_expr_t [@default IsNull]} [@name "ATTRIBUTE_NAME"]
167
  | Function of {
168
  id: vhdl_name_t ;
169
  assoc_list: vhdl_assoc_element_t list } [@name "FUNCTION_CALL"]
170
  | NoName 
171
and vhdl_assoc_element_t =
172
  {
173
  formal_name: vhdl_name_t option [@default None];
174
  formal_arg: vhdl_name_t option [@default None];
175
  actual_name: vhdl_name_t option [@default None];
176
  actual_designator: vhdl_name_t option [@default None];
177
  actual_expr: vhdl_expr_t option [@default None]}
178
and vhdl_element_assoc_t = {
179
  choices: vhdl_expr_t list [@default []];
180
  expr: vhdl_expr_t }
181
and vhdl_array_attributes_t =
182
  | AAttInt of {
183
  id: string ;
184
  arg: int } 
185
  | AAttAscending 
186
and vhdl_signal_attributes_t =
187
  | SigAtt of string 
188
and vhdl_string_attributes_t =
189
  | StringAtt of string 
190
and vhdl_suffix_selection_t =
191
  | Idx of int 
192
  | SuffixRange of int * int
193

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

    
271
and show_vhdl_type_t : vhdl_type_t -> Ppx_deriving_runtime.string =
272
  fun x  -> Format.asprintf "%a" pp_vhdl_type_t x
273

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

    
296
and show_vhdl_element_declaration_t :
297
  vhdl_element_declaration_t -> Ppx_deriving_runtime.string =
298
  fun x  -> Format.asprintf "%a" pp_vhdl_element_declaration_t x
299

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

    
320
and show_vhdl_subtype_indication_t :
321
  vhdl_subtype_indication_t -> Ppx_deriving_runtime.string =
322
  fun x  -> Format.asprintf "%a" pp_vhdl_subtype_indication_t x
323

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

    
349
and show_vhdl_discrete_range_t :
350
  vhdl_discrete_range_t -> Ppx_deriving_runtime.string =
351
  fun x  -> Format.asprintf "%a" pp_vhdl_discrete_range_t x
352

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

    
411
and show_vhdl_constraint_t : vhdl_constraint_t -> Ppx_deriving_runtime.string
412
  = fun x  -> Format.asprintf "%a" pp_vhdl_constraint_t x
413

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

    
440
and show_vhdl_definition_t : vhdl_definition_t -> Ppx_deriving_runtime.string
441
  = fun x  -> Format.asprintf "%a" pp_vhdl_definition_t x
442

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

    
587
and show_vhdl_expr_t : vhdl_expr_t -> Ppx_deriving_runtime.string =
588
  fun x  -> Format.asprintf "%a" pp_vhdl_expr_t x
589

    
590
and pp_vhdl_name_t :
591
  Format.formatter -> vhdl_name_t -> Ppx_deriving_runtime.unit =
592
  let __9 () = pp_vhdl_assoc_element_t
593
  
594
  and __8 () = pp_vhdl_name_t
595
  
596
  and __7 () = pp_vhdl_expr_t
597
  
598
  and __6 () = pp_vhdl_name_t
599
  
600
  and __5 () = pp_vhdl_name_t
601
  
602
  and __4 () = pp_vhdl_discrete_range_t
603
  
604
  and __3 () = pp_vhdl_name_t
605
  
606
  and __2 () = pp_vhdl_expr_t
607
  
608
  and __1 () = pp_vhdl_name_t
609
  
610
  and __0 () = pp_vhdl_name_t
611
   in
612
  ((let open! Ppx_deriving_runtime in
613
      fun fmt  ->
614
        function
615
        | Simple a0 ->
616
             (Format.fprintf fmt "%s") a0;
617
        | Identifier a0 ->
618
             (Format.fprintf fmt "%s") a0;
619
        | Selected a0 ->
620
             ((fun x  ->
621
                 ignore
622
                   (List.fold_left
623
                      (fun sep  ->
624
                         fun x  ->
625
                           if sep then Format.fprintf fmt ".";
626
                           ((__0 ()) fmt) x;
627
                           true) false x);) a0;)
628
        | Index { id = aid; exprs = aexprs } ->
629
            ((__1 ()) fmt) aid;
630
            Format.fprintf fmt "(";
631
            (fun x  ->
632
                ignore
633
                (List.fold_left
634
                  (fun sep  ->
635
                    fun x  ->
636
                      if sep then Format.fprintf fmt ",@ ";
637
                                  ((__2 ()) fmt) x;
638
                                  true
639
                  ) false x);
640
            ) aexprs;
641
            Format.fprintf fmt ")";
642
        | Slice { id = aid; range = arange } ->
643
              ((__3 ()) fmt) aid;
644
              Format.fprintf fmt "(";
645
              ((__4 ()) fmt) arange;
646
              Format.fprintf fmt ")";
647
        | Attribute { id = aid; designator = adesignator; expr = aexpr } ->
648
              ((__5 ()) fmt) aid;
649
              Format.fprintf fmt "\'";
650
              ((__6 ()) fmt) adesignator;
651
              (match aexpr with
652
              | IsNull -> Format.fprintf fmt "";
653
              | _ ->
654
                Format.fprintf fmt "(";
655
                ((__7 ()) fmt) aexpr;
656
                Format.fprintf fmt ")")
657
        | Function { id = aid; assoc_list = aassoc_list } ->
658
            (((__8 ()) fmt) aid;
659
            Format.fprintf fmt "(";
660
            ((fun x  ->
661
              Format.fprintf fmt "@[";
662
              ignore
663
                (List.fold_left
664
                   (fun sep  ->
665
                      fun x  ->
666
                        if sep then Format.fprintf fmt ";@ ";
667
                        ((__9 ()) fmt) x;
668
                        true) false x);
669
            Format.fprintf fmt "@]")) aassoc_list;
670
            Format.fprintf fmt ")";)
671
        | NoName  -> Format.pp_print_string fmt "")
672
    [@ocaml.warning "-A"])
673

    
674
and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string =
675
  fun x  -> Format.asprintf "%a" pp_vhdl_name_t x
676

    
677
and pp_vhdl_assoc_element_t :
678
  Format.formatter -> vhdl_assoc_element_t -> Ppx_deriving_runtime.unit =
679
  let __4 () = pp_vhdl_expr_t
680
  
681
  and __3 () = pp_vhdl_name_t
682
  
683
  and __2 () = pp_vhdl_name_t
684
  
685
  and __1 () = pp_vhdl_name_t
686
  
687
  and __0 () = pp_vhdl_name_t
688
   in
689
  ((let open! Ppx_deriving_runtime in
690
      fun fmt  ->
691
        fun x  ->
692
          (match x.formal_name with
693
          | None -> Format.pp_print_string fmt ""
694
          | Some NoName -> Format.pp_print_string fmt ""
695
          | Some a -> 
696
              (((__0 ()) fmt) a;
697
              (match x.formal_arg with
698
              | None -> Format.pp_print_string fmt ""
699
              | Some b -> ((__1 ()) fmt) b);
700
              Format.fprintf fmt " => "));
701
          (match x.actual_name with
702
          | None -> 
703
              ((match x.actual_designator with
704
              | None -> Format.pp_print_string fmt ""
705
              | Some NoName -> Format.pp_print_string fmt ""
706
              | Some b -> ((__3 ()) fmt) b);
707
              (match x.actual_expr with
708
              | None -> Format.pp_print_string fmt ""
709
              | Some IsNull -> Format.pp_print_string fmt ""
710
              | Some c -> ((__4 ()) fmt) c);)
711
          | Some a -> 
712
              (((__2 ()) fmt) a;
713
              (match a with
714
              | NoName -> ()
715
              | _ -> Format.fprintf fmt "(");
716
              (match x.actual_designator with
717
              | None -> Format.pp_print_string fmt ""
718
              | Some b -> ((__3 ()) fmt) b);
719
              (match x.actual_expr with
720
              | None -> Format.pp_print_string fmt ""
721
              | Some IsNull -> Format.pp_print_string fmt ""
722
              | Some c -> ((__4 ()) fmt) c);
723
              (match a with
724
              | NoName -> ()
725
              | _ -> Format.fprintf fmt ")")));)
726
    [@ocaml.warning "-A"])
727

    
728
and show_vhdl_assoc_element_t :
729
  vhdl_assoc_element_t -> Ppx_deriving_runtime.string =
730
  fun x  -> Format.asprintf "%a" pp_vhdl_assoc_element_t x
731

    
732
and pp_vhdl_element_assoc_t :
733
  Format.formatter -> vhdl_element_assoc_t -> Ppx_deriving_runtime.unit =
734
  let __1 () = pp_vhdl_expr_t
735
  
736
  and __0 () = pp_vhdl_expr_t
737
   in
738
  ((let open! Ppx_deriving_runtime in
739
      fun fmt  ->
740
        fun x  ->
741
            (match x.choices with
742
            | [] -> Format.fprintf fmt "";
743
            | _ -> 
744
              (((fun x  ->
745
                ignore
746
                  (List.fold_left
747
                     (fun sep  ->
748
                        fun x  ->
749
                          if sep then Format.fprintf fmt "|@ ";
750
                          ((__0 ()) fmt) x;
751
                          true) false x))) x.choices;
752
              Format.fprintf fmt " => ";));
753
           ((__1 ()) fmt) x.expr)
754
    [@ocaml.warning "-A"])
755

    
756
and show_vhdl_element_assoc_t :
757
  vhdl_element_assoc_t -> Ppx_deriving_runtime.string =
758
  fun x  -> Format.asprintf "%a" pp_vhdl_element_assoc_t x
759

    
760
(* TODO *)
761
and (pp_vhdl_array_attributes_t :
762
      Format.formatter ->
763
        vhdl_array_attributes_t -> Ppx_deriving_runtime.unit)
764
  =
765
  ((let open! Ppx_deriving_runtime in
766
      fun fmt  ->
767
        function
768
        | AAttInt { id = aid; arg = aarg } ->
769
            (Format.fprintf fmt "@[<2>AAttInt {@,";
770
             ((Format.fprintf fmt "@[%s =@ " "id";
771
               (Format.fprintf fmt "%S") aid;
772
               Format.fprintf fmt "@]");
773
              Format.fprintf fmt ";@ ";
774
              Format.fprintf fmt "@[%s =@ " "arg";
775
              (Format.fprintf fmt "%d") aarg;
776
              Format.fprintf fmt "@]");
777
             Format.fprintf fmt "@]}")
778
        | AAttAscending  -> Format.pp_print_string fmt "AAttAscending")
779
  [@ocaml.warning "-A"])
780

    
781
and show_vhdl_array_attributes_t :
782
  vhdl_array_attributes_t -> Ppx_deriving_runtime.string =
783
  fun x  -> Format.asprintf "%a" pp_vhdl_array_attributes_t x
784

    
785
(* TODO *)
786
and (pp_vhdl_signal_attributes_t :
787
      Format.formatter ->
788
        vhdl_signal_attributes_t -> Ppx_deriving_runtime.unit)
789
  =
790
  ((let open! Ppx_deriving_runtime in
791
      fun fmt  ->
792
        function
793
        | SigAtt a0 ->
794
            (Format.fprintf fmt "(@[<2>SigAtt@ ";
795
             (Format.fprintf fmt "%S") a0;
796
             Format.fprintf fmt "@])"))
797
  [@ocaml.warning "-A"])
798

    
799
and show_vhdl_signal_attributes_t :
800
  vhdl_signal_attributes_t -> Ppx_deriving_runtime.string =
801
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_attributes_t x
802

    
803
(* TODO *)
804
and (pp_vhdl_string_attributes_t :
805
      Format.formatter ->
806
        vhdl_string_attributes_t -> Ppx_deriving_runtime.unit)
807
  =
808
  ((let open! Ppx_deriving_runtime in
809
      fun fmt  ->
810
        function
811
        | StringAtt a0 ->
812
            (Format.fprintf fmt "(@[<2>StringAtt@ ";
813
             (Format.fprintf fmt "%S") a0;
814
             Format.fprintf fmt "@])"))
815
  [@ocaml.warning "-A"])
816

    
817
and show_vhdl_string_attributes_t :
818
  vhdl_string_attributes_t -> Ppx_deriving_runtime.string =
819
  fun x  -> Format.asprintf "%a" pp_vhdl_string_attributes_t x
820

    
821
(* TODO *)
822
and (pp_vhdl_suffix_selection_t :
823
      Format.formatter ->
824
        vhdl_suffix_selection_t -> Ppx_deriving_runtime.unit)
825
  =
826
  ((let open! Ppx_deriving_runtime in
827
      fun fmt  ->
828
        function
829
        | Idx a0 ->
830
            (Format.fprintf fmt "(@[<2>Idx@ ";
831
             (Format.fprintf fmt "%d") a0;
832
             Format.fprintf fmt "@])")
833
        | SuffixRange (a0,a1) ->
834
            (Format.fprintf fmt "(@[<2>SuffixRange (@,";
835
             ((Format.fprintf fmt "%d") a0;
836
              Format.fprintf fmt ",@ ";
837
              (Format.fprintf fmt "%d") a1);
838
             Format.fprintf fmt "@,))@]"))
839
  [@ocaml.warning "-A"])
840

    
841
and show_vhdl_suffix_selection_t :
842
  vhdl_suffix_selection_t -> Ppx_deriving_runtime.string =
843
  fun x  -> Format.asprintf "%a" pp_vhdl_suffix_selection_t x
844

    
845
let rec (vhdl_type_t_to_yojson : vhdl_type_t -> Yojson.Safe.json) =
846
  ((let open! Ppx_deriving_yojson_runtime in
847
      function
848
      | Base arg0 ->
849
          `List
850
            [`String "Base";
851
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
852
      | Range (arg0,arg1,arg2) ->
853
          `List
854
            [`String "Range";
855
            ((function
856
              | None  -> `Null
857
              | Some x ->
858
                  ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x))
859
              arg0;
860
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1;
861
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg2]
862
      | Bit_vector (arg0,arg1) ->
863
          `List
864
            [`String "Bit_vector";
865
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
866
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1]
867
      | Array arg0 ->
868
          `List
869
            [`String "ARRAY_TYPE_DEFINITION";
870
            (let fields = []  in
871
             let fields =
872
               ("definition",
873
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x)
874
                    arg0.definition))
875
               :: fields  in
876
             let fields =
877
               if arg0.const = None
878
               then fields
879
               else
880
                 ("const",
881
                   (((function
882
                      | None  -> `Null
883
                      | Some x ->
884
                          ((fun x  -> vhdl_constraint_t_to_yojson x)) x))
885
                      arg0.const))
886
                 :: fields
887
                in
888
             let fields =
889
               if arg0.indexes = []
890
               then fields
891
               else
892
                 ("indexes",
893
                   (((fun x  ->
894
                        `List
895
                          (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
896
                      arg0.indexes))
897
                 :: fields
898
                in
899
             `Assoc fields)]
900
      | Record arg0 ->
901
          `List
902
            [`String "RECORD_TYPE_DEFINITION";
903
            ((fun x  ->
904
                `List
905
                  (List.map
906
                     (fun x  -> vhdl_element_declaration_t_to_yojson x) x)))
907
              arg0]
908
      | Enumerated arg0 ->
909
          `List
910
            [`String "ENUMERATION_TYPE_DEFINITION";
911
            ((fun x  ->
912
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
913
      | Void  -> `List [`String "Void"])
914
  [@ocaml.warning "-A"])
915

    
916
and (vhdl_type_t_of_yojson :
917
      Yojson.Safe.json -> vhdl_type_t Ppx_deriving_yojson_runtime.error_or)
918
  =
919
  ((let open! Ppx_deriving_yojson_runtime in
920
      function
921
      | `List ((`String "Base")::arg0::[]) ->
922
          ((function
923
            | `String x -> Result.Ok x
924
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
925
            ((fun arg0  -> Result.Ok (Base arg0)))
926
      | `List ((`String "Range")::arg0::arg1::arg2::[]) ->
927
          ((function
928
            | `Int x -> Result.Ok x
929
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg2) >>=
930
            ((fun arg2  ->
931
                ((function
932
                  | `Int x -> Result.Ok x
933
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
934
                  (fun arg1  ->
935
                     ((function
936
                       | `Null -> Result.Ok None
937
                       | x ->
938
                           ((function
939
                             | `String x -> Result.Ok x
940
                             | _ -> Result.Error "Vhdl_ast.vhdl_type_t") x)
941
                             >>= ((fun x  -> Result.Ok (Some x)))) arg0)
942
                       >>=
943
                       (fun arg0  -> Result.Ok (Range (arg0, arg1, arg2))))))
944
      | `List ((`String "Bit_vector")::arg0::arg1::[]) ->
945
          ((function
946
            | `Int x -> Result.Ok x
947
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg1) >>=
948
            ((fun arg1  ->
949
                ((function
950
                  | `Int x -> Result.Ok x
951
                  | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
952
                  (fun arg0  -> Result.Ok (Bit_vector (arg0, arg1)))))
953
      | `List ((`String "ARRAY_TYPE_DEFINITION")::arg0::[]) ->
954
          ((function
955
            | `Assoc xs ->
956
                let rec loop xs ((arg0,arg1,arg2) as _state) =
957
                  match xs with
958
                  | ("indexes",x)::xs ->
959
                      loop xs
960
                        (((function
961
                           | `List xs ->
962
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
963
                                 [] xs
964
                           | _ -> Result.Error "Vhdl_ast.vhdl_type_t.indexes")
965
                            x), arg1, arg2)
966
                  | ("const",x)::xs ->
967
                      loop xs
968
                        (arg0,
969
                          ((function
970
                            | `Null -> Result.Ok None
971
                            | x ->
972
                                ((fun x  -> vhdl_constraint_t_of_yojson x) x)
973
                                  >>= ((fun x  -> Result.Ok (Some x)))) x),
974
                          arg2)
975
                  | ("definition",x)::xs ->
976
                      loop xs
977
                        (arg0, arg1,
978
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
979
                             x))
980
                  | [] ->
981
                      arg2 >>=
982
                        ((fun arg2  ->
983
                            arg1 >>=
984
                              (fun arg1  ->
985
                                 arg0 >>=
986
                                   (fun arg0  ->
987
                                      Result.Ok
988
                                        (Array
989
                                           {
990
                                             indexes = arg0;
991
                                             const = arg1;
992
                                             definition = arg2
993
                                           })))))
994
                  | _::xs -> loop xs _state  in
995
                loop xs
996
                  ((Result.Ok []), (Result.Ok None),
997
                    (Result.Error "Vhdl_ast.vhdl_type_t.definition"))
998
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t")) arg0
999
      | `List ((`String "RECORD_TYPE_DEFINITION")::arg0::[]) ->
1000
          ((function
1001
            | `List xs ->
1002
                map_bind (fun x  -> vhdl_element_declaration_t_of_yojson x)
1003
                  [] xs
1004
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
1005
            ((fun arg0  -> Result.Ok (Record arg0)))
1006
      | `List ((`String "ENUMERATION_TYPE_DEFINITION")::arg0::[]) ->
1007
          ((function
1008
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1009
            | _ -> Result.Error "Vhdl_ast.vhdl_type_t") arg0) >>=
1010
            ((fun arg0  -> Result.Ok (Enumerated arg0)))
1011
      | `List ((`String "Void")::[]) -> Result.Ok Void
1012
      | _ -> Result.Error "Vhdl_ast.vhdl_type_t")
1013
  [@ocaml.warning "-A"])
1014

    
1015
and (vhdl_element_declaration_t_to_yojson :
1016
      vhdl_element_declaration_t -> Yojson.Safe.json)
1017
  =
1018
  ((let open! Ppx_deriving_yojson_runtime in
1019
      fun x  ->
1020
        let fields = []  in
1021
        let fields =
1022
          ("definition",
1023
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.definition))
1024
          :: fields  in
1025
        let fields =
1026
          ("names",
1027
            ((fun x  ->
1028
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
1029
               x.names))
1030
          :: fields  in
1031
        `Assoc fields)
1032
  [@ocaml.warning "-A"])
1033

    
1034
and (vhdl_element_declaration_t_of_yojson :
1035
      Yojson.Safe.json ->
1036
        vhdl_element_declaration_t Ppx_deriving_yojson_runtime.error_or)
1037
  =
1038
  ((let open! Ppx_deriving_yojson_runtime in
1039
      function
1040
      | `Assoc xs ->
1041
          let rec loop xs ((arg0,arg1) as _state) =
1042
            match xs with
1043
            | ("names",x)::xs ->
1044
                loop xs
1045
                  (((function
1046
                     | `List xs ->
1047
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1048
                     | _ ->
1049
                         Result.Error
1050
                           "Vhdl_ast.vhdl_element_declaration_t.names") x),
1051
                    arg1)
1052
            | ("definition",x)::xs ->
1053
                loop xs
1054
                  (arg0,
1055
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x))
1056
            | [] ->
1057
                arg1 >>=
1058
                  ((fun arg1  ->
1059
                      arg0 >>=
1060
                        (fun arg0  ->
1061
                           Result.Ok { names = arg0; definition = arg1 })))
1062
            | _::xs -> loop xs _state  in
1063
          loop xs
1064
            ((Result.Error "Vhdl_ast.vhdl_element_declaration_t.names"),
1065
              (Result.Error "Vhdl_ast.vhdl_element_declaration_t.definition"))
1066
      | _ -> Result.Error "Vhdl_ast.vhdl_element_declaration_t")
1067
  [@ocaml.warning "-A"])
1068

    
1069
and (vhdl_subtype_indication_t_to_yojson :
1070
      vhdl_subtype_indication_t -> Yojson.Safe.json)
1071
  =
1072
  ((let open! Ppx_deriving_yojson_runtime in
1073
      fun x  ->
1074
        let fields = []  in
1075
        let fields =
1076
          if x.const = NoConstraint
1077
          then fields
1078
          else
1079
            ("const", (((fun x  -> vhdl_constraint_t_to_yojson x)) x.const))
1080
            :: fields
1081
           in
1082
        let fields =
1083
          if x.functionName = NoName
1084
          then fields
1085
          else
1086
            ("functionName",
1087
              (((fun x  -> vhdl_name_t_to_yojson x)) x.functionName))
1088
            :: fields
1089
           in
1090
        let fields =
1091
          if x.name = NoName
1092
          then fields
1093
          else ("name", (((fun x  -> vhdl_name_t_to_yojson x)) x.name)) ::
1094
            fields
1095
           in
1096
        `Assoc fields)
1097
  [@ocaml.warning "-A"])
1098

    
1099
and (vhdl_subtype_indication_t_of_yojson :
1100
      Yojson.Safe.json ->
1101
        vhdl_subtype_indication_t Ppx_deriving_yojson_runtime.error_or)
1102
  =
1103
  ((let open! Ppx_deriving_yojson_runtime in
1104
      function
1105
      | `Assoc xs ->
1106
          let rec loop xs ((arg0,arg1,arg2) as _state) =
1107
            match xs with
1108
            | ("name",x)::xs ->
1109
                loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
1110
            | ("functionName",x)::xs ->
1111
                loop xs (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
1112
            | ("const",x)::xs ->
1113
                loop xs
1114
                  (arg0, arg1, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
1115
            | [] ->
1116
                arg2 >>=
1117
                  ((fun arg2  ->
1118
                      arg1 >>=
1119
                        (fun arg1  ->
1120
                           arg0 >>=
1121
                             (fun arg0  ->
1122
                                Result.Ok
1123
                                  {
1124
                                    name = arg0;
1125
                                    functionName = arg1;
1126
                                    const = arg2
1127
                                  }))))
1128
            | _::xs -> loop xs _state  in
1129
          loop xs
1130
            ((Result.Ok NoName), (Result.Ok NoName),
1131
              (Result.Ok NoConstraint))
1132
      | _ -> Result.Error "Vhdl_ast.vhdl_subtype_indication_t")
1133
  [@ocaml.warning "-A"])
1134

    
1135
and (vhdl_discrete_range_t_to_yojson :
1136
      vhdl_discrete_range_t -> Yojson.Safe.json)
1137
  =
1138
  ((let open! Ppx_deriving_yojson_runtime in
1139
      function
1140
      | SubDiscreteRange arg0 ->
1141
          `List
1142
            [`String "SUB_DISCRETE_RANGE";
1143
            ((fun x  -> vhdl_subtype_indication_t_to_yojson x)) arg0]
1144
      | NamedRange arg0 ->
1145
          `List
1146
            [`String "NAMED_RANGE";
1147
            ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
1148
      | DirectedRange arg0 ->
1149
          `List
1150
            [`String "RANGE_WITH_DIRECTION";
1151
            (let fields = []  in
1152
             let fields =
1153
               ("_to", ((fun x  -> vhdl_expr_t_to_yojson x) arg0._to)) ::
1154
               fields  in
1155
             let fields =
1156
               ("from", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.from)) ::
1157
               fields  in
1158
             let fields =
1159
               ("direction",
1160
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
1161
                    arg0.direction))
1162
               :: fields  in
1163
             `Assoc fields)])
1164
  [@ocaml.warning "-A"])
1165

    
1166
and (vhdl_discrete_range_t_of_yojson :
1167
      Yojson.Safe.json ->
1168
        vhdl_discrete_range_t Ppx_deriving_yojson_runtime.error_or)
1169
  =
1170
  ((let open! Ppx_deriving_yojson_runtime in
1171
      function
1172
      | `List ((`String "SUB_DISCRETE_RANGE")::arg0::[]) ->
1173
          ((fun x  -> vhdl_subtype_indication_t_of_yojson x) arg0) >>=
1174
            ((fun arg0  -> Result.Ok (SubDiscreteRange arg0)))
1175
      | `List ((`String "NAMED_RANGE")::arg0::[]) ->
1176
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
1177
            ((fun arg0  -> Result.Ok (NamedRange arg0)))
1178
      | `List ((`String "RANGE_WITH_DIRECTION")::arg0::[]) ->
1179
          ((function
1180
            | `Assoc xs ->
1181
                let rec loop xs ((arg0,arg1,arg2) as _state) =
1182
                  match xs with
1183
                  | ("direction",x)::xs ->
1184
                      loop xs
1185
                        (((function
1186
                           | `String x -> Result.Ok x
1187
                           | _ ->
1188
                               Result.Error
1189
                                 "Vhdl_ast.vhdl_discrete_range_t.direction")
1190
                            x), arg1, arg2)
1191
                  | ("from",x)::xs ->
1192
                      loop xs
1193
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
1194
                  | ("_to",x)::xs ->
1195
                      loop xs
1196
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1197
                  | [] ->
1198
                      arg2 >>=
1199
                        ((fun arg2  ->
1200
                            arg1 >>=
1201
                              (fun arg1  ->
1202
                                 arg0 >>=
1203
                                   (fun arg0  ->
1204
                                      Result.Ok
1205
                                        (DirectedRange
1206
                                           {
1207
                                             direction = arg0;
1208
                                             from = arg1;
1209
                                             _to = arg2
1210
                                           })))))
1211
                  | _::xs -> loop xs _state  in
1212
                loop xs
1213
                  ((Result.Error "Vhdl_ast.vhdl_discrete_range_t.direction"),
1214
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t.from"),
1215
                    (Result.Error "Vhdl_ast.vhdl_discrete_range_t._to"))
1216
            | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")) arg0
1217
      | _ -> Result.Error "Vhdl_ast.vhdl_discrete_range_t")
1218
  [@ocaml.warning "-A"])
1219

    
1220
and (vhdl_constraint_t_to_yojson : vhdl_constraint_t -> Yojson.Safe.json) =
1221
  ((let open! Ppx_deriving_yojson_runtime in
1222
      function
1223
      | RefConstraint arg0 ->
1224
          `List
1225
            [`String "RefConstraint";
1226
            (let fields = []  in
1227
             let fields =
1228
               ("ref_name",
1229
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.ref_name))
1230
               :: fields  in
1231
             `Assoc fields)]
1232
      | RangeConstraint arg0 ->
1233
          `List
1234
            [`String "RANGE_CONSTRAINT";
1235
            (let fields = []  in
1236
             let fields =
1237
               ("range",
1238
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
1239
               :: fields  in
1240
             `Assoc fields)]
1241
      | IndexConstraint arg0 ->
1242
          `List
1243
            [`String "INDEX_CONSTRAINT";
1244
            (let fields = []  in
1245
             let fields =
1246
               ("ranges",
1247
                 ((fun x  ->
1248
                     `List
1249
                       (List.map
1250
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1251
                    arg0.ranges))
1252
               :: fields  in
1253
             `Assoc fields)]
1254
      | ArrayConstraint arg0 ->
1255
          `List
1256
            [`String "ARRAY_CONSTRAINT";
1257
            (let fields = []  in
1258
             let fields =
1259
               ("sub", ((fun x  -> vhdl_constraint_t_to_yojson x) arg0.sub))
1260
               :: fields  in
1261
             let fields =
1262
               ("ranges",
1263
                 ((fun x  ->
1264
                     `List
1265
                       (List.map
1266
                          (fun x  -> vhdl_discrete_range_t_to_yojson x) x))
1267
                    arg0.ranges))
1268
               :: fields  in
1269
             `Assoc fields)]
1270
      | RecordConstraint  -> `List [`String "RecordConstraint"]
1271
      | NoConstraint  -> `List [`String "NoConstraint"])
1272
  [@ocaml.warning "-A"])
1273

    
1274
and (vhdl_constraint_t_of_yojson :
1275
      Yojson.Safe.json ->
1276
        vhdl_constraint_t Ppx_deriving_yojson_runtime.error_or)
1277
  =
1278
  ((let open! Ppx_deriving_yojson_runtime in
1279
      function
1280
      | `List ((`String "RefConstraint")::arg0::[]) ->
1281
          ((function
1282
            | `Assoc xs ->
1283
                let rec loop xs (arg0 as _state) =
1284
                  match xs with
1285
                  | ("ref_name",x)::xs ->
1286
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
1287
                  | [] ->
1288
                      arg0 >>=
1289
                        ((fun arg0  ->
1290
                            Result.Ok (RefConstraint { ref_name = arg0 })))
1291
                  | _::xs -> loop xs _state  in
1292
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ref_name")
1293
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1294
      | `List ((`String "RANGE_CONSTRAINT")::arg0::[]) ->
1295
          ((function
1296
            | `Assoc xs ->
1297
                let rec loop xs (arg0 as _state) =
1298
                  match xs with
1299
                  | ("range",x)::xs ->
1300
                      loop xs
1301
                        ((fun x  -> vhdl_discrete_range_t_of_yojson x) x)
1302
                  | [] ->
1303
                      arg0 >>=
1304
                        ((fun arg0  ->
1305
                            Result.Ok (RangeConstraint { range = arg0 })))
1306
                  | _::xs -> loop xs _state  in
1307
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.range")
1308
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1309
      | `List ((`String "INDEX_CONSTRAINT")::arg0::[]) ->
1310
          ((function
1311
            | `Assoc xs ->
1312
                let rec loop xs (arg0 as _state) =
1313
                  match xs with
1314
                  | ("ranges",x)::xs ->
1315
                      loop xs
1316
                        ((function
1317
                          | `List xs ->
1318
                              map_bind
1319
                                (fun x  -> vhdl_discrete_range_t_of_yojson x)
1320
                                [] xs
1321
                          | _ ->
1322
                              Result.Error
1323
                                "Vhdl_ast.vhdl_constraint_t.ranges") x)
1324
                  | [] ->
1325
                      arg0 >>=
1326
                        ((fun arg0  ->
1327
                            Result.Ok (IndexConstraint { ranges = arg0 })))
1328
                  | _::xs -> loop xs _state  in
1329
                loop xs (Result.Error "Vhdl_ast.vhdl_constraint_t.ranges")
1330
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1331
      | `List ((`String "ARRAY_CONSTRAINT")::arg0::[]) ->
1332
          ((function
1333
            | `Assoc xs ->
1334
                let rec loop xs ((arg0,arg1) as _state) =
1335
                  match xs with
1336
                  | ("ranges",x)::xs ->
1337
                      loop xs
1338
                        (((function
1339
                           | `List xs ->
1340
                               map_bind
1341
                                 (fun x  -> vhdl_discrete_range_t_of_yojson x)
1342
                                 [] xs
1343
                           | _ ->
1344
                               Result.Error
1345
                                 "Vhdl_ast.vhdl_constraint_t.ranges") x),
1346
                          arg1)
1347
                  | ("sub",x)::xs ->
1348
                      loop xs
1349
                        (arg0, ((fun x  -> vhdl_constraint_t_of_yojson x) x))
1350
                  | [] ->
1351
                      arg1 >>=
1352
                        ((fun arg1  ->
1353
                            arg0 >>=
1354
                              (fun arg0  ->
1355
                                 Result.Ok
1356
                                   (ArrayConstraint
1357
                                      { ranges = arg0; sub = arg1 }))))
1358
                  | _::xs -> loop xs _state  in
1359
                loop xs
1360
                  ((Result.Error "Vhdl_ast.vhdl_constraint_t.ranges"),
1361
                    (Result.Error "Vhdl_ast.vhdl_constraint_t.sub"))
1362
            | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")) arg0
1363
      | `List ((`String "RecordConstraint")::[]) ->
1364
          Result.Ok RecordConstraint
1365
      | `List ((`String "NoConstraint")::[]) -> Result.Ok NoConstraint
1366
      | _ -> Result.Error "Vhdl_ast.vhdl_constraint_t")
1367
  [@ocaml.warning "-A"])
1368

    
1369
and (vhdl_definition_t_to_yojson : vhdl_definition_t -> Yojson.Safe.json) =
1370
  ((let open! Ppx_deriving_yojson_runtime in
1371
      function
1372
      | Type arg0 ->
1373
          `List
1374
            [`String "TYPE_DECLARATION";
1375
            (let fields = []  in
1376
             let fields =
1377
               ("definition",
1378
                 ((fun x  -> vhdl_type_t_to_yojson x) arg0.definition))
1379
               :: fields  in
1380
             let fields =
1381
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1382
               fields  in
1383
             `Assoc fields)]
1384
      | Subtype arg0 ->
1385
          `List
1386
            [`String "SUBTYPE_DECLARATION";
1387
            (let fields = []  in
1388
             let fields =
1389
               ("typ",
1390
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
1391
               :: fields  in
1392
             let fields =
1393
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1394
               fields  in
1395
             `Assoc fields)])
1396
  [@ocaml.warning "-A"])
1397

    
1398
and (vhdl_definition_t_of_yojson :
1399
      Yojson.Safe.json ->
1400
        vhdl_definition_t Ppx_deriving_yojson_runtime.error_or)
1401
  =
1402
  ((let open! Ppx_deriving_yojson_runtime in
1403
      function
1404
      | `List ((`String "TYPE_DECLARATION")::arg0::[]) ->
1405
          ((function
1406
            | `Assoc xs ->
1407
                let rec loop xs ((arg0,arg1) as _state) =
1408
                  match xs with
1409
                  | ("name",x)::xs ->
1410
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1411
                  | ("definition",x)::xs ->
1412
                      loop xs (arg0, ((fun x  -> vhdl_type_t_of_yojson x) x))
1413
                  | [] ->
1414
                      arg1 >>=
1415
                        ((fun arg1  ->
1416
                            arg0 >>=
1417
                              (fun arg0  ->
1418
                                 Result.Ok
1419
                                   (Type { name = arg0; definition = arg1 }))))
1420
                  | _::xs -> loop xs _state  in
1421
                loop xs
1422
                  ((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
1423
                    (Result.Error "Vhdl_ast.vhdl_definition_t.definition"))
1424
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
1425
      | `List ((`String "SUBTYPE_DECLARATION")::arg0::[]) ->
1426
          ((function
1427
            | `Assoc xs ->
1428
                let rec loop xs ((arg0,arg1) as _state) =
1429
                  match xs with
1430
                  | ("name",x)::xs ->
1431
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1432
                  | ("typ",x)::xs ->
1433
                      loop xs
1434
                        (arg0,
1435
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
1436
                             x))
1437
                  | [] ->
1438
                      arg1 >>=
1439
                        ((fun arg1  ->
1440
                            arg0 >>=
1441
                              (fun arg0  ->
1442
                                 Result.Ok
1443
                                   (Subtype { name = arg0; typ = arg1 }))))
1444
                  | _::xs -> loop xs _state  in
1445
                loop xs
1446
                  ((Result.Error "Vhdl_ast.vhdl_definition_t.name"),
1447
                    (Result.Error "Vhdl_ast.vhdl_definition_t.typ"))
1448
            | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")) arg0
1449
      | _ -> Result.Error "Vhdl_ast.vhdl_definition_t")
1450
  [@ocaml.warning "-A"])
1451

    
1452
and (vhdl_expr_t_to_yojson : vhdl_expr_t -> Yojson.Safe.json) =
1453
  ((let open! Ppx_deriving_yojson_runtime in
1454
      function
1455
      | Call arg0 ->
1456
          `List [`String "CALL"; ((fun x  -> vhdl_name_t_to_yojson x)) arg0]
1457
      | Cst arg0 ->
1458
          `List
1459
            [`String "CONSTANT_VALUE";
1460
            (let fields = []  in
1461
             let fields =
1462
               if arg0.unit_name = None
1463
               then fields
1464
               else
1465
                 ("unit_name",
1466
                   (((function
1467
                      | None  -> `Null
1468
                      | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
1469
                      arg0.unit_name))
1470
                 :: fields
1471
                in
1472
             let fields =
1473
               ("value", ((fun x  -> vhdl_cst_val_t_to_yojson x) arg0.value))
1474
               :: fields  in
1475
             `Assoc fields)]
1476
      | Op arg0 ->
1477
          `List
1478
            [`String "EXPRESSION";
1479
            (let fields = []  in
1480
             let fields =
1481
               if arg0.args = []
1482
               then fields
1483
               else
1484
                 ("args",
1485
                   (((fun x  ->
1486
                        `List
1487
                          (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
1488
                      arg0.args))
1489
                 :: fields
1490
                in
1491
             let fields =
1492
               if arg0.id = ""
1493
               then fields
1494
               else
1495
                 ("id",
1496
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
1497
                      arg0.id))
1498
                 :: fields
1499
                in
1500
             `Assoc fields)]
1501
      | IsNull  -> `List [`String "IsNull"]
1502
      | Time arg0 ->
1503
          `List
1504
            [`String "Time";
1505
            (let fields = []  in
1506
             let fields =
1507
               if arg0.phy_unit = ""
1508
               then fields
1509
               else
1510
                 ("phy_unit",
1511
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
1512
                      arg0.phy_unit))
1513
                 :: fields
1514
                in
1515
             let fields =
1516
               ("value",
1517
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.value))
1518
               :: fields  in
1519
             `Assoc fields)]
1520
      | Sig arg0 ->
1521
          `List
1522
            [`String "Sig";
1523
            (let fields = []  in
1524
             let fields =
1525
               if arg0.att = None
1526
               then fields
1527
               else
1528
                 ("att",
1529
                   (((function
1530
                      | None  -> `Null
1531
                      | Some x ->
1532
                          ((fun x  -> vhdl_signal_attributes_t_to_yojson x))
1533
                            x)) arg0.att))
1534
                 :: fields
1535
                in
1536
             let fields =
1537
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
1538
               fields  in
1539
             `Assoc fields)]
1540
      | SuffixMod arg0 ->
1541
          `List
1542
            [`String "SuffixMod";
1543
            (let fields = []  in
1544
             let fields =
1545
               ("selection",
1546
                 ((fun x  -> vhdl_suffix_selection_t_to_yojson x)
1547
                    arg0.selection))
1548
               :: fields  in
1549
             let fields =
1550
               ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.expr)) ::
1551
               fields  in
1552
             `Assoc fields)]
1553
      | Aggregate arg0 ->
1554
          `List
1555
            [`String "AGGREGATE";
1556
            (let fields = []  in
1557
             let fields =
1558
               if arg0.elems = []
1559
               then fields
1560
               else
1561
                 ("elems",
1562
                   (((fun x  ->
1563
                        `List
1564
                          (List.map
1565
                             (fun x  -> vhdl_element_assoc_t_to_yojson x) x)))
1566
                      arg0.elems))
1567
                 :: fields
1568
                in
1569
             `Assoc fields)]
1570
      | QualifiedExpression arg0 ->
1571
          `List
1572
            [`String "QUALIFIED_EXPRESSION";
1573
            (let fields = []  in
1574
             let fields =
1575
               if arg0.expression = None
1576
               then fields
1577
               else
1578
                 ("expression",
1579
                   (((function
1580
                      | None  -> `Null
1581
                      | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
1582
                      arg0.expression))
1583
                 :: fields
1584
                in
1585
             let fields =
1586
               if arg0.aggregate = []
1587
               then fields
1588
               else
1589
                 ("aggregate",
1590
                   (((fun x  ->
1591
                        `List
1592
                          (List.map
1593
                             (fun x  -> vhdl_element_assoc_t_to_yojson x) x)))
1594
                      arg0.aggregate))
1595
                 :: fields
1596
                in
1597
             let fields =
1598
               ("type_mark",
1599
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.type_mark))
1600
               :: fields  in
1601
             `Assoc fields)]
1602
      | Others  -> `List [`String "OTHERS"])
1603
  [@ocaml.warning "-A"])
1604

    
1605
and (vhdl_expr_t_of_yojson :
1606
      Yojson.Safe.json -> vhdl_expr_t Ppx_deriving_yojson_runtime.error_or)
1607
  =
1608
  ((let open! Ppx_deriving_yojson_runtime in
1609
      function
1610
      | `List ((`String "CALL")::arg0::[]) ->
1611
          ((fun x  -> vhdl_name_t_of_yojson x) arg0) >>=
1612
            ((fun arg0  -> Result.Ok (Call arg0)))
1613
      | `List ((`String "CONSTANT_VALUE")::arg0::[]) ->
1614
          ((function
1615
            | `Assoc xs ->
1616
                let rec loop xs ((arg0,arg1) as _state) =
1617
                  match xs with
1618
                  | ("value",x)::xs ->
1619
                      loop xs
1620
                        (((fun x  -> vhdl_cst_val_t_of_yojson x) x), arg1)
1621
                  | ("unit_name",x)::xs ->
1622
                      loop xs
1623
                        (arg0,
1624
                          ((function
1625
                            | `Null -> Result.Ok None
1626
                            | x ->
1627
                                ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
1628
                                  ((fun x  -> Result.Ok (Some x)))) x))
1629
                  | [] ->
1630
                      arg1 >>=
1631
                        ((fun arg1  ->
1632
                            arg0 >>=
1633
                              (fun arg0  ->
1634
                                 Result.Ok
1635
                                   (Cst { value = arg0; unit_name = arg1 }))))
1636
                  | _::xs -> loop xs _state  in
1637
                loop xs
1638
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.value"),
1639
                    (Result.Ok None))
1640
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1641
      | `List ((`String "EXPRESSION")::arg0::[]) ->
1642
          ((function
1643
            | `Assoc xs ->
1644
                let rec loop xs ((arg0,arg1) as _state) =
1645
                  match xs with
1646
                  | ("id",x)::xs ->
1647
                      loop xs
1648
                        (((function
1649
                           | `String x -> Result.Ok x
1650
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.id") x),
1651
                          arg1)
1652
                  | ("args",x)::xs ->
1653
                      loop xs
1654
                        (arg0,
1655
                          ((function
1656
                            | `List xs ->
1657
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1658
                                  [] xs
1659
                            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.args")
1660
                             x))
1661
                  | [] ->
1662
                      arg1 >>=
1663
                        ((fun arg1  ->
1664
                            arg0 >>=
1665
                              (fun arg0  ->
1666
                                 Result.Ok (Op { id = arg0; args = arg1 }))))
1667
                  | _::xs -> loop xs _state  in
1668
                loop xs ((Result.Ok ""), (Result.Ok []))
1669
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1670
      | `List ((`String "IsNull")::[]) -> Result.Ok IsNull
1671
      | `List ((`String "Time")::arg0::[]) ->
1672
          ((function
1673
            | `Assoc xs ->
1674
                let rec loop xs ((arg0,arg1) as _state) =
1675
                  match xs with
1676
                  | ("value",x)::xs ->
1677
                      loop xs
1678
                        (((function
1679
                           | `Int x -> Result.Ok x
1680
                           | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.value")
1681
                            x), arg1)
1682
                  | ("phy_unit",x)::xs ->
1683
                      loop xs
1684
                        (arg0,
1685
                          ((function
1686
                            | `String x -> Result.Ok x
1687
                            | _ ->
1688
                                Result.Error "Vhdl_ast.vhdl_expr_t.phy_unit")
1689
                             x))
1690
                  | [] ->
1691
                      arg1 >>=
1692
                        ((fun arg1  ->
1693
                            arg0 >>=
1694
                              (fun arg0  ->
1695
                                 Result.Ok
1696
                                   (Time { value = arg0; phy_unit = arg1 }))))
1697
                  | _::xs -> loop xs _state  in
1698
                loop xs
1699
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.value"),
1700
                    (Result.Ok ""))
1701
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1702
      | `List ((`String "Sig")::arg0::[]) ->
1703
          ((function
1704
            | `Assoc xs ->
1705
                let rec loop xs ((arg0,arg1) as _state) =
1706
                  match xs with
1707
                  | ("name",x)::xs ->
1708
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1709
                  | ("att",x)::xs ->
1710
                      loop xs
1711
                        (arg0,
1712
                          ((function
1713
                            | `Null -> Result.Ok None
1714
                            | x ->
1715
                                ((fun x  ->
1716
                                    vhdl_signal_attributes_t_of_yojson x) x)
1717
                                  >>= ((fun x  -> Result.Ok (Some x)))) x))
1718
                  | [] ->
1719
                      arg1 >>=
1720
                        ((fun arg1  ->
1721
                            arg0 >>=
1722
                              (fun arg0  ->
1723
                                 Result.Ok (Sig { name = arg0; att = arg1 }))))
1724
                  | _::xs -> loop xs _state  in
1725
                loop xs
1726
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.name"),
1727
                    (Result.Ok None))
1728
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1729
      | `List ((`String "SuffixMod")::arg0::[]) ->
1730
          ((function
1731
            | `Assoc xs ->
1732
                let rec loop xs ((arg0,arg1) as _state) =
1733
                  match xs with
1734
                  | ("expr",x)::xs ->
1735
                      loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
1736
                  | ("selection",x)::xs ->
1737
                      loop xs
1738
                        (arg0,
1739
                          ((fun x  -> vhdl_suffix_selection_t_of_yojson x) x))
1740
                  | [] ->
1741
                      arg1 >>=
1742
                        ((fun arg1  ->
1743
                            arg0 >>=
1744
                              (fun arg0  ->
1745
                                 Result.Ok
1746
                                   (SuffixMod
1747
                                      { expr = arg0; selection = arg1 }))))
1748
                  | _::xs -> loop xs _state  in
1749
                loop xs
1750
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.expr"),
1751
                    (Result.Error "Vhdl_ast.vhdl_expr_t.selection"))
1752
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1753
      | `List ((`String "AGGREGATE")::arg0::[]) ->
1754
          ((function
1755
            | `Assoc xs ->
1756
                let rec loop xs (arg0 as _state) =
1757
                  match xs with
1758
                  | ("elems",x)::xs ->
1759
                      loop xs
1760
                        ((function
1761
                          | `List xs ->
1762
                              map_bind
1763
                                (fun x  -> vhdl_element_assoc_t_of_yojson x)
1764
                                [] xs
1765
                          | _ -> Result.Error "Vhdl_ast.vhdl_expr_t.elems") x)
1766
                  | [] ->
1767
                      arg0 >>=
1768
                        ((fun arg0  -> Result.Ok (Aggregate { elems = arg0 })))
1769
                  | _::xs -> loop xs _state  in
1770
                loop xs (Result.Ok [])
1771
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1772
      | `List ((`String "QUALIFIED_EXPRESSION")::arg0::[]) ->
1773
          ((function
1774
            | `Assoc xs ->
1775
                let rec loop xs ((arg0,arg1,arg2) as _state) =
1776
                  match xs with
1777
                  | ("type_mark",x)::xs ->
1778
                      loop xs
1779
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
1780
                  | ("aggregate",x)::xs ->
1781
                      loop xs
1782
                        (arg0,
1783
                          ((function
1784
                            | `List xs ->
1785
                                map_bind
1786
                                  (fun x  -> vhdl_element_assoc_t_of_yojson x)
1787
                                  [] xs
1788
                            | _ ->
1789
                                Result.Error "Vhdl_ast.vhdl_expr_t.aggregate")
1790
                             x), arg2)
1791
                  | ("expression",x)::xs ->
1792
                      loop xs
1793
                        (arg0, arg1,
1794
                          ((function
1795
                            | `Null -> Result.Ok None
1796
                            | x ->
1797
                                ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
1798
                                  ((fun x  -> Result.Ok (Some x)))) x))
1799
                  | [] ->
1800
                      arg2 >>=
1801
                        ((fun arg2  ->
1802
                            arg1 >>=
1803
                              (fun arg1  ->
1804
                                 arg0 >>=
1805
                                   (fun arg0  ->
1806
                                      Result.Ok
1807
                                        (QualifiedExpression
1808
                                           {
1809
                                             type_mark = arg0;
1810
                                             aggregate = arg1;
1811
                                             expression = arg2
1812
                                           })))))
1813
                  | _::xs -> loop xs _state  in
1814
                loop xs
1815
                  ((Result.Error "Vhdl_ast.vhdl_expr_t.type_mark"),
1816
                    (Result.Ok []), (Result.Ok None))
1817
            | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")) arg0
1818
      | `List ((`String "OTHERS")::[]) -> Result.Ok Others
1819
      | _ -> Result.Error "Vhdl_ast.vhdl_expr_t")
1820
  [@ocaml.warning "-A"])
1821

    
1822
and (vhdl_name_t_to_yojson : vhdl_name_t -> Yojson.Safe.json) =
1823
  ((let open! Ppx_deriving_yojson_runtime in
1824
      function
1825
      | Simple arg0 ->
1826
          `List
1827
            [`String "SIMPLE_NAME";
1828
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1829
      | Identifier arg0 ->
1830
          `List
1831
            [`String "IDENTIFIER";
1832
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0]
1833
      | Selected arg0 ->
1834
          `List
1835
            [`String "SELECTED_NAME";
1836
            ((fun x  ->
1837
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
1838
      | Index arg0 ->
1839
          `List
1840
            [`String "INDEXED_NAME";
1841
            (let fields = []  in
1842
             let fields =
1843
               ("exprs",
1844
                 ((fun x  ->
1845
                     `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
1846
                    arg0.exprs))
1847
               :: fields  in
1848
             let fields =
1849
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1850
               fields  in
1851
             `Assoc fields)]
1852
      | Slice arg0 ->
1853
          `List
1854
            [`String "SLICE_NAME";
1855
            (let fields = []  in
1856
             let fields =
1857
               ("range",
1858
                 ((fun x  -> vhdl_discrete_range_t_to_yojson x) arg0.range))
1859
               :: fields  in
1860
             let fields =
1861
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1862
               fields  in
1863
             `Assoc fields)]
1864
      | Attribute arg0 ->
1865
          `List
1866
            [`String "ATTRIBUTE_NAME";
1867
            (let fields = []  in
1868
             let fields =
1869
               if arg0.expr = IsNull
1870
               then fields
1871
               else
1872
                 ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.expr))
1873
                 :: fields
1874
                in
1875
             let fields =
1876
               ("designator",
1877
                 ((fun x  -> vhdl_name_t_to_yojson x) arg0.designator))
1878
               :: fields  in
1879
             let fields =
1880
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1881
               fields  in
1882
             `Assoc fields)]
1883
      | Function arg0 ->
1884
          `List
1885
            [`String "FUNCTION_CALL";
1886
            (let fields = []  in
1887
             let fields =
1888
               ("assoc_list",
1889
                 ((fun x  ->
1890
                     `List
1891
                       (List.map (fun x  -> vhdl_assoc_element_t_to_yojson x)
1892
                          x)) arg0.assoc_list))
1893
               :: fields  in
1894
             let fields =
1895
               ("id", ((fun x  -> vhdl_name_t_to_yojson x) arg0.id)) ::
1896
               fields  in
1897
             `Assoc fields)]
1898
      | NoName  -> `List [`String "NoName"])
1899
  [@ocaml.warning "-A"])
1900

    
1901
and (vhdl_name_t_of_yojson :
1902
      Yojson.Safe.json -> vhdl_name_t Ppx_deriving_yojson_runtime.error_or)
1903
  =
1904
  ((let open! Ppx_deriving_yojson_runtime in
1905
      function
1906
      | `List ((`String "SIMPLE_NAME")::arg0::[]) ->
1907
          ((function
1908
            | `String x -> Result.Ok x
1909
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1910
            ((fun arg0  -> Result.Ok (Simple arg0)))
1911
      | `List ((`String "IDENTIFIER")::arg0::[]) ->
1912
          ((function
1913
            | `String x -> Result.Ok x
1914
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1915
            ((fun arg0  -> Result.Ok (Identifier arg0)))
1916
      | `List ((`String "SELECTED_NAME")::arg0::[]) ->
1917
          ((function
1918
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
1919
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t") arg0) >>=
1920
            ((fun arg0  -> Result.Ok (Selected arg0)))
1921
      | `List ((`String "INDEXED_NAME")::arg0::[]) ->
1922
          ((function
1923
            | `Assoc xs ->
1924
                let rec loop xs ((arg0,arg1) as _state) =
1925
                  match xs with
1926
                  | ("id",x)::xs ->
1927
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1928
                  | ("exprs",x)::xs ->
1929
                      loop xs
1930
                        (arg0,
1931
                          ((function
1932
                            | `List xs ->
1933
                                map_bind (fun x  -> vhdl_expr_t_of_yojson x)
1934
                                  [] xs
1935
                            | _ -> Result.Error "Vhdl_ast.vhdl_name_t.exprs")
1936
                             x))
1937
                  | [] ->
1938
                      arg1 >>=
1939
                        ((fun arg1  ->
1940
                            arg0 >>=
1941
                              (fun arg0  ->
1942
                                 Result.Ok
1943
                                   (Index { id = arg0; exprs = arg1 }))))
1944
                  | _::xs -> loop xs _state  in
1945
                loop xs
1946
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1947
                    (Result.Error "Vhdl_ast.vhdl_name_t.exprs"))
1948
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1949
      | `List ((`String "SLICE_NAME")::arg0::[]) ->
1950
          ((function
1951
            | `Assoc xs ->
1952
                let rec loop xs ((arg0,arg1) as _state) =
1953
                  match xs with
1954
                  | ("id",x)::xs ->
1955
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
1956
                  | ("range",x)::xs ->
1957
                      loop xs
1958
                        (arg0,
1959
                          ((fun x  -> vhdl_discrete_range_t_of_yojson x) x))
1960
                  | [] ->
1961
                      arg1 >>=
1962
                        ((fun arg1  ->
1963
                            arg0 >>=
1964
                              (fun arg0  ->
1965
                                 Result.Ok
1966
                                   (Slice { id = arg0; range = arg1 }))))
1967
                  | _::xs -> loop xs _state  in
1968
                loop xs
1969
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
1970
                    (Result.Error "Vhdl_ast.vhdl_name_t.range"))
1971
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
1972
      | `List ((`String "ATTRIBUTE_NAME")::arg0::[]) ->
1973
          ((function
1974
            | `Assoc xs ->
1975
                let rec loop xs ((arg0,arg1,arg2) as _state) =
1976
                  match xs with
1977
                  | ("id",x)::xs ->
1978
                      loop xs
1979
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
1980
                  | ("designator",x)::xs ->
1981
                      loop xs
1982
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
1983
                  | ("expr",x)::xs ->
1984
                      loop xs
1985
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
1986
                  | [] ->
1987
                      arg2 >>=
1988
                        ((fun arg2  ->
1989
                            arg1 >>=
1990
                              (fun arg1  ->
1991
                                 arg0 >>=
1992
                                   (fun arg0  ->
1993
                                      Result.Ok
1994
                                        (Attribute
1995
                                           {
1996
                                             id = arg0;
1997
                                             designator = arg1;
1998
                                             expr = arg2
1999
                                           })))))
2000
                  | _::xs -> loop xs _state  in
2001
                loop xs
2002
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
2003
                    (Result.Error "Vhdl_ast.vhdl_name_t.designator"),
2004
                    (Result.Ok IsNull))
2005
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
2006
      | `List ((`String "FUNCTION_CALL")::arg0::[]) ->
2007
          ((function
2008
            | `Assoc xs ->
2009
                let rec loop xs ((arg0,arg1) as _state) =
2010
                  match xs with
2011
                  | ("id",x)::xs ->
2012
                      loop xs (((fun x  -> vhdl_name_t_of_yojson x) x), arg1)
2013
                  | ("assoc_list",x)::xs ->
2014
                      loop xs
2015
                        (arg0,
2016
                          ((function
2017
                            | `List xs ->
2018
                                map_bind
2019
                                  (fun x  -> vhdl_assoc_element_t_of_yojson x)
2020
                                  [] xs
2021
                            | _ ->
2022
                                Result.Error
2023
                                  "Vhdl_ast.vhdl_name_t.assoc_list") x))
2024
                  | [] ->
2025
                      arg1 >>=
2026
                        ((fun arg1  ->
2027
                            arg0 >>=
2028
                              (fun arg0  ->
2029
                                 Result.Ok
2030
                                   (Function { id = arg0; assoc_list = arg1 }))))
2031
                  | _::xs -> loop xs _state  in
2032
                loop xs
2033
                  ((Result.Error "Vhdl_ast.vhdl_name_t.id"),
2034
                    (Result.Error "Vhdl_ast.vhdl_name_t.assoc_list"))
2035
            | _ -> Result.Error "Vhdl_ast.vhdl_name_t")) arg0
2036
      | `List ((`String "NoName")::[]) -> Result.Ok NoName
2037
      | _ -> Result.Error "Vhdl_ast.vhdl_name_t")
2038
  [@ocaml.warning "-A"])
2039

    
2040
and (vhdl_assoc_element_t_to_yojson :
2041
      vhdl_assoc_element_t -> Yojson.Safe.json)
2042
  =
2043
  ((let open! Ppx_deriving_yojson_runtime in
2044
      fun x  ->
2045
        let fields = []  in
2046
        let fields =
2047
          if x.actual_expr = None
2048
          then fields
2049
          else
2050
            ("actual_expr",
2051
              (((function
2052
                 | None  -> `Null
2053
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
2054
                 x.actual_expr))
2055
            :: fields
2056
           in
2057
        let fields =
2058
          if x.actual_designator = None
2059
          then fields
2060
          else
2061
            ("actual_designator",
2062
              (((function
2063
                 | None  -> `Null
2064
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
2065
                 x.actual_designator))
2066
            :: fields
2067
           in
2068
        let fields =
2069
          if x.actual_name = None
2070
          then fields
2071
          else
2072
            ("actual_name",
2073
              (((function
2074
                 | None  -> `Null
2075
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
2076
                 x.actual_name))
2077
            :: fields
2078
           in
2079
        let fields =
2080
          if x.formal_arg = None
2081
          then fields
2082
          else
2083
            ("formal_arg",
2084
              (((function
2085
                 | None  -> `Null
2086
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
2087
                 x.formal_arg))
2088
            :: fields
2089
           in
2090
        let fields =
2091
          if x.formal_name = None
2092
          then fields
2093
          else
2094
            ("formal_name",
2095
              (((function
2096
                 | None  -> `Null
2097
                 | Some x -> ((fun x  -> vhdl_name_t_to_yojson x)) x))
2098
                 x.formal_name))
2099
            :: fields
2100
           in
2101
        `Assoc fields)
2102
  [@ocaml.warning "-A"])
2103

    
2104
and (vhdl_assoc_element_t_of_yojson :
2105
      Yojson.Safe.json ->
2106
        vhdl_assoc_element_t Ppx_deriving_yojson_runtime.error_or)
2107
  =
2108
  ((let open! Ppx_deriving_yojson_runtime in
2109
      function
2110
      | `Assoc xs ->
2111
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
2112
            match xs with
2113
            | ("formal_name",x)::xs ->
2114
                loop xs
2115
                  (((function
2116
                     | `Null -> Result.Ok None
2117
                     | x ->
2118
                         ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
2119
                           ((fun x  -> Result.Ok (Some x)))) x), arg1, arg2,
2120
                    arg3, arg4)
2121
            | ("formal_arg",x)::xs ->
2122
                loop xs
2123
                  (arg0,
2124
                    ((function
2125
                      | `Null -> Result.Ok None
2126
                      | x ->
2127
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
2128
                            ((fun x  -> Result.Ok (Some x)))) x), arg2, arg3,
2129
                    arg4)
2130
            | ("actual_name",x)::xs ->
2131
                loop xs
2132
                  (arg0, arg1,
2133
                    ((function
2134
                      | `Null -> Result.Ok None
2135
                      | x ->
2136
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
2137
                            ((fun x  -> Result.Ok (Some x)))) x), arg3, arg4)
2138
            | ("actual_designator",x)::xs ->
2139
                loop xs
2140
                  (arg0, arg1, arg2,
2141
                    ((function
2142
                      | `Null -> Result.Ok None
2143
                      | x ->
2144
                          ((fun x  -> vhdl_name_t_of_yojson x) x) >>=
2145
                            ((fun x  -> Result.Ok (Some x)))) x), arg4)
2146
            | ("actual_expr",x)::xs ->
2147
                loop xs
2148
                  (arg0, arg1, arg2, arg3,
2149
                    ((function
2150
                      | `Null -> Result.Ok None
2151
                      | x ->
2152
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
2153
                            ((fun x  -> Result.Ok (Some x)))) x))
2154
            | [] ->
2155
                arg4 >>=
2156
                  ((fun arg4  ->
2157
                      arg3 >>=
2158
                        (fun arg3  ->
2159
                           arg2 >>=
2160
                             (fun arg2  ->
2161
                                arg1 >>=
2162
                                  (fun arg1  ->
2163
                                     arg0 >>=
2164
                                       (fun arg0  ->
2165
                                          Result.Ok
2166
                                            {
2167
                                              formal_name = arg0;
2168
                                              formal_arg = arg1;
2169
                                              actual_name = arg2;
2170
                                              actual_designator = arg3;
2171
                                              actual_expr = arg4
2172
                                            }))))))
2173
            | _::xs -> loop xs _state  in
2174
          loop xs
2175
            ((Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
2176
              (Result.Ok (Some NoName)), (Result.Ok (Some NoName)),
2177
              (Result.Ok (Some IsNull)))
2178
      | _ -> Result.Error "Vhdl_ast.vhdl_assoc_element_t")
2179
  [@ocaml.warning "-A"])
2180

    
2181
and (vhdl_element_assoc_t_to_yojson :
2182
      vhdl_element_assoc_t -> Yojson.Safe.json)
2183
  =
2184
  ((let open! Ppx_deriving_yojson_runtime in
2185
      fun x  ->
2186
        let fields = []  in
2187
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
2188
          :: fields  in
2189
        let fields =
2190
          if x.choices = []
2191
          then fields
2192
          else
2193
            ("choices",
2194
              (((fun x  ->
2195
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
2196
                 x.choices))
2197
            :: fields
2198
           in
2199
        `Assoc fields)
2200
  [@ocaml.warning "-A"])
2201

    
2202
and (vhdl_element_assoc_t_of_yojson :
2203
      Yojson.Safe.json ->
2204
        vhdl_element_assoc_t Ppx_deriving_yojson_runtime.error_or)
2205
  =
2206
  ((let open! Ppx_deriving_yojson_runtime in
2207
      function
2208
      | `Assoc xs ->
2209
          let rec loop xs ((arg0,arg1) as _state) =
2210
            match xs with
2211
            | ("choices",x)::xs ->
2212
                loop xs
2213
                  (((function
2214
                     | `List xs ->
2215
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
2216
                     | _ ->
2217
                         Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices")
2218
                      x), arg1)
2219
            | ("expr",x)::xs ->
2220
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
2221
            | [] ->
2222
                arg1 >>=
2223
                  ((fun arg1  ->
2224
                      arg0 >>=
2225
                        (fun arg0  ->
2226
                           Result.Ok { choices = arg0; expr = arg1 })))
2227
            | _::xs -> loop xs _state  in
2228
          loop xs
2229
            ((Result.Ok []),
2230
              (Result.Error "Vhdl_ast.vhdl_element_assoc_t.expr"))
2231
      | _ -> Result.Error "Vhdl_ast.vhdl_element_assoc_t")
2232
  [@ocaml.warning "-A"])
2233

    
2234
and (vhdl_array_attributes_t_to_yojson :
2235
      vhdl_array_attributes_t -> Yojson.Safe.json)
2236
  =
2237
  ((let open! Ppx_deriving_yojson_runtime in
2238
      function
2239
      | AAttInt arg0 ->
2240
          `List
2241
            [`String "AAttInt";
2242
            (let fields = []  in
2243
             let fields =
2244
               ("arg",
2245
                 ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
2246
               :: fields  in
2247
             let fields =
2248
               ("id",
2249
                 ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2250
                    arg0.id))
2251
               :: fields  in
2252
             `Assoc fields)]
2253
      | AAttAscending  -> `List [`String "AAttAscending"])
2254
  [@ocaml.warning "-A"])
2255

    
2256
and (vhdl_array_attributes_t_of_yojson :
2257
      Yojson.Safe.json ->
2258
        vhdl_array_attributes_t Ppx_deriving_yojson_runtime.error_or)
2259
  =
2260
  ((let open! Ppx_deriving_yojson_runtime in
2261
      function
2262
      | `List ((`String "AAttInt")::arg0::[]) ->
2263
          ((function
2264
            | `Assoc xs ->
2265
                let rec loop xs ((arg0,arg1) as _state) =
2266
                  match xs with
2267
                  | ("id",x)::xs ->
2268
                      loop xs
2269
                        (((function
2270
                           | `String x -> Result.Ok x
2271
                           | _ ->
2272
                               Result.Error
2273
                                 "Vhdl_ast.vhdl_array_attributes_t.id") x),
2274
                          arg1)
2275
                  | ("arg",x)::xs ->
2276
                      loop xs
2277
                        (arg0,
2278
                          ((function
2279
                            | `Int x -> Result.Ok x
2280
                            | _ ->
2281
                                Result.Error
2282
                                  "Vhdl_ast.vhdl_array_attributes_t.arg") x))
2283
                  | [] ->
2284
                      arg1 >>=
2285
                        ((fun arg1  ->
2286
                            arg0 >>=
2287
                              (fun arg0  ->
2288
                                 Result.Ok
2289
                                   (AAttInt { id = arg0; arg = arg1 }))))
2290
                  | _::xs -> loop xs _state  in
2291
                loop xs
2292
                  ((Result.Error "Vhdl_ast.vhdl_array_attributes_t.id"),
2293
                    (Result.Error "Vhdl_ast.vhdl_array_attributes_t.arg"))
2294
            | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")) arg0
2295
      | `List ((`String "AAttAscending")::[]) -> Result.Ok AAttAscending
2296
      | _ -> Result.Error "Vhdl_ast.vhdl_array_attributes_t")
2297
  [@ocaml.warning "-A"])
2298

    
2299
and (vhdl_signal_attributes_t_to_yojson :
2300
      vhdl_signal_attributes_t -> Yojson.Safe.json)
2301
  =
2302
  ((let open! Ppx_deriving_yojson_runtime in
2303
      function
2304
      | SigAtt arg0 ->
2305
          `List
2306
            [`String "SigAtt";
2307
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
2308
  [@ocaml.warning "-A"])
2309

    
2310
and (vhdl_signal_attributes_t_of_yojson :
2311
      Yojson.Safe.json ->
2312
        vhdl_signal_attributes_t Ppx_deriving_yojson_runtime.error_or)
2313
  =
2314
  ((let open! Ppx_deriving_yojson_runtime in
2315
      function
2316
      | `List ((`String "SigAtt")::arg0::[]) ->
2317
          ((function
2318
            | `String x -> Result.Ok x
2319
            | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t") arg0)
2320
            >>= ((fun arg0  -> Result.Ok (SigAtt arg0)))
2321
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_attributes_t")
2322
  [@ocaml.warning "-A"])
2323

    
2324
and (vhdl_string_attributes_t_to_yojson :
2325
      vhdl_string_attributes_t -> Yojson.Safe.json)
2326
  =
2327
  ((let open! Ppx_deriving_yojson_runtime in
2328
      function
2329
      | StringAtt arg0 ->
2330
          `List
2331
            [`String "StringAtt";
2332
            ((fun (x : Ppx_deriving_runtime.string)  -> `String x)) arg0])
2333
  [@ocaml.warning "-A"])
2334

    
2335
and (vhdl_string_attributes_t_of_yojson :
2336
      Yojson.Safe.json ->
2337
        vhdl_string_attributes_t Ppx_deriving_yojson_runtime.error_or)
2338
  =
2339
  ((let open! Ppx_deriving_yojson_runtime in
2340
      function
2341
      | `List ((`String "StringAtt")::arg0::[]) ->
2342
          ((function
2343
            | `String x -> Result.Ok x
2344
            | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t") arg0)
2345
            >>= ((fun arg0  -> Result.Ok (StringAtt arg0)))
2346
      | _ -> Result.Error "Vhdl_ast.vhdl_string_attributes_t")
2347
  [@ocaml.warning "-A"])
2348

    
2349
and (vhdl_suffix_selection_t_to_yojson :
2350
      vhdl_suffix_selection_t -> Yojson.Safe.json)
2351
  =
2352
  ((let open! Ppx_deriving_yojson_runtime in
2353
      function
2354
      | Idx arg0 ->
2355
          `List
2356
            [`String "Idx";
2357
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0]
2358
      | SuffixRange (arg0,arg1) ->
2359
          `List
2360
            [`String "SuffixRange";
2361
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg0;
2362
            ((fun (x : Ppx_deriving_runtime.int)  -> `Int x)) arg1])
2363
  [@ocaml.warning "-A"])
2364

    
2365
and (vhdl_suffix_selection_t_of_yojson :
2366
      Yojson.Safe.json ->
2367
        vhdl_suffix_selection_t Ppx_deriving_yojson_runtime.error_or)
2368
  =
2369
  ((let open! Ppx_deriving_yojson_runtime in
2370
      function
2371
      | `List ((`String "Idx")::arg0::[]) ->
2372
          ((function
2373
            | `Int x -> Result.Ok x
2374
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg0) >>=
2375
            ((fun arg0  -> Result.Ok (Idx arg0)))
2376
      | `List ((`String "SuffixRange")::arg0::arg1::[]) ->
2377
          ((function
2378
            | `Int x -> Result.Ok x
2379
            | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t") arg1) >>=
2380
            ((fun arg1  ->
2381
                ((function
2382
                  | `Int x -> Result.Ok x
2383
                  | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2384
                   arg0)
2385
                  >>= (fun arg0  -> Result.Ok (SuffixRange (arg0, arg1)))))
2386
      | _ -> Result.Error "Vhdl_ast.vhdl_suffix_selection_t")
2387
  [@ocaml.warning "-A"])
2388

    
2389
type 'basetype vhdl_type_attributes_t =
2390
  | TAttNoArg of {
2391
  id: string } 
2392
  | TAttIntArg of {
2393
  id: string ;
2394
  arg: int } 
2395
  | TAttValArg of {
2396
  id: string ;
2397
  arg: 'basetype } 
2398
  | TAttStringArg of {
2399
  id: string ;
2400
  arg: string } 
2401

    
2402
(* TODO *)
2403
let rec pp_vhdl_type_attributes_t
2404
  =
2405
  ((let open! Ppx_deriving_runtime in
2406
      fun poly_basetype  ->
2407
        fun fmt  ->
2408
          function
2409
          | TAttNoArg { id = aid } ->
2410
              (Format.fprintf fmt "@[<2>TAttNoArg {@,";
2411
               (Format.fprintf fmt "@[%s =@ " "id";
2412
                (Format.fprintf fmt "%S") aid;
2413
                Format.fprintf fmt "@]");
2414
               Format.fprintf fmt "@]}")
2415
          | TAttIntArg { id = aid; arg = aarg } ->
2416
              (Format.fprintf fmt "@[<2>TAttIntArg {@,";
2417
               ((Format.fprintf fmt "@[%s =@ " "id";
2418
                 (Format.fprintf fmt "%S") aid;
2419
                 Format.fprintf fmt "@]");
2420
                Format.fprintf fmt ";@ ";
2421
                Format.fprintf fmt "@[%s =@ " "arg";
2422
                (Format.fprintf fmt "%d") aarg;
2423
                Format.fprintf fmt "@]");
2424
               Format.fprintf fmt "@]}")
2425
          | TAttValArg { id = aid; arg = aarg } ->
2426
              (Format.fprintf fmt "@[<2>TAttValArg {@,";
2427
               ((Format.fprintf fmt "@[%s =@ " "id";
2428
                 (Format.fprintf fmt "%S") aid;
2429
                 Format.fprintf fmt "@]");
2430
                Format.fprintf fmt ";@ ";
2431
                Format.fprintf fmt "@[%s =@ " "arg";
2432
                (poly_basetype fmt) aarg;
2433
                Format.fprintf fmt "@]");
2434
               Format.fprintf fmt "@]}")
2435
          | TAttStringArg { id = aid; arg = aarg } ->
2436
              (Format.fprintf fmt "@[<2>TAttStringArg {@,";
2437
               ((Format.fprintf fmt "@[%s =@ " "id";
2438
                 (Format.fprintf fmt "%S") aid;
2439
                 Format.fprintf fmt "@]");
2440
                Format.fprintf fmt ";@ ";
2441
                Format.fprintf fmt "@[%s =@ " "arg";
2442
                (Format.fprintf fmt "%S") aarg;
2443
                Format.fprintf fmt "@]");
2444
               Format.fprintf fmt "@]}"))
2445
  [@ocaml.warning "-A"])
2446

    
2447
and show_vhdl_type_attributes_t  =
2448
  fun poly_basetype  ->
2449
    fun x  ->
2450
      Format.asprintf "%a" (pp_vhdl_type_attributes_t poly_basetype) x
2451

    
2452
let rec vhdl_type_attributes_t_to_yojson :
2453
  'basetype .
2454
    ('basetype -> Yojson.Safe.json) ->
2455
      'basetype vhdl_type_attributes_t -> Yojson.Safe.json
2456
  =
2457
  fun poly_basetype  ->
2458
    ((let open! Ppx_deriving_yojson_runtime in
2459
        function
2460
        | TAttNoArg arg0 ->
2461
            `List
2462
              [`String "TAttNoArg";
2463
              (let fields = []  in
2464
               let fields =
2465
                 ("id",
2466
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2467
                      arg0.id))
2468
                 :: fields  in
2469
               `Assoc fields)]
2470
        | TAttIntArg arg0 ->
2471
            `List
2472
              [`String "TAttIntArg";
2473
              (let fields = []  in
2474
               let fields =
2475
                 ("arg",
2476
                   ((fun (x : Ppx_deriving_runtime.int)  -> `Int x) arg0.arg))
2477
                 :: fields  in
2478
               let fields =
2479
                 ("id",
2480
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2481
                      arg0.id))
2482
                 :: fields  in
2483
               `Assoc fields)]
2484
        | TAttValArg arg0 ->
2485
            `List
2486
              [`String "TAttValArg";
2487
              (let fields = []  in
2488
               let fields =
2489
                 ("arg", ((poly_basetype : _ -> Yojson.Safe.json) arg0.arg))
2490
                 :: fields  in
2491
               let fields =
2492
                 ("id",
2493
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2494
                      arg0.id))
2495
                 :: fields  in
2496
               `Assoc fields)]
2497
        | TAttStringArg arg0 ->
2498
            `List
2499
              [`String "TAttStringArg";
2500
              (let fields = []  in
2501
               let fields =
2502
                 ("arg",
2503
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2504
                      arg0.arg))
2505
                 :: fields  in
2506
               let fields =
2507
                 ("id",
2508
                   ((fun (x : Ppx_deriving_runtime.string)  -> `String x)
2509
                      arg0.id))
2510
                 :: fields  in
2511
               `Assoc fields)])
2512
    [@ocaml.warning "-A"])
2513

    
2514
and vhdl_type_attributes_t_of_yojson :
2515
  'basetype .
2516
    (Yojson.Safe.json -> 'basetype Ppx_deriving_yojson_runtime.error_or) ->
2517
      Yojson.Safe.json ->
2518
        'basetype vhdl_type_attributes_t Ppx_deriving_yojson_runtime.error_or
2519
  =
2520
  fun poly_basetype  ->
2521
    ((let open! Ppx_deriving_yojson_runtime in
2522
        function
2523
        | `List ((`String "TAttNoArg")::arg0::[]) ->
2524
            ((function
2525
              | `Assoc xs ->
2526
                  let rec loop xs (arg0 as _state) =
2527
                    match xs with
2528
                    | ("id",x)::xs ->
2529
                        loop xs
2530
                          ((function
2531
                            | `String x -> Result.Ok x
2532
                            | _ ->
2533
                                Result.Error
2534
                                  "Vhdl_ast.vhdl_type_attributes_t.id") x)
2535
                    | [] ->
2536
                        arg0 >>=
2537
                          ((fun arg0  -> Result.Ok (TAttNoArg { id = arg0 })))
2538
                    | _::xs -> loop xs _state  in
2539
                  loop xs (Result.Error "Vhdl_ast.vhdl_type_attributes_t.id")
2540
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2541
        | `List ((`String "TAttIntArg")::arg0::[]) ->
2542
            ((function
2543
              | `Assoc xs ->
2544
                  let rec loop xs ((arg0,arg1) as _state) =
2545
                    match xs with
2546
                    | ("id",x)::xs ->
2547
                        loop xs
2548
                          (((function
2549
                             | `String x -> Result.Ok x
2550
                             | _ ->
2551
                                 Result.Error
2552
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2553
                            arg1)
2554
                    | ("arg",x)::xs ->
2555
                        loop xs
2556
                          (arg0,
2557
                            ((function
2558
                              | `Int x -> Result.Ok x
2559
                              | _ ->
2560
                                  Result.Error
2561
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2562
                    | [] ->
2563
                        arg1 >>=
2564
                          ((fun arg1  ->
2565
                              arg0 >>=
2566
                                (fun arg0  ->
2567
                                   Result.Ok
2568
                                     (TAttIntArg { id = arg0; arg = arg1 }))))
2569
                    | _::xs -> loop xs _state  in
2570
                  loop xs
2571
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2572
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2573
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2574
        | `List ((`String "TAttValArg")::arg0::[]) ->
2575
            ((function
2576
              | `Assoc xs ->
2577
                  let rec loop xs ((arg0,arg1) as _state) =
2578
                    match xs with
2579
                    | ("id",x)::xs ->
2580
                        loop xs
2581
                          (((function
2582
                             | `String x -> Result.Ok x
2583
                             | _ ->
2584
                                 Result.Error
2585
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2586
                            arg1)
2587
                    | ("arg",x)::xs ->
2588
                        loop xs
2589
                          (arg0,
2590
                            ((poly_basetype : Yojson.Safe.json -> _ error_or)
2591
                               x))
2592
                    | [] ->
2593
                        arg1 >>=
2594
                          ((fun arg1  ->
2595
                              arg0 >>=
2596
                                (fun arg0  ->
2597
                                   Result.Ok
2598
                                     (TAttValArg { id = arg0; arg = arg1 }))))
2599
                    | _::xs -> loop xs _state  in
2600
                  loop xs
2601
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2602
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2603
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2604
        | `List ((`String "TAttStringArg")::arg0::[]) ->
2605
            ((function
2606
              | `Assoc xs ->
2607
                  let rec loop xs ((arg0,arg1) as _state) =
2608
                    match xs with
2609
                    | ("id",x)::xs ->
2610
                        loop xs
2611
                          (((function
2612
                             | `String x -> Result.Ok x
2613
                             | _ ->
2614
                                 Result.Error
2615
                                   "Vhdl_ast.vhdl_type_attributes_t.id") x),
2616
                            arg1)
2617
                    | ("arg",x)::xs ->
2618
                        loop xs
2619
                          (arg0,
2620
                            ((function
2621
                              | `String x -> Result.Ok x
2622
                              | _ ->
2623
                                  Result.Error
2624
                                    "Vhdl_ast.vhdl_type_attributes_t.arg") x))
2625
                    | [] ->
2626
                        arg1 >>=
2627
                          ((fun arg1  ->
2628
                              arg0 >>=
2629
                                (fun arg0  ->
2630
                                   Result.Ok
2631
                                     (TAttStringArg { id = arg0; arg = arg1 }))))
2632
                    | _::xs -> loop xs _state  in
2633
                  loop xs
2634
                    ((Result.Error "Vhdl_ast.vhdl_type_attributes_t.id"),
2635
                      (Result.Error "Vhdl_ast.vhdl_type_attributes_t.arg"))
2636
              | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")) arg0
2637
        | _ -> Result.Error "Vhdl_ast.vhdl_type_attributes_t")
2638
    [@ocaml.warning "-A"])
2639

    
2640
let typ_att_noarg = ["base"; "left"; "right"; "high"; "low"] 
2641
let typ_att_intarg = ["pos"; "val"; "succ"; "pred"; "leftof"; "rightof"] 
2642
let typ_att_valarg = ["image"] 
2643
let typ_att_stringarg = ["value"] 
2644
let array_att_intarg =
2645
  ["left"; "right"; "high"; "low"; "range"; "reverse_range"; "length"] 
2646
type vhdl_parameter_t =
2647
  {
2648
  names: vhdl_name_t list ;
2649
  mode: string list [@default []];
2650
  typ: vhdl_subtype_indication_t ;
2651
  init_val: vhdl_cst_val_t option [@default None]}
2652

    
2653
(* TODO *)
2654
let rec pp_vhdl_parameter_t :
2655
  Format.formatter -> vhdl_parameter_t -> Ppx_deriving_runtime.unit =
2656
  let __2 () = pp_vhdl_cst_val_t
2657
  
2658
  and __1 () = pp_vhdl_subtype_indication_t
2659
  
2660
  and __0 () = pp_vhdl_name_t
2661
   in
2662
  ((let open! Ppx_deriving_runtime in
2663
      fun fmt  ->
2664
        fun x  ->
2665
          Format.fprintf fmt "@[<2>{ ";
2666
          ((((Format.fprintf fmt "@[%s =@ " "names";
2667
              ((fun x  ->
2668
                  Format.fprintf fmt "@[<2>[";
2669
                  ignore
2670
                    (List.fold_left
2671
                       (fun sep  ->
2672
                          fun x  ->
2673
                            if sep then Format.fprintf fmt ";@ ";
2674
                            ((__0 ()) fmt) x;
2675
                            true) false x);
2676
                  Format.fprintf fmt "@,]@]")) x.names;
2677
              Format.fprintf fmt "@]");
2678
             Format.fprintf fmt ";@ ";
2679
             Format.fprintf fmt "@[%s =@ " "mode";
2680
             ((fun x  ->
2681
                 Format.fprintf fmt "@[<2>[";
2682
                 ignore
2683
                   (List.fold_left
2684
                      (fun sep  ->
2685
                         fun x  ->
2686
                           if sep then Format.fprintf fmt ";@ ";
2687
                           (Format.fprintf fmt "%S") x;
2688
                           true) false x);
2689
                 Format.fprintf fmt "@,]@]")) x.mode;
2690
             Format.fprintf fmt "@]");
2691
            Format.fprintf fmt ";@ ";
2692
            Format.fprintf fmt "@[%s =@ " "typ";
2693
            ((__1 ()) fmt) x.typ;
2694
            Format.fprintf fmt "@]");
2695
           Format.fprintf fmt ";@ ";
2696
           Format.fprintf fmt "@[%s =@ " "init_val";
2697
           ((function
2698
             | None  -> Format.pp_print_string fmt "None"
2699
             | Some x ->
2700
                 (Format.pp_print_string fmt "(Some ";
2701
                  ((__2 ()) fmt) x;
2702
                  Format.pp_print_string fmt ")"))) x.init_val;
2703
           Format.fprintf fmt "@]");
2704
          Format.fprintf fmt "@ }@]")
2705
    [@ocaml.warning "-A"])
2706

    
2707
and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string =
2708
  fun x  -> Format.asprintf "%a" pp_vhdl_parameter_t x
2709

    
2710
let rec (vhdl_parameter_t_to_yojson : vhdl_parameter_t -> Yojson.Safe.json) =
2711
  ((let open! Ppx_deriving_yojson_runtime in
2712
      fun x  ->
2713
        let fields = []  in
2714
        let fields =
2715
          if x.init_val = None
2716
          then fields
2717
          else
2718
            ("init_val",
2719
              (((function
2720
                 | None  -> `Null
2721
                 | Some x -> ((fun x  -> vhdl_cst_val_t_to_yojson x)) x))
2722
                 x.init_val))
2723
            :: fields
2724
           in
2725
        let fields =
2726
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
2727
          :: fields  in
2728
        let fields =
2729
          if x.mode = []
2730
          then fields
2731
          else
2732
            ("mode",
2733
              (((fun x  ->
2734
                   `List
2735
                     (List.map
2736
                        (fun (x : Ppx_deriving_runtime.string)  -> `String x)
2737
                        x))) x.mode))
2738
            :: fields
2739
           in
2740
        let fields =
2741
          ("names",
2742
            ((fun x  ->
2743
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
2744
               x.names))
2745
          :: fields  in
2746
        `Assoc fields)
2747
  [@ocaml.warning "-A"])
2748

    
2749
and (vhdl_parameter_t_of_yojson :
2750
      Yojson.Safe.json ->
2751
        vhdl_parameter_t Ppx_deriving_yojson_runtime.error_or)
2752
  =
2753
  ((let open! Ppx_deriving_yojson_runtime in
2754
      function
2755
      | `Assoc xs ->
2756
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
2757
            match xs with
2758
            | ("names",x)::xs ->
2759
                loop xs
2760
                  (((function
2761
                     | `List xs ->
2762
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
2763
                     | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.names") x),
2764
                    arg1, arg2, arg3)
2765
            | ("mode",x)::xs ->
2766
                loop xs
2767
                  (arg0,
2768
                    ((function
2769
                      | `List xs ->
2770
                          map_bind
2771
                            (function
2772
                             | `String x -> Result.Ok x
2773
                             | _ ->
2774
                                 Result.Error
2775
                                   "Vhdl_ast.vhdl_parameter_t.mode") [] xs
2776
                      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t.mode") x),
2777
                    arg2, arg3)
2778
            | ("typ",x)::xs ->
2779
                loop xs
2780
                  (arg0, arg1,
2781
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
2782
                    arg3)
2783
            | ("init_val",x)::xs ->
2784
                loop xs
2785
                  (arg0, arg1, arg2,
2786
                    ((function
2787
                      | `Null -> Result.Ok None
2788
                      | x ->
2789
                          ((fun x  -> vhdl_cst_val_t_of_yojson x) x) >>=
2790
                            ((fun x  -> Result.Ok (Some x)))) x))
2791
            | [] ->
2792
                arg3 >>=
2793
                  ((fun arg3  ->
2794
                      arg2 >>=
2795
                        (fun arg2  ->
2796
                           arg1 >>=
2797
                             (fun arg1  ->
2798
                                arg0 >>=
2799
                                  (fun arg0  ->
2800
                                     Result.Ok
2801
                                       {
2802
                                         names = arg0;
2803
                                         mode = arg1;
2804
                                         typ = arg2;
2805
                                         init_val = arg3
2806
                                       })))))
2807
            | _::xs -> loop xs _state  in
2808
          loop xs
2809
            ((Result.Error "Vhdl_ast.vhdl_parameter_t.names"),
2810
              (Result.Ok []), (Result.Error "Vhdl_ast.vhdl_parameter_t.typ"),
2811
              (Result.Ok (Some (CstInt 0))))
2812
      | _ -> Result.Error "Vhdl_ast.vhdl_parameter_t")
2813
  [@ocaml.warning "-A"])
2814

    
2815
type vhdl_subprogram_spec_t =
2816
  {
2817
  name: string [@default ""];
2818
  subprogram_type: string [@default ""];
2819
  typeMark: vhdl_name_t [@default NoName];
2820
  parameters: vhdl_parameter_t list ;
2821
  isPure: bool [@default false]}
2822

    
2823
(* TODO *)
2824
let rec pp_vhdl_subprogram_spec_t :
2825
  Format.formatter -> vhdl_subprogram_spec_t -> Ppx_deriving_runtime.unit =
2826
  let __1 () = pp_vhdl_parameter_t
2827
  
2828
  and __0 () = pp_vhdl_name_t
2829
   in
2830
  ((let open! Ppx_deriving_runtime in
2831
      fun fmt  ->
2832
        fun x  ->
2833
          (match x.subprogram_type with
2834
          | "function" -> 
2835
              if (x.isPure) then
2836
                Format.fprintf fmt "pure %s" x.subprogram_type
2837
              else
2838
                Format.fprintf fmt "impure %s" x.subprogram_type
2839
          | "procedure" ->
2840
              Format.fprintf fmt "%s %s" x.subprogram_type x.name);
2841
          (match x.parameters with
2842
          | [] -> Format.fprintf fmt "";
2843
          | _ -> 
2844
            Format.fprintf fmt "(@[";
2845
            ((fun x  ->
2846
                ignore
2847
                  (List.fold_left
2848
                     (fun sep  ->
2849
                        fun x  ->
2850
                          if sep then Format.fprintf fmt ",@ ";
2851
                          ((__1 ()) fmt) x;
2852
                          true) false x))) x.parameters;
2853
            Format.fprintf fmt "@])");
2854
          (match x.typeMark with
2855
          | NoName -> Format.fprintf fmt "";
2856
          | _ -> 
2857
              Format.fprintf fmt "returns ";
2858
              ((__0 ()) fmt) x.typeMark))
2859
   [@ocaml.warning "-A"])
2860

    
2861
and show_vhdl_subprogram_spec_t :
2862
  vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string =
2863
  fun x  -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x
2864

    
2865
let rec (vhdl_subprogram_spec_t_to_yojson :
2866
          vhdl_subprogram_spec_t -> Yojson.Safe.json)
2867
  =
2868
  ((let open! Ppx_deriving_yojson_runtime in
2869
      fun x  ->
2870
        let fields = []  in
2871
        let fields =
2872
          if x.isPure = false
2873
          then fields
2874
          else
2875
            ("isPure",
2876
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x)) x.isPure))
2877
            :: fields
2878
           in
2879
        let fields =
2880
          if x.parameters = []
2881
          then fields
2882
          else
2883
            ("parameters",
2884
              (((fun x  ->
2885
                   `List
2886
                     (List.map (fun x  -> vhdl_parameter_t_to_yojson x) x)))
2887
                 x.parameters))
2888
            :: fields
2889
           in
2890
        let fields =
2891
          if x.typeMark = NoName
2892
          then fields
2893
          else
2894
            ("typeMark", (((fun x  -> vhdl_name_t_to_yojson x)) x.typeMark))
2895
            :: fields
2896
           in
2897
        let fields =
2898
          if x.subprogram_type = ""
2899
          then fields
2900
          else
2901
            ("subprogram_type",
2902
              (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
2903
                 x.subprogram_type))
2904
            :: fields
2905
           in
2906
        let fields =
2907
          if x.name = ""
2908
          then fields
2909
          else
2910
            ("name",
2911
              (((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x.name))
2912
            :: fields
2913
           in
2914
        `Assoc fields)
2915
  [@ocaml.warning "-A"])
2916

    
2917
and (vhdl_subprogram_spec_t_of_yojson :
2918
      Yojson.Safe.json ->
2919
        vhdl_subprogram_spec_t Ppx_deriving_yojson_runtime.error_or)
2920
  =
2921
  ((let open! Ppx_deriving_yojson_runtime in
2922
      function
2923
      | `Assoc xs ->
2924
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4) as _state) =
2925
            match xs with
2926
            | ("name",x)::xs ->
2927
                loop xs
2928
                  (((function
2929
                     | `String x -> Result.Ok x
2930
                     | _ ->
2931
                         Result.Error "Vhdl_ast.vhdl_subprogram_spec_t.name")
2932
                      x), arg1, arg2, arg3, arg4)
2933
            | ("subprogram_type",x)::xs ->
2934
                loop xs
2935
                  (arg0,
2936
                    ((function
2937
                      | `String x -> Result.Ok x
2938
                      | _ ->
2939
                          Result.Error
2940
                            "Vhdl_ast.vhdl_subprogram_spec_t.subprogram_type")
2941
                       x), arg2, arg3, arg4)
2942
            | ("typeMark",x)::xs ->
2943
                loop xs
2944
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
2945
                    arg4)
2946
            | ("parameters",x)::xs ->
2947
                loop xs
2948
                  (arg0, arg1, arg2,
2949
                    ((function
2950
                      | `List xs ->
2951
                          map_bind (fun x  -> vhdl_parameter_t_of_yojson x)
2952
                            [] xs
2953
                      | _ ->
2954
                          Result.Error
2955
                            "Vhdl_ast.vhdl_subprogram_spec_t.parameters") x),
2956
                    arg4)
2957
            | ("isPure",x)::xs ->
2958
                loop xs
2959
                  (arg0, arg1, arg2, arg3,
2960
                    ((function
2961
                      | `Bool x -> Result.Ok x
2962
                      | _ ->
2963
                          Result.Error
2964
                            "Vhdl_ast.vhdl_subprogram_spec_t.isPure") x))
2965
            | [] ->
2966
                arg4 >>=
2967
                  ((fun arg4  ->
2968
                      arg3 >>=
2969
                        (fun arg3  ->
2970
                           arg2 >>=
2971
                             (fun arg2  ->
2972
                                arg1 >>=
2973
                                  (fun arg1  ->
2974
                                     arg0 >>=
2975
                                       (fun arg0  ->
2976
                                          Result.Ok
2977
                                            {
2978
                                              name = arg0;
2979
                                              subprogram_type = arg1;
2980
                                              typeMark = arg2;
2981
                                              parameters = arg3;
2982
                                              isPure = arg4
2983
                                            }))))))
2984
            | _::xs -> loop xs _state  in
2985
          loop xs
2986
            ((Result.Ok ""), (Result.Ok ""), (Result.Ok NoName),
2987
              (Result.Ok []), (Result.Ok false))
2988
      | _ -> Result.Error "Vhdl_ast.vhdl_subprogram_spec_t")
2989
  [@ocaml.warning "-A"])
2990

    
2991
let arith_funs = ["+"; "-"; "*"; "/"; "mod"; "rem"; "abs"; "**"; "&"] 
2992
let bool_funs = ["and"; "or"; "nand"; "nor"; "xor"; "not"] 
2993
let rel_funs =
2994
  ["<";
2995
  ">";
2996
  "<=";
2997
  ">=";
2998
  "/=";
2999
  "=";
3000
  "?=";
3001
  "?/=";
3002
  "?<";
3003
  "?<=";
3004
  "?>";
3005
  "?>=";
3006
  "??"] 
3007
let shift_funs = ["sll"; "srl"; "sla"; "sra"; "rol"; "ror"] 
3008

    
3009
type vhdl_waveform_element_t =
3010
  {
3011
  value: vhdl_expr_t option [@default None];
3012
  delay: vhdl_expr_t option [@default None]}[@@deriving
3013
                                              ((show { with_path = false }),
3014
                                                (yojson { strict = false }))]
3015

    
3016
let rec pp_vhdl_waveform_element_t :
3017
  Format.formatter -> vhdl_waveform_element_t -> Ppx_deriving_runtime.unit =
3018
  let __1 () = pp_vhdl_expr_t
3019
  
3020
  and __0 () = pp_vhdl_expr_t
3021
   in
3022
  ((let open! Ppx_deriving_runtime in
3023
      fun fmt  ->
3024
        fun x  ->
3025
          (match x.value with
3026
          | None -> Format.fprintf fmt "";
3027
          | Some IsNull -> Format.fprintf fmt "null";
3028
          | Some v -> ((__0 ()) fmt) v);
3029
          (match x.delay with
3030
          | None -> Format.fprintf fmt "";
3031
          | Some v -> 
3032
              Format.fprintf fmt " after ";
3033
              ((__1 ()) fmt) v))
3034
    [@ocaml.warning "-A"])
3035

    
3036
and show_vhdl_waveform_element_t :
3037
  vhdl_waveform_element_t -> Ppx_deriving_runtime.string =
3038
  fun x  -> Format.asprintf "%a" pp_vhdl_waveform_element_t x
3039

    
3040
let rec (vhdl_waveform_element_t_to_yojson :
3041
          vhdl_waveform_element_t -> Yojson.Safe.json)
3042
  =
3043
  ((let open! Ppx_deriving_yojson_runtime in
3044
      fun x  ->
3045
        let fields = []  in
3046
        let fields =
3047
          if x.delay = None
3048
          then fields
3049
          else
3050
            ("delay",
3051
              (((function
3052
                 | None  -> `Null
3053
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
3054
                 x.delay))
3055
            :: fields
3056
           in
3057
        let fields =
3058
          if x.value = None
3059
          then fields
3060
          else
3061
            ("value",
3062
              (((function
3063
                 | None  -> `Null
3064
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
3065
                 x.value))
3066
            :: fields
3067
           in
3068
        `Assoc fields)
3069
  [@ocaml.warning "-A"])
3070

    
3071
and (vhdl_waveform_element_t_of_yojson :
3072
      Yojson.Safe.json ->
3073
        vhdl_waveform_element_t Ppx_deriving_yojson_runtime.error_or)
3074
  =
3075
  ((let open! Ppx_deriving_yojson_runtime in
3076
      function
3077
      | `Assoc xs ->
3078
          let rec loop xs ((arg0,arg1) as _state) =
3079
            match xs with
3080
            | ("value",x)::xs ->
3081
                loop xs
3082
                  (((function
3083
                     | `Null -> Result.Ok None
3084
                     | x ->
3085
                         ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
3086
                           ((fun x  -> Result.Ok (Some x)))) x), arg1)
3087
            | ("delay",x)::xs ->
3088
                loop xs
3089
                  (arg0,
3090
                    ((function
3091
                      | `Null -> Result.Ok None
3092
                      | x ->
3093
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
3094
                            ((fun x  -> Result.Ok (Some x)))) x))
3095
            | [] ->
3096
                arg1 >>=
3097
                  ((fun arg1  ->
3098
                      arg0 >>=
3099
                        (fun arg0  ->
3100
                           Result.Ok { value = arg0; delay = arg1 })))
3101
            | _::xs -> loop xs _state  in
3102
          loop xs ((Result.Ok None), (Result.Ok None))
3103
      | _ -> Result.Error "Vhdl_ast.vhdl_waveform_element_t")
3104
  [@ocaml.warning "-A"])
3105

    
3106
type vhdl_sequential_stmt_t =
3107
  | VarAssign of
3108
  {
3109
  label: vhdl_name_t [@default NoName];
3110
  lhs: vhdl_name_t ;
3111
  rhs: vhdl_expr_t } [@name "VARIABLE_ASSIGNMENT_STATEMENT"]
3112
  | SigSeqAssign of
3113
  {
3114
  label: vhdl_name_t [@default NoName];
3115
  lhs: vhdl_name_t ;
3116
  rhs: vhdl_waveform_element_t list } [@name "SIGNAL_ASSIGNMENT_STATEMENT"]
3117
  | If of
3118
  {
3119
  label: vhdl_name_t [@default NoName];
3120
  if_cases: vhdl_if_case_t list ;
3121
  default: vhdl_sequential_stmt_t list [@default []]} [@name "IF_STATEMENT"]
3122
  | Case of
3123
  {
3124
  label: vhdl_name_t [@default NoName];
3125
  guard: vhdl_expr_t ;
3126
  branches: vhdl_case_item_t list } [@name "CASE_STATEMENT_TREE"]
3127
  | Exit of
3128
  {
3129
  label: vhdl_name_t [@default NoName];
3130
  loop_label: string option [@default Some ""];
3131
  condition: vhdl_expr_t option [@default Some IsNull]}
3132
  [@name "EXIT_STATEMENT"]
3133
  | Assert of
3134
  {
3135
  label: vhdl_name_t [@default NoName];
3136
  cond: vhdl_expr_t ;
3137
  report: vhdl_expr_t [@default IsNull];
3138
  severity: vhdl_expr_t [@default IsNull]} [@name "ASSERTION_STATEMENT"]
3139
  | ProcedureCall of
3140
  {
3141
  label: vhdl_name_t [@default NoName];
3142
  name: vhdl_name_t ;
3143
  assocs: vhdl_assoc_element_t list } [@name "PROCEDURE_CALL_STATEMENT"]
3144
  | Wait [@name "WAIT_STATEMENT"]
3145
  | Null of {
3146
  label: vhdl_name_t [@default NoName]} [@name "NULL_STATEMENT"]
3147
  | Return of {
3148
  label: vhdl_name_t [@default NoName]} [@name "RETURN_STATEMENT"]
3149
and vhdl_if_case_t =
3150
  {
3151
  if_cond: vhdl_expr_t ;
3152
  if_block: vhdl_sequential_stmt_t list }
3153
and vhdl_case_item_t =
3154
  {
3155
  when_cond: vhdl_expr_t list ;
3156
  when_stmt: vhdl_sequential_stmt_t list }
3157

    
3158
let rec pp_vhdl_sequential_stmt_t :
3159
  Format.formatter -> vhdl_sequential_stmt_t -> Ppx_deriving_runtime.unit =
3160
  let __22 () = pp_vhdl_name_t
3161
  
3162
  and __21 () = pp_vhdl_name_t
3163
  
3164
  and __20 () = pp_vhdl_assoc_element_t
3165
  
3166
  and __19 () = pp_vhdl_name_t
3167
  
3168
  and __18 () = pp_vhdl_name_t
3169
  
3170
  and __17 () = pp_vhdl_expr_t
3171
  
3172
  and __16 () = pp_vhdl_expr_t
3173
  
3174
  and __15 () = pp_vhdl_expr_t
3175
  
3176
  and __14 () = pp_vhdl_name_t
3177
  
3178
  and __13 () = pp_vhdl_expr_t
3179
  
3180
  and __12 () = pp_vhdl_name_t
3181
  
3182
  and __11 () = pp_vhdl_case_item_t
3183
  
3184
  and __10 () = pp_vhdl_expr_t
3185
  
3186
  and __9 () = pp_vhdl_name_t
3187
  
3188
  and __8 () = pp_vhdl_sequential_stmt_t
3189
  
3190
  and __7 () = pp_vhdl_if_case_t
3191
  
3192
  and __6 () = pp_vhdl_name_t
3193
  
3194
  and __5 () = pp_vhdl_waveform_element_t
3195
  
3196
  and __4 () = pp_vhdl_name_t
3197
  
3198
  and __3 () = pp_vhdl_name_t
3199
  
3200
  and __2 () = pp_vhdl_expr_t
3201
  
3202
  and __1 () = pp_vhdl_name_t
3203
  
3204
  and __0 () = pp_vhdl_name_t
3205
   in
3206
  ((let open! Ppx_deriving_runtime in
3207
      fun fmt  ->
3208
        function
3209
        | VarAssign { label = alabel; lhs = alhs; rhs = arhs } ->
3210
            (match alabel with
3211
              | NoName -> Format.fprintf fmt "";
3212
              | _ -> (((__0 ()) fmt) alabel;
3213
                     Format.fprintf fmt ": ")
3214
            );
3215
            ((__1 ()) fmt) alhs;
3216
            Format.fprintf fmt " := ";
3217
            ((__2 ()) fmt) arhs;
3218
(* TODO: Check
3219
            (Format.fprintf fmt "@[<2>VarAssign {@,";
3220
             (((Format.fprintf fmt "@[%s =@ " "label";
3221
                ((__0 ()) fmt) alabel;
3222
                Format.fprintf fmt "@]");
3223
               Format.fprintf fmt ";@ ";
3224
               Format.fprintf fmt "@[%s =@ " "lhs";
3225
               ((__1 ()) fmt) alhs;
3226
               Format.fprintf fmt "@]");
3227
              Format.fprintf fmt ";@ ";
3228
              Format.fprintf fmt "@[%s =@ " "rhs";
3229
              ((__2 ()) fmt) arhs;
3230
              Format.fprintf fmt "@]");
3231
             Format.fprintf fmt "@]}") *)
3232
        | SigSeqAssign { label = alabel; lhs = alhs; rhs = arhs } ->
3233
            (match alabel with
3234
              | NoName -> Format.fprintf fmt "";
3235
              | _ -> (((__3 ()) fmt) alabel;
3236
                     Format.fprintf fmt ":@ ")
3237
            );
3238
            Format.fprintf fmt "@[<2>";
3239
            ((__4 ()) fmt) alhs;
3240
            Format.fprintf fmt "@ <=@ ";
3241
            ((fun x  ->
3242
               Format.fprintf fmt "@[";
3243
               ignore
3244
                 (List.fold_left
3245
                   (fun sep  ->
3246
                     fun x  ->
3247
                       if sep then Format.fprintf fmt "";
3248
                        ((__5 ()) fmt) x;
3249
                        true) false x);
3250
            Format.fprintf fmt "@]@]")) arhs;
3251
        | If { label = alabel; if_cases = aif_cases; default = adefault } ->
3252
            (match alabel with
3253
              | NoName -> Format.fprintf fmt "";
3254
              | _ -> (((__6 ()) fmt) alabel;
3255
                     Format.fprintf fmt ":@ ")
3256
            );
3257
            Format.fprintf fmt "@[<v>if";
3258
            ((fun x ->
3259
               ignore
3260
               (List.fold_left
3261
                 (fun sep  ->
3262
                   fun x  ->
3263
                           if sep then Format.fprintf fmt "@;elseif";
3264
                                ((__7 ()) fmt) x;
3265
                                true
3266
                 ) false x);
3267
             )) aif_cases;
3268
             (match adefault with
3269
              | [] -> Format.fprintf fmt "";
3270
              | _  -> (Format.fprintf fmt "@;else";
3271
                      ((fun x  ->
3272
                          Format.fprintf fmt "@;<0 2>";
3273
                          ignore
3274
                            (List.fold_left
3275
                              (fun sep  ->
3276
                                fun x  ->
3277
                                        if sep then Format.fprintf fmt "";
3278
                          ((__8 ()) fmt) x;
3279
                          true) false x))) adefault));
3280
            Format.fprintf fmt "@;end if@]"
3281
        | Case { label = alabel; guard = aguard; branches = abranches } ->
3282
            (match alabel with
3283
              | NoName -> Format.fprintf fmt "";
3284
              | _ -> (((__9 ()) fmt) alabel;
3285
                     Format.fprintf fmt ":@ ")
3286
            );
3287
            Format.fprintf fmt "@[<v>case ";
3288
            ((__10 ()) fmt) aguard;
3289
            Format.fprintf fmt " is";
3290
            ((fun x  ->
3291
                ignore
3292
                  (List.fold_left
3293
                     (fun sep  ->
3294
                        fun x  ->
3295
                          if sep then Format.fprintf fmt "";
3296
                          ((__11 ()) fmt) x;
3297
                          true) false x);)) abranches;
3298
            Format.fprintf fmt "@;end case@]";
3299
        | Exit
3300
            { label = alabel; loop_label = aloop_label;
3301
              condition = acondition }
3302
            ->
3303
            (match alabel with
3304
              | NoName -> Format.fprintf fmt "";
3305
              | _ -> (((__12 ()) fmt) alabel;
3306
                     Format.fprintf fmt ":@ ")
3307
            );
3308
            Format.fprintf fmt "exit";
3309
            (match aloop_label with
3310
               | None  -> Format.pp_print_string fmt ""
3311
               | Some x -> (Format.fprintf fmt "@ %s@ ") x);
3312
            ((function
3313
               | None  -> Format.pp_print_string fmt ""
3314
               | Some x ->
3315
                   (Format.pp_print_string fmt "when@ ";
3316
                    ((__13 ()) fmt) x;))) acondition;
3317
        | Assert
3318
            { label = alabel; cond = acond; report = areport;
3319
              severity = aseverity }
3320
            ->
3321
            Format.fprintf fmt "@[<v 2>";
3322
            (match alabel with
3323
              | NoName -> Format.fprintf fmt "";
3324
              | _ -> (((__14 ()) fmt) alabel;
3325
                     Format.fprintf fmt ":@ ")
3326
            );
3327
            Format.fprintf fmt "assert ";
3328
            ((__15 ()) fmt) acond;
3329
            (match areport with
3330
            | IsNull -> Format.fprintf fmt "";
3331
            | _ -> 
3332
                Format.fprintf fmt "@;report ";
3333
                ((__16 ()) fmt) areport);
3334
            (match aseverity with
3335
            | IsNull -> Format.fprintf fmt "";
3336
            | _ -> 
3337
                Format.fprintf fmt "@;severity ";
3338
                ((__17 ()) fmt) aseverity);
3339
            Format.fprintf fmt "@]";
3340
        | ProcedureCall { label = alabel; name = aname; assocs = aassocs } ->
3341
            (match alabel with
3342
              | NoName -> Format.fprintf fmt "";
3343
              | _ -> (((__18 ()) fmt) alabel;
3344
                     Format.fprintf fmt ":@ ")
3345
            );
3346
            ((__19 ()) fmt) aname;
3347
            (match aassocs with
3348
            | [] -> Format.fprintf fmt "";
3349
            | _ ->
3350
               Format.fprintf fmt "(@[<v>";
3351
               ((fun x  ->
3352
                ignore
3353
                  (List.fold_left
3354
                     (fun sep  ->
3355
                        fun x  ->
3356
                          if sep then Format.fprintf fmt ",@ ";
3357
                          ((__20 ()) fmt) x;
3358
                          true) false x))) aassocs;
3359
               Format.fprintf fmt "@])");
3360
        | Wait  -> Format.pp_print_string fmt "wait"
3361
        | Null { label = alabel } ->
3362
            (match alabel with
3363
              | NoName -> Format.fprintf fmt "";
3364
              | _ -> (((__18 ()) fmt) alabel;
3365
                     Format.fprintf fmt ":@ ")
3366
            );
3367
            Format.fprintf fmt "null";
3368
        | Return { label = alabel } ->
3369
            (match alabel with
3370
              | NoName -> Format.fprintf fmt "";
3371
              | _ -> (((__19 ()) fmt) alabel;
3372
                     Format.fprintf fmt ":@ ")
3373
            );
3374
            Format.fprintf fmt "return";)
3375
    [@ocaml.warning "-A"])
3376

    
3377
and show_vhdl_sequential_stmt_t :
3378
  vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string =
3379
  fun x  -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x
3380

    
3381
and pp_vhdl_if_case_t :
3382
  Format.formatter -> vhdl_if_case_t -> Ppx_deriving_runtime.unit =
3383
  let __1 () = pp_vhdl_sequential_stmt_t
3384
  
3385
  and __0 () = pp_vhdl_expr_t
3386
   in
3387
  ((let open! Ppx_deriving_runtime in
3388
      fun fmt  ->
3389
        fun x  ->
3390
          Format.fprintf fmt " (";
3391
          ((__0 ()) fmt) x.if_cond;
3392
          Format.fprintf fmt ") then@;<0 2>";
3393
          ((fun x  ->
3394
             ignore
3395
               (List.fold_left
3396
                  (fun sep  ->
3397
                     fun x  ->
3398
                             if sep then Format.fprintf fmt "@;<0 2>";
3399
                       ((__1 ()) fmt) x;
3400
                       true) false x);
3401
          )) x.if_block;)
3402
    [@ocaml.warning "-A"])
3403

    
3404
and show_vhdl_if_case_t : vhdl_if_case_t -> Ppx_deriving_runtime.string =
3405
  fun x  -> Format.asprintf "%a" pp_vhdl_if_case_t x
3406

    
3407
and pp_vhdl_case_item_t :
3408
  Format.formatter -> vhdl_case_item_t -> Ppx_deriving_runtime.unit =
3409
  let __1 () = pp_vhdl_sequential_stmt_t
3410
  
3411
  and __0 () = pp_vhdl_expr_t
3412
   in
3413
  ((let open! Ppx_deriving_runtime in
3414
      fun fmt  ->
3415
        fun x  ->
3416
                Format.fprintf fmt "@;@[<v 2>when ";
3417
            ((fun x  ->
3418
                ignore
3419
                  (List.fold_left
3420
                     (fun sep  ->
3421
                        fun x  ->
3422
                          if sep then Format.fprintf fmt "@ |@ ";
3423
                          ((__0 ()) fmt) x;
3424
                          true) false x);)) x.when_cond;
3425
           Format.fprintf fmt " => ";
3426
           (fun x  ->
3427
               ignore
3428
                 (List.fold_left
3429
                    (fun sep  ->
3430
                       fun x  ->
3431
                         if sep then Format.fprintf fmt "@;";
3432
                         ((__1 ()) fmt) x;
3433
                         Format.fprintf fmt ";";
3434
                         true) ((List.length x) > 1) x);) x.when_stmt;
3435
           Format.fprintf fmt "@]")
3436
    [@ocaml.warning "-A"])
3437

    
3438
and show_vhdl_case_item_t : vhdl_case_item_t -> Ppx_deriving_runtime.string =
3439
  fun x  -> Format.asprintf "%a" pp_vhdl_case_item_t x
3440

    
3441
let rec (vhdl_sequential_stmt_t_to_yojson :
3442
          vhdl_sequential_stmt_t -> Yojson.Safe.json)
3443
  =
3444
  ((let open! Ppx_deriving_yojson_runtime in
3445
      function
3446
      | VarAssign arg0 ->
3447
          `List
3448
            [`String "VARIABLE_ASSIGNMENT_STATEMENT";
3449
            (let fields = []  in
3450
             let fields =
3451
               ("rhs", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.rhs)) ::
3452
               fields  in
3453
             let fields =
3454
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
3455
               fields  in
3456
             let fields =
3457
               if arg0.label = NoName
3458
               then fields
3459
               else
3460
                 ("label",
3461
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3462
                 :: fields
3463
                in
3464
             `Assoc fields)]
3465
      | SigSeqAssign arg0 ->
3466
          `List
3467
            [`String "SIGNAL_ASSIGNMENT_STATEMENT";
3468
            (let fields = []  in
3469
             let fields =
3470
               ("rhs",
3471
                 ((fun x  ->
3472
                     `List
3473
                       (List.map
3474
                          (fun x  -> vhdl_waveform_element_t_to_yojson x) x))
3475
                    arg0.rhs))
3476
               :: fields  in
3477
             let fields =
3478
               ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) arg0.lhs)) ::
3479
               fields  in
3480
             let fields =
3481
               if arg0.label = NoName
3482
               then fields
3483
               else
3484
                 ("label",
3485
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3486
                 :: fields
3487
                in
3488
             `Assoc fields)]
3489
      | If arg0 ->
3490
          `List
3491
            [`String "IF_STATEMENT";
3492
            (let fields = []  in
3493
             let fields =
3494
               if arg0.default = []
3495
               then fields
3496
               else
3497
                 ("default",
3498
                   (((fun x  ->
3499
                        `List
3500
                          (List.map
3501
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
3502
                      arg0.default))
3503
                 :: fields
3504
                in
3505
             let fields =
3506
               ("if_cases",
3507
                 ((fun x  ->
3508
                     `List
3509
                       (List.map (fun x  -> vhdl_if_case_t_to_yojson x) x))
3510
                    arg0.if_cases))
3511
               :: fields  in
3512
             let fields =
3513
               if arg0.label = NoName
3514
               then fields
3515
               else
3516
                 ("label",
3517
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3518
                 :: fields
3519
                in
3520
             `Assoc fields)]
3521
      | Case arg0 ->
3522
          `List
3523
            [`String "CASE_STATEMENT_TREE";
3524
            (let fields = []  in
3525
             let fields =
3526
               ("branches",
3527
                 ((fun x  ->
3528
                     `List
3529
                       (List.map (fun x  -> vhdl_case_item_t_to_yojson x) x))
3530
                    arg0.branches))
3531
               :: fields  in
3532
             let fields =
3533
               ("guard", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.guard)) ::
3534
               fields  in
3535
             let fields =
3536
               if arg0.label = NoName
3537
               then fields
3538
               else
3539
                 ("label",
3540
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3541
                 :: fields
3542
                in
3543
             `Assoc fields)]
3544
      | Exit arg0 ->
3545
          `List
3546
            [`String "EXIT_STATEMENT";
3547
            (let fields = []  in
3548
             let fields =
3549
               if arg0.condition = (Some IsNull)
3550
               then fields
3551
               else
3552
                 ("condition",
3553
                   (((function
3554
                      | None  -> `Null
3555
                      | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
3556
                      arg0.condition))
3557
                 :: fields
3558
                in
3559
             let fields =
3560
               if arg0.loop_label = (Some "")
3561
               then fields
3562
               else
3563
                 ("loop_label",
3564
                   (((function
3565
                      | None  -> `Null
3566
                      | Some x ->
3567
                          ((fun (x : Ppx_deriving_runtime.string)  ->
3568
                              `String x)) x)) arg0.loop_label))
3569
                 :: fields
3570
                in
3571
             let fields =
3572
               if arg0.label = NoName
3573
               then fields
3574
               else
3575
                 ("label",
3576
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3577
                 :: fields
3578
                in
3579
             `Assoc fields)]
3580
      | Assert arg0 ->
3581
          `List
3582
            [`String "ASSERTION_STATEMENT";
3583
            (let fields = []  in
3584
             let fields =
3585
               if arg0.severity = IsNull
3586
               then fields
3587
               else
3588
                 ("severity",
3589
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.severity))
3590
                 :: fields
3591
                in
3592
             let fields =
3593
               if arg0.report = IsNull
3594
               then fields
3595
               else
3596
                 ("report",
3597
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.report))
3598
                 :: fields
3599
                in
3600
             let fields =
3601
               ("cond", ((fun x  -> vhdl_expr_t_to_yojson x) arg0.cond)) ::
3602
               fields  in
3603
             let fields =
3604
               if arg0.label = NoName
3605
               then fields
3606
               else
3607
                 ("label",
3608
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3609
                 :: fields
3610
                in
3611
             `Assoc fields)]
3612
      | ProcedureCall arg0 ->
3613
          `List
3614
            [`String "PROCEDURE_CALL_STATEMENT";
3615
            (let fields = []  in
3616
             let fields =
3617
               if arg0.assocs = []
3618
               then fields
3619
               else
3620
                 ("assocs",
3621
                   (((fun x  ->
3622
                        `List
3623
                          (List.map
3624
                             (fun x  -> vhdl_assoc_element_t_to_yojson x) x)))
3625
                      arg0.assocs))
3626
                 :: fields
3627
                in
3628
             let fields =
3629
               ("name", ((fun x  -> vhdl_name_t_to_yojson x) arg0.name)) ::
3630
               fields  in
3631
             let fields =
3632
               if arg0.label = NoName
3633
               then fields
3634
               else
3635
                 ("label",
3636
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3637
                 :: fields
3638
                in
3639
             `Assoc fields)]
3640
      | Wait  -> `List [`String "WAIT_STATEMENT"]
3641
      | Null arg0 ->
3642
          `List
3643
            [`String "NULL_STATEMENT";
3644
            (let fields = []  in
3645
             let fields =
3646
               if arg0.label = NoName
3647
               then fields
3648
               else
3649
                 ("label",
3650
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3651
                 :: fields
3652
                in
3653
             `Assoc fields)]
3654
      | Return arg0 ->
3655
          `List
3656
            [`String "RETURN_STATEMENT";
3657
            (let fields = []  in
3658
             let fields =
3659
               if arg0.label = NoName
3660
               then fields
3661
               else
3662
                 ("label",
3663
                   (((fun x  -> vhdl_name_t_to_yojson x)) arg0.label))
3664
                 :: fields
3665
                in
3666
             `Assoc fields)])
3667
  [@ocaml.warning "-A"])
3668

    
3669
and (vhdl_sequential_stmt_t_of_yojson :
3670
      Yojson.Safe.json ->
3671
        vhdl_sequential_stmt_t Ppx_deriving_yojson_runtime.error_or)
3672
  =
3673
  ((let open! Ppx_deriving_yojson_runtime in
3674
      function
3675
      | `List ((`String "VARIABLE_ASSIGNMENT_STATEMENT")::arg0::[]) ->
3676
          ((function
3677
            | `Assoc xs ->
3678
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3679
                  match xs with
3680
                  | ("label",x)::xs ->
3681
                      loop xs
3682
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3683
                  | ("lhs",x)::xs ->
3684
                      loop xs
3685
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3686
                  | ("rhs",x)::xs ->
3687
                      loop xs
3688
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
3689
                  | [] ->
3690
                      arg2 >>=
3691
                        ((fun arg2  ->
3692
                            arg1 >>=
3693
                              (fun arg1  ->
3694
                                 arg0 >>=
3695
                                   (fun arg0  ->
3696
                                      Result.Ok
3697
                                        (VarAssign
3698
                                           {
3699
                                             label = arg0;
3700
                                             lhs = arg1;
3701
                                             rhs = arg2
3702
                                           })))))
3703
                  | _::xs -> loop xs _state  in
3704
                loop xs
3705
                  ((Result.Ok NoName),
3706
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
3707
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
3708
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3709
      | `List ((`String "SIGNAL_ASSIGNMENT_STATEMENT")::arg0::[]) ->
3710
          ((function
3711
            | `Assoc xs ->
3712
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3713
                  match xs with
3714
                  | ("label",x)::xs ->
3715
                      loop xs
3716
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3717
                  | ("lhs",x)::xs ->
3718
                      loop xs
3719
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3720
                  | ("rhs",x)::xs ->
3721
                      loop xs
3722
                        (arg0, arg1,
3723
                          ((function
3724
                            | `List xs ->
3725
                                map_bind
3726
                                  (fun x  ->
3727
                                     vhdl_waveform_element_t_of_yojson x) []
3728
                                  xs
3729
                            | _ ->
3730
                                Result.Error
3731
                                  "Vhdl_ast.vhdl_sequential_stmt_t.rhs") x))
3732
                  | [] ->
3733
                      arg2 >>=
3734
                        ((fun arg2  ->
3735
                            arg1 >>=
3736
                              (fun arg1  ->
3737
                                 arg0 >>=
3738
                                   (fun arg0  ->
3739
                                      Result.Ok
3740
                                        (SigSeqAssign
3741
                                           {
3742
                                             label = arg0;
3743
                                             lhs = arg1;
3744
                                             rhs = arg2
3745
                                           })))))
3746
                  | _::xs -> loop xs _state  in
3747
                loop xs
3748
                  ((Result.Ok NoName),
3749
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.lhs"),
3750
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.rhs"))
3751
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3752
      | `List ((`String "IF_STATEMENT")::arg0::[]) ->
3753
          ((function
3754
            | `Assoc xs ->
3755
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3756
                  match xs with
3757
                  | ("label",x)::xs ->
3758
                      loop xs
3759
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3760
                  | ("if_cases",x)::xs ->
3761
                      loop xs
3762
                        (arg0,
3763
                          ((function
3764
                            | `List xs ->
3765
                                map_bind
3766
                                  (fun x  -> vhdl_if_case_t_of_yojson x) []
3767
                                  xs
3768
                            | _ ->
3769
                                Result.Error
3770
                                  "Vhdl_ast.vhdl_sequential_stmt_t.if_cases")
3771
                             x), arg2)
3772
                  | ("default",x)::xs ->
3773
                      loop xs
3774
                        (arg0, arg1,
3775
                          ((function
3776
                            | `List xs ->
3777
                                map_bind
3778
                                  (fun x  ->
3779
                                     vhdl_sequential_stmt_t_of_yojson x) []
3780
                                  xs
3781
                            | _ ->
3782
                                Result.Error
3783
                                  "Vhdl_ast.vhdl_sequential_stmt_t.default")
3784
                             x))
3785
                  | [] ->
3786
                      arg2 >>=
3787
                        ((fun arg2  ->
3788
                            arg1 >>=
3789
                              (fun arg1  ->
3790
                                 arg0 >>=
3791
                                   (fun arg0  ->
3792
                                      Result.Ok
3793
                                        (If
3794
                                           {
3795
                                             label = arg0;
3796
                                             if_cases = arg1;
3797
                                             default = arg2
3798
                                           })))))
3799
                  | _::xs -> loop xs _state  in
3800
                loop xs
3801
                  ((Result.Ok NoName),
3802
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.if_cases"),
3803
                    (Result.Ok []))
3804
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3805
      | `List ((`String "CASE_STATEMENT_TREE")::arg0::[]) ->
3806
          ((function
3807
            | `Assoc xs ->
3808
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3809
                  match xs with
3810
                  | ("label",x)::xs ->
3811
                      loop xs
3812
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3813
                  | ("guard",x)::xs ->
3814
                      loop xs
3815
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2)
3816
                  | ("branches",x)::xs ->
3817
                      loop xs
3818
                        (arg0, arg1,
3819
                          ((function
3820
                            | `List xs ->
3821
                                map_bind
3822
                                  (fun x  -> vhdl_case_item_t_of_yojson x) []
3823
                                  xs
3824
                            | _ ->
3825
                                Result.Error
3826
                                  "Vhdl_ast.vhdl_sequential_stmt_t.branches")
3827
                             x))
3828
                  | [] ->
3829
                      arg2 >>=
3830
                        ((fun arg2  ->
3831
                            arg1 >>=
3832
                              (fun arg1  ->
3833
                                 arg0 >>=
3834
                                   (fun arg0  ->
3835
                                      Result.Ok
3836
                                        (Case
3837
                                           {
3838
                                             label = arg0;
3839
                                             guard = arg1;
3840
                                             branches = arg2
3841
                                           })))))
3842
                  | _::xs -> loop xs _state  in
3843
                loop xs
3844
                  ((Result.Ok NoName),
3845
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.guard"),
3846
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.branches"))
3847
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3848
      | `List ((`String "EXIT_STATEMENT")::arg0::[]) ->
3849
          ((function
3850
            | `Assoc xs ->
3851
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3852
                  match xs with
3853
                  | ("label",x)::xs ->
3854
                      loop xs
3855
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3856
                  | ("loop_label",x)::xs ->
3857
                      loop xs
3858
                        (arg0,
3859
                          ((function
3860
                            | `Null -> Result.Ok None
3861
                            | x ->
3862
                                ((function
3863
                                  | `String x -> Result.Ok x
3864
                                  | _ ->
3865
                                      Result.Error
3866
                                        "Vhdl_ast.vhdl_sequential_stmt_t.loop_label")
3867
                                   x)
3868
                                  >>= ((fun x  -> Result.Ok (Some x)))) x),
3869
                          arg2)
3870
                  | ("condition",x)::xs ->
3871
                      loop xs
3872
                        (arg0, arg1,
3873
                          ((function
3874
                            | `Null -> Result.Ok None
3875
                            | x ->
3876
                                ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
3877
                                  ((fun x  -> Result.Ok (Some x)))) x))
3878
                  | [] ->
3879
                      arg2 >>=
3880
                        ((fun arg2  ->
3881
                            arg1 >>=
3882
                              (fun arg1  ->
3883
                                 arg0 >>=
3884
                                   (fun arg0  ->
3885
                                      Result.Ok
3886
                                        (Exit
3887
                                           {
3888
                                             label = arg0;
3889
                                             loop_label = arg1;
3890
                                             condition = arg2
3891
                                           })))))
3892
                  | _::xs -> loop xs _state  in
3893
                loop xs
3894
                  ((Result.Ok NoName), (Result.Ok (Some "")),
3895
                    (Result.Ok (Some IsNull)))
3896
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3897
      | `List ((`String "ASSERTION_STATEMENT")::arg0::[]) ->
3898
          ((function
3899
            | `Assoc xs ->
3900
                let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
3901
                  match xs with
3902
                  | ("label",x)::xs ->
3903
                      loop xs
3904
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2,
3905
                          arg3)
3906
                  | ("cond",x)::xs ->
3907
                      loop xs
3908
                        (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x), arg2,
3909
                          arg3)
3910
                  | ("report",x)::xs ->
3911
                      loop xs
3912
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x),
3913
                          arg3)
3914
                  | ("severity",x)::xs ->
3915
                      loop xs
3916
                        (arg0, arg1, arg2,
3917
                          ((fun x  -> vhdl_expr_t_of_yojson x) x))
3918
                  | [] ->
3919
                      arg3 >>=
3920
                        ((fun arg3  ->
3921
                            arg2 >>=
3922
                              (fun arg2  ->
3923
                                 arg1 >>=
3924
                                   (fun arg1  ->
3925
                                      arg0 >>=
3926
                                        (fun arg0  ->
3927
                                           Result.Ok
3928
                                             (Assert
3929
                                                {
3930
                                                  label = arg0;
3931
                                                  cond = arg1;
3932
                                                  report = arg2;
3933
                                                  severity = arg3
3934
                                                }))))))
3935
                  | _::xs -> loop xs _state  in
3936
                loop xs
3937
                  ((Result.Ok NoName),
3938
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.cond"),
3939
                    (Result.Ok IsNull), (Result.Ok IsNull))
3940
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3941
      | `List ((`String "PROCEDURE_CALL_STATEMENT")::arg0::[]) ->
3942
          ((function
3943
            | `Assoc xs ->
3944
                let rec loop xs ((arg0,arg1,arg2) as _state) =
3945
                  match xs with
3946
                  | ("label",x)::xs ->
3947
                      loop xs
3948
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
3949
                  | ("name",x)::xs ->
3950
                      loop xs
3951
                        (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2)
3952
                  | ("assocs",x)::xs ->
3953
                      loop xs
3954
                        (arg0, arg1,
3955
                          ((function
3956
                            | `List xs ->
3957
                                map_bind
3958
                                  (fun x  -> vhdl_assoc_element_t_of_yojson x)
3959
                                  [] xs
3960
                            | _ ->
3961
                                Result.Error
3962
                                  "Vhdl_ast.vhdl_sequential_stmt_t.assocs") x))
3963
                  | [] ->
3964
                      arg2 >>=
3965
                        ((fun arg2  ->
3966
                            arg1 >>=
3967
                              (fun arg1  ->
3968
                                 arg0 >>=
3969
                                   (fun arg0  ->
3970
                                      Result.Ok
3971
                                        (ProcedureCall
3972
                                           {
3973
                                             label = arg0;
3974
                                             name = arg1;
3975
                                             assocs = arg2
3976
                                           })))))
3977
                  | _::xs -> loop xs _state  in
3978
                loop xs
3979
                  ((Result.Ok NoName),
3980
                    (Result.Error "Vhdl_ast.vhdl_sequential_stmt_t.name"),
3981
                    (Result.Ok []))
3982
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3983
      | `List ((`String "WAIT_STATEMENT")::[]) -> Result.Ok Wait
3984
      | `List ((`String "NULL_STATEMENT")::arg0::[]) ->
3985
          ((function
3986
            | `Assoc xs ->
3987
                let rec loop xs (arg0 as _state) =
3988
                  match xs with
3989
                  | ("label",x)::xs ->
3990
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
3991
                  | [] ->
3992
                      arg0 >>=
3993
                        ((fun arg0  -> Result.Ok (Null { label = arg0 })))
3994
                  | _::xs -> loop xs _state  in
3995
                loop xs (Result.Ok NoName)
3996
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
3997
      | `List ((`String "RETURN_STATEMENT")::arg0::[]) ->
3998
          ((function
3999
            | `Assoc xs ->
4000
                let rec loop xs (arg0 as _state) =
4001
                  match xs with
4002
                  | ("label",x)::xs ->
4003
                      loop xs ((fun x  -> vhdl_name_t_of_yojson x) x)
4004
                  | [] ->
4005
                      arg0 >>=
4006
                        ((fun arg0  -> Result.Ok (Return { label = arg0 })))
4007
                  | _::xs -> loop xs _state  in
4008
                loop xs (Result.Ok NoName)
4009
            | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")) arg0
4010
      | _ -> Result.Error "Vhdl_ast.vhdl_sequential_stmt_t")
4011
  [@ocaml.warning "-A"])
4012

    
4013
and (vhdl_if_case_t_to_yojson : vhdl_if_case_t -> Yojson.Safe.json) =
4014
  ((let open! Ppx_deriving_yojson_runtime in
4015
      fun x  ->
4016
        let fields = []  in
4017
        let fields =
4018
          ("if_block",
4019
            ((fun x  ->
4020
                `List
4021
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
4022
               x.if_block))
4023
          :: fields  in
4024
        let fields =
4025
          ("if_cond", ((fun x  -> vhdl_expr_t_to_yojson x) x.if_cond)) ::
4026
          fields  in
4027
        `Assoc fields)
4028
  [@ocaml.warning "-A"])
4029

    
4030
and (vhdl_if_case_t_of_yojson :
4031
      Yojson.Safe.json -> vhdl_if_case_t Ppx_deriving_yojson_runtime.error_or)
4032
  =
4033
  ((let open! Ppx_deriving_yojson_runtime in
4034
      function
4035
      | `Assoc xs ->
4036
          let rec loop xs ((arg0,arg1) as _state) =
4037
            match xs with
4038
            | ("if_cond",x)::xs ->
4039
                loop xs (((fun x  -> vhdl_expr_t_of_yojson x) x), arg1)
4040
            | ("if_block",x)::xs ->
4041
                loop xs
4042
                  (arg0,
4043
                    ((function
4044
                      | `List xs ->
4045
                          map_bind
4046
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
4047
                            xs
4048
                      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t.if_block")
4049
                       x))
4050
            | [] ->
4051
                arg1 >>=
4052
                  ((fun arg1  ->
4053
                      arg0 >>=
4054
                        (fun arg0  ->
4055
                           Result.Ok { if_cond = arg0; if_block = arg1 })))
4056
            | _::xs -> loop xs _state  in
4057
          loop xs
4058
            ((Result.Error "Vhdl_ast.vhdl_if_case_t.if_cond"),
4059
              (Result.Error "Vhdl_ast.vhdl_if_case_t.if_block"))
4060
      | _ -> Result.Error "Vhdl_ast.vhdl_if_case_t")
4061
  [@ocaml.warning "-A"])
4062

    
4063
and (vhdl_case_item_t_to_yojson : vhdl_case_item_t -> Yojson.Safe.json) =
4064
  ((let open! Ppx_deriving_yojson_runtime in
4065
      fun x  ->
4066
        let fields = []  in
4067
        let fields =
4068
          ("when_stmt",
4069
            ((fun x  ->
4070
                `List
4071
                  (List.map (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x))
4072
               x.when_stmt))
4073
          :: fields  in
4074
        let fields =
4075
          ("when_cond",
4076
            ((fun x  ->
4077
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
4078
               x.when_cond))
4079
          :: fields  in
4080
        `Assoc fields)
4081
  [@ocaml.warning "-A"])
4082

    
4083
and (vhdl_case_item_t_of_yojson :
4084
      Yojson.Safe.json ->
4085
        vhdl_case_item_t Ppx_deriving_yojson_runtime.error_or)
4086
  =
4087
  ((let open! Ppx_deriving_yojson_runtime in
4088
      function
4089
      | `Assoc xs ->
4090
          let rec loop xs ((arg0,arg1) as _state) =
4091
            match xs with
4092
            | ("when_cond",x)::xs ->
4093
                loop xs
4094
                  (((function
4095
                     | `List xs ->
4096
                         map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
4097
                     | _ ->
4098
                         Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond")
4099
                      x), arg1)
4100
            | ("when_stmt",x)::xs ->
4101
                loop xs
4102
                  (arg0,
4103
                    ((function
4104
                      | `List xs ->
4105
                          map_bind
4106
                            (fun x  -> vhdl_sequential_stmt_t_of_yojson x) []
4107
                            xs
4108
                      | _ ->
4109
                          Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt")
4110
                       x))
4111
            | [] ->
4112
                arg1 >>=
4113
                  ((fun arg1  ->
4114
                      arg0 >>=
4115
                        (fun arg0  ->
4116
                           Result.Ok { when_cond = arg0; when_stmt = arg1 })))
4117
            | _::xs -> loop xs _state  in
4118
          loop xs
4119
            ((Result.Error "Vhdl_ast.vhdl_case_item_t.when_cond"),
4120
              (Result.Error "Vhdl_ast.vhdl_case_item_t.when_stmt"))
4121
      | _ -> Result.Error "Vhdl_ast.vhdl_case_item_t")
4122
  [@ocaml.warning "-A"])
4123

    
4124
type vhdl_port_mode_t =
4125
  | InPort [@name "in"]
4126
  | OutPort [@name "out"]
4127
  | InoutPort [@name "inout"]
4128
  | BufferPort [@name "buffer"]
4129

    
4130
let rec (pp_vhdl_port_mode_t :
4131
          Format.formatter -> vhdl_port_mode_t -> Ppx_deriving_runtime.unit)
4132
  =
4133
  ((let open! Ppx_deriving_runtime in
4134
      fun fmt  ->
4135
        function
4136
        | InPort  -> Format.pp_print_string fmt "in"
4137
        | OutPort  -> Format.pp_print_string fmt "out"
4138
        | InoutPort  -> Format.pp_print_string fmt "inout"
4139
        | BufferPort  -> Format.pp_print_string fmt "buffer")
4140
  [@ocaml.warning "-A"])
4141

    
4142
and show_vhdl_port_mode_t : vhdl_port_mode_t -> Ppx_deriving_runtime.string =
4143
  fun x  -> Format.asprintf "%a" pp_vhdl_port_mode_t x
4144

    
4145
let rec (vhdl_port_mode_t_to_yojson : vhdl_port_mode_t -> Yojson.Safe.json) =
4146
  ((let open! Ppx_deriving_yojson_runtime in
4147
      function
4148
      | InPort  -> `List [`String "in"]
4149
      | OutPort  -> `List [`String "out"]
4150
      | InoutPort  -> `List [`String "inout"]
4151
      | BufferPort  -> `List [`String "buffer"])
4152
  [@ocaml.warning "-A"])
4153

    
4154
and (vhdl_port_mode_t_of_yojson :
4155
      Yojson.Safe.json ->
4156
        vhdl_port_mode_t Ppx_deriving_yojson_runtime.error_or)
4157
  =
4158
  ((let open! Ppx_deriving_yojson_runtime in
4159
      function
4160
      | `List ((`String "in")::[]) -> Result.Ok InPort
4161
      | `List ((`String "out")::[]) -> Result.Ok OutPort
4162
      | `List ((`String "inout")::[]) -> Result.Ok InoutPort
4163
      | `List ((`String "buffer")::[]) -> Result.Ok BufferPort
4164
      | _ -> Result.Error "Vhdl_ast.vhdl_port_mode_t")
4165
  [@ocaml.warning "-A"])
4166

    
4167
type vhdl_port_t =
4168
  {
4169
  names: vhdl_name_t list [@default []];
4170
  mode: vhdl_port_mode_t [@default InPort];
4171
  typ: vhdl_subtype_indication_t ;
4172
  expr: vhdl_expr_t [@default IsNull]}
4173

    
4174
let rec pp_vhdl_port_t :
4175
  Format.formatter -> vhdl_port_t -> Ppx_deriving_runtime.unit =
4176
  let __3 () = pp_vhdl_expr_t
4177
  
4178
  and __2 () = pp_vhdl_subtype_indication_t
4179
  
4180
  and __1 () = pp_vhdl_port_mode_t
4181
  
4182
  and __0 () = pp_vhdl_name_t
4183
   in
4184
  ((let open! Ppx_deriving_runtime in
4185
      fun fmt  ->
4186
        fun x  ->
4187
          Format.fprintf fmt "@[";
4188
          ((((
4189
              ((fun x  ->
4190
                  Format.fprintf fmt "@[";
4191
                  ignore
4192
                    (List.fold_left
4193
                       (fun sep  ->
4194
                          fun x  ->
4195
                            if sep then Format.fprintf fmt ",@ ";
4196
                            ((__0 ()) fmt) x;
4197
                            true) false x);
4198
                  Format.fprintf fmt "@,@]")) x.names;
4199
              );
4200
             Format.fprintf fmt ": ";
4201
             ((__1 ()) fmt) x.mode;
4202
             );
4203
             Format.fprintf fmt " ";
4204
            ((__2 ()) fmt) x.typ;
4205
            );
4206
          (match x.expr with
4207
           | IsNull -> Format.fprintf fmt "";
4208
           | _ -> (Format.fprintf fmt "@[:= ";
4209
                   ((__3 ()) fmt) x.expr;
4210
                   Format.fprintf fmt "@]"));
4211
          Format.fprintf fmt "@]"))
4212
    [@ocaml.warning "-A"])
4213

    
4214
and show_vhdl_port_t : vhdl_port_t -> Ppx_deriving_runtime.string =
4215
  fun x  -> Format.asprintf "%a" pp_vhdl_port_t x
4216

    
4217
let rec (vhdl_port_t_to_yojson : vhdl_port_t -> Yojson.Safe.json) =
4218
  ((let open! Ppx_deriving_yojson_runtime in
4219
      fun x  ->
4220
        let fields = []  in
4221
        let fields =
4222
          if x.expr = IsNull
4223
          then fields
4224
          else ("expr", (((fun x  -> vhdl_expr_t_to_yojson x)) x.expr)) ::
4225
            fields
4226
           in
4227
        let fields =
4228
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
4229
          :: fields  in
4230
        let fields =
4231
          if x.mode = InPort
4232
          then fields
4233
          else ("mode", (((fun x  -> vhdl_port_mode_t_to_yojson x)) x.mode))
4234
            :: fields
4235
           in
4236
        let fields =
4237
          if x.names = []
4238
          then fields
4239
          else
4240
            ("names",
4241
              (((fun x  ->
4242
                   `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x)))
4243
                 x.names))
4244
            :: fields
4245
           in
4246
        `Assoc fields)
4247
  [@ocaml.warning "-A"])
4248

    
4249
and (vhdl_port_t_of_yojson :
4250
      Yojson.Safe.json -> vhdl_port_t Ppx_deriving_yojson_runtime.error_or)
4251
  =
4252
  ((let open! Ppx_deriving_yojson_runtime in
4253
      function
4254
      | `Assoc xs ->
4255
          let rec loop xs ((arg0,arg1,arg2,arg3) as _state) =
4256
            match xs with
4257
            | ("names",x)::xs ->
4258
                loop xs
4259
                  (((function
4260
                     | `List xs ->
4261
                         map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4262
                     | _ -> Result.Error "Vhdl_ast.vhdl_port_t.names") x),
4263
                    arg1, arg2, arg3)
4264
            | ("mode",x)::xs ->
4265
                loop xs
4266
                  (arg0, ((fun x  -> vhdl_port_mode_t_of_yojson x) x), arg2,
4267
                    arg3)
4268
            | ("typ",x)::xs ->
4269
                loop xs
4270
                  (arg0, arg1,
4271
                    ((fun x  -> vhdl_subtype_indication_t_of_yojson x) x),
4272
                    arg3)
4273
            | ("expr",x)::xs ->
4274
                loop xs
4275
                  (arg0, arg1, arg2, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4276
            | [] ->
4277
                arg3 >>=
4278
                  ((fun arg3  ->
4279
                      arg2 >>=
4280
                        (fun arg2  ->
4281
                           arg1 >>=
4282
                             (fun arg1  ->
4283
                                arg0 >>=
4284
                                  (fun arg0  ->
4285
                                     Result.Ok
4286
                                       {
4287
                                         names = arg0;
4288
                                         mode = arg1;
4289
                                         typ = arg2;
4290
                                         expr = arg3
4291
                                       })))))
4292
            | _::xs -> loop xs _state  in
4293
          loop xs
4294
            ((Result.Ok []), (Result.Ok InPort),
4295
              (Result.Error "Vhdl_ast.vhdl_port_t.typ"), (Result.Ok IsNull))
4296
      | _ -> Result.Error "Vhdl_ast.vhdl_port_t")
4297
  [@ocaml.warning "-A"])
4298
type vhdl_declaration_t =
4299
  | VarDecl of
4300
  {
4301
  names: vhdl_name_t list ;
4302
  typ: vhdl_subtype_indication_t ;
4303
  init_val: vhdl_expr_t [@default IsNull]} [@name "VARIABLE_DECLARATION"]
4304
  | CstDecl of
4305
  {
4306
  names: vhdl_name_t list ;
4307
  typ: vhdl_subtype_indication_t ;
4308
  init_val: vhdl_expr_t } [@name "CONSTANT_DECLARATION"]
4309
  | SigDecl of
4310
  {
4311
  names: vhdl_name_t list ;
4312
  typ: vhdl_subtype_indication_t ;
4313
  init_val: vhdl_expr_t [@default IsNull]} [@name "SIGNAL_DECLARATION"]
4314
  | ComponentDecl of
4315
  {
4316
  name: vhdl_name_t [@default NoName];
4317
  generics: vhdl_port_t list [@default []];
4318
  ports: vhdl_port_t list [@default []]} [@name "COMPONENT_DECLARATION"]
4319
  | Subprogram of
4320
  {
4321
  spec: vhdl_subprogram_spec_t ;
4322
  decl_part: vhdl_declaration_t list [@default []];
4323
  stmts: vhdl_sequential_stmt_t list [@default []]} [@name "SUBPROGRAM_BODY"]
4324

    
4325
let rec pp_vhdl_declaration_t :
4326
  Format.formatter -> vhdl_declaration_t -> Ppx_deriving_runtime.unit =
4327
  let __14 () = pp_vhdl_sequential_stmt_t
4328
  
4329
  and __13 () = pp_vhdl_declaration_t
4330
  
4331
  and __12 () = pp_vhdl_subprogram_spec_t
4332

    
4333
  and __11 () = pp_vhdl_port_t
4334
  
4335
  and __10 () = pp_vhdl_port_t
4336
  
4337
  and __9 () = pp_vhdl_name_t
4338
  
4339
  and __8 () = pp_vhdl_expr_t
4340
  
4341
  and __7 () = pp_vhdl_subtype_indication_t
4342
  
4343
  and __6 () = pp_vhdl_name_t
4344
  
4345
  and __5 () = pp_vhdl_expr_t
4346
  
4347
  and __4 () = pp_vhdl_subtype_indication_t
4348
  
4349
  and __3 () = pp_vhdl_name_t
4350
  
4351
  and __2 () = pp_vhdl_expr_t
4352
  
4353
  and __1 () = pp_vhdl_subtype_indication_t
4354
  
4355
  and __0 () = pp_vhdl_name_t
4356
   in
4357
  ((let open! Ppx_deriving_runtime in
4358
      fun fmt  ->
4359
        function
4360
        | VarDecl { names = anames; typ = atyp; init_val = ainit_val } ->
4361
            (Format.fprintf fmt "variable ";
4362
             ((((fun x  ->
4363
                    ignore
4364
                      (List.fold_left
4365
                         (fun sep  ->
4366
                            fun x  ->
4367
                              if sep then Format.fprintf fmt ",";
4368
                              ((__0 ()) fmt) x;
4369
                              true) false x);)) anames;
4370
               Format.fprintf fmt " : ";
4371
               ((__1 ()) fmt) atyp;
4372
               (match ainit_val with
4373
                | IsNull  -> Format.pp_print_string fmt ""
4374
                | _ ->
4375
                    (Format.fprintf fmt ":=";
4376
                     ((__2 ()) fmt) ainit_val;))));)
4377
        | CstDecl { names = anames; typ = atyp; init_val = ainit_val } ->
4378
            (Format.fprintf fmt "constant ";
4379
             ((((fun x  ->
4380
                    ignore
4381
                      (List.fold_left
4382
                         (fun sep  ->
4383
                            fun x  ->
4384
                              if sep then Format.fprintf fmt ",";
4385
                              ((__3 ()) fmt) x;
4386
                              true) false x);)) anames;
4387
               Format.fprintf fmt " : ";
4388
               ((__4 ()) fmt) atyp;
4389
              Format.fprintf fmt ":=";
4390
              ((__5 ()) fmt) ainit_val)))
4391
        | SigDecl { names = anames; typ = atyp; init_val = ainit_val } ->
4392
            (Format.fprintf fmt "signal ";
4393
            ((fun x  ->
4394
              ignore
4395
              (List.fold_left
4396
                (fun sep  ->
4397
                  fun x  ->
4398
                    if sep then Format.fprintf fmt ",";
4399
                                ((__6 ()) fmt) x;
4400
                                true) false x);
4401
              )) anames;
4402
            Format.fprintf fmt " : ";
4403
            ((__7 ()) fmt) atyp;
4404
            (match ainit_val with
4405
              | IsNull  -> Format.pp_print_string fmt ""
4406
              | _ ->
4407
                  (Format.fprintf fmt ":=";
4408
                  ((__8 ()) fmt) ainit_val;)))
4409
        | ComponentDecl
4410
            { name = aname; generics = agenerics; ports = aports } ->
4411
            Format.fprintf fmt "@[<v 2>component ";
4412
            ((__9 ()) fmt) aname;
4413
            Format.fprintf fmt " is@;";
4414
            ((fun x  ->
4415
              ignore
4416
                (List.fold_left
4417
                  (fun sep  ->
4418
                    fun x  ->
4419
                      if sep then Format.fprintf fmt "@;";
4420
                        ((__10 ()) fmt) x;
4421
                        true) false x))) agenerics;
4422
            ((fun x  ->
4423
              ignore
4424
                (List.fold_left
4425
                  (fun sep  ->
4426
                    fun x  ->
4427
                      if sep then Format.fprintf fmt "@;";
4428
                        ((__11 ()) fmt) x;
4429
                        true) false x))) aports;
4430
            Format.fprintf fmt "@]@;end component";
4431
        | Subprogram
4432
            { spec = aspec; decl_part = adecl_part; stmts = astmts }
4433
            ->
4434
              Format.fprintf fmt "@[<v 2>";
4435
              ((__12 ()) fmt) aspec;
4436
              Format.fprintf fmt " is";
4437
              (match adecl_part with
4438
              | [] -> Format.fprintf fmt "";
4439
              | _ ->
4440
                ((fun x  ->
4441
                  ignore
4442
                    (List.fold_left
4443
                      (fun sep  ->
4444
                         fun x  ->
4445
                           if sep then Format.fprintf fmt "";
4446
                             Format.fprintf fmt "@;";
4447
                             ((__13 ()) fmt) x;
4448
                             Format.fprintf fmt ";";
4449
                             true) false x))) adecl_part);
4450
              Format.fprintf fmt "@]@;";
4451
              Format.fprintf fmt "@[<v 2>begin@;";
4452
              ((fun x  ->
4453
                  ignore
4454
                    (List.fold_left
4455
                       (fun sep  ->
4456
                          fun x  ->
4457
                            if sep then Format.fprintf fmt "@;";
4458
                            ((__14 ()) fmt) x;
4459
                            Format.fprintf fmt ";";
4460
                            true) false x))) astmts;
4461
              Format.fprintf fmt "@]@;end";)
4462
    [@ocaml.warning "-A"])
4463

    
4464
and show_vhdl_declaration_t :
4465
  vhdl_declaration_t -> Ppx_deriving_runtime.string =
4466
  fun x  -> Format.asprintf "%a" pp_vhdl_declaration_t x
4467

    
4468
let rec (vhdl_declaration_t_to_yojson :
4469
          vhdl_declaration_t -> Yojson.Safe.json)
4470
  =
4471
  ((let open! Ppx_deriving_yojson_runtime in
4472
      function
4473
      | VarDecl arg0 ->
4474
          `List
4475
            [`String "VARIABLE_DECLARATION";
4476
            (let fields = []  in
4477
             let fields =
4478
               if arg0.init_val = IsNull
4479
               then fields
4480
               else
4481
                 ("init_val",
4482
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.init_val))
4483
                 :: fields
4484
                in
4485
             let fields =
4486
               ("typ",
4487
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
4488
               :: fields  in
4489
             let fields =
4490
               ("names",
4491
                 ((fun x  ->
4492
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
4493
                    arg0.names))
4494
               :: fields  in
4495
             `Assoc fields)]
4496
      | CstDecl arg0 ->
4497
          `List
4498
            [`String "CONSTANT_DECLARATION";
4499
            (let fields = []  in
4500
             let fields =
4501
               ("init_val",
4502
                 ((fun x  -> vhdl_expr_t_to_yojson x) arg0.init_val))
4503
               :: fields  in
4504
             let fields =
4505
               ("typ",
4506
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
4507
               :: fields  in
4508
             let fields =
4509
               ("names",
4510
                 ((fun x  ->
4511
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
4512
                    arg0.names))
4513
               :: fields  in
4514
             `Assoc fields)]
4515
      | SigDecl arg0 ->
4516
          `List
4517
            [`String "SIGNAL_DECLARATION";
4518
            (let fields = []  in
4519
             let fields =
4520
               if arg0.init_val = IsNull
4521
               then fields
4522
               else
4523
                 ("init_val",
4524
                   (((fun x  -> vhdl_expr_t_to_yojson x)) arg0.init_val))
4525
                 :: fields
4526
                in
4527
             let fields =
4528
               ("typ",
4529
                 ((fun x  -> vhdl_subtype_indication_t_to_yojson x) arg0.typ))
4530
               :: fields  in
4531
             let fields =
4532
               ("names",
4533
                 ((fun x  ->
4534
                     `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
4535
                    arg0.names))
4536
               :: fields  in
4537
             `Assoc fields)]
4538
      | ComponentDecl arg0 ->
4539
          `List
4540
            [`String "COMPONENT_DECLARATION";
4541
            (let fields = []  in
4542
             let fields =
4543
               if arg0.ports = []
4544
               then fields
4545
               else
4546
                 ("ports",
4547
                   (((fun x  ->
4548
                        `List
4549
                          (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
4550
                      arg0.ports))
4551
                 :: fields
4552
                in
4553
             let fields =
4554
               if arg0.generics = []
4555
               then fields
4556
               else
4557
                 ("generics",
4558
                   (((fun x  ->
4559
                        `List
4560
                          (List.map (fun x  -> vhdl_port_t_to_yojson x) x)))
4561
                      arg0.generics))
4562
                 :: fields
4563
                in
4564
             let fields =
4565
               if arg0.name = NoName
4566
               then fields
4567
               else
4568
                 ("name", (((fun x  -> vhdl_name_t_to_yojson x)) arg0.name))
4569
                 :: fields
4570
                in
4571
             `Assoc fields)]
4572
      | Subprogram arg0 ->
4573
          `List
4574
            [`String "SUBPROGRAM_BODY";
4575
            (let fields = []  in
4576
             let fields =
4577
               if arg0.stmts = []
4578
               then fields
4579
               else
4580
                 ("stmts",
4581
                   (((fun x  ->
4582
                        `List
4583
                          (List.map
4584
                             (fun x  -> vhdl_sequential_stmt_t_to_yojson x) x)))
4585
                      arg0.stmts))
4586
                 :: fields
4587
                in
4588
             let fields =
4589
               if arg0.decl_part = []
4590
               then fields
4591
               else
4592
                 ("decl_part",
4593
                   (((fun x  ->
4594
                        `List
4595
                          (List.map
4596
                             (fun x  -> vhdl_declaration_t_to_yojson x) x)))
4597
                      arg0.decl_part))
4598
                 :: fields
4599
                in
4600
             let fields =
4601
               ("spec",
4602
                 ((fun x  -> vhdl_subprogram_spec_t_to_yojson x) arg0.spec))
4603
               :: fields  in
4604
             `Assoc fields)])
4605
  [@ocaml.warning "-A"])
4606

    
4607
and (vhdl_declaration_t_of_yojson :
4608
      Yojson.Safe.json ->
4609
        vhdl_declaration_t Ppx_deriving_yojson_runtime.error_or)
4610
  =
4611
  ((let open! Ppx_deriving_yojson_runtime in
4612
      function
4613
      | `List ((`String "VARIABLE_DECLARATION")::arg0::[]) ->
4614
          ((function
4615
            | `Assoc xs ->
4616
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4617
                  match xs with
4618
                  | ("names",x)::xs ->
4619
                      loop xs
4620
                        (((function
4621
                           | `List xs ->
4622
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4623
                                 [] xs
4624
                           | _ ->
4625
                               Result.Error
4626
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4627
                          arg1, arg2)
4628
                  | ("typ",x)::xs ->
4629
                      loop xs
4630
                        (arg0,
4631
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4632
                             x), arg2)
4633
                  | ("init_val",x)::xs ->
4634
                      loop xs
4635
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4636
                  | [] ->
4637
                      arg2 >>=
4638
                        ((fun arg2  ->
4639
                            arg1 >>=
4640
                              (fun arg1  ->
4641
                                 arg0 >>=
4642
                                   (fun arg0  ->
4643
                                      Result.Ok
4644
                                        (VarDecl
4645
                                           {
4646
                                             names = arg0;
4647
                                             typ = arg1;
4648
                                             init_val = arg2
4649
                                           })))))
4650
                  | _::xs -> loop xs _state  in
4651
                loop xs
4652
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4653
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4654
                    (Result.Ok IsNull))
4655
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4656
      | `List ((`String "CONSTANT_DECLARATION")::arg0::[]) ->
4657
          ((function
4658
            | `Assoc xs ->
4659
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4660
                  match xs with
4661
                  | ("names",x)::xs ->
4662
                      loop xs
4663
                        (((function
4664
                           | `List xs ->
4665
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4666
                                 [] xs
4667
                           | _ ->
4668
                               Result.Error
4669
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4670
                          arg1, arg2)
4671
                  | ("typ",x)::xs ->
4672
                      loop xs
4673
                        (arg0,
4674
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4675
                             x), arg2)
4676
                  | ("init_val",x)::xs ->
4677
                      loop xs
4678
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4679
                  | [] ->
4680
                      arg2 >>=
4681
                        ((fun arg2  ->
4682
                            arg1 >>=
4683
                              (fun arg1  ->
4684
                                 arg0 >>=
4685
                                   (fun arg0  ->
4686
                                      Result.Ok
4687
                                        (CstDecl
4688
                                           {
4689
                                             names = arg0;
4690
                                             typ = arg1;
4691
                                             init_val = arg2
4692
                                           })))))
4693
                  | _::xs -> loop xs _state  in
4694
                loop xs
4695
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4696
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4697
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.init_val"))
4698
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4699
      | `List ((`String "SIGNAL_DECLARATION")::arg0::[]) ->
4700
          ((function
4701
            | `Assoc xs ->
4702
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4703
                  match xs with
4704
                  | ("names",x)::xs ->
4705
                      loop xs
4706
                        (((function
4707
                           | `List xs ->
4708
                               map_bind (fun x  -> vhdl_name_t_of_yojson x)
4709
                                 [] xs
4710
                           | _ ->
4711
                               Result.Error
4712
                                 "Vhdl_ast.vhdl_declaration_t.names") x),
4713
                          arg1, arg2)
4714
                  | ("typ",x)::xs ->
4715
                      loop xs
4716
                        (arg0,
4717
                          ((fun x  -> vhdl_subtype_indication_t_of_yojson x)
4718
                             x), arg2)
4719
                  | ("init_val",x)::xs ->
4720
                      loop xs
4721
                        (arg0, arg1, ((fun x  -> vhdl_expr_t_of_yojson x) x))
4722
                  | [] ->
4723
                      arg2 >>=
4724
                        ((fun arg2  ->
4725
                            arg1 >>=
4726
                              (fun arg1  ->
4727
                                 arg0 >>=
4728
                                   (fun arg0  ->
4729
                                      Result.Ok
4730
                                        (SigDecl
4731
                                           {
4732
                                             names = arg0;
4733
                                             typ = arg1;
4734
                                             init_val = arg2
4735
                                           })))))
4736
                  | _::xs -> loop xs _state  in
4737
                loop xs
4738
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.names"),
4739
                    (Result.Error "Vhdl_ast.vhdl_declaration_t.typ"),
4740
                    (Result.Ok IsNull))
4741
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4742
      | `List ((`String "COMPONENT_DECLARATION")::arg0::[]) ->
4743
          ((function
4744
            | `Assoc xs ->
4745
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4746
                  match xs with
4747
                  | ("name",x)::xs ->
4748
                      loop xs
4749
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2)
4750
                  | ("generics",x)::xs ->
4751
                      loop xs
4752
                        (arg0,
4753
                          ((function
4754
                            | `List xs ->
4755
                                map_bind (fun x  -> vhdl_port_t_of_yojson x)
4756
                                  [] xs
4757
                            | _ ->
4758
                                Result.Error
4759
                                  "Vhdl_ast.vhdl_declaration_t.generics") x),
4760
                          arg2)
4761
                  | ("ports",x)::xs ->
4762
                      loop xs
4763
                        (arg0, arg1,
4764
                          ((function
4765
                            | `List xs ->
4766
                                map_bind (fun x  -> vhdl_port_t_of_yojson x)
4767
                                  [] xs
4768
                            | _ ->
4769
                                Result.Error
4770
                                  "Vhdl_ast.vhdl_declaration_t.ports") x))
4771
                  | [] ->
4772
                      arg2 >>=
4773
                        ((fun arg2  ->
4774
                            arg1 >>=
4775
                              (fun arg1  ->
4776
                                 arg0 >>=
4777
                                   (fun arg0  ->
4778
                                      Result.Ok
4779
                                        (ComponentDecl
4780
                                           {
4781
                                             name = arg0;
4782
                                             generics = arg1;
4783
                                             ports = arg2
4784
                                           })))))
4785
                  | _::xs -> loop xs _state  in
4786
                loop xs ((Result.Ok NoName), (Result.Ok []), (Result.Ok []))
4787
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4788
      | `List ((`String "SUBPROGRAM_BODY")::arg0::[]) ->
4789
          ((function
4790
            | `Assoc xs ->
4791
                let rec loop xs ((arg0,arg1,arg2) as _state) =
4792
                  match xs with
4793
                  | ("spec",x)::xs ->
4794
                      loop xs
4795
                        (((fun x  -> vhdl_subprogram_spec_t_of_yojson x) x),
4796
                          arg1, arg2)
4797
                  | ("decl_part",x)::xs ->
4798
                      loop xs
4799
                        (arg0,
4800
                          ((function
4801
                            | `List xs ->
4802
                                map_bind
4803
                                  (fun x  -> vhdl_declaration_t_of_yojson x)
4804
                                  [] xs
4805
                            | _ ->
4806
                                Result.Error
4807
                                  "Vhdl_ast.vhdl_declaration_t.decl_part") x),
4808
                          arg2)
4809
                  | ("stmts",x)::xs ->
4810
                      loop xs
4811
                        (arg0, arg1,
4812
                          ((function
4813
                            | `List xs ->
4814
                                map_bind
4815
                                  (fun x  ->
4816
                                     vhdl_sequential_stmt_t_of_yojson x) []
4817
                                  xs
4818
                            | _ ->
4819
                                Result.Error
4820
                                  "Vhdl_ast.vhdl_declaration_t.stmts") x))
4821
                  | [] ->
4822
                      arg2 >>=
4823
                        ((fun arg2  ->
4824
                            arg1 >>=
4825
                              (fun arg1  ->
4826
                                 arg0 >>=
4827
                                   (fun arg0  ->
4828
                                      Result.Ok
4829
                                        (Subprogram
4830
                                           {
4831
                                             spec = arg0;
4832
                                             decl_part = arg1;
4833
                                             stmts = arg2
4834
                                           })))))
4835
                  | _::xs -> loop xs _state  in
4836
                loop xs
4837
                  ((Result.Error "Vhdl_ast.vhdl_declaration_t.spec"),
4838
                    (Result.Ok []), (Result.Ok []))
4839
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4840
      | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")
4841
  [@ocaml.warning "-A"])
4842

    
4843
type vhdl_load_t =
4844
  | Library of vhdl_name_t list [@name "LIBRARY_CLAUSE"][@default []]
4845
  | Use of vhdl_name_t list [@name "USE_CLAUSE"][@default []]
4846

    
4847
(* Adapted. TODO: check indentation *)
4848
let rec pp_vhdl_load_t :
4849
  Format.formatter -> vhdl_load_t -> Ppx_deriving_runtime.unit =
4850
  let __1 () = pp_vhdl_name_t
4851
  
4852
  and __0 () = pp_vhdl_name_t
4853
   in
4854
  ((let open! Ppx_deriving_runtime in
4855
      fun fmt  ->
4856
        function
4857
        | Library a0 ->
4858
            (Format.fprintf fmt "library ";
4859
             ((fun x  ->
4860
                 ignore
4861
                   (List.fold_left
4862
                      (fun sep  ->
4863
                         fun x  ->
4864
                           if sep then Format.fprintf fmt ".";
4865
                           ((__0 ()) fmt) x;
4866
                           true) false x))) a0;
4867
             Format.fprintf fmt ":")
4868
        | Use a0 ->
4869
            (Format.fprintf fmt "use ";
4870
             ((fun x  ->
4871
                 ignore
4872
                   (List.fold_left
4873
                      (fun sep  ->
4874
                         fun x  ->
4875
                           if sep then Format.fprintf fmt ".";
4876
                           ((__1 ()) fmt) x;
4877
                           true) false x))) a0))
4878
    [@ocaml.warning "-A"])
4879

    
4880
and show_vhdl_load_t : vhdl_load_t -> Ppx_deriving_runtime.string =
4881
  fun x  -> Format.asprintf "%a" pp_vhdl_load_t x
4882

    
4883
let rec (vhdl_load_t_to_yojson : vhdl_load_t -> Yojson.Safe.json) =
4884
  ((let open! Ppx_deriving_yojson_runtime in
4885
      function
4886
      | Library arg0 ->
4887
          `List
4888
            [`String "LIBRARY_CLAUSE";
4889
            ((fun x  ->
4890
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0]
4891
      | Use arg0 ->
4892
          `List
4893
            [`String "USE_CLAUSE";
4894
            ((fun x  ->
4895
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))) arg0])
4896
  [@ocaml.warning "-A"])
4897

    
4898
and (vhdl_load_t_of_yojson :
4899
      Yojson.Safe.json -> vhdl_load_t Ppx_deriving_yojson_runtime.error_or)
4900
  =
4901
  ((let open! Ppx_deriving_yojson_runtime in
4902
      function
4903
      | `List ((`String "LIBRARY_CLAUSE")::arg0::[]) ->
4904
          ((function
4905
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4906
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
4907
            ((fun arg0  -> Result.Ok (Library arg0)))
4908
      | `List ((`String "USE_CLAUSE")::arg0::[]) ->
4909
          ((function
4910
            | `List xs -> map_bind (fun x  -> vhdl_name_t_of_yojson x) [] xs
4911
            | _ -> Result.Error "Vhdl_ast.vhdl_load_t") arg0) >>=
4912
            ((fun arg0  -> Result.Ok (Use arg0)))
4913
      | _ -> Result.Error "Vhdl_ast.vhdl_load_t")
4914
  [@ocaml.warning "-A"])
4915

    
4916
type vhdl_declarative_item_t =
4917
  {
4918
  use_clause: vhdl_load_t option [@default None];
4919
  declaration: vhdl_declaration_t option [@default None];
4920
  definition: vhdl_definition_t option [@default None]}[@@deriving
4921
                                                         ((show
4922
                                                             {
4923
                                                               with_path =
4924
                                                                 false
4925
                                                             }),
4926
                                                           (yojson
4927
                                                              {
4928
                                                                strict =
4929
                                                                  false
4930
                                                              }))]
4931
let rec pp_vhdl_declarative_item_t :
4932
  Format.formatter -> vhdl_declarative_item_t -> Ppx_deriving_runtime.unit =
4933
  let __2 () = pp_vhdl_definition_t
4934
  
4935
  and __1 () = pp_vhdl_declaration_t
4936
  
4937
  and __0 () = pp_vhdl_load_t
4938
   in
4939
  ((let open! Ppx_deriving_runtime in
4940
      fun fmt  ->
4941
        fun x  ->
4942
          (match x.use_clause with
4943
          | None -> Format.fprintf fmt "";
4944
          | Some e -> ((__0 ()) fmt) e);
4945
          (match x.declaration with
4946
          | None -> Format.fprintf fmt "";
4947
          | Some e -> ((__1 ()) fmt) e);
4948
          (match x.definition with
4949
          | None -> Format.fprintf fmt "";
4950
          | Some e -> ((__2 ()) fmt) e);)
4951
    [@ocaml.warning "-A"])
4952

    
4953
and show_vhdl_declarative_item_t :
4954
  vhdl_declarative_item_t -> Ppx_deriving_runtime.string =
4955
  fun x  -> Format.asprintf "%a" pp_vhdl_declarative_item_t x
4956

    
4957
let rec (vhdl_declarative_item_t_to_yojson :
4958
          vhdl_declarative_item_t -> Yojson.Safe.json)
4959
  =
4960
  ((let open! Ppx_deriving_yojson_runtime in
4961
      fun x  ->
4962
        let fields = []  in
4963
        let fields =
4964
          if x.definition = None
4965
          then fields
4966
          else
4967
            ("definition",
4968
              (((function
4969
                 | None  -> `Null
4970
                 | Some x -> ((fun x  -> vhdl_definition_t_to_yojson x)) x))
4971
                 x.definition))
4972
            :: fields
4973
           in
4974
        let fields =
4975
          if x.declaration = None
4976
          then fields
4977
          else
4978
            ("declaration",
4979
              (((function
4980
                 | None  -> `Null
4981
                 | Some x -> ((fun x  -> vhdl_declaration_t_to_yojson x)) x))
4982
                 x.declaration))
4983
            :: fields
4984
           in
4985
        let fields =
4986
          if x.use_clause = None
4987
          then fields
4988
          else
4989
            ("use_clause",
4990
              (((function
4991
                 | None  -> `Null
4992
                 | Some x -> ((fun x  -> vhdl_load_t_to_yojson x)) x))
4993
                 x.use_clause))
4994
            :: fields
4995
           in
4996
        `Assoc fields)
4997
  [@ocaml.warning "-A"])
4998

    
4999
and (vhdl_declarative_item_t_of_yojson :
5000
      Yojson.Safe.json ->
5001
        vhdl_declarative_item_t Ppx_deriving_yojson_runtime.error_or)
5002
  =
5003
  ((let open! Ppx_deriving_yojson_runtime in
5004
      function
5005
      | `Assoc xs ->
5006
          let rec loop xs ((arg0,arg1,arg2) as _state) =
5007
            match xs with
5008
            | ("use_clause",x)::xs ->
5009
                loop xs
5010
                  (((function
5011
                     | `Null -> Result.Ok None
5012
                     | x ->
5013
                         ((fun x  -> vhdl_load_t_of_yojson x) x) >>=
5014
                           ((fun x  -> Result.Ok (Some x)))) x), arg1, arg2)
5015
            | ("declaration",x)::xs ->
5016
                loop xs
5017
                  (arg0,
5018
                    ((function
5019
                      | `Null -> Result.Ok None
5020
                      | x ->
5021
                          ((fun x  -> vhdl_declaration_t_of_yojson x) x) >>=
5022
                            ((fun x  -> Result.Ok (Some x)))) x), arg2)
5023
            | ("definition",x)::xs ->
5024
                loop xs
5025
                  (arg0, arg1,
5026
                    ((function
5027
                      | `Null -> Result.Ok None
5028
                      | x ->
5029
                          ((fun x  -> vhdl_definition_t_of_yojson x) x) >>=
5030
                            ((fun x  -> Result.Ok (Some x)))) x))
5031
            | [] ->
5032
                arg2 >>=
5033
                  ((fun arg2  ->
5034
                      arg1 >>=
5035
                        (fun arg1  ->
5036
                           arg0 >>=
5037
                             (fun arg0  ->
5038
                                Result.Ok
5039
                                  {
5040
                                    use_clause = arg0;
5041
                                    declaration = arg1;
5042
                                    definition = arg2
5043
                                  }))))
5044
            | _::xs -> loop xs _state  in
5045
          loop xs ((Result.Ok None), (Result.Ok None), (Result.Ok None))
5046
      | _ -> Result.Error "Vhdl_ast.vhdl_declarative_item_t")
5047
  [@ocaml.warning "-A"])
5048

    
5049
type vhdl_signal_condition_t =
5050
  {
5051
  expr: vhdl_waveform_element_t list [@default []];
5052
  cond: vhdl_expr_t [@default IsNull]}[@@deriving
5053
                                        ((show { with_path = false }),
5054
                                          (yojson { strict = false }))]
5055

    
5056
let rec pp_vhdl_signal_condition_t :
5057
  Format.formatter -> vhdl_signal_condition_t -> Ppx_deriving_runtime.unit =
5058
  let __1 () = pp_vhdl_expr_t
5059
  
5060
  and __0 () = pp_vhdl_waveform_element_t
5061
   in
5062
  ((let open! Ppx_deriving_runtime in
5063
      fun fmt  ->
5064
        fun x  ->
5065
          ((fun x  ->
5066
              ignore
5067
                (List.fold_left
5068
                   (fun sep  ->
5069
                      fun x  ->
5070
                        if sep then Format.fprintf fmt ";@ ";
5071
                        ((__0 ()) fmt) x;
5072
                        true) false x))) x.expr;
5073
          (match x.cond with
5074
          | IsNull -> Format.fprintf fmt "";
5075
          | _ -> Format.fprintf fmt "when ";
5076
                 ((__1 ()) fmt) x.cond);)
5077
    [@ocaml.warning "-A"])
5078

    
5079
and show_vhdl_signal_condition_t :
5080
  vhdl_signal_condition_t -> Ppx_deriving_runtime.string =
5081
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_condition_t x
5082

    
5083
let rec (vhdl_signal_condition_t_to_yojson :
5084
          vhdl_signal_condition_t -> Yojson.Safe.json)
5085
  =
5086
  ((let open! Ppx_deriving_yojson_runtime in
5087
      fun x  ->
5088
        let fields = []  in
5089
        let fields =
5090
          if x.cond = IsNull
5091
          then fields
5092
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
5093
            fields
5094
           in
5095
        let fields =
5096
          if x.expr = []
5097
          then fields
5098
          else
5099
            ("expr",
5100
              (((fun x  ->
5101
                   `List
5102
                     (List.map
5103
                        (fun x  -> vhdl_waveform_element_t_to_yojson x) x)))
5104
                 x.expr))
5105
            :: fields
5106
           in
5107
        `Assoc fields)
5108
  [@ocaml.warning "-A"])
5109

    
5110
and (vhdl_signal_condition_t_of_yojson :
5111
      Yojson.Safe.json ->
5112
        vhdl_signal_condition_t Ppx_deriving_yojson_runtime.error_or)
5113
  =
5114
  ((let open! Ppx_deriving_yojson_runtime in
5115
      function
5116
      | `Assoc xs ->
5117
          let rec loop xs ((arg0,arg1) as _state) =
5118
            match xs with
5119
            | ("expr",x)::xs ->
5120
                loop xs
5121
                  (((function
5122
                     | `List xs ->
5123
                         map_bind
5124
                           (fun x  -> vhdl_waveform_element_t_of_yojson x) []
5125
                           xs
5126
                     | _ ->
5127
                         Result.Error "Vhdl_ast.vhdl_signal_condition_t.expr")
5128
                      x), arg1)
5129
            | ("cond",x)::xs ->
5130
                loop xs (arg0, ((fun x  -> vhdl_expr_t_of_yojson x) x))
5131
            | [] ->
5132
                arg1 >>=
5133
                  ((fun arg1  ->
5134
                      arg0 >>=
5135
                        (fun arg0  -> Result.Ok { expr = arg0; cond = arg1 })))
5136
            | _::xs -> loop xs _state  in
5137
          loop xs ((Result.Ok []), (Result.Ok IsNull))
5138
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_condition_t")
5139
  [@ocaml.warning "-A"])
5140

    
5141
type vhdl_signal_selection_t =
5142
  {
5143
  expr: vhdl_waveform_element_t list [@default []];
5144
  when_sel: vhdl_expr_t list [@default []]}[@@deriving
5145
                                             ((show { with_path = false }),
5146
                                               (yojson { strict = false }))]
5147

    
5148
let rec pp_vhdl_signal_selection_t :
5149
  Format.formatter -> vhdl_signal_selection_t -> Ppx_deriving_runtime.unit =
5150
  let __1 () = pp_vhdl_expr_t
5151
  
5152
  and __0 () = pp_vhdl_waveform_element_t
5153
   in
5154
  ((let open! Ppx_deriving_runtime in
5155
      fun fmt  ->
5156
        fun x  ->
5157
          ((fun x  ->
5158
            ignore
5159
              (List.fold_left
5160
                (fun sep  ->
5161
                  fun x  ->
5162
                    if sep then Format.fprintf fmt "@ ";
5163
                      ((__0 ()) fmt) x;
5164
                      true) false x))) x.expr;
5165
          Format.fprintf fmt " when ";
5166
          ((fun x  ->
5167
            ignore
5168
              (List.fold_left
5169
                (fun sep  ->
5170
                  fun x  ->
5171
                    if sep then Format.fprintf fmt "|@ ";
5172
                      ((__1 ()) fmt) x;
5173
                      true) false x))) x.when_sel)
5174
    [@ocaml.warning "-A"])
5175

    
5176
and show_vhdl_signal_selection_t :
5177
  vhdl_signal_selection_t -> Ppx_deriving_runtime.string =
5178
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_selection_t x
5179

    
5180
let rec (vhdl_signal_selection_t_to_yojson :
5181
          vhdl_signal_selection_t -> Yojson.Safe.json)
5182
  =
5183
  ((let open! Ppx_deriving_yojson_runtime in
5184
      fun x  ->
5185
        let fields = []  in
5186
        let fields =
5187
          if x.when_sel = []
5188
          then fields
5189
          else
5190
            ("when_sel",
5191
              (((fun x  ->
5192
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
5193
                 x.when_sel))
5194
            :: fields
5195
           in
5196
        let fields =
5197
          if x.expr = []
5198
          then fields
5199
          else
5200
            ("expr",
5201
              (((fun x  ->
5202
                   `List
5203
                     (List.map
5204
                        (fun x  -> vhdl_waveform_element_t_to_yojson x) x)))
5205
                 x.expr))
5206
            :: fields
5207
           in
5208
        `Assoc fields)
5209
  [@ocaml.warning "-A"])
5210

    
5211
and (vhdl_signal_selection_t_of_yojson :
5212
      Yojson.Safe.json ->
5213
        vhdl_signal_selection_t Ppx_deriving_yojson_runtime.error_or)
5214
  =
5215
  ((let open! Ppx_deriving_yojson_runtime in
5216
      function
5217
      | `Assoc xs ->
5218
          let rec loop xs ((arg0,arg1) as _state) =
5219
            match xs with
5220
            | ("expr",x)::xs ->
5221
                loop xs
5222
                  (((function
5223
                     | `List xs ->
5224
                         map_bind
5225
                           (fun x  -> vhdl_waveform_element_t_of_yojson x) []
5226
                           xs
5227
                     | _ ->
5228
                         Result.Error "Vhdl_ast.vhdl_signal_selection_t.expr")
5229
                      x), arg1)
5230
            | ("when_sel",x)::xs ->
5231
                loop xs
5232
                  (arg0,
5233
                    ((function
5234
                      | `List xs ->
5235
                          map_bind (fun x  -> vhdl_expr_t_of_yojson x) [] xs
5236
                      | _ ->
5237
                          Result.Error
5238
                            "Vhdl_ast.vhdl_signal_selection_t.when_sel") x))
5239
            | [] ->
5240
                arg1 >>=
5241
                  ((fun arg1  ->
5242
                      arg0 >>=
5243
                        (fun arg0  ->
5244
                           Result.Ok { expr = arg0; when_sel = arg1 })))
5245
            | _::xs -> loop xs _state  in
5246
          loop xs ((Result.Ok []), (Result.Ok []))
5247
      | _ -> Result.Error "Vhdl_ast.vhdl_signal_selection_t")
5248
  [@ocaml.warning "-A"])
5249

    
5250
type vhdl_conditional_signal_t =
5251
  {
5252
  postponed: bool [@default false];
5253
  label: vhdl_name_t [@default NoName];
5254
  lhs: vhdl_name_t ;
5255
  rhs: vhdl_signal_condition_t list ;
5256
  cond: vhdl_expr_t [@default IsNull];
5257
  delay: vhdl_expr_t [@default IsNull]}
5258

    
5259
let rec pp_vhdl_conditional_signal_t :
5260
  Format.formatter -> vhdl_conditional_signal_t -> Ppx_deriving_runtime.unit
5261
  =
5262
  let __4 () = pp_vhdl_expr_t
5263
  
5264
  and __3 () = pp_vhdl_expr_t
5265
  
5266
  and __2 () = pp_vhdl_signal_condition_t
5267
  
5268
  and __1 () = pp_vhdl_name_t
5269
  
5270
  and __0 () = pp_vhdl_name_t
5271
   in
5272
  ((let open! Ppx_deriving_runtime in
5273
      fun fmt  ->
5274
        fun x  ->
5275
          (match x.label with
5276
            | NoName -> Format.fprintf fmt "";
5277
            | _ -> (((__0 ()) fmt) x.label;
5278
                   Format.fprintf fmt ":@ ")
5279
          );
5280
          if (x.postponed) then Format.fprintf fmt "postponed@ ";
5281
          ((__1 ()) fmt) x.lhs;
5282
          Format.fprintf fmt " <= ";
5283
          (match x.delay with
5284
            | IsNull -> Format.fprintf fmt "";
5285
            | _ -> ((__4 ()) fmt) x.delay;
5286
                   Format.fprintf fmt " ");
5287
          ((fun x  ->
5288
             Format.fprintf fmt "@[";
5289
             ignore
5290
               (List.fold_left
5291
                 (fun sep  ->
5292
                   fun x  ->
5293
                     if sep then Format.fprintf fmt "";
5294
                      ((__2 ()) fmt) x;
5295
                      Format.fprintf fmt ";";
5296
                      true) false x);
5297
          Format.fprintf fmt "@]")) x.rhs;
5298
          (match x.cond with
5299
            | IsNull -> Format.fprintf fmt "";
5300
            | _ -> Format.fprintf fmt "when (";
5301
                   ((__3 ()) fmt) x.cond;
5302
                   Format.fprintf fmt ")"))
5303
   [@ocaml.warning "-A"])
5304

    
5305
and show_vhdl_conditional_signal_t :
5306
  vhdl_conditional_signal_t -> Ppx_deriving_runtime.string =
5307
  fun x  -> Format.asprintf "%a" pp_vhdl_conditional_signal_t x
5308

    
5309
let rec (vhdl_conditional_signal_t_to_yojson :
5310
          vhdl_conditional_signal_t -> Yojson.Safe.json)
5311
  =
5312
  ((let open! Ppx_deriving_yojson_runtime in
5313
      fun x  ->
5314
        let fields = []  in
5315
        let fields =
5316
          if x.delay = IsNull
5317
          then fields
5318
          else ("delay", (((fun x  -> vhdl_expr_t_to_yojson x)) x.delay)) ::
5319
            fields
5320
           in
5321
        let fields =
5322
          if x.cond = IsNull
5323
          then fields
5324
          else ("cond", (((fun x  -> vhdl_expr_t_to_yojson x)) x.cond)) ::
5325
            fields
5326
           in
5327
        let fields =
5328
          ("rhs",
5329
            ((fun x  ->
5330
                `List
5331
                  (List.map (fun x  -> vhdl_signal_condition_t_to_yojson x) x))
5332
               x.rhs))
5333
          :: fields  in
5334
        let fields = ("lhs", ((fun x  -> vhdl_name_t_to_yojson x) x.lhs)) ::
5335
          fields  in
5336
        let fields =
5337
          if x.label = NoName
5338
          then fields
5339
          else ("label", (((fun x  -> vhdl_name_t_to_yojson x)) x.label)) ::
5340
            fields
5341
           in
5342
        let fields =
5343
          if x.postponed = false
5344
          then fields
5345
          else
5346
            ("postponed",
5347
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x))
5348
                 x.postponed))
5349
            :: fields
5350
           in
5351
        `Assoc fields)
5352
  [@ocaml.warning "-A"])
5353

    
5354
and (vhdl_conditional_signal_t_of_yojson :
5355
      Yojson.Safe.json ->
5356
        vhdl_conditional_signal_t Ppx_deriving_yojson_runtime.error_or)
5357
  =
5358
  ((let open! Ppx_deriving_yojson_runtime in
5359
      function
5360
      | `Assoc xs ->
5361
          let rec loop xs ((arg0,arg1,arg2,arg3,arg4,arg5) as _state) =
5362
            match xs with
5363
            | ("postponed",x)::xs ->
5364
                loop xs
5365
                  (((function
5366
                     | `Bool x -> Result.Ok x
5367
                     | _ ->
5368
                         Result.Error
5369
                           "Vhdl_ast.vhdl_conditional_signal_t.postponed") x),
5370
                    arg1, arg2, arg3, arg4, arg5)
5371
            | ("label",x)::xs ->
5372
                loop xs
5373
                  (arg0, ((fun x  -> vhdl_name_t_of_yojson x) x), arg2, arg3,
5374
                    arg4, arg5)
5375
            | ("lhs",x)::xs ->
5376
                loop xs
5377
                  (arg0, arg1, ((fun x  -> vhdl_name_t_of_yojson x) x), arg3,
5378
                    arg4, arg5)
5379
            | ("rhs",x)::xs ->
5380
                loop xs
5381
                  (arg0, arg1, arg2,
5382
                    ((function
5383
                      | `List xs ->
5384
                          map_bind
5385
                            (fun x  -> vhdl_signal_condition_t_of_yojson x)
5386
                            [] xs
5387
                      | _ ->
5388
                          Result.Error
5389
                            "Vhdl_ast.vhdl_conditional_signal_t.rhs") x),
5390
                    arg4, arg5)
5391
            | ("cond",x)::xs ->
5392
                loop xs
5393
                  (arg0, arg1, arg2, arg3,
5394
                    ((fun x  -> vhdl_expr_t_of_yojson x) x), arg5)
5395
            | ("delay",x)::xs ->
5396
                loop xs
5397
                  (arg0, arg1, arg2, arg3, arg4,
5398
                    ((fun x  -> vhdl_expr_t_of_yojson x) x))
5399
            | [] ->
5400
                arg5 >>=
5401
                  ((fun arg5  ->
5402
                      arg4 >>=
5403
                        (fun arg4  ->
5404
                           arg3 >>=
5405
                             (fun arg3  ->
5406
                                arg2 >>=
5407
                                  (fun arg2  ->
5408
                                     arg1 >>=
5409
                                       (fun arg1  ->
5410
                                          arg0 >>=
5411
                                            (fun arg0  ->
5412
                                               Result.Ok
5413
                                                 {
5414
                                                   postponed = arg0;
5415
                                                   label = arg1;
5416
                                                   lhs = arg2;
5417
                                                   rhs = arg3;
5418
                                                   cond = arg4;
5419
                                                   delay = arg5
5420
                                                 })))))))
5421
            | _::xs -> loop xs _state  in
5422
          loop xs
5423
            ((Result.Ok false), (Result.Ok NoName),
5424
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.lhs"),
5425
              (Result.Error "Vhdl_ast.vhdl_conditional_signal_t.rhs"),
5426
              (Result.Ok IsNull), (Result.Ok IsNull))
5427
      | _ -> Result.Error "Vhdl_ast.vhdl_conditional_signal_t")
5428
  [@ocaml.warning "-A"])
5429

    
5430
type vhdl_process_t =
5431
  {
5432
  id: vhdl_name_t [@default NoName];
5433
  declarations: vhdl_declarative_item_t list
5434
    [@key "PROCESS_DECLARATIVE_PART"][@default Some []];
5435
  active_sigs: vhdl_name_t list [@default []];
5436
  body: vhdl_sequential_stmt_t list
5437
    [@key "PROCESS_STATEMENT_PART"][@default []]}
5438

    
5439
let rec pp_vhdl_process_t :
5440
  Format.formatter -> vhdl_process_t -> Ppx_deriving_runtime.unit =
5441
  let __3 () = pp_vhdl_sequential_stmt_t
5442
  
5443
  and __2 () = pp_vhdl_name_t
5444
  
5445
  and __1 () = pp_vhdl_declarative_item_t
5446
  
5447
  and __0 () = pp_vhdl_name_t
5448
   in
5449
  ((let open! Ppx_deriving_runtime in
5450
      fun fmt  ->
5451
        fun x  ->
5452
          Format.fprintf fmt "@[<v 2>";
5453
          (match x.id with
5454
          | NoName -> Format.fprintf fmt "";
5455
          | _ -> 
5456
              ((__0 ()) fmt) x.id;
5457
              Format.fprintf fmt ": ");
5458
          Format.fprintf fmt "process ";
5459
          (match x.active_sigs with
5460
          | [] -> Format.fprintf fmt "";
5461
          | _ -> Format.fprintf fmt "(";
5462
                 ((fun x  ->
5463
                    ignore
5464
                      (List.fold_left
5465
                         (fun sep  ->
5466
                            fun x  ->
5467
                              if sep then Format.fprintf fmt ",";
5468
                              ((__2 ()) fmt) x;
5469
                              true) false x))) x.active_sigs;
5470
                 Format.fprintf fmt ")");
5471
          Format.fprintf fmt " is@;";
5472
          ((fun x  ->
5473
            ignore
5474
            (List.fold_left
5475
              (fun sep  ->
5476
                fun x  ->
5477
                  if sep then Format.fprintf fmt "@;";
5478
                    ((__1 ()) fmt) x;
5479
                    Format.fprintf fmt ";";
5480
                    true) false x))) x.declarations;
5481
          Format.fprintf fmt "@]@;@[<v 2>begin@;";
5482
          ((fun x  ->
5483
               ignore
5484
                 (List.fold_left
5485
                    (fun sep  ->
5486
                       fun x  ->
5487
                         if sep then Format.fprintf fmt "@;";
5488
                         ((__3 ()) fmt) x;
5489
                         Format.fprintf fmt ";";
5490
                         true) false x);)) x.body;
5491 </