The code is from: S. L. Harris and D. Harris, "Digital Design and RISC-V Computer Architecture Textbook," 2021 ACM/IEEE Workshop on Computer Architecture Education (WCAE), Raleigh, NC, USA, 2021, pp. 1-5, doi: 10.1109/WCAE53984.2021.9707615.
I have made some slight modifications to it and simulated with iverilog. The assembly code can be simulated in https://venus.kvakil.me/. This book is highly recommended for beginners in computer architecture. It can be effectively complemented by two authoritative textbooks to enhance your learning experience(Computer Organization and Design THE HARDWARE SOFTWARE INTERFACE, Computer Architecture: A Quantitative Approach). Additionally, you can utilize the provided code to practice debugging a basic CPU, understanding the data flow and hazard handling. For a complete and detailed explanation, readers are encouraged to refer to the original book.