Summary
- Date:
23 Nov 2019
Directory
Please go to tesla-cat/Works-Done-In-Dzmitry-Lab-At-CQT
the codes are located at
Works-Done-In-Dzmitry-Lab-At-CQT/Cyclone V SoC Control System/Quartus Project Stage 3/the documents are located at
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
DE10_NANO_SoC_GHRDfolder downloaded from terasic official site. This Quartus project provides a template to build on top of.- I then defined PIO ports provided by the
Platform Designerin Quartus, the PIO ports can be accessed by the processor using C program
the FPGA using verilog
this is done via memory mapping
- I then defined PIO ports provided by the
- In this project I defined 4 PIOs in
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
- In this project I defined 4 PIOs in
- Then I modify the main verilog module
DE10_NANO_SoC_GHRD/DE10_NANO_SoC_GHRD.v the code I added are highlighted in the following way
- Then I modify the main verilog module
//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
DE10_NANO_SoC_GHRD/my_modules/ DataSender.v: gets data fromMy16ChannelCounterand send them toFIFOMemoryMapper.v: gets data fromrequestPIOand send them toMy16ChannelCounterMy16ChannelCounter.v: gets data from pinsin16Channelsand send them toDataSenderMyMainModule.v: wraps the above upToShortPulse.v: a utility forFIFO
- Finally I can focus on writing my own modules, which I am familiar with. You can find my modules in
I have finished the codes, then I did physical pin mapping according to
Documents/PinMap.html, then I compiled the project to generateDE10_NANO_SoC_GHRD/output_files/DE10_NANO_SoC_GHRD.sofThen I modified the file
DE10_NANO_SoC_GHRD/output_files/sof_to_rbf.batand used it to convertDE10_NANO_SoC_GHRD.softosoc_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
HPS_FPGA_LED first I modify
HPS_FPGA_LED/main.cthen I
makethe C file into executableHPS_FPGA_LED
- I modify the example project
Inside the C file, 3 addresses for the FIFO are defined, they are the same as in
DE10_NANO_SoC_GHRD/soc_system.qsys- I did not define the address for
requestPIOfor flexibility, instead the user will input the address as argument for the program In this case the “user” would be the nodeJs program below
- I did not define the address for
Javascript Part
First I create a class
nodeJsPart/my_modules/SimpleDE10NANO.js, this class does all the work, it is a http serverI then create the client side script
nodeJsPart/my_modules/client.html, this is only a demo of using the backend API, the counter data are plotted using plotly.jsThen I create the main file
nodeJsPart/server.js, it automatically finds the processor’s IP addressFinally I copied the C executable
HPS_FPGA_LEDtonodeJsPart/HPS_FPGA_LEDso it can be called byserver.jsas a child_processI also had to follow
Documents/terasic_de10_lab_setup.pdfto fix the IP and Mac addressesFinally I typed
node server.jsin the console and visited192.168.101.172:3000from a computer connected to the same router as the DE10 Nano boardEverything worked and I felt happy, next I will let my boss use it in his lab and provide feedback so I may discover bugs