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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [tools/] [dspmem/] [mkinit.c] - Blame information for rev 211

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

Line No. Rev Author Line
1 42 hellwig
/*
2
 * mkinit.c -- generate Verilog defparam statements from C data
3
 */
4
 
5
 
6
#include <stdio.h>
7
#include <stdlib.h>
8
#include <string.h>
9
 
10
 
11
#define ATT_HI_FILE_NAME        "dspatthi.init"
12
#define ATT_LO_FILE_NAME        "dspattlo.init"
13
#define CHR_HI_FILE_NAME        "dspchrhi.init"
14
#define CHR_LO_FILE_NAME        "dspchrlo.init"
15
 
16
 
17
unsigned char data[][80] = {
18
  #include "screen"
19
};
20
 
21
 
22
int main(void) {
23
  FILE *outFile;
24
  int i, j;
25
  unsigned char b[64];
26
  int index, row, col;
27
 
28
  if (sizeof(data) != 30 * 80) {
29
    printf("Error: wrong size of data\n");
30
    exit(1);
31
  }
32
  outFile = fopen(ATT_HI_FILE_NAME, "w");
33
  if (outFile == NULL) {
34
    printf("Error: cannot open file '%s'\n", ATT_HI_FILE_NAME);
35
    exit(1);
36
  }
37
  for (i = 0; i < 64; i++) {
38
    fprintf(outFile, "  defparam display_att_hi.INIT_%02X = 256'h", i);
39
    for (j = 0; j < 64; j++) {
40
      index = i * 64 + j;
41
      row = index / 128;
42
      col = index % 128;
43
      if (0 <= row && row < 30 &&
44
 
45
        b[j] = 0x07;
46
      } else {
47
        b[j] = 0;
48
      }
49
    }
50
    for (j = 63; j >= 0; j--) {
51
      fprintf(outFile, "%01X", (b[j] >> 4) & 0x0F);
52
    }
53
    fprintf(outFile, ";\n");
54
  }
55
  fclose(outFile);
56
  outFile = fopen(ATT_LO_FILE_NAME, "w");
57
  if (outFile == NULL) {
58
    printf("Error: cannot open file '%s'\n", ATT_LO_FILE_NAME);
59
    exit(1);
60
  }
61
  for (i = 0; i < 64; i++) {
62
    fprintf(outFile, "  defparam display_att_lo.INIT_%02X = 256'h", i);
63
    for (j = 0; j < 64; j++) {
64
      index = i * 64 + j;
65
      row = index / 128;
66
      col = index % 128;
67
      if (0 <= row && row < 30 &&
68
 
69
        b[j] = 0x07;
70
      } else {
71
        b[j] = 0;
72
      }
73
    }
74
    for (j = 63; j >= 0; j--) {
75
      fprintf(outFile, "%01X", (b[j] >> 0) & 0x0F);
76
    }
77
    fprintf(outFile, ";\n");
78
  }
79
  fclose(outFile);
80
  outFile = fopen(CHR_HI_FILE_NAME, "w");
81
  if (outFile == NULL) {
82
    printf("Error: cannot open file '%s'\n", CHR_HI_FILE_NAME);
83
    exit(1);
84
  }
85
  for (i = 0; i < 64; i++) {
86
    fprintf(outFile, "  defparam display_chr_hi.INIT_%02X = 256'h", i);
87
    for (j = 0; j < 64; j++) {
88
      index = i * 64 + j;
89
      row = index / 128;
90
      col = index % 128;
91
      if (0 <= row && row < 30 &&
92
 
93
        b[j] = data[row][col];
94
      } else {
95
        b[j] = 0;
96
      }
97
    }
98
    for (j = 63; j >= 0; j--) {
99
      fprintf(outFile, "%01X", (b[j] >> 4) & 0x0F);
100
    }
101
    fprintf(outFile, ";\n");
102
  }
103
  fclose(outFile);
104
  outFile = fopen(CHR_LO_FILE_NAME, "w");
105
  if (outFile == NULL) {
106
    printf("Error: cannot open file '%s'\n", CHR_LO_FILE_NAME);
107
    exit(1);
108
  }
109
  for (i = 0; i < 64; i++) {
110
    fprintf(outFile, "  defparam display_chr_lo.INIT_%02X = 256'h", i);
111
    for (j = 0; j < 64; j++) {
112
      index = i * 64 + j;
113
      row = index / 128;
114
      col = index % 128;
115
      if (0 <= row && row < 30 &&
116
 
117
        b[j] = data[row][col];
118
      } else {
119
        b[j] = 0;
120
      }
121
    }
122
    for (j = 63; j >= 0; j--) {
123
      fprintf(outFile, "%01X", (b[j] >> 0) & 0x0F);
124
    }
125
    fprintf(outFile, ";\n");
126
  }
127
  fclose(outFile);
128
  return 0;
129
}

powered by: WebSVN 2.1.0

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