Project

General

Profile

Download (252 KB) Statistics
| Branch: | Tag: | Revision:
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 ();
254
                        ((__3 ()) fmt) x;
255
                        Format.fprintf fmt ";@;";
256
                        true) false x);
257
              Format.fprintf fmt "@]end record") a0;
258
        | Enumerated a0 ->
259
            (Format.fprintf fmt "(";
260
            ((fun x  ->
261
              ignore
262
              (List.fold_left
263
                (fun sep  ->
264
                  fun x  ->
265
                    if sep then Format.fprintf fmt ",@ ";
266
                      ((__4 ()) fmt) x;
267
                    true) false x))) a0;
268
             Format.fprintf fmt ")");
269
        | Void  -> Format.pp_print_string fmt "")
270
    [@ocaml.warning "-A"])
271

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

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

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

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

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

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

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

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

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

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

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

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

    
592
and show_vhdl_expr_t : vhdl_expr_t -> Ppx_deriving_runtime.string =
593
  fun x  -> Format.asprintf "%a" pp_vhdl_expr_t x
594

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

    
679
and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string =
680
  fun x  -> Format.asprintf "%a" pp_vhdl_name_t x
681

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

    
733
and show_vhdl_assoc_element_t :
734
  vhdl_assoc_element_t -> Ppx_deriving_runtime.string =
735
  fun x  -> Format.asprintf "%a" pp_vhdl_assoc_element_t x
736

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

    
761
and show_vhdl_element_assoc_t :
762
  vhdl_element_assoc_t -> Ppx_deriving_runtime.string =
763
  fun x  -> Format.asprintf "%a" pp_vhdl_element_assoc_t x
764

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

    
786
and show_vhdl_array_attributes_t :
787
  vhdl_array_attributes_t -> Ppx_deriving_runtime.string =
788
  fun x  -> Format.asprintf "%a" pp_vhdl_array_attributes_t x
789

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

    
804
and show_vhdl_signal_attributes_t :
805
  vhdl_signal_attributes_t -> Ppx_deriving_runtime.string =
806
  fun x  -> Format.asprintf "%a" pp_vhdl_signal_attributes_t x
807

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

    
822
and show_vhdl_string_attributes_t :
823
  vhdl_string_attributes_t -> Ppx_deriving_runtime.string =
824
  fun x  -> Format.asprintf "%a" pp_vhdl_string_attributes_t x
825

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

    
846
and show_vhdl_suffix_selection_t :
847
  vhdl_suffix_selection_t -> Ppx_deriving_runtime.string =
848
  fun x  -> Format.asprintf "%a" pp_vhdl_suffix_selection_t x
849

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2394
type 'basetype vhdl_type_attributes_t =
2395
  | TAttNoArg of {
2396
  id: string } 
2397
  | TAttIntArg of {
2398
  id: string ;
2399
  arg: int } 
