1. INTRODUCTION

 

1.1 Motivation

Basic EDK Tutorial is a document made for beginners who are entering the embedded system design using FPGAs. This tutorial explains, step by step, the procedure of designing a simple digital system using C language and Xilinx Vivado Design Suite.

 

1.2 Purpose of this tutorial

This tutorial is made to introduce you how to create and test an project and run it on your development board.

After completing this tutorial, you will be able to:

The following project is designed for:

1.3 Objectives of this tutorial

In this tutorial a PWM signal modulated using the sine wave with two different frequencies (1 Hz and 3.5 Hz) will be created. Frequency that will be chosen depends on the position of the two-state on-board switch (sw0).

 

PWM Signal

Pulse-width modulation (PWM) uses a rectangular pulse wave whose pulse width is modulated by some other signal (in our case we will use a sine wave) resulting in the variation of the average value of the waveform. Typically, PWM signals are used to either convey information over a communications channel or control the amount of power sent to a load. To learn more about PWM signals, please visit  http://en.wikipedia.org/wiki/Pulse-width_modulation.

 

Illustration 1.1. illustrates the principle of pulse-width modulation. In this picture an arbitrary signal is used to modulate the PWM signal, but in our case sine wave signal will be used.

 

graphics3

Illustration 1.1: Example of the PWM signal

 

1.4 One possible solution for the modulator design

Considering that we are working with digital systems and signals, our task will be to generate an digital representation of an analog (sine) signal with two frequencies: 1  Hz and 3.5 Hz.

Illustration 1.2 is showing the sine wave that will be used to modulate the PWM signal.

 

graphics4

Illustration 1.2: Sine wave with 256 samples

 

One period of the sine wave is represented with 256 (28) samples, where each sample can take one of 4096 (212) possible values. Since the sine wave is a periodic signal, we only need to store samples of one period of the signal.

Note: Pay attention that all of sine signals with the same amplitude, regardless their frequency, look the same during the one period of a signal. The only thing that is different between these sine signals is duration of a signal period. This means that the sample rate of these signals is different.

 

Considering that the whole system will be clocked with the 100 MHz system clock, to get 1 Hz and 3.5 Hz frequencies (which is much smaller than 100 MHz) we should divide system clock frequency with integer value N.

In the Tables 1.1 and 1.2 are shown parameters that are necessary for generating sine signals with 1 Hz and 3.5 Hz frequencies.

 

 

Table 1.1: Sine signal with the frequency of 1 Hz

T=1 s

T=1/1 Hz=1 s

 

T is the period of the signal

f1=256 Hz

f1=256*1 Hz=256 Hz (or read in time: 1 s/256)

 

f1 is the frequency of reading whole period (T) with 256 samples

N1=390625

N1=100 MHz/256 Hz=390625

 

N1 is the number which divides frequency of the input clock signal (100 MHz) to the required frequency for the digital sine module

N2=95

N2=390625/4096=95.3674

N2 is the number which divides frequency of the input clock signal (100 MHz) to the required frequency for the PWM's FSM module

N1=389120

N1=95*4096=389120

This is new calculation, because N1 must be divisible with 4096

 

 

 

 

 

Table 1.2: Sine signal with the frequency of 3.5 Hz

T=0.286 s

T=1/3.5 Hz=0.286 s

 

T is the period of the signal

f2=896 Hz

f2=256*3.5 Hz=896 Hz (or read in time: 0.286 s/256)

 

f2 is the frequency of reading whole period (T)

N1=111607.1429

N1=100 MHz/896 Hz=111607.1428571

 

N1 is the number which divides frequency of the input clock signal (100 MHz) to the required frequency for the digital sine module

N2=27

N2=111607.1428571/4096=27.2478

N2 is the number which divides frequency of the input clock signal (100 MHz) to the required frequency for the PWM's FSM module

N1=110592

N1=27*4096=110592

This is new calculation, because N1 must be divisible with 4096

 

Now, it is obvious that the sine wave can be generated by reading sample values of one period, that are stored in one table, with appropriate speed. In our case the values will be generated using the sine function from the C numerics library (math.h) and will be stored in an array.

 

1.4.1 Block diagram

Block diagram on the Illustration 1.3 shows the structure of one possible system that can be used to generate required PWM signals.

 

