Revision a16d29bf
Added by Arnaud Dieumegard almost 5 years ago
src/backends/VHDL/mini_vhdl_utils.ml | ||
---|---|---|
1 |
open Vhdl_ast |
|
2 |
open Mini_vhdl_ast |
|
3 |
|
|
4 |
let mini_vhdl_declaration_t_names decl= |
|
5 |
match decl with |
|
6 |
| SigDecl { names; typ; init_val } -> names |
|
7 |
| _ -> [] |
|
8 |
|
|
9 |
let rec get_ports: vhdl_port_t list -> vhdl_port_mode_t -> vhdl_port_t list= |
|
10 |
fun l -> fun m -> match l with |
|
11 |
| [] -> [] |
|
12 |
| hd::tl -> if hd.mode = m then hd::(get_ports tl m) else get_ports tl m |
|
13 |
|
|
14 |
let get_names : vhdl_port_t -> vhdl_name_t list= fun x -> x.names |
|
15 |
|
|
16 |
let rec duplicates l1= |
|
17 |
match l1 with |
|
18 |
| [] -> [] |
|
19 |
| hd::tl -> if List.mem hd tl then hd::(duplicates (List.filter (fun x -> List.mem x tl) tl)) else duplicates tl |
|
20 |
|
|
21 |
let equals n1 n2= |
|
22 |
match (n1,n2) with |
|
23 |
| (Simple a, Identifier b) -> a = b |
|
24 |
| (Identifier a, Simple b) -> a = b |
|
25 |
| (Simple a, Selected ((Simple b)::[])) -> a = b |
|
26 |
| (Simple a, Selected ((Identifier b)::[])) -> a = b |
|
27 |
| (Identifier a, Selected ((Simple b)::[])) -> a = b |
|
28 |
| (Identifier a, Selected ((Identifier b)::[])) -> a = b |
|
29 |
| (Selected ((Simple b)::[]), Simple a) -> a = b |
|
30 |
| (Selected ((Identifier b)::[]), Simple a) -> a = b |
|
31 |
| (Selected ((Simple b)::[]), Identifier a) -> a = b |
|
32 |
| (Selected ((Identifier b)::[]), Identifier a) -> a = b |
|
33 |
| (a,b) -> a = b |
|
34 |
|
|
35 |
let find_vhdl_name_t l x = |
|
36 |
let rec find_vhdl_name_t_aux x l index = |
|
37 |
match l with |
|
38 |
| [] -> -1 |
|
39 |
| hd::tl -> if (equals x hd) then index else find_vhdl_name_t_aux x tl (index+1) in |
|
40 |
find_vhdl_name_t_aux x l 0 |
|
41 |
|
|
42 |
let rec vhdl_name_t_mem x l = |
|
43 |
match l with |
|
44 |
| [] -> false |
|
45 |
| hd::tl -> equals x hd || vhdl_name_t_mem x tl |
|
46 |
|
|
47 |
let rec diff l1 l2 to_string_name = |
|
48 |
match l1 with |
|
49 |
| [] -> [] |
|
50 |
| hd::tl -> |
|
51 |
if vhdl_name_t_mem hd l2 then diff tl l2 to_string_name else hd::(diff tl l2 to_string_name) |
|
52 |
|
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
Communalisation of mini-vhdl structure utils