-
Notifications
You must be signed in to change notification settings - Fork 0
/
tomif.c
41 lines (35 loc) · 848 Bytes
/
tomif.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
#include<stdint.h>
#include<string.h>
void main(void)
{
FILE *fp;
int i;
uint16_t ram[32768];
int fs;
fp = fopen("out.bin","rb");
fs = fread(ram,sizeof(uint16_t),32768,fp);
for(i=0;i<fs;i++)
{
ram[i] = ram[i] >> 8 | ram[i] << 8;
}
if(fs > 1000)
{
fp = fopen("kernl-misc-0-7-3.mif","w");
fprintf(fp, "DEPTH = %d;\n",fs);
fprintf(fp, "WIDTH = 16;\n");
fprintf(fp, "ADDRESS_RADIX = HEX;\n");
fprintf(fp, "DATA_RADIX = HEX;\n");
fprintf(fp, "CONTENT\nBEGIN\n");
for(i=0;i<fs;i++)
{
fprintf(fp, "%03X : %04X ;\n",i,ram[i]);
}
fprintf(fp, "END;\n");
fclose(fp);
printf("MIF file created %d words.\n",fs);
}
fclose(fp);
}