--- tags: computer-arch --- # Assignment1: RISC-V Assembly and Instruction Pipeline > Due: ==Oct 10, 2022== ## Requirements 1. Following the instructions of [Lab1: RV32I Simulator](/@sysprog/H1TpVYMdB), you shall write RISC-V assembly programs ([RV32I](https://en.wikipedia.org/wiki/RISC-V) ISA) and output to the console with environment calls. * Select one of the problems listed at [LeetCode](https://leetcode.com/problemset/all/). Difficuty "[Easy](https://leetcode.com/problemset/all/?difficulty=EASY)" is preferable. The input data of specified [LeetCode](https://leetcode.com/problemset/all/) problems MUST be accessed in the form of **pointer, array, linked list, or tree**. It is not permitted to have only primitive integer types such as `char` and `int` in parameter list. * That is, you CAN NOT select [69. Sqrt(x)](https://leetcode.com/problems/sqrtx/), which specifies one integer paramater instead of memory regions. * At least 3 test data should be included in your program(s). * Without accepting an external data set, you can inline the predefined data. * Avoid solving the same problem as others. You will have a separate program for a unique problem. * Then, you shall start earlier, otherwise there would be less availability for you to work on. * Your program(s) MUST contain loops (or recursive calls) and conditional branches. * 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 have to ensure the program fully functioned with [Ripes](https://github.com/mortbopet/Ripes) simulator. * Reference: [Example RISC-V Assembly Programs](https://marz.utk.edu/my-courses/cosc230/book/example-risc-v-assembly-programs/) 2. You have to explain how each instruction works along with [Ripes](https://github.com/mortbopet/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. 3. Write down your thoughts and progress in [HackMD notes](https://hackmd.io/s/features). * [Example page](https://hackmd.io/@kaeteyaruyo/risc-v-hw1) > :warning: Do not modify this note. * Insert your HackMD notes and RISC-V assembly programs in the following table. * Your HackMD page should be [Published](https://hackmd.io/s/all-about-profile-page) and editable as [Signed-in write](https://hackmd.io/@codimd/note-permission). * You MUST write in English, of course. ## Fill in the table for your homework | Formal given name | Descriptions | HackMD note | Program (GitHub hyperlink) | |:-----------------:| ---------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | | Sample1 | Single number II ([LeetCode 137](https://leetcode.com/problems/single-number-ii/)) | [Lab1: RV32I Simulator](https://hackmd.io/@eecheng/HJojUvdrw) | - | | Sample2 | Patching Array ([LeetCode330](https://leetcode.com/problems/patching-array/)) | [Lab1: RV32I Simulator](https://hackmd.io/@7y4UQB2gRoSQRw5iAm-5lw/r1__oMEHY) | [Patching Array](https://github.com/chinghongfang/ComputerArchitecture/tree/main/hw1) | | Sample3 | Shuffle the Array ([LeetCode 1470](https://leetcode.com/problems/shuffle-the-array/)) | [Lab1: RV32I Simulator](https://hackmd.io/@wIVnCcUaTouAktrkMVLEMA/ryqv60zHK) | [Shuffle the Array](https://gist.github.com/tobychui/032db06f31c7b72be1df5b30ab8d937c) | | 鄭明奇^+^ | Remove Duplicates from Sorted Array ([LeetCode 26](https://leetcode.com/problems/remove-duplicates-from-sorted-array/)) | [Lab1: RV32I Simulator](https://hackmd.io/@teimeikichengmingchi/RISC-V-Assignment1) | [Remove Duplicates from Sorted Array](https://github.com/teimeikichengmingchi/NCKU-RISC-V/tree/main/homework1) | | 潘鴻福 | Long Pressed Name ([LeetCode 925](https://leetcode.com/problems/long-pressed-name/)) | [Lab1: RV32I Simulator](https://hackmd.io/@kaminto-1999/long-pressed-name) | [Long Pressed Name](https://github.com/kaminto-1999/ComputerArchitectureNCKU111) | | 陳品崴 | Pascal's Triangle II ([LeetCode 119](https://leetcode.com/problems/pascals-triangle-ii/)) | [Lab1: RV32I Simulator](https://hackmd.io/@pTOtphjnSgqKNp2mfa6tCw/SkwIDjUZs) | [Pascal's Triangle II](https://github.com/David66131/computer_arch_2022/tree/main/HW1) | | 馮柏為 | Find the Highest Altitude ([LeetCode 1732](https://leetcode.com/problems/find-the-highest-altitude/)) | [Lab1: RV32I Simulator](https://hackmd.io/@r1YLxwFRRPe1xninh0Ma6w/BygEuPtfo) | [Longest Common Prefix]() | | 周士翔 | Two sum ([LeetCode 1](https://leetcode.com/problems/two-sum/)) | [Lab1: RV32I Simulator](https://hackmd.io/@zDmciYQATNm-8XeyJ5Th0Q/r1htullMj) | [Two sum](https://github.com/jc123488/TwoSum.git) | | 黃彥承 | Missing Number ([LeetCode 268](https://leetcode.com/problems/missing-number/)) | [Lab1: RV32I Simulator](https://hackmd.io/@teimeikichengmingchi/RISC-V-Assignment1) | [Missing Number]() | | 何坤霖 | Majority Element([LeetCode 169](https://leetcode.com/problems/majority-element/)) | [Lab1: RV32I Simulator](https://hackmd.io/@dgKSmDN0T_quhIoU9NVThA/BJapX2U-s) | [Majority Element]() | | 吳宇晨 | Find Target Indices After Sorting Array ([LeetCode 2089](https://leetcode.com/problems/find-target-indices-after-sorting-array/)) | [Lab1: RV32I Simulator](https://hackmd.io/@bcQ6fpRFSRW8UlMXdeUoiQ/ByXg5nLZs) | [Find Target Indices After Sorting Array](https://github.com/mpyh12345/Assignment-1) | | 王漢祺 | Three Consecutive Odds ([LeetCode 1550](https://leetcode.com/problems/three-consecutive-odds/)) | [Lab1: RV32I Simulator](https://hackmd.io/@wanghanchi/BkM-53UWi) | [Three Consecutive Odds](https://github.com/WangHanChi/2022_Computer_Architecture) | | 陳韋勳^+^ | Remove Element ([LeetCode 27](https://leetcode.com/problems/remove-element/)) | [Lab1: RV32I Simulator](https://hackmd.io/@0SHE18LgRsqRjsgqxIFjVA/B10AgBJfo) | [Remove Element](https://github.com/jack771029/computer_architecture/tree/main/hw1) | | 鄭至崴 | Move Zeroes ([LeetCode 283](https://leetcode.com/problems/move-zeroes/)) | [Lab1: RV32I Simulator](https://hackmd.io/@Fo7UsdePRsKPVV4CPYGbpA/rk91z0LWi) | [Move Zeroes](https://github.com/Chih-Wei-Cheng/ComputerArchitecture/tree/main/hw1) | | 張瑞甫 | Trapping Rain Water([LeetCode42](https://leetcode.com/problems/teemo-attacking/)) | [Lab1: RV32I Simulator](https://hackmd.io/@n96111150/HJlXb0Ibj) | [Trapping Rain Water](https://github.com/Chiwawachiwawa/Trapping-Rain-Water) | | 黃榆哲 | Best Time to Buy and Sell Stock([LeetCode 121](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/)) | [Lab1: RV32I Simulator](https://hackmd.io/@n7MIa9jgToeqs2aY5BaKEA/Hk3B5RUZo) | [Best Time to Buy and Sell Stock](https://github.com/zer1109/Computer_Architecture/tree/master) | | 楊淳皓 | Concatenation of Array ([LeetCode 1929](https://leetcode.com/problems/concatenation-of-array/)) | [Lab1: RV321 Simulator](https://hackmd.io/@Vgwl_uixQFasIvsDbsFlvA/SkZNzs8bs) | [Concatenation of Array](https://github.com/tonych1997/Computer-Architecture) | | 王彥翔 | Convert Binary Number in a Linked List to Integer([LeetCode 1290](https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/)) | [Lab1: RV321 Simulator](https://hackmd.io/@JHfVFxIbS6umD24Uy4CqvA/BkKU8MFzo) | [Convert Binary Number in a Linked List to Integer](https://github.com/tonych1997/Computer-Architecture) | | 謝鈞霖 | Find the Difference([LeetCode 389](https://leetcode.com/problems/find-the-difference/)) | [Lab1: RV321 Simulator](https://hackmd.io/@Vgwl_uixQFasIvsDbsFlvA/SkZNzs8bs) | [Find the Difference](https://github.com/tonych1997/Computer-Architecture) | | 謝長成 | Number of Good Pairs([LeetCode 1512](https://leetcode.com/problems/number-of-good-pairs/)) | [Lab1: RV321 Simulator](https://hackmd.io/@fl7xQ3gkQfufBHCfBYB5sw/r1wGn7vZs) | [Number of Good Pairs](https://github.com/HCCFish/ComputerArchitecture/tree/main/hw1) | | 陳邦尉 | 122. Best Time to Buy and Sell Stock II([LeetCode 122](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/)) | [Lab1: RV321 Simulator](https://hackmd.io/07GCKEiATceZlYfG9J43wQ) | [Best Time to Buy and Sell Stock](https://github.com/ram-a11y/Computer-Architecture) | | 張中龍 | Lemonade Change([LeetCode 860](https://leetcode.com/problems/lemonade-change/)) | [Lab1: RV321 Simulator](https://hackmd.io/@ncxDr8I_QguW3tkdtqgZ-Q/Sk0rRIvbi) | [Lemonade Change](https://github.com/a1933b/HW1_Lemonade-Change) | | 陳奕萍 | Search Insert Position ([LeetCode 35](https://leetcode.com/problems/search-insert-position/)) | [Lab1: RV321 Simulator](https://hackmd.io/@P76111482/BJxisP5Mi) | [Search Insert Position](https://github.com/qwer951212/ComputerArchitecture_HW1) | | 蘇勇達 | Length of Last Word ([LeetCode 58](https://leetcode.com/problems/length-of-last-word/)) | [Lab1: RV321 Simulator](https://hackmd.io/@2gMSvG25RxKj2-N_rAY6zg/S10sPrJ_o) |[Length of Last Word](https://github.com/YongDaSu/2022ComputerArchitecture_1) | | 陳彥甫 | Remove Linked List Elements ([LeetCode 203](https://leetcode.com/problems/remove-linked-list-elements/)) | [Lab1: RV321 Simulator](https://hackmd.io/@qwe661234/H1J9kc6Ws) | [Remove Linked List Elements](https://github.com/qwe661234/ComputerArchitectureHW/tree/main/HW1-LeetCode-203-RISCV) | | 吳峻廷 | Linked List Cycle ([LeetCode 141](https://leetcode.com/problems/linked-list-cycle/)) | [Lab1: RV321 Simulator](https://hackmd.io/sniBC9-XSeWupAC4oOaRUg?view) | [Linked List Cycle](https://github.com/ChunTing-Wu/Linked_List_Cycle) | | 王昱承 | Running Sum of 1d Array ([LeetCode 1480](https://leetcode.com/problems/running-sum-of-1d-array/)) | [Lab1: RV321 Simulator](https://hackmd.io/@zKOCm3SSTKyUyiPV-nfEjw/ryC8TgjZi) | [Running Sum of 1d Array](https://github.com/yuchengwang1121/Computer-Architecture/tree/main/Assignment%201) | | 黃昱澄 | Build Array from Permutation([LeetCode1920](https://leetcode.com/problems/build-array-from-permutation/)) | [Lab1: RV321 Simulator](https://hackmd.io/@7UuLPITUR02HgYqwo0PaIQ/rJz5QcFWs) | [Build Array from Permutation](https://github.com/char0815/computer_structure.git) | | 吳紀寬 | Single Number([LeetCode136](https://leetcode.com/problems/single-number/)) | [Lab1: RV321 Simulator](https://hackmd.io/JqxPI8fpSP-_0JBFB2t-Tw?view) | [Single Number](https://github.com/kenwaytempler/Single-Number/tree/main) | | 黃冠予 | Decode XORed Array([LeetCode1720](https://leetcode.com/problems/decode-xored-array/)) | [Lab1: RV321 Simulator](https://hackmd.io/@ZLQisilvQvOh2DclLmk1bg/SyjKI7sZi) | [Decode XORed Array](https://github.com/GYHuang111/Computer-Architecture/tree/main) | | 俞杉麒 | Decompress Run-Length Encoded List([LeetCode1313](https://leetcode.com/problems/decompress-run-length-encoded-list/)) | [Lab1: RV321 Simulator](https://hackmd.io/@XiaXia/ComputerArchitecture_Hw1) | [Decompress Run-Length Encoded List](https://github.com/dhiptmc/ComputerArchitecture/tree/main/Hw1) | | 張邦翰 | Monotonic Array[(LeetCode 896)](https://leetcode.com/problems/monotonic-array/) | [Lab1: RV32I Simulator](https://hackmd.io/@0M4xubFKTNeuc7WRhLY9lA/rk5VinbXs) | [Monotonic Array](https://github.com/NotA1ive/mono) | | | 吳昱 | Palindrome Linked List[(LeetCode 234)](https://leetcode.com/problems/palindrome-linked-list/) | [Lab1: RV32I Simulator](https://hackmd.io/@kdnvt/2022-arch-hw1) | [Palindrome Linked List](https://github.com/kdnvt/Palindrome-linked-list/) | | 洪嘉志 | Sort Array By Parity ([LeetCode 905](https://leetcode.com/problems/sort-array-by-parity/)) | [Lab1: RV32I Simulator](https://hackmd.io/@aa12551/SJq6Z3h-j) | [Sort Array By Parity](https://github.com/aa12551/Computer-Architecture) | | 江坤諦 | Remove Duplicates from Sorted List II([LeetCode 82](https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/)) | [Lab1: RV32I Simulator](https://hackmd.io/@1fW2vTD6S7O0ODaFZa6pNA/SJAjZJAWj) | [Remove Duplicates from Sorted List II](https://github.com/chiangkd/Computer-Architecture) | | 賴致文^+^ | Find Numbers with Even Number of Digits([LeetCode1295](https://leetcode.com/problems/find-numbers-with-even-number-of-digits/)) | [Lab1: RV32I Simulator](https://hackmd.io/@b3nzYEHmSeCBZhvZgxI-DA/BJzNlmlfs) | [Find Numbers with Even Number of Digits](https://github.com/chihwenlai/Computer-Architecture/tree/main/HW1) | | 陳嘉晟 | Add Two Numbers ([LeetCode2](https://leetcode.com/problems/add-two-numbers/)) | [Lab1: RV32I Simulator](https://hackmd.io/@Haser/Sk9JF0CWo) | [Add Two Numbers](https://github.com/Haser0305/ComputerArchitecture/tree/main/Homework/hw1) | | 杜孟聰 | Invert Binary Tree ([LeetCode 226](https://leetcode.com/problems/invert-binary-tree/)) | [Lab1: RV32I Simulator](https://hackmd.io/@MicahDoo/HJKfe5Izj) | [Invert Binary Tree](https://gist.github.com/MicahDoo/fb15432a15a59d77260106489345d6ad) |https://github.com/hsuanxc/ComputerArchiteture-2022-NCKU/tree/main/HW01 | 曾晧峖 | Valid Anagram ([Leetcode 242](https://leetcode.com/problems/valid-anagram/)) | [Lab1: RV32I Simulator](https://hackmd.io/@tseng0201/rkN-AlvMi) | [Valid Anagram](https://github.com/tseng0201/ComputerArchitecture-2022-/tree/main/HW1) | | 莊集^+^ | Contains Duplicate ([Leetcode 217](https://leetcode.com/problems/contains-duplicate/)) | [Lab1: RV32I Simulator](https://hackmd.io/@y8jRQNyoRe6WG-qekloIlA/Sk0PXEDzj) | [Contains Duplicate](https://github.com/JiggerChuang/NCKU_CA_HW_2022/tree/main/hw1) | | 方宣翔 | Plus One ([Leetcode 66](https://leetcode.com/problems/plus-one/)) | [Lab1: RV32I Simulator](https://hackmd.io/giUz5KioQjSdc95UZlfpxQ?view) | [Plus One](https://github.com/fanghsuanhsiang/plus_one) | | 陳證仰 | Merge Two Sorted Lists ([LeetCode 21](https://leetcode.com/problems/merge-two-sorted-lists/)) | [Lab1: RV32I Simulator](https://hackmd.io/@chenzenyang0905/Hy0CNLQGs) | [Merge Two Sorted Lists](https://github.com/chenzenyang/computer-architecture-2022-fall/tree/main/homework1) | | 鄒崴丞 | Binary Search ([LeetCode 704](https://leetcode.com/problems/binary-search/description/)) | [Lab1: RV32I Simulator](https://hackmd.io/@StevenChou43/rkvkJ_Kjc) | [Binary Search](https://github.com/StevenChou499/2022_Computer_Architecture) | | 李協儒 | Reverse Linked List ([LeetCode 206](https://leetcode.com/problems/reverse-linked-list/)) | [Lab1: RV32I Simulator](https://hackmd.io/@DotandLog/BJcgekYzi) | [Reverse Linked List](https://github.com/DotandLog/CA-fa22/tree/main/HW1) | | 黃柏瑜 | Jewels and Stones ([LeetCode 771](https://leetcode.com/problems/jewels-and-stones/description/)) | [Lab1: RV32I Simulator](https://hackmd.io/@maromaSamsa/B1O9CmKzj) | [Jewels and Stones](https://github.com/maromaSamsa/Computer_Arch2022/tree/main/Lab1_RV32I%20Simulator) | | 陳柏瑋 | Find Pivot Index ([LeetCode 724](https://leetcode.com/problems/find-pivot-index/)) | [Lab1: RV32I Simulator](https://hackmd.io/@JxPCbLVmQh2_5-6E4fvX9w/B17hsV-ms) | [Find Pivot Index](https://github.com/abnormal749/Computer_Arch2022/tree/main/Lab1_RV32I) | | 陳靖雯 | Roman to Integer ([LeetCode 13](https://leetcode.com/problems/roman-to-integer/)) | [Lab1: RV32I Simulator](https://hackmd.io/@n4ybS5zCSBmmjJ_7Vq6YEQ/SkxP0yWQj) | [Roman to Integer](https://github.com/Raymonna/computer-architecture/tree/main/homework1) |