Forum Discussion
How to obtain the counting of TTL pulses from an FPGA?
- 2 years ago
Hi,
If you want to retrieve the RTL count data in a .txt file, you can use PIO IP to pass the RTL count data to embedded system to be written in .txt file.
PIO IP reference link - https://www.macnica.co.jp/en/business/semiconductor/articles/intel/113961/
TXT file mounting video link - https://www.youtube.com/watch?v=kbIcXwtfBiY&t=414s
To mount the text file in embedded system (eclipse), will need to debug the software Debug As -> Nios II Hardware.
For USB-to-UART, you may refer to this video link https://www.youtube.com/watch?v=7xJ9dhVDCwU&t=271s and reference design https://www.intel.com/content/www/us/en/design-example/715139/cyclone-v-uart-rs-232-maximum-baud-rate-reference-design.html. For the USB part putty (HPS), may be you need to open a new thread in https://community.intel.com/t5/Intel-SoC-FPGA-Embedded/bd-p/soc-fpga-embedded-development-suite to get more details.
If want to send the count data at end of interval, may be can do something like below in RTL:
assign count = (timer == 32'd4999) ? count_reg : 32'b0;
Btw, I had create a design uart_putty.zip attached below for demonstration. The ./software/usbuart/output_end_interval.txt record the count data at end interval while the ./software/usbuart/output_whole_interval.txt record the count data for whole interval.
Let me know if you have any further update or concern.
Thanks,
Best Regards,
Sheng
Hi,
The 32-bits RTL count data obtained is passed to the embedded system through the PIO IP.
In <path>/uart_putty/software/uabuart/main.c:
FILE* - specify a file name.
fopen - open the .txt file
reg_bb[0] = *(volatile unsigned char *) PIO_3_BASE;
reg_bb[1] = *(volatile unsigned char *) PIO_2_BASE;
reg_bb[2] = *(volatile unsigned char *) PIO_1_BASE;
reg_bb[3] = *(volatile unsigned char *) PIO_0_BASE;
int combinedValue = (reg_bb[0] << 24) | (reg_bb[1] << 16) | (reg_bb[2] <<
Retrieve the PIO value (RTL count data) 8-bits each and then combine to 32-bits.
sprintf - convert the combined value to string
strcpy - copy the string to buffer
fputs - write the buffer value to the .txt file and fclose
PutUart1() and GetUart1() are for uart transmit and receive respectively. For the uart transmit to the putty (usb-to-uart), this probably will need help from another forum because will require some board configuration.
Yes, this design is ready for the FPGA programming. Have to program the .sof and .elf files. If you use other boards, try to regenerate all the things.
Thanks,
Regards,
Sheng
Thanks a lot for your help!