summaryrefslogtreecommitdiffstats
path: root/zpu/sw/simulator/com/zylin/zpu/simulator/tools/MakeDRAM.java
blob: f641595b303748ac44de580128f9369c35eb7eab (plain)
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

package com.zylin.zpu.simulator.tools;

import java.io.FileInputStream;
import java.io.IOException;

public class MakeDRAM
{
    public static void main(String[] args) throws IOException
    {
       new MakeDRAM().run(args[0]);
    }

    private void run(String string) throws IOException
    {
        FileInputStream file=new FileInputStream(string);
        
        int i=0;
        while (file.available()>4)
        {
            byte[] tmp=new byte[4];
            file.read(tmp);
            int word=0;
            for (int j=0; j<4; j++)
            {
                word|=((int)(tmp[j])&0xff)<<((3-j)*8);
            }
            String str=Integer.toHexString(word);
            while (str.length()<8)
            {
                str="0"+str;
            }
            
            System.out.println(str);
            i++;
        }
    }

}
OpenPOWER on IntegriCloud