arche
Class UP

java.lang.Object
  |
  +--physis.core.virtualmachine.VirtualMachine
        |
        +--physis.core.virtualmachine.PhysisVirtualMachine
              |
              +--arche.UP

public class UP
extends PhysisVirtualMachine

This universal processor is designed to increase the evolvability in Tierra-like systems. The main goal is to enable the evolution of the decoding system, here the processor structure and the instruction set.
The universal processor is something like the Universal Turing Machine. On the codetape the description of the processor is stored:
description_of_processor_P#self_replicating_code_for_P

WARNING FOR DEVELOPERS: The inner structure of this class is rather fragile! e.g. If you change one of the instructions, then you should the number_of_ops table! This class is meant to be ETERNAL! ;)


Field Summary
static short ADD
           
static short ALLOCATE
           
static short AND
           
static short B
          Blank (for separating different stacks for example).
private static int BEGIN
           
static short CDEC
           
static short CINC
           
static short CLEAR
           
static short COMPARE
           
static short DEC
           
private  int direction
          The actual direction (the communication partner).
static short DIV
           
static short DIVIDE
           
static short FORK_TH
           
static short GDIR
           
static short I
          Instruction
static short IFNOTZERO
           
static short IFZERO
           
static short IN
           
static short INC
           
private static int INSTRUCTION
           
private  short[][] instruction_table
           
private  Storage IP
           
static short IS_SEP
           
static short JUMP
           
static short KILL_TH
           
static short LOAD
           
static short MOD
           
static short MOVE
           
static short MUL
           
static short NEG
           
static short NOP
           
static short NOT
           
private  short[] operands
          puffer for operands - 3 is the maximum number of operands
static short OR
           
static short OUT
           
static short Q
          Queue
static short R
          Register.
static short RECIEVE
           
static short REL_LOAD
           
static short REL_STORE
           
static short S
          Stack
static short SDIR
           
static short SEND
           
static short SEPARATOR
          Separator
private  int separator_position
           
private  Storage[] ses
          The structural elements.
static short SHIFT_L
           
static short SHIFT_R
           
private  int ssize
           
static int STORAGE_ARRAY_SIZE
           
static short STORE
           
static short SUB
           
static short XOR
           
 
Fields inherited from class physis.core.virtualmachine.PhysisVirtualMachine
alien, bearer, blank, counter, gestation_time, GESTATION_TIME_INVALID, tape
 
Constructor Summary
UP()
           
 
Method Summary
 void add(int op1, int op2, int result)
           
 void allocate(int size_addr)
          Allocates memory with the specified size.
 void and(int op1, int op2, int result)
           
(package private)  void buildInstructionSet()
          Builds the instrucionset from the tape.
(package private)  void buildProcessor()
          The main for method for building the processor.
(package private)  void buildStructure(StorageArray sta)
          Builds the structural elements.
 void cdec(int n)
           
 void cinc(int n)
           
 void clear(int n)
           
 void compare(int op1, int op2, int result)
          Compares the content of the op1 and op2 and the result is stored in the result SE element.
(package private)  void createInstruction(int number, int start, int stop)
          Creates the NUMBERth instruction which is on the tape from start to stop.
 void dec(int what)
          Decrements the content of a structural element.
 void div(int op1, int op2, int result)
           
 void divide()
          The only one biological operation for cell division.
 void execute()
          Calling this method forces the machine to execute the next instruction.
 void execute(int numberofinstructions)
          Calling this method forces te VM to execute the next N instructions.
private  int fillOperands(int numops, short[] insts, int from)
           
 void fork_th(int pos)
           
 void gdir(int whereTo)
           
 Genome getGenome()
          Returns the genetic information.
 int getGenomeSize()
          Returns the size of the genome.
 java.lang.String getState()
          Returns the String representation of the current state of the virtualmachine including all stacks registers in the architecture and the instruction point by the instructionpointer: etc.
 void ifnotzero(int strel)
          Executes the next instruction if the content of thestructural element pointed by strel is zero.
 void ifzero(int strel)
          Executes the next instruction if the content of thestructural element pointed by strel is zero.
 void in(int destination)
          Reads one piece of data (an int) from the outside world (environment).
 void inc(int what)
          Increments the content of a structural element.
(package private)  void incrementIP(int value)
          The instruction pointer-register is incremented.
 void is_sep(int src, int dst)
           
