Giter Club home page Giter Club logo

minijava-to-k210-riscv-compiler's Introduction

MiniJava to K210 RISC-V Assembly Compiler

This Compiler can translate MiniJava into K210 RISC-V assembly.

MiniJava Syntax and Type System

MiniJava is a subset of Java. The meaning of a MiniJava program is given by its meaning as a Java program.
BNF for MiniJava
Syntax alternative source Tufts
Syntax alternative source UCR
MiniJava-typesystem

If the syntax of the input MiniJava program is not correct, the Compiler will report an exception. Although common IDEs cannot check for MiniJava syntax correctness, the correct MiniJava program should be able to run in Java properly.

Kendryte K210 (K210)

K210 is a RISC-V Dual Core 64bit chip for AI+IOT. It is widely used in the development board of embedded system.
RISC-V Assembly can run on K210 by using RISC-V GNU Toolchain.
If you are interested in my development environment, please refer to this tutorial. UART is used for input and output on the development board.

Usage

Compatibility

minijava-to-k210-riscv-compiler.jar is written by using jdk1.8.0_101.
JRE version 1.8+ should be able to execute minijava-to-k210-riscv-compiler.jar properly.
JRE 15.0.1 can execute it properly.

Command

If you would like to print RISC-V assembly to terminal,
java -jar minijava-to-k210-riscv-compiler.jar < test.java

If you would like to print RISC-V assembly to file test.s,
java -jar minijava-to-k210-riscv-compiler.jar < test.java > test.s

Examples

k210asms & k210out_pics:
The RISC-V assembly files in k210asms are compiled from the corresponding MiniJava files in testcases.
The pictures in k210out_pics are the serial communication result of the corresponding RISC-V assembly files in k210asms.

About

This project is based on the RISC-V version homework of UCLA CS132. The project contains four parts to form a compiler pipeline: [Type Checker] -> [Translate to Sparrow] -> [Translate to SparrowV (Register Allocation)] -> [RISC-V assembly]. In the original homework, the target language of the last step is Venus RISC-V assembly.

The project is formed by modifying the target language of the last step to K210 RISC-V assembly. This tutorial records the steps to complete the project.

Copyright Notice

The copyright of the content in the folder testcases and cs132.jar belongs to Professor Palsberg.

For Academic Integrity, this is NOT a open source project, and the file minijava-to-k210-riscv-compiler.jar is highly obfuscated.
(Professor Palsberg spent a lot of energy on the development of the RISC-V version homework for UCLA CS132 Compiler Construction, which is a CS capstone, so I try to protect the effectiveness of the homework here.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.