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

Subversion Repositories ag_6502

[/] [ag_6502/] [trunk/] [fighter/] [bintomem2/] [bintomem2.c] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 olegodints
#include <stdio.h>
2
#include <fcntl.h>
3
#include <string.h>
4
#include <io.h>
5
 
6
 
7
int main(int argc, const char*argv[])
8
{
9
        char*p;
10
        int c, a = argc>1?strtoul(argv[1], &p, 0):0;
11
        unsigned char mem[65536];
12
        int size = 0;
13
        _setmode(0, _O_BINARY);
14
        memset(mem, 0, sizeof(mem));
15
        while ((c = getchar()) != EOF) {
16
                mem[a] = c;
17
                ++ a;
18
        }
19
        {
20
                int mod, blk, bit, b, mask, m, ad, ad1;
21
                printf("parameter\n");
22
                for (mod = 0; mod < 0x10; ++mod) {
23
                        mask = 1 << (mod & 7);
24
                        ad = !(mod >> 3);
25
                        for (blk = 0; blk < 0x40; ++ blk) {
26
                                printf("\tD_%01X_%02X = 256'h", mod, blk);
27
                                b = 0;
28
                                m = 8;
29
                                ad1 = ad + 512 - 2;
30
                                for (bit = 0; bit < 256; ++bit, ad += 2, ad1 -= 2) {
31
//                                      printf("\nmem[%04X] (%02X) & %02X = %02X\n", ad1, mem[ad1], mask, mem[ad1] & mask);
32
                                        if (mem[ad1] & mask) b |= m;
33
                                        m >>= 1;
34
                                        if (!m) { printf("%X", b); m = 8; b = 0; }
35
                                }
36
                                printf("%c\n", (blk == 0x3F && mod == 0x0F)?';':',');
37
                        }
38
                        printf("\n");
39
                }
40
        }
41
        {
42
                int mod, blk;
43
                for (mod = 0; mod < 0x10; ++mod) {
44
                        printf("\tRAM16Kx1#(");
45
                        for (blk = 0; blk < 0x40; ++ blk) {
46
                                printf("D_%01X_%02X%c", mod, blk, (blk == 0x3F)?')':',');
47
                        }
48
                        printf("\n\t\tram%X(CLK1, AB1x, CSM[%i], READ, DO1[%i], DI1[%i], CLK2, AB2, CS2, DO2[%i]);\n",
49
                                mod, (mod >> 3), mod & 7, mod & 7, mod);
50
                }
51
        }
52
        return 0;
53
}

powered by: WebSVN 2.1.0

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