Code Monkey home page Code Monkey logo

nemu-zig's Introduction

nemu-zig

My nemu (NJU EMUlator) implement in Zig. Now supports riscv32im ISA.


nemu-zig is developed with the master branch version of Zig. The latest tested zig version is 0.13.0-dev.46+3648d7df1.

How To Run

First make sure zig is in your $PATH. (The pre-built binary of Zig can be downloaded from here)

Build And Run NEMU

Run built-in image:

zig build run

Run your own image:

zig build run -- /path/to/image.bin

Run with disasm:

llvm needs to be installed before running disasm.

zig build -DITRACE run

Run with difftest:

nemu support comparing running result with spike while simulating riscv32.

make difftest IMG=/path/to/image.bin

Run Unit Tests

Zig provides zig test which can be used to ensure behavior meets expectations.

Unit tests are defined in src/test.zig. But now only expr test was supported.

zig build test

Possible problems

library 'LLVM' not found

This problem may occur when running nemu-zig with disasm on Debian-based systems.

-> % zig build -DITRACE                                                         
install                                                          
└─ install nemu-zig                                              
   └─ zig build-exe nemu-zig Debug native failure                                                                                 
error: error: unable to find Dynamic system library 'LLVM' using strategy 'paths_first'. searched paths:

Solution:

// build.zig

// change this line
exe.linkSystemLibrary("LLVM");
// to (modified "16" to your llvm version)
exe.linkSystemLibrary("LLVM-16");

'llvm-c/*.h' file not found

This problem may occur when running nemu-zig with disasm on Debian-based systems.

nemu/lib/llvm_slim.h:1:10: error: 'llvm-c/Disassembler.h' file not found
#include <llvm-c/Disassembler.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~

Solution:

# Modified "16" to your llvm version
sudo ln -s /usr/include/llvm-c-16/llvm-c/ /usr/include/llvm-c
sudo ln -s /usr/include/llvm-16/llvm /usr/include/llvm

nemu-zig's People

Contributors

judehahh avatar emin017 avatar

Stargazers

 bettynawolff@gmail.com avatar

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.