FIFO Memory [Avalon-MM Write Slave to MM Read Slave]: How to read data from FIFO

Status
Not open for further replies.

AbinayaSivam

Member level 1
Joined
Jul 27, 2017
Messages
38
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
345
Hello,

I want to write 32-bit data into FIFO and read the data from FIFO. So, I have followed this FIFO configuration :Aalon-MM write slave to Avalon-MM read slave.

Questions to be clarified:

1. I have enabled "backpressure" how to set in wait request signal in NIOS (0`s (deserted) or 1`s (asserted)).

2. I want example code to read the data from FIFO. I have tried but its throwing error. "FIFO_0_IN_BASE" is undeclared.

in which file i can find Base address and control address for read operation. Please anyone guide me.

NIOS Code
Code:
#include "sys/alt_stdio.h"
#include "alt_types.h"
#include<io.h>
#include<system.h>
#include<stdio.h>
#include "altera_avalon_pio_regs.h"
#include "altera_avalon_fifo.h"
#include "altera_avalon_fifo_util.h"
#include "altera_avalon_fifo_regs.h"

#define FIFO_0_IN_BASE 0x3000
#define ctrl_address 0x3040


int main()
{

    	int result,i=0;
        int *data=0;

    	IOWR(ENABLE_BASE, 0, 0x1);		// Enable the counter
    	alt_printf("Hello from Nios II!\n");		// Send Hello World to the JTAG UART

    	while(1)
    	{
    	//*data = IORD_ALTERA_AVALON_FIFO_DATA(FIFO_0_IN_BASE);
    	data=altera_avalon_read_fifo(FIFO_0_IN_BASE, ctrl_address, 0);
    	printf("%d\n",*data);
    	}
    	/*  {
    	altera_avalon_read_fifo(FIFO_0_IN_CSR_BASE, ctrl_address,  *data);
    	printf("LEVEL: %u\n", level);
    	while(1)
    	{
    	result=IORD(FIFO_0_IN_BASE, 0);
    	printf("%d\n",result);
    	}
    for (i=0;i<100;i++)

    	{
              result=IORD(COUNTER_OUT_BASE, 0);
    		  printf("%d\n",(result+i));
    	}*/
    	return 0;
}

WHICH Read function I should Use ? Difference please
Code:
altera_avalon_read_fifo(FIFO_0_IN_CSR_BASE, ctrl_address,  *data);
IORD_ALTERA_AVALON_FIFO_DATA(FIFO_0_IN_BASE);

Qsys
 

Attachments

  • FIFO_Block.JPG
    165.5 KB · Views: 159

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…