private  boolean isCodeForStructruralElement(short c)
           
 void jump(int address)
          Jumps to the address (mod codetape size).
 void kill_th()
           
 void load(int source, int destination)
          Loads data from memory pointed by the source structural element.
 void mod(int op1, int op2, int result)
           
 void move(int source, int destination)
          Moves data between the SEs.
 void mul(int op1, int op2, int result)
           
 void neg(int op1, int result)
           
 void not(int op1, int result)
           
 void or(int op1, int op2, int result)
           
 void out(int source)
          Writes one piece of data (an int) to the outside world (environment).
 void receive(int dst)
          Receives a piece of data from an other processor.
 void rel_load(int base, int offset, int destination)
           
 void rel_store(int base, int offset, int from)
           
 void reset()
          Resets the virtual machine's state.
 void restart()
          This should be called after successfull proliferation.
 void sdir(int whereFrom)
          Th processor can communicate with other processors in its neighbourhood but only with one in a moment.
 void send(int src)
          Sends a piece of data to an other processor pointed by the direction.
(package private)  void setIP(int value)
          Directly sets the instruction pointer.
 void shift_l(int op1, int result)
           
 void shift_r(int op1, int result)
           
 void store(int destination, int data)
          Writes data to memory from the source structural element.
 void sub(int op1, int op2, int result)
           
 void xor(int op1, int op2, int result)
           
 
Methods inherited from class physis.core.virtualmachine.PhysisVirtualMachine
getBearer, getEffectiveLength, getGestationTime, loadCodeTape, setBearer
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

STORAGE_ARRAY_SIZE

public static final int STORAGE_ARRAY_SIZE

BEGIN

private static final int BEGIN

INSTRUCTION

private static final int INSTRUCTION

ses

private Storage[] ses
The structural elements. (SEs) This is basically a memory array. Its cells can be used by different data structures called structural elements (registers, queuse, stacks).

ssize

private int ssize

instruction_table

private short[][] instruction_table

separator_position

private int separator_position

direction

private int direction
The actual direction (the communication partner).

operands

private short[] operands
puffer for operands - 3 is the maximum number of operands

IP

private Storage IP

NOP

public static final short NOP

IN

public static final short IN

OUT

public static final short OUT

LOAD

public static final short LOAD

STORE

public static final short STORE

MOVE

public static final short MOVE

ALLOCATE

public static final short ALLOCATE

COMPARE

public static final short COMPARE

IFZERO

public static final short IFZERO

JUMP

public static final short JUMP

DEC

public static final short DEC

INC

public static final short INC

DIVIDE

public static final short DIVIDE

SDIR

public static final short SDIR

GDIR

public static final short GDIR

SEND

public static final short SEND

RECIEVE

public static final short RECIEVE

ADD

public static final short ADD

SUB

public static final short SUB

MUL

public static final short MUL

DIV

public static final short DIV

MOD

public static final short MOD

AND

public static final short AND

OR

public static final short OR

XOR

public static final short XOR

NEG

public static final short NEG

NOT

public static final short NOT

SHIFT_L

public static final short SHIFT_L

SHIFT_R

public static final short SHIFT_R

FORK_TH

public static final short FORK_TH

KILL_TH

public static final short KILL_TH

R

public static final short R
Register.

S

public static final short S
Stack

Q

public static final short Q
Queue

I

public static final short I
Instruction

B

public static final short B
Blank (for separating different stacks for example).

SEPARATOR

public static final short SEPARATOR
Separator

CLEAR

public static final short CLEAR

CINC

public static final short CINC

CDEC

public static final short CDEC

IS_SEP

public static final short IS_SEP

REL_LOAD

public static final short REL_LOAD

REL_STORE

public static final short REL_STORE

IFNOTZERO

public static final short IFNOTZERO
Constructor Detail

UP

public UP()
Method Detail

reset

public void reset()
Description copied from class: VirtualMachine
Resets the virtual machine's state.
Overrides:
reset in class VirtualMachine

restart

