Skip to content

Commit f9f388e

Browse files
committed
change ordering of function definitions
1 parent 5b5e94b commit f9f388e

2 files changed

Lines changed: 46 additions & 46 deletions

File tree

gate.c

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,6 @@
44

55
typedef uint64_t cell;
66

7-
// human attempt, 54 gates
8-
cell conway_clayton(cell in[9]) {
9-
// pairs
10-
cell p00 = ~(in[0] | in[1]);
11-
cell p10 = ~(in[2] | in[3]);
12-
cell p20 = ~(in[5] | in[6]);
13-
cell p30 = ~(in[7] | in[8]);
14-
cell p01 = in[0] ^ in[1];
15-
cell p11 = in[2] ^ in[3];
16-
cell p21 = in[5] ^ in[6];
17-
cell p31 = in[7] ^ in[8];
18-
cell p02 = in[0] & in[1];
19-
cell p12 = in[2] & in[3];
20-
cell p22 = in[5] & in[6];
21-
cell p32 = in[7] & in[8];
22-
// halfs
23-
cell h00 = p00 & p10;
24-
cell h10 = p20 & p30;
25-
cell h01 = (p00 & p11) | (p10 & p01);
26-
cell h11 = (p20 & p31) | (p30 & p21);
27-
cell h03 = (p02 & p11) | (p12 & p01);
28-
cell h13 = (p22 & p31) | (p32 & p21);
29-
cell h02 = (p02 & p10) | (p00 & p12) | (p01 & p11);
30-
cell h12 = (p22 & p30) | (p20 & p32) | (p21 & p31);
31-
// neighbors
32-
cell n2 = (h01 & h11) | (h02 & h10) | (h00 & h12);
33-
cell n3 = (h03 & h10) | (h13 & h00) | (h02 & h11 ) | (h12 & h01);
34-
// rule
35-
cell out = n3 | (in[4] & n2);
36-
return out;
37-
}
38-
397
cell conway(cell in[9]) {
408
cell in_0 = in[0];
419
cell in_1 = in[1];
@@ -223,6 +191,38 @@ cell conway(cell in[9]) {
223191
return out;
224192
}
225193

194+
// human attempt, 54 gates
195+
cell conway_clayton(cell in[9]) {
196+
// pairs
197+
cell p00 = ~(in[0] | in[1]);
198+
cell p10 = ~(in[2] | in[3]);
199+
cell p20 = ~(in[5] | in[6]);
200+
cell p30 = ~(in[7] | in[8]);
201+
cell p01 = in[0] ^ in[1];
202+
cell p11 = in[2] ^ in[3];
203+
cell p21 = in[5] ^ in[6];
204+
cell p31 = in[7] ^ in[8];
205+
cell p02 = in[0] & in[1];
206+
cell p12 = in[2] & in[3];
207+
cell p22 = in[5] & in[6];
208+
cell p32 = in[7] & in[8];
209+
// halfs
210+
cell h00 = p00 & p10;
211+
cell h10 = p20 & p30;
212+
cell h01 = (p00 & p11) | (p10 & p01);
213+
cell h11 = (p20 & p31) | (p30 & p21);
214+
cell h03 = (p02 & p11) | (p12 & p01);
215+
cell h13 = (p22 & p31) | (p32 & p21);
216+
cell h02 = (p02 & p10) | (p00 & p12) | (p01 & p11);
217+
cell h12 = (p22 & p30) | (p20 & p32) | (p21 & p31);
218+
// neighbors
219+
cell n2 = (h01 & h11) | (h02 & h10) | (h00 & h12);
220+
cell n3 = (h03 & h10) | (h13 & h00) | (h02 & h11 ) | (h12 & h01);
221+
// rule
222+
cell out = n3 | (in[4] & n2);
223+
return out;
224+
}
225+
226226
typedef struct {
227227
cell* cells;
228228
size_t cells_len;

gate.c.template

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44

55
typedef uint64_t cell;
66

7+
cell conway(cell in[9]) {
8+
cell in_0 = in[0];
9+
cell in_1 = in[1];
10+
cell in_2 = in[2];
11+
cell in_3 = in[3];
12+
cell in_4 = in[4];
13+
cell in_5 = in[5];
14+
cell in_6 = in[6];
15+
cell in_7 = in[7];
16+
cell in_8 = in[8];
17+
{{ logic }}
18+
return out;
19+
}
20+
721
// human attempt, 54 gates
822
cell conway_clayton(cell in[9]) {
923
// pairs
@@ -36,20 +50,6 @@ cell conway_clayton(cell in[9]) {
3650
return out;
3751
}
3852

39-
cell conway(cell in[9]) {
40-
cell in_0 = in[0];
41-
cell in_1 = in[1];
42-
cell in_2 = in[2];
43-
cell in_3 = in[3];
44-
cell in_4 = in[4];
45-
cell in_5 = in[5];
46-
cell in_6 = in[6];
47-
cell in_7 = in[7];
48-
cell in_8 = in[8];
49-
{{ logic }}
50-
return out;
51-
}
52-
5353
typedef struct {
5454
cell* cells;
5555
size_t cells_len;

0 commit comments

Comments
 (0)