-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sus
More file actions
35 lines (26 loc) · 845 Bytes
/
test.sus
File metadata and controls
35 lines (26 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module fp_test {
clock clk
input float a
input float b
input float c
output float d
fp32_add add
fp32_mul mul
float tmp = add(a, b)
d = mul(tmp, c)
}
module ComputeRoots {
action compute_roots'0 : float a'0, float b'0, float c'0 {
trigger roots_valid : float root_1, float root_2
float half_b = fp32_mul_pow2(b, -1)
float discriminant = fp32_sub(fp32_mul(half_b, half_b), fp32_mul(a, c))
float discr_sqrt = fp32_sqrt(discriminant)
float a_recip = fp32_rcp(a)
float half_b_neg = fp32_neg(half_b)
when fp32_ge(discriminant, 0.0) {
float r1 = fp32_mul(fp32_add(half_b_neg, discr_sqrt), a_recip)
float r2 = fp32_mul(fp32_sub(half_b_neg, discr_sqrt), a_recip)
roots_valid(r1, r2)
}
}
}