scieee AI-readable full text Open interactive document viewer

Development of an acoustic modem using synthesizable microcontroller

Hassan Mobshar, Muhammad Fahad

Abstract

In this thesis, an acoustic modem is developed on a digital programmable device for underwater communications. The system consists of a synthesize microcontroller as well the different elements necessaries for the modulation and demodulation of the signals. That should be developed for the design. The objective is to develop the system using a high-level hardware description language and to show the system’s functioning on a flexible platform (a programable logical device) with the perspective that, in the future, it can be implemented in a personalized integrated circuit and thus obtain a compact and energy efficient system.

Full text

DEVELOPMENT OF AN ACOUSTIC MODEM USING SYNTHESIZABLE MICROCONTROLLER by Muhammad Fahad Hassan-Mobshar BACHELOR’S THESIS Bachelor’s Degree in Industrial Electronics and Automatic Control Engineering Barcelona, 4 June 2019 Director: Jordi Cosp Vilella Electronic Engineering Department DEVELOPMENT OF AN ACOUSTIC MODEM USING SYNTHESIZABLE MICROCONTROLLER BACHELOR’S THESIS Bachelor’s degree in Industrial Electronics and Automatic Control Engineering Volume I Report & Annexes Author: M. Fahad Hassan-Mobshar Director: Jordi Cosp Vilella Call: June 2019 Chapter 0: I “He who loves practice without theory is like the sailor who boards ship without a rudder and compass and never knows where he may cast.” Leonardo Da Vinci Development of an acoustic modem II ABSTRACT In this thesis, an acoustic modem is developed on a digital programmable device for underwater communications. The system consists of a synthesize microcontroller as well the different elements necessaries for the modulation and demodulation of the signals. That should be developed for the design. The objective is to develop the system using a high-level hardware description language and to show the system’s functioning on a flexible platform (a programable logical device) with the perspective that, in the future, it can be implemented in a personalized integrated circuit and thus obtain a compact and energy efficient system. Chapter 0: Resum III RESUM En aquest treball es desenvolupa un mòdem acústic per a comunicacions submarines sobre un dispositiu digital programable. El sistema està compost per un microcontrolador sintetitzable més els diferents elements necessàries per a la modulació i desmodulació dels senyals que cal desenvolupar per al disseny. L’objectiu és desenvolupar el sistema utilitzant un llenguatge d’alt nivell de descripció hardware i demostrar el funcionament del sistema sobre una plataforma flexible (un dispositiu lògic programable) amb la perspectiva que, en un futur, pugui ser implementat en un circuit integrat a mida i així obtenir un sistema compacte i de baix consum. Development of an acoustic modem IV RESUMEN En este trabajo se desarrolla un módem acústico para comunicaciones submarinas sobre un dispositivo digitar programable. El sistema consiste en un microcontrolador sintetizable y los diferentes elementos necesarios para la modulación y demodulación de las señales a desarrollar para el diseño. El objetivo es desarrollar el sistema utilizando un lenguaje de descripción de hardware i demostrar el funcionamiento del sistema sobre una plataforma flexible (un dispositivo lógico programable) con el fin de que, en el futuro, pueda implementarse en un circuito integrado personalizado y así obtener un sistema compacto y de bajo consumo. Chapter 0: Index XI 7. RESULTS.......................................................................... 73 7.1. Maximum frequency detection .................................... 74 7.2. Error Setpoint ............................................................ 76 7.3. Power Setpoint .......................................................... 77 7.4. Performance .............................................................. 79 7.5. Resources.................................................................. 81 8. FUTURE WORK ................................................................ 83 9. CONCLUSION .................................................................. 85 10. REFERENCES ................................................................ 89 A. ANNEXE: TABLES .......................................................... - 1 - I. ADC Tables ................................................................ - 1 - II. Cortex M3 Tables ..................................................... - 12 - III. IP Tables ................................................................. - 15 - B. ANNEXE: BUDGET ....................................................... - 27 - I. Devices cost ............................................................ - 27 - II. Licences cost ........................................................... - 28 - III. Engineering work cost .............................................. - 29 - IV. Total ....................................................................... - 30 - C. ANNEXE: USER MANUAL ............................................. - 31 - I. Configuration ........................................................... - 31 - II. Generating modem .................................................. - 31 - D. ANNEXE: CODE............................................................ - 37 - I. Hardware code ........................................................ - 37 - FF_D_T ........................................................................ - 37 - Development of an acoustic modem XII Square Generator ......................................................... - 39 - II. Software code.......................................................... - 42 - Main............................................................................. - 43 - Gpio C file .................................................................... - 44 - E. ANNEXE: SCHEMATIC ................................................. - 51 - Chapter 1: Preface M. FAHAD HASSAN 1 1. PREFACE 1.1. Background In the last few decades, the progress of technology has increased in oceanographic researches. The use of Autonomous Underwater Vehicles (AUV) and sensors networks are very common in this field to study oceans activities or use for marine security. Apart from these activities, exist a strong scientific interest to develop systems to observe, monitor and track the aquatic species. In the electronic engineering department of this campus, they are studying a positioned and monitoring system for aquatics species. Two different environments have been considered to locate the species; localization of the species in open areas using autonomous underwater vehicles, and localization of the species in specific areas using underwater observatories. The aim of the thesis is to locate the species, control and examine with autonomous vehicles. Two basic methods can be used to monitor the spices: the active and the passive. In the passive method, a hydrophone is used to hear the sound produced Figure 1-1: GUANAY II AUV developed by The Technological Development Centre for Remote Acquisition System and Information Treatment (SARTI). Extract from [13] Development of an acoustic modem 2 M. FAHAD HASSAN by some species. Different species can be identified by applying filters algorithms and pattern recognition. The bioacoustics is the discipline which studies this area. In the UPC exist an investigation group specialized in this discipline; Laboratori d’Aplicacións Bioacústiques (LAB). In the active method, the animal es identified by placing on them an acoustic transductor. Because of the versatility, size and the features, aquatic TAG is the common systems used to monetarize the species. This method offers certain advantages in front of passive systems, such as, identification of individual species or localization of species which not emits any characteristic sound. The active method is interesting since the same system can be used to locate and to monitor de species as well to position autonomous submarines, ships or different sensors. 1.1.1. Positioning algorithms The positioning algorithms are used to calculate distances between two nodes 1 . There is two way to calculate the distance: - Time of flight (TOF): TOF is the time lag between a device sends the signal and receives the answer from another device. And in case the propagation 1 A node is either a redistribution point or a communication endpoint. Figure 1-2: Underwater active method of communication. Submarines, ships and satellites communicating with node. Extract from [21] Chapter 1: Preface M. FAHAD HASSAN 3 speed of the signal is known, the distance between two nodes can be calculated easily. - Time Difference of Flight (TDOF): In this case, the distance is calculated using the differences of time between two received signals. The signal is generated in one point and is received in different nodes. This method is really useful when the initial broadcasting time is not known, thus the localization is determined by receiving two signals. However, all nodes have to be perfectly synchronized to know the time with precision. 1.2. Aim of the thesis As it has mentioned, the aim of the university investigation work is to develop a system to locate and fallow underwater species using the acoustic positioned system. The active method is used to locate the species in which an acoustic TAG is incorporated in the aquatic species thus the nodes or autonomous underwater vehicles could detect them. The aim of this thesis is to develop a modem which will be incorporated on the aquatic species. And it is going to study a device which could be compact and as small as possible. A compact device would not be annoying for the species and could allow monitoring small aquatic animals. A microcontroller and ADC are used to create the modem which is going to implement in Field-Programmable Gate Array (FPGA) thus the modem is going to develop with Hardware Description Language (HDL). Developing the modem in FPGA will allow to emulate it, besides to know the dimension and the maximum clock speed of the device, among other features. The main part of the thesis is to develop an application using a microcontroller in FPGA. Some characteristics are going to study to develop microcontroller in FGPA; such as how it works, how it could program, how it could connect with other parts, and how much space is required to develop it. Furthermore, the advantages and disadvantages of using a microcontroller for this application will be discussed. Because this work is the first stage in which Development of an acoustic modem 4 M. FAHAD HASSAN the functionality of the modem is observed. If the modem works properly, this could be implemented in an integrated device. 1.3. Objectives This thesis is a part of a University Project hence the objective are chosen which are important for this part. These are principals’ objectives on which the thesis is focused on. 1- The main objective of the thesis is to develop the microcontroller in FPGA and programme with a little application to know either is function correctly or not. 2- Study how to connect an Analogue-to-Digital Converter, and examine the communication between ADC and microcontroller. In case this could not work properly, the modem would not get the signal correctly. 3- Observe that the modem works properly; it obtains data from ADC, the microcontroller works correctly, and send the echo for the proper input signal and not by error. 4- The output signal is going to use to calculate the distance between the transmitter and receptor. Hence observe that the processing time is known so, to not create an error by the node or AUV to establish the exact position of the animal. 5- The animals could change their position; therefore, it is important to establish the minimum processing time so the AUV could calculate the distance accurately. 6- Observe the sources that have been used to develop the modem, and estimate the space. This is important especially for the future case when the modem is implemented in an integrated circuit. Chapter 1: Preface M. FAHAD HASSAN 5 1.4. Work planning To achieve the objectives, previous commented, it is going to follow following planning. In the following sections, the main parts of the thesis are going to discuss and a resume of their uses. 1.4.1. Conversion of the analogue signal to digital The ADC is used to convert the input analogic signal into a digital signal. This device is created in HDL language. Vivado is used to create all the Modem, and in this program exist an IP named XADC which is used to convert analogue data to digital. Three weeks are planned to dedicate to this section and make the ADC working in the FPGA. In this time the XADC core is going to study; ports descriptions, XADC configuration, among other concepts. 1.4.2. Adapting the microcontroller and implementing in FPGA The thesis consists of designing an acoustic modem using a microcontroller. The modem receives an electric signal which is converted in 16 bits digital signal. This microcontroller has to be created with HDL though to implement in an FPGA and observe the functionality. The ARM developers have public available microcontroller Cortex-M3. This device has peripherals to connect with Vivado elements and could be synthesised in Vivado and later implement in FPGA thus to observe the functionality. The microcontroller detects the signal signature using the Goertzel Algorithm and obtain the power of the signal. If the power is greater than the set point, the input signal corresponds to the detection signal. When this occurs, the microcontroller sends the eco of this signal. The microcontroller is programmed using C language with Keil 𝜇Vision program. This way marine animal which has the modem, will be detected. After that, the distance between the modem and the node will be calculated. Development of an acoustic modem 6 M. FAHAD HASSAN Five weeks are planned to dedicate to this section and make the microcontroller working in the FPGA. 1.4.3. Connecting ADC with microcontroller to detect the signal In this period the modem is going to test; obtaining the analogue signal, processing with a microcontroller with Goertzel algorithm, and send the echo in the case is the input signal correspond to the desired signal. Six weeks are planned to dedicate to this part. 1.4.4. Drafting the report Some parts of the report are going to write during previous stages, thus not to have a lot of work in the final weeks. Moreover, the last three weeks are going to spend to draft the report. The Figure 1-3 shows the Gantt chart of the planning, which also includes previous works. Chapter 1: Preface M. FAHAD HASSAN 7 Figure 1-3: Thesis planning that lasted 17 weeks. Development of an acoustic modem 8 M. FAHAD HASSAN This page intentionally left blank Chapter 2: background M. FAHAD HASSAN 15 2.3. Verilog 2.3.1. Hardware description languages Hardware Description Language (HDL) is used in design electronics to describe models which describe logic circuits, for example, truth tables or integrated circuits. HDL has a lot of advantages. One of these is that design functionality could be verified before translating in a real hardware circuit. They are different HDL to describe a logic model, the two most common are VHDL and Verilog because these are more widely used and well supported HDLs. VHDL stands by Very High-Speed Integrated Circuit Hardware Description Language developed in 1980. VHDL is more verbose than Verilog and have less common with programming language C. On the other hand, the Verilog is more compact but has a lower level of programming construct. In this chapter, only Verilog HDL is described because of the used in the thesis. To know about VHDL visit [3]. 2.3.2. Introduction to Verilog Verilog is a computer-based language to describe the hardware of the digital systems in a textual form. Functionality is described to implemented in hardware which can be defined in Boolean logic equations, truth tables and netlist of block interconnections. The Verilog language has similarities with the C programming language. Verilog is case-sensitive and has a basic preprocessor to control flow keywords, such as 𝑖𝑓/𝑒𝑙𝑠𝑒, 𝑓𝑜𝑟 or 𝑤ℎ𝑖𝑙𝑒. These keywords have to be lowercase. The module begins with the keyword 𝑚𝑜𝑑𝑢𝑙𝑒 and ends with 𝑒𝑛𝑑𝑚𝑜𝑑𝑢𝑙𝑒. The variables needed to declare with bit-widths. The Verilog differs from C for control-flow statements which are initiated with keyword 𝑏𝑒𝑔𝑖𝑛 and close with 𝑒𝑛𝑑 statement, however, other characteristics are same such as: ending line with a semicolon, comments begin with double-slash (//) or multi-comment with “/* … */”. Development of an acoustic modem 16 M. FAHAD HASSAN 2.3.3. Generating a digital block with Verilog In this section, a simple digital block is created using Verilog to understand the functionality of the language. An adder is created as a demonstration example of a digital block. The block obtains two input signals which are going to save and will be allowed any time at the output port. It will make an add operation and save data in D Flip-Flop thus to access any time. The Verilog design begins with the name 𝑚𝑜𝑑𝑢𝑙𝑒, after which the module name is given. Next, they are I/O ports declarations which could be input, output or bidirectional, beginning with 𝑖𝑛𝑝𝑢𝑡, 𝑜𝑢𝑡𝑝𝑢𝑡 or 𝑖𝑛𝑜𝑢𝑡 keywords, respectively. In Verilog when any variable or port are declared, it is also needed the width size of the port or variable. For the example, the input ports have width two and the output port has width three –the third MSB is the carryout bit–, and there is not any port which is declared as bidirectional. After the port’s declaration, internal variables or 𝑛𝑒𝑡𝑠 are declared. 𝑁𝑒𝑡 data type represents physical interconnect between structures. And the variable data type represents elements to store data temporarily. For this example, variables are used to save data in D Flip-Flop. module add_2bits (CLK, RST, A, B, ADD); input CLK, RST; input [1:0] A, B; output [2:0] ADD; ... endmoudle Code 2-5: Ports declaration of the example module Chapter 2: background M. FAHAD HASSAN 17 After the variable’s declaration, the hardware is described using different type of structures. The complete Hardware description is shown in Code 2-7. An 𝑎𝑙𝑤𝑎𝑦𝑠 assignment is used to create a synchronous system and inside the statement, the process is executed sequentially. The process is executed when the clock signal has a rising edge (𝑝𝑜𝑠𝑒𝑑𝑔𝑒). 𝐼𝑓 − 𝑒𝑙𝑠𝑒 statements are used to initiate variables with reset. Because the reset is Active-Low the not operation is made using “!” symbol. “{ }” symbol is used to concatenate two variables. In the example this is used to create input signals of width three thus not to have width problems. After adding, the result is assigned to the output port. module add_2bits (CLK, RST, A, B, ADD); input CLK, RST; input [1:0] A, B; output [2:0] ADD; reg [2:0] Add_aux; endmoudle Code 2-6: Variables declaration for the example design Development of an acoustic modem 18 M. FAHAD HASSAN module add_2bits (CLK, RST, A, B, ADD); input CLK, RST; input [1:0] A, B; output[2:0] ADD; reg [2:0] Add_aux; always @(posedge CLK) begin if (!RST) begin Add_aux <= 0; end else begin Add_aux <= {A,1'b0} + {B,1'b0}; end end assign ADD = Add_aux; endmoudle Code 2-7: Complete hardware description of the adder Chapter 3: Modem M. FAHAD HASSAN 19 3. MODEM The modem is developed using a microcontroller and an Analogue to Digital Converter. The FPGA has an analogic port thus to obtain the analogue signal. The sinusoidal signal of a specific frequency is generated using a wave generator to emulate the input signal coming from AUV or node. This signal is converted using the ADC to obtain digital signal. This data is read by the microcontroller which is connected to ADC by AXI Interconnect and GPIO. The microcontroller performs the Goertzel Algorithm to detect the tone of the signal. When the input signal frequency corresponds to the selected frequency for the Goertzel Algorithm, a significant value of power from the Algorithm is received. This power is compared with a setpoint value and in case this is higher than the setpoint, an Enable signal is set. This signal allowed to generate a square signal thus to emulate the Echo. The modem consists of three parts: - An ADC - A Microcontroller - Other parts for connection In the following chapters, these parts are described with detail. Development of an acoustic modem 20 M. FAHAD HASSAN This page intentionally left blank Chapter 4: Analogue to digital converter (ADC) M. FAHAD HASSAN 21 4. ANALOGUE TO DIGITAL CONVERTER (ADC) This chapter described an Analogue-to-Digital Converter which is used in the modem. As is mentioned, this part is used to convert external electric, analogue, signal to digital signal. The node device sends an acoustic wave to communicate with the animal, modem. A medium stage consists of an acoustic sensor which converts an acoustic wave into an electrical signal, known as the acoustic signal. The ADC receives this analogue signal to convert it to digital. The ADC block could be modelled in Vivado. The program Vivado has an IP catalogue in which a lot of components are pre-designed as a block, knowing as IP. This could be imported in a Diagram when a Block Design is created. All connections of IP could be made external so to control or interact with the ADC after creating the wrapper in Vivado in Verilog or VHDL language. Furthermore, it could import more than one IP and interconnect in these in the same block diagram. In the following section, the main features of XADC are described because the core could be modified from external, it is important to know the characteristics of the XADC. Figure 4-1 illustrates the block design of this device. Development of an acoustic modem 22 M. FAHAD HASSAN 4.1. ADC channels definition The ADC has different pins for connection, which are used to configure ADC or connect with external ports to get the analogue signal or send the digital. The definition of these is described in this section. 4.1.1. Dynamic Reconfiguration Port bus (s_drp) The DRP bus consists of: input address bus (daddr_in[6:0]), input enable signal (den_in), data input bus (di_in[15:0]), output data bus (do_out[15:0]), data ready signal (drdy_out) and write input enable (dwe_in). The address bus is an input bus and indicates the address to access up to 128 registers (daddr_in[6:0] = 00h to 7Fh). Data input bus is used to save data in these registers. Before saving this data, the write enable signal has to be logic- High. Data ready signal goes logic-High when the data are written successfully in the register. The input-enable signal has to be High to set an address or the write-enable signal. It should also be a logic-High to set data in the output bus. The bus has 16-bit width but only the 12 MSBs are the useful converted data. Figure 4-1: XADC Wizard IP Chapter 4: Analogue to digital converter (ADC) M. FAHAD HASSAN 23 4.1.2. Dedicated analogue input (Vp_Vn) This port is used to get analogue signals. It is formed by two channels: 𝑉𝑃 and 𝑉𝑁. 𝑉𝑃 (vp_in) is a positive input terminal of the dedicated differential analogue channel and 𝑉𝑁 (vn_in) is the negative input terminal of the dedicated differential analogue channel. These pins should be connected to GND when they are not using. 4.1.3. Auxiliary analogue inputs These are multi-function pins that could support an analogue or a digital input-output (I/O). These pins support sixteen pares of analogue inputs, auxiliary positive analogue input (𝑉 𝐴𝑈𝑋𝑃) and auxiliary negative analogue input (𝑉 𝐴𝑈𝑋𝑁). The analogue input channels support multiple analogue input signal types. These pins could be used as digital I/O when not being used as analogue inputs. Other core channels are described in Table A-1. 4.2. ADC registers All registers in the register interface are accessible through the dynamic reconfiguration port (DRP). The DRP allows accessing up to 128 registers with 16 bits width. The first 64 address locations (𝑑𝑎𝑑𝑑𝑟_𝑖𝑛[6:0] = 00ℎ 𝑡𝑜 3𝐹ℎ) contain the readonly status registers, and they are known as status registers. These registers contain the result of analogue to digital conversion of the channels. The next 64 registers (𝑑𝑎𝑑𝑑𝑟𝑖𝑛[6:0]=40ℎ 𝑡𝑜 7𝐹ℎ) are control registers and are readable or writeable through the DRP. In Figure 4-2 are shown these registers. Development of an acoustic modem 24 M. FAHAD HASSAN 4.2.1. Status registers The first 64 address locations contain the result of an Analogue-to-Digital conversion of on-chip sensors and external analogue channels. All sensors and external analogue input channels have a unique channel address. The measurement result from each channel is stored in a status register. The status registers also store the maximum and minimum measurements recorded for the on-chip sensors since the device power-up or since the last user reset of the ADC. Table A-2 defines the status registers. 4.2.1.1. Flag register The 16-bits flag register is accessed by address 𝐴𝐷𝐷𝑅[6:0] = 3𝐹ℎ. It is consisted of: The bus 𝐴𝐿𝑀[6:0] reflect the status of the alarm output 𝐴𝐿𝑀[6:0]. Figure 4-2: XADC registers (status and control registers). Extract from [32]. Figure 4-3: Flag register (Address = 𝟑𝑭𝒉) Chapter 4: Analogue to digital converter (ADC) M. FAHAD HASSAN 31 4.4.1. Single channel mode In this mode, an analogue-to-digital conversion channel is selected by writing to bit locations 𝐶𝐻[4: 0] in control register 40h. See Table A-3 so how to select this mode. The configuration of analogue input mode (𝐵𝑈 ) and settling time (ACQ) also be set by writing to control register 40ℎ. 4.4.2. Automatic channel sequencer The automatic channel sequencer sets up a range of predefined operating modes. The sequencer automatically selects the next channel for conversion, sets the averaging, configures the analogue input channels, sets the required setting time for acquisition, and stores the results in the status registers. To select sequencer mode, see Table A-9. This mode needs several configuration registers to set. 4.4.2.1. ADC channel selection registers The ADC channel selection registers enable and disable a channel in the automatic channel sequencer. The bits for these registers are defined in Table A-12 and Table A-13. A logic 1 enables a channel in the sequence. It consists of one pair of 16-bit registers (48ℎ and 49ℎ). 4.4.2.2. ADC channel averaging Averaging could be selected independently for each channel in the sequence. It consists of one pair of 16-bit registers (4𝐴ℎ and 4𝐵ℎ). These registers also have the same bit assignments as the channel sequence registers listed in Table A-12 and Table A-13. When averaging is enables for some of the channels of the sequence, the EOS is only pulsed after the sequence has completed the amount of averaging selected by using 𝐴𝑉𝐺[1:0] bits (see Table A-7). If a channel in the sequence does not have averaging enabled, its status register is updated for every pass through Development of an acoustic modem 32 M. FAHAD HASSAN the sequencer. When a channel has averaging enabled, its status register is only updated after the averaging is complete. 4.4.2.3. ADC channel analogue-input mode These registers are used to configure an ADC channel as either unipolar or bipolar in the automatic sequence. It consists of one pair of 16-bit registers (4𝐶ℎ and 4𝐷ℎ). These registers also have the same bit assignments as the channel sequence registers listed in Table A-12 and Table A-13. However, only external analogue input channels, such as the dedicated input channels (𝑉𝑃 and 𝑉𝑁) and the auxiliary analogue input (VAUXP[15:0] and VAUXN[15:0]) could be configured in this way. 4.4.2.4. ADC channel setting time The default setting time for an external channel in continuous sampling mode is four ADCCLK cycles. The settling time is additional acquisition time after the end of a conversion. However, by setting the corresponding bits (for external channels) to logic 1 in registers 4𝐸ℎ and 4𝐹ℎ, the associated channel could have its settling time extended to 10 ADCCLK cycles. The bit definition (which bits correspond to which external channels) for these registers are the same as the sequencer channel selection shown in Table A-12 and Table A-13. 4.4.3. External multiplexer mode The XADC allows an output bus called MUXADDR[4:0] (up to 16 external signals) to control an external multiplexor. The address on this bus reflects the channel currently being acquired. The external multiplexor is useful where FPGA I/O resources are limited, and auxiliary analogue inputs are not available. The dedicated analogue inputs (𝑉𝑃/𝑉𝑁) or internal auxiliary inputs (𝑉 𝐴𝑈𝑋[15: 0]) are used to connect the external multiplexer to the XADC block. Two external multiplexers are used to support simultaneous sampling. Chapter 4: Analogue to digital converter (ADC) M. FAHAD HASSAN 33 The MUX bit is set to 1 to select this mode. The channel selection bits (𝐶𝐻[4:0]) in 𝐶𝑜𝑛𝑓𝑖𝑔𝑢𝑟𝑎𝑡𝑖𝑜𝑛 𝑅𝑒𝑔𝑖𝑠𝑡𝑒𝑟 0 are used to nominate the channel for connection to the external multiplexor. 4.5. Timing All XADC timing is synchronized to the DRP clock (DCLK). The ADCCLK generated by dividing DCLK by the user selection in the configuration register (see Table 4-1). The ADC operates either in continuous sampling mode or event sampling mode. The operating mode is selected by writing to configuration register 0 (see Table A-3). 4.5.1. Continuous sampling In continuous sampling mode, the ADC automatically starts a new conversion at the end of the current conversion cycle. The analogue-to-digital conversion process is made up of two parts, the acquisition phase and the conversion phase. 4.5.1.1. Acquisition phase The acquisition phase involves charging a capacitor in the ADC to the voltage on the selected channel. The time required to charge this capacitor depends on the selected input-channel source impedance. A settling period of four ADCCLK cycles is left between the end of the current conversion and the start of the next conversion. Figure 4-10: Continuous sampling mode. Extract from [32]. Development of an acoustic modem 34 M. FAHAD HASSAN In single channel mode, the 𝑐𝑜𝑛𝑓𝑖𝑔𝑢𝑟𝑎𝑡𝑖𝑜𝑛 𝑟𝑒𝑔𝑖𝑠𝑡𝑒𝑟 0 has to be written to select the next channel for conversion. 4.5.1.2. Conversion phase The conversion phase starts at the end of the 4 or 10 ADCCLK cycles settling time and it takes 22 ADCCLK. The BUSY signal transitions to an active-High to indicate the ADC is carrying out a conversion. 16 DCLK cycles after BUSY goes Low, EOC pulses High for one DCLK cycles. EOS indicates the end of the sequence, which depends on the automatic channel sequencer settings and averaging settings. 4.5.2. Event sampling mode In event sampling mode next conversion is initiated using a trigger input signal called CONVST. A rising edge on CONVST defines the exact sampling instant for the selected analogue-input channel. The BUSY signal transition High just after the sampling instant on the next rising edge of DCLK. As with the continuous sampling mode, enough time must be allowed between a channel change and the sampling edge (rising edge of CONVST). A settling period of four ADCCLK cycles is recommended between the end of the current conversion (BUSY going logic-Low) and the start of the next conversion. 16 DCLK cycles after Busy goes Low, EOC pulses High for one DCLK. Chapter 4: Analogue to digital converter (ADC) M. FAHAD HASSAN 35 It is not possible to interrupt the conversion or start a new conversion until BUSY goes Low after a conversion has been initiated by CONVST. 4.5.3. Dynamic reconfiguration Port Timing The DRP address (DADDR) and write enable (DWE) inputs are captured when the DRP enables is logic High (DEN). When DRDY goes High, the data for this read operation is valid on the DO bus. DWE signal has to be logic Low. For a write operation, the DWE signal is logic High and the DI bus and DRP address (DADDR) is captured. The DRDY signal goes logic High when the data has been successfully written to the DRP registers. A ness read or write operation cannot be initiated until the DRDY signal has gone logic-Low. Figure 4-11: Event sampling mode. Extract from [32]. Development of an acoustic modem 36 M. FAHAD HASSAN Figure 4-12: DRP timing. Extract from [32]. Chapter 5: ARM Cortex-M3 M. FAHAD HASSAN 37 5. ARM CORTEX-M3 ARM processors address many different market segments including enterprise application, automotive systems, home networking and wireless technologies. The ARM Cortex family of processors provided a standard architecture to address the board performance. The ARM Cortex family includes processors based on the three distinct profiles; the A profile for sophisticated and complex operating systems; the R profile for real-time systems; and the M profile optimized for cost-sensitive and microcontroller applications. The ARM Developer has different Cortex-M microcontrollers without a licence to develop in FPGA. The most common microcontroller is based on Cortex M0, known as Cortex M1. This microcontroller supports all FPGA functionalities and with the facility to edit using Hardware Description Languages. Nevertheless, for this thesis, a Cortex-M3 microcontroller is used because of their easy connections with Vivado components through AXI-3 bus. Furthermore, the Cortex-M3 does not need extra third-party components to function properly because it is packed as a Vivado IP. This core is also available by ARM Developer to implement in FPGA however it is developed for Arty A7 Xilinx board and has an example Hardware and Software program. Hence a lot of time is dedicated to this part; first to understand the example and adapt for Nexys 4DDR board, and then to develop the modem in this board. 5.1. Introduction The ARM Cortex-M processors are high performance, low cost, low power, 32- bit RISC processors, designed for microcontroller applications [4]. The Cortex M processors are based on the ARMv7-M architecture. This architecture includes Development of an acoustic modem 38 M. FAHAD HASSAN efficient 3-stage pipeline instructions and low-latency Interrupt Service Routine (ISR) entry and exit. Cortex M3 also includes hardware divide and Multiply-Accumulate (MAC) operations, a Nested Vectored Interrupt Controller (NVIC), an optional memory protection Unit (MPU), Timer, Debug Access Port (DAP) and optional Embedded Trace Macrocell (ETM). The Cortex M3 processor is used for different applications such as microcontrollers, industrial control, in mobile phones (as secondary core), in an FPGA (as softcore), and other applications. 5.2. FPGA edition The Cortex M3 is adapted to implement in FPGA with similar internal features. The core includes a Nested Vectored Interrupt Controller which support up to 240 interrupts, the priority of each of them could be changed dynamically. It supports configurable embedded debug support, ITCM alias support and Serial Wire (SW), JTAG, or combined SWJ-DP debug port. An AHB to AXI bridge is integrated to make possible the communication with GPIOs or other external Vivado components. The core allows by their pins (see Table A-14) the following optional features: - Embedded Trace Macrocell (ETM) - Data Watchpoint and Trace (DWT) - Instrumentation Trace Macrocell (ITM) coupled with Trace Port Interface Unit (TPIU) - Memory Protection Unit (MPU) - AHB access through Serial-Wire or JTAG Debug Port - Flash Patch Breakpoint (FPB) There are two Tightly Coupled Memory (TCM), for code and data, which are configurable in size. The Instruction Tightly Coupled Memory (ITCM) can be configured at run time to be aliased to either or both of 0x00000000 and Chapter 5: ARM Cortex-M3 M. FAHAD HASSAN 39 0x10000000. The Data Tightly Coupled Memory (DTCM) is at a fixed location of 0x20000000. The size of ITCM and DTCM could be chosen, each of them, from 8 kB to 1 GB with multiple of 8. The instruction code and data code AHB interfaces from the processor are combined internally. Any access from either of these buses which does not match an active ITCM alias is presented on the external instruction AXI interface. The system AHB interface from the processor is used to access the DTCM. Any access which is not within the range of the configured DTCM size is presented on the system AXI interface. The ITCM and DTCM connection is shown in Figure 5-1. 5.3. Core features As is mentioned, the core has features which could be accessible by their ports. It is interesting to know the functionality of these features. Figure 5-1: Internal memory processing multiplexor. Extract from [14]. Development of an acoustic modem 40 M. FAHAD HASSAN 5.3.1. Nested Vectored Interrupt Controller (NVIC) NVIC can support up to 240 external interrupts with 256 levels of priority which can be changed dynamically. The ARMv7-M architecture supports levelsensitive and pulse-sensitive interrupt behaviour. NVIC can be enabled or disabled by writing to their corresponding Interrupt Set-Enable or Interrupt Clear-Enable register bit field. A function is used in this thesis to enable and disable the interrupts. When an interrupt is disabled, interrupt assertion causes the interrupt to become pending, but it cannot become active. In this case, it remains active until this is cleared by a reset or an exception return. The software can set or remove the pending state of NVIC interrupts using registers, the Set Pending Register and Clear-Pending Register. Two functions are used to Set-Pending interrupt and Clear-Pending Register, which accesses to Set pending Register and Clear-Pending Register to write-one to enable and writezero to disable. 5.3.2. The system timer (SysTick) The core includes a system timer, SysTick which provide a 24-bit clear-on- write, decrementing counter with the flexible control mechanism. The timer could be used - As an RTOS tick timer, that fire at a programmable rate and invokes a SysTick routine each time is fire. - As a high-speed alarm timer. - As a variable rate signal timer. - As a simple counter. The software can use this to measure time to completion and time used. - As an internal clock source control base on missing or meeting duration. The timer consists of four registers: Chapter 5: ARM Cortex-M3 M. FAHAD HASSAN 47 5.5.2. Debug window Debug level enables to set the level of debug supported. Different debug levels can be selected from zero to three; where 0 is no debugging, 1 select two breakpoints and one watchpoint, 2 is full debug except DWT, and 3 is full debug including DWT. Trace level enables to set the level of debug trace which is supported from no trace to full trace. If the Debug level is set to 0 (no debug), the Trace level is automatically set to 0. In other cases, the Trace level has to be reset to the required value. JTAG present enables Cortex-M3 JTAG-debug pins, by default Serial Wire (SW) interface is used. 5.5.3. Instruction and data memory window ITCM or DTCM size select the size of Instruction Tightly Coupled Memory or Data Tightly Coupled Memory, respectively. These memories can have range 8 KB to 1 MB. To select instruction memory, Initialize ITCM is enabled and then the filename is specified. The same procedure is done to select data memory –enable the Initialize DTCM, and specified the filename– but in data memory window. The filename cannot have quote marks around it and the filename has to be added into the design and marked as a memory initialization file. Caution. Vivado reads the memory file during synthesis. That is to say, any modification in memory will not be updated after the synthesis has been completed. Hence it is needed to rerun the synthesis, and generate the bitstream file again. 5.6. Program This section describes the microcontroller program file using Keil uVision. Keil uVision is a program dedicated to generate program files for microcontrollers. This program is used to generate file .hex to run the Cortex M3. Development of an acoustic modem 48 M. FAHAD HASSAN The example program has included also a software example in Keil uVision with an example application. These files have been studied because some files are common files which do not depend on the application, such as core_cm3. To generate the software file, the next steps are followed: - After the hardware design is completed, the standalone BSP files are generated using SDK program, which is included in Vivado. This program generates from Hardware Description File the BSP files to include in Keil project. This way the hardware design is included software files to interact with Hardware design by the program. - The program is developed in Keil using C language. The main part of this program is the Goertzel Algorithm to detect the input signal (see 5.6.1. Goertzel Algorithm). - When the program is finished, it is compiled to generate .hex files. - Finally, the synthesis is rerun to include in bitstream the new hex file. 5.6.1. Goertzel Algorithm The Goertzel Algorithm is used to detect a specific predeterminate frequency. The algorithm can be used for tone detection and use less CPU than the Fast Fourier Transform. It gives real and imaginary frequency components as a Discrete Fourier Transform (DFT) or Fast Fourier Transform (FFT). This algorithm only can detect the tone when the input signal corresponds to a sinusoidal. For another sort of signal, this algorithm is not useful. The number of samples and sampling rate has to know previously to calculate the algorithm parameters. Furthermore, it needs n number of samples to obtain the frequency components. This could be a problem because the number of samples has to be stored in RAM. However, the algorithm is modified to work real-time thus not to save data in memory which could take time and power of microcontroller. Hence, when the sample data is obtained, an output signal goes logic-High thus not to obtain more Chapter 5: ARM Cortex-M3 M. FAHAD HASSAN 49 data until the algorithm has finished the calculation. After the calculation has been done the signal return logic-Low again. The algorithm is shown in Code D-11 and Code D-12. Development of an acoustic modem 50 M. FAHAD HASSAN This page intentionally left blank Chapter 6: IP used in block design M. FAHAD HASSAN 51 6. IP USED IN BLOCK DESIGN To develop the design there have been used some other Vivado IPs. These IPs are necessary thus to interconnect the main blocks. 6.1.1. AXI Interconnect This IP is used to interconnect one or more AXI memory-mapped master device to one or more AXI memory-mapped slave device. AXI Interconnect core can be configured to perform one of the following general connectivity patterns: - N-to-1 Interconnect: in this configuration mode multiple master devices access to the single slave device. - 1-to-N Interconnect: in this configuration mode only one master device access to multiple slave devices. - N-to-M interconnect: in this configuration mode multiple master devices access to multiple slave devices. A slave device is a target of an AXI transfer which receives in-bound AXI transactions and a master device is a source of an AXI transfer which generates out-bound AXI transactions. The block diagram of AXI Interconnect is shown in Figure 6-1. The definition of AXI Interconnect are divided into three tables: AXI Interconnect Slave I/O pins, AXI Interconnect Master I/O pins, and AXI Global signals; which are shown in Table A-15, Table A-16 and Table A-17, respectively. Development of an acoustic modem 52 M. FAHAD HASSAN 6.1.2. Utility The AXI Interconnect IP is used to connect the Microcontroller to external GPIOs. The Microcontroller is the only one which performs as master. But there are four Slave devices which are: GPIO 0, GPIO1, GPIO 2 (see 6.2. AXI GPIO) and Block RAM Controller (6.3. AXI BRAM Controller). The AXI Interconnect is shown in Figure 6-2. Figure 6-1: AXI Interconnect Block diagram. Extract from [24] Figure 6-2: AXI Interconnect IP Chapter 6: IP used in block design M. FAHAD HASSAN 53 6.2. AXI GPIO The General-Purpose Input Output (GPIO) can be configured as either a single or dual-channel device, each of this could be configured input or output. Channel one is always present. Channel two is enabled only if the core is configured for dual channel. The maximum GPIO width is thirty-two bits. When the channels are configured as outputs, the default value could be selected. The AXI GPIO also be configured to generate an interrupt when the Enable Interrupt option is set. The interrupt is generated when a transition occurs in any of their input. The Block diagram of the GPIO is shown in Figure 6-3. The port description is could observe in Table A-18. Figure 6-3: AXI GPIO block diagram. Extract from [23] Development of an acoustic modem 54 M. FAHAD HASSAN 6.2.1. Utility The GPIOs are used to get data from output or send data to output. The AXI GPIO IP is shown in Figure 6-4: AXI GPIO IPFigure 6-4. Three GPIOs are used for different purposes which are explained below. The AXI GPIO 2 is explained in 6.11. ADC diagram. 6.2.1.1. AXI GPIO 0 The GPIO 0 is used to interact with outside sending data coming from the Microcontroller. This port sends the power of the signal obtained from the Goertzel Algorithm. The uses of this GPIO is 16-bits width output port. Therefore, there is no need for an interrupt signal thus the Enable Interrupt is not selected. Only one channel of this GPIO is used therefore the Enable Dual Channel also not selected. The default value of the port is set to zero. 6.2.1.2. AXI GPIO 1 The GPIO 1 is used to get data from the button and send data to LED. These two components are used to know if the Microcontroller is functioning. The application consists of; when a button is pulsed, a LED is illuminated. This Figure 6-4: AXI GPIO IP Chapter 6: IP used in block design M. FAHAD HASSAN 55 application is developed in the Microcontroller thus to know the correct functioning of Hardware and Software of Microcontroller. In this version of thesis two push buttons and two RGB LEDs are used to do this application. However, when this application is will implement in Silicon, the application is worked using one push button and one LED, or will be removed. The GPIO 1 uses two channels so Enable Dual Channel is set. The push button signal is obtained from channel 2 and the signal is sent by channel 1 to illuminate the LED. The microcontroller does not pay attention to this GPIO unless it receives the interrupt, which is generated by GPIO when the button is pushed. 6.3. AXI BRAM Controller AXI BRAM Controller is designed to communicate the system master device with local Block RAM. The core could be configured as a single port or both ports to connect with the BRAM Block. The AXI BRAM Controller IP could be configured with ECC functionality with an available external ECC register set via second AXI port. The Error Correction Codes (ECC) is used to mitigate the effect of BRAM single Event Upsets. ECC bits are generated when writing to the block RAM and stored together with the written data. The ECC bits are used to correct any single bit errors and detect any double bit errors in the data when the block RAM is being read. You could read [6] for more detail about this function. Five-channel AXI interface is used to perform all communication with the AXI master device. The write operation is initiated on the Write Address Channel (AW) which specifies the type of write transaction and the information address. The Write Data Channel (W) is used to communicate all write data. The Write Response Channel (B) is used to respond to the operation. The Read Address Channel (AR) communicates all address and control signals on the master device request. The Read Data Channel show the data and status of the operation when the read data is available to send. Development of an acoustic modem 56 M. FAHAD HASSAN Figure 6-5 shows the Block Diagram of used Bram Controller. The channels definition of AXI BRAM Controller IP is explained in Table A-19. 6.3.1. Utility AXI BRAM Controller IP is used to communicate Memory Generator Block with Microcontroller Cortex M3. This block is connected through AXI Interconnect and communicate with this as Master device. 32-bits memory data is used which need 13-bits address. The AXI BRAM Controller is configured as a single port with ECC disabled. The AXI BRAM Controller is shown in Figure 6-6. Figure 6-5: AXI BRAM Controller Block Diagram. Extract from [6]. Figure 6-6: AXI BRAM Controller IP Chapter 6: IP used in block design M. FAHAD HASSAN 63 - Enable Clock Monitoring: This feature allowed to monitor the clocks in a system. The Clock Monitor can detect the change in clock frequency, a glitch 3 in the clock or a stop clock. - MMCM or PLL: this option is used to select either MMCM primitives or PLL primitives. - Frequency synthesis: this feature is enabled when output clocks frequencies needed to be different active input-output clocks. - Phase alignment: this feature allows the output clock to be phase locked to the reference. - Dynamic reconfiguration: this feature allows to programme the primitive after the device is configured, through AXI4-Lite interface. - Safe Clock Startup and Sequencing: this feature allows to generate stable clock at the output using BUFGCF after Locked is sampled High for 8 input clocks. The delay between two enabled output clocks in a sequence is 8 cycle of the second clock in the sequence clock. - Minimize power: This feature minimizes the amount of power needed for the primitives. This feature is not available when the Spread Spectrum (SS) option is selected. - Spread Spectrum (SS): This feature provides modulated output clocks which reduces the spectral density of the electromagnetic interference (EMI) generated by electronic devices. this feature is only available for MMCM (E2/E3) primitives. - Dynamic phase shift: This feature allows changing the phase relationship on the output clocks. This feature is not available when the Spread Spectrum (SS) option is selected. - Balanced: this feature selects balanced results in the software choosing the correct Bandwidth for jitter optimization. 3 Glitch is a transition that occurs on signal before the settlement of this to intended value. In clock signal this can cause an asynchronous behaviour or unstable data. Development of an acoustic modem 64 M. FAHAD HASSAN - Minimize output Jitter: this feature minimizes the jitter on the output clocks but consumes more power and may cause possible errors on the phase. This feature is not available when Maximize input jitter filtering option is chosen. - Maximize input jitter filtering: This feature allows to filter larger input jitter on the input. This feature is not allowed when Minimize output jitter option is chosen. The ports description is showed in Table A-24. 6.6.2. Utility The clocking wizard is used to create the system clock. The input clock of this Wizard is 100 MHz (Xilinx Nexys 4DDR board used a quartz crystal of 100 MHz) and the system clock has 50 MHz frequency. In this case, controlling wizard is not relevant therefore Enable Clock Monitoring is disabled. To create output clock MMCM primitives are used. Since the output clock frequency is different from input clock frequency the Frequency Synthesis option is enabled and Phase Assignment also enabled so to lock the phase. Furthermore, Safe Clock Start-up is enabled. The Balanced options are used to choose the correct Bandwidth of Jitter Optimization. In the Output Clock option, two output clocks are enabled, one as a system clock and another auxiliary clock which could be used for other purposes. 50 MHz is chosen as the frequency of both output clocks. Automatic Control On-Chip is enabled to create source. The MMCM/PLL option is locked so Wizard would choose automatically these options; such as Bandwidth, RIVCLK1_PERIOD, REF_JITTER1, etcetera. The Clocking Wizard is shown in Figure 6-12. Chapter 6: IP used in block design M. FAHAD HASSAN 65 6.7. Utility Vector Logic The Utility Vector Logic core is used to create logic functions. The core support bitwise 𝐴𝑁𝐷, 𝑂𝑅, 𝑋𝑂𝑅 and 𝑁𝑂𝑇 functions. The core gets two input ports, except for NOT operation in which case only one input is needed, and an output port. The width of these ports has to be the same, and the minimum width has to be one. The Utility Vector Logic core is used to make AND, OR and NOT logic operations. For more detail about the function of this core, see 6.11. ADC diagram and 6.12. Clock and reset diagram. 6.8. Constant The constant core used to drive a constant value in the output. The constant value is could express in Decimal, binary (b at the beginning), octal (O at the beginning) and hexadecimal (0x or 0X at the beginning). The core only has one output port, which could have 4096 as maximum port width. These constant cores are used to set different signals. 6.9. Concat The Concat core is used a mechanism to combine bus signals of varying width into a signal bus. The core allowed to select maximum 32 input ports, each of them could have 4096-bits width. The output width is selected automatically with inputs width. Figure 6-12:Clocking Wizard IP Development of an acoustic modem 66 M. FAHAD HASSAN The functionality of the Concat block diagram is shown in Figure 6-13. 6.10. Slice The slice core is used to select some specific bits from the input bus. The core allowed to select input width and from which width to which width wants to select from input data. 6.11. ADC diagram The function of this diagram is to connect the XADC Wizard with AXI GPIO and generate the Echo signal when an enable is received. This diagram consists of XADC Wizard, AXI GPIO, FF_D_T, Square Generator, Concat, Slices and Utility Vector Logic. The ADC diagram is shown in Figure 6-14. 6.11.1. AXI GPIO The GPIO 2 is used to configure the ADC or obtain converted analogic data from it. Each channel of the GPIO is could be configured, by Microcontroller, as input or output, because both ports, input and output, of each channel are connected to even send data or receive data. The channel one of GPIO is used to obtain or send control signals. When this port sends data, the bus consists of; Square Generate signal Enable (𝑆𝐼𝐺𝑁𝐴𝐿𝑆[9]) Figure 6-13: Concat block diagram. Extract from [27]. Chapter 6: IP used in block design M. FAHAD HASSAN 67 (see 6.11.4. Square Generator), the signal GOERTZ_STARTED signal (SIGNALS[8]) (see 6.11.3. FF_D_T), write enable signal (𝑆𝐼𝐺𝑁𝐴𝐿𝑆[7]) and desired ADC registers address (𝑆𝐼𝐺𝑁𝐴𝐿𝑆[6:0]). Four slices are used to separate these signals and, send to the corresponding block. When the channel one of GPIO port is configured as input, it obtains different signals from ADC. In this case, bus SIGNALS[9:0] is formed by Data Enable signal (𝑆𝐼𝐺𝑁𝐴𝐿𝑆[7]), BUSY signal (𝑆𝐼𝐺𝑁𝐴𝐿𝑆[6]) and Channel Out bus (𝑆𝐼𝐺𝑁𝐴𝐿𝑆[4:0]) (see 4.1. ADC channels definition). Other bits are not used but they are necessary to have the same width as input bus. These bits of SIGNALS are set to zero. One concat element is used to combine this signal in one port. The connection of this concat is shown in Figure 6-14. The channel two of GPIO is used to receive and send data. When the channel is configured as input, the GPIO receives data from FF_D_T block. In FF_D_T block the converted data is saved (see 6.11.3. FF_D_T). Otherwise, this port sends data, which have to be saved in ADC registers (see 4.2. ADC registers). The width of this channel is 16 bits. The interruption of the GPIO is enabled to obtain data when an acoustic signal is received. 6.11.2. XADC Wizard The XADC Wizard is the element which gets analogic input and is configured to obtain digital data. (see 4.Analogue to digital converter (ADC)). The core has enabled two input analogic channels, one of them is configured to bipolar input. The ADC uses DRP interface and it works in continuous sampling mode. Input clock of ADC is same as the system clock (50 MHz) and configured to obtain 80 kilo-Samples (KSPS). The reset of this core is active-High, but the system reset is active-Low. Therefore, the Utility Vector Logic core is used to covert active-Low to active-High. This core is configured to make a NOT logic operation thus to reset the core properly. Other ports connection are described in 6.11.1 AXI GPIO. Development of an acoustic modem 68 M. FAHAD HASSAN The connection of this core is shown in Figure 6-14. Alarm outputs ports (𝑢𝑠𝑒𝑟_𝑡𝑒𝑚𝑝𝑒_𝑎𝑙𝑎𝑟𝑚_𝑜𝑢𝑡, 𝑣𝑐𝑐𝑖𝑛𝑡_𝑎𝑙𝑎𝑟𝑚_𝑜𝑢𝑡, 𝑣𝑐𝑐𝑎𝑢𝑥_𝑎𝑙𝑎𝑟𝑚_𝑜𝑢𝑡, 𝑜𝑡_𝑜𝑢𝑡 and 𝑎𝑙𝑎𝑟𝑚_𝑜𝑢𝑡) are not connected because this are not useful for the modem. The 𝑒𝑜𝑠_𝑜𝑢𝑡 pin is also not used because only one input port is used at the time to convert data. 6.11.3. FF_D_T In Vivado there are no Flip Flop component IP however it can be described using Hardware Description Language and packed as a block diagram. The FF_D_T block is generated using Verilog HDL which includes one D Flip Flop and one T Flip Flop. The D Flip Flop obtain data from ADC wizard and when the Data Ready (DRDY) signal is active, save the data in the register. Then the saved data is sent to the microcontroller through GPIO. The input and output bus have the same width which could be selected from external however the predefined width is 16 bits. The T Flip Flop obtain the Data Ready (DRDY) signal and Goertzel Started (GOERT_STARTED) signal to determine the Data Enable (DATA_ENABLE) signal. When there is a rising edge of Goertzel Started signal that means the Goertzel Algorithm has started the calculation and no data is needed. Hence the Data Enable signal is set to logic-Low. When the Goertzel Started is logic-Low and there is a Data Ready signal, the Data Enable signal is set to logic-High. The Data Enable is created because the DRDY only is active one clock and the microcontroller could not have time to catch the signal and thus the signal is disabled during the Goertzel calculation so not to make an error with input data. The core ports description is shown in Table A-21. 6.11.4. Square Generator The Square Generator block, as is named say, is a block that generate a square digital signal. The block consists of two counters; one counter is used to Chapter 6: IP used in block design M. FAHAD HASSAN 69 obtain desired output signal frequency, and the second one is used to determine output signal timing. When the input Enable signal has a rising edge the two counters start counting. The frequency counter gives signal every half period of output Signal thus to set logic-High or logic-Low the output signal (the signal begins with logic- Low). And when the timing counter has achieved the desired value the output signal goes permanently logic-Low unless there is another input Enable. If during the timing counting, Enable signal goes logic-High, this is ignored until the counter achieved the objective value. The core pins are described in Table A-22. 6.12. Clock and reset diagram The function of this diagram is to create appropriate clocks and resets for different elements of the modem, such as AXI Interconnect, Cortex M3, etcetera. The design receives the input clock (𝑠𝑦𝑠_𝑐𝑙𝑜𝑐𝑘) and the reset (𝑠𝑦𝑠_𝑟𝑒𝑠𝑒𝑡_𝑛) signal from Nexys 4 DDR, and auxiliary reset signal (𝑠𝑦𝑠𝑟𝑒𝑠𝑡𝑟𝑒𝑞) from Cortex M3. The clock signal is received by clocking wizard to generate system clock. Individual Processor System Reset gets the each of reset signals to generate output resets. Three resets are generated with these cores: one reset signal is for peripheral; one reset signal is for interconnect, and the last reset signal is for system general reset. Furthermore, the core generates a reset for debug port. The diagram is shown in Figure 6-15. Development of an acoustic modem 70 M. FAHAD HASSAN This page intentionally left blank Chapter 6: IP used in block design M. FAHAD HASSAN 71 Figure 6-14: ADC Diagram with all connection. Note: for better view visit Annex Schematic. Development of an acoustic modem 72 M. FAHAD HASSAN Figure 6-15: Clock and reset diagram with all connection. Note: for better view visit Annex Schematic Chapter 7: Results M. FAHAD HASSAN 79 The Power Setpoint limited the detection of the signal. The figure shows the power of frequencies near 10 kHz. It is chosen 9.8, 9.9, 10, 10.1 and 10.2 kHz frequencies to observe when the echo will be sent. It is observed that the limit of activation is from 10 kHz to 10.1 kHz because with these input signal frequencies the power is upper than Power Setpoint. Other frequencies do not have enough power to activate the Echo signal. 7.4. Performance The modem function correctly establishing the input frequency to 10 kHz with input signal amplitude of the 200 mV. In the following graphics, the modem performance is shown with different input frequencies. The figure shows 5 ms of a sinusoidal signal, in the blue, activation every 100 ms and there correspond echo, in red, of square signal with a duration of 5 ms. 10 1010 2010 3010 4010 5010 6010 7010 8010 9010 0 500 1000 1500 2000 Power Samples taken Different frequencies powe - detecting 10 kHz 9.8 kHz 9.9 kHz 10 kHz 10.1 kHz 10.2 kHz Setpoint Figure 7-7: Power of different frequencies close to 10 kHz. Development of an acoustic modem 80 M. FAHAD HASSAN In the figure… the signal is shown to observe in detail. As it mentioned, it has studied timer to send echo in established time but this did not work correctly and it is not included in the modem. Nevertheless, because Figure 7-8: In blue the input signal of 10 kHz, amplitude of 200 mV and activating the signal every 100 ms. In red the Echo sent by modem. Time 20 ms/div. Voltage 100 mV/div. Figure 7-9: In blue, input signal of 10 kHz, amplitude 200 mV, sinusoidal and duration of 5 ms. In Red the echo send by modem; square signal of 10 kHz and 5 ms of duration. Time 1.2 ms/div. Voltage 100 mV/div. Chapter 7: Results M. FAHAD HASSAN 81 calculation in real time, the time of calculation is very little, as it could see in the figure. In this figure, it is shown the delay between the ending of the input signal and sending the echo. This time depends on the microcontroller instruction processing time. It can observe that there are 112 𝜇s of delay between the input signal and the Echo. 7.5. Resources As is mentioned in objective, one of the main objectives is to develop a compact modem using the minim of the resources. A following it is shown the resources of FPGA that are needed to develop the modem. Figure 7-10: Observing the delay between input signal and Echo. In blue, input sinusoidal signal of 10 kHz and amplitude of 200 mV. In Red the echo send by modem square signal of 10 kHz. Time 50 us/div. Voltage 100 mV/div. Development of an acoustic modem 82 M. FAHAD HASSAN The figure shows the percentage of the FPGA resources used. It can observe that about 23 per cent of Look Up Tables, and about 5 per cent of Flip Flop are used to develop the modem. And approximately 14 per cent of memory is used. Hence, the modem is developed using very few resources. Figure 7-11: Table of resources used and resources available in Nexys 4DDR board. Figure 7-12: Graphic showing the percentage of the board resources used. Chapter 8: Future work M. FAHAD HASSAN 83 8. FUTURE WORK In this thesis, an acoustic modem using a synthesize microcontroller has been developed. The core has developed in FGPA to observe the functionality of the modem. And during their developing, it has observed some limitations using this specific microcontroller. It has observed that the microcontroller with Cortex-M3 core has data acquisition limits, which limits the detection of the higher input signal frequencies. This could be improved using a microcontroller with better features and increasing the input Clock frequency. This investigation work is the previous stage to develop a modem in a silicon chip. But before generating the chip, the Goertzel Algorithm could be used as Digital Filter thus the microcontroller could not need to process the information and detect the tone of the signal. And the microcontroller could be used to do other jobs. Hence, the next stage of this thesis would be developing the silicon chip with Digital filter to improve modem functionality and with filter, the modem could not have the input signal frequency limitations. Development of an acoustic modem 84 M. FAHAD HASSAN This page intentionally left blank Chapter 9: Conclusion M. FAHAD HASSAN 85 9. CONCLUSION Developing the modem has consisted of the main objectives set from the beginning. There was a clear idea, develop a modem which will be used to track underwater species. Use of the microcontroller will allow the detection of the communication signal. The processor and other parts will be created using Hardware Description Language and this way the modem will be compact. Because of being part of a big project, the thesis is limited to create the modem using a microcontroller and assuming that the input signal is electric and adapted to be processed. And the output is a signal that emulates the Echo which will be sent to answer. The first part was how to get the signal to process with the microcontroller. The idea was, using an Analogue to Digital converter (ADC) the data can be converted in digital. Moreover, it was not necessary to buy a separate component because almost all FPGA boards include an ADC in the board. The next stage was the connection of these two devices which involves GPIOs, Verilog modules and others IP. The connection has been improved as the thesis is developed. And the final stage was processing the signal and detect whether the signal corresponds to the specifications or not. Different ideas came out to the surface, such as, use of bandpass filter, or use of matched filter [7]. But finally, it has decided to use the Goertzel Algorithm to detect the tone of the signal. This algorithm is fast and easier to implement in C code. The design of the system started studying the ADC. It is used XADC predesigned component which performs analogue to digital conversion and with other more functionalities. During this part, some complication has been faced because of the technical problems with the core. Once the ADC function properly, the next stage was to select the Microcontroller which was described in HDL and could be implemented on FPGA. Development of an acoustic modem 86 M. FAHAD HASSAN At first, the Cortex-M0 and Cortex-M1 was tried to use for modem but it was observed that these have problems to implement in FPGA because of not founding third party parts. Thus, it was decided to implement Cortex-M3, which came as a compact core. Furthermore, the core has AHB to AXI bridge to connect with other Vivado parts with AXI protocol. Subsequently, the core was implemented in FPGA programming a small pilot program, included with the ARM developer package. To understand how the microcontroller functions, how it connects, and how it is programmed, took some days. When the program functioned correctly, the ADC was connected to the microcontroller. At this stage, the system was capable to convert the analogue data into digital and the microcontroller got the data to process. When the Goertzel Algorithm began to be implemented, another problem arose. It needed a vector of data to proceed with the calculation. And this could have taken a lot of time for the tone detection. The solution was, modify the Algorithm to work in real time. It was observed that using Microcontroller Cortex-M3 for real-time detection limits the acquisition frequency of the ADC to 80 kHz. This frequency does not achieve the Nyquist rate to detect 69 kHz. Thus, the detection of the objective input signal, which has 69 kHz frequency, is not possible. However, to demonstrate the correct functionality of the modem, it was proposed the detection of the signal with 10 kHz frequency. After processing the signal, it was detected the tone of the signal. And when the tone corresponds to 10 kHz frequency, an echo signal is generated with similar characteristics than the input signal. Completed the modem, it has observed the use of sources to create the modem. And as it could see in the Chapter 7, these are very few elements which are used to develop the modem in the FPGA. Since they are used different programs and there are some procedures to fallow to configure the programs, generate the Digital blocs and create software, a user’s manual is provided in the annexes of this document. Chapter 9: Conclusion M. FAHAD HASSAN 87 Finally, one of the issues faced at the end of the thesis was to send the echo at the established time. It has used a microcontroller internal timer, configured the timer before the Goertzel Algorithm starts and an interruption occurs when the selected delay time has passed. Thus, to generate the echo two conditions needed to be fulfilled: the input signal corresponds to the desired signal and timer interruption has occurred. It has been studied this functionality nevertheless it has not been achieved due to lack of time. Development of an acoustic modem 88 M. FAHAD HASSAN This page intentionally left blank Chapter 10: References M. FAHAD HASSAN 73 DEVELOPMENT OF AN ACOUSTIC MODEM USING SYNTHESIZABLE MICROCONTROLLER BACHELOR’S THESIS Bachelor’s degree in Industrial Electronics and Automatic Control Engineering Annexes Author: M. Fahad Hassan-Mobshar Director: Jordi Cosp Vilella Call: June 2019 Development of an acoustic modem Chapter A: Annexe: Tables M. FAHAD HASSAN - 1 - A. ANNEXE: TABLES I. ADC Tables Table A-1: XADC I/O ports Name Type Description s_drp_daddr_in Input Input address port. This port specified the address of the XADC registers. The port has 7-bit width ([6:0]). s_drp_den_in Input Data enable signal. Signal has to be set logic-High before data is carry out or carry in. s_drp_di_in Input Data input port. It is used to save data in XADC registers. The port has 16-bit width ([15:0]). s_drp_do_out Output Data output port. It is used to obtain data from ADC. The port has 16-bit width ([15:0]). s_drp_drdy_out Output Data ready port. This signal goes high when the ADC has carried data in output port. s_drp_dwe_in Input Data write enable signal. This signa has to be logic-High to write data in XADC registers. Vp_Vn_vn_in Input Analogic input Vn negative port. Vp_Vn_vp_in Input Analogic input Vn positive port. Development of an acoustic modem - 2 - M. FAHAD HASSAN Vaux2_vaxn2 Input Analogic input Vaux2 negative port. Vaux2_vaxp2 Input Analogic input Vaux2 positive port. Vaux10_vaxn10 Input Analogic input Vaux10 negative port. Vaux10_vaxp10 Input Analogic input Vaux10 positive port. dclk Input Input XADC clock. The clock has 50 MHz frequency. reset_in Input Reset input signal. Active logic-High. user_temp_ _alarm_out Output Temperature alarm. The signal is logic-High when the measured temperature is upper or lower than established temperature limits. vccint_alarm_out Output 𝑉𝐶𝐶𝐼𝑁𝑇 alarm. The signal is logic-High when measured VCCINT is upper or lower than established VCCINT limits. vccaus_alrm_out Output VCCAUX alarm. This signal is logic-High when measured VCCAUX is upper or lower than established VCCAUX limits. ot_out Output Over Temperature. This signal turns logic- High when the temperature exceeds the over temperature (OT) threshold. The default OT threshold is 125 ºC. alarm_out Output Alarm. This signal could be used to flag the occurrence of any other alarm. This signal is active logic-High. channel_out Output Channel selection output. The current ADC channel is placed on these outputs at the end of an ADC conversion. The port has 5- Chapter A: Annexe: Tables M. FAHAD HASSAN - 3 - bit width ([4:0]). To know more about input MUX, see Table A-6. eoc_out Output End of conversion. This signal transition to logic-High at the endo of an ADC conversion. eos Output End of sequence. This signal transitions to logic-High when the measurement data from the las channel in an automatic channel sequence is written to the status registers. busy Output Busy. This signal transitions to logic-High for an extended period during and ADC or sensor calibration. Table A-2: Status registers Name Address Description Temperature 00h The result of temperature sensor measurement is stored at this location. The 12 MSBs correspond to the temperature sensor transfer function shown in Figure 4-8. 𝑽𝑪𝑪𝑰𝑵𝑻 01h The result of 𝑉𝐶𝐶𝐼𝑁𝑇 supply monitor measurement is stored at this location. The 12 MSBs correspond to the supply sensor transfer function shown in Figure 4-9. 𝑽𝑪𝑪𝑨𝑼𝑿 02h The result of 𝑉𝐶𝐶𝐴𝑈𝑋 data supply monitor measurement is stored at this location. The 12 MSBs correspond to the supply sensor transfer function shown in Figure 4-9. 𝑽𝑷/𝑽𝑵 03h The result of a conversion the dedicated analogue input channel is stored in this register. Development of an acoustic modem - 4 - M. FAHAD HASSAN The 12 MSBs correspond to the transfer function shown in Figure 4-6 or Figure 4-7 depending on analogue input mode. 𝑽𝑹𝑬𝑭𝑷 04h The result of a conversion on the reference input 𝑉𝑅𝐸𝐹𝑃 is stored in this register. The 12 MSBs correspond to the ADC transfer function shown in Figure 4-9. 𝑽𝑹𝑬𝑭𝑵 05h The result of a conversion on the reference input 𝑉𝑅𝐸𝐹𝑁 is stored in this register. The channel is measured in bipolar mode with a two’s complement’s output coding as shown in Figure 4-9. The supply sensor is also used to measure 𝑉𝑅𝐸𝐹𝑁, thus 1 LSB = 3 V/4096. 𝑽𝑪𝑪𝑩𝑹𝑨𝑴 06h The result of the on-chip 𝑉𝐶𝐶𝐵𝑅𝐴𝑀 supply monitor measurement is stored at this location. The 12 MSBs correspond to the supply sensor transfer function shown in Figure 4-9. Undefined 07h This location is unused. Supply A offset 08h The calibration coefficient for the supply sensor offset using ADC A is stored at this location. ADC A offset 09h The calibration coefficient for the ADC A offset is stored at this location. ADC A gain 0Ah The calibration coefficient for the ADC A gain error is stored at this location. Undefined 0Bh to 0Fh These locations are unused. 𝑽𝑨𝑼𝑿𝑷[𝟏𝟓:𝟎] /𝑽𝑨𝑼𝑿𝑵[𝟏𝟓:𝟎] 10h to 1Fh The results of the conversions on auxiliary analogue input channels are stored in this Chapter A: Annexe: Tables M. FAHAD HASSAN - 5 - register. The 12 MSBs correspond to transfer function shown in Figure 4-6 or Figure 4-7 depending on analogue input mode. Max temp 20h Maximum temperature measurement recorded since power-up or the last XADC reset. Max 𝑽𝑪𝑪𝑰𝑵𝑻 21h Maximum 𝑉𝐶𝐶𝐼𝑁𝑇 measurement recorded since power-up or the last XADC reset. Max 𝑽𝑪𝑪𝑨𝑼𝑿 22h Maximum 𝑉𝐶𝐶𝐴𝑈𝑋 measurement recorded since power-up or the last XADC reset. Max 𝑽𝑪𝑪𝑩𝑹𝑨𝑴 23h Maximum 𝑉𝐶𝐶𝐵𝑅𝐴𝑀 measurement recorded since power-up or the last XADC reset. Min temp 24h Minimum temperature measurement recorded since power-up or the last XADC reset. Min 𝑽𝑪𝑪𝑰𝑵𝑻 25h Minimum 𝑉𝐶𝐶𝐼𝑁𝑇 measurement recorded since power-up or the last XADC reset. Min 𝑽𝑪𝑪𝑨𝑼𝑿 26h Minimum 𝑉𝐶𝐶𝐴𝑈𝑋 measurement recorded since power-up or the last XADC reset. Min 𝑽𝑪𝑪𝑩𝑹𝑨𝑴 27h Minimum 𝑉𝐶𝐶𝐵𝑅𝐴𝑀 measurement recorded since power-up or the last XADC reset. Undefined 28h to 2Ah These locations are unused. Unassigned 2Bh Undefined 2Ch to 2Eh These locations are unused. Unassigned 2Fh Development of an acoustic modem - 6 - M. FAHAD HASSAN Supply B offset 30h The calibration coefficient for the supply sensor offset using ADC B is stored at this location. ADC B offset 31h The calibration coefficient for the ADC B gain error is stored at this location. ADC B gain 32h The calibration coefficient for the ADC B gain error is stored at this location. Undefined 33h to 3Eh These locations are unused. Flag 3Fh This register contains general status information (see Flag register). Table A-3: Configuration register for 0, address 𝟒𝟎𝒉 Bit Name Description [4:0] CH[4:0] When operating in single channel mode or external multiplexer mode, these bits are used to select the ADC input channel. See Table A-6. [7:5] 0 These bits should always set logic Low. 8 ACQ When using single channel mode, this bit is set logic 1 to increase the setting time available on external analogue input in continuous sampling mode by six ADCCLK cycles. 9 EC  This bit is used to select either continuous (logic 0) or event-driven (logic 1) sampling mode for the ADC. Chapter A: Annexe: Tables M. FAHAD HASSAN - 7 - 10 BU  This bit is used in single channel mode to select either unipolar (logic 0) or bipolar (logic 1) operating mode for the ADC analogue input. 11 MUX This bit should be set to a logic 1 to enable external multiplexer mode. [13:12] AVG[1:0] These bits are used to set the amount of sample averaging on selected channels in both single channel and sequence modes. See Table A-7. 14 0 This bit should always set as logic Low. 15 CAVG This bit is used to disable averaging for the calculation of the calibration coefficients. Averaging is enabled by default (logic 0) and is fixed at 16 samples. Table A-4: Configuration register, address 𝟒𝟏𝒉 Bit Name Description 0 OT This bit is used to disable the over-temperature signal by setting this bit to logic 1. 0 to 3, 8 ALM[3:0] These bits are used to disable individual alarm outputs (logic 1) for temperature, 𝑉𝐶𝐶𝐼𝑁𝑇, 𝑉𝐶𝐶𝐴𝑈𝑋, and 𝑉𝐶𝐶𝐵𝑅𝐴𝑀, respectively. [7:4] CAL0 to CAL3 These bits enable (logic 1) the application of the calibration coefficients to the ADC and on-chip supply sensor measurements. See Table A-8. [11:9] 0 These bits should always set logic Low. Development of an acoustic modem - 8 - M. FAHAD HASSAN [16:12] SEQ[3:0] These bits enable the channel-sequencer function. See Table A-9. Table A-5: Configuration register 3, address 𝟒𝟐𝒉 Bit Name Description [3:0] 0 These bits should always set logic Low. [5:4] PD[1:0] The XADC could be power-down using these bits. See Table A-10. [7:6] 0 These bits should always set logic Low. [15:8] CD[7:0] These bits select the division ratio between the DRP clock (DCLK) and lower frequency ADC clock (ADCCLK) used for ADC. See Table A-11. Table A-6: ADC channel selection ADC Channel CH[4:0] Description 0 00h On-chip temperature 1 01h 𝑉𝐶𝐶𝐼𝑁𝑇 2 02h 𝑉𝐶𝐶𝐴𝑈𝑋 3 03h 𝑉𝑃, 𝑉𝑁− Dedicated analogue input 4 04h 𝑉𝑅𝐸𝐹𝑃 (1.25 𝑉)(1) 5 05h 𝑉𝑅𝐸𝐹𝑁 (0 𝑉)(1) Chapter A: Annexe: Tables M. FAHAD HASSAN - 15 - nTDOEN Output Test data out enable is unused unless SWO block is being used. TRACENA Output Trace Enable port. If the TRCENA bit of the Debug Exception and Monitor Control Register is enabled then the power consumption of Data Watchpoint and Trace (DWT) and Instrumentation Trace Macrocell blocks is minimized. TRACECLK Output Is the reference clock for the Trace Poet Interface Unit (TPIU). It is asynchronous to the other clocks. TRCEDATA[3:0] Output Output data for clocked modes. TRACEDATA changes on both edges of TRCECLK III. IP Tables Table A-15: AXI Interconnect core Slave I/O signals Signal Name Direction Width Description Snn_ACLK Input 1 Slave interface clock input Snn_ARESETN Input 1 Slave interface reset input (active-Low) Snn_AXI_araddr Input 32 Read address channel address Snn_AXI_arcache Input 4 Read address channel cache characteristics Snn_AXI_arburst Input 2 Read address channel burst type (0-2) Development of an acoustic modem - 16 - M. FAHAD HASSAN Snn_AXI_arlen Input 4 Read address channel burst length code (0-16) Snn_AXI_arlock Input 2 Read address channel atomic access type (0, 1) Snn_AXI_arprot Input 3 Read address channel protection bits Snn_AXI_arready Output 1 Read address channel ready Snn_AXI_arsize Input 3 Read address channel transfer size code (0-7) Snn_AXI_aruser Input 1 User-defined AR channel signals. Snn_AXI_arvalid Input 1 Read address channel valid Snn_AXI_awaddr Input 32 Write address channel address Snn_AXI_awburst Input 2 Write address channel burst type code (0-2) Snn_AXI_awcahce Input 4 Write address channel cache characteristics Snn_AXI_awlen Input 4 Write address channel burst length Snn_AXI_awlock Input 2 Write address channel atomic access type (0,1) Chapter A: Annexe: Tables M. FAHAD HASSAN - 17 - Snn_AXI_awprot Input 3 Write address channel protection bits Snn_AXI_awready Output 1 Write address channel ready Snn_AXI_awsize Input 3 Write address channel transfer size code (0-7) Snn_AXI_awuser Input 1 User defined aw channel signals Snn_AXI_awvalid Input 1 Write address channel valid Snn_AXI_bready Input 1 Write response channel ready Snn_AXI_bresp Output 2 Write response channel response code (0-3) Snn_AXI_bvalid Output 1 Write response channel valid Snn_AXI_rdata Output 32 Read data channel data Snn_AXI_rlast Output 1 Read data channel last data beat Snn_AXI_rready Input 1 Read data channel ready. Snn_AXI_rresp Output 2 Read data channel response code (0-3) Snn_AXI_rvalid Output 1 Read data channel valid Snn_AXI_wdata Input 32 Write data channel data Development of an acoustic modem - 18 - M. FAHAD HASSAN Snn_AXI_wlast Input 1 Write data channel last data beat Snn_AXI_wready Output 1 Write data channel ready Snn_AXI_wstrb Input 4 Write data channel byte strobes Snn_AXI_wvalid input 1 Write data channel valid Table A-16: AXI Interconnect core Master I/O signals Signal Name Direction Width Description Mnn_ACLK Input 1 Master interface clock input Mnn_ARESETN Input 1 Master interface reset input (active-Low) Mnn_AXI_araddr Output 32 Read address channel address Mnn_AXI_arready Input 1 Read address channel ready Mnn_AXI_arvalid Output 1 Read address channel valid Mnn_AXI_awaddr Output 32 Write address channel address Mnn_AXI_awready Intput 1 Write address channel ready Chapter A: Annexe: Tables M. FAHAD HASSAN - 19 - Mnn_AXI_awvalid Output 1 Write address channel valid Mnn_AXI_bready Output 1 Write response channel ready Mnn_AXI_bresp Input 2 Write response channel response code (0-3) Mnn_AXI_bvalid Input 1 Write response channel valid Mnn_AXI_rdata Input 32 Read data channel data Mnn_AXI_rready Output 1 Read data channel ready. Mnn_AXI_rresp Input 2 Read data channel response code (0-3) Mnn_AXI_rvalid Input 1 Read data channel valid Mnn_AXI_wdata Output 32 Write data channel data Mnn_AXI_wready Input 1 Write data channel ready Mnn_AXI_wstrb Output 4 Write data channel byte strobes Mnn_AXI_wvalid Output 1 Write data channel valid Table A-17: AXI Global port signals Signal Name Direction Width Description Development of an acoustic modem - 20 - M. FAHAD HASSAN ACLK Input 1 Clock input ARESETN Input 1 Global reset input (active-Low) Table A-18: AXI GPIO I/O signals Signal Name Direction Description S_AXI_aclk Input AXI Clock S_AXI_arestn Reset AXI Reset, active-Low S_AXI Input / Output AXI slave signals in Table A-15 these signals are described ip2intc_irpt Output AXI GPIO interrupt. Active-High and level sensitive signal. gpio_io_i gpio2_io_i Input Channel 1 and Channel 2 purpose input pins. Width of this port is configurable, maximum 32-bits. gpio_io_o gpio2_io_o Output Channel 1 and Channel 2 general purpose output. Width of this port is configurable, maximum 32-bits. gpio_io_t gpio2_io_t Output Channel 1 and Channel 2 general purpose 3-state pins. Width of this port is configurable, maximum 32-bits. Table A-19: AXI BRAM Controller I/O signals Signal Name Direction Description Chapter A: Annexe: Tables M. FAHAD HASSAN - 21 - S_AXI_aclk Input AXI Clock S_AXI_arestn Input AXI Reset, active-Low S_AXI Input / Output AXI slave signals in Table A-15 are described bram_addr_a Output BRAM Port A (write port) address bus. Bus is sized according to data width and based on C_S_AXI_BASEADDR and C_S_AXI_HIGHADDR. In this case this width is 13-bits bram_clk_a Output Port A BRAM clock. Connected to ACLK with same frequency, and same phase. bram_wrdata_a Output BRAM Port A (write port) address bus. Bus is sixed according to data width and based on C_S_AXI_BASEADDR and C_S_AXI_HIGHADDR. In this case the pin has 32-bits width. bram_rdata_a Input BRAM Port A (read port) read data bus. Size of BRAM read data width is equal to size of AXI slave port connection to the AXI BRAM Controller. In this case the pin has 32-bits width. bram_en_a Output BRAM Port A (write port) enable signal. Active High. bram_rst_a Output BRAM Port A reset. Active-High. bram_we_a 4 bits BRAM Port A active-High write enable signal. Development of an acoustic modem - 22 - M. FAHAD HASSAN Table A-20: Block Memory Generator core I/O pins Signal Name Direction Description addra Input Port A Address, addresses the memory space for port A Read and Write operation. clka Input Port A Clock, port A operations are synchronous to this clock. For synchronous operation. dina Input Port A Data Input, data input to be written into the memory through port A. douta Output Port A data output, data output from Read operations through port A. ena Input Port A Clock Enable, enables Read, Write, and reset operations through port A. rsta Input Port A set/Reset, reset the Port A memory output latch or output register. wea [3:0] Input Port A Write Enable, enables Write operations through port A. Table A-21: FF_D_T block I/O ports description Signal Name Direction Description CLK Input Input Clock signal. Clock frequency 50 MHz. RST Input Input reset signal. Active logic-Low. DATA_INPUT Input Input data port. Data to save in register. Chapter A: Annexe: Tables M. FAHAD HASSAN - 23 - DRDY Input ADC data ready signal. GOERT_STARTED Input Goertzel Algorithm started enable. When this signal is logic-High, indicates that the Goertzel algorithm is being calculated. DATA_OUTPUT Output Data output port. DATA_ENABLE Output Data ready enable signal. Table A-22: Square Generator block I/O ports description Signal Name Direction Description CLK Input Input Clock signal. Clock frequency 50 MHz. RST Input Input reset signal. Active logic-Low. Enable Input Enable to begin the signal generation. Data_Out Out Data out of generated signal. Table A-23: Processor Synchronous Reset Module I/O pins Signal Name Direction Description slowest_sync_clk Input Slowest Synchronous Clock ext_reset_in Input External Reset Input, Active-High or Low based upon the generic Ext Reset Active Polarity. Development of an acoustic modem - 24 - M. FAHAD HASSAN aux_reset_in Input Auxiliary Reset Input. Active-High or Low based upon the generic Auxiliary Reset Active Polarity. mb_debug_sys_rst Input MDM reset input. Always active-High, minimum width defined by parameter External Reset Active Window Width. dcm_locked Input DCM Lock signal. mb_reset Output MB core reset. Active-High. bus_struct_reset Output Bus Structures reset, Active-High. 1- bit width. peripheral_reset Output Peripheral reset is for all peripherals attached to any bus that is synchronous with the slowest_sync_clk. Active-High. interconnect_aresetn Output Interconnect_aresetne reset, for example, interconnects with active- Low reset inputs. peripheral_aresetn Output The signal peripheral_aresetn is for all peripherals attached to interconnect that is synchronous with the slowest_sync_clk. Active-Low. Table A-24: Clocking Wizard core I/O pins Signal Name Direction Description Chapter C: Annexe: User manual M. FAHAD HASSAN - 31 - C. ANNEXE: USER MANUAL This chapter describes the previous configuration of programs to edit the modem files. It also describes the steps to follow to generate the modem for FPGA. I. Configuration Before start developing the modem in Vivado, first, the configuration is needed. During this hardware and software repositories are going to add in the Viviado project. You can visit the following link to configure. The video describes step by step the configuration of Vivado to use Cortex-M processor. • Arm Cortex-M DesignStart FPGA: STEP 2 Prepare Vivado for Cortex-M development II. Generating modem They are some steps to follow to generate the .bit file for FPGA. These steps depend on whether the software is modified or hardware. If you need to modify only software of the microcontroller continues to step 16 to generate a new bitstream file. When in the design any minimum change is made, the next steps are followed to generate the bit file. 1. To modify hardware; goes to Vivado project, expand the m1_for_arty_a7_wrapper, double click on the block diagram entry. Development of an acoustic modem - 32 - M. FAHAD HASSAN 2. After modifying the design, first, you have to validate the design clicking on validate design tick box. 3. If there is no error the design will be validated successfully. Save the block diagram. 4. Next, generate a new bitstream image file. The new bitstream takes around 20 min to build (depends on the PC). 5. When the new bitstream file has generated, we need to generate new hardware file. Go to 𝑓𝑖𝑙𝑒 → 𝐸𝑥𝑝𝑜𝑟𝑡 → 𝐸𝑥𝑝𝑜𝑟𝑡 𝐻𝑎𝑟𝑑𝑤𝑎𝑟𝑒 in Vivado to generate new hardware description file. Figure C-1: Opening Block diagram Figure C-2: Validating design Chapter C: Annexe: User manual M. FAHAD HASSAN - 33 - 6. The next window will appear when you click con Export Hardware. 7. In choose location, navigate to the folder Software, where the hardware description file will be saved. If appears a warining click in ok, the waring would be because you are going to rebuild the Hardware. Figure C-3: Export Hardware Figure C-4: Export Hardware window Development of an acoustic modem - 34 - M. FAHAD HASSAN 8. Open a new windows folder and navigate to sdk_workspace (…/software/m3_for_arty_a7_1/sdk_workspace). Delete all files and folders because new bsp files will be saved in this folder. 9. Next, you need to launch SDK thus go to 𝑓𝑖𝑙𝑒 → 𝐿𝑎𝑢𝑛𝑐ℎ 𝑆𝐷𝐾 . The following window will appear. 10.In Export location, navigate to the Software directory. In Workspace navigate to …/software/m3_for_arty_a7_1/sdk_workspace, and click in ok. 11.When the SDK has launched, go to 𝑋𝑖𝑙𝑖𝑛𝑥 → 𝑅𝑒𝑝𝑜𝑠𝑖𝑡𝑜𝑟𝑖𝑒𝑠. 12.There rescan the repositories and click in ok. Figure C-5: Launch SDK Figure C-6: SW repositories Chapter C: Annexe: User manual M. FAHAD HASSAN - 35 - 13.Now go to 𝑓𝑖𝑙𝑒 → 𝑛𝑒𝑤 → 𝐵𝑜𝑎𝑟𝑑 𝑆𝑢𝑝𝑝𝑜𝑟𝑡 𝑃𝑎𝑐𝑘𝑎𝑔𝑒 and click on. 14.Click in finish 15.After a while, you will see in SDK log that the bsp has been created. 16.Now open the Keil uVision program from Software folder. Figure C-7: Rescanning SW repositories Figure C-8: Generating new BSP Figure C-9:Generating standalone bsp Development of an acoustic modem - 36 - M. FAHAD HASSAN 17.If you need to modify any software, modify. 18.Click in rebuild and ensure that there are no errors. 19.Open a new windows folder and navigate to Bulid Keil (…/software/m3_for_arty_a7_1/Bulid_Keil). Click on make_hex_a7. This will generate new bram_a7.hex file with the new program. 20.Go back to Vivado and Run Synthesis. After the synthesis has finished successfully, generate Bitstream file. 21.Finally, when the Bitstream file is successfully generated, you can implement the file in FPGA. Chapter D: Annexe: Code M. FAHAD HASSAN - 37 - D. ANNEXE: CODE This chapter shows the software and hardware code of the device. This are only codes which are created by the developer. Other elements are part of Cortex-M3 and Vivado. These parts can be observed in Annexe Schematic. The chapter is divided into two sections: Hardware Code and Software Code. I. Hardware code There are two elements created for modem using Verilog HDL. The two parts generated are FF_D_T block and Square Generator block. Specified FF_D_T module FF_D_T#( parameter DWIDTH = 16 ) ( input [DWIDTH-1:0] DATA_INPUT, input CLK, input RST, input DRDY, input GOERT_STARTED, output [DWIDTH-1:0] DATA_OUTPUT, output DATA_ENABLE ); Code D-1: FF-D-T module code (I); I/O declaration. Development of an acoustic modem - 38 - M. FAHAD HASSAN reg [DWIDTH-1:0] D_OUT_AUX; reg D_ENABLE_AUX; reg GS_Z1; reg GS_Z2; always @(posedge CLK) begin if (!RST) begin D_OUT_AUX <= 0; end else if (DRDY) begin D_OUT_AUX <= DATA_INPUT; end end assign DATA_OUTPUT = D_OUT_AUX; always @(posedge CLK) begin if (!RST) begin D_ENABLE_AUX <= 0; GS_Z1 <= 0; GS_Z2 <= 0; end else if (!GS_Z1 && GS_Z2) D_ENABLE_AUX <= 0; else if(!GOERT_STARTED && DRDY) D_ENABLE_AUX <= !(D_ENABLE_AUX); GS_Z2 <= GS_Z1; GS_Z1 <= GOERT_STARTED; end assign DATA_ENABLE = D_ENABLE_AUX; endmodule Code D-2: FF-D-T module code (II). Chapter D: Annexe: Code M. FAHAD HASSAN - 39 - Square Generator module Square_Generator#( parameter DO_Width = 8, parameter Input_Clock_Frequency = 50, // Clock time in MHz parameter Signal_Time = 5000, // Time in microseconds parameter Output_Signal_Frequency = 10000 // Frequency in Hz ) ( input CLK, input RST, input Enable, output [DO_Width-1:0] Data_Out ); reg [DO_Width-1:0] D_OUT_AUX; reg EnableZ1; reg EnableZ; reg EAux; reg [31:0] Tem; reg [31:0] TS; // to count de period reg ES; // to obtain enable Code D-3: Square Generator module code (I); I/O and internal registers declaration. Development of an acoustic modem - 40 - M. FAHAD HASSAN always @(posedge CLK) begin /* Enable detection. The aux Enable is active for long time, until the complete signal is not transmit */ if (!RST) begin EnableZ1 <= 0; EnableZ <= 0; TS <= 0; ES <= 0; D_OUT_AUX <= 0; Tem <= 0; end else begin EnableZ1 <= EnableZ; EnableZ <= Enable; if (EnableZ1 == 0 && EnableZ == 1) begin EAux <= 1; end /* Counter to create square signal period */ if (EAux) begin // couter for signal T: Input_Freq / (Out_Freq * 2); Out_T/2 * 1/Input_T if (TS < (In_Clk_Frq*500000/Out_Sig_Frq - 1)) begin TS <= TS+1; end else if (TS == (In_Clk_Frq*500000/Out_Sig_Frq -1)) begin ES <= 1; TS <= 0; end end Code D-4: Square Generator module code (II)