-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombinational.act
36 lines (33 loc) · 1014 Bytes
/
combinational.act
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
35
36
import "globals.act";
import "channel.act";
defproc add(bool a, b; bool cin; bool s, cout)
{
bool _a, _b, _cin;
prs {
[unstab=1] a =>_a-
[unstab=1] b =>_b-
[unstab=1] cin =>_cin-
[unstab=1] (~a & ~b & ~_cin) | (~a & ~_b & ~cin) | (~_a & ~_b & ~_cin) | (~_a & ~b & ~cin) -> s+
(_a & b & cin) | (_a & _b & _cin) | (a & _b & cin) | (a & b & _cin) -> s-
[unstab=1] (~_a & ~_b) | (~_a & ~b & ~_cin) | (~a & ~_b & ~_cin) -> cout+
(_a & _b) | (_a & b & _cin) | (a & _b & _cin) -> cout-
}
}
/* MSB = array[7] .. array[0] = LSB */
defproc add8(bool a[8], b[8]; bool cin; bool out[8], cout)
{
add x[8];
(; i : 8 : x[i].a = a[i]; x[i].b = b[i]; x[i].s = out[i]; )
x[0].cin = cin;
x[7].cout = cout;
(; i : 1..7 : x[i].cin = x[i-1].cout; )
}
/* MSB = array[11] .. array[0] = LSB */
defproc add12(bool a[12], b[12]; bool cin; bool out[12], cout)
{
add x[12];
(; i : 12 : x[i].a = a[i]; x[i].b = b[i]; x[i].s = out[i]; )
x[0].cin = cin;
x[11].cout = cout;
(; i : 1..11 : x[i].cin = x[i-1].cout; )
}