Skip to content

Welcome to the APB (Advanced Peripheral Bus) Master-Slave implementation in Verilog RTL! 🎯 This project demonstrates the full APB protocol including master and slave FSM-based logic with memory operations, protocol error detection, address range validation, and extensive modular testbenches.

Notifications You must be signed in to change notification settings

DuttPanchal04/APB-Master-Slave-Verilog-Simulation-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ APB Master-Slave Verilog Design

Welcome to the APB (Advanced Peripheral Bus) Master-Slave implementation in Verilog RTL! 🎯 This project demonstrates the full APB protocol including master and slave FSM-based logic with memory operations, protocol error detection, address range validation, and extensive modular testbenches.

πŸ’‘ Built as part of my self-learning and internship experience in the field of VLSI Design Verification using EDA Playground.


πŸ“š Table of Contents


🧠 What is APB?

APB (Advanced Peripheral Bus) is part of the AMBA protocol suite from ARM, ideal for connecting low-power peripherals such as timers, UART, GPIOs.

πŸ”Œ Key Signals:

  • PCLK – Clock
  • PRESETn – Reset (active-low)
  • PADDR – Address bus
  • PWDATA – Write data
  • PRDATA – Read data
  • PWRITE – Write enable
  • PSEL – Slave select
  • PENABLE – Transfer phase control
  • PREADY – Slave ready response
  • PSLVERR – Slave Error indicator 🚨

🧩 Features

🧭 Master Design (apb_master.v)

  • FSM with states: IDLE β†’ SETUP β†’ ENABLE
  • Accepts transfer signal to start transactions
  • Supports both read (READ_WRITE=0) and write (READ_WRITE=1) operations
  • Transfers address and data only in correct state
  • Receives read data when PREADY is high

πŸ—οΈ Slave Design (apb_slave.v)

  • FSM: IDLE β†’ SETUP β†’ ENABLE
  • Implements a 256-byte internal memory 🧠
  • Valid address range: 0x05 to 0xF1
  • Detects protocol violations (e.g., PENABLE high in SETUP)
  • Responds with PSLVERR=1 for invalid address or protocol error
  • Handles wait state using PREADY

πŸ§ͺ Simulation Guide

πŸ”— EDA Playground

You can run this project on EDA Playground directly:

πŸ‘‰ Click Here to Simulate APB Master on EDA Playground πŸ‘‰ Click Here to Simulate APB Slave on EDA Playground

πŸ”¬ Testcase Scenarios

Each scenario can be simulated using $test$plusargs():

πŸ§ͺ APB Slave Testbench (apb_slave_tb.v)

Plusarg Description
+WRITE_CONT Continuous write to multiple valid addresses πŸ“
+READ_CONT Continuous read from valid addresses πŸ“–
+WRITE_RANDOM Random data and address write ✨
+DEF_MEM_LOC View default memory content after reset 🧼
+FINAL_MEM Dump full memory after transactions πŸ“Š
+PSLVERR_AT_WRITE Invalid address write triggers PSLVERR 🚨
+PSLVERR_AT_READ Invalid address read triggers PSLVERR πŸ›‘
+WRITE_PENAB1_AT_IDLE Protocol error (PENABLE=1 during IDLE) ⚠️
+READ_PENAB1_AT_IDLE Protocol error on read ⚠️
+RST_CHECK Check memory reset functionality and data clearance πŸ”
+NO_XFER_PSEL_ONLY PSEL toggled without PENABLE (no real transfers) ❌
+BURST_WRITE_INVALID Back-to-back writes without deasserting PENABLE ❗

πŸ§ͺ APB Master Testbench (apb_master_tb.v)

Plusarg Description
+SINGLE_WRITE Single write transaction initiated by master ✍️
+SINGLE_READ Single read transaction by master 🧐
+WRITE_AT_PREADY_LOW Write attempt when PREADY is low (ignored) πŸ›‘
+READ_AT_PREADY_LOW Read attempt when PREADY is low (ignored) πŸ›‘
+TRANSFER_LOW Transfer signal permanently low (no transaction) β›”
+RST_CHECK Reset applied during active transfer (reset test) πŸ”„
+RANDOM_WRITE Random address and data write from master 🎲
+WRITE_CONT Continuous writes (3 back-to-back) from master πŸ’Ύ

πŸ“ˆ Waveform Debugging ( Snapshots of Results of Some Testcases )

Single Write and Single Read Operation - APB Master SINGLE WRITE AND READ - APB MASTER

Write and Read Operation - APB Slave WRITE AND READ - APB SLAVE

Slave Error Response - APB Slave SLAVE ERROR - APB SLAVE

Protocol Violation - APB Slave Protocol Error - APB SLAVE

Run more testcases from EDA Playground!


πŸ“Œ Learning Outcomes

✨ Designed and verified a full-fledged APB master-slave interface
πŸ› οΈ Practiced FSM-based control logic in Verilog
βœ… Gained hands-on debugging with plusargs and $monitor()
🧠 Understood protocol behavior and bus transactions
🌊 Simulated and analyzed waveform using GTKWave


🚧 Future Enhancements

  • βœ… Integrate APB Master + Slave in one top module
  • βŒ› Add configurable wait states for PREADY
  • πŸ” Add burst transfer support (APB 3.0 feature)
  • πŸ›‘οΈ Add assertion checks (SVA)
  • πŸ”Œ APB to AHB Bridge
  • 🌍 Open-source toolchain integration

Reference

πŸ‘¨β€πŸ’» Author

Dutt Panchal

πŸ™Œ Thanks for visiting! Happy Simulating ⚑

About

Welcome to the APB (Advanced Peripheral Bus) Master-Slave implementation in Verilog RTL! 🎯 This project demonstrates the full APB protocol including master and slave FSM-based logic with memory operations, protocol error detection, address range validation, and extensive modular testbenches.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published