Try   HackMD

Assignment1: RISC-V Assembly and Instruction Pipeline

Due: Oct 14, 2024

Requirements

  1. Following the instructions of Lab1: RV32I Simulator, you shall get acquainted with RISC-V assembly programs (RV32I ISA) and output to the console with environment calls.
  2. Choose one problem (A, B, or C) from Quiz1, translate it from C code to a complete RISC-V assembly program, and include the relevant test data.
    • When translating C code to RISC-V assembly, avoid a mindless, direct conversion. Instead, use this opportunity to enhance the code. Your RISC-V assembly should demonstrate improvements in both code size and runtime performance compared to what a general C compiler would produce. Aim to leverage the strengths of RISC-V architecture to create more efficient assembly code than automated compilation.
    • Generate a simplified (but still informative) use case that serves as the subject for your assignment, demonstrating examples selected from LeetCode or practical open-source projects related to the above-selected problems (i.e., derived from Problem A/B/C from Quiz1). For instance, you can create a use case that involves performing branchless counting leading zero operations on integer base-2 values, titled "Implement log2 with branchless clz" or "Matrix multiplication using bfloat16." Alternatively, it is acceptable to specify the use cases like "Optimize LeetCode Problem #X by using half-precision floating point to reduce memory usage."
    • You are required to use only RV32I instructions (without M or F/D extensions) for floating-point data manipulation. This means you should not depend on a C compiler to generate assembly routines; instead, you must write RISC-V assembly code from scratch.
    • At least 3 test data should be included in your program(s).
      • Instead of accepting an external dataset, you can inline predefined data directly. You should automate the testing procedures as much as possible, meaning there's no need to manually check each program output. Instead, implement internal validation to handle the result checking.
    • Do choose a unique subject to work on, as each student should have a separate program. Starting earlier is advised to ensure you have ample time for your work.
    • Your program(s) must include loops (or recursive calls) and conditional branches, especially when writing test cases.
    • You must demonstrate iterative efforts to enhance the RISC-V programs, including reducing code size and minimizing runtime overhead, with explicit measurements.
    • Although you MUST write down your own RISC-V assembly, you can still verify the output of the C compiler's assembly output. As a result, you are able to describe the entire program.
    • You must ensure that the program functions correctly with the Ripes simulator.
    • Reference: Example RISC-V Assembly Programs and arch-riscv-progs.
  3. You must provide explanations for both the program's functionality and the operation of each instruction using the Ripes simulator.
    • Using the visualization for signals such as register write/enable signals, multiplexer input selection, and more, describe your application. You must provide examples for each stage, including IF, ID, IE, MEM, and WB. You should also explain the appropriate memory update steps.
  4. Write down your thoughts and progress in HackMD notes.
    • Example page
    • Insert your HackMD notes and RISC-V assembly programs in the following table.
    • Your HackMD page should be Published and editable as Signed-in write.
    • Write in English and feel free to utilize ChatGPT or QuillBot to improve your writing.
  5. BONUS: If you participate in class discussions during code reviews or test question reviews, the instructor may consider awarding extra credit.

Fill in the table for your homework

Edit # # this page # # after after logging into HackMD.
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
Be aware of spaces. Separate each item with |. Your HackMD page should be Published and editable as Signed-in write.

