yosys-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
manual/CHAPTER_StateOfTheArt/cmp_tbdata.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
+ Include dependency graph for manual/CHAPTER_StateOfTheArt/cmp_tbdata.c:

Go to the source code of this file.

Functions

void check (bool ok)
 
int main (int argc, char **argv)
 

Variables

int line = 0
 
char buffer1 [1024]
 
char buffer2 [1024]
 

Function Documentation

void check ( bool  ok)

Definition at line 10 of file manual/CHAPTER_StateOfTheArt/cmp_tbdata.c.

11 {
12  if (ok)
13  return;
14  // fprintf(stderr, "Error in testbench output compare (line=%d):\n-%s\n+%s\n", line, buffer1, buffer2);
15  exit(1);
16 }

+ Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 18 of file manual/CHAPTER_StateOfTheArt/cmp_tbdata.c.

19 {
20  FILE *f1, *f2;
21  bool eof1, eof2;
22  int i;
23 
24  check(argc == 3);
25 
26  f1 = fopen(argv[1], "r");
27  f2 = fopen(argv[2], "r");
28 
29  check(f1 && f2);
30 
31  while (!feof(f1) && !feof(f2))
32  {
33  line++;
34  buffer1[0] = 0;
35  buffer2[0] = 0;
36 
37  eof1 = fgets(buffer1, 1024, f1) == NULL;
38  eof2 = fgets(buffer2, 1024, f2) == NULL;
39 
40  if (*buffer1 && buffer1[strlen(buffer1)-1] == '\n')
41  buffer1[strlen(buffer1)-1] = 0;
42 
43  if (*buffer2 && buffer2[strlen(buffer2)-1] == '\n')
44  buffer2[strlen(buffer2)-1] = 0;
45 
46  check(eof1 == eof2);
47 
48  for (i = 0; buffer1[i] || buffer2[i]; i++)
49  {
50  check(buffer1[i] != 0 && buffer2[i] != 0);
51 
52  // first argument is the reference. An 'z' or 'x'
53  // here means we don't care about the result.
54  if (buffer1[i] == 'z' || buffer1[i] == 'x')
55  continue;
56 
57  check(buffer1[i] == buffer2[i]);
58  }
59  }
60 
61  check(feof(f1) && feof(f2));
62 
63  fclose(f1);
64  fclose(f2);
65  return 0;
66 }
#define NULL

+ Here is the call graph for this function:

Variable Documentation

char buffer1[1024]

Definition at line 7 of file manual/CHAPTER_StateOfTheArt/cmp_tbdata.c.

char buffer2[1024]

Definition at line 8 of file manual/CHAPTER_StateOfTheArt/cmp_tbdata.c.

int line = 0

Definition at line 6 of file manual/CHAPTER_StateOfTheArt/cmp_tbdata.c.