inflearn logo

RISC-V CPU Design for FPGA Implementation ② Building a 5-Stage Pipeline TinyRV32I from Scratch

Starting from the operating principles of RISC-V instructions, this is a hands-on CPU design course in which you directly design a 32-bit CPU with a five-stage pipeline, completing the process from Verilog RTL implementation and simulation verification to running it on a physical FPGA. Among the 40 RV32I instructions, 14 instructions essential for learning the core structure of a CPU are selected to progressively build TinyRV32I. You will directly design and verify the key structures that make up a real CPU, including the datapath, pipeline registers, ALU and control circuits, branches, hazards, stalls and flushes, and memory-mapped I/O. The Verilog RTL, testbenches, assembly programs, memory images, and FPGA constraint files used in the course are provided. Ultimately, you will run actual programs on an Arty S7-25 FPGA using the CPU you designed. This course does not end here. After completing the core CPU structure through TinyRV32I, the series continues as a step-by-step CPU design program in which you expand it into a Full RV32I CPU supporting all 40 RV32I instructions in the follow-up course.

2 learners are taking this course

Level Intermediate

Course period Unlimited

Architecture
Architecture
FPGA
FPGA
verilog
verilog
cpu
cpu
riscv
riscv
Architecture
Architecture
FPGA
FPGA
verilog
verilog
cpu
cpu
riscv
riscv

What you will gain after the course

  • You can design a 5-stage pipeline RISC-V CPU yourself.

  • It has the source code. This is the first step toward creating your own proprietary ISA and designing a CPU.

  • You can complete a TinyRV32I CPU consisting of 14 instructions that operates as Verilog RTL.

  • You can program your own designed CPU and run it on an FPGA.

  • You can verify CPU operation through command-specific testbenches and simulations.

This is a rare course where you design a RISC-V CPU yourself and run it on an FPGA

Understanding CPU architecture theoretically and designing a functioning CPU yourself are entirely different experiences.

This course is not about running a completed CPU black-box block on an FPGA. Starting with the question of how RISC-V instructions are actually executed in hardware, we derive the necessary hardware structure step by step and implement it directly as a white box in Verilog RTL.

The goal is to complete a 32-bit TinyRV32I CPU with a 5-stage pipeline structure and run programs directly on an Arty S7-25 FPGA.


Why start with 14 of the 40 RV32I instructions?

Rather than implementing many instructions from the outset, it is important to accurately understand the CPU’s core structure and complete it yourself.

In this course, we will implement TinyRV32I by selecting 14 of the 40 RV32I instructions needed to learn the CPU’s core operations, including arithmetic and logical operations, memory access, and branching.

TinyRV32I is not a CPU with a reduced data width. It fully retains 32-bit data and addresses, 32 general-purpose registers, and a 5-stage pipeline structure, while limiting the range of supported instructions solely for educational purposes.

Therefore, rather than simply following a simplified example, this is a process of gradually completing the core structure of an actual CPU design.


Implement a 5-stage pipeline CPU in RTL

The instruction execution process is divided into the following five stages and implemented in actual hardware.

  • Instruction Fetch

  • Instruction Decode

  • Execute

  • Memory Access

  • Write Back

Starting with basic blocks such as the Program Counter, Register File, Immediate Generator, Decoder, and ALU, we progressively implement everything through Pipeline Registers, Branch control, Hazard handling, Stall, and Flush.

Rather than merely learning each block independently, you will connect how data and control signals move throughout the CPU to complete a single processor.


Connect the memory and FPGA peripherals

We don’t stop at implementing just the CPU core.

Implement the memory structure for Load and Store operations, and use Memory-Mapped I/O to connect the CPU to the FPGA board’s switches, buttons, and LEDs.

Through this, you will experience the process of controlling actual FPGA inputs and outputs, going beyond simply executing instructions in simulation.


Proceed with design and verification together

Writing the RTL code alone does not complete the CPU design.

Each functional block is verified step by step through testbenches and simulation, after which the entire CPU is integrated to confirm that actual programs execute correctly.

Through this process, you will go beyond simply learning Verilog syntax and experience the hardware design process of designing, verifying, and troubleshooting RTL.


All the source code needed to build and practice with the CPU is provided

All the practice files used in the course are provided, allowing students to reproduce and modify the designs themselves.

  • Verilog RTL

  • Testbench

  • Assembly program

  • Memory Image

  • FPGA constraint file

  • Practical materials needed for FPGA implementation

Rather than just viewing the completed result, you can learn how the CPU works internally by directly examining and modifying the code.


Finally, you will run a program on an actual FPGA

After synthesizing and implementing the completed TinyRV32I in Vivado, you will generate a Bitstream and deploy it directly to the lightweight, affordable Arty S7-25 FPGA. You will then verify that the CPU you designed executes actual programs, receives input from the FPGA board, and outputs the results. (Other boards such as the Zybo-Z7 can also be used; only the xdc pin mapping needs to be modified.)

The entire process is connected as follows.

RISC-V instructions → CPU architecture → datapath → 5-stage pipeline → Verilog RTL → testbench verification → CPU integration → program preparation → Vivado synthesis → FPGA execution


continues as a 40-instruction standard CPU design series

This course is not a process that ends with a single hands-on exercise; it is part of a RISC-V CPU design series that expands step by step.

Volume 1 RV32I Instruction Structure and Execution

Volume 2 TinyRV32I · 5-Stage Pipeline and FPGA Implementation ← You are here

