23
23
24
24
function infer_clocks! (ci:: ClockInference )
25
25
@unpack ts, eq_domain, var_domain, inferred = ci
26
- @unpack graph = ts. structure
26
+ @unpack var_to_diff, graph = ts. structure
27
27
fullvars = get_fullvars (ts)
28
28
isempty (inferred) && return ci
29
29
# TODO : add a graph type to do this lazily
@@ -37,6 +37,11 @@ function infer_clocks!(ci::ClockInference)
37
37
end
38
38
end
39
39
end
40
+ for v in vertices (var_to_diff)
41
+ if (v′ = var_to_diff[v]) != = nothing
42
+ add_edge! (var_graph, v, v′)
43
+ end
44
+ end
40
45
cc = connected_components (var_graph)
41
46
for c′ in cc
42
47
c = BitSet (c′)
@@ -75,6 +80,11 @@ function resize_or_push!(v, val, idx)
75
80
push! (v[idx], val)
76
81
end
77
82
83
+ function is_time_domain_conversion (v)
84
+ istree (v) && (o = operation (v)) isa Operator &&
85
+ input_timedomain (o) != output_timedomain (o)
86
+ end
87
+
78
88
function split_system (ci:: ClockInference{S} ) where {S}
79
89
@unpack ts, eq_domain, var_domain, inferred = ci
80
90
fullvars = get_fullvars (ts)
@@ -113,8 +123,7 @@ function split_system(ci::ClockInference{S}) where {S}
113
123
@assert cid!= = 0 " Internal error! Variable $(fullvars[i]) doesn't have a inferred time domain."
114
124
var_to_cid[i] = cid
115
125
v = fullvars[i]
116
- if istree (v) && (o = operation (v)) isa Operator &&
117
- input_timedomain (o) != output_timedomain (o)
126
+ if is_time_domain_conversion (v)
118
127
push! (input_idxs[cid], i)
119
128
push! (inputs[cid], fullvars[i])
120
129
end
0 commit comments