Project

General

Profile

Download (4.93 KB) Statistics
| Branch: | Tag: | Revision:
1
open Vhdl_ast
2
open Vhdl_ast_pp
3
open Mini_vhdl_ast
4
open Vhdl_2_mini_vhdl_map
5
open Lustre_types
6
open Utils
7

    
8
let _ = fun (_ : mini_vhdl_component_instantiation_t)  -> () 
9
let _ = fun (_ : mini_vhdl_concurrent_stmt_t)  -> () 
10
let _ = fun (_ : mini_vhdl_component_t)  -> () 
11
let _ = fun (_ : mini_vhdl_design_file_t)  -> () 
12

    
13
class virtual mini_vhdl_to_lustre_map =
14
  object (self)
15
    inherit vhdl_2_mini_vhdl_map
16
    method virtual  list : 'a . ('a -> 'a) -> 'a list -> 'a list
17
    method virtual  mini_vhdl_component_instantiation_t : 
18
      mini_vhdl_component_instantiation_t -> statement
19
    method virtual  mini_vhdl_concurrent_stmt_t : 
20
      mini_vhdl_concurrent_stmt_t -> statement
21
    method virtual  mini_vhdl_component_t : 
22
      mini_vhdl_component_t -> top_decl_desc
23
    method virtual  mini_vhdl_design_file_t : 
24
      mini_vhdl_design_file_t -> program
25

    
26
    method mini_vhdl_declaration_t : mini_vhdl_declaration_t -> mini_vhdl_declaration_t=
27
      fun x -> x
28

    
29
    method mini_vhdl_process_t : mini_vhdl_process_t -> mini_vhdl_process_t=
30
      fun x -> x
31

    
32
    method mini_vhdl_component_instantiation_t :
33
      mini_vhdl_component_instantiation_t -> statement=
34
      fun { name; archi; entity; generic_map; port_map }  ->
35
        let name = self#vhdl_name_t name  in
36
        let archi = archi  in
37
        let entity = entity  in
38
        let generic_map = self#list self#vhdl_assoc_element_t generic_map  in
39
        let port_map = self#list self#vhdl_assoc_element_t port_map  in
40
        Eq {eq_lhs=[show_vhdl_name_t name];
41
            eq_rhs={expr_tag=Utils.new_tag (); expr_desc=Expr_ident "toto";
42
                    expr_type={tdesc=Tconst "cst"; tid=0}; expr_clock={cdesc=Cvar;cscoped=false;cid=0};
43
                    expr_delay={ddesc=Dundef;did=0}; expr_annot=None; expr_loc=Location.dummy_loc};
44
            eq_loc=Location.dummy_loc}
45

    
46
    method mini_vhdl_concurrent_stmt_t :
47
      mini_vhdl_concurrent_stmt_t -> statement=
48
      fun x  ->
49
        match x with
50
        | Process a -> let a = self#mini_vhdl_process_t a  in
51
            Eq {eq_lhs=["Process"];
52
                eq_rhs={expr_tag=Utils.new_tag (); expr_desc=Expr_ident "toto";
53
                        expr_type={tdesc=Tconst "cst"; tid=0}; expr_clock={cdesc=Cvar;cscoped=false;cid=0};
54
                        expr_delay={ddesc=Dundef;did=0}; expr_annot=None; expr_loc=Location.dummy_loc};
55
                eq_loc=Location.dummy_loc}
56
        | ComponentInst a ->
57
            let a = self#mini_vhdl_component_instantiation_t a  in a
58

    
59
    method mini_vhdl_package_t : mini_vhdl_package_t -> top_decl_desc=
60
      fun { name; shared_defs; shared_decls; shared_uses }  ->
61
        let name = self#vhdl_name_t name  in
62
        let shared_defs = self#list self#vhdl_definition_t shared_defs  in
63
        let shared_decls = List.map self#mini_vhdl_declaration_t shared_decls  in
64
        let shared_uses = self#list self#vhdl_load_t shared_uses in
65
        let node_id = show_vhdl_name_t name in
66
        let node_type = Types.new_var () in
67
        let node_clock = Clocks.new_ck Cvar false in
68
        Node { node_id; node_type; node_clock; 
69
               node_inputs=[]; node_outputs = []; node_locals = [];
70
               node_gencalls = []; node_checks = []; node_asserts = [];
71
               node_stmts = []; node_dec_stateless = false; node_stateless = None; 
72
               node_spec = None; node_annot = [] }
73

    
74
    method mini_vhdl_component_t :
75
      mini_vhdl_component_t -> top_decl_desc=
76
      fun
77
        { names; generics; ports; contexts; declarations; definitions; body }
78
         ->
79
        let names = self#list self#vhdl_name_t names  in
80
        let generics = self#list self#vhdl_port_t generics  in
81
        let ports = self#list self#vhdl_port_t ports  in
82
        let contexts = self#list self#vhdl_load_t contexts  in
83
        let declarations = List.map self#mini_vhdl_declaration_t declarations  in
84
        let definitions = self#list self#vhdl_definition_t definitions  in
85
        let body = List.map self#mini_vhdl_concurrent_stmt_t body  in
86
        let node_id = String.concat "__" (List.map show_vhdl_name_t names) in
87
        let node_type = Types.new_var () in
88
        let node_clock = Clocks.new_ck Cvar false in
89
        Node { node_id; node_type; node_clock; 
90
               node_inputs=[]; node_outputs = []; node_locals = [];
91
               node_gencalls = []; node_checks = []; node_asserts = [];
92
               node_stmts = body; node_dec_stateless = false; node_stateless = None; 
93
               node_spec = None; node_annot = [] }
94

    
95
    method mini_vhdl_design_file_t :
96
      mini_vhdl_design_file_t -> program =
97
      fun { components; packages }  ->
98
        let components = List.map self#mini_vhdl_component_t components  in
99
        let packages = List.map self#mini_vhdl_package_t packages  in
100
        let desc x = { top_decl_desc = x; top_decl_owner = ""; top_decl_itf = false; top_decl_loc = Location.dummy_loc } in
101
        let desc1 = List.map desc components in
102
        let desc2 = List.map desc packages in
103
        desc1 @ desc2
104
  end
(3-3/3)