Project

General

Profile

« Previous | Next » 

Revision a16d29bf

Added by Arnaud Dieumegard about 6 years ago

Communalisation of mini-vhdl structure utils

View differences:

src/tools/importer/mini_vhdl_check.ml
1 1
open Vhdl_ast
2 2
open Mini_vhdl_ast
3 3
open Vhdl_2_mini_vhdl_map
4
open Mini_vhdl_utils
4 5

  
5 6
(*
6 7
type db_tuple_t =
......
29 30
  | [] -> ""
30 31
  | _ -> Printf.sprintf "%s [%s]\n" s (String.concat ", " (List.map to_string_name l))
31 32

  
32
(**
33
 * Helpers
34
 *)
35
let mini_vhdl_declaration_t_names decl=
36
  match decl with
37
  | SigDecl { names; typ; init_val } -> names
38
  | _ -> []
39

  
40
let rec get_ports: vhdl_port_t list -> vhdl_port_mode_t -> vhdl_port_t list= 
41
  fun l -> fun m -> match l with 
42
    | [] -> [] 
43
    | hd::tl -> if hd.mode = m then hd::(get_ports tl m) else get_ports tl m
44

  
45
let get_names : vhdl_port_t -> vhdl_name_t list= fun x -> x.names
46

  
47
let rec duplicates l1=
48
  match l1 with
49
  | [] -> []
50
  | hd::tl -> if List.mem hd tl then hd::(duplicates (List.filter (fun x -> List.mem x tl) tl)) else duplicates tl
51

  
52
let equals n1 n2=
53
  match (n1,n2) with
54
  | (Simple a, Identifier b) -> a = b
55
  | (Identifier a, Simple b) -> a = b
56
  | (Simple a, Selected ((Simple b)::[])) -> a = b
57
  | (Simple a, Selected ((Identifier b)::[])) -> a = b
58
  | (Identifier a, Selected ((Simple b)::[])) -> a = b
59
  | (Identifier a, Selected ((Identifier b)::[])) -> a = b
60
  | (Selected ((Simple b)::[]), Simple a) -> a = b
61
  | (Selected ((Identifier b)::[]), Simple a) -> a = b
62
  | (Selected ((Simple b)::[]), Identifier a) -> a = b
63
  | (Selected ((Identifier b)::[]), Identifier a) -> a = b
64
  | (a,b) -> a = b
65

  
66
let rec vhdl_name_t_mem x l =
67
  match l with
68
  | [] -> false
69
  | hd::tl -> equals x hd || vhdl_name_t_mem x tl
70

  
71
let rec diff l1 l2 to_string_name =
72
  match l1 with
73
  | [] -> []
74
  | hd::tl -> 
75
      if vhdl_name_t_mem hd l2 then diff tl l2 to_string_name else hd::(diff tl l2 to_string_name)
76

  
77 33
(**
78 34
 * Display
79 35
 *)

Also available in: Unified diff