randdata.c
2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
*************************************************************************/
/*
* File: randinst.c
* Creator: rww@sgi.com
* Create Date: Wed Sep 28 13:52:37 PDT 1994
*
* This file has some functions to generate random instructions.
*
*/
#include <stdio.h>
#include <string.h>
typedef unsigned long int u32;
u32 R32(void);
void init_random(void);
main( int argc, char **argv )
{
int i, c;
u32 inst;
u32 inst1;
u32 inst2;
u32 inst3;
char buf[80];
FILE *data;
int wide;
if( argc == 1 ) {
fprintf(stderr,"Usage: %s count [width]\n", argv[0] );
exit(1);
};
init_random();
data = fopen("dmem","w");
c = atoi(argv[1]);
wide = 1;
if( argc > 2 )
wide = atoi( argv[2] );
if( wide == 1 )
i=1;
else
i=0;
for(; i<=c; i++) {
inst = R32();
if( wide == 1 ) {
printf("dep $%d 0x%08x\n", i, inst );
fwrite( & inst, sizeof( inst ), 1, data );
} else {
inst1 = R32();
inst2 = R32();
inst3 = R32();
printf("dep $v%d 0x%08x%08x 0x%08x%08x\n", i, inst, inst1, inst2, inst3 );
fwrite( & inst, sizeof( inst ), 1, data );
fwrite( & inst1, sizeof( inst ), 1, data );
fwrite( & inst2, sizeof( inst ), 1, data );
fwrite( & inst3, sizeof( inst ), 1, data );
};
};
fclose( data );
}
void
init_random( void )
{
int rseed;
rseed = time( 0 );
srandom(rseed);
}
u32
R32( void )
{
return( (random()<<1) | (random() & 1) );
}