Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Circular Buffers: A FIFO Data Storage Solution, Study notes of Digital Signal Processing

Circular buffers, a type of first-in-first-out (fifo) data storage solution commonly used in digital signal processing algorithms. The text compares shifted buffers and circular buffers, explaining the advantages of the latter. It includes pseudo-code for implementing a circular buffer.

Typology: Study notes

2011/2012

Uploaded on 10/17/2012

tiuw
tiuw 🇺🇸

4.7

(18)

288 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Connexions module: m36654 1
Circular Buffers
David Waldo
This work is produced by The Connexions Project and licensed under the
Creative Commons Attribution License
Abstract
Circular buers are used for rst-in-rst-out (FIFO) buers.
1 Introduction
When performing DSP algorithms data needs to be stored as it is being input. Only a certain amount of
data is kept. New data is saved and the old data is removed. This is a rst-in-rst-out (FIFO) buer. There
are two ways to implenent the FIFO buer. One is to shift the data and the other is to implement a circular
buer.
2 Shifted buer
There are two ways of implementing a FIFO buer. Both methods start with dening an array that is the
length of data needed to be stored. The rst method of implementing a FIFO buer is to add the new data
to the beginning of the buer and shifting the old data in the buer. The last value that is shifted out is
discarded or used before it is removed.
Figure 1
To implement the FIFO buer by shifting the following pseudo-code can be used.
N
- number of coecients
x(n)
- stored input data, n = 0...N-1
input_sample
- variable that contains the newest input sample
Version 1.2: Feb 28, 2011 11:38 pm US/Central
http://creativecommons.org/licenses/by/3.0/
http://cnx.org/content/m36654/1.2/
pf3

Partial preview of the text

Download Circular Buffers: A FIFO Data Storage Solution and more Study notes Digital Signal Processing in PDF only on Docsity!

Circular Buffers

David Waldo

This work is produced by The Connexions Project and licensed under the Creative Commons Attribution License †

Abstract Circular buers are used for rst-in-rst-out (FIFO) buers.

1 Introduction

When performing DSP algorithms data needs to be stored as it is being input. Only a certain amount of data is kept. New data is saved and the old data is removed. This is a rst-in-rst-out (FIFO) buer. There are two ways to implenent the FIFO buer. One is to shift the data and the other is to implement a circular buer.

2 Shifted buer

There are two ways of implementing a FIFO buer. Both methods start with dening an array that is the length of data needed to be stored. The rst method of implementing a FIFO buer is to add the new data to the beginning of the buer and shifting the old data in the buer. The last value that is shifted out is discarded or used before it is removed.

Figure 1

To implement the FIFO buer by shifting the following pseudo-code can be used. N - number of coecients x(n) - stored input data, n = 0...N- input_sample - variable that contains the newest input sample ∗Version 1.2: Feb 28, 2011 11:38 pm US/Central †http://creativecommons.org/licenses/by/3.0/

// Shift in the new sample. Note the data is shifted starting at the end. for (i=N-2; i>=0; i--){ x[i+1] = x[i]; } x[0] = input_sample

3 Circular buer

The second method is the more preferable method since it takes less processing. In this method a circular buer is implemented. An index keeps track of the current point in the buer. The data in the buer does not get shifted, the index gets incremented and wrapped around when it gets to the end of the buer. The element after the current index is the last value in the circular buer. The following gure shows the circular buer after the index has already wrapped around.

Figure 2

In the following gure is an example of a FIFO circular buer with the number elements equal to 7. In the gure the current index is 3 and that is where the new sample is stored. The last element in the buer is in element 4.

Figure 3: FIFO buer implemented using a circular buer