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

Subversion Repositories mblite

[/] [mblite/] [trunk/] [sw/] [util/] [bin2mem4.c] - Blame information for rev 6

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

Line No. Rev Author Line
1 5 takar
/******************************************************************************************
2
*   syntax: bin2mem  < filename1.bin
3
*   author: Rene van Leuken
4
*   modified: Tamar Kranenburg
5
*   February, 2008: header string provided, so ModelSim can recognize the file's format
6
*                   (= Veriloh hex) when 'Importing' into memory ... (Huib)
7
*   September, 2008: prevent reversing byte order
8
*
9
*******************************************************************************************/
10
 
11
#include <stdio.h>
12
 
13
main()
14
{
15
    unsigned char c0, c1, c2, c3;
16
 
17
    FILE *fp0, *fp1, *fp2, *fp3;
18
    fp0=fopen("rom0.mem", "wb");
19
    fp1=fopen("rom1.mem", "wb");
20
    fp2=fopen("rom2.mem", "wb");
21
    fp3=fopen("rom3.mem", "wb");
22
 
23
    fprintf(fp0, "// memory data file (do not edit the following line - required for mem load use)\n");
24
    fprintf(fp1, "// memory data file (do not edit the following line - required for mem load use)\n");
25
    fprintf(fp2, "// memory data file (do not edit the following line - required for mem load use)\n");
26
    fprintf(fp3, "// memory data file (do not edit the following line - required for mem load use)\n");
27
    fprintf(fp0, "// format=hex addressradix=h dataradix=h version=1.0 wordsperline=1\n");
28
    fprintf(fp1, "// format=hex addressradix=h dataradix=h version=1.0 wordsperline=1\n");
29
    fprintf(fp2, "// format=hex addressradix=h dataradix=h version=1.0 wordsperline=1\n");
30
    fprintf(fp3, "// format=hex addressradix=h dataradix=h version=1.0 wordsperline=1\n");
31
    fprintf(fp0, "@00000000\n");
32
    fprintf(fp1, "@00000000\n");
33
    fprintf(fp2, "@00000000\n");
34
    fprintf(fp3, "@00000000\n");
35
 
36
    while (!feof(stdin)) {
37
        c0 = getchar() & 0x0ff;
38
        c1 = getchar() & 0x0ff;
39
        c2 = getchar() & 0x0ff;
40
        c3 = getchar() & 0x0ff;
41
        fprintf (fp0, "%.2x\n", c3);
42
        fprintf (fp1, "%.2x\n", c2);
43
        fprintf (fp2, "%.2x\n", c1);
44
        fprintf (fp3, "%.2x\n", c0);
45
    }
46
 
47
    fprintf(fp0, "\n");
48
    fprintf(fp1, "\n");
49
    fprintf(fp2, "\n");
50
    fprintf(fp3, "\n");
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.