JOP - Java Optimized Processor
|
Home |
Getting StartedThis document is also available as PDF: An Introduction to the Design Flow for JOP This section describes the design flow for JOP - how to build the Java processor and a Java application from scratch (the VHDL and Java sources) and download the processor to an FPGA and the Java application to the processor. 1 IntroductionJOP [2], the Java optimized processor, is an open-source development platform available for different targets (Altera and Xilinx FPGAs and various types of FPGA boards). To support several targets, the design-flow is a little bit complicated. There is a Makefile available and when everything is set up correctly, a simplemakeshould build everything from the sources and download a Hello World example. However, to customize the Makefile for a different target it is necessary to understand the complete design flow. It should be noted that an Ant1 based build process is also available. 1.1 ToolsAll needed tools are freely available.
javac gcc make cvs quartus_mapAll the executables should be found and usually report their usage. 1.2 Getting StartedThis section shows a quick step-by-step build of JOP for the Cyclone target in the minimal configuration. All directory paths are given relative to the JOP root directory jop. The build process is explained in more detail in one of the following sections.1.2.1 Download the SourceCreate a working directory and download JOP from the www.opencores.org CVS server:cvs -d :pserver:anonymous@cvs.opencores.org:/cvsroot/anonymous \ -z9 co -P jopAll sources are downloaded to a directory jop. For the following command change to this directory. Create the needed directories with: make directories 1.2.2 ToolsThe tools contain Jopa, the microcode assembler, JopSim, a Java based simulation of JOP, and JOPizer, the application builder. The tools are built with following make command:make tools 1.2.3 Assemble the Microcode JVM, Compile the ProcessorThe JVM configured to download the Java application from the serial interface is built with:make jopserThis command also invokes Quartus to build the processer. If you want to build it within Quartus follow the following instructions: Start Quartus II and open the project jop.qpf from directory quartus/cycmin in Quartus with File - Open Project.... Start the compiler and fitter with Processing - Start Compilation. After successful compilation the FPGA is configured with Tools - Programmer and Start. 1.2.4 Compiling and Downloading the Java ApplicationA simple Hello World application is the default application in the Makefile. It is built and downloaded to JOP with:make jappThe "Hello World" message should be printed in the command window. For a different application change the Makefile targets or override the make variables at the command line. The following example builds and runs some benchmarks on JOP: make japp -e P1=bench P2=jbe P3=DoAllThe three variables P1, P2, and P3 are a shortcut to set the directory, the package name, and the main class of the application. 1.2.5 USB based BoardsSeveral Altera based boards use an FTDI FT2232 USB chip for the FPGA and Java program download. To change the download flow for those boards change the value of the following variable in the Makefile to true:USB=trueThe Java download channel is mapped to a virtual serial port on the PC. Check the port number in the system properties and set the variable COM_PORT accordingly. 1.3 Xilinx Spartan-3 Starter KitThe Xilinx tool chain is still not well supported by the Makefile or the Ant design flow. Here is a short list on how to build JOP for a Xilinx board:make tools cd asm jopser cd ..Now start the Xilinx IDE wirh the project file jop.npl. It will be converted to a new (binary) jop.ise project. The .npl project file is used as it is simple to edit (ASCII).
make java_app make downloadNow your first Java program runs on JOP/Spartan-3! 2 Booting JOP - How Your Application StartsBasically this is a two step process: (a) configuration of the FPGA and (b) downloading the Java application. There are different possibilities to perform these steps.2.1 FPGA ConfigurationFPGAs are usually SRAM based and lose their configuration after power down. Therefore the configuration has to be loaded on power up. For development the FPGA can be configured via a download cable (with JTAG commands). This can be done within the IDEs from Altera and Xilinx or with command line tools such as quartus_pgm or jbi32. For the device to boot automatically, the configuration has to be stored in non volatile memory such as Flash. Serial Flash is directly supported by an FPGA to boot on power up. Another method is to use a standard parallel Flash to store the configuration and additional data (e.g. the Java application). A small PLD reads the configuration data from the Flash and shifts it into the FPGA. This method is used on the Cyclone and ACEX boards.2.2 Java DownloadWhen the FPGA is configured the Java application has to be downloaded into the main memory. This download is performed in microcode as part of the JVM startup sequence. The application is a .jop file generated by JOPizer. At the moment there are three options:
2.3 CombinationsTheoretically all variants to configure the FPGA can be combined with all variations to download the Java application. However, only two combinations are useful:
3 The Design FlowThis section describes the design flow to build JOP in greater detail.3.1 ToolsThere are a few tools necessary to build and download JOP to the FPGA boards. Most of them are written in Java. Only the tools that access the serial line are written in C.33.1.1 DownloadingThese little programs are already compiled and the binaries are checked in into the repository. The sources can be found in directory c_src.
3.1.2 Generation of FilesThese tools are written in Java and are delivered in source form. The source can be found under java/tools/src and the class files are in jop-tools.jar in directory java/tools/dist/lib.
3.1.3 Simulation
3.2 TargetsJOP has been successfully ported to several different FPGAs and boards. The main distribution contains the ports for the FPGAs:
3.2.1 Cyclone EP1C6/12This board is the workhorse for the JOP development and comes in two versions: with an Cyclone EP1C6 or EP1C12. The schematics can be found in Appendix . The board contains:
3.2.2 Xilinx Spartan-3The Spartan-3 specific files are jop_xs3.vhd and mem_xs3.vhd for the Xilinx Spartan-3 Starter Kit and jop_trenz.vhd and mem_trenz.vhd for the Trenz Retrocomputing board.4 EclipseIn folder eclipse there are four Eclipse projects that you can import into your Eclipse workspace. However, do not use that directory as your workspace directory. Choose a directory outside of the JOP source tree for the workspace. All projects use the Eclipse path variable6 JOP_HOME that has to point to the root directory (.../jop) of the JOP sources. Under Window - Preferences... select General - Workspace - Linked Resources and create the path variable JOP_HOME with New.... Import the projects with File - Import.. and Existing Projects into Workspace. It is suggested to an Eclipse workspace that is not part of the jop source tree. Select as root directory .../jop/eclipse, select the projects you want to import, select Copy projects into workspace, and press Finish. Table 2 shows all available projects.
5 SimulationThis section contains the information you need to get a simulation of JOP running. There are two ways to simulate JOP:
5.1 JopSim SimulationThe high level simulation with JopSim is a simple JVM written in Java that can execute the JOP specific application (the .jop file). It is started with:make jsimTo output each executing bytecode during the simulation run change in the Makefile the logging parameter to -Dlog="true". 5.2 VHDL SimulationThis section is about running a VHDL simulation with ModelSim. All simulation files are vendor independent and should run on any versions of ModelSim or a different VHDL simulator. You can simulate JOP even with the free ModelSim XE II Starter Xilinx version, the ModelSim Altera version or the ModelSim Actel version. To simulate JOP, or any other processor design, in a vendor neutral way, models of the internal memories (block RAM) and the external main memory are necessary. Beside this, only a simple clock driver is necessary. To speed-up the simulation a little bit, a simulation of the UART output, which is used for System.out.print(), is also part of the package. Table 3 lists the simulation files for JOP and the programs that generates the initialization data. The non-generated VHDL files can be found in directory vhdl/simulation.
make simAfter a few seconds you should see the startup message from JOP printed in ModelSim's command window. The simulation can be continued with run -all and after around 6 ms simulation time the actual Java main() method is executed. During those 6 ms, which will probably be minutes of simulation, the memory is initialized for the garbage collector. 6 Files Types You Might EncounterAs there are various tools involved in the complete build process, you will find files with various extensions. The following list explains the file types you might encounter when changing and building JOP. The following files are the source files:
7 Information on the WebFurther information on JOP and the build process can be found on the Internet at the following places:
8 Porting JOPPorting JOP to a different FPGA platform or board usually consists of adapting pin definitions and selection of the correct memory interface. Memory interfaces for the SimpCon interconnect can be found in directory vhdl/memory.8.1 Test UtilitiesTo verify that the port of JOP is successful there are some small test programs in asm/src. To run the JVM on JOP the microcode jvm.asm is assembled and will be stored in an on-chip ROM. The Java application will then be loaded by the first microcode instructions in jvm.asm into an external memory. However, to verify that JOP and the serial line are working correctly, it is possible to run small test programs directly in microcode. One test program (blink.asm) does not need the main memory and is a first test step before testing the possibly changed memory interface. testmon.asm can be used to debug the main memory interface. Both test programs can be built with the make targets jop_blink_test and jop_testmon.8.1.1 Blinking LED and UART outputThe test is built with:make jop_blink_testAfter download, the watchdog LED should blink and the FPGA will print out 0 and 1 on the serial line. Use a terminal program or the utility e.exe to check the output from the serial line. 8.1.2 Test MonitorStart a terminal program (e.g. HyperTerm) to communicate with the monitor program and build the test monitor with:make jop_testmonAfter download the program prints the content of the memory at address 0. The program understands following commands:
9 Extending JOPJOP is a soft-core processor and customizing it for an application is an interesting opportunity.9.1 Native MethodsThe native language of JOP is microcode. A native method is implemented in JOP microcode. The interface to this native method is through a special bytecode. The mapping between native methods and the special bytecode is performed by JOPizer. When adding a new (special) bytecode to JOP, the following files have to be changed:
9.2 A new Peripheral DeviceCreation of a new peripheral devices involves some VHDL coding. However, there are several examples in jop/vhdl/scio available. All peripheral components in JOP are connected with the SimpCon [3] interface. For a device that implements the Wishbone [1] bus, a SimpCon-Wishbone bridge (sc2wb.vhd) is available (e.g., it is used to connect the AC97 interface in the dspio project). For an easy start use an existing example and change it to your needs. Take a look into sc_test_slave.vhd. All peripheral components (SimpCon slaves) are connected in one module usually named scio_xxx.vhd. Browse the examples and copy one that best fits your needs. In this module the address of your peripheral device is defined (e.g. 0x10 for the primary UART). This I/O address is mapped to a negative memory address for JOP. That means 0xffffff80 is added as a base to the I/O address. By convention this address mapping is defined in com.jopdesign.sys.Const. Here is the UART example:// use negative base address for fast constant load // with bipush public static final int IO_BASE = 0xffffff80; ... public static final int IO_STATUS = IO_BASE+0x10; public static final int IO_UART = IO_BASE+0x10+1;The I/O devices are accessed from Java by native8 functions: Native.rdMem() and Native.wrMem() in pacakge com.jopdesign.sys. Again an example with the UART: // busy wait on free tx buffer // no wait on an open serial line, just wait // on the baud rate while ((Native.rdMem(Const.IO_STATUS)&1)==0) { ; } Native.wrMem(c, Const.IO_UART);Best practise is to create a new I/O configuration scio_xxx.vhdl and a new Quartus project for this configuration. This avoids the mixup of the changes with a new version of JOP. For the new Quartus project only the three files jop.cdf, jop.qpf, and jop.qsf have to be copied in a new directory under quartus. This new directory is the project name that has to be set in the Makefile: QPROJ=yourprojectThe new VHDL module and the scio_xxx.vhdl are added in jop.qsf. This file is a plain ASCII file and can be edited with a standard editor or within Quartus. 9.3 A Customized InstructionA customized instruction can be simply added by implementing it in microcode and mapping it to a native function as described before. If you want to include a hardware module that implements this instruction a new microinstruction has to be introduced. Besides mapping this instruction to a native method the instruction has also be added to the microcode assembler Jopa.9.4 Dependencies and ConfigurationsAs JOP and the JVM are a mix of VHDL and Java files, changes in the central data structures or some configurations needs an update in several files.9.4.1 Stack SizeThe on-chip stack size can be configured by changing following constants:
9.4.2 Changing the Class Format
References
Footnotes:1http://ant.apache.org/ 2All addresses in JOP are counted in 32-bit quantities. However, the Flash is connected only to the lower 8 bits of the data bus. Therefore a store of one word in the main memory needs four loads from the Flash. 3The Java JDK still comes without the javax.comm package and getting this optional package correctly installed is not that easy. 4http://jakarta.apache.org/bcel/ 5http://www.jopwiki.com/FPGA_boards 6Eclipse (path) variables are workspace specific. 7Eclipse can't use path variables for external .jar files. 8These are not real functions and are substituted by special bytecodes on application building with JOPizer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Copyright © 2000-2007, Martin Schoeberl
|