# godelmachine/ahb2 architecture

> Architecture diagram of the GitHub repository godelmachine/ahb2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/godelmachine/ahb2
- Repository: https://github.com/godelmachine/ahb2

## Overview

##### Project Type and Purpose
- This project is a verification IP (VIP) designed specifically for the AMBA AHB 2.0 interface.
- It uses SystemVerilog and the UVM (Universal Verification Methodology) framework.
- The purpose of this project is to simulate, verify, and validate the design and behavior of AHB bus transactions using dedicated agents and a test environment.

##### File Structure
- Top-level directories are organized around key UVM verification components:
- "ahb_env": Contains the UVM environment files such as coverage, sequences, configuration, and the top-level environment definition.
- "ahb_master_agent": Houses files related to the AHB master agent, including its driver, monitor, configuration, and sequences.
- "ahb_slv_agent": Contains similar UVM components (driver, monitor, sequences, and configuration) but for the slave agent.
- "reset_agent": Provides reset mechanism files with a driver and sequences to manage reset behavior within the testbench.
- "ahb_test": Contains testbench package definitions and test cases.
- "rtl": Likely includes a minimal RTL module (an AHB interface definition) that is being verified by the VIP.
- "sim": Contains simulation-related files, such as a Makefile, simulation scripts, and test case configurations.

##### Key Insights from the README
- The README clearly describes the project as an AMBA AHB 2.0 VIP in UVM, which confirms that the primary focus is to provide a comprehensive verification environment for the AHB bus.
- The structure supports UVM best practices with dedicated agents for different roles (master, slave, reset) and an overarching environment to tie everything together.

a. Main Components:
- AHB Environment (ahb_env): The top-level testbench environment that coordinates various agents and test sequences.
- AHB Master Agent (ahb_master_agent): Contains driver, monitor, configuration, and sequencers for acting as the AHB bus master.
- AHB Slave Agent (ahb_slv_agent): Similarly, contains the necessary components to simulate an AHB slave.
- Reset Agent (reset_agent): Responsible for generating and managing reset sequences for the testbench.
- DUT/Interface (rtl): Represents the actual AHB interface design or a minimal DUT, which the VIP tests interact with.
- Simulation Control (sim): Encompasses the Makefile, simulation scripts, and test case configurations used to launch and run the verification environment.
- Test Suites (ahb_test): Contains specific test cases and any supporting package definitions.

b. Relationships and Interactions:
- The AHB Environment acts as the central hub that instantiates the master, slave, and reset agents.
- The agents interact with the DUT via the provided AHB interface defined in the RTL.
- The simulation control (in the sim directory) orchestrates the simulation flow and test case execution.
- Data flows include stimulus generation from sequences flowing to drivers, which then drive transactions onto the DUT, while monitors capture and check the transactions for correctness and coverage.

c. Important Architectural Patterns/Design Principles:
- UVM Architecture: The use of agents (master, slave, reset) along with sequencers, drivers, monitors, and configuration objects.
- Modular Separation: The project is clearly separated into distinct modules that help isolate responsibilities (e.g., stimulus generation, transaction monitoring, reset handling).
- Reusability and Extensibility: The separation into agents and environment components makes it easier to extend or modify the testbench for additional features or different AHB configurations.

d. Relevant Technologies/Frameworks:
- SystemVerilog and UVM for creating a reusable and scalable verification environment.
- Simulation scripting (Perl script in sim, Makefile, and simulation command files) to control test execution.
- Coverage collection (indicated by files like ahb_coverage.svh) to ensure comprehensive verification.

##### Specific Elements
- Clear, labeled blocks for each of the main components:
- AHB Environment (ahb_env)
- AHB Master Agent (ahb_master_agent)
- AHB Slave Agent (ahb_slv_agent)
- Reset Agent (reset_agent)
- DUT/RTL (rtl)
- Simulation Framework (sim)
- Test Suites (ahb_test)
- From sequencers (in agents) to drivers and then to the DUT.
- Feedback paths from monitors to the environment for coverage checking.
- Visual distinctions:
- Annotations for any critical interfaces or interaction protocols:

##### Detailed but Clear
- Remember that clarity and accuracy will help stakeholders (developers, verification engineers, etc.) understand how the components collaborate to achieve overall verification of the AHB 2.0 protocol.

## Diagram (Mermaid)

```mermaid
flowchart TD
    TEST["Test Suites"]:::tests
    SIM["Simulation Control"]:::control
    ENV["AHB Environment"]:::environment
    MASTER["AHB Master Agent"]:::agent
    SLAVE["AHB Slave Agent"]:::agent
    RESET["Reset Agent"]:::agent
    DUT["DUT/Interface"]:::dut

    TEST -->|"configures"| ENV
    SIM -->|"launches"| ENV
    ENV -->|"instantiates"| MASTER
    ENV -->|"instantiates"| SLAVE
    ENV -->|"instantiates"| RESET
    MASTER -->|"drives_transactions"| DUT
    SLAVE -->|"drives_transactions"| DUT
    RESET -->|"applies_reset"| DUT
    DUT -->|"monitored_by"| ENV

    click ENV "https://github.com/godelmachine/ahb2/tree/master/ahb_env"
    click MASTER "https://github.com/godelmachine/ahb2/tree/master/ahb_master_agent"
    click SLAVE "https://github.com/godelmachine/ahb2/tree/master/ahb_slv_agent"
    click RESET "https://github.com/godelmachine/ahb2/tree/master/reset_agent"
    click DUT "https://github.com/godelmachine/ahb2/blob/master/rtl/ahb_intf.sv"
    click SIM "https://github.com/godelmachine/ahb2/tree/master/sim"
    click TEST "https://github.com/godelmachine/ahb2/tree/master/ahb_test"

    classDef environment fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef agent fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef control fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef tests fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef dut fill:#F08080,stroke:#333,stroke-width:2px;
```
