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.
· 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.
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
"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.
Designed and FPGA-verified by a practicing engineering professor with 30 years of experience, who began as a system semiconductor researcher at Samsung Electronics’ DS Division, received the Silver Award (Group Chairman’s Award) at the Samsung Technology Awards for design automation, and served as Director of Samsung’s UK and German subsidiaries and head of the System LSI marketing and sales group, this is a one-of-a-kind, hands-on course.
We also provide free web-based practice tools developed by the author: EdgeTCAD, EdgeAssembler, and EdgeVerilog.
We have created an educational environment where students can directly simulate and analyze the structures, operating principles, and electrical properties of semiconductor devices such as PN junctions, MOS capacitors, planar MOSFETs, 3D FinFETs, and GAA on their own PCs using the semiconductor device simulation tool EdgeTCAD.
With EdgeAssembler, you can convert RISC-V Assembly into Machine Code and Instruction Encoding and inspect the results, and use EdgeVerilog to design RTL and simulate it on your PC.
[ Key differentiators for industry professionals and aspiring engineers ]
Architecture design skills—rather than connecting off-the-shelf IP or modifying code, directly design the RV32I five-stage Pipeline (IF·ID·EX·MEM·WB) in RTL, including Data Hazard Forwarding, Load-Use Stall, and Branch handling. Understanding and directly working 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.