labs.beatcraft.com
DE0-Nano

DE0-Nano/JavaRock

This article explains how to install JavaRock and executes a sample program on DE0-Nano. JavaRock is a high-level synthesis tool, which generates VHDL and Verilog HDL code from Java code. DE0-Nano is a FPGA board, which is developed by Terasic Technologies Inc.

This article is organized as it is followed:

  • About Host Machine
    This section shows the set up. It uses a virtual machine (Ubuntu 12.04LTS, 32bit version) runs on a Windows PC. The applications use here are also listed.

  • Configuring Ubuntu and Editing Files
    This section explains how to install the development tools on Windows as well as Ubuntu and how to modify the configuration files for working with DE0-Nano.

  • Writing to DE0-Nano
    It shows how to transfer the program from Ubuntu to DE0-Nano and to run a sample program on DE0-Nano. This sample program lets an LED blink.

About Host Machine

These are details of the host machine.

OS:

  • Host OS: Windows 7 (64bit version, hereafter “Windows”)
  • Guest OS: Ubuntu 12.04 LTS (32bit version, hereafter “Ubuntu”)

Applications:

  • VMware Player (Windows, 64bit version)
  • DE0-Nano System Builder (Windows)
  • Quartus II 12.0sp1 (Ubuntu, hereafter “Quartus”)

    Create Ubuntu image on VMware Player. Its disk size is 20GB.

    DE0-Nano System Builder is an application, which generates the project file (qpf) and pin-assignment configuration file (qsf) for FE0-Nano, which is a product of Terasic Technologies Inc. DE0-Nano System Builder runs only on Windows.

    Quartus is a design and development tool for FPGA and CPLD. This is created by Altera Corporation.

    Quartus is installed on Ubuntu. 12.0sp1 version of Quartus is used for this project. This is not the newest version of Quartus, but this version is recommended by the creator of JavaRock. Please download Quartus 12.0sp1.

Configuring Ubuntu and Editing Files

This part explains how to set up the guest OS of Ubuntu.

Installing the development tool

Install the development tool and OpenJDK. The former is used for installing Quartus, and OpenJDK, which enables JavaRock.

$ sudo apt-get install build-essential
$ sudo apt-get install openjdk-7-jdk

Adding udev rules

To make Ubuntu recognize the USB-Blaster, add the rule file of USB-Blaster (51-usbblaster.rules) to the rule file of udev (/etc/udev/rule.d). The USB-Blaster is a device, which is used for transferring programs from Ubuntu to DE0-Nano via USB connection. Udev is to manage device files, adding or deleting them.

After adding the rule file of USB-Blaster, please reboot udev. Just adding the file does not make this change effective.

$ sudo vi /etc/udev/rules.d/51-usbblaster.rules

 SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="09fb",
 ATTRS{idProduct}=="6001", MODE="0666", SYMLINK+="usbblaster/%k"


$ sudo udevadm control --reload-rules

Constitution of working directory

The diagram shown below shows the organization of working directories, which are used for this article, of Ubuntu.

${HOME}
  |-- altera/                      <- The install directory for Quartus
  |      
  `-- JavaRock           
         |- javarock_20130708.jar  <- The execution file of JavaRock
         `- samples/               <- Extraction directory for JavaRock samples_20130707.tar.gz
              |
           <snip>
              |
              |-- de0-nano/        <- Added working directory for DE0-Nano
              |     |-  model/     <- The directory for placing DE0-Nano project file 
              |     |     |- test.qpf 
              |     |     `- test.qsf
              |     |
              |     |- test.java
              |     `- test.sh
           <snip>
              |
              `-- led/
                    |- counter.java
                    `- led.java

Configuring environment variables

To increase boot speed of Quartus, PATH of Quartus is added to bashrc. Also, JavaRock's PATH to its execution file are added to bashrc. This lets JavaRock Build program easier. Both PATHs are added to the end of bashrc.

Code>

About the files of newly added directories

The files added for this article are shown below.

  • de0-nano/model/test.qpf: This a project file, which DE0-Nano System Builder generates for this project.

  • de0-nano/model/test.qsf: This is a qsf (pin-assignment configuration file), which assigns CLOCK and LED[8] on DE0-Nano SystemBuilder. It is also added to a vhd file, which is generated by JavaRock.

  • de0-nano/test.sh, test.java: samples/test/test.sh, test.java is modified for making a LED blink.

About editing test.sh and test.java

