OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [doc/] [magic/] [random.c] - Blame information for rev 41

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 hellwig
/*
2
 * random.c -- a random generator to generate magic numbers
3
 */
4
 
5
 
6
#include <stdio.h>
7
#include <stdlib.h>
8
#include <string.h>
9
 
10
 
11
unsigned long currentRandom = 0x3AE82DD4;
12
 
13
 
14
void nextRandom(void) {
15
  currentRandom = 3141592621U * currentRandom + 12345;
16
}
17
 
18
 
19
int main(int argc, char *argv[]) {
20
  int n, i;
21
 
22
  if (argc != 2) {
23
    printf("Usage: %s <number>\n", argv[0]);
24
    return 1;
25
  }
26
  n = atoi(argv[1]);
27
  for (i = 0; i < n; i++) {
28
    printf("%3d: 0x%08lX\n", i, currentRandom);
29
    nextRandom();
30
  }
31
  return 0;
32
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.