hades.models.pic
Class PicEprom

java.lang.Object
  extended byhades.models.pic.PicEprom
All Implemented Interfaces:
PicMemory
Direct Known Subclasses:
TurboPicCore.PicMemoryEpromAdapter

public class PicEprom
extends java.lang.Object
implements PicMemory

PicEprom - The Eprom implemented in Microchip-microcontrollers


Field Summary
protected  int bits
           
protected  int bytes
           
protected  long[] eprom
           
protected  java.lang.String filename
           
protected  java.lang.String[] labels
           
protected  long maxWord
           
protected  java.util.Hashtable mlTable
           
 
Constructor Summary
PicEprom()
          Default-Constructor, using 2K with 16 bit
PicEprom(int size, int bitsPerWord)
          Constructor with the opportunity to change the size and the number of bits per word the Eprom is using
 
Method Summary
 void addLabel(int addr, java.lang.String name)
          set a label 'name' for ROM address 'addr'.
 void addMemoryListener(MemoryListener ML)
           
 boolean canChangeSize()
          canChangeSize interfaces Memory, size is fixed!
 void clearLabels()
           
 int getBitsPerWord()
          getBitsPerWord interfaces Memory, same as getWordWidth()
 long[] getDataArray()
          getDataArray interfaces Memory, read the whole memory
 long getDataAt(int address)
          getDataAt interfaces Memory, same as readMemory()
 java.lang.String getFilename()
           
 java.lang.String getLabel(int addr)
          return the label corresponding to this ROM address - or null if none set.
 int getMemorySize()
          getMemorySize reports the size of the eprom in words
 java.lang.String getResourcename()
          getResourcename interfaces Memory, uses filename
 int getSize()
          getSize interfaces Memory, same as getMemorySize()
 int getWordWidth()
          getWordWidth reports the width of one word in bits
 boolean hasLabel(int addr)
          check whether address 'addr' has a label set.
 boolean load(java.lang.Object parent, java.lang.String resourcename)
          load the PicEprom contents from a resource called "resourcename" and belonging to SimObject "parent".
 boolean load(java.lang.String resourcename)
           
 void load(java.lang.String name, java.lang.String dir)
          Open the given filename and load the content into the ROM.
 boolean loadHEX(java.io.InputStream is)
           
 void loadLBL(java.io.InputStream is)
          try to parse a .lbl file with label declarations, on label per line:
 boolean loadROM(java.io.InputStream is)
          load ROM data from an InputStream, returns false if OK, true if errors occured.
 boolean merge(java.io.BufferedReader reader)
          merge interfaces Memory, no function
 boolean parse(java.io.BufferedReader reader)
          parse interfaces Memory, no function
protected  void parseLabelLine(java.lang.String line)
           
 void por()
          Power-on-reset, fills eprom with 0
 int readMemory(int address)
          Read a word, from interface PicMemory
 void removeMemoryListener(MemoryListener ML)
           
 void reset()
          Reset, does nothing
 boolean resize(int i, int j)
           
 boolean save(java.io.PrintWriter PW)
          save interfaces Memory, no function
 void save(java.lang.String name, java.lang.String dir)
           
 void setBitsPerWord(int n_bits)
          setBitsPerWord interfaces Memory, no function
 void setDataArray(long[] data)
          setDataArray interfaces Memory, write a memory-block
 void setDataAt(int address, long value)
          setDataAt interfaces Memory, same as writeMemory()
 void setFilename(java.lang.String name)
           
 void setFilename(java.lang.String name, java.lang.String dir)
           
 void setResourcename(java.lang.String name)
          setResourcename interfaces Memory, uses filename
 void setSize(int n_words)
          setSize interfaces Memory, no function
 void writeMemory(int address, int word)
          Write a word, from interface PicMemory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bits

protected int bits

maxWord

protected long maxWord

bytes

protected int bytes

eprom

protected long[] eprom

filename

protected java.lang.String filename

mlTable

protected java.util.Hashtable mlTable

labels

protected java.lang.String[] labels
Constructor Detail

PicEprom

public PicEprom(int size,
                int bitsPerWord)
Constructor with the opportunity to change the size and the number of bits per word the Eprom is using


PicEprom

public PicEprom()
Default-Constructor, using 2K with 16 bit

Method Detail

por

public void por()
Power-on-reset, fills eprom with 0


reset

