Project

General

Profile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2688
and show_vhdl_parameter_t : vhdl_parameter_t -> Ppx_deriving_runtime.string =
2689
  fun x  -> Format.asprintf "%a" pp_vhdl_parameter_t x
2690

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

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

    
2796
type vhdl_subprogram_spec_t =
2797
  {
2798
  name: string [@default ""];
2799
  subprogram_type: string [@default ""];
2800
  typeMark: vhdl_name_t [@default NoName];
2801
  parameters: vhdl_parameter_t list ;
2802
  isPure: bool [@default false]}
2803

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

    
2841
and show_vhdl_subprogram_spec_t :
2842
  vhdl_subprogram_spec_t -> Ppx_deriving_runtime.string =
2843
  fun x  -> Format.asprintf "%a" pp_vhdl_subprogram_spec_t x
2844

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

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

    
2971
let arith_funs = ["+"; "-"; "*"; "/"; "mod"; "rem"; "abs"; "**"; "&"] 
2972
let bool_funs = ["and"; "or"; "nand"; "nor"; "xor"; "not"] 
2973
let rel_funs =
2974
  ["<";
2975
  ">";
2976
  "<=";
2977
  ">=";
2978
  "/=";
2979
  "=";
2980
  "?=";
2981
  "?/=";
2982
  "?<";
2983
  "?<=";
2984
  "?>";
2985
  "?>=";
2986
  "??"] 
2987
let shift_funs = ["sll"; "srl"; "sla"; "sra"; "rol"; "ror"] 
2988

    
2989
type vhdl_waveform_element_t =
2990
  {
2991
  value: vhdl_expr_t option [@default None];
2992
  delay: vhdl_expr_t option [@default None]}[@@deriving
2993
                                              ((show { with_path = false }),
2994
                                                (yojson { strict = false }))]
2995

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

    
3016
and show_vhdl_waveform_element_t :
3017
  vhdl_waveform_element_t -> Ppx_deriving_runtime.string =
3018
  fun x  -> Format.asprintf "%a" pp_vhdl_waveform_element_t x
3019

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

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

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

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

    
3358
and show_vhdl_sequential_stmt_t :
3359
  vhdl_sequential_stmt_t -> Ppx_deriving_runtime.string =
3360
  fun x  -> Format.asprintf "%a" pp_vhdl_sequential_stmt_t x
3361

    
3362
and pp_vhdl_if_case_t :
3363
  Format.formatter -> vhdl_if_case_t -> Ppx_deriving_runtime.unit =
3364
  let __1 () = pp_vhdl_sequential_stmt_t
3365
  
3366
  and __0 () = pp_vhdl_expr_t
3367
   in
3368
  ((let open! Ppx_deriving_runtime in
3369
      fun fmt  ->