test.sh and test.java are edited as they are shown below. In this article, the sample makes only one LED blink, and unnecessary parts in these files are erased or commented out.

  • test.sh
    $ diff -upN samples_orig/test/test.sh samples/de0-nano/test.sh
    --- samples_orig/test/test.sh   2013-07-08 07:25:19.000000000 +0900
    +++ samples/de0-nano/test.sh    2014-05-20 18:30:01.516000467 +0900
    @@ -1,5 +1,3 @@
    -java -cp $JAVAROCK:../led:../sc1602:../echo:. openjdk.com.sun.tools.javac.Main \
    +java -cp $JAVAROCK:../led:. openjdk.com.sun.tools.javac.Main \
       ../led/counter.java ../led/led.java  \
    -  ../sc1602/SC1602Wrapper.java ../sc1602/SC1602Writer.java ../sc1602/sc1602_test.java  \
    -  ../echo/echo.java ./rs232c.java \
       test.java

  • test.java
    $ diff -upN samples_orig/test/test.java samples/de0-nano/test.java
    --- samples_orig/test/test.java 2013-07-08 07:25:19.000000000 +0900
    +++ samples/de0-nano/test.java  2014-05-20 17:38:47.528038697 +0900
    @@ -3,8 +3,8 @@ import net.wasamon.javarock.rt.*;
     @javarockhdl
     public class test{
       led obj0 = new led();
    -  echo obj1 = new echo();
    -  sc1602_test obj2 = new sc1602_test();
    +  //echo obj1 = new echo();
    +  //sc1602_test obj2 = new sc1602_test();
       //VGAJavaTest vga = new VGAJavaTest();
    
       @combination
    @@ -15,8 +15,8 @@ public class test{
       @auto
       public void main(){
         obj0.start();
    -    obj1.start();
    -    obj2.start();
    +    //obj1.start();
    +    //obj2.start();
         //vga.start();
       }
     }

Executing test.sh

After the modification of test.sh and test.java are completed, please execute test.sh. Then, make sure that test.vhd, led.vhd, and counter.vhd are located at the directory of de0-nano.

$ ./test.sh
Compile: counter
Compile: led
Compile: test 
pass: connection
pass: bypass
pass: optimization
pass: linkage
pass: generate

$ ls
counter.vhd  led.vhd  model  test.class  test.java  test.sh  test.vhd

About test.qpf and test.qsf

For the details of test.qpf and test.qsf, please download these attached files below and look them at for the reference.

test.qsf is modified to match the variables in a part of entity test of test.vhd. The original test.qsf does not match the pin-assignment of test.vhd. Based up the orignal test.qsf, the generated program will not run sucessfully.

Also the generated vhd files (test.vhd, led.vhd, and counter.vhd) are modified as they can read by the compiler.


  • test.vhd (for reference)
    entity test is -- net.wasamon.javarock.model.vhdl.VHDLModule@33117621
      port (
        notify_method_busy : OUT std_logic;
        output_port_led : OUT std_logic;
        notify_method_request : IN std_logic;
        reset : IN std_logic;
        clk : IN std_logic
      ); -- net.wasamon.javarock.model.vhdl.VHDLModule@33117621

  • model/testqsf
     #============================================================
     # CLOCK
     #============================================================
    -set_location_assignment PIN_R8 -to CLOCK_50
    -set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to CLOCK_50
    +set_location_assignment PIN_R8 -to clk
    +set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to clk
    
     #============================================================
     # LED
     #============================================================
    -set_location_assignment PIN_A15 -to LED[0]
    -set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to LED[0] 
    +set_location_assignment PIN_A15 -to output_port_led
    +set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to output_port_led
    
     #============================================================
     # End of pin assignments by Terasic System Builder
     #============================================================
    
    +set_location_assignment PIN_A11 -to reset
    +set_instance_assignment -name IO_STANDARD 2.5V -to reset
    +set_global_assignment -name VHDL_FILE ../led.vhd
    +set_global_assignment -name VHDL_FILE ../counter.vhd
    +set_global_assignment -name VHDL_FILE ../test.vhd
    +set_global_assignment -name PARTITION_NETLIST_TYPE SOURCE -section_id Top
    +set_global_assignment -name PARTITION_FITTER_PRESERVATION_LEVEL PLACEMENT_AND_ROUTING -section_id Top
    +set_global_assignment -name PARTITION_COLOR 16764057 -section_id Top
    +
    +set_global_assignment -name STRATIX_DEVICE_IO_STANDARD "2.5 V"
    +
    +
    +
    +set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top

Writing to DE0-Nano

Steps to write the generated files to DE0-Nano are shown below. All steps are done within Ubuntu.

1. Start up Quartus
Quartus is needed for writing the generated project file, and its build image, and post-build image to DE0-Nano.~

$ quartus
quartus01.png


2. Read the project file
Read test.qpf (a project file) from Open Project.

quartus02.png


3. Compile the Project
Click “Start Complication” that is located at “Processing” of the menu bar. This compiles the generated files inside the project.

4. Check the pin-assignments
Click “Pin Planner” that is the part of “Assignments” of the menu bar. You can see the configuration of pins, and you can check whether the configuration of pins is the same as your pin-assignments or not.

The configuration (allocation) of pins for this article is shown below.

quartus04.png


5. Start up Programmer
Click “Programmer” that is categorized as the part of “Tool.” The function of “Programmer” is to write the generated image to DE0-Nano. In other words, it is “programming” to DE0-Nano. You can select a device, which is used for writing the image file to the board. In this article, USB-Blaster is selected.

If the pop-up window indicates “NO Hardware,” click “Hardware Settings” and select a device that is listed inside “Current Selected Hardware. For this article, it should be “USB-Blaster.”

Caution: If USB-Blaster DOES NOT appear at the selection, please check the rule file of udev.~

quartus07.png


6. Transfer the image to DE0-Nano
Click “Start” that is located inside “Programmer”. The generated image is transferred to DE0-Nano.

Please check the “Progress” reaches at 100% (Successful). If does it so, in this case, LED0 at DE0-Nano starts blinking.

quartus06.png


javarock.jpg


Revision History

  • 2014/12/25 This article is initially uploaded

Attach file: filetest.qsf 404 download [Information] filetest.qpf 379 download [Information] filejavarock.jpg 563 download [Information] filequartus07.png 588 download [Information] filequartus06.png 668 download [Information] filequartus04.png 601 download [Information] filequartus02.png 574 download [Information] filequartus01.png 587 download [Information]

Front page   Edit Freeze Diff Backup Upload Copy Rename Reload   New List of pages Search Recent changes   RSS of recent changes
Last-modified: 2014-12-25 (Thu) 04:22:00 (1065d)