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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [utils/] [bin2vmem.c] - Diff between revs 45 and 46

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 45 Rev 46
Line 79... Line 79...
        int c;
        int c;
        int i = 0;
        int i = 0;
        int write_size_word=0; // Disabled by default
        int write_size_word=0; // Disabled by default
        unsigned int image_size;
        unsigned int image_size;
        int output_fmt = FMT_WITH_ADDR; // 0 - standard 4 per line with address, 1 - synfmt
        int output_fmt = FMT_WITH_ADDR; // 0 - standard 4 per line with address, 1 - synfmt
 
        int bytes_per_word = BYTES_PER_WORD;
 
 
        // Counters keeping track of what we've printed
        // Counters keeping track of what we've printed
        int current_addr = 0;
        int current_addr = 0;
        int word_counter = 0;
        int word_counter = 0;
        int byte_counter = 0;
        int byte_counter = 0;
Line 92... Line 93...
          fprintf(stderr,"\tPlease specify a binary file to convert to VMEM\n");
          fprintf(stderr,"\tPlease specify a binary file to convert to VMEM\n");
          fprintf(stderr,"\n\tbin2vmem - creates vmem output to stdout from bin\n");
          fprintf(stderr,"\n\tbin2vmem - creates vmem output to stdout from bin\n");
          fprintf(stderr,"\n\tBy default the output is word addressed 32-bit words\n");
          fprintf(stderr,"\n\tBy default the output is word addressed 32-bit words\n");
          fprintf(stderr,"\tSpecify -synfmt on the command line after the filename\n");
          fprintf(stderr,"\tSpecify -synfmt on the command line after the filename\n");
          fprintf(stderr,"\tto output in the alterative format, which is a simple\n");
          fprintf(stderr,"\tto output in the alterative format, which is a simple\n");
          fprintf(stderr,"\tlist of the data words.\n");
          fprintf(stderr,"\tlist of the data words. The default bytes per word is 4.\n");
 
 
          fprintf(stderr,"\n");
          fprintf(stderr,"\n");
 
          fprintf(stderr,"\tAdditionally, to specify the bytes per word (per line)\n");
 
          fprintf(stderr,"\twhen specifying the -synfmt simple list format, use the\n");
 
          fprintf(stderr,"\tswitch -bpw=N after specifying the -synfmt option. Example:\n");
 
          fprintf(stderr,"\t\t./bin2vmem prog.bin -synfmt -bpw=2 > prog.vmem\n");
 
          fprintf(stderr,"\n");
          exit(1);
          exit(1);
        }
        }
 
 
        fd = fopen( argv[FILENAME_CMDLINE_INDEX], "r" );
        fd = fopen( argv[FILENAME_CMDLINE_INDEX], "r" );
 
 
        if (argc > 2) // check for the -synfmt switch
        if (argc > 2) // check for the -synfmt switch
          {
          {
            if (strcmp("-synfmt", argv[FMT_CMDLINE_INDEX]) == 0)
            if (strcmp("-synfmt", argv[FMT_CMDLINE_INDEX]) == 0)
 
              {
              output_fmt = FMT_SYN; // synthesis friendly format - single column, no addr
              output_fmt = FMT_SYN; // synthesis friendly format - single column, no addr
 
                int bytes_per_word_tmp;
 
                if (argc > 3) // Check for extra bytes per word option
 
                  if (1 == sscanf(argv[FMT_CMDLINE_INDEX+1], "-bpw=%d", &bytes_per_word_tmp))
 
                    {
 
                      if(bytes_per_word_tmp < 4 && bytes_per_word_tmp > 0)
 
                        {
 
                          //printf("# Bytes per word: %d\n", bytes_per_word_tmp);
 
                          bytes_per_word = bytes_per_word_tmp;
 
                        }
 
 
 
                    }
 
              }
 
 
          }
          }
 
 
        if (fd == NULL) {
        if (fd == NULL) {
                fprintf(stderr,"failed to open input file: %s\n",argv[1]);
                fprintf(stderr,"failed to open input file: %s\n",argv[1]);
                exit(1);
                exit(1);
Line 136... Line 156...
            }
            }
 
 
            // Now write out the image size
            // Now write out the image size
            printf("@%8x", current_addr);
            printf("@%8x", current_addr);
            printf("%8x", image_size);
            printf("%8x", image_size);
            current_addr += WORDS_PER_LINE * BYTES_PER_WORD;
            current_addr += WORDS_PER_LINE * bytes_per_word;
          }
          }
 
 
 
 
        // Fix for the current bootloader software! Skip the first 4 
        // Fix for the current bootloader software! Skip the first 4 
        // bytes of application data. Hopefully it's not important. 030509 -- jb
        // bytes of application data. Hopefully it's not important. 030509 -- jb
Line 171... Line 191...
 
 
              printf("%.2x", (unsigned int) c); // now print the actual char
              printf("%.2x", (unsigned int) c); // now print the actual char
 
 
              byte_counter++;
              byte_counter++;
 
 
              if (byte_counter == BYTES_PER_WORD)
              if (byte_counter == bytes_per_word)
                {
                {
                  word_counter++;
                  word_counter++;
                  byte_counter=0;
                  byte_counter=0;
                }
                }
              if (word_counter == WORDS_PER_LINE)
              if (word_counter == WORDS_PER_LINE)
Line 187... Line 207...
            } // End of FMT_WITH_ADDR
            } // End of FMT_WITH_ADDR
          else if (output_fmt == FMT_SYN) // simple list of data words
          else if (output_fmt == FMT_SYN) // simple list of data words
            {
            {
              printf("%.2x", (unsigned int) c); // now print the actual char
              printf("%.2x", (unsigned int) c); // now print the actual char
              byte_counter++;
              byte_counter++;
              if (byte_counter == BYTES_PER_WORD)
              if (byte_counter == bytes_per_word)
                {
                {
                  printf("\n");
                  printf("\n");
                  byte_counter=0;
                  byte_counter=0;
                }
                }
            }
            }

powered by: WebSVN 2.1.0

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