Skip to content
This repository was archived by the owner on Oct 30, 2021. It is now read-only.

Commit d81f9fd

Browse files
committed
Enhance test
1 parent b09971b commit d81f9fd

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

tools/testing/miner/main.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static void test(int i, uint64_t start, uint32_t poll)
137137
usleep(1);
138138
}
139139

140-
static int mine(void)
140+
static int mine(int stages)
141141
{
142142
write_reg32(MINER_CTL_REG, 0);
143143
uint32_t block[10];
@@ -158,7 +158,18 @@ static int mine(void)
158158

159159
for (int i = 0; i < 8; i++)
160160
write_reg32(MINER_DIFF_REG + i, 0xffffffff);
161-
write_reg32(MINER_DIFF_REG + 0, 0x00000007);
161+
switch (stages)
162+
{
163+
case 8:
164+
write_reg32(MINER_DIFF_REG + 0, 0x00000007);
165+
break;
166+
case 4:
167+
write_reg32(MINER_DIFF_REG + 0, 0x0000000f);
168+
break;
169+
case 2:
170+
write_reg32(MINER_DIFF_REG + 0, 0x0000001f);
171+
break;
172+
}
162173

163174
write_reg32(MINER_CTL_REG,
164175
(0x01 << MINER_CTL_FIRST_SHIFT) | (0x80 << MINER_CTL_LAST_SHIFT) | MINER_CTL_RUN_MASK);
@@ -297,7 +308,8 @@ int main()
297308
uint8_t stages = bitfield(STATUS, STAGES);
298309

299310
double expected = h / (24.0 / stages);
300-
printf("Miner clock %'u MHz, expected hash rate %'.2f MH/S\n", h, expected);
311+
printf("Miner clock %'u MHz, pipeline stages %d, expected hash rate %'.2f MH/S\n", h, stages,
312+
expected);
301313
double r = rate() / 1.0e6;
302314
int pass = fabs(r - expected) < (expected * .001);
303315
printf("Measured %'.2f MH/S, %s\n", r, pass ? "PASS" : "FAIL");
@@ -309,7 +321,7 @@ int main()
309321
for (int i = 1; i <= 10; i++)
310322
{
311323
printf("\nSearch %d\n", i);
312-
if (mine())
324+
if (mine(stages))
313325
break;
314326
}
315327
printf("\n");

0 commit comments

Comments
 (0)