clock unification now works if when is applied to a boolean comparison

This commit is contained in:
Antoine Grimod 2023-01-09 22:54:08 +01:00
parent 2da1fac66f
commit ad4f5e7962

View File

@ -1121,14 +1121,15 @@ let clock_unification_pass verbose debug ast =
| EVar([TBool], var) -> acc, e | EVar([TBool], var) -> acc, e
| EConst([TBool], cons) -> acc, e | EConst([TBool], cons) -> acc, e
| EMonOp([TBool], MOp_not, e) -> count_not e (acc + 1) | EMonOp([TBool], MOp_not, e) -> count_not e (acc + 1)
| _ -> raise (PassExn "verify_when failure") | EComp(_, _, e1, e2) -> acc, e
| _ -> raise (PassExn "count_not failure")
in in
let verify_when e1 e2 = let verify_when e1 e2 =
let n1, var1 = count_not e1 0 let n1, var1 = count_not e1 0
and n2, var2 = count_not e2 0 in and n2, var2 = count_not e2 0 in
if n1 mod 2 <> n2 mod 2 || var1 <> var2 then if n1 mod 2 <> n2 mod 2 || var1 <> var2 then
raise (PassExn "clock unification failure") raise (PassExn "verify_when failure")
in in
let get_var_name var = match var with let get_var_name var = match var with
@ -1243,14 +1244,9 @@ let clock_unification_pass verbose debug ast =
snd n.n_local_vars); (* Initializing local variables to Unknown clock *) snd n.n_local_vars); (* Initializing local variables to Unknown clock *)
List.iter (fun v -> Hashtbl.replace known_clocks v Base) ( List.iter (fun v -> Hashtbl.replace known_clocks v Base) (
snd n.n_outputs); (* Initializing outputs to base clock *) snd n.n_outputs); (* Initializing outputs to base clock *)
try
begin
iter_til_stable n.n_equations; iter_til_stable n.n_equations;
(* catch potential errors and test for unification *) (* catch potential errors and test for unification *)
check_unification n; check_unification n;
Some n Some n
end end
with
| PassExn err -> (verbose err; None)
end
in node_pass compute_clock_node ast in node_pass compute_clock_node ast