public void reset()
Reset, does nothing


resize

public boolean resize(int i,
                      int j)

getMemorySize

public int getMemorySize()
getMemorySize reports the size of the eprom in words

Specified by:
getMemorySize in interface PicMemory

getWordWidth

public int getWordWidth()
getWordWidth reports the width of one word in bits

Specified by:
getWordWidth in interface PicMemory

readMemory

public int readMemory(int address)
Read a word, from interface PicMemory

Specified by:
readMemory in interface PicMemory

writeMemory

public void writeMemory(int address,
                        int word)
Write a word, from interface PicMemory

Specified by:
writeMemory in interface PicMemory

setFilename

public void setFilename(java.lang.String name)

setFilename

public void setFilename(java.lang.String name,
                        java.lang.String dir)

getFilename

public java.lang.String getFilename()

load

public void load(java.lang.String name,
                 java.lang.String dir)
Open the given filename and load the content into the ROM. Format: Hex-Numbers seperated by spaces and line-feeds are stored beginning by address 0. If a number ends with a colon, it is the address the following numbers are stored at.


load

public boolean load(java.lang.String resourcename)

load

public boolean load(java.lang.Object parent,
                    java.lang.String resourcename)
load the PicEprom contents from a resource called "resourcename" and belonging to SimObject "parent". This method uses DesignManager to lookup an InputStream for the resource; if the name ends with ".hex" we expect Intel HEX-format data, and raw ".rom" data otherwise.


loadROM

public boolean loadROM(java.io.InputStream is)
load ROM data from an InputStream, returns false if OK, true if errors occured.


parseLabelLine

protected void parseLabelLine(java.lang.String line)
                       throws java.lang.Exception
Throws:
java.lang.Exception

addLabel

public void addLabel(int addr,
                     java.lang.String name)
set a label 'name' for ROM address 'addr'. Neither argument is checked.


hasLabel

public boolean hasLabel(int addr)
check whether address 'addr' has a label set. This method does not check the address range.


getLabel

public java.lang.String getLabel(int addr)
return the label corresponding to this ROM address - or null if none set. This method does not check the address range.


clearLabels

public void clearLabels()

loadHEX

public boolean loadHEX(java.io.InputStream is)

loadLBL

public void loadLBL(java.io.InputStream is)
try to parse a .lbl file with label declarations, on label per line:
        #label 0123 LabelAtAddr0x0123
        #label affe LabelAtAddr0xAFFE
        ...
     


save

public void save(java.lang.String name,
                 java.lang.String dir)

getSize

public int getSize()
getSize interfaces Memory, same as getMemorySize()


setSize

public void setSize(int n_words)
             throws java.lang.Exception
setSize interfaces Memory, no function

Throws:
java.lang.Exception

getBitsPerWord

public int getBitsPerWord()
getBitsPerWord interfaces Memory, same as getWordWidth()


setBitsPerWord

public void setBitsPerWord(int n_bits)
                    throws java.lang.Exception
setBitsPerWord interfaces Memory, no function

Throws:
java.lang.Exception

canChangeSize

public boolean canChangeSize()
canChangeSize interfaces Memory, size is fixed!


getDataAt

public long getDataAt(int address)
getDataAt interfaces Memory, same as readMemory()


setDataAt

public void setDataAt(int address,
                      long value)
setDataAt interfaces Memory, same as writeMemory()


getDataArray

public long[] getDataArray()
getDataArray interfaces Memory, read the whole memory


setDataArray

public void setDataArray(long[] data)
setDataArray interfaces Memory, write a memory-block


parse

public boolean parse(java.io.BufferedReader reader)
              throws java.lang.Exception
parse interfaces Memory, no function

Throws:
java.lang.Exception

merge

public boolean merge(java.io.BufferedReader reader)
              throws java.lang.Exception
merge interfaces Memory, no function

Throws:
java.lang.Exception

save

public boolean save(java.io.PrintWriter PW)
             throws java.lang.Exception
save interfaces Memory, no function

Throws:
java.lang.Exception

getResourcename

public java.lang.String getResourcename()
getResourcename interfaces Memory, uses filename


setResourcename

public void setResourcename(java.lang.String name)
setResourcename interfaces Memory, uses filename


addMemoryListener

public void addMemoryListener(MemoryListener ML)

removeMemoryListener

public void removeMemoryListener(MemoryListener ML)