1 Forming and Co-simulation of Square and Triangular Waveforms by Using System

—Nowadays Field Programmable Gate Arrays(FPGAs) are used to implement several processes in different areas such military defense, medical devices, automation, telecommunication, and image processing etc. Some of the advantages of FPGA are parallel and hardware processing. On the other hand programming FPGAs by classic design methodologies requires much effort. Therefore, design tools like System Generator can provide facilities about programming FPGAs. System Generator is a design tool from Xilinx to program the Xilinx FPGAs in MATLAB/Simulink graphic based editor. Also its block set is limited with respect to Simulink, has. In this study square, and triangular waveforms are built with the basic blocks of System Generator tool. These waveforms belong to basic sources for signal processing. Generally, they are used in power electronics especially for producing PWM, or sinus PWM. Also co-simulation can be done by using System Generator. Square waveform block, which is implemented, has variable amplitude, frequency, duty cycle, and offset values whereas triangular waveform has variable amplitude, frequency, and offset values. Triangular waveform has an error as 2 % due to data bus width.


I. INTRODUCTION
PGA belongs to Programmable Logic Devices(PLDs) and is a very large scaled integrated circuit(VLSI) [1] Also FPGA is formed as a matrix of configurable logic block which can be connected to each other via fully programmable interconnections [2]. It's clocking rate can be multiples of 100 Mega Hertzs, which can be seen low with respect to computer has. Since it makes parallel processing, has capability of making operations as hardware, and consumes low power, it is preferred in todays's electronic devices such as led tv, mobile phones, modems, imaging devices etc. So processing rate of FPGA increase enormously.
System generator is a tool for MATLAB/Simulink graphicbased editor, which is provided by XILINX firm in order to program its FPGAs [4]. Therefore, previous knowledge about design methodologies, or hardware descriptive language shouldn't be necessary by using System Generator. Also System Generator tool has co-simulation choice. Cosimulation provides both processing validation of the algorithm in a hardware, and increase in simulation speed. However, the number of Xilinx blocks are limited with regarding to Simulink blocks. In co-simulation process all of the Xilinx specific blocks are implemented and run in the target FPGA.
A periodic waveform is a waveform which repeats itself in time. Periodic waveforms are important in electronic circuits, and can be used for different purposes such as clocking, switching, triggering, producing different wave shapes as PWM signal vice versa [5]. Besides basic periodic waveforms are sine, square, rectangular, triangular, saw tooth, and pulse waveforms.
In this study it is aimed to implement two new blocks as square and triangular waveform for System Generator by using existed Xilinx specific blocks in Simulink. Several parameters as amplitude, frequency, and offset of these blocks can be tuned. After all, co-simulation is done for validation.

II. MATERIALS AND METHODS
Square and triangular periodic waveforms are two of the basic waveforms used in electronic circuits. They can also be used in power electronics for different purposes.

A. Square waveform
Square wave is a type of periodic waveform which alternates between two levels [6]. It is shape is given in dis offset in amplitude; Also square waveform can be used as a pulse train if its amplitude changes between A and 0. Besides duty cycle can be changed and PWM signal is obtained.

B. Triangular waveform
Triangular wave is a non-sinusoidal two directional waveform [5]. It is linearly increases, and decreases between these two points. and it is alternated between two points by a ramp shape. Triangular waveform is shown in Fig.2 t One period(T) Also an offset value, or time delay can be added to the signal. In practise triangular waveform can be obtained by electronic circuits. Examples of such circuits are operational transresistance amplifier (OTRA) and current feedback operational amplifier [7,8]. Besides triangular waveform can be implemented by using up-down counter in software tools. Also look up tables can be used for any desired signal shape [9].

C. System Generator
System Generator is tool provided by Xilinx firm for MATLAB/Simulink, for programming its FPGAs visually. Xilinx blockset is added to Simulink by System Generator, and a Simulink model can be implemented with consisting of Xilinx specific blocks, and then FPGA program is built automatically. Therefore, there is no need to know programming language, and design methodologies [4].
If it is desired to make simulation with Xilinx blocks, initially System Generator icon should be added to the model. A window, which is shown in Figure 3, to make the various settings is open after double clicking this icon. In this window FPGA type, clock rate, operation type is chosen.

Fig. 3 System Generator window
Co-simulation option can be chosen, in order to make cosimulation with the specific FPGA. Vivado software runs in background to produce the bitstream file after pressing the Generate button. After all co-simulation can be done by loading bitstream file to FPGA.

D. BASYS3 FPGA training card
BASYS3 has Xilinx Artix-7 architecture and is a cheap and entry-level FPGA development card for Vivado. It has 33280 logic cell and its clocking rate is 150 MHz. BASYS3 FPGA training card is shown in Figure 4 In this study, periodic square and triangular waveform blocks are implemented by using Xilinx specific blocks in MATLAB/Simulink. Therefore, these blocks simulated and co-simulated.
Periodic square waveform, implemented with Xilinx blocks are shown in Figure 5  Here amplitude, frequency, offset of the square waveform can be adapted. Also, if it is desired to use this block as a PWM signal generator there is an option for duty cycle.
In the application firstly, this block is simulated with the parameters for peak amplitude, frequency, and offset as 50, 50, and 0 respectively. Then co-simulation block of square waveform is generated by System Generator and added to the model as shown in Figure 7; Fig. 7 The square waveform model with co-simulation block As mentioned above, triangular waveform is built with the Xilinx specific blocks as shown in Figure 8; In this model an up-counter is used for control logic, and one up-counter and one down-counter is used for forming triangular wave. Later amplitude, and offset of this wave is adapted. Thus, this model is masked, and then triangular waveform block is built. Block parameter window of this block is shown in Figure 9; In this window frequency, amplitude, offset, and step size of the counters can be adapted.
Therefore, frequency, amplitude, offset, frequency, and step size of the counters are selected as 50, 50, 0, and 1000 respectively. The model with co-simulation block, generated is shown in Figure 10; Fig. 10. The triangular waveform model with co-simulation block Two models are run and simulation, and co-simulation results for square, and triangular waves are obtained as in Figure 11, and 12 respectively. It can be seen from the figures 11, and 12 that simulation, and co-simulation results are same for both square, and triangular waveforms. This means that validation for the associated hardware is performed. Also in detailed analysis of the waveforms, there is an error as % 1.2 in the amplitude of triangular waveform. This error is occurred to the signed number bit bus width of block. Also, the error can be decrease by increasing the bit bus width, or using floating point math.

IV. CONCLUSION
In this study it is aimed to add two new blocks as square and triangular waveforms to Xilinx blockset, provided by System Generator, in MATLAB/Simulink graph-based editor.
Also, these waveforms are among fundamental signals in electronics. Square waveform has harmonics of basic frequency, so it can be uses in harmonic analysis. In addition, this block has an extra choice as duty cycle. So this wave can be used as square wave PWM. Triangular wave can be used in sinus PWM. Resulted signal of the block is satisfactorily from the viewpoint of sampling number, and the shape of the signal. Besides, BASYS3 FPGA card has a 100 MHz clock rate. So it can support PWM signals with high speed, and resolution.
Co-simulation results shown that the card can be used as a signal generator in practical circuits. This card can be used with Pmode (Peripheral mode) accessories for real time applications. Since FPGA can make parallel operations, this card can be used as multiple signal generator due to the range of Pmode accessory outputs.
Finally, this two block is sent to Xilinx Firm with the hope of contribution to Xilinx blockset provided by System Generator to MATLAB/Simulink.