OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_c/] [ihex2mif/] [ihex.c] - Diff between revs 25 and 45

Show entire file | Details | Blame | View Log

Rev 25 Rev 45
Line 18... Line 18...
#endif
#endif
 
 
/* some ansi prototypes.. maybe ought to make a .h file */
/* some ansi prototypes.. maybe ought to make a .h file */
 
 
/* this loads an intel hex file into the memory[] array */
/* this loads an intel hex file into the memory[] array */
void load_file(char *filename);
int load_file(char *filename);
 
 
/* this writes a part of memory[] to an intel hex file */
/* this writes a part of memory[] to an intel hex file */
void save_file(char *command);
void save_file(char *command);
 
 
/* this is used by load_file to get each line of intex hex */
/* this is used by load_file to get each line of intex hex */
Line 75... Line 75...
}
}
 
 
/* loads an intel hex file into the global memory[] array */
/* loads an intel hex file into the global memory[] array */
/* filename is a string of the file to be opened */
/* filename is a string of the file to be opened */
 
 
void load_file(filename)
int load_file(filename)
char *filename;
char *filename;
{
{
        char line[1000];
        char line[1000];
        FILE *fin;
        FILE *fin;
        int addr, n, status, bytes[256];
        int addr, n, status, bytes[256];
Line 87... Line 87...
        int minaddr=65536, maxaddr=0;
        int minaddr=65536, maxaddr=0;
 
 
        if (strlen(filename) == 0) {
        if (strlen(filename) == 0) {
                printf("   Can't load a file without the filename.");
                printf("   Can't load a file without the filename.");
                printf("  '?' for help\n");
                printf("  '?' for help\n");
                return;
                return 0;
        }
        }
        fin = fopen(filename, "r");
        fin = fopen(filename, "r");
        if (fin == NULL) {
        if (fin == NULL) {
                printf("   Can't open file '%s' for reading.\n", filename);
                printf("   Can't open file '%s' for reading.\n", filename);
                //return;
                //return;
Line 114... Line 114...
                        }
                        }
                        if (status == 1) {  /* end of file */
                        if (status == 1) {  /* end of file */
                                fclose(fin);
                                fclose(fin);
                                printf("   Loaded %d bytes between:", total);
                                printf("   Loaded %d bytes between:", total);
                                printf(" %04X to %04X\n", minaddr, maxaddr);
                                printf(" %04X to %04X\n", minaddr, maxaddr);
                                return;
 
 
                                return maxaddr;
                        }
                        }
                        if (status == 2) ;  /* begin of file */
                        if (status == 2) ;  /* begin of file */
                } else {
                } else {
                        printf("   Error: '%s', line: %d\n", filename, lineno);
                        printf("   Error: '%s', line: %d\n", filename, lineno);
                }
                }
                lineno++;
                lineno++;
        }
        }
 
        return maxaddr;//it should not reach here
}
}
 
 
 
 
/* the command string format is "S begin end filename" where */
/* the command string format is "S begin end filename" where */
/* "begin" and "end" are the locations to dump to the intel */
/* "begin" and "end" are the locations to dump to the intel */

powered by: WebSVN 2.1.0

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