display.c
1.92 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
#include <stdio.h>
#include "acc_user.h"
#include "vcsuser.h"
FILE *OutFile;
void PrintTabHeader(char *prog_name)
{
fprintf(OutFile, "#\n");
fprintf(OutFile, "# created by %s.c\n", prog_name);
fprintf(OutFile, "#\n");
fprintf(OutFile, "vclk @C 1(8) 0(8)\n");
fprintf(OutFile, "frac[4:0] @I @E 2\n");
fprintf(OutFile, "rgb_a[7:0] @I @E 2\n");
fprintf(OutFile, "rgb_b[7:0] @I @E 2\n");
fprintf(OutFile, "sync_b @I @E 2\n");
fprintf(OutFile, "lerp_rgb[7:0] @O @S 15\n");
fprintf(OutFile, "lerp_sync @O @S 15\n");
fprintf(OutFile, "\n"); /* required newline */
}
void open_out_file(void)
{
char *filename;
acc_initialize();
acc_configure(accDevelopmentVersion, "1.6");
if (tf_nump() != 1)
{
tf_error("Illegal number of arguments to open_out_file");
tf_putp(0, -1);
}
else
{
if ((filename = tf_getcstringp(1)) == NULL)
{
tf_error("Illegal parameters passed to open_out_file");
tf_putp(0, -1);
}
else
{
if ((OutFile = fopen(filename, "w")) == NULL)
{
tf_error("Couldn't open output file");
tf_putp(0, -1);
}
PrintTabHeader("display");
}
}
tf_putp(0, 0);
}
void output_lerp(void)
{
int frac, rgb_a, rgb_b, sync_b, lerp_rgb, lerp_sync;
if (OutFile != NULL)
{
if (tf_nump() != 6)
{
tf_error("Illegal number of arguments to output_lerp");
tf_putp(0, -1);
}
else
{
frac = tf_getp(1);
rgb_a = tf_getp(2);
rgb_b = tf_getp(3);
sync_b = tf_getp(4);
lerp_rgb = tf_getp(5);
lerp_sync = tf_getp(6);
fprintf(OutFile, "0x%.2x 0x%.2x 0x%.2x %d\t0x%.2x %d \n",
frac, rgb_a, rgb_b, sync_b, lerp_rgb, lerp_sync);
}
}
tf_putp(0, 0);
}
void close_output_files(void)
{
if (OutFile != NULL) fclose(OutFile);
tf_putp(0, 0);
}