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

Subversion Repositories usb_fpga_1_2

[/] [usb_fpga_1_2/] [trunk/] [java/] [ztex/] [IhxFile.java] - Diff between revs 2 and 3

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

Rev 2 Rev 3
Line 22... Line 22...
package ztex;
package ztex;
 
 
import java.io.*;
import java.io.*;
import java.util.*;
import java.util.*;
import java.net.*;
import java.net.*;
 
/**
 
  * A class representing a firmware image loaded from an ihx (Intel Hex format) file.
 
  */
public class IhxFile {
public class IhxFile {
 
 
 
/**
 
  * This array stores the firmware image.
 
  * Values <0 and >255 mean that the data is undefined.
 
  */
    public short ihxData[] = new short[65536];
    public short ihxData[] = new short[65536];
 
 
// ******* readHexDigit ********************************************************
// ******* readHexDigit ********************************************************
    private static final int readHexDigit( InputStream in ) throws IOException, IhxParseException {
    private static final int readHexDigit( InputStream in ) throws IOException, IhxParseException {
        int b = in.read();
        int b = in.read();
Line 46... Line 53...
    private static final int readHexByte(InputStream in) throws IOException, IhxParseException {
    private static final int readHexByte(InputStream in) throws IOException, IhxParseException {
        return (readHexDigit(in) << 4) | readHexDigit(in);
        return (readHexDigit(in) << 4) | readHexDigit(in);
    }
    }
 
 
// ******* IhxFile *************************************************************
// ******* IhxFile *************************************************************
 
/**
 
  * Constructs an instance from a given file name.
 
  * This method can also read system resources, e.g. files from the current jar archive.
 
  * @param fileName The file name.
 
  * @throws IOException If an read error occurred.
 
  * @throws IhxFileDamagedException If the ihx file is damaged.
 
  */
    public IhxFile ( String fileName ) throws IOException, IhxFileDamagedException {
    public IhxFile ( String fileName ) throws IOException, IhxFileDamagedException {
        InputStream in = JInputStream.getInputStream( fileName );
        InputStream in = JInputStream.getInputStream( fileName );
        int b, len, cs, addr;
        int b, len, cs, addr;
        byte buf[] = new byte[255];
        byte buf[] = new byte[255];
        boolean eof = false;
        boolean eof = false;
Line 116... Line 130...
            System.err.println( "Warning: Error closing file " + fileName + ": " + e.getLocalizedMessage() );
            System.err.println( "Warning: Error closing file " + fileName + ": " + e.getLocalizedMessage() );
        }
        }
    }
    }
 
 
// ******* dataInfo ************************************************************
// ******* dataInfo ************************************************************
 
 /**
 
  * Print out some information about the memory usage.
 
  * @param out Where the data is printed out.
 
  */
    public void dataInfo( PrintStream out ) {
    public void dataInfo( PrintStream out ) {
        int addr=-1;
        int addr=-1;
        for ( int i=0; i<=65536; i++ ) { // data
        for ( int i=0; i<=65536; i++ ) { // data
            if ( (i==65536 || ihxData[i]<0) && addr>=0 ) {
            if ( (i==65536 || ihxData[i]<0) && addr>=0 ) {
                System.out.println( i-addr + " Bytes from " + Integer.toHexString(addr) + " to " + Integer.toHexString(i-1) );
                System.out.println( i-addr + " Bytes from " + Integer.toHexString(addr) + " to " + Integer.toHexString(i-1) );

powered by: WebSVN 2.1.0

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