JOP Reference Handbook: Building Embedded Systems with a Java Processor
Total Page:16
File Type:pdf, Size:1020Kb
Downloaded from orbit.dtu.dk on: Sep 30, 2021 JOP Reference Handbook: Building Embedded Systems with a Java Processor Schoeberl, Martin Publication date: 2009 Document Version Publisher's PDF, also known as Version of record Link back to DTU Orbit Citation (APA): Schoeberl, M. (2009). JOP Reference Handbook: Building Embedded Systems with a Java Processor. http://www.jopdesign.com/ General rights Copyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright owners and it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights. Users may download and print one copy of any publication from the public portal for the purpose of private study or research. You may not further distribute the material or use it for any profit-making activity or commercial gain You may freely distribute the URL identifying the publication in the public portal If you believe that this document breaches copyright please contact us providing details, and we will remove access to the work immediately and investigate your claim. JOP Reference Handbook JOP Reference Handbook Building Embedded Systems with a Java Processor Martin Schoeberl Copyright c 2009 Martin Schoeberl Martin Schoeberl Strausseng. 2-10/2/55 A-1050 Vienna, Austria Email: [email protected] Visit the accompanying web site on http://www.jopdesign.com/ and the JOP Wiki at http://www.jopwiki.com/ Published 2009 by CreateSpace, http://www.createspace.com/ All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, recording or otherwise, without the prior written permission of Martin Schoeberl. Library of Congress Cataloging-in-Publication Data Schoeberl, Martin JOP Reference Handbook: Building Embedded Systems with a Java Processor / Martin Schoeberl Includes bibliographical references and index. ISBN 978-1438239699 Manufactured in the United States of America. Typeset in 11pt Times by Martin Schoeberl Foreword This book is about JOP, the Java Optimized Processor. JOP is an implementation of the Java virtual machine (JVM) in hardware. The main implementation platform is a field- programmable gate array (FPGA). JOP began as a research project for a PhD thesis. In the mean time, JOP has been used in several industrial applications and as a research platform. JOP is a time-predictable processor for hard real-time systems implemented in Java. JOP is open-source under the GNU GPL and has a growing user base. This book is written for all of you who build this lively community. For a long time the PhD thesis, some research papers, and the web site have been the main documentation for JOP. A PhD thesis focus is on research results and implementation details are usually omitted. This book complements the thesis and provides insight into the implementation of JOP and the accompanying JVM. Furthermore, it gives you an idea how to build an embedded real-time system based on JOP. V Acknowledgements Many users of JOP contributed to the design of JOP and to the tool chain. I also want to thank the students at the Vienna University of Technology during the four years of the course “The JVM in Hardware” and the students from CBS, Copenhagen at an embed- ded systems course in Java for the interesting questions and discussions. Furthermore, the questions and discussions in the Java processor mailing list provided valuable input for the documentation now available in form of this book. The following list of contributors to JOP is roughly in chronological order. Ed Anuff wrote testmon.asm to perform a memory interface test and BlockGen.java to con- vert Altera .mif files to Xilinx memory blocks. Flavius Gruian wrote the initial version of JOPizer to generate the .jop file from the application classes. JOPizer is based on the open source library BCEL and is a substitute to the formerly used JavaCodeCompact from Sun. Peter Schrammel and Christof Pitter have implemented the first version of long bytecodes. Rasmus Pedersen based a class on very small information systems on JOP and invited my to co-teach this class in Copenhagen. During this time the first version of the WCET analysis tool was developed by Rasmus. Rasmus has also implemented an Eclipse plugin for the JOP design flow. Alexander Dejaco and Peter Hilber have developed the I/O interface board for the LEGO Mindstorms. Christof Pitter designed and implemented the chip-multiprocessor (CMP) version of JOP during his PhD thesis. Wolfgang Puffitsch first contribution to JOP was the finalization of the floating point library SoftFloat. Wolfgang, now an active de- veloper of JOP, contributed several enhancements (e.g., exceptions, HW field access, data cache,...) and works towards real-time garbage collection for the CMP version of JOP. Alberto Andriotti contributed several JVM test cases. Stefan Hepp has implemented an op- timizer at bytecode level during his Bachelor thesis work. Benedikt Huber has redesigned the WCET analysis tool for JOP during his Master’s thesis. Trevor Harmon, who imple- mented the WCET tool Volta for JOP during his PhD thesis, helped me with proofreading of the handbook. Furthermore, I would like to thank Walter Wilhelm from EEG for taking the risk to ac- cept a JOP based hardware for the Kippfahrleitung project at a very early development stage of JOP. The development of JOP has received funding from the Wiener Innova- tionsfoderprogram¨ (Call IKT 2004) and from the EU project JEOPARD. Contents Foreword v Acknowledgements vii 1 Introduction 1 1.1 A Quick Tour on JOP ............................. 1 1.1.1 Building JOP and Running “Hello World” .............. 1 1.1.2 The Design Structure ......................... 2 1.2 A Short History ................................ 3 1.3 JOP Features ................................. 4 1.4 Is JOP the Solution for Your Problem? .................... 6 1.5 Outline of the Book .............................. 6 2 The Design Flow 9 2.1 Introduction .................................. 9 2.1.1 Tools ................................. 9 2.1.2 Getting Started ............................ 10 2.1.3 Xilinx Spartan-3 Starter Kit ..................... 11 2.2 Booting JOP — How Your Application Starts ................ 12 2.2.1 FPGA Configuration ......................... 12 2.2.2 Java Download ............................ 12 2.2.3 Combinations ............................. 13 2.2.4 Stand Alone Configuration ...................... 14 2.3 The Design Flow ............................... 15 2.3.1 Tools ................................. 15 2.3.2 Targets ................................ 16 2.4 Eclipse ..................................... 18 2.5 Simulation ................................... 19 2.5.1 JopSim Simulation .......................... 19 2.5.2 VHDL Simulation .......................... 20 X CONTENTS 2.6 Files Types You Might Encounter ...................... 21 2.7 Information on the Web ............................ 23 2.8 Porting JOP .................................. 23 2.8.1 Test Utilities ............................. 23 2.9 Extending JOP ................................ 24 2.9.1 Native Methods ............................ 25 2.9.2 A new Peripheral Device ....................... 25 2.9.3 A Customized Instruction ...................... 26 2.9.4 Dependencies and Configurations .................. 27 2.10 Directory Structure .............................. 28 2.10.1 The Java Sources for JOP ...................... 30 2.11 The JOP Hello World Exercise ........................ 30 2.11.1 Manual build ............................. 30 2.11.2 Using make .............................. 31 2.11.3 Change the Java Program ....................... 31 2.11.4 Change the Microcode ........................ 31 2.11.5 Use a Different Target Board ..................... 32 2.11.6 Compile a Different Java Application ................ 32 2.11.7 Simulation .............................. 33 2.11.8 WCET Analysis ........................... 33 3 Java and the Java Virtual Machine 35 3.1 Java ...................................... 35 3.1.1 History ................................ 37 3.1.2 The Java Programming Language .................. 38 3.2 The Java Virtual Machine ........................... 39 3.2.1 Memory Areas ............................ 40 3.2.2 JVM Instruction Set ......................... 40 3.2.3 Methods ............................... 42 3.2.4 Implementation of the JVM ..................... 43 3.3 Embedded Java ................................ 44 3.4 Summary ................................... 45 4 Hardware Architecture 47 4.1 Overview of JOP ............................... 47 4.2 Microcode ................................... 49 4.2.1 Translation of Bytecodes to Microcode ............... 49 CONTENTS XI 4.2.2 Compact Microcode ......................... 51 4.2.3 Instruction Set ............................ 52 4.2.4 Bytecode Example .......................... 53 4.2.5 Microcode Branches ......................... 54 4.2.6 Flexible Implementation of Bytecodes ................ 54 4.2.7 Summary ............................... 55 4.3 The Processor Pipeline ............................ 55 4.3.1 Java Bytecode Fetch ......................... 56 4.3.2 Microcode Instruction Fetch ..................... 57 4.3.3 Decode and Address Generation ................... 59 4.3.4 Execute ................................ 60 4.3.5 Interrupt Logic ............................ 61 4.3.6 Summary ..............................