Volume 3 Standard CPU · 40 Instructions and Hazard Control

Volume 4 Vision · NPU SoC · Camera and Accelerator Integration

It starts with understanding the instructions, then building the CPU yourself and expanding it to Full RV32I.


The goal of this course is not to become someone who uses a completed CPU, but to develop the engineering skills to understand the CPU's internal architecture and design and verify it directly in RTL.

Take on the challenge. By the end of this process of putting your own code on the board and checking the results, you will have leveled up into a hardware engineer with a completely different perspective.

Recommended for
these people

Who is this course right for?

  • An engineering student who has studied computer architecture theory but has no hands-on CPU design experience

  • An embedded developer who wants to directly implement and verify the RISC-V architecture on an FPGA

  • Learners who have studied Verilog but have not yet built a polished system themselves

  • Learners preparing for employment in the semiconductor and digital design fields who need a portfolio

Need to know before starting?

  • Basic concepts of digital logic circuits and computer architecture (registers, ALU, memory)

  • Basic syntax of Verilog HDL and experience writing simple modules

  • Basic Understanding of the RISC-V Instruction Set or Take Series Volume 1 (Designing a RISC-V CPU for FPGA Implementation ① Learning the RV32I Instruction Structure and Execution Principles with Python)

Hello
This is EdgeChipLab

Career Verified

Design and implement AI semiconductors directly on FPGAs

As a current university professor, I have incorporated 30 years of experience in the system semiconductor industry, along with expertise in AI semiconductor research and education.

This is a hands-on curriculum designed by a professor who teaches semiconductor engineering, based on direct design and FPGA verification experience—from starting as a systems semiconductor researcher in Samsung Electronics’ DS Division, to serving as a Director at the company’s UK and German subsidiaries, and then leading the System LSI marketing and sales group.

This is not simply a course on how to use FPGAs.
It is designed to help you understand AI algorithms → directly design NPUs and CPUs in RTL → implement them on an FPGA → verify them on actual hardware → and ultimately expand to AI SoCs.

AI Algorithm → RTL Design → FPGA Implementation → Bit-True Verification → AI SoC

 

Beyond theory to real-world AI hardware implementation

It is difficult to develop system-level AI semiconductor design capabilities with only fragmented, scattered knowledge.

Students do not stop at using finished black-box IP. The goal is to gradually develop the system design skills needed to design an AI NPU and RISC-V CPU themselves, integrate memory and peripherals, and ultimately build their own AI SoC.

Starting with the fundamentals of transistors and digital circuits, you will progress through FPGAs, CPUs, and NPUs to hardware for accelerating Transformers and LLMs.

 

We validate the research results on actual FPGA hardware.

This is not a lecture you simply watch. Rather than stopping at theory or basic simulations, you will run AI semiconductor circuits you designed yourself on an actual FPGA and perform Bit-True verification to confirm that the Python model and RTL results match down to the last bit.

The instructor’s research findings, including four KCI-listed papers on AI semiconductors, FPGAs, and RISC-V, are also connected to the educational content, enabling technologies validated through research to be applied to actual designs and FPGA implementations.

We make the source code needed for hands-on practice publicly available, including our self-developed RISC-V CPU, Python code for image training, and Verilog RTL.

Centered around the affordable Arty S7-25 FPGA board and the free Vivado design tool, this course is designed to enable learners to reproduce the entire process of designing, implementing, and verifying their own work.

It is also compatible with Digilent FPGA boards, including the Zybo Z7. You can use it by modifying the XDC pin mapping (board) and clock division parameters (RTL) to match the board.

The 'MNIST NPU with FPGA' course only requires modifying the XDC pin mapping, while courses using an OLED and Camera require modifying the clock division parameters (RTL).

→The lecture exercises are configured with clock division parameters based on Arty S7’s 100 MHz input clock. Since other boards have different input clocks (for example, Zybo Z7 has 125 MHz), you will need to recalculate the division values so that the target frequency remains the same. If you miss this part, the screen or video may not display properly, which can easily be mistaken for a code error, so please check it.

 

A Seamless Full-Stack Roadmap: From the Basics to a mini LLM Accelerator

All the lectures are not independent fragments, but a journey toward completing one vast system.

  • Step 1: AI Theory and Image Processing Fundamentals (including Machine Learning)

  • Step 2: AI Accelerator (NPU) Design and Verification (Including Machine Learning)

  • Step 3: RISC-V CPU Design and System Integration

  • Step 4: Advanced AI SoC Implementation and Expansion into a mini LLM Acceleration Platform (Continuous Content Updates)

     

 

Objective verification metrics

All design outcomes from this course have undergone rigorous validation against global standards and by academia.

  • RISC-V Architecture Verification: In-house developed RISC-V CPU, passed the international foundation’s official compliance test (ACT), with source code released publicly (GitHub)

  • Academic Authority: Four sole-authored academic papers (published in the prestigious KCI A-rated journal IJIBC)

  • Global Recognition: Authored and published two global Amazon technology books (reached No. 3 on the bestseller list)

  • Real-world operation verified: 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 time you complete this process of uploading code directly to the board and verifying the results, you will have leveled up into a hardware engineer with a completely different perspective.

More

Curriculum

All

10 lectures ∙ (3hr 30min)

Published: 
Last updated: 

Reviews

Not enough reviews.
Please write a valuable review that helps everyone!

EdgeChipLab's other courses

Check out other courses by the instructor!

Similar courses

Explore other courses in the same field!

Limited time deal

$108.90

14%

$127.60