Skip to content

yy214123/classify-rv32i

 
 

Repository files navigation

Assignment 2: Classify

This project is part of the NCKU CSIE Computer Architecture course. It focuses on implementing core mathematical functions and file operations using only the RV32I instruction set of the RISC-V architecture. The goal is to enhance understanding of low-level operations and improve efficiency in RISC-V programming.


Setup Instructions

1. Download Required Tools

Run the following command to download necessary tools:

$ bash tools/download_tools.sh

2. Start the Venus Simulator

Run the simulator using:

$ java -jar tools/venus.jar . -dm

3. Mount Local Files

In the Venus web terminal, execute:

$ mount local labs

In your browser, you may see a prompt saying Key has been shown in the Venus mount server! Please copy and paste it into here.. You should be able to see a key in the most recent line of your local terminal output; just copy and paste it into the dialog.

For more detailed steps and troubleshooting, please refer to Lab 3: RISC-V, Venus.


Part A - Mathematical Functions

Task 1: ReLU

commit 51048b5

Task 2: ArgMax

commit 6bd7b55

Task 3.1: Dot Product

commit cecbee4
According to the assignment requirements:
you must use only RV32I instructions; instructions from the M extension are not allowed.
Therefore, I used repeated addition and subtraction to perform the multiplication operation in the dot product calculation.

When I conducted the tests, I found that some test cases failed to pass:

Test Case Status
test_abs_minus_one ✅ Pass
test_abs_one ✅ Pass
test_argmax_invalid_n ✅ Pass
test_chain_1 ❌ Fail
test_classify_3_print ❌ Fail

Debugging Dot Product (Task 3.1)

Problem: The initial implementation of the dot product used elements of the second vector as the loop count. If any element was zero, the loop failed, causing incorrect results.

Debugging Process:

  1. Added additional test cases where elements in the second vector included zeros.
  2. Analyzed the loop logic and identified that zero values caused premature loop termination.

Solution: Refactored the loop to handle zero elements correctly, ensuring that all test cases pass. The updated logic can be found in commit 765ecf1.

Task 3.2: Matrix Multiplication

commit 61b1015


Part B - File Operations

Task 1: Read Matrix

commit c818213

Task 2: Write Matrix

commit 0c66e48

Task 3: Classification

commit 25eea7c


TODO:Improve performance

  • Current Issue: The repeated addition/subtraction approach for multiplication causes excessive looping.
  • Proposed Solution: Optimize loop structure and investigate alternative implementations.

About

Assignment 2: Classify

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 54.9%
  • Assembly 43.0%
  • Shell 2.1%