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

Subversion Repositories RISCMCU

[/] [RISCMCU/] [trunk/] [hex2mif/] [hex2mif.c] - Blame information for rev 28

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 yapzihe
#include <stdio.h>
2
#include <stdlib.h>
3
 
4
void process(FILE *, FILE *);
5
void prn_info();
6
 
7
int main(int argc, char **argv)
8
{
9
        FILE *ifp, *ofp;
10
 
11
        if (argc != 2) {
12
                prn_info();
13
                exit(1);
14
        }
15
 
16
        ifp = fopen(argv[1], "r");
17
        ofp = fopen("program.mif", "w");
18
        process(ifp, ofp);
19
        fclose(ifp);
20
        fclose(ofp);
21
        return 0;
22
}
23
 
24
void process(FILE *ifp, FILE *ofp)
25
{
26
        int c;
27
 
28
        fprintf(ofp, "width = 16;\ndepth = 512;\n\n"
29
        "address_radix = hex;\ndata_radix = hex;\n\n"
30
        "content begin\n[0..1ff]: 0;\n\n");
31
 
32
        while((c = getc(ifp)) != EOF) {
33
                if (c != '\n')
34
                        putc(c, ofp);
35
                else {
36
                        putc(';', ofp);
37
                        putc(c, ofp);
38
                }
39
        }
40
 
41
        fprintf(ofp, "\n\nend;");
42
 
43
        printf("Mission Accomplished");
44
}
45
 
46
void prn_info()
47
{
48
        printf("Mission Failed");
49
}

powered by: WebSVN 2.1.0

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