RISC-V CPU Design for FPGA Implementation ③ Build a Full CPU with a 5-Stage Pipeline Supporting 40 RV32I Instructions Yourself
As you study CPUs and RISC-V, you may understand what the instructions do but still find yourself asking, “How are these instructions actually executed in hardware?” and “How can I verify that a CPU I designed myself really works correctly?” Many existing resources stop at ISA explanations or simple CPU examples, and many others rely on completed IP, making it difficult to experience the entire process of designing and verifying a CPU yourself and running programs on an actual FPGA.
I have spent many years working in R&D and business in the system semiconductor field, and I have observed this learning gap firsthand while teaching semiconductor design and FPGA at a university. For this reason, rather than providing a completed CPU and simply checking that it operates, this course is structured around designing the CPU directly in a White Box approach, starting with the question, “What hardware is required to execute RV32I instructions?”
In Volume 3, we expand Volume 2’s TinyRV32I into a Full-Version 32-bit CPU that uses 40 RV32I instructions. We extend the datapath, Decoder, Branch·Jump, and Byte/Halfword Memory Access, and implement Forwarding and Load-Use Interlock so that the 5-stage Pipeline can handle data dependencies on its own. We then integrate CSR, Exception, Interrupt, Trap, and MRET to complete a CPU capable of handling not only normal program execution but also exceptions and external events.
The design does not end with RTL Simulation. You will run actual programs on the CPU, compare the results with the Spike Reference Model, and learn the purpose of the RISC-V Architecture Compatibility Test as well as how to perform and evaluate it through real verification cases. Finally, you will implement the verified CPU on an Arty S7-25 FPGA, receive input from Switches and Buttons, run programs, and confirm the results by displaying them on LEDs.
The problem this course aims to solve is not simply learning more RISC-V instructions. Its goal is to connect instructions → CPU architecture → Verilog RTL → Pipeline control → program execution → standards-based verification → actual FPGA operation into a single flow, enabling students to fundamentally understand the internal structure of a CPU and develop the engineering skills to design and verify one themselves.
Ability to design a full-version RISC-V CPU that executes all 40 RV32I instructions
Ability to implement a 5-stage pipeline and hazard control
Ability to design CPU control structures, including CSR, exceptions, interrupts, and traps
Practical skills for systematically verifying CPUs
The complete experience of running a self-designed CPU on an FPGA with an actual program
Design your own full-version CPU using all 40 RV32I instructions
Go beyond a mini CPU and build a 32-bit RISC-V CPU capable of running real programs yourself.
This course covers the process of expanding Volume 2’s TinyRV32I into a Full-Version CPU using the 40 RV32I instructions. Rather than using a completed CPU IP, you will analyze the hardware structures required by the instructions and implement them directly in Verilog RTL.
You will learn how instructions are implemented as an actual datapath and control structure by expanding beyond arithmetic and logical operations to include Shift, Compare, Jump, Byte/Halfword Load·Store, CSR, and System instructions.
Extend the 5-stage pipeline into a structure capable of executing real programs
As the number of instructions increases, simply expanding the Decoder is not enough to complete the CPU.
Extend the ALU, Immediate Generator, Branch/Jump, Load/Store, and Write Back paths, and implement Forwarding and Load-Use Interlock so that the hardware directly handles data dependencies in programs.
If the required value has already been generated, forward it; if it is not yet ready, as with a Load, briefly stall the pipeline. By implementing PC redirection and flushing for branches and jumps, you will understand how a 5-stage pipeline correctly executes real programs.
Implement Byte/Halfword memory access and MMIO
Beyond 32-bit word access, implement Load and Store operations in Byte and Halfword units.
Handle Sign/Zero Extension, Byte Enable, and Address Alignment, and connect the CPU to the FPGA board’s switches, buttons, and LEDs through Memory-Mapped I/O.
Through this, you will understand the entire path of a Load or Store instruction: address calculation → memory access → data selection → register or peripheral.
Integrate CSRs, Exceptions, Interrupts, and Traps into the CPU
In addition to normal instruction execution, directly implement exceptions occurring in the CPU and external Interrupts.
Configure Machine-Level CSRs such as mstatus, mtvec, mepc, mcause, mtval, mie, and mip, and handle ECALL, EBREAK, Illegal Instruction, Misaligned Access, External Interrupts, and MRET.
Through this, you will learn at the RTL level how normal program execution → trap occurrence → handler transfer → state saving → program return takes place within a single CPU.
Verify against standards beyond the in-house Testbench
You cannot conclude that the design is correct simply because the CPU runs several in-house test programs.
This section explains a case in which this CPU's instruction behavior was verified based on the standard. Files related to ACT are not included in the provided materials. Rather than simply checking the PASS result, you will also learn what was executed, what was compared, and to what extent the result demonstrates the CPU's accuracy.
Run actual programs on a CPU that has passed ACT
This is the greatest distinguishing feature of this course.
A case study in designing a CPU that uses 40 RV32I instructions and validating it with the Architecture Compatibility Test, then implementing the same CPU on an actual FPGA.
The completed CPU runs an actual program, reads inputs from the Switches and Buttons, performs computations and branching, and then outputs the results through the LEDs.
The entire process is connected as follows.
40-Instruction RV32I → 5-Stage Pipeline → Hazard Control → CSR/Trap → ACT Verification → FPGA → Real Program
We provide hands-on materials needed for CPU design and verification
We provide the key design and verification materials used in the course so that you can run and modify them yourself.
Verilog RTL
Testbench
Assembly Program
Memory Image
FPGA Top-Level RTL
XDC Pin Constraint
Vivado Implementation Materials
Rather than just viewing the completed result, you can directly reproduce the entire process of design → Simulation → standard verification → FPGA implementation.
This is the full-version stage of the RISC-V CPU design series
This course is the third in a progressively expanding RISC-V CPU design series.
Volume 1 RV32I Instruction Structure and Execution Volume 2 TinyRV32I · 5-Stage Pipeline and FPGA Implementation Volume 340-Instruction Full RV32I · ACT Verification Case · FPGA Program Execution ← You are here Volume 4 AI SoC Integrating the CPU, NPU, and Peripherals
The goal of this course is to share the experience of having a self-designed full-version RISC-V CPU pass standards-based verification and to experience the entire process through running programs on an actual FPGA.
Recommended for these people
Who is this course right for?
Hardware engineers who want to learn the fundamentals of RISC-V CPUs and expand into designing a full-version pipelined CPU
Developers with RTL design experience who want to practice exception handling and standard verification methods in CPU architecture
Those who want to design a more complete CPU themselves, going beyond a simple CPU example
Those who want to go beyond simulation and run the CPU they designed on an actual FPGA.
Those who want to study the process of integrating multiple RTL blocks into a single system
Need to know before starting?
Experience designing and simulating HDL-based RTL using Verilog or VHDL, etc.
Basic CPU architecture (Datapath, Control Unit, pipeline) and foundational knowledge of the RISC-V ISA
Experience using Vivado or similar FPGA development tools and proficiency in utilizing FPGA boards
"In the AI era, the surest response is to build AI semiconductors yourself."
This program is neither a theory-focused university course nor the standardized curriculum of a contract department tailored to specific specifications. Nor is it limited to simply gaining experience using EDA tools or leveraging libraries, as in conventional fragmented practical seminars.
Starting out as a systems semiconductor researcher in Samsung Electronics’ DS Division, winning the Silver Award (Group Chairman’s Award) at the Samsung Technology Awards, and serving as Director of Samsung’s UK and Germany subsidiaries and head of the System LSI Marketing and Sales Group, this unique, hands-on course was designed and FPGA-validated by a practicing engineering professor with 30 years of experience.
The author also provides EdgeAssembler and EdgeVerilog, free web-based tools he developed for hands-on practice. Use EdgeAssembler to convert RISC-V Assembly into Machine Code and Instruction Encoding and inspect the results, and EdgeVerilog to design and simulate RTL. (Free access: https://www.semiconductorschool.co.kr → click the 'LAUNCH' button)
[ Key differentiators for working professionals & aspiring engineers ]
Architecture design skills—rather than connecting off-the-shelf IP or modifying code, you’ll design the RV32I five-stage pipeline (IF·ID·EX·MEM·WB) directly in RTL, including data hazard forwarding, load-use stalls, and branch handling. Understanding and working directly with the five-stage pipeline is what sets your design skills apart.
From Algorithm to RTL — Implement an MNIST CNN as NPU RTL, starting with a Python model and applying Quantization, then verify that the Python and hardware results match bit-for-bit for the same input. The key is to achieve 100% identical results in Python and Verilog and produce results from actual FPGA operation.
CPU + NPU + RTOS integration on a single FPGA — Put everything on a single device: a CPU you designed running an NPU you designed, with FreeRTOS implemented by EdgeChipLab running on top. Students can use all these publicly available RTL and code resources to create their own semiconductor chips.
Free RTL design and simulation environment — With our in-house developed EdgeVerilog v1.0, you can write Verilog RTL, run simulations, and analyze waveforms on a PC or smartphone without signing up or installing any software. We provide a real simulation environment based on Icarus Verilog and 52 design examples for free, making it easy for anyone to get started with semiconductor design practice.
AI Algorithm → RTL Design → FPGA Implementation → Bit-True Verification → AI SoC
It provides an unparalleled, top-tier practical guide not only for undergraduate and graduate students, but also for working professionals looking to advance into next-generation AI semiconductor/SoC design.
Beyond theory to actual AI hardware implementation
It is difficult to develop system-level AI semiconductor design skills with only scattered, fragmented knowledge.
Students will not stop at using finished black-box IP. The goal is to progressively develop the system design skills to design an AI NPU and a 5-stage Pipeline RISC-V CPU themselves, integrate memory and peripherals, port an RTOS on top of them, and ultimately build their own AI SoC.
Starting with the fundamentals of transistors and digital circuits, this course connects FPGA, CPU, and NPU technologies to hardware for accelerating Transformers and LLMs.
We validate the research results on actual FPGA hardware.
This is not a lecture you only watch. Rather than stopping at theory or simple simulations, you will run AI semiconductor circuits you designed yourself on an actual FPGA and perform Bit-True verification, confirming that the Python model and RTL results match down to the last bit.
The instructor also connects research results, including four KCI-indexed papers on AI semiconductors, FPGAs, and RISC-V, to the educational content, taking technologies validated through research into actual design and FPGA implementation. The source code needed for the exercises—including a self-developed RISC-V CPU, Python code for image training, and Verilog RTL—is made available.
Built around the affordable Arty S7-25 FPGA board and the free Vivado design tool, this course enables learners to reproduce the entire process of designing, implementing, and verifying their own work. It can also be used with Digilent FPGA boards, including the Zybo Z7. Simply modify the XDC pin mapping (board) and clock division parameters (RTL) to match your board. The 'MNIST NPU with FPGA' course only requires modifying the XDC pin mapping, while courses that use an OLED and camera require modifying the clock division parameters (RTL).
→ The divider parameters for the course exercises are set based on the Arty S7’s 100 MHz input clock. Since other boards have different input clocks (for example, the Zybo Z7 has a 125 MHz input clock), you will need to recalculate the divider value so that the target frequency remains the same. If you miss this, the screen or video may not display properly,which can easily be mistaken for a code error, so please check.
Free RISC-V and Verilog Practice Environment — EdgeAssembler · EdgeVerilog
You can now start semiconductor design practice in your web browser without installing any software.
EdgeAssembler and EdgeVerilog, developed by the instructor, are free educational tools for hands-on practice. In EdgeAssembler, you can see how RISC-V Assembly is converted into Machine Code, and in EdgeVerilog, you can design and simulate RTL that processes those instructions. They run directly in your web browser, with no need to install separate EDA software.
Instruction Encoding Display: Select a Machine Code row to display its 32-bit binary representation and illustrate the opcode, rd, funct3, rs1, rs2, and imm fields.
Immediate Reconstruction: Reassemble scattered immediate bits, as in B-type and J-type, and display the offset and target address as well.
TinyRV32I Target: Tests tailored to the range of instructions supported by the textbook CPU
Encoding verification tool: Does not execute hardware; actual behavior is verified through EdgeVerilog’s RTL Simulation.
Key Features of EdgeVerilog
Actual RTL Simulation: Compile and simulate based on the open-source Icarus Verilog 12
Waveform Viewer: Observe signal changes, zoom, display HEX/DEC/BIN, position the cursor at signal changes, navigate to the previous or next change, and expand bus bits.
Example Library: Provides 52 digital circuit design examples, including counters, FSMs, and CPUs.
Project management: Write RTL and testbenches, autosave, and ZIP export/import
Mobile Support: Edit RTL, run simulations, and analyze waveforms on smartphones as well
Free of charge: Freely available for educational and non-commercial purposes.
Using the two tools together, learners can explore everything from introductory Verilog-HDL and FSMs to AXI4 and RISC-V CPU design, and verify everything from instruction encoding to RTL.
EdgeAssembler is a tool for checking instruction encoding, and EdgeVerilog is an educational tool for RTL functional verification. FPGA synthesis, implementation, and timing verification are performed in Vivado.
A seamless full-stack roadmap: from fundamentals to a mini LLM accelerator
Each lecture is part of a journey toward completing one vast system, not an isolated fragment.
Step 1: Fundamentals of AI Theory and Image Processing (Including Machine Learning)
Step 2: AI Accelerator (NPU) Design and Verification (Including Machine Learning)
Step 3: 5-Stage Pipeline RISC-V CPU Design and System Integration
Step 4: Advanced AI SoC Implementation and Expansion into a Mini LLM Acceleration Platform (Ongoing Content Updates)
Objective Verification Metrics
All design deliverables from this course have undergone rigorous validation against global standards and by the academic community.
5-Stage Pipeline RISC-V Architecture Verification: In-house developed RISC-V CPU passed the international foundation’s official compliance test (ACT), and its source code was released (GitHub)
Academic Recognition: Four sole-authored academic papers published in IJIBC, a prestigious KCI Grade A journal.
Global Recognition: Published four global Amazon technology books (reached #1 bestseller status)
Real-World Operation Verification Complete: Core IPs, including the RV32I CPU, NPU, vision system, GPS, Transformer, and AURA-Edge SoC, operate flawlessly in the Arty S7 environment.
Take on the challenge. By the end of this process of loading your own code onto the board and verifying the results, you will have leveled up into a hardware engineer with a completely different perspective.