Streamer bitrate different from actual transfer rate

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi!

   

I've build an application in C# wich takes data from a Spartan6 FPGA and put them into a txt file.

   

I am testing the slave fifo interface (32 bit).

   

While the Streamer shows a bitrate of 180MB/s, the actual transfer rate is around 8MB/s.

   

This is the C# code of Streamer that show the bitrate:

   

 public unsafe void XferData(byte[][] cBufs, byte[][] xBufs, byte[][] oLaps, ISO_PKT_INFO[][] pktsInfo)

   

        {

   

            int k = 0;

   

            int len = 0;

   


   

            Successes = 0;

   

            Failures = 0;

   


   

            XferBytes = 0;

   

            t1 = DateTime.Now;

   


   

            for (; bRunning; )

   

            {

   

                // WaitForXfer

   

                fixed (byte* tmpOvlap = oLaps)

   

                {

   

                    OVERLAPPED* ovLapStatus = (OVERLAPPED*)tmpOvlap;

   

                    if (!EndPoint.WaitForXfer(ovLapStatus->hEvent, 500))

   

                    {

   

                        EndPoint.Abort();

   

                        PInvoke.WaitForSingleObject(ovLapStatus->hEvent, 500);

   

                    }

   

                }

   


   

                if (EndPoint.Attributes == 1)

   

                {

   

                    CyIsocEndPoint isoc = EndPoint as CyIsocEndPoint;

   

                    // FinishDataXfer

   

                    if (isoc.FinishDataXfer(ref cBufs, ref xBufs, ref len, ref oLaps, ref pktsInfo))

   

                    {

   

                        ISO_PKT_INFO[] pkts = pktsInfo;

   


   

                        for (int j = 0; j < PPX; j++)

   

                        {

   

                            if (pkts.Status == 0)

   

                            {

   

                                XferBytes += pkts.Length;

   

                                Successes++;

   

                            }

   

                            else

   

                                Failures++;

   


   

                            pkts.Length = 0;

   

                        }

   


   

                    }

   

                    else

   

                        Failures++;

   

                }

   

                else

   

                {

   

                    // FinishDataXfer

   

                    if (EndPoint.FinishDataXfer(ref cBufs, ref xBufs, ref len, ref oLaps))

   

                    {

   

                        XferBytes += len;

   

                        Successes++;

   

                    }

   

                    else

   

                        Failures++;

   

                }

   


   

                k++;

   

                if (k == QueueSz)  // Only update displayed stats once each time through the queue

   

                {

   

                    k = 0;

   

                    t2 = DateTime.Now;

   

                    elapsed = t2 - t1;

   


   

                    xferRate = (long)(XferBytes / elapsed.TotalMilliseconds);

   

                    xferRate = xferRate / (int)100 * (int)100;

   


   

                    // Call StatusUpdate() in the main thread

   

                    this.Invoke(updateUI);

   


   

                    // For small QueueSz or PPX, the loop is too tight for UI thread to ever get service.   

   

                    // Without this, app hangs in those scenarios.

   

                    Thread.Sleep(1);

   

                }

   

                // Re-submit this buffer into the queue

   

                len = BufSz;

   

                EndPoint.BeginDataXfer(ref cBufs, ref xBufs, ref len, ref oLaps);

   

            } // End infinite loop

   

        }

   

 

   

And this is the code that I use to write into file:

   

 

   

        public unsafe void WriteToFileThread()

   

        {

   


   

            int bytes = 16384;

   

            byte[] buffer = new byte[bytes];

   

            bool bXferCompleted = false;

   

            bool IsPkt = false;

   


   

            CyBulkEndPoint bulkEpt = EndPoint as CyBulkEndPoint;

   

            if (bulkEpt != null)

   

                bXferCompleted = bulkEpt.XferData(ref buffer, ref bytes, IsPkt);

   

            try

   

            {

   

                while(true)

   

                WriteXferData(buffer, bytes, bXferCompleted);

   

            }

   

            catch (NullReferenceException e)

   

            {

   

                e.GetBaseException();

   

                this.Invoke(handleException);

   

            }

   

        }

   

 

   

What is the problem?

   

 

   

Thank you!

0 Likes
3 Replies
Anonymous
Not applicable
        Can you attach the project here? Can it be used along with the fx3 and fpga codes available with AN61345? Thanks Nikhil   
0 Likes
Anonymous
Not applicable

 I am still debugging it.

   

For what application do you need it?

0 Likes