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 31

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 31 nussgipfel
 *  compile with:
34
 *  "gcc -o GECKO3COM_simple_prng_tb GECKO3COM_simple_prng_tb.c"
35
 *
36 29 nussgipfel
 * \author    Christoph Zimmermann bfh.ch
37
 * \date      26. February 2010
38
 *
39
 */
40
 
41
#include <stdio.h>
42
#include <stdint.h>
43
#include <stdbool.h>
44
#include <math.h>
45
 
46
int main (void)
47
{
48
  /*--------------------------------------------------------------------------*/
49
  /* start of user configuration values */
50
 
51
  /* variable type of the desired value */
52
  uint32_t prng_data = 0x55555555;
53
 
54
  /* desired filename */
55
  const char* FILENAME = "GECKO3COM_simple_prng_tb.hex";
56
 
57
  /* how many times should the datablock repeated in the file */
58
  int16_t loop = 4096;
59
 
60
  /* end of configuration values */
61
  /*--------------------------------------------------------------------------*/
62
 
63
  FILE *output;
64
  uint64_t i,j;
65
 
66
  uint32_t prng_feedback;
67
 
68
  printf("Hello, this programm will write values with a bit length of %d to the file %s\n", sizeof(prng_data)*8, FILENAME);
69
 
70
  output = fopen(FILENAME, "w+b");
71
 
72
  /* create the desired number of data blocks */
73
  for(j=0; j<loop;j++) {
74
 
75
    if(!fwrite(&prng_data, sizeof(prng_data), 1, output)) {
76
      printf("ERROR writing to the file\n");
77
      return 0;
78
    }
79
 
80
    prng_feedback = prng_data >> 10;
81
    prng_feedback ^= prng_data >> 12;
82
    prng_feedback ^= prng_data >> 13;
83
    prng_feedback ^= prng_data >> 15;
84
 
85
    prng_feedback &= 0x00000001;
86
 
87
    prng_data = prng_data << 1;
88
    prng_data |= prng_feedback;
89
  }
90
 
91
  fclose(output);
92
  return 1;
93
}

powered by: WebSVN 2.1.0

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