Direct-Mapped Cache

An -byte, -bytes-per-block direct-mapped cache of blocks requires only a write policy to store memory blocks using an index that governs the cache row on which the memory block is written, such that . The length of the tag is therefore equal to

where is the number of bits allocated to the offset, or the length of every block:

\begin{document}
 
\begin{tikzpicture}
   % Draw the inner boxes for Metadata
   \draw[thick, fill=darkgray] (-.5,3) rectangle (1,4);
   \draw[thick, fill=darkgray] (-.5,2) rectangle (1,3);
   \node at (3, 1.5) {$\vdots$};
   \draw[thick, fill=darkgray] (-.5,0) rectangle (1,1);
   
   % Draw the inner boxes for Data
   \draw[thick] (1,3) rectangle (5,4) node[midway] {$K$ bytes};
   \draw[thick] (1,2) rectangle (5,3) node[midway] {$K$ bytes};
   \node at (0.25, 1.5) {$\vdots$};
   \draw[thick] (1,0) rectangle (5,1) node[midway] {$K$ bytes};
   
   % Add text labels
   \node at (-1.25, 4.25) {Index};
   \node[align=center] at (0.25, 4.5) {Metadata \\ (Tag)};
   \node at (3, 4.75) {Data Offset};
   
   % Add index numbers
   \node at (-1,3.5) {$0$};
   \node at (-1,2.5) {$1$};
   \node at (-1, 1.5) {$\vdots$};
   \node at (-1.5,0.5) {$2^{N_i}-1$};
   
   % Add offset numbers
   \node at (1.75, 4.25) {$2^{N_o}-1$};
   \node at (3, 4.25) {$\cdots$};
   \node at (3.75, 4.25) {1};
   \node at (4.75, 4.25) {0};
\end{tikzpicture}
 
\end{document}

Note!

The figure above shows offset data stored in little-endian format.

Examples