Hades logoHades applet banner
Femtojava processor: factorial

applet icon

The image above shows a thumbnail of the interactive Java applet embedded into this page. Unfortunately, your browser is not Java-aware or Java is disabled in the browser preferences. To start the applet, please enable Java and reload this page. (You might have to restart the browser.)

Circuit Description

This applet demonstrates a simulation of a example using the component FemtoJavaProcessor to calculate the factorial of the given input value. The Femtojava processor is a Java Microcontroller with 4 input ports, 4 output ports, 2 external interrupt inputs, and 1 serial port. It uses It uses a reduced-instruction-set Harvard architecture, and runs a subset of JAVA bytecode.

FemtoJava instruction set: Instruction type Arithmetic and logic Control flow Stack Load/store Array Extended Others Mnemonics iadd, isub, imul, ineg, ishr, ishl, iushr, iand, ior, and ixor goto, ifeq, ifne, iflt, ifge, ifgt, ifle, if_icmpeq, if_icmpne, if_icmplt, if_icmpge, if_icmpgt, if_icmple, return, ireturn, and invokestatic iconst_m1, iconst_0, iconst_1, iconst_2, iconst_3, iconst_4, iconst_5, bipush, pop, pop2, dup, dup_x1, dup_x2, dup2, dup2_x1, and swap iload, iload_0, iload_1, iload_2, iload_3, istore, istore_0, istore_1, istore_2, and istore_3 iaload, baload, caload, saload, iastore, bastore, castore, sastore, and arraylength load_idx, store_idx, and sleep nop, iinc, getstatic, putstatic

The user write a Java source at following format:

The designer can model, simulate, and build the system implementation directly in Java. We provide libraries that improve simulation accuracy and allow direct mapping of classes used by simulation to actual code in the final implementation. These predefined classes also cover all the details required to interface the microcontroller with the real world (interrupt mechanism programming, communication with LCD displays, and keyboards). A set of tools can help the designer predict the final system performance and costs. The design process is based on the Sashimi design environment. Sashimi uses freely available tools, like the Java compiler and the JVM included in the Java development kit (JDK). In addition, we also provided tools specifically designed for Sashimi. IT IS POSSIBLE to synthesize small Java microcontrollers in a single FPGA chip.

The microcontroller executes Java bytecodes natively, with no new compiler or JVM implementation required. Because they are reconfigurable, the FPGA devices provide opportunities to update microcontroller capabilities. The design environment fully supports generating an optimized microcontroller and the adapted code. Please look at the following papers to learn more about Sashimi Project from Universidade Federal do Rio Grande do SUL (UFRGS), Brazil, Prof. Luigi Carro (supervisor); The FemtoJava as a HADES component was written by Aroldo Ferreira, André Bigonha, Alisson Garcia and Ricardo Ferreira from Universidade Federal of Vicosa, Viçosa, Brazil.

BECK FILHO, Antonio Carlos ; MATTOS, Julio ; WAGNER, Flavio ; CARRO, L. . CACO PS - A General Purpose Cycle-accurate Configurable Power Simulator. In: 16th Symposium on Integrated Circuits and Systems Design, 2003, São Paulo. Proceedings. Los Alamitos : IEEE Computer Society Press, 2003. v. 1. p. 349-354.

ITO, S., CARRO, L., JACOBI, R. Sashimi and FemtoJava: making Java work for microcontroller applications. IEEE Design & Test of Computers. Estados Unidos: , p.100 - 110, 2001. The authors investigate complete system development using a Java machine aimed at FPGA devices. A new design strategy targets a single FPGA chip, within which the dedicated Java microcontroller--FemtoJava--is synthesized.

FemtoJavaProcessor Description: The component FemtoJavaProcessor is used to simulate FemtoJava programs codes on hades. To use this component the program code need to implement the Runnable interface, and have a copy of initSystem on method run. It's not necessary to implement the IOInterface, because this is already done by FemtoJavaProcessor.

Component full name: dpi.sashimi.FemtoJavaProcessor
Program: dpi.sashimi.FemtoJavaProgramTester
Restrictions: Only one component instance can be used on simulation, because it uses Sashimi API, which work with statics methods and variables.
How to use: First choose the number (from 0 to 6) at IpinVector. Then click calculate button to start the calculation. (Note that the algorithm as coded here uses 8-bit variables; therefore, input values above 6 cause an arithmetic overflow.)

Code:


package dpi.sashimi;
import saito.sashimi.*;

public class FemtoJavaProgramTester 
       implements IntrInterface, TimerInterface, Runnable {
    
    /** Creates a new instance of FemtoJavaProgramTester */
    
    public FemtoJavaProgramTester() {
        FemtoJavaTimer.setTimerClass(this);
        FemtoJavaInterruptSystem.setInterruptClass(this);
        
    }
    /**************************************************************************
    *                          VARIABLES
    *************************************************************************/        
    static int value;    
    static int result = 1;
    
    /**************************************************************************
    *                          MAIN FUNCTION
    *************************************************************************/    
    public static void initSystem()
    {                   
            FemtoJavaInterruptSystem.globalEnable();
            FemtoJavaInterruptSystem.enable(0xff);
            while(true)
            {
              
               FemtoJava.sleep();
            }
    }
    /**************************************************************************
     *                          INTERRUPTIONS
     *************************************************************************/    
    public void int0Method() {
	value = FemtoJavaIO.read(0);
	result = 1;
	if(value != 0)  {
		for(;value > 0; value-- ) {
			result *= value;
		}
	}
	FemtoJavaIO.write( result, 0 );
	}
    
    public void int1Method() {
    }
    
    public void spiMethod() {
    }
        
    public void tf0Method() {
    }
    
    public void tf1Method() {
    }
       
    /**************************************************************************
     *                          SIMULATION
     *************************************************************************/
    public void run() {
        initSystem();
    }    
}

Print version | Run this demo in the Hades editor (via Java WebStart)
Usage | FAQ | About | License | Feedback | Tutorial (PDF) | Referenzkarte (PDF, in German)
Impressum http://tams.informatik.uni-hamburg.de/applets/hades/webdemos/96-femtojava/factorial/factorial.html