graphics5

Illustration 1.3: Block diagram

 

The embedded system is composed of:

 

 

Let us briefly explain each part of this system:

 

MicroBlaze Processor – is a 32-bit soft processor, which is included in the Vivado 2014.2 release. The MicroBlaze is highly configurable soft core processor, allowing you to select a specific set of features required by your design.

 

The fixed feature set of the processor includes:

 

In addition to these fixed features, the MicroBlaze processor is parametrized to allow selective enabling of additional functionality:

 

graphics6

Illustration 1.4: MicroBlaze Core Block Diagram

 

The MicroBlaze core is organized as a Harvard architecture with separate bus interface units for data and instruction accesses. The following two memory interfaces are supported: Local Memory Bus (LMB) and the AMBA AXI4 interface (AXI4) and ACE interface (ACE). The LMB provides single-cycle access to on-chip dual-port block RAM. The AXI4 interfaces provide a connection to both on-chip and off-chip peripherals and memory. The ACE interfaces provide cache coherent connections to memory. MicroBlaze also supports up to 16 AXI4-Stream interface ports, each with one master and one slave interface.

 

MicroBlaze can be configured with the following bus interfaces:

 

Note: If you want to read and learn more about the MicroBlaze Processor core, please refer to “MicroBlaze Processor reference Guide (v2014.1)”.

 

 

LogiCORE IP AXI Timer/Counter – The LogiCORE IP AXI Timer/Counter is a 32/64-bit timer module that interfaces to the AXI4-Lite interface. The AXI Timer is organized as two identical timer modules. Each timer module has an associated load register that is used to hold either the initial value for the counter for event generation or a capture value, depending on the mode of the timer.

The AXI Timer includes the following features:

graphics7

Illustration 1.5: AXI Timer Core Block Diagram

 

Note: If you want to read and learn more about the AXI Timer/Counter core, please refer to “LogiCORE IP AXI Timer v2.0 Product Guide”.

 

 

LogiCORE IP AXI Interrupt Controller (INTC) – The LogiCORE IP AXI Interrupt Controller (INTC) core receives  multiple interrupt inputs from peripheral devices and merges them to a single interrupt output to the system processor. The registers used for storing interrupt vector addresses, checking, enabling and acknowledging interrupts are accessed through the AXI4-Lite interface.

 

The AXI Interrupt Controller includes the following features:

graphics8

Illustration 1.6: AXI INTC Core Block Diagram

 

The LogiCORE IP INTC core concentrates multiple interrupt inputs from peripheral devices to a single interrupt output to the system processor. The registers used for checking, enabling, and acknowledging interrupts are accessed through the AXI4-Lite interface.

 

Note: If you want to read and learn more about the AXI Interrupt Controller core, please refer to “LogiCORE IP AXI Interrupt Controller (INTC) v4.1 Product Guide”.

 

 

LogiCORE IP AXI General Purpose Input/Output (GPIO) – The LogiCORE IP AXI General Purpose Input/Output (GPIO) core provides a general purpose input/output interface to the AXI interface. This 32-bit soft IP core is designed to interface with the AXI4-Lite interface.

The AXI GPIO includes the following features:

 

The AXI GPIO design provides a general purpose input/output interface to an AXI4-Lite interface. The AXI GPIO can be configured as either a single or a dual-channel device. The width of each channel is independently configurable.

The ports are configured dynamically for input or output by enabling or disabling the 3-state buffer. The channels can be configured to generate an interrupt when a transition on any of their inputs occurs.

 

graphics9

Illustration 1.7: AXI GPIO Block Diagram

 

Note: If you want to read and learn more about the AXI GPIO core, please refer to “LogiCORE IP AXI GPIO v2.0 Product Guide”.

 

1.4.2 Design Steps

This tutorial will be realized step by step with the idea to explain the whole procedure of designing an digital system, using Vivado tool.

graphics10

 

 

Illustration 1.8: Design steps

 

1.5 Embedded Design Process Flow

Vivado Design Suite is designed to help us in all phases of the embedded design process. On the Illustration 1.9 is shown the Vivado architecture structure of how the tools operate together to create an embedded system.

 

graphics11

Illustration 1.9: Typical Embedded Design Process Flow