owned this note
owned this note
Published
Linked with GitHub
# Assignment3: Single-Cycle RISC-V CPU
Contributed by [dcciou](https://github.com/dcciou)
:::danger
You MUST write in English.
:::
<!--
1.完成exercise1-3.6
2.Describe the operation of ‘Hello World in Chisel’ and enhance it by incorporating logic circuit.
2.pass the unit test
3.run hw2 on MyCPU
-->
# complete code
After fullfilled all blank, it showed:
```
[info] FibonacciTest:
[info] Single Cycle CPU
[info] - should recursively calculate Fibonacci(10)
[info] ExecuteTest:
[info] Execution of Single Cycle CPU
[info] - should execute correctly
[info] InstructionFetchTest:
[info] InstructionFetch of Single Cycle CPU
[info] - should fetch instruction
[info] ByteAccessTest:
[info] Single Cycle CPU
[info] - should store and load a single byte
[info] InstructionDecoderTest:
[info] InstructionDecoder of Single Cycle CPU
[info] - should produce correct control signal
[info] RegisterFileTest:
[info] Register File of Single Cycle CPU
[info] - should read the written content
[info] - should x0 always be zero
[info] - should read the writing content
[info] QuicksortTest:
[info] Single Cycle CPU
[info] - should perform a quicksort on 10 numbers
[info] Run completed in 47 seconds, 682 milliseconds.
[info] Total number of tests run: 9
[info] Suites: completed 7, aborted 0
[info] Tests: succeeded 9, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 68 s (01:08), completed Nov 27, 2023 8:45:17 PM
```
you can find my code [here](https://github.com/dcciou/assignment3)
# myCPU
The original way used the same register and performed an ecall after the calculation, without actually storing the three pieces of data. For the convenience of CPU testing, I have modified it to store the data on the stack, ensuring that the data is stored at 0x04, 0x08, 0x0a.
```
//add in main part
li sp, 0x0C
//add in count_one part, before bnez t0,loop
sw a6, 0(sp)
addi sp, sp, -4
```
During the conversion process, the following issue occurred because the makefile only converts .S files and not .s files.
```
make: *** No rule to make target 'hw2.asmbin', needed by 'update'.
```
Then, I added a test for hw2 within cputest, which involves verifying the success of the calculation (you can find my code on [GitHub](https://github.com/dcciou/assignment3)).
The results are as follows:
```
[info] HW2Test:
[info] Single Cycle CPU
[info] - should count the number of one
[info] Run completed in 15 seconds, 321 milliseconds.
[info] Total number of tests run: 1
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
```
<!--
# 問題
## curl沒載(command not found)
## JDK11 沒安裝教學
To install Eclipse Temurin JDK 11 on Ubuntu, you can follow these steps:
1. **Install Necessary Packages**: First, make sure that you have all the necessary packages installed on your system:
```bash
sudo apt-get install -y wget apt-transport-https gnupg
```
2. **Download and Add the GPG Key**: Eclipse Adoptium uses a GPG key to sign their packages. Download and add this key to your system:
```bash
wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo apt-key add -
```
3. **Configure the Eclipse Adoptium Repository**: You'll need to add the Eclipse Adoptium repository to your system:
```bash
echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list
```
4. **Install Eclipse Temurin JDK 11**: Update your package list and install the JDK:
```bash
sudo apt-get update
sudo apt-get install temurin-11-jdk
```
Please note that the last command in the quoted instructions installs JDK 17, but to install JDK 11, you should replace `temurin-17-jdk` with `temurin-11-jdk`.
After installation, you can verify the installation by checking the version of the JDK:
```bash
java -version
```
## import riscv-none-elf-as 失敗
首先要找到該檔案的路徑,並往前推一層才會import成功( You should add the directory to the PATH, not the binary itself)
```bash
//location:/home/mio93001/riscv-none-elf-gcc/bin/riscv-none-elf-as
correct path: /home/mio93001/riscv-none-elf-gcc/bin
```
## 有時候terminal會怪怪的,重開就好了
ex:明明就有permission卻一直說denied
# 單字
- DSL:domain specific language
- rigorous:嚴格的
- prone:易於
- omit:忽略
-
# 語法
- 退一層資料夾: cd ..
- 找檔案位置:
似乎只要把 address 跟data.expect給他就能測試了
-->