Summary ===================== :Date: 23 Nov 2019 Directory --------------- Please go to `tesla-cat/Works-Done-In-Dzmitry-Lab-At-CQT `_ - the codes are located at :code:`Works-Done-In-Dzmitry-Lab-At-CQT/Cyclone V SoC Control System/Quartus Project Stage 3/` - the documents are located at :code:`Works-Done-In-Dzmitry-Lab-At-CQT/Cyclone V SoC Control System/Documents/` Verilog Part ------------------- - The cyclone V FPGA is a SoC system consists of an Arm v7 processor and a FPGA - I start from the :code:`DE10_NANO_SoC_GHRD` folder downloaded from terasic official site. This Quartus project provides a template to build on top of. - I then defined PIO ports provided by the :code:`Platform Designer` in Quartus, the PIO ports can be accessed by - the processor using C program - the FPGA using verilog - this is done via memory mapping - In this project I defined 4 PIOs in :code:`DE10_NANO_SoC_GHRD/soc_system.qsys` - FIFOreadRequest: 1 bit - FIFOreadDataQueue: 32 bits - FIFOreadEmpty: 1 bit - requestPIO: 32 bits - The FIFO is used to **send data from FPGA to processor** - The requestPIO is used to **handle request sent by the processor** - Then I modify the main verilog module :code:`DE10_NANO_SoC_GHRD/DE10_NANO_SoC_GHRD.v` - the code I added are highlighted in the following way .. code-block:: verilog //OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO // Begin Code added by me Part 0: Physical Pins ... // End Code added by me Part 0: Physical Pins //OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO - After modifying the above two existing files, I create a FIFO module using Quartus standard library - Finally I can focus on writing my own modules, which I am familiar with. You can find my modules in :code:`DE10_NANO_SoC_GHRD/my_modules/` - :code:`DataSender.v` : gets data from :code:`My16ChannelCounter` and send them to :code:`FIFO` - :code:`MemoryMapper.v` : gets data from :code:`requestPIO` and send them to :code:`My16ChannelCounter` - :code:`My16ChannelCounter.v` : gets data from pins :code:`in16Channels` and send them to :code:`DataSender` - :code:`MyMainModule.v` : wraps the above up - :code:`ToShortPulse.v` : a utility for :code:`FIFO` - I have finished the codes, then I did physical pin mapping according to :code:`Documents/PinMap.html`, then I compiled the project to generate :code:`DE10_NANO_SoC_GHRD/output_files/DE10_NANO_SoC_GHRD.sof` - Then I **modified** the file :code:`DE10_NANO_SoC_GHRD/output_files/sof_to_rbf.bat` and used it to convert :code:`DE10_NANO_SoC_GHRD.sof` to :code:`soc_system.rbf`. I then put this file in the boot partition of the SD card of the DE10 nano board. Now the verilog program will automatically run whenever the board reboots C Part ------------------- - I modify the example project :code:`HPS_FPGA_LED` - first I modify :code:`HPS_FPGA_LED/main.c` - then I :code:`make` the C file into executable :code:`HPS_FPGA_LED` - Inside the C file, **3** addresses for the FIFO are defined, they are the same as in :code:`DE10_NANO_SoC_GHRD/soc_system.qsys` - I did not define the address for :code:`requestPIO` for flexibility, instead the user will input the address as argument for the program - In this case the "user" would be the nodeJs program below Javascript Part ------------------- - First I create a **class** :code:`nodeJsPart/my_modules/SimpleDE10NANO.js`, this class does all the work, it is a http server - I then create the client side script :code:`nodeJsPart/my_modules/client.html`, this is only a **demo** of using the backend API, the counter data are plotted using plotly.js - Then I create the main file :code:`nodeJsPart/server.js`, it **automatically** finds the processor's IP address - Finally I copied the C executable :code:`HPS_FPGA_LED` to :code:`nodeJsPart/HPS_FPGA_LED` so it can be called by :code:`server.js` as a child_process - I also had to follow :code:`Documents/terasic_de10_lab_setup.pdf` to fix the IP and Mac addresses - Finally I typed :code:`node server.js` in the console and visited :code:`192.168.101.172:3000` from a computer connected to the same router as the DE10 Nano board - Everything worked and I felt happy, next I will let my boss use it in his lab and provide feedback so I may discover bugs