public void restart()
Description copied from class: PhysisVirtualMachine
This should be called after successfull proliferation. (it doesn't change the gestation_time to invalid)
Overrides:
restart in class PhysisVirtualMachine

getState

public java.lang.String getState()
Description copied from class: VirtualMachine
Returns the String representation of the current state of the virtualmachine including all stacks registers in the architecture and the instruction point by the instructionpointer: etc. It's mainly used by the debuggers or tracers.
Overrides:
getState in class VirtualMachine

execute

public void execute()
Description copied from class: VirtualMachine
Calling this method forces the machine to execute the next instruction. (Execution step by step).
Overrides:
execute in class VirtualMachine

fillOperands

private int fillOperands(int numops,
                         short[] insts,
                         int from)

execute

public void execute(int numberofinstructions)
Description copied from class: VirtualMachine
Calling this method forces te VM to execute the next N instructions.
Overrides:
execute in class VirtualMachine
Following copied from class: physis.core.virtualmachine.VirtualMachine
Parameters:
number_of_instructions - The exact number of the instructions to be executed.

getGenome

public Genome getGenome()
Description copied from class: PhysisVirtualMachine
Returns the genetic information.
Overrides:
getGenome in class PhysisVirtualMachine

getGenomeSize

public int getGenomeSize()
Description copied from class: PhysisVirtualMachine
Returns the size of the genome.
Overrides:
getGenomeSize in class PhysisVirtualMachine

buildProcessor

void buildProcessor()
The main for method for building the processor.

buildStructure

void buildStructure(StorageArray sta)
Builds the structural elements. Scans the symbols before the separator.

buildInstructionSet

void buildInstructionSet()
Builds the instrucionset from the tape. Scans the symbols before the separator.

createInstruction

void createInstruction(int number,
                       int start,
                       int stop)
Creates the NUMBERth instruction which is on the tape from start to stop.

incrementIP

void incrementIP(int value)
The instruction pointer-register is incremented. The codetape is circular.
Parameters:
value - the amount of incrementation

setIP

void setIP(int value)
Directly sets the instruction pointer.

in

public void in(int destination)
Reads one piece of data (an int) from the outside world (environment).
Parameters:
destination - Index for the structural element where to be loaded. It's counted modulo number_of_elements.

out

public void out(int source)
Writes one piece of data (an int) to the outside world (environment).
Parameters:
source - Index for the structural element of the source. It's counted modulo number_of_elements.

load

public void load(int source,
                 int destination)
Loads data from memory pointed by the source structural element. Only this and the store instruction can access the memory. (RISC style)
Parameters:
source - The index of the SE which contains the memory address.
destination - The index of the SE which is the destination.

store

public void store(int destination,
                  int data)
Writes data to memory from the source structural element. Only this and the store instruction can access the memory. (RISC style)
Parameters:
source - The index of the SE which contains the memory address.
destination - The index of the SE which is the destination.

move

public void move(int source,
                 int destination)
Moves data between the SEs.

allocate

public void allocate(int size_addr)
Allocates memory with the specified size. (The location is the end of the the organism by default in the Alife system.)
Parameters:
size_addr - is the structural elements' index.

compare

public void compare(int op1,
                    int op2,
                    int result)
Compares the content of the op1 and op2 and the result is stored in the result SE element. RESULT: negative if op1 < op2, zero if op1 = op2, positive if op1 > op2.

ifzero

public void ifzero(int strel)
Executes the next instruction if the content of thestructural element pointed by strel is zero.

jump

public void jump(int address)
Jumps to the address (mod codetape size). Address is in a SE.

dec

public void dec(int what)
Decrements the content of a structural element.

inc

public void inc(int what)
Increments the content of a structural element.

divide

public void divide()
The only one biological operation for cell division.

sdir

public void sdir(int whereFrom)
Th processor can communicate with other processors in its neighbourhood but only with one in a moment. (Later this can be paralleled).
Parameters:
whereFrom - The SE where the new direction is stored.

gdir

public void gdir(int whereTo)

send

public void send(int src)
Sends a piece of data to an other processor pointed by the direction.

receive

public void receive(int dst)
Receives a piece of data from an other processor.

add

public void add(int op1,
                int op2,
                int result)

sub

public void sub(int op1,
                int op2,
                int result)

mul

public void mul(int op1,
                int op2,
                int result)

div

public void div(int op1,
                int op2,
                int result)

mod

public void mod(int op1,
                int op2,
                int result)

and

public void and(int op1,
                int op2,
                int result)

or

public void or(int op1,
               int op2,
               int result)

xor

public void xor(int op1,
                int op2,
                int result)

neg

public void neg(int op1,
                int result)

not

public void not(int op1,
                int result)

shift_l

public void shift_l(int op1,
                    int result)

shift_r

public void shift_r(int op1,
                    int result)

fork_th

public void fork_th(int pos)

kill_th

public void kill_th()

clear

public void clear(int n)

cinc

public void cinc(int n)

cdec

public void cdec(int n)

is_sep

public void is_sep(int src,
                   int dst)

rel_load

public void rel_load(int base,
                     int offset,
                     int destination)

rel_store

public void rel_store(int base,
                      int offset,
                      int from)

ifnotzero

public void ifnotzero(int strel)
Executes the next instruction if the content of thestructural element pointed by strel is zero.

isCodeForStructruralElement

private boolean isCodeForStructruralElement(short c)