contributed by < hungyuhang, RayChen >
Introduction
System emulation provides a virtual model of a machine (CPU, memory and emulated devices) to run a guest OS. In integrated circuit (IC) design, system emulation plays a significant role during the initial design phase of the chip.
And among those system emulators, semu is a minimalist RISC-V system emulator capable of running Linux the kernel and corresponding userland. But as the term "minimalist" implies, semu does not include some essential peripherals, such as the RTC module.
To improve the system emulation of semu, we add a simple RTC module. The implementations are in the following repositories:
hungyuhang/semu
contributed by < hungyuhang >
Environment Setup
Issue Encountered when Running Chisel Bootcamp
I run the Chisel Bootcamp on my Windows laptop locally using Docker.
But the Docker image provided by Chisel has some issues. After I boot up the Docker image, the code cell in the Jupyter notebook of the Chisel bootcamp cannot execute normally.
To solve the issue, I rebuild the Docker image using the method in this article. And after the fixup, the bootcamp runs normally.
GTKWave Installation
contributed by < hungyuhang >
Problem Selection
For this assignment, I choose the program Find Leftmost 0-byte using CLZ by 陳川曜.
And the reason to pick this implementation, is because there are a lot of binary operations in this implementation, and I want to practice more binary operations so that I can be more familiar with it.
Program Adaptation
Assembly Code
To adapt the assembly from Ripes to rv32emu, most of the work involves changing the code for system calls. For example, in Ripes there is a system call to print integer. But in rv32emu, it only supports system call to print string.
contributed by < hungyuhang >
Multiplication Overflow Prediction
This method utilizes the formula below:$$ \lceil log_2(xy) \rceil \leq \lceil log_2(x) \rceil + \lceil log_2(y) \rceil $$
So if we calculate log2(x) and log2(y), we can predict whether the product of x and y will overflow without doing the multiplication.
By counting the leading zeros of x and y in binary representation, we can obtain the logarithm of x and y with base 2.
Although the concept is straightforward, this method has some exceptions.
For example, for $x \approx 2^{61.4}$ and $y \approx 2^{1.6}$, the result of $\lceil log_2(x) \rceil + \lceil log_2(y) \rceil$ is 64, and the algorithm will predict that the product of $x$ and $y$ will overflow. However, the product of $x$ and $y$ is about $2^{63}$, since it is smaller than $2^{64}$, the value will not overflow.
N26122026洪佑杭 changed 2 years agoView mode Like Bookmark