de.cau.cs.kieler.krep.evalbench.program
Class LstAssembler

java.lang.Object
  extended by de.cau.cs.kieler.krep.evalbench.program.LstAssembler
All Implemented Interfaces:
IAssembler

public final class LstAssembler
extends Object
implements IAssembler

Read generated KEP lst file, which generated externally, eg, by kasm2kepe.

Rating yellow
(2010-02-05) review by cmot, msp

Constructor Summary
LstAssembler()
          Creates a new external assembler instance.
 
Method Summary
 int adr2row(int i)
          compute at which line in the assembler code a absolute pc is displayed.
 void assemble(String progName, InputStream program)
          Assemble a given program string and generated object code in readable hex coded format and instruction array.
 void assemble(String progName, String program)
          Assemble a given program string and return object code information in readable hex coded format.
 String canExecute(IConfig c)
          Check whether the Assembler can be executed on the current processor This should check, whether the correct processor (KEP/KReP) is used, and whether it has enough resources, like number of signals, etc.
 LinkedList<Signal> getInputs()
          After a program has been assembled, a list of input signals can be extracted.
 String[][] getInstructions()
          After a program has been assembled, an array with the contained instructions can be extracted.
 String getName()
          
 String[] getObj(IConfig c)
          After a program has been assembled, an array with the contained object-code can be extracted.
 LinkedList<Signal> getOutputs()
          After a program has been assembled, a list of output signals can be extracted.
 HashMap<String,Integer> getSignalIndex()
          
 int getTickLen()
          
 int size()
          The number of instructions in the program.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LstAssembler

public LstAssembler()
Creates a new external assembler instance.

Method Detail

assemble

public void assemble(String progName,
                     String program)
              throws ParseException
Assemble a given program string and return object code information in readable hex coded format. In the returned array each string represents an instruction.

Specified by:
assemble in interface IAssembler
Parameters:
progName - Name of the program
program - assembler program
Throws:
ParseException - when the input string has an invalid format

assemble

public void assemble(String progName,
                     InputStream program)
              throws ParseException
Assemble a given program string and generated object code in readable hex coded format and instruction array.

Specified by:
assemble in interface IAssembler
Parameters:
progName - Name of the program
program - assembler program
Throws:
ParseException - when the input string has an invalid format

getInputs

public LinkedList<Signal> getInputs()
After a program has been assembled, a list of input signals can be extracted.

Specified by:
getInputs in interface IAssembler
Returns:
list of input signals of the last assembled program

getOutputs

public LinkedList<Signal> getOutputs()
After a program has been assembled, a list of output signals can be extracted.

Specified by:
getOutputs in interface IAssembler
Returns:
list of output signals of the last assembled program

getInstructions

public String[][] getInstructions()
After a program has been assembled, an array with the contained instructions can be extracted. Each array element is a triple of strings; the first string contains the instruction index; the second one contains a label name, e.g. "loop0:", or an empty string if there is no label for that instruction. The third string contains the readable assembler instruction code.

Specified by:
getInstructions in interface IAssembler
Returns:
array with instructions (nr., label, code)

canExecute

public String canExecute(IConfig c)
Check whether the Assembler can be executed on the current processor This should check, whether the correct processor (KEP/KReP) is used, and whether it has enough resources, like number of signals, etc.

Specified by:
canExecute in interface IAssembler
Parameters:
c - the configuration
Returns:
null if processor can execute this program. Otherwise a detailed message why the execution is not possible is returned.

getObj

public String[] getObj(IConfig c)
After a program has been assembled, an array with the contained object-code can be extracted.

Specified by:
getObj in interface IAssembler
Parameters:
c - configuration of the current processor
Returns:
array with hex-code

getSignalIndex

public HashMap<String,Integer> getSignalIndex()

Specified by:
getSignalIndex in interface IAssembler
Returns:
mapping to get signal index for each valid signal in the program

adr2row

public int adr2row(int i)
compute at which line in the assembler code a absolute pc is displayed. This takes label into account.

Specified by:
adr2row in interface IAssembler
Parameters:
i - absolute address in memory
Returns:
the line in the source code

size

public int size()
The number of instructions in the program. This value is only available after the assembling took place.

Specified by:
size in interface IAssembler
Returns:
size of the program in instructions.

getName

public String getName()

Specified by:
getName in interface IAssembler
Returns:
the human readable name of the assembler

getTickLen

public int getTickLen()

Specified by:
getTickLen in interface IAssembler
Returns:
maximal number of instructions in one tick for this program