Formal given name Descriptions HackMD note Source code (GitHub/gist hyperlink)
Sample0 Palindrome Linked List Lab1: RV32I Assembly code
Sample1 Patching Array Lab1: RV32I Assembly code
Sample2 Three Consecutive Odds Lab1: RV32I Assembly code
Sample3 Implement Variable Byte Compression By Counting Leading Zeros Lab1: RV32I Assembly code
Sample4 Get sine value without floating point multiplication support Lab1: RV32I Assembly code
曾遠哲 Minimum Speed to Arrive on Time Lab1: RV32I Assembly code
陳家揚 Power of Four Lab1: RV32I Assembly code
王晴文 Number of 1 bits Lab1: RV32I Assembly code
方榮彬 Compute Hamming Distance with counting leading zero Lab1: RV32I Assembly code
郭昱辰 Maximum XOR of Two Numbers in an Array Lab1: RV32I Assembly code
簡子昕 Two Out of Three Lab1: RV32I Assembly code
柳嘉祐 Binary Number with Alternating Bits Lab1: RV32I Assembly code
陳彥廷 Number Complement Lab1: RV32I Assembly code
鄭煦霖 Single Number II Lab1: RV32I Assembly code
盧尚毅 Sort Integers by The Number of 1 Bits Lab1: RV32I Assembly code
賴傑南 Binary Gap Lab1: RV32I Assembly code
郭子敬 Valid Perfect Square Lab1: RV32I Assembly code
劉哲維 Reverse Bits Lab1: RV32I Assembly code
李皓翔 Integer Replacement Lab1: RV32I Assembly code
戴均原 Bitwise AND of Numbers Range Lab1: RV32I Assembly code
陳柏勳 Counting Bits Lab1: RV32I Assembly code
阮祈翰 Number of Bit Changes to Make Two Integers Equal Lab1: RV32I Assembly code
饒胤琛 Check if Bitwise OR Has Trailing Zeros Lab1: RV32I Assembly
check the permission of HackMD note
code
莊易騰 Find the K-or of an Array Lab1: RV32I Assembly code
吳中玄 Power of Two Lab1: RV32I Assembly
check the permission of HackMD note
code
邱柏穎 1D Convolution by FP16 Lab1: RV32I Assembly code
張恩祥 Race car Lab1: RV32I Assembly code
姜冠宇 Knight Probability in Chessboard Lab1: RV32I Assembly code
吳哲郁 Hamming Distance Lab1: RV32I Assembly code
蔡雅彤 Elias Gamma Encoding with CLZ Lab1: RV32I Assembly code
黃啟維 Rectangle Area in BF16 Lab1: RV32I Assembly
check the permission of HackMD note
code
洪翊碩 Complex Multiplication Lab1: RV32I Assembly code
吳昀鴻 Deriving LeetCode Problem 29 Using Floating-Point : Analyzing Precision Differences Between FP32 and BF16 Lab1: RV32I Assembly code
李尚宸 Missing Number Lab1: RV32I Assembly code
郭君瑋 Number of Steps to Reduce a Number to Zero Lab1: RV32I Assembly code
孫禾洵 Best Time to Buy and Sell Stock II Lab1: RV32I Assembly code
廖奕凱 Implement count leading zero and popcount to solve LeetCode problem 1342. Lab1: RV32I Assembly code
曹為廷 Maximum Subarray Lab1: RV32I Assembly code
謝明翰 Finding the Closest Power of Two Greater Than or Equal to a Number Lab1: RV32I Assembly code
高孟霆 Sum of Values at Indices With K Set Bits Lab1: RV32I Assembly code
吳彥廷 Multiplying with BF16 format. Lab1: RV32I Assembly code
鄭九彰 Single Number Lab1: RV32I Assembly
check the permission of HackMD note
code
陳奕嘉 Power of Four Lab1: RV32I Assembly code
蔡承璋 Single Number III Lab1: RV32I Assembly code
許翰翔 Int to Float conversion Lab1: RV32I Assembly code
黃若綾 Convert a Number to Hexadecimal Lab1: RV32I Assembly code
李其儒 Factorial Trailing Zeroes Lab1: RV32I Assembly code
丁語婕 Minimum Bit Flips to Convert Number Lab1: RV32I Assembly code
王信智 Minimum Flips to Make a OR b Equal to c Lab1: RV32I Assembly code
陳致翰 Climbing Stairs Lab1: RV32I Assembly code
李協儒 Fast Approximation of Reciprocal Square Root Lab1: RV32I Assembly code
徐崇智 Smallest Power of Two Greater Than or Equal to n Lab1: RV32I Assembly code
周姵彣 Product of Array Except Self Lab1: RV32I Assembly code
黃士昕 Find the K-th Character in String Game II Lab1: RV32I Assembly code
葉人豪 Complement of Base 10 Integer Lab1: RV32I Assembly code
林趺菩 Running Sum of 1d Array Lab1: RV32I Assembly code
程品叡 Minimum One Bit Operations to Make Integers Zero Lab1: RV32I Assembly code
蘇湘婷 Broken Calculator
shorten
Lab1: RV32I Assembly code
余紹桓 Finding the square root of number using binary search Lab1: RV32I Assembly code
吳睿秉 Find the XOR of Numbers Which Appear Twice Lab1: RV32I Assembly code
章元豪 Concatenation of Consecutive Binary Numbers Lab1: RV32I Assembly code
黃守維 Number of Zero-Filled Subarrays Lab1: RV32I Assembly
use Permalink
code
黃詩哲 Determinant of Second Order Matrix Lab1: RV32I Assembly
use Permalink
code
邱繼寬 ? Lab1: RV32I Assembly code
洪至謙 TwoSum
Do choose a unique subject to work on
Lab1: RV32I Assembly code
陳昭詣 Find the Difference Lab1: RV32I Assembly code
曾謙文 Gray Code Lab1: RV32I Assembly
check the permission of HackMD note
code
陳冠霖 Minimum Changes To Make Alternating Binary String Lab1: RV32I Assembly code
陳侯華 Binary Watch Lab1: RV32I Assembly code
何承頴 XOR Operation in an Array Lab1: RV32I Assembly code
呂修麟 Minimum Size Subarray Sum Lab1: RV32I Assembly code
劉孟璋 Number of Steps to Reduce a Number in Binary Representation to One Lab1: RV32I Assembly code
龔祐萱 Max Consecutive Ones Lab1: RV32I Assembly code
蘇暐倫 Pascal's Triangle Lab1: RV32I Assembly code
陳柏儒 Division Optimization Lab1: RV32I Assembly code
唐文駿 The square root of 𝑥 Lab1: RV32I Assembly code
傅信豪 Counting Zero from Frontend or Backend Lab1: RV32I Assembly code
劉益祥 Convert the Temperature Lab1: RV32I Assembly code
林濤 Total Hamming Distance Lab1: RV32I Assembly code
陳乃宇 Convert Binary Number in a Linked List to Integer Lab1: RV32I Assembly code
黃灝 XOR Queries of a Subarray Lab1: RV32I Assembly code
湯秉翰 Add Digits Lab1: RV32I Assembly code
林乙民 K Closest Points to Origin Lab1: RV32I Assembly code
林靖婷 Bfloat16 Matrix Multiplication Lab1: RV32I Assembly code
洪靖睿 Number of Even and odd Bits Lab1: RV32I Assembly code
蔡承遠 Third Maximum Number Lab1: RV32I Assembly code
郭晏愷 Add Binary Lab1: RV32I Assembly code
蕭維昭 Implement square root using CLZ method Lab1: RV32I Assembly
use Permalink
code
徐向廷 Optimize "Squares of a Sorted Array" By Reducing Memory Usage Lab1: RV32I Assembly code
李宗翰 Three Consecutive Odds Lab1: RV32I Assembly code
蕭郁霖 Divide Two Integers Lab1: RV32I Assembly code
邱家浩 Find if Array Can Be Sorted Lab1: RV32I Assembly code
王景霈 UTF-8 Validation Lab1: RV32I Assembly code
傅孟楷 Reverse Bits Lab1: RV32I Assembly code
李漢德 Number of Even and Odd Bits Lab1: RV32I Assembly code
簡德彥 Improving shift-and-add multiplication using clz Lab1: RV32I Assembly code
吳秉宥 Implement binary GCD algorithm using clz Lab1: RV32I Assembly code
黃書堯 Calculating the n-th Root of x Lab1: RV32I Assembly code
林子齊 Sigmoid Function by BF16 without Floating Point Support Lab1: RV32I Assembly code
黃詠筑 Length of Last Word Lab1: RV32I Assembly
use Permalink
code
林育丞 Optimized RSA with efficient bitwise operations Lab1: RV32I Assembly
use Permalink
code
黎詠哲 Remove Duplicates from Sorted Array Lab1: RV32I Assembly code
陳禹丞 Running Sum of 1D Array Lab1: RV32I Assembly code
宋明翰 Prime Number of Set Bits in Binary Representation Lab1: RV32I Assembly code
章劉軒瑋 Bilinear Interpolation by using BF16 and related operations Lab1: RV32I Assembly code
黃丞漢 Palindrome Number Lab1: RV32I Assembly code
廖華鑫 Number of 1 Bits Lab1: RV32I Assembly code
王韻茨 Row With Maximum Ones Lab1: RV32I Assembly code
蔡文賓 Find the Pivot Integer La1: RV32I Assembly code
王柏皓 Restore IP Addresses Lab1: RV32I Assembly
use Permalink
code
宋唯廷 Distance Metrics in Machine Learning Lab1: RV32I Assembly code
李建佑 Find Closest Number to Zero Lab1: RV32I Assembly code
劉欣宜 Fibonacci number Lab1: RV32I Assembly code
江冠德 Calculate the logarithm to base 2 with branchless clz Lab1: RV32I Assembly code
李懿宸 Climbing Stairs Lab1: RV32I Assembly code
蕭力文 Construct the Minimum Bitwise Array Lab1: RV32I Assembly code
吳柏漢 Find Numbers with Even Number of Digits Lab1: RV32I Assembly code
侯廷錡 Add Binary with Variable Lengths
Improve the description
Lab1: RV32I Assembly code
鄭智元 ? Lab1: RV32I Assembly code
謝廷昇 Golomb Code Lab1: RV32I Assembly code
王彥珽 Prime Number of Set Bits in Binary Representation Lab1: RV32I Assembly code
陳品彤 Run Length Code Lab1: RV32I Assembly code
曾俊瑋 Check if Bitwise OR Has Trailing Zeros Lab1: RV32I Assembly
use Permalink
code
陳榮昶 ? Lab1: RV32I Assembly
check the permission of HackMD note
code

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
You can only add your notes in the area above this box and be aware of spaces. Separate each item with | and there should only be one space before and after the | character, do not add extra spaces.