- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I have following questions?
- Why read pointer is 1 less than the write pointer?
- What is this dump value 19844532 at position 0 of read status pointer?
- I am writing 1 to 8 to fifo but not getting the last digits as fifo read status pointer reaches 0.
Here is my code and designs.
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "C:\altera\15.1\embedded\ip\altera\hps\altera_hps\hwlib\include\hwlib.h"
#include "C:\altera\15.1\embedded\ip\altera\hps\altera_hps\hwlib\include\soc_cv_av\socal\socal.h"
#include "C:\altera\15.1\embedded\ip\altera\hps\altera_hps\hwlib\include\soc_cv_av\socal\hps.h"
#include "C:\altera\15.1\embedded\ip\altera\hps\altera_hps\hwlib\include\soc_cv_av\socal\alt_gpio.h"
#include "D:\TestDesigns\customfifoloopback1\hps_0.h"
//fifo status pointers
//#define FIFO_FULL ((*(FIFO_write_status_ptr+1))& 1 )
//#define FIFO_EMPTY ((*(FIFO_read_ptr+1))& 2 )
//LW Addresses
#define REG_BASE 0xFF200000
#define REG_SPAN 0x00200000
//initializing the pointers
void* virtual_base;
volatile unsigned int * FIFO_write_status_ptr= NULL;
volatile unsigned int * FIFO_read_status_ptr = NULL ;
volatile unsigned int * FIFO_write_ptr = NULL ;
volatile unsigned int * FIFO_read_ptr = NULL ;
unsigned int value;
int data[5];
int i;
//int FIFO_FULL;
//int FIFO_EMPTY;
//main functions
int main ()
{
int fd = EXIT_FAILURE;
fd=open("/dev/mem",(O_RDWR|O_SYNC));
if (fd < 0) {
perror("open");
exit(EXIT_FAILURE);
}
printf("fd is ok\n");
//accessing the virtual addresses of the fifo pointers
virtual_base=mmap(NULL,REG_SPAN,(PROT_READ|PROT_WRITE),MAP_SHARED,fd,REG_BASE);
printf("virtual base pointer to open device memory file is ok\n");
FIFO_write_status_ptr = (unsigned int *)(virtual_base+FIFO_0_IN_CSR_BASE);
FIFO_read_status_ptr = (unsigned int *)(virtual_base+FIFO_0_OUT_CSR_BASE);
FIFO_write_ptr=(unsigned int *)(virtual_base+FIFO_0_IN_BASE);
FIFO_read_ptr= (unsigned int *)(virtual_base+FIFO_0_OUT_BASE);
printf("fifo pointers are ok\n");
//entering data into the fifo
for(i=0;i<8;i++)
{
data[i]=i+1;
*FIFO_write_ptr=data[i];
printf("////////////////////////////\n");
printf("you entered the value %d\n",*FIFO_write_ptr);
printf("fifo write status pointer is %d\n",*FIFO_write_status_ptr);
printf("//////////////////////////////\n");
}
printf("reading back the data\n");
for(i=0;i<8;i++)
{
//reading data from the fifo
printf("////////////////////////////\n");
printf("the output value from the fifo is%d\n",*FIFO_read_ptr);
printf("fifo read status pointer is %d\n",*FIFO_read_status_ptr);
printf("/////////////////////////////\n");
}
return 0;
}
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
May I know which Quartus Version you are using and are you using Cyclone V soc?
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page