📈
Ween's Lab
UdemyYouTubeTikTok
  • Welcome
  • 📻FPGA Tutorials
    • FPGA Boards: Getting Started
      • Getting Started with PYNQ on Kria KV260 Vision AI Starter Kit
      • Getting Started with PYNQ on Red Pitaya STEMlab 125-14
      • Getting Started with PYNQ on ZYBO
    • FPGA Ethernet Tutorial
      • FPGA Tutorial Ethernet 1: Simple TCP Server
    • PYNQ FPGA Tutorial 101
      • Part 0: Introduction
      • Part 1: GPIO
      • Part 2: Custom IP
      • Part 3: Memory
      • Part 4: ANN Processor
    • PYNQ FPGA Tutorial 102
      • Part 0: Introduction
      • Part 1: Memory Mapped
      • Part 2: Direct Memory Access
      • Part 3: AXI-Lite Multiplier
      • Part 4: AXI-Stream Multiplier with DMA
      • Part 5: AXI-Lite GCD
      • Part 6: AXI-Stream GCD with DMA
      • Part 7: Access to DDR from PL
    • ZYNQ FPGA Tutorial
      • Part 1: Gate-Level Combinational Circuit
      • Part 2: RT-Level Combinational Circuit
      • Part 3: Regular Sequential Circuit
      • Part 4: FSM Sequential Circuit
      • Part 5: ZYNQ Architecture
      • Part 6: ARM CPU and FPGA Module
      • Part 7: FPGA Memory
      • Part 8: Hardware Accelerator for Neural Networks
    • ZYNQ FPGA Linux Kernel Module
      • Cross Compiling Kernel, Kernel Module, and User Program for PYNQ
      • Configure PL to PS Interrupt in Kernel Module
      • Configure AXI DMA in Kernel Module
  • 📟Proyek Arduino
    • Kumpulan Proyek
      • Rangkaian LED
      • LED Berkedip Nyala Api
      • LED Chaser
      • LED Binary Counter
      • OLED 128x4 Bitcoin Ticker
      • Rangkaian Button
      • Button Multifungsi
      • Button Interrupt
      • Button Debouncing
    • Pelatihan Mikrokontroler Arduino ESP32
      • Bab 1 Pengenalan Mikrokontroler
      • Bab 2 Pengenalan Arduino
      • Bab 3 Pengenalan Bahasa C
      • Bab 4 Digital Output
      • Bab 5 Digital Input
      • Bab 6 Serial Communication
      • Bab 7 Analog-to-Digital Conversion
      • Bab 8 Interrupt
      • Bab 9 Timer
      • Bab 10 Pulse-Width Modulation
      • Bab 11 SPI Communication
      • Bab 12 I2C Communication
  • 💰Finance
    • Coding for Finance
      • Build a Bitcoin Price Alert with Google Cloud and Telegram
      • Build a Bitcoin Ticker with ESP32 and Arduino
      • Stock Price Forecasting with LSTM
    • Trading dan Investasi
      • Istilah Ekonomi, Keuangan, Bisnis, Trading, dan Investasi
      • Jalan Menuju Financial Abundance
      • Memahami Korelasi Emas, Oil, Dollar, BTC, Bonds, dan Saham
      • Mindset Trading dan Investasi
      • Rangkuman Buku: Rahasia Analisis Fundamental Saham
      • Rangkuman Buku: The Psychology of Money
      • Rangkuman Kuliah: Introduction to Adaptive Markets
      • Rumus Menjadi Orang Kaya
  • 📝Life
    • Life Quotes
Powered by GitBook
On this page
  • Objective
  • Source Code
  • References
  • 1. Introduction to SoC FPGA
  • 1.1. FPGA vs. SoC FPGA
  • 1.2. SoC FPGA vs. SoC
  • 1.3. ZYNQ Development Flow
  • 1.4. Hardware Development
  • 1.5. Software Development
  • 1.6. PYNQ
  • 2. Design Example
  • 3. Conclusion
  1. FPGA Tutorials
  2. ZYNQ FPGA Tutorial

Part 5: ZYNQ Architecture

PreviousPart 4: FSM Sequential CircuitNextPart 6: ARM CPU and FPGA Module

Last updated 10 months ago

Objective

This tutorial contains information about the ZYNQ SoC and a simple example that consists of an AXI GPIO. In this tutorial, you will learn how to program ZYNQ PS with C.

Source Code

This repository contains all of the code required in order to follow this tutorial.

References

1. Introduction to SoC FPGA

1.1. FPGA vs. SoC FPGA

One of the main differences between FPGAs and FPGA SoCs is the presence or absence of a hard processor. A hard processor is a processor that has been fabricated as silicon on an FPGA chip. This is different from a soft processor, which is an RTL design programmed into the FPGA.

Examples of soft processors are Microblaze (Xilinx/AMD) and Nios (Altera/Intel). One of the limitations of soft processors is their limited clock frequency (several hundred MHz). Meanwhile, the hard processor used on the Zynq is an ARM Cortex-A with a clock that can reach 1.5 GHz.

1.2. SoC FPGA vs. SoC

One of the main differences between FPGA SoCs and SoCs in general is whether there is an FPGA. Examples of SoCs are generally used in single-board computers, such as raspberries, and gadgets, such as smartphones and tablets.

This type of SoC usually does not have programmable logic (FPGA), only a processor, which usually uses ARM. Development on this SoC is only at the software level (firmware, OS, or application level).

