inflearn logo

RISC-V CPU Design for FPGA Implementation ① Learning the RV32I Instruction Structure and Execution Principles with Python

When you decide to build a CPU, you usually start by looking for a circuit diagram. But the moment you unfold the schematic, questions arise that you cannot answer. Why does this block need to be here? Why are there two ports for reading registers? The answer lies entirely in the instructions. Once you know what the instructions require, the circuits you need are determined. It does not work the other way around. There are already many RISC-V courses. But most of them display values on slides, say "This is how it works," and move on. Students have no way to verify whether those values are correct. This course comes with a Python instruction-execution simulator. Type run ADD, and the machine code is assembled on the spot, the 32 bits are broken down by field, and how the registers change appears on the screen. Every number in the textbook is the result of running this tool, and it can be reproduced identically on your screen. Commercial debuggers require licenses, and simulators are difficult to install. This tool only requires Python. No board, license, or installation is needed. You will execute all 40 RV32I instructions yourself without leaving out a single one, discovering along the way what the circuit needs to do.

(5.0) 1 reviews

14 learners

Level Basic

Course period Unlimited

riscv
riscv
cpu-architecture
cpu-architecture
instruction-set-architecture
instruction-set-architecture
FPGA
FPGA
Computer Architecture
Computer Architecture
riscv
riscv
cpu-architecture
cpu-architecture
instruction-set-architecture
instruction-set-architecture
FPGA
FPGA
Computer Architecture
Computer Architecture

What you will gain after the course

  • · You will establish the criteria for designing an instruction set for your own CPU.

  • · You can develop a specific CPU design topic for a capstone design project, competition submission, or graduation project.

  • · You can look at 32-bit machine code, determine its format, split it into fields, and read what instruction it represents.

  • · You can directly execute 40 RV32I instructions and observe changes in the registers and memory.

  • · Can explain which blocks of the circuit an instruction passes through and how the 13 control signals are determined

  • · You will have a Python command execution simulator that you can run again at any time

  • · You can understand the meaning of Bit-True verification and determine what the statement “verified” guarantees.

  • · In technical interviews, you can answer questions about how the CPU works based on hands-on experience rather than memorized explanations.

■ Build a CPU yourself on an FPGA.

The CPU is the brain of the computer. However, there are not many courses that systematically teach you how to design a CPU yourself. Most begin by showing RTL code or explaining the datapath. But the real question is this.

Why does the CPU need to have this structure?

Why are there 32 registers?

Why do we need an ALU?

Why are there two read ports?

Why does Write Back exist?

The answers to all these questions are found in the instructions. A CPU is a circuit built to execute instructions. If you do not understand instructions, you cannot understand a CPU either. This lecture is a process of learning instructions from the perspective of someone who designs CPUs.


■ The Goal of This Course

The goal of this course is not to memorize the RV32I instructions. It is to build the foundation for designing a RISC-V CPU that operates on an FPGA. Going forward, you will…

· Single-Cycle CPU

· Pipeline CPU

· You will proceed through FPGA implementation.

This course is the first step.


■ Why this order?

Many people start by studying RTL in order to build a CPU. However, the order should be reversed.

Instruction → required operation → datapath → control signals → RTL → FPGA

A CPU is the result of implementing the functionality required by instructions. Let’s take ADD as an example.

Two registers must be read, the ALU must perform the calculation, and the result must be written back to a register. These requirements determine the register file, ALU, MUX, and control unit.

This is also why there are two read ports. None of the 40 RV32I instructions reads more than two registers. Once you understand the instructions, you can see why that circuit is necessary.


■ What will you learn?

You will execute all 40 RV32I instructions yourself. This is not simply about showing add x5, x1, x2 → 0x002082B3. You will create machine code yourself, decode it again, execute it, observe the registers change, confirm the memory changes, and even trace the datapath and control signals.

See exactly how a single instruction moves through the CPU from start to finish.


■ What makes this course unique

This course includes RV32I Instruction Studio, a Python-based instruction simulator created by the instructor. No separate FPGA board is required. You do not need a complex simulator either.

If you have only Python installed

· Instruction execution

· Generate machine code

· Decoding

· Check the registers

· Check memory

· Check the datapath

· control signal checks can all be performed directly by you.· tín hiệu điều khiển.


You can reproduce all the numbers in the textbook and obtain the same results.

· Execute all 40 instructions — these are not examples selected from only the frequently used ones

· Learning begins only after all 1,231 built-in validations pass

· We deliberately introduce 14 defects and even test whether the verification actually catches them

· No external libraries — just 550KB in total, and you can get started with a single line after extracting it.


■ Curriculum

Section 1. Understanding the Basics of the CPU

1. How Does a CPU Execute Instructions? — Hands-On Environment and Registers

2. 32-bit Instruction Structure and Immediate Values

Section 2. Executing RV32I Instructions

3. Arithmetic, Logical, and Shift Instructions

4. Load/Store · Branch · JAL/JALR Instructions

Section 3. How Does the CPU Work?

5. Single-Cycle Datapath and Control Signals