2400
  | TAttValArg of {
2401
  id: string ;
2402
  arg: 'basetype } 
2403
  | TAttStringArg of {
2404
  id: string ;
2405
  arg: string } 
2406

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

    
2452
and show_vhdl_type_attributes_t  =
2453
  fun poly_basetype  ->
2454
    fun x  ->
2455
      Format.asprintf "%a" (pp_vhdl_type_attributes_t poly_basetype) x
2456

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

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

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

    
2658
let rec pp_vhdl_parameter_t :
2659
  Format.formatter -> vhdl_parameter_t -> Ppx_deriving_runtime.unit =
2660
  let __2 () = pp_vhdl_cst_val_t
2661
  
2662
  and __1 () = pp_vhdl_subtype_indication_t
2663
  
2664
  and __0 () = pp_vhdl_name_t
2665
   in
2666
  ((let open! Ppx_deriving_runtime in
2667
      fun fmt  ->
2668
        fun x  ->
2669
          ((fun x  ->
2670
             ignore
2671
               (List.fold_left
2672
                 (fun sep  ->
2673
                   fun x  ->
2674
                     if sep then Format.fprintf fmt ", ";
2675
                       ((__0 ()) fmt) x;
2676
                       true) false x))) x.names;
2677
          Format.fprintf fmt ": ";
2678
          ((fun x  ->
2679
             ignore
2680
               (List.fold_left
2681
                 (fun sep  ->
2682
                   fun x  ->
2683
                     if sep then Format.fprintf fmt "";
2684
                       Format.fprintf fmt "%s " x;
2685
                       true) false x))) x.mode;
2686
          ((__1 ()) fmt) x.typ;
2687
          (match x.init_val with
2688
           | None  -> Format.pp_print_string fmt ""
2689
           | Some x ->
2690
                 (Format.pp_print_string fmt " := ";
2691
                 ((__2 ()) fmt) x));)
2692
    [@ocaml.warning "-A"])
2693

    
2694
and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string =
2695
  fun x  -> Format.asprintf "%a" pp_vhdl_parameter_t x
2696

    
2697
let rec (vhdl_parameter_t_to_yojson : vhdl_parameter_t -> Yojson.Safe.json) =
2698
  ((let open! Ppx_deriving_yojson_runtime in
2699
      fun x  ->
2700
        let fields = []  in
2701
        let fields =
2702
          if x.init_val = None
2703
          then fields
2704
          else
2705
            ("init_val",
2706
              (((function
2707
                 | None  -> `Null
2708
                 | Some x -> ((fun x  -> vhdl_cst_val_t_to_yojson x)) x))
2709
                 x.init_val))
2710
            :: fields
2711
           in
2712
        let fields =
2713
          ("typ", ((fun x  -> vhdl_subtype_indication_t_to_yojson x) x.typ))
2714
          :: fields  in
2715
        let fields =
2716
          if x.mode = []
2717
          then fields
2718
          else
2719
            ("mode",
2720
              (((fun x  ->
2721
                   `List
2722
                     (List.map
2723
                        (fun (x : Ppx_deriving_runtime.string)  -> `String x)
2724
                        x))) x.mode))
2725
            :: fields
2726
           in
2727
        let fields =
2728
          ("names",
2729
            ((fun x  ->
2730
                `List (List.map (fun x  -> vhdl_name_t_to_yojson x) x))
2731
               x.names))
2732
          :: fields  in
2733
        `Assoc fields)
2734
  [@ocaml.warning "-A"])
2735

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

    
2802
type vhdl_subprogram_spec_t =
2803
  {
2804
  name: string [@default ""];
2805
  subprogram_type: string [@default ""];
2806
  typeMark: vhdl_name_t [@default NoName];
2807
  parameters: vhdl_parameter_t list ;
2808
  isPure: bool [@default false]}
2809

    
2810
let rec pp_vhdl_subprogram_spec_t :
2811
  Format.formatter -> vhdl_subprogram_spec_t -> Ppx_deriving_runtime.unit =
2812
  let __1 () = pp_vhdl_parameter_t
2813
  
2814
  and __0 () = pp_vhdl_name_t
2815
   in
2816
  ((let open! Ppx_deriving_runtime in
2817
      fun fmt  ->
2818
        fun x  ->
2819
          (match x.subprogram_type with
2820
          | "function" -> 
2821
              if (x.isPure) then
2822
                Format.fprintf fmt "pure %s %s" x.subprogram_type x.name
2823
              else
2824
                Format.fprintf fmt "impure %s %s" x.subprogram_type x.name
2825
          | "procedure" ->
2826
              Format.fprintf fmt "%s %s" x.subprogram_type x.name);
2827
          (match x.parameters with
2828
          | [] -> Format.fprintf fmt "";
2829
          | _ -> 
2830
            Format.fprintf fmt "(@[";
2831
            ((fun x  ->
2832
                ignore
2833
                  (List.fold_left
2834
                     (fun sep  ->
2835
                        fun x  ->
2836
                          if sep then Format.fprintf fmt ";@ ";
2837
                          ((__1 ()) fmt) x;
2838
                          true) false x))) x.parameters;
2839
            Format.fprintf fmt "@])");
2840
          (match x.typeMark with
2841
          | NoName -> Format.fprintf fmt "";
2842
          | _ -> 
2843
              Format.fprintf fmt "return ";
2844
              ((__0 ()) fmt) x.typeMark))
2845
   [@ocaml.warning "-A"])
2846

    
2847
and show_vhdl_subprogram_spec_t :
2848
  vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string =
2849
  fun x  -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x
2850

    
2851
let rec (vhdl_subprogram_spec_t_to_yojson :
2852
          vhdl_subprogram_spec_t -> Yojson.Safe.json)
2853
  =
2854
  ((let open! Ppx_deriving_yojson_runtime in
2855
      fun x  ->
2856
        let fields = []  in
2857
        let fields =
2858
          if x.isPure = false
2859
          then fields
2860
          else
2861
            ("isPure",
2862
              (((fun (x : Ppx_deriving_runtime.bool)  -> `Bool x)) x.isPure))
2863
            :: fields
2864
           in
2865
        let fields =
2866
          if x.parameters = []
2867
          then fields
2868
          else
2869
            ("parameters",
2870
              (((fun x  ->
2871
                   `List
2872
                     (List.map (fun x  -> vhdl_parameter_t_to_yojson x) x)))
2873
                 x.parameters))
2874
            :: fields
2875
           in
2876
        let fields =
2877
          if x.typeMark = NoName
2878
          then fields
2879
          else
2880
            ("typeMark", (((fun x  -> vhdl_name_t_to_yojson x)) x.typeMark))
2881
            :: fields
2882
           in
2883
        let fields =
2884
          if x.subprogram_type = ""
2885
          then fields
2886
          else
2887
            ("subprogram_type",
2888
              (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
2889
                 x.subprogram_type))
2890
            :: fields
2891
           in
2892
        let fields =
2893
          if x.name = ""
2894
          then fields
2895
          else
2896
            ("name",
2897
              (((fun (x : Ppx_deriving_runtime.string)  -> `String x)) x.name))
2898
            :: fields
2899
           in
2900
        `Assoc fields)
2901
  [@ocaml.warning "-A"])
2902

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

    
2977
let arith_funs = ["+"; "-"; "*"; "/"; "mod"; "rem"; "abs"; "**"; "&"] 
2978
let bool_funs = ["and"; "or"; "nand"; "nor"; "xor"; "not"] 
2979
let rel_funs =
2980
  ["<";
2981
  ">";
2982
  "<=";
2983
  ">=";
2984
  "/=";
2985
  "=";
2986
  "?=";
2987
  "?/=";
2988
  "?<";
2989
  "?<=";
2990
  "?>";
2991
  "?>=";
2992
  "??"] 
2993
let shift_funs = ["sll"; "srl"; "sla"; "sra"; "rol"; "ror"] 
2994

    
2995
type vhdl_waveform_element_t =
2996
  {
2997
  value: vhdl_expr_t option [@default None];
2998
  delay: vhdl_expr_t option [@default None]}[@@deriving
2999
                                              ((show { with_path = false }),
3000
                                                (yojson { strict = false }))]
3001

    
3002
let rec pp_vhdl_waveform_element_t :
3003
  Format.formatter -> vhdl_waveform_element_t -> Ppx_deriving_runtime.unit =
3004
  let __1 () = pp_vhdl_expr_t
3005
  
3006
  and __0 () = pp_vhdl_expr_t
3007
   in
3008
  ((let open! Ppx_deriving_runtime in
3009
      fun fmt  ->
3010
        fun x  ->
3011
          (match x.value with
3012
          | None -> Format.fprintf fmt "";
3013
          | Some IsNull -> Format.fprintf fmt "null";
3014
          | Some v -> ((__0 ()) fmt) v);
3015
          (match x.delay with
3016
          | None -> Format.fprintf fmt "";
3017
          | Some v -> 
3018
              Format.fprintf fmt " after ";
3019
              ((__1 ()) fmt) v))
3020
    [@ocaml.warning "-A"])
3021

    
3022
and show_vhdl_waveform_element_t :
3023
  vhdl_waveform_element_t -> Ppx_deriving_runtime.string =
3024
  fun x  -> Format.asprintf "%a" pp_vhdl_waveform_element_t x
3025

    
3026
let rec (vhdl_waveform_element_t_to_yojson :
3027
          vhdl_waveform_element_t -> Yojson.Safe.json)
3028
  =
3029
  ((let open! Ppx_deriving_yojson_runtime in
3030
      fun x  ->
3031
        let fields = []  in
3032
        let fields =
3033
          if x.delay = None
3034
          then fields
3035
          else
3036
            ("delay",
3037
              (((function
3038
                 | None  -> `Null
3039
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
3040
                 x.delay))
