d0iasm / rvemu-for-book Goto Github PK
View Code? Open in Web Editor NEWReference implementation for the book "Writing a RISC-V Emulator in Rust".
Home Page: http://book.rvemu.app/
License: MIT License
Reference implementation for the book "Writing a RISC-V Emulator in Rust".
Home Page: http://book.rvemu.app/
License: MIT License
Excuse me ,I am a new hand, and the particularity of SIE confuses me a lot.
Could me tell me why read/write SIE register is different from other register?
/// Load a value from a CSR.
pub fn load_csr(&self, addr: usize) -> u64 {
match addr {
SIE => self.csrs[MIE] & self.csrs[MIDELEG],
_ => self.csrs[addr],
}
}
/// Store a value to a CSR.
pub fn store_csr(&mut self, addr: usize, value: u64) {
match addr {
SIE => {
self.csrs[MIE] =
(self.csrs[MIE] & !self.csrs[MIDELEG]) | (value & self.csrs[MIDELEG]);
}
_ => self.csrs[addr] = value,
}
}
The section explaining why rvemu is little-endian may mislead readers because it is not precise enough.
While the base memory system does not need to be little-endian with regards to instruction decoding, the current standardized memory operations do have to be little-endian. I think this may have been a requirement added after the 1.0 release of the specification, but I don't want to track down when it was added.
From: https://book.rvemu.app/setup-and-implement-two-instructions
RISC-V has either little-endian or big-endian byte order, but our emulator will implement a little-endian system since it is currently dominant commercially like x86 systems.
Section 1.2 of RISC-V Specification v2.0
The base RISC-V ISA has a little-endian memory system, but non-standard variants can provide a big-endian or bi-endian memory system
The section goes on to explain the exact (rather complex) memory requirements of the RISC-V.
Section 2.6 of RISC-V Specification v2.0
RV32I provides a 32-bit user address space that is byte-addressed and little-endian.
Thanks for your kindness. You have written such a tutorial and shared your code, which encourages me to learn it and complete the tutorial.
The new project is available at here and the online book is hosted on github page.
I have used most of your code and follow the structure of yours. I hope this tutorial will be helpful for anyone who want to learn about RISC-V emulator.
Lines 85 to 88 in eedfb40
You mention that this is the instruction for adding 64-bit integers. From the RISC-V spec this opcode is only for 32-bit integers.
hey, d0iasm,
your project rvemu is awesome and makes me excting! but the rvemu for book seems not to be finished, i really look forworad your book! Hope to see it soon!
Hello, I compiled the xv6 kernel myself and find the compiler uses the C extension of riscv, so the emulator failed to run the binary.
How did you modify the makefile of xv6 to disable the C extension?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.