Section 4. CPU Verification and Wrap-Up

6. Bit-True Verification and Roadmap for the Next Steps

Each lesson is followed by a lab. The execution order, screen checks, self-assessment items, and example solutions'

It consists of four steps, showing exactly what to enter and in what order.


■ Recommended for

· Those who want to implement a CPU directly on an FPGA

· Those who are just starting out with CPU design

· Those who want to learn RISC-V systematically

· Those who want to connect computer architecture with RTL design

· Those who want to implement a CPU for a capstone design project or competition

· Those preparing for employment in the system semiconductor and fabless industries


■ Practice Environment

All you need is Python and Jupyter Notebook.

https://github.com/estlit/SemiconductorSchool-Labs

→ Level4_Lab_RV32I_Instruction_Studio.zip

Extract the files, and you can get started in Jupyter with the single line below.

%run Lab01.py


■ By the end of the course

You will

· Understand RV32I instructions and

· Be able to explain the CPU datapath,

· Understand why control signals are necessary

· gain the foundation needed to implement a CPU on an FPGA

In the next course, you will implement the instructions you learned this time in Verilog RTL and run them on an FPGA board.

Volume 1 RV32I Instruction Structure and Execution ← You are here

Volume 2 TinyRV32I · 5-Stage Pipeline and FPGA Implementation

Volume 3 Standard CPU · 40 Instructions and Hazard Control

Volume 4 Vision · NPU SoC · Camera and Accelerator Integration


This is the first step in the long journey of building a CPU.

Start now.

Recommended for
these people

Who is this course right for?

  • · Those who want to design their own CPU directly in hardware

  • · System software and firmware developers looking to learn the RISC-V architecture through hands-on practice

  • · Those who want to understand instruction set architecture (ISA) through execution rather than specification documents

  • · University and graduate students preparing to design FPGA-based processors

  • · Those preparing for employment in the system semiconductor and fabless fields who need expertise in CPU architecture

  • · Those who need to interpret assembly code and register states in practical embedded development work

  • · Those who want to verify CPU operation in a hands-on environment without a commercial debugger license

Need to know before starting?

  • Python basics (it’s sufficient to be able to run code and read the results)

  • Computer Architecture Basics (You can follow along without it)

Hello
This is EdgeChipLab

Career Verified

"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.

It is a one-of-a-kind, hands-on course designed and FPGA-validated by a practicing engineering professor with 30 years of experience, who began as a systems semiconductor researcher in Samsung Electronics’ DS Division, won the Silver Prize (Group Chairman’s Award) at the Samsung Technology Awards in the field of design automation, and went on to serve as a Director at Samsung’s UK and German subsidiaries and as the head of the System LSI Marketing and Sales Group.

[ Key differentiators for working professionals & aspiring engineers ]

  • Overcome the limitations of working engineers: Go beyond simply modifying code or using off-the-shelf IP to acquire practical, architecture-level expertise in designing NPUs and CPUs directly in RTL.

  • Establishing a Full-Flow practical system: Complete the entire value chain, from analyzing AI algorithms to FPGA implementation and Bit-True hardware integration verification, and extending to an AI SoC based on a CPU + NPU + RTOS.

  • Field validation complete: Going beyond theory taught in university classrooms, we deliver proven processes that can be applied immediately in real-world work, distilling design expertise from the front lines of industry.

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

For undergraduates and graduate students, as well as working professionals seeking to advance as next-generation AI semiconductor/SoC designers, it provides an unparalleled, top-tier practical guide.

 

Beyond theory to actual AI hardware implementation

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

Students do not stop at using completed black-box IP. The goal is to progressively develop the system design skills needed to design an AI NPU and 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 lecture exercises are configured with divider parameters based on Arty S7’s 100 MHz input clock. Since other boards have different input clocks (e.g., Zybo Z7 uses 125 MHz), you will need to recalculate the divider values so that the target frequency remains the same. If you overlook this, the screen or video may not display properly,so please check, as it can easily be mistaken for a code error.

 

A seamless full-stack roadmap: from the basics to a mini LLM accelerator

Every lecture is not an isolated fragment, but part of 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 deliverables from this course have undergone rigorous validation against global standards and by the academic community.

  • RISC-V Architecture Verification: In-house developed RISC-V CPU, passed the International Foundation’s official compliance test (ACT), and source code released (GitHub)

  • Academic Authority: Four Sole-Author Academic Papers (published in the prestigious KCI A-ranked journal IJIBC)

  • Global Recognition: Published four global Amazon technology books (reached #1 bestseller status)


    Published books: Roger Kim: books, biography, latest update

  • 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 time you complete this process of uploading code to the board yourself and checking the results, you will have leveled up into a hardware engineer with a completely different perspective than before.

More

Curriculum

All

6 lectures ∙ (1hr 41min)

Published: 
Last updated: 

Reviews

All

1 reviews

5.0

1 reviews

EdgeChipLab's other courses

Check out other courses by the instructor!

Similar courses

Explore other courses in the same field!

25% off for new members

$18.60

25%

$28.60