3041
            :: fields
3042
           in
3043
        let fields =
3044
          if x.value = None
3045
          then fields
3046
          else
3047
            ("value",
3048
              (((function
3049
                 | None  -> `Null
3050
                 | Some x -> ((fun x  -> vhdl_expr_t_to_yojson x)) x))
3051
                 x.value))
3052
            :: fields
3053
           in
3054
        `Assoc fields)
3055
  [@ocaml.warning "-A"])
3056

    
3057
and (vhdl_waveform_element_t_of_yojson :
3058
      Yojson.Safe.json ->
3059
        vhdl_waveform_element_t Ppx_deriving_yojson_runtime.error_or)
3060
  =
3061
  ((let open! Ppx_deriving_yojson_runtime in
3062
      function
3063
      | `Assoc xs ->
3064
          let rec loop xs ((arg0,arg1) as _state) =
3065
            match xs with
3066
            | ("value",x)::xs ->
3067
                loop xs
3068
                  (((function
3069
                     | `Null -> Result.Ok None
3070
                     | x ->
3071
                         ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
3072
                           ((fun x  -> Result.Ok (Some x)))) x), arg1)
3073
            | ("delay",x)::xs ->
3074
                loop xs
3075
                  (arg0,
3076
                    ((function
3077
                      | `Null -> Result.Ok None
3078
                      | x ->
3079
                          ((fun x  -> vhdl_expr_t_of_yojson x) x) >>=
3080
                            ((fun x  -> Result.Ok (Some x)))) x))
3081
            | [] ->
3082
                arg1 >>=
3083
                  ((fun arg1  ->
3084
                      arg0 >>=
3085
                        (fun arg0  ->
3086
                           Result.Ok { value = arg0; delay = arg1 })))
3087
            | _::xs -> loop xs _state  in
3088
          loop xs ((Result.Ok None), (Result.Ok None))
3089
      | _ -> Result.Error "Vhdl_ast.vhdl_waveform_element_t")
3090
  [@ocaml.warning "-A"])
3091

    
3092
type vhdl_sequential_stmt_t =
3093
  | VarAssign of
3094
  {
3095
  label: vhdl_name_t [@default NoName];
3096
  lhs: vhdl_name_t ;
3097
  rhs: vhdl_expr_t } [@name "VARIABLE_ASSIGNMENT_STATEMENT"]
3098
  | SigSeqAssign of
3099
  {
3100
  label: vhdl_name_t [@default NoName];
3101
  lhs: vhdl_name_t ;
3102
  rhs: vhdl_waveform_element_t list } [@name "SIGNAL_ASSIGNMENT_STATEMENT"]
3103
  | If of
3104
  {
3105
  label: vhdl_name_t [@default NoName];
3106
  if_cases: vhdl_if_case_t list ;
3107
  default: vhdl_sequential_stmt_t list [@default []]} [@name "IF_STATEMENT"]
3108
  | Case of
3109
  {
3110
  label: vhdl_name_t [@default NoName];
3111
  guard: vhdl_expr_t ;
3112
  branches: vhdl_case_item_t list } [@name "CASE_STATEMENT_TREE"]
3113
  | Exit of
3114
  {
3115
  label: vhdl_name_t [@default NoName];
3116
  loop_label: string option [@default Some ""];
3117
  condition: vhdl_expr_t option [@default Some IsNull]}
3118
  [@name "EXIT_STATEMENT"]
3119
  | Assert of
3120
  {
3121
  label: vhdl_name_t [@default NoName];
3122
  cond: vhdl_expr_t ;
3123
  report: vhdl_expr_t [@default IsNull];
3124
  severity: vhdl_expr_t [@default IsNull]} [@name "ASSERTION_STATEMENT"]
3125
  | ProcedureCall of
3126
  {
3127
  label: vhdl_name_t [@default NoName];
3128
  name: vhdl_name_t ;
3129
  assocs: vhdl_assoc_element_t list } [@name "PROCEDURE_CALL_STATEMENT"]
3130
  | Wait [@name "WAIT_STATEMENT"]
3131
  | Null of {
3132
  label: vhdl_name_t [@default NoName]} [@name "NULL_STATEMENT"]
3133
  | Return of
3134
  {
3135
  label: vhdl_name_t option [@default None];
3136
  expr: vhdl_expr_t option [@default None]} [@name "RETURN_STATEMENT"]
3137
and vhdl_if_case_t =
3138
  {
3139
  if_cond: vhdl_expr_t ;
3140
  if_block: vhdl_sequential_stmt_t list }
3141
and vhdl_case_item_t =
3142
  {
3143
  when_cond: vhdl_expr_t list ;
3144
  when_stmt: vhdl_sequential_stmt_t list }
3145

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