# parhamsoltani/lan_zynq architecture

> Architecture diagram of the GitHub repository parhamsoltani/lan_zynq, 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/parhamsoltani/lan_zynq
- Repository: https://github.com/parhamsoltani/lan_zynq

## Overview

##### Main Components
- Embedded lwIP Network Stack: Show the lwIP stack as part of the software running on the PS. Indicate that it is responsible for handling UDP/TCP protocols, DHCP client, and IP (IPv4/IPv6) functionalities.
- UDP and TCP Server Modules: Represent the dedicated UDP server functions and the TCP echo server (operating on port 7) as distinct “server” blocks, integrated into the lwIP application-level layer.
- Ethernet Interface / Processing System MAC: Include a block for the physical Ethernet interface (xemacps) which is linked to the PS. Also note that the “xemacpsif_physpeed” component may be modified to match the specific board/part.
- Vivado Hardware Design & IP: Optionally include a block that shows the hardware design flow (e.g., the processing system IP configuration, constraints such as the .xdc files, and the bitstream generated in Vivado). This emphasizes the integration between the programmable logic and the processing system side.
- SDK Development Environment: Illustrate that the firmware (including main.c and the corresponding lwIP server code) is developed in the SDK and is compiled and linked with embedded libraries.

##### Relationships and Data Flow
- That the lwIP stack delivers data to both UDP and TCP server modules.
- That the main application (implemented in main.c) initializes the lwIP stack, sets up the UDP server (using UDPServer_init, Send_UDP, and the recv_callback_udp callback), and the TCP echo service.
- A directional data flow that starts at the network interface, passes through the lwIP stack, reaches the application layer (server logic), and then the responses are routed back out to the network interface.

##### Architectural Design Patterns and Technologies
- Separation between hardware and software by distinguishing the processing system (hardware block) and the embedded software running on it.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Hardware Layer"
        PS["ZYNQ-7020 Processing System (PS)"]:::hardware
        ETH["Ethernet Interface (xemacps MAC)"]:::hardware
        Vivado["Vivado Hardware Design & IP"]:::hardware
    end

    subgraph "Software Layer"
        SDK["SDK Development Environment"]:::software
        lwIP["Embedded lwIP Network Stack"]:::software
        Servers["UDP and TCP Server Modules"]:::app
    end

    %% Data Flow Connections
    ETH -->|"receive_packets"| lwIP
    lwIP -->|"deliver_data"| Servers
    Servers -->|"send_response"| lwIP
    lwIP -->|"transmit_packets"| ETH

    %% Hardware/Software Integration
    PS -->|"hosts_fw"| lwIP
    PS -->|"hosts_eth"| ETH
    Vivado -->|"configures"| PS
    SDK -->|"develops_fw"| lwIP
    SDK -->|"develops_app"| Servers

    %% Legend Subgraph
    subgraph "Legend"
        L1["Blue: Hardware Modules"]
        L2["Green: System/Library Software"]
        L3["Orange: Application Modules"]
    end

    %% Click Events
    click PS "https://github.com/parhamsoltani/lan_zynq/tree/main/LAN_PS.srcs/sources_1/bd/design_1/ip/design_1_processing_system7_0_0"
    click lwIP "https://github.com/parhamsoltani/lan_zynq/tree/main/LAN_PS.sdk/standalone_bsp_0/ps7_cortexa9_0/include/lwip"
    click Servers "https://github.com/parhamsoltani/lan_zynq/tree/main/LAN_PS.sdk/Echo_LAN/src"
    click ETH "https://github.com/parhamsoltani/lan_zynq/tree/main/PHYSPEED"
    click Vivado "https://github.com/parhamsoltani/lan_zynq/tree/main/LAN_PS.srcs/sources_1/bd/design_1"
    click SDK "https://github.com/parhamsoltani/lan_zynq/blob/main/LAN_PS.sdk"

    %% Style Definitions
    classDef hardware fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef software fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef app fill:#FFA500,stroke:#000,stroke-width:2px;
```
