Thread: What is the difference between “buffering in a memory” and “assigning data to the mem

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    5

    What is the difference between “buffering in a memory” and “assigning data to the mem

    Forgive the newbie question.

    What is the difference between "buffering in on-chip ram" and "assigning a data or writing/reading to/from the on-chip ram"?

    How are they different from the perspective of programming?

    Or I should say how to write a C code for buffering?

    Is it same as assigning the data to an array (just like normal array assignment in C code?)

    Do I need to do something like ""put at the tail. get from the head.? Simple example for me please?

    Could you please give a short C code example of how to load a 4 bytes of data from a 12 bytes data to a buffer?

    Thank you in advance.

    I have an issue where the rate the data is sent to serial port (50Hz) is way faster than the serial port can receive (8Hz).

    Basically, what I have is, data is sent from fpga vhdl block to NIos II system, Nios II system sends the data to serial port, Matlab access the serial port to real time plot the graph.

    So, I wanted to go for the buffering approach. I am using Quartus 12.1 sp1, vhdl and Nios II programmed in C code for DE0-Nano. In Qsys, I am using a few cores such as timer, sdram, uart, pios etc.

  2. #2
    Registered User
    Join Date
    Feb 2012
    Posts
    347
    First of all if it is asynchronous serial communication then baud rate should be matching to establish proper communication. If you are saying that the data is coming at a faster rate than the processor can handle you can use the buffering method. I hope whatever serial data comes you get an interrupt, so as soon as the interrupt is happening, write the data to an array and increment the index. Simultaneously the processor whenever it is free should check for the array and if any data is available it should process and maintain other index. But remember that the array can only be of fixed size. If the incoming data crosses the limit then it will overwrite the data in the array.

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    5
    Quote Originally Posted by Satya View Post
    First of all if it is asynchronous serial communication then baud rate should be matching to establish proper communication. If you are saying that the data is coming at a faster rate than the processor can handle you can use the buffering method. I hope whatever serial data comes you get an interrupt, so as soon as the interrupt is happening, write the data to an array and increment the index. Simultaneously the processor whenever it is free should check for the array and if any data is available it should process and maintain other index. But remember that the array can only be of fixed size. If the incoming data crosses the limit then it will overwrite the data in the array.
    Thank you for your reply...
    Yes, I am talking about the data is coming at a faster rate than the processor can handle, so I want to use the buffering method

    I wanted to know the difference between the two, what I have to do in buffering case, is it same as assigning the data to an array (just like normal array assignment in C code?)

    Or do I need to do something like ""put at the tail. get from the head.?


    Could you please give a short C code example of how to load a 4 bytes of data from a 12 bytes data to a buffer?

  4. #4
    Registered User
    Join Date
    Feb 2012
    Posts
    347
    There are several methods to do the same. Yes it is normal array assignment in C. The simplest is put the data received from the serial port into the array and increment the index1. In the main processor use some other index and read the data from the same array and process the data. You can also do it the other way you said using pointers. You can google first in first out in C.

  5. #5
    Registered User
    Join Date
    Aug 2006
    Posts
    5
    Quote Originally Posted by Satya View Post
    There are several methods to do the same. Yes it is normal array assignment in C. The simplest is put the data received from the serial port into the array and increment the index1. In the main processor use some other index and read the data from the same array and process the data. You can also do it the other way you said using pointers. You can google first in first out in C.
    Thank you Satya, I did google and found this fifo example in C code, A FIFO Buffer Implementation
    It looks much more complicated compared to the normal array assignment in C, I want to know the difference of these two, why people want to do the complicated fifo way if a normal array assignment in C can do the same??
    Forgive newbie question... appreciate any link or resources for further reading

  6. #6
    Registered User
    Join Date
    Feb 2012
    Posts
    347
    Don't worry you can do it using normal array implementation.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. difference between data object and data structure?
    By c_lady in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2011, 12:30 PM
  2. Help assigning memory to structure arrays
    By pk68 in forum C++ Programming
    Replies: 10
    Last Post: 11-29-2010, 07:37 AM
  3. Replies: 12
    Last Post: 04-11-2010, 07:14 AM
  4. assigning a memory address to a pointer
    By MK27 in forum C Programming
    Replies: 5
    Last Post: 09-16-2008, 01:01 PM
  5. Dynamically assigning data-types
    By Morgan in forum C Programming
    Replies: 3
    Last Post: 03-30-2005, 10:14 AM

Tags for this Thread