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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [or1ksim/] [testsuite/] [test-code-or1k/] [testfloat/] [random.c] - Blame information for rev 430

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

Line No. Rev Author Line
1 234 jeremybenn
 
2
/*
3
===============================================================================
4
 
5
This C source file is part of TestFloat, Release 2a, a package of programs
6
for testing the correctness of floating-point arithmetic complying to the
7
IEC/IEEE Standard for Floating-Point.
8
 
9
Written by John R. Hauser.  More information is available through the Web
10
page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'.
11
 
12
THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort
13
has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
14
TIMES RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO
15
PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
16
AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
17
 
18
Derivative works are acceptable, even for commercial purposes, so long as
19
(1) they include prominent notice that the work is derivative, and (2) they
20
include prominent notice akin to these four paragraphs for those parts of
21
this code that are retained.
22
 
23
Modified for use with or1ksim's testsuite.
24
 
25
Contributor Julius Baxter <julius.baxter@orsoc.se>
26
 
27
===============================================================================
28
*/
29
                                                                 /*
30
#include <stdlib.h>
31
                                                                 */
32
#include "support.h" // OR1k support C library
33
#include "milieu.h"
34
#include "random.h"
35
 
36
uint8 randomUint8( void )
37
{
38
 
39
    return (bits8) ( rand()>>4 );
40
 
41
}
42
 
43
uint16 randomUint16( void )
44
{
45
 
46
    return ( ( rand() & 0x0FF0 )<<4 ) | ( ( rand()>>4 ) & 0xFF );
47
 
48
}
49
 
50
uint32 randomUint32( void )
51
{
52
 
53
    return
54
          ( ( (uint32) ( rand() & 0x0FF0 ) )<<20 )
55
        | ( ( (uint32) ( rand() & 0x0FF0 ) )<<12 )
56
        | ( ( rand() & 0x0FF0 )<<4 )
57
        | ( ( rand()>>4 ) & 0xFF );
58
 
59
}
60
 
61
#ifdef BITS64
62
 
63
uint64 randomUint64( void )
64
{
65
 
66
    return ( ( (uint64) randomUint32() )<<32 ) | randomUint32();
67
 
68
}
69
 
70
#endif
71
 

powered by: WebSVN 2.1.0

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