Forum Discussion
Altera_Forum
Honored Contributor
19 years agoHi tyrone,
My ring buffer sizes are powers of 2, usually 512 bytes. I have two variables that tell me where the 'in' and 'out' positions are. When characters are inserted or removed these indexes are incremented, I then &= them with a mask that keeps them in range and takes care of the wrap around. For a 512 byte buffer the mask is 0x1ff. Quick and simple. Banx.