# Diagrams package that allows to draw computer buffers (memory diagrams)

I'm writing a document that explains internals of memory buffers and computers and I'm looking for a LaTeX package that would allow me to create diagrams similar to the following:

Circular buffer:

Linear buffer:

Any suggestions?

-
You can use TikZ to draw this and much more. – Martin Scharrer May 16 '11 at 16:30
For the ring buffer you should be able to adept the answers to How can I produce a 'ring (or wheel) chart'. – Martin Scharrer May 16 '11 at 16:32
Thanks. There both look great. – Phonon May 16 '11 at 16:35
@Martin Dude! This is amazing! Thanks! = ) – Phonon May 16 '11 at 18:50
You are welcome. I personally would keep the '4 bytes in FIFO' text upright. You just need to change sloped,above,allow upside down to right. – Martin Scharrer May 16 '11 at 18:57

You can draw such diagrams with TikZ (tikz package plus libraries) or PS-Tricks (pstricks and other pst- packages). I personally would recommend TikZ.

Here is how I would draw these diagrams:

\documentclass{article}

\usepackage{tikz}

\begin{document}
\sffamily
\textbf{Circular buffer:}

\begin{tikzpicture}[>=latex,font=\sffamily,semithick,scale=1.75]
\fill [green!25] (0,0) -- (67.5:1) arc [end angle=-22.5, start angle=67.5, radius=1] -- cycle;
\draw [thick] (0,0) circle (1);
\foreach \angle in {90,67.5,...,-67.5}
\draw (\angle:1) -- (\angle-180:1);
\node [circle,thick,fill=white,draw=black,align=center,minimum size=3cm] at (0,0) {FIFO as a\\Circulate Buffer};
\draw [<-] (56.25:1) -- (56.25:1.25) -- +(.333,0)
\draw [<-] (-33.75:1) -- (-33.75:1.25) -- +(.333,0)
node [right,inner xsep=.333cm] (Tail) {Tail (insert)};
\draw [->,shorten >=5pt,shorten <=5pt] (Tail.west) to [bend right]
node [midway,sloped,above,allow upside down] {\footnotesize 4\,bytes in FIFO}
\end{tikzpicture}

\bigskip
\bigskip

\textbf{Linear buffer:}
\par
\bigskip

\begin{tikzpicture}[>=latex,font=\sffamily,every node/.style={minimum width=1cm,minimum height=1.5em,outer sep=0pt,draw=black,fill=blue!40,semithick}]
\node at (0,0) (A) {};
\node [anchor=west] at (A.east) (B) {};
\node [anchor=west] at (B.east) (C) {1};
\node [anchor=west] at (C.east) (D) {2};
\node [anchor=west] at (D.east) (E) {3};
\node [anchor=west] at (E.east) (F) {};
\node [anchor=west] at (F.east) (G) {};
\draw [->,shorten >=2pt,shorten <=2pt,semithick] (G.south) -- +(0,-1em) -| (A);
\end{tikzpicture}
\end{document}


-