de.cau.cs.kieler.krep.evalbench.smakc
Class KitAssembler

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

public class KitAssembler
extends Object
implements IAssembler

Assembler for Safe State Machines in the Kit format. This is mainly a wrapper for KepAssembler, into which SSMs are compiled.

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

Constructor Summary
KitAssembler()
          generate new empty assembler for kit files.
 
Method Summary
 int adr2row(int i)
          compute at which line in the assembler code a absolute pc is displayed.
 void assemble(String name, InputStream program)
          Assemble a given program string and generated object code in readable hex coded format and instruction array.
 void assemble(String name, 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

KitAssembler

public KitAssembler()
generate new empty assembler for kit files.

Method Detail

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

assemble

public void assemble(String name,
                     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:
name - Name of the program
program - assembler program
Throws:
ParseException - when the input string has an invalid format

assemble

public void assemble(String name,
                     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:
name - Name of the program
program - assembler program
Throws:
ParseException - when the input string has an invalid format

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.

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

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)

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

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

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

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