Hades logoHades applet banner
Femtojava processor: adder

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 an Adder using the component FemtoJavaProcessor. FemtojavaProcessor is a Java Microcontroller, 4 input ports, 4 output ports, 2 external interruptions, 1 serial port. FemtoJava is a Java microcontroller with 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. Design process The Sashimi design environment 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.Somador_lcd_femtoJava_hades Restrictions: Only one componemt instance can be used on simulation, because it uses Sashimi API, which only supports static methods and variables. How to use: First turn on the lcd clicking ON_OFF switch. Choose the input number values by clicking on IpinVectors, click on Send button to show the result.

Source Code:

/** File: Somador_lcd_femtoJava_hades.java
 @author: Aroldo Ferreira da Silva & Ricardo Santos Ferreira 
 Universidade Federal de Viçosa, Brazil
 http://www.dpi.ufv.br
 27/01/2004 - Update 27/01/2006
  
 Compute Sum of 2 input Integer at port 0 and 1, and send to lcd Hitashi 2x24.
   Switch On, LCD ON, choose the input number and press SEND....
   
   LCD port Data is connected to femtojava port 1 and RS and Enable signal to 
   port 0, bit 0 and bit 2. 
*/



package dpi.sashimi;

import saito.sashimi.*;


public class Somador_lcd_femtoJava_hades extends java.lang.Object implements IntrInterface, TimerInterface, Runnable {
   
    public static boolean notInitializedLCD = true; 
    
    public static int i = 0;  
    
    public static int int0 = 0;  // input 0
    public static int int1 = 0;  // input 1
    public static int sum = 0;  
    
    public static String copy_value;  
  
    public static char c; 
    
 
    public Somador_lcd_femtoJava_hades( ) {
        FemtoJavaInterruptSystem.setInterruptClass( this );
    }
    
            
    public static void initSystem() {
        FemtoJavaInterruptSystem.globalEnable();
        FemtoJavaInterruptSystem.enable( FemtoJavaInterruptSystem.INT0 );  
        FemtoJavaInterruptSystem.enable( FemtoJavaInterruptSystem.INT1 ); 
        
        while(true) {
            FemtoJava.sleep();
        }
         
    }
    
 
    
    public void int0Method() {
        
        int0 = FemtoJavaIO.read(0);  
        int1 = FemtoJavaIO.read(1);  
        sum = int0 + int1;   // compute Input0 plus Input 1   
         
        InitLCDDisplay();
	
        SendStringtoLCD("A = ");         
	// send input 0 to LCD
        copy_value = String.valueOf(int0);  
        SendStringtoLCD(copy_value);
	SendStringtoLCD("   B = ");
	copy_value = String.valueOf(int1);  
	SendStringtoLCD(copy_value);
	SendStringtoLCD(", A+B = ");            
        copy_value = String.valueOf(sum);  
        SendStringtoLCD(copy_value);
        
    }
    
    
    
    public void int1Method() {
          // init lcd Hitashi
        if ( notInitializedLCD ) 
		LCD_turnON();
            
        else 
                LCD_turnOFF();
            
    }
    
    public void tf0Method() { 
        
    }
    
    public void tf1Method() {
    }
    
    
    public void spiMethod() {
    }
    
    
    public void run() {
        initSystem();
    }
    
    public static void InitLCDDisplay() {
         // LCD initialize 
        FemtoJavaIO.write( 0, 0 );  
        FemtoJavaIO.write( 1, 1 );   
        FemtoJavaIO.write( 4, 0 );  
        FemtoJavaIO.write( 0, 0 );  
        
        // LCD cursor position 
        FemtoJavaIO.write( 128, 1 );  
        FemtoJavaIO.write( 4, 0 ); 
        FemtoJavaIO.write( 0, 0 ); 
    }
    
    /** Write a char at current LCD position */
    public static void SendChartoLCD(char c) {
    // put C on port 1  
        FemtoJavaIO.write( c, 1 );
    // send char rs=1, switch enable signal on port 0, bit 2 101 -> 001
        FemtoJavaIO.write( 5, 0 ); 
        FemtoJavaIO.write( 1, 0 );  
    }
    
    /** Send a LCD command */
    public static void SendCmdtoLCD(char c) {
         // put C on port 1  
        FemtoJavaIO.write( c, 1 );
    // send command rs=0, switch enable signal on port 0, bit 2 100 -> 000
        FemtoJavaIO.write( 4, 0 ); 
        FemtoJavaIO.write( 0, 0 );  

    }
    
    /** Write a string at current LCD position */
    public static void SendStringtoLCD(String s) {
    int i;
    char c;
    	for ( i = 0; i < s.length(); i++ ) {
            c = s.charAt(i);
            SendChartoLCD(c);
	}
    }
    
    public static void LCD_turnON() {
            FemtoJavaIO.write( 0, 0 );  
            FemtoJavaIO.write( 52, 1 );  // 8 bits mode, number of lines = 1
            FemtoJavaIO.write( 4, 0 ); 
            FemtoJavaIO.write( 0, 0 );  
            
            
            FemtoJavaIO.write( 14, 1 );   // switch on display, cursor at 0,0  
            FemtoJavaIO.write( 4, 0 ); 
            FemtoJavaIO.write( 0, 0 );  
            
            FemtoJavaIO.write( 1, 1 );   // clear display
            FemtoJavaIO.write( 4, 0 ); 
            FemtoJavaIO.write( 0, 0 );  
            
            
            FemtoJavaIO.write( 6, 1 );  // cursor moving from left to right
            FemtoJavaIO.write( 4, 0 ); 
            FemtoJavaIO.write( 0, 0 );
            
               notInitializedLCD = false; 
   }
   
   public static void LCD_turnOFF() {
            // lcd OFF
            FemtoJavaIO.write( 0, 0 ); 
            FemtoJavaIO.write( 9, 1 );  
            FemtoJavaIO.write( 4, 0 ); 
            FemtoJavaIO.write( 0, 0 ); 
            
            notInitializedLCD = true; 
            
            int0 = int1 = sum = 0;
   }
    
}

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/adder/adder.html