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

Subversion Repositories gecko3

[/] [gecko3/] [trunk/] [GECKO3COM/] [gecko3com-ip/] [core/] [GECKO3COM_simple_prng_tb.c] - Blame information for rev 29

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

Line No. Rev Author Line
1 29 nussgipfel
/* GECKO3COM
2
 *
3
 * Copyright (C) 2010 by
4
 *   ___    ____  _   _
5
 *  (  _`\ (  __)( ) ( )
6
 *  | (_) )| (_  | |_| |   Bern University of Applied Sciences
7
 *  |  _ <'|  _) |  _  |   School of Engineering and
8
 *  | (_) )| |   | | | |   Information Technology
9
 *  (____/'(_)   (_) (_)
10
 *
11
 *
12
 * This program is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU General Public License as published by
14
 * the Free Software Foundation, either version 3 of the License, or
15
 * (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 */
24
 
25
/*********************************************************************/
26
/** \file     GECKO3COM_simple_prng_tb.c
27
 *********************************************************************
28
 * \brief     simple programm to fill a file with a desired length value
29
 *
30
 *  to change the length of the value simply change the type of the value
31
 *  variable.
32
 *
33
 * \author    Christoph Zimmermann bfh.ch
34
 * \date      26. February 2010
35
 *
36
 */
37
 
38
#include <stdio.h>
39
#include <stdint.h>
40
#include <stdbool.h>
41
#include <math.h>
42
 
43
int main (void)
44
{
45
  /*--------------------------------------------------------------------------*/
46
  /* start of user configuration values */
47
 
48
  /* variable type of the desired value */
49
  uint32_t prng_data = 0x55555555;
50
 
51
  /* desired filename */
52
  const char* FILENAME = "GECKO3COM_simple_prng_tb.hex";
53
 
54
  /* how many times should the datablock repeated in the file */
55
  int16_t loop = 4096;
56
 
57
  /* end of configuration values */
58
  /*--------------------------------------------------------------------------*/
59
 
60
  FILE *output;
61
  uint64_t i,j;
62
 
63
  uint32_t prng_feedback;
64
 
65
  printf("Hello, this programm will write values with a bit length of %d to the file %s\n", sizeof(prng_data)*8, FILENAME);
66
 
67
  output = fopen(FILENAME, "w+b");
68
 
69
  /* create the desired number of data blocks */
70
  for(j=0; j<loop;j++) {
71
 
72
    if(!fwrite(&prng_data, sizeof(prng_data), 1, output)) {
73
      printf("ERROR writing to the file\n");
74
      return 0;
75
    }
76
 
77
    prng_feedback = prng_data >> 10;
78
    prng_feedback ^= prng_data >> 12;
79
    prng_feedback ^= prng_data >> 13;
80
    prng_feedback ^= prng_data >> 15;
81
 
82
    prng_feedback &= 0x00000001;
83
 
84
    prng_data = prng_data << 1;
85
    prng_data |= prng_feedback;
86
  }
87
 
88
  fclose(output);
89
  return 1;
90
}

powered by: WebSVN 2.1.0

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