checkrand.c
1.05 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
#include <stdio.h>
#include "PR/rdpsim/test/vi/OutData/vi_rand/vi_rand.c"
int CurrentLine = 0;
int NumErrors = 0;
main(int argc, char *argv[])
{
FILE *InFile;
char InData[80] = "foo";
char *ReadOk = "foo";
unsigned int reset_l, vrand, crand;
if (!argv[1])
{
fprintf(stderr, "ERROR, specify file \n");
NumErrors++;
}
else if ((InFile = fopen(argv[1], "r")) == NULL)
{
fprintf(stderr, "ERROR, cannot open %s \n", argv[1]);
exit (1);
}
while((InData[0] != '0') && (InData[0] != '1'))
{
fgets(InData, 80, InFile);
}
while (ReadOk)
{
sscanf(InData, "%x %x", &reset_l, &vrand);
vi_rand(reset_l, &crand);
if (CurrentLine)
{
if (vrand != crand)
{
printf("ERROR rand, line %d (computed) 0x%.2x != (verilog) 0x%.2x \n",
CurrentLine, crand, vrand);
NumErrors++;
}
}
ReadOk = fgets(InData, 80, InFile);
CurrentLine++;
}
fclose(InFile);
printf("!!! %s of vi_rand: number of errors:\t\t%d\n", argv[1], NumErrors);
}