Compare commits

...

2 Commits

Author SHA1 Message Date
Antoine Grimod
a5f8c720f4 extended when once again 2023-01-09 23:04:36 +01:00
Antoine Grimod
ad4f5e7962 clock unification now works if when is applied to a boolean comparison 2023-01-09 22:54:26 +01:00

View File

@ -1121,14 +1121,14 @@ 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") | _ -> acc, e
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 +1243,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