1.3. ZYNQ Development Flow

Development on Zynq consists of two stages, namely hardware/FPGA/programmable logic (PL) development and software/firmware/processing system (PS).

The hardware development means that we create RTL modules with Verilog or VHDL, which later will be programmed into the FPGA.

The software development means we create programs in C, Python, or other languages that later will be programmed into the PS (or, in other words, run on an ARM Cortex CPU).

1.4. Hardware Development

The type of development hardware on ZYNQ consists of three types:

  • Low-level development (Verilog, SystemVerilog, VHDL) with the main tool Vivado. Development is carried out using RTL design.

  • Apart from that, there is high-level synthesis (HLS) with the C language. In HLS, the C code will still be generated into Verilog or VHDL by the HLS compiler. After becoming Verilog or VHDL code, you will still need Vivado to synthesize the design. HLS uses Vitis HLS/Vivado HLS. Apart from C, high-level development, we can also use MATLAB with a tool called Vitis Model Composer/Xilinx System Generator DSP.

  • Vitis AI is not actually development hardware but uses a core called DPU that has been made by Xilinx. The cores are programmed into the FPGA. With Vitis AI, we can convert, optimize, and quantize AI models created using libraries such as TensorFlow into instruction sets that run on DPU.

1.5. Software Development

The type of software or embedded software on Zynq consists of three types:

  1. Baremetal uses the C/C++ language using the Vitis SDK/Xilinx SDK tools.

  2. RTOS uses real-time OS freeRTOS carried out on the Vitis SDK/Xilinx SDK tools.

  3. Linux uses OS (PYNQ, PetaLinux, Custom Linux).

1.6. PYNQ

PYNQ (Python productivity for Zynq) is a framework and hardware ecosystem based on the Xilinx Zynq SoC FPGA that abstracts away some complexity and allows you to write simpler code that utilizes memory map access, hardware interrupts, and DMA under the Linux OS.

The analogy is like an Arduino. Arduino consists of a framework, libraries, and hardware ecosystem. Arduino currently has quite a lot of boards that can support the Arduino framework. The first version of the Arduino board only had one version (ATmega). Currently, many microcontrollers are supported, such as STM, ESP, etc.

Just like the Arduino, PYNQ also does almost the same thing. PYNQ consists of Linux, its framework, libraries, and hardware ecosystem. PYNQ currently has several supported boards. Such as PYNQ-Z1, PYNQ-Z2, ZCU 104, Kria, RFSoC 4x2, and even Alveo.

PYNQ is a Linux framework and library that will be installed on a microSD and run on a Zynq SoC FPGA, making the SoC FPGA like an embedded Linux board. The analogy is also like a Raspberry Pi, which is equipped with an FPGA. We can connect a monitor, keyboard, and mouse to the Zynq board (certain boards that support it) and use it like a Raspberry Pi or a computer in general.

In conclusion, PYNQ abstracts the complexity of Linux, which allows users to create Linux embedded application programs that are integrated with FPGAs more easily.

2. Design Example

In this design example, we are going to create a system that consists of ZYNQ PS and GPIO on the PL. This system design consists of a GPIO that is implemented on the FPGA. The GPIO is connected to the AXI interconnect via the General-Purpose AXI Ports.

We configure the ZYNQ PS by enabling UART 1. We are going to use this for communication between ZYNQ and the host PC.

Then, we configure the AXI GPIO. Set the width to 4-bit because we only have 4 LEDs on the ZyBo. Set the default value to 0x00000005 so that when the FPGA is programmed, the LED is turned on.

After the AXI GPIO is connected to the PS, it gets the address as shown in the following figure. This address will be used in the C program.

The following code shows the C code to access the AXI GPIO. We use a C pointer that points to the address of the AXI GPIO IP. In the main program, we blink the LEDs and also send "Hello, World!" to the serial terminal.

helloworld.c
#include <stdio.h>
#include "sleep.h"

#define MEM_GPIO_BASE 	0x41200000

uint32_t *mem_gpio_p;

int main()
{
    mem_gpio_p = (uint32_t *)MEM_GPIO_BASE;

    while (1)
    {
        *(mem_gpio_p+0) = 0x0;
	sleep(1);
	*(mem_gpio_p+0) = 0xF;
	sleep(1);
	printf("Hello, World!\n");
    }

    return 0;
}

The following figure shows the result of the serial terminal.

3. Conclusion

In this tutorial, we covered the ZYNQ SoC and a simple example that consists of an AXI GPIO.

AMD Zynq™ 7000 SoCs,

Official PYNQ website,

📻
https://www.amd.com/en/products/adaptive-socs-and-fpgas/soc/zynq-7000.html
http://www.pynq.io/
zybo_tutorial/part_5 at main · weenslab/zybo_tutorialGitHub
Figure 2. ZYNQ architecture block diagram
Figure 4. PYNQ architecture
Figure 5. Block design of the GPIO example
Figure 6. Enabling UART 1 in ZYNQ PS
Figure 7. Configuring the AXI GPIO
Figure 8. The address of the AXI GPIO
Figure 9. UART output printed on the serial terminal
Figure 1. Samsung Exynos SoC. Source:
Figure 3. Vitis AI structure. Source:
https://en.wikipedia.org/wiki/Exynos
https://www.xilinx.com/products/design-tools/vitis/vitis-ai.html#:~:text=The%20Vitis%20AI%20Library%20is,model%20deployment%20on%20AMD%20platforms.
Logo