Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / tools / importer / mini_vhdl_check.ml @ a33a345a

History | View | Annotate | Download (2.11 KB)

1
open Vhdl_ast
2
open Mini_vhdl_ast
3
open Vhdl_2_mini_vhdl_map
4

    
5
(*
6
type db_tuple_t =
7
  {
8
    mutable entity: vhdl_entity_t;
9
    mutable architecture: vhdl_architecture_t;
10
    mutable architecture_signals: mini_vhdl_declaration_t list;
11
    mutable architecture_ports: vhdl_port_t list;
12
    mutable architecture_generics: vhdl_port_t list;
13
    mutable assigned_names: vhdl_name_t list;
14
    mutable contexts: vhdl_load_t list;
15
  }
16
*)
17

    
18
let mini_vhdl_declaration_t_names decl=
19
  match decl with
20
  | SigDecl { names; typ; init_val } -> names
21
  | _ -> []
22

    
23
let check_mini_vhdl db to_string_name =
24
  let disp : db_tuple_t -> unit=
25
    fun {entity; architecture; architecture_signals; architecture_ports; architecture_generics; assigned_names; contexts} ->
26
      Printf.printf "Architecture: %s | " (to_string_name architecture.name);
27
      Printf.printf "Entity: %s\n" (to_string_name entity.name);
28
      let sigs_names = List.flatten (List.map mini_vhdl_declaration_t_names architecture_signals) in
29
      let get_names : vhdl_port_t -> vhdl_name_t list= fun x -> x.names in
30
      let rec get_ports: vhdl_port_t list -> vhdl_port_mode_t -> vhdl_port_t list= 
31
        fun l -> fun m -> match l with 
32
        | [] -> [] 
33
        | hd::tl -> if hd.mode = m then hd::(get_ports tl m) else get_ports tl m in
34
      let in_ports_names = List.flatten (List.map get_names (get_ports architecture_ports InPort)) in
35
      let out_ports_names = List.flatten (List.map get_names (get_ports architecture_ports OutPort)) in
36
      let inout_ports_names = List.flatten (List.map get_names (get_ports architecture_ports InoutPort)) in
37
      let generics_names = List.flatten (List.map get_names architecture_generics) in
38
      let filter_display s l = match l with
39
      | [] -> ()
40
      | _ -> Printf.printf "\t%s: %s\n" s (String.concat ", " (List.map to_string_name l)) in
41
      filter_display "Signals" sigs_names;
42
      filter_display "In ports" in_ports_names;
43
      filter_display "InOut ports" inout_ports_names;
44
      filter_display "Out ports" out_ports_names;
45
      filter_display "Generics" generics_names;
46
      filter_display "Assigned names" assigned_names in
47
  List.iter disp db