The Basic Memory Element - The Flip-Flop
• Up until know we have looked upon memory elements
as black boxes. The basic memory element is called the
flip-flop ( )דלגלגor latch. It is composed of 2 cross-
coupled NOR gates. It's truth
table is: R
R S Q !Q
0 0 Q !Q
1 0 0 1
0 1 1 0 _
1 1 unstable S
• We can see that the flip-flop "stores" the contained value
as long as it's inputs are 0. The problem is that the flip-
flop isn't stable (.)יציב
The D Flip-Flop
• Adding 2 AND gates to the flip-flop turns it into a stable
memory element. The 2 inputs are C (clock) and D (data).
When C is asserted (set to 1) the ff is open, the value of D
is stored in it, and Q becomes D. When C is deasserted
the ff is closed and Q is the value of whatever was stored
the last time the ff was open. C
• This type of flip-flop is Q
activated by the rising edge
of the clock. As the clock Q
diagram shows: D
The Master-Slave Flip-Flop
• In order to implement a falling clock ff we use 2 D flip-
flops called a master-slave flip-flop. Now the value Q
changes on the falling edge of the clock.
D D Q D Q Q
latch latch _ _
C C Q Q
The Register File Read register
number 1 Read
• The register-file has to enable us to read number 2
1 or 2 registers and write into 1 register. Write
The read part is easy we use 2 MUXs Write
to choose the registers that are read. data Write
• For the write part we use a decoder, given a number i
it asserts the ith line and deasserts all other lines. This line
together with the write signal provide the C input to each register.
Read register Write
Register 0 Register 0
Register 1 M
u Read data 1 Register number n-to-1 C
Register n – 1 x decoder Register 1
Register n n– 1
Register n – 1
u Read data 2
Register data D
SRAM (Static Random Access Memory)
• Larger amounts of memory than register-files are built with
SRAMs. A SRAM chip is a circuit that stores many memory
elements and enables access to one at a time. SRAMs have fixed
access time to any memory element.
• A 256K x 1 SRAM can hold 256 entries each of which is 1-bit
wide. Thus it will have 18 address lines (256K=218), 1 data input
line and 1 data output line. A 32K x 8 SRAM has the same amount
of total bits but has 15 address lines, 8 input and 8 output lines.
The number of possible Address 15
addresses is called
the height and the Chip select
number of bits in Output enable SRAM 8
each location is 32K 8
called the width.
Typical access 8
times are 5-25 ns. 5
The Three-State Buffer
• To build large memories we would need giant MUXs in order to
read their contents (look at the register-file diagram). For a 64K x1
SRAM we would need a 64K to 1 MUX.
• Instead large memories are implemented by using a shared output
line called a bit-line. To allow multiple source to set a single line
we use the three-state buffer Enable
(or tri-state buffer). A three-state buffer Data 0 In Out
has 2 inputs: a data-signal
Select 1 Enable
and an Output enable. The single
output is the data-signal if the Output Data 1
enable is set (1). If the Output enable is 0 Select 2 Enable Output
the output of the buffer is in a In Out
high-impedance state which enables
other three-state buffers to set the bit-line. Select 3 Enable
• A 4-way MUX is composed of 4 Data 3
A 4 x 2 SRAM
D D D D
Write enable C latch Q C latch Q
2-to-4 D D
C latch Q C latch Q
D D D D
C latch Q C latch Q
D D D D
C latch Q C latch Q
Dout 7 Dout
A 32K x 8 SRAM
• We still need a large decoder and a large number of word lines
(the lines used to enable the individual cells).
• The solution is to organize memories as rectangular ( )מלבניarrays
and use a 2-step decoding process: The 1st decoder creates an
address for the eight 512x64 arrays. Then a set of MUXs selects 1
bit out of every 64 bit-wide array.
9-to-512 512 64 512 64 512 64 512 64 512 64 512 64 512 64 512 64
decoder 512 SRAM SRAM SRAM SRAM SRAM SRAM SRAM SRAM
Mux Mux Mux Mux Mux Mux Mux Mux
Dout7 Dout6 Dout5 Dout4 Dout3 Dout2 Dout1
DRAM (Dynamic Random Access Memory)
• In SRAM the value stored in a cell is kept on a pair of inverting
gates as long as the power is on. In Dynamic RAM the value kept
in a cell is stored as a charge ( )מטעןin a capacitor ( .)קבלA single
transistor is used to access this value.
• Because DRAMs use 1 transistor per bit they are cheaper and
denser ( )צפופיםthen SRAM which use 4-6 transistors per bit.
• In DRAM the charge must be refreshed by reading it and writing
it back again. This is why it is called dynamic RAM.
• The charge can be kept for several milliseconds which is close to a
million clock cycles.
• If we had to refresh each bit we would have no time left to read or
• Fortunately DRAMs use a 2-level decoding structure which
enables refreshing an entire row at once. Typically, refresh
operations take 1-2% of the active cycles of the DRAM. 9
A 4M x 1 DRAM
• DRAMs use a 2-level decoder: a row-access followed by a
column-acess. The row-access chooses a row and stores it in a set
of column latches. The column-access use a MUX to select the
data from the row. To save pins ( )פינים, רגלייםthe same address
lines are used for both the row and column addresses: A pair of
signals RAS (Row Access Strobe) and CAS (Column Access
Strobe) are used to signal if a row or column address is being
• Refresh is performed by reading Row
a row and writing the values back. 11-to-2048
• In 1997, typical DRAM access
times are 60-110ns. The cost per Address[10– 0] Column latches
bit makes DRAM ideal for main
memory. The speed of SRAM Mux
makes it ideal for caches. Dout
EDO and SDRAMs
• A 4M x1 DRAM reads 2048 bits on every row-access and throws
away 2047 bits. It is possible to provide higher bandwidth by
allowing a column address change without a row address change,
resulting in an access to bits in the column latches. This is called
page-mode or static-column mode.
• Nibble-mode RAMs internally create the next 3 column address
thus provding 4 bits (a nibble) for every row access.
• EDO (Extended Data Out) RAMS are the latest versions of page-
mode style. They are becoming standard and have an access time
• SDRAMs(Synchronous DRAMS) and SSRAMs enable reading
or writing a burst of data from sequential addresses in a row or in
a column. SDRAMs and SSRAMs are used mainly in caches
where blocks of data are transferred.
Error Detection and Correction
• Because of potential data corruption in large memories.
Most computers use some sort of error-checking code.
• One simple code that is used is a parity code. The
number of 1s in a word is counted. The word has odd
parity if the number of 1s is odd and even parity if the
number of 1s is even. The parity bit is written into
memory along with the word (1 for odd, 0 for even).
• When the word is read so is the parity bit, if the parity
stored doesn't match the parity read an error is signaled.
• A 1 bit parity can detect only 1 bit of error.
• Parity is only an error-detection scheme. There are more
complex error correction codes (ECC) which can correct
errors in several bits. 12