Change benchmark to calc MD5 on 1024 softcores
This commit is contained in:
@@ -1,82 +1,27 @@
|
||||
#include "../io_reg.h"
|
||||
#include "md5.h"
|
||||
#include "uprintf.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define DATA_ADDR 0x10000
|
||||
#define DATA_LEN 0x10000
|
||||
|
||||
void put_char(char c)
|
||||
{
|
||||
IO_REG_CONSOLE = c | IO_REG_CONSOLE_SEND;
|
||||
}
|
||||
|
||||
#define N 200
|
||||
#define CHUNK 4
|
||||
#define ARR_LEN (10 * N / 3 + 1)
|
||||
|
||||
static int arr[ARR_LEN];
|
||||
|
||||
void print_digit(int d)
|
||||
int main(void)
|
||||
{
|
||||
static int cnt = 0;
|
||||
uint8_t result[16];
|
||||
|
||||
p("%d", d);
|
||||
cnt++;
|
||||
md5Buf((uint8_t *)DATA_ADDR, DATA_LEN, result);
|
||||
|
||||
if (cnt == CHUNK) {
|
||||
p("\n");
|
||||
cnt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* See: https://en.wikipedia.org/wiki/Spigot_algorithm */
|
||||
|
||||
int main()
|
||||
{
|
||||
p("\nComputation of %d first digits of PI\n", N);
|
||||
|
||||
for (int i = 0; i < ARR_LEN; i++)
|
||||
arr[i] = 2;
|
||||
|
||||
int nines = 0;
|
||||
int predigit = 0;
|
||||
|
||||
for (int j = 1; j < N + 1; j++) {
|
||||
int q = 0;
|
||||
|
||||
for (int i = ARR_LEN; i > 0; i--) {
|
||||
int x = 10 * arr[i - 1] + q * i;
|
||||
arr[i - 1] = x % (2 * i - 1);
|
||||
q = x / (2 * i - 1);
|
||||
}
|
||||
|
||||
arr[0] = q % 10;
|
||||
q = q / 10;
|
||||
|
||||
if (9 == q)
|
||||
nines++;
|
||||
else if (10 == q) {
|
||||
print_digit(predigit + 1);
|
||||
|
||||
for (int k = 0; k < nines; k++)
|
||||
print_digit(0);
|
||||
|
||||
predigit = 0;
|
||||
nines = 0;
|
||||
}
|
||||
else {
|
||||
print_digit(predigit);
|
||||
predigit = q;
|
||||
|
||||
if (0 != nines) {
|
||||
for (int k = 0; k < nines; k++)
|
||||
print_digit(9);
|
||||
|
||||
nines = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
p("%d", predigit);
|
||||
|
||||
p("\nDONE\n");
|
||||
IO_REG_MD5_OUT0 = *(uint32_t *)(result + 0);
|
||||
IO_REG_MD5_OUT1 = *(uint32_t *)(result + 4);
|
||||
IO_REG_MD5_OUT2 = *(uint32_t *)(result + 8);
|
||||
IO_REG_MD5_OUT3 = *(uint32_t *)(result + 12);
|
||||
|
||||
/* Stop simulation */
|
||||
IO_REG_CTRL = IO_REG_CTRL_STOP;
|
||||
|
||||
Reference in New Issue
Block a user