Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Memory Management Unit (MMU) Design Using Verilog HDL

MMU Architecture

๐Ÿ“– Overview

This project implements a 32-bit Memory Management Unit (MMU) in Verilog HDL capable of translating virtual addresses into physical addresses using a Translation Lookaside Buffer (TLB) and a Page Table Walker (PTW).

The MMU supports:

  • Virtual-to-Physical Address Translation
  • TLB-Based Address Lookup
  • Page Table Walking (PTW)
  • Permission Checking
  • Execute Fault Detection
  • Bypass Mode Operation
  • Verification using Icarus Verilog and GTKWave

This project demonstrates key concepts in Computer Architecture, Memory Management, RTL Design, and Digital System Verification.


โœจ Features

  • โœ… 32-bit Virtual Memory Translation
  • โœ… Translation Lookaside Buffer (TLB)
  • โœ… Page Table Walker (PTW)
  • โœ… Permission Checking
  • โœ… Execute Fault Detection
  • โœ… TLB Refill Mechanism
  • โœ… Physical Address Generation
  • โœ… Bypass Translation Mode
  • โœ… Self-Checking Testbenches
  • โœ… GTKWave Verification

๐Ÿ—๏ธ MMU Architecture

MMU Architecture Diagram

Major Components

TLB (Translation Lookaside Buffer)

  • Stores recent address translations
  • Performs VPN + ASID matching
  • Provides fast translation lookup

PTW (Page Table Walker)

  • Handles TLB misses
  • Reads page table entries from memory
  • Extracts PPN and permission bits

Permission Checker

  • Read Permission Validation
  • Write Permission Validation
  • Execute Permission Validation
  • User/Supervisor Access Checking

Physical Address Generator

Generates:

Physical Address = {PPN, Offset}

๐Ÿ“‚ Project Structure

MMU-Design-Verilog-HDL
โ”‚
โ”œโ”€โ”€ docs
โ”‚   โ””โ”€โ”€ MMU_Project_Documentation.md
โ”‚
โ”œโ”€โ”€ images
โ”‚   โ”œโ”€โ”€ bypass_mode.png
โ”‚   โ”œโ”€โ”€ execute_fault.png
โ”‚   โ”œโ”€โ”€ mmu_architecture.png
โ”‚   โ”œโ”€โ”€ mmu_waveform.png
โ”‚   โ”œโ”€โ”€ tlb_hit.png
โ”‚   โ””โ”€โ”€ tlb_miss_refill.png
โ”‚
โ”œโ”€โ”€ reports
โ”‚   โ””โ”€โ”€ Verification_Report.md
โ”‚
โ”œโ”€โ”€ rtl
โ”‚   โ”œโ”€โ”€ mmu.v
โ”‚   โ”œโ”€โ”€ perm_check.v
โ”‚   โ”œโ”€โ”€ ptw.v
โ”‚   โ””โ”€โ”€ tlb.v
โ”‚
โ”œโ”€โ”€ tb
โ”‚   โ”œโ”€โ”€ mem_bram.v
โ”‚   โ”œโ”€โ”€ mem_bram_tb.v
โ”‚   โ”œโ”€โ”€ mmu_tb.v
โ”‚   โ”œโ”€โ”€ perm_check_tb.v
โ”‚   โ”œโ”€โ”€ ptw_tb.v
โ”‚   โ””โ”€โ”€ tlb_tb.v
โ”‚
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ LICENSE
โ””โ”€โ”€ README.md

๐Ÿง  Address Format

Virtual Address (32-bit)

31                     12 11          0
+-----------------------+-------------+
| Virtual Page Number   |   Offset    |
+-----------------------+-------------+
         20 bits            12 bits

Physical Address (32-bit)

31                     12 11          0
+-----------------------+-------------+
| Physical Page Number  |   Offset    |
+-----------------------+-------------+
         20 bits            12 bits

โš™๏ธ Simulation

Compile

iverilog -g2012 -o mmu_test \
tb/mmu_tb.v \
tb/mem_bram.v \
rtl/mmu.v \
rtl/tlb.v \
rtl/ptw.v \
rtl/perm_check.v

Run

vvp mmu_test

Open Waveforms

gtkwave mmu.vcd

๐Ÿ“Š Simulation Waveform

MMU Waveform


๐Ÿงช Verification Results

Test 1 โ€” TLB Miss + Refill

Result:

PA = 00ABC100

โœ… PASS


Test 2 โ€” TLB Hit

Result:

PA = 00ABC200

โœ… PASS


Test 3 โ€” Execute Fault Detection

Result:

exec_fault = 1

โœ… PASS


Test 4 โ€” Bypass Mode

Result:

PA = CAFEBABE

โœ… PASS


๐Ÿ“ˆ Final Simulation Output

TEST1 : TLB MISS + REFILL
PA=00abc100

TEST2 : TLB HIT
PA=00abc200

TEST3 : EXECUTE FAULT
exec_fault=1

TEST4 : BYPASS
PA=cafebabe

MMU TEST COMPLETE

๐Ÿ›  Tools Used

Tool Purpose
Verilog HDL RTL Design
Icarus Verilog Simulation
GTKWave Waveform Analysis
Git Version Control
GitHub Repository Hosting
VS Code Development Environment

๐Ÿ“š Learning Outcomes

  • Memory Management Concepts
  • Virtual Memory Translation
  • Translation Lookaside Buffers (TLB)
  • Page Table Walking (PTW)
  • Permission Checking Logic
  • RTL Design Methodology
  • Functional Verification
  • Waveform Debugging
  • Digital System Design

๐Ÿ”ฎ Future Enhancements

  • 4-Way Set Associative TLB
  • Multi-Level Page Tables
  • TLB Replacement Policies
  • RISC-V Sv32 Integration
  • Performance Counters
  • FPGA Deployment
  • AXI Memory Interface

๐Ÿ“„ Documentation

Detailed documentation:

docs/MMU_Project_Documentation.md

Verification report:

reports/Verification_Report.md

๐Ÿ‘ฉโ€๐Ÿ’ป Author

Vaishnava Devi

B.Sc. Digital and Cyber Forensic Science


๐Ÿ“œ License

This project is licensed under the MIT License.

About

Parameterizable 32-bit Memory Management Unit (MMU) designed in Verilog HDL featuring virtual memory translation, TLB-based address lookup, ASID-aware translation, Page Table Walker (PTW), permission checking, page and execute fault handling, self-checking verification testbenches & comprehensive waveform verification using Icarus Verilog & GTKwave

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages