|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbyucc.jhdl.base.CompiledCodeGenerator
This class is a generic interface for compiled code simulators. The default JHDL MCSimulator is used to do all of the scheduling of circuit elements. At the level where the various PropagateableLists are fired during simulation, this interface allows that part of the inner loop to be offloaded into a compiled code backend. The class was written with the principal intent to allow my bytecode compiled code version to be leveraged to support native assembly code. Admittedly, I know relatively little about assembly programming, and simply make a naive attempt to make a generic interface that abstracts much of the complexities of dealing with JHDL simulation. The basic idea is the concept of a location. The abstract methods implemented by a particular back end operate on locations (in assembly I thought of either addresses or registers, for the byte codes it would be stack location (almost always the top). The initializeCode() method is used to set up the global data structures needed for the operation of the simulation. The array of value propagaters is used extensively to create the code. The extending classes must know how to retrieve information from a ValuePropagater and store information to it. The implementation is left up to the user. Another important concept is the label. It is assumed that the code is generated as the abstract methods are called. The setLabelLocation() method is called where the jump label needs to be. So, a gotoLabel() will occur before the label location is set (we don't know where it is yet!)
Field Summary | |
protected static boolean |
DEBUG
|
protected static long |
multiputs
|
protected byucc.jhdl.base.ValuePropagater[] |
vp_array
|
Constructor Summary | |
CompiledCodeGenerator(byucc.jhdl.base.ClockableList cl)
Generates code for a clockable list. |
|
CompiledCodeGenerator(byucc.jhdl.base.PropagateableList pl)
Generates code for a PropagateableList. |
Method Summary | |
abstract int |
andIntegers(int location1,
int location2)
Perform a bitwise AND on two locations. |
abstract int |
andIntegerWithConstant(int location,
int constant)
Perform a bitwise AND on a constant and a value |
abstract void |
finalizeCode()
Do things like compilation, writing to file, anything necessary to prepare the code for running. |
protected void |
generateCodeForClockable(Clockable c)
|
protected void |
generateCodeForPropagateable(byucc.jhdl.base.Propagateable p)
|
protected int |
getVPWireValue(int index)
|
abstract void |
gotoLabel(java.lang.String label)
Jump! Now! |
abstract void |
gotoLabelIfLtZero(int location,
java.lang.String label)
If the value in location is less than zero, then branch to the label. |
abstract void |
handleUnrecognizedPropagateable(byucc.jhdl.base.Propagateable p,
int index)
Handle a Propagateable that the CompiledCodeGenerator can't. |
protected void |
initGlobalVPArray(byucc.jhdl.base.ClockableList cl)
|
protected void |
initGlobalVPArray(byucc.jhdl.base.PropagateableList pl)
|
abstract void |
initializeCode()
Performs necessary code initialization. |
abstract int |
loadConstant(int constant)
Load a constant into a location. |
abstract int |
loadVPDataField(int index)
Loads the data field of a ValuePropagater. |
abstract int |
notInteger(int location)
Perform a bitwise NOT on a value |
abstract int |
orIntegers(int location1,
int location2)
Perform a bitwise OR on two locations. |
abstract int |
orIntegerWithConstant(int location,
int constant)
Perform a bitwise OR on a constant and a value |
abstract void |
printDebugInfo()
Embed code to print debug information. |
abstract void |
printLocationContents(int location)
Embed code to print the contents of a location. |
abstract void |
printMessage(java.lang.String msg)
Embed code to print a message. |
protected void |
putVPWireValue(int location,
int index)
|
abstract void |
setLabelLocation(java.lang.String label)
Mark the current point in the generated code with this label. |
abstract int |
shiftLeft(int location,
int shift_amt)
Shifts a value left by shift_amt places. |
abstract int |
shiftRightLogical(int location,
int shift_amt)
Shifts a value right by shift_amt places. |
abstract void |
simulate()
Execute the generated Code. |
abstract void |
storeVPDataField(int location,
int index)
Stores a value into the data field of a ValuePropagater. |
int |
type()
This method returns one of the predefined schematic constants to identify the type of this cell. |
abstract int |
xorIntegers(int location1,
int location2)
Perform a bitwise XOR on two locations. |
abstract int |
xorIntegerWithConstant(int location,
int constant)
Perform a bitwise XOR on a constant and a value |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static boolean DEBUG
protected static long multiputs
protected byucc.jhdl.base.ValuePropagater[] vp_array
Constructor Detail |
public CompiledCodeGenerator(byucc.jhdl.base.PropagateableList pl)
pl
- Contains cells and wires to simulate.public CompiledCodeGenerator(byucc.jhdl.base.ClockableList cl)
cl
- Contains synchronous elements to simulate.Method Detail |
public abstract void initializeCode()
public abstract void finalizeCode()
public abstract int loadVPDataField(int index)
index
- Index of the ValuePropagater to load
public abstract void storeVPDataField(int location, int index)
location
- the location of the value to storeindex
- Index of the ValuePropagater to store intopublic abstract int andIntegerWithConstant(int location, int constant)
location
- location of the non-constant valueconstant
- the constant to AND with
public abstract int andIntegers(int location1, int location2)
location1
- first locationlocation2
- second location
public abstract int orIntegerWithConstant(int location, int constant)
location
- location of the non-constant valueconstant
- the constant to AND with
public abstract int orIntegers(int location1, int location2)
location1
- first locationlocation2
- second location
public abstract int xorIntegerWithConstant(int location, int constant)
location
- location of the non-constant valueconstant
- the constant to AND with
public abstract int xorIntegers(int location1, int location2)
location1
- first locationlocation2
- second location
public abstract int notInteger(int location)
location
- location of the non-constant value
public abstract int shiftLeft(int location, int shift_amt)
location
- the location of the value to shiftshift_amt
- how many places to shift
public abstract int loadConstant(int constant)
constant
- constant to load
public abstract int shiftRightLogical(int location, int shift_amt)
location
- the location of the value to shiftshift_amt
- how many places to shift
public abstract void printMessage(java.lang.String msg)
msg
- public abstract void printDebugInfo()
public abstract void printLocationContents(int location)
location
- public abstract void gotoLabelIfLtZero(int location, java.lang.String label)
location
- location of the int to compare to zerolabel
- branch label to jump topublic abstract void gotoLabel(java.lang.String label)
label
- branch label to jump topublic abstract void setLabelLocation(java.lang.String label)
label
- the branch labelpublic abstract void handleUnrecognizedPropagateable(byucc.jhdl.base.Propagateable p, int index)
p
- the unrecognized Propagateableindex
- the wire index of the first input to the cell
(indexes into the global ValuePropagater array)public abstract void simulate()
protected int getVPWireValue(int index)
protected void putVPWireValue(int location, int index)
protected void initGlobalVPArray(byucc.jhdl.base.PropagateableList pl)
protected void initGlobalVPArray(byucc.jhdl.base.ClockableList cl)
protected void generateCodeForPropagateable(byucc.jhdl.base.Propagateable p)
protected void generateCodeForClockable(Clockable c)
public int type()
PreDefinedSchematic
type
in interface PreDefinedSchematic
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |