URL
https://opencores.org/ocsvn/mblite/mblite/trunk
[/] [mblite/] [trunk/] [sw/] [util/] [bin2mem.c] - Blame information for rev 9
Go to most recent revision |
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
5 |
takar |
/******************************************************************************************
|
2 |
|
|
* syntax: bin2mem < filename1.bin > filename2.mem
|
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 c1, c2, c3, c4;
|
16 |
|
|
|
17 |
|
|
printf("// memory data file (do not edit the following line - required for mem load use)\n");
|
18 |
|
|
printf("// format=hex addressradix=h dataradix=h version=1.0 wordsperline=1\n");
|
19 |
|
|
printf("@00000000\n");
|
20 |
|
|
while (!feof(stdin)) {
|
21 |
|
|
c1 = getchar() & 0x0ff;
|
22 |
|
|
c2 = getchar() & 0x0ff;
|
23 |
|
|
c3 = getchar() & 0x0ff;
|
24 |
|
|
c4 = getchar() & 0x0ff;
|
25 |
|
|
printf ("%.2x%.2x%.2x%.2x\n", c1, c2, c3, c4);
|
26 |
|
|
}
|
27 |
|
|
putchar('\n');
|
28 |
|
|
return 0;
|
29 |
|
|
}
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.