Registers and Counters

Similar documents
Overview. Memory Classification Read-Only Memory (ROM) Random Access Memory (RAM) Functional Behavior of RAM. Implementing Static RAM

Picture of memory. Word FFFFFFFD FFFFFFFE FFFFFFFF

CENG4480 Lecture 09: Memory 1

Logic and Computer Design Fundamentals. Chapter 8 Memory Basics

Dec Hex Bin ORG ; ZERO. Introduction To Computing

Ripple Counters. Lecture 30 1

Code No: R Set No. 1

CENG3420 Lecture 08: Memory Organization

END-TERM EXAMINATION

Code No: R Set No. 1

CREATED BY M BILAL & Arslan Ahmad Shaad Visit:

Software and Hardware

SECTION-A

Code No: 07A3EC03 Set No. 1

Internal Memory. Computer Architecture. Outline. Memory Hierarchy. Semiconductor Memory Types. Copyright 2000 N. AYDIN. All rights reserved.

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language

Organization. 5.1 Semiconductor Main Memory. William Stallings Computer Organization and Architecture 6th Edition

William Stallings Computer Organization and Architecture 6th Edition. Chapter 5 Internal Memory

Homeschool Enrichment. The System Unit: Processing & Memory

II/IV B.Tech (Regular/Supplementary) DEGREE EXAMINATION. Answer ONE question from each unit.

3. The high voltage level of a digital signal in positive logic is : a) 1 b) 0 c) either 1 or 0

CC411: Introduction To Microprocessors

William Stallings Computer Organization and Architecture 8th Edition. Chapter 5 Internal Memory

Computer Systems. Binary Representation. Binary Representation. Logical Computation: Boolean Algebra

Random Access Memory (RAM)

CS232: Computer Architecture II

Code No: R Set No. 1

Reference Sheet for C112 Hardware

5 Computer Organization

Introduction read-only memory random access memory

Memory Addressing, Binary, and Hexadecimal Review

Chapter 6 (Lect 3) Counters Continued. Unused States Ring counter. Implementing with Registers Implementing with Counter and Decoder

Memory and Programmable Logic

Computer Organization. 8th Edition. Chapter 5 Internal Memory

Storage Elements & Sequential Circuits

UNIT - V MEMORY P.VIDYA SAGAR ( ASSOCIATE PROFESSOR) Department of Electronics and Communication Engineering, VBIT

Chapter 5 Internal Memory

Concept of Memory. The memory of computer is broadly categories into two categories:

The Memory Component

COMPUTER ARCHITECTURE AND ORGANIZATION Register Transfer and Micro-operations 1. Introduction A digital system is an interconnection of digital

PDF created with pdffactory Pro trial version How Computer Memory Works by Jeff Tyson. Introduction to How Computer Memory Works

Model EXAM Question Bank

COA. Prepared By: Dhaval R. Patel Page 1. Q.1 Define MBR.

(Refer Slide Time: 00:01:53)

10/24/2016. Let s Name Some Groups of Bits. ECE 120: Introduction to Computing. We Just Need a Few More. You Want to Use What as Names?!

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Computing Layers

Microcomputers. Outline. Number Systems and Digital Logic Review

ELEG3923 Microprocessor Ch.0 & Ch.1 Introduction to Microcontroller

1. Draw general diagram of computer showing different logical components (3)

Computer Organization

Chapter 3 - Top Level View of Computer Function

Chapter 9: A Closer Look at System Hardware

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

Chapter 9: A Closer Look at System Hardware 4

Computer Architecture: Part III. First Semester 2013 Department of Computer Science Faculty of Science Chiang Mai University

Summer 2003 Lecture 18 07/09/03

SHRI ANGALAMMAN COLLEGE OF ENGINEERING. (An ISO 9001:2008 Certified Institution) SIRUGANOOR, TIRUCHIRAPPALLI

PC I/O. May 7, Howard Huang 1

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Building Memory

Basic Organization Memory Cell Operation. CSCI 4717 Computer Architecture. ROM Uses. Random Access Memory. Semiconductor Memory Types

Computer Organization & Architecture M. A, El-dosuky

ECE 341. Lecture # 16

CS 101, Mock Computer Architecture

Microcomputer Architecture and Programming

Injntu.com Injntu.com Injntu.com R16

CS 31: Intro to Systems Digital Logic. Kevin Webb Swarthmore College February 2, 2016

BUILDING BLOCKS OF A BASIC MICROPROCESSOR. Part 1 PowerPoint Format of Lecture 3 of Book

MEMORY AND PROGRAMMABLE LOGIC

CS429: Computer Organization and Architecture

Large and Fast: Exploiting Memory Hierarchy

SUBJECT CODE: IT T35 DIGITAL SYSTEM DESIGN YEAR / SEM : 2 / 3

CS 261 Fall Mike Lam, Professor. Memory

Computer Organization and Assembly Language (CS-506)

Announcement. Computer Architecture (CSC-3501) Lecture 20 (08 April 2008) Chapter 6 Objectives. 6.1 Introduction. 6.

CS429: Computer Organization and Architecture

Computers Are Your Future

CS 31: Intro to Systems Digital Logic. Kevin Webb Swarthmore College February 3, 2015

Principles of Digital Techniques PDT (17320) Assignment No State advantages of digital system over analog system.

Components of a personal computer

VALLIAMMAI ENGINEERING COLLEGE. SRM Nagar, Kattankulathur DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING EC6302 DIGITAL ELECTRONICS

Introduction to computers

Memory & Simple I/O Interfacing

Digital Logic Design Exercises. Assignment 1

CONTENTS CHAPTER 1: NUMBER SYSTEM. Foreword...(vii) Preface... (ix) Acknowledgement... (xi) About the Author...(xxiii)

ECE 485/585 Microprocessor System Design

Semiconductor Memories: RAMs and ROMs

The D igital Digital Logic Level Chapter 3 1

Show how to connect three Full Adders to implement a 3-bit ripple-carry adder

Main Memory (RAM) Organisation

INTRODUCTION TO COMPUTERS

A+ Certification Guide. Chapter 5 Random Access Memory

Chapter 1. Data Storage Pearson Addison-Wesley. All rights reserved

Announcements. This week: no lab, no quiz, just midterm

Memory Hierarchy. Cache Memory. Virtual Memory

EEM 486: Computer Architecture. Lecture 9. Memory

Memory System Design. Outline

Random Access Memory (RAM)

Semiconductor Memory Types Microprocessor Design & Organisation HCA2102

So computers can't think in the same way that people do. But what they do, they do excellently well and very, very fast.

Technology in Action

Transcription:

Week-6 Registers and Counters Acknowledgement: Most of the following slides are adapted from Prof. Kale's slides at UIUC, USA.

Registers and Counters Sequential circuits are classified based in their function, e.g., registers. Register: A group of flip-flops each storing one bit of information. Registers include flip-flops and gates: flip-flops hold the information, gates control how the information is transferred to the register. Counter is a register that goes through a predetermined sequence of states. Registers and Counters 2

What good are registers? Flip-flops are limited because they can store only one bit. Most of the time, we need storage with more than one bit. Most computers work with integers and single-precision floating-point numbers that are 32-bits long. Registers are commonly used as temporary storage in a processor. They are faster and more convenient than main memory. More registers can help speed up complex calculations. IN C: register int i = 0; Registers and Counters 3

4-bit Register Loads in parallel Clear: Cleans the output to all 0 s. Registers and Counters 4

Register with Parallel Load 1 1 To fully synchronize the system, clock signals should arrive at the same time at all flipflops. 0 0 1 I0 I1 Therefore, we do not control the clock by gates. 0 1 I2 Load = 1, we load data. 1 Load =0, register content does not change. 0 1 I3 Registers and Counters 5

Implementing Sequential Circuits Using a register with parallel load capability, one can implement arbitrary sequential circuits. The register can act as the memory component. Input Combinational Logic Output Register Sequential Circuit Registers and Counters 6

Example Present Input Next Output State State A 1 A 2 x A 1 A 2 Y 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 1 0 0 1 1 0 1 1 1 0 0 1 0 0 1 0 1 0 1 0 1 1 0 1 1 0 1 1 1 0 0 1 State table Registers and Counters 7

Example (Cont d) A 2 Present Input Next Output State State A 1 A 2 x A 1 A 2 Y A 1 0 0 0 0 1 0 0 1 A 1 = A 1 X 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 1 0 0 1 1 0 1 1 1 0 0 1 0 0 1 0 1 0 1 0 1 1 0 1 1 0 1 1 1 0 0 1 A 1 X 0 1 0 1 0 1 0 1 X A 2 A 2 A 2 = A 2 X+ A 2 X = A 2 X A 1 0 0 1 0 0 0 1 0 Y = A 2 X CENG-232 X Sequential Circuit Design Page 8

.. with a combinational circuit A 1 A 2 x y Logic Diagram Registers and Counters 9

Shift Registers A register capable of shifting its binary information in one or both directions is called the shift register. Registers and Counters 11

Serial transfer Clocked 4 times Registers and Counters 12

Table Showing Shift A digital system is in the serial mode when information is processed one bit at a time. Registers and Counters 13

Serial data transfer One application of shift registers is converting between serial data and parallel data. Computers typically work with multiple-bit quantities. ASCII text characters are 8 bits long. Integers, single-precision floating-point numbers, and screen pixels are up to 32 bits long. But sometimes it s necessary to send or receive data serially, or one bit at a time. Some examples include: Input devices such as keyboards and mice. Output devices like printers. Any serial port, USB (Universal Serial Bus) or Firewire device transfers data serially. Registers and Counters 14

Receiving serial data To receive serial data using a shift register: The serial device is connected to the register s SI input. The shift register outputs Q3-Q0 are connected to the computer. The serial device transmits one bit of data per clock cycle. These bits go into the SI input of the shift register. After four clock cycles, the shift register will hold a four-bit word. The computer then reads all four bits at once from the Q3-Q0 outputs. serial device computer Registers and Counters 15

Sending data serially To send data serially with a shift register, you do the opposite: The CPU is connected to the register s D inputs. The shift output (Q3 in this case) is connected to the serial device. The computer first stores a four-bit word in the register, in one cycle. The serial device can then read the shift output. One bit appears on Q3 on each clock cycle. After four cycles, the entire four-bit word will have been sent. computer serial device Registers and Counters 16

Remember 4-bit Parallel Adder Circuit? Registers and Counters 17

Serial Addition Slower compared to parallel addition, but uses less equipment. Why Flip-Flop? Registers and Counters 18

Serial Adder: Design Procedure State Table for a Serial Adder without using Full-Adder: Carry-out Carry-in Present State Inputs Next State Output Flip-Flop inputs Q x y Q S J0 K0 0 0 0 0 0 0 x 0 0 1 0 1 0 x 0 1 0 0 1 0 x 0 1 1 1 0 1 x 1 0 0 0 1 x 1 1 0 1 1 0 x 0 1 1 0 1 0 x 0 1 1 1 1 1 x 0 J0=xy K0=x y = (x+y) S=x XOR y XOR Q Registers and Counters 20

Serial Adder Circuit Registers and Counters 21

Universal Shift Register A register capable of shifting in both directions and loading in parallel. Stores Information Multiplexer Inputs: 0: No Change 1: Shift Right 2: Shift Left 3: Parallel load Controls information transfer Registers and Counters 22

Registers - Summary A register is a special state machine that stores multiple bits of data. Several variations are possible: Parallel loading to store data into the register. Shifting the register contents either left or right. Counters are considered a type of register too! One application of shift registers is converting between serial and parallel data. Registers are a central part of modern processors, as we will see in coming weeks. Registers and Counters 24

Counters A register that goes trough a prescribed sequence of states is called a counter. Binary counter Counts through binary sequence n bit counter counts from 0 to 2 n -1 There are two groups of counters: Ripple counters and Synchronous counters. Ripple counters: The flip-flop output triggers other flip-flops in sequence. Synchronous counters count the clock. Registers and Counters 25

What good are counters? Counters can act as simple clocks to keep track of time. You may need to record how many times something has happened. How many bits/bytes have been sent or received? How many steps have been performed in some computation? All processors contain a program counter, or PC. Programs consist of a list of instructions that are to be executed one after another (for the most part; except?). The PC keeps track of the instruction currently being executed. The PC increments once on each instruction cycle, and the next program instruction is then executed. Registers and Counters 26

Binary Ripple Counter A binary ripple counter consists of a series of complementing flip-flops, with the output of each flipflop connected to the next higher order. Examples of complementing flip-flops are T and D (with the output complement connected to the input) flip-flop. Binary Count Sequence A3 A2 A1 A0 0 0 0 0 0 0 0 1 A0 is complemented at each count pulse 0 0 1 0 A1 is complemented when A0 goes from 1 to 0 0 0 1 1 0 1 0 0 A2 is complemented when A1 goes from 1 to 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 A3 is complemented when A2 goes from 1 to 0 Registers and Counters 27

Binary Ripple Counter Count-down counter: A binary counter with reverse count: Starts from 15 goes down. In a count-down counter, the least significant bit is complemented with every count pulse. Any other bit is complemented if the previous bit goes from 0 to 1. We can use the same counter design with negative edge flip-flops to make a countdown flip-flop. Registers and Counters 28

Examples of Binary Ripple Counters No clocks! Count pulse! Why is the Count negated at the clock input? Registers and Counters 29

BCD Ripple Counter A BCD (Binary Coded Decimal) counter starts from 0, ends at 9. Registers and Counters 30

Logic Diagram of BCD Ripple Counter Q1 is applied to the C inputs of Q2 and Q8 (?) Q2 is applied to the C input of Q4 (?) J and K are connected to either 1 or flip-flop outputs (?) Study!!! Registers and Counters 31

Logic Diagram of BCD Ripple Counter Verification: Does the circuit follow the states? Q1 is complemented with every count (J=K=1) Q2 complements if Q1 goes from 1 to 0 and Q8 is 0 Q2 remains 0 if Q8 becomes 1 Q4 complements if Q2 goes from 1 to 0 Q8 remains 0 as long as Q2 or Q4 is 0 When Q2 and Q4 are 1, Q8 complements when Q1 goes from 1 to 0. Q8 clears and the next Q1 transition. Registers and Counters 32

Three-Decade Decimal BCD Counter Counts from 0 to 999: When Q8 goes from 1 to 0 the next higher order decade is triggered 0 to 9 to 0 Registers and Counters 33

4-bit Synchronous Binary Counters A flip-flop is complemented if all lower bits are 1. A3 A2 A1 A0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 Registers and Counters 34

4-bit Up-Down Binary Counters In a down binary counter, The least significant bit is always complemented, a bit is complemented if all lower bits are 0. Up = 1, Down =0: Circuit counts up since input comes from Normal output Up = 0, Down =1: Circuit counts down since input comes from Complemented output Registers and Counters 35

Binary Counter with Parallel Load Sometimes we need an initial value prior to the count operation. Initial value: I3 I2 I1 I0 Registers and Counters 36

Binary Counter with Parallel Load Count = 1, Load =0 1 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 Registers and Counters 37

Binary Counter with Parallel Load Count = 0, Load =1 0 0 1 0 1 1 I 0 I 0 0 I 0 1 1 1 1 1 1 I 1 I 1 I 2 I 2 I 3 I 3 I 1 1 Registers and Counters 38

Binary Counter with Parallel Load In part (a), 1001 (9) is detected. In part (b), 1010 (10) is detected. Why? In part (a), LOAD is set to 1 and effective next cycle. (LOAD is a synchronous control input) In part (b), counter is immediately cleared. (Clear is an asynchronous control input) Registers and Counters 39

Counters with unused states The examples shown so far have all had 2 n states, and used n flip-flops. But sometimes you may have unused, leftover states. For example, here is a state table and diagram for a counter that repeatedly counts from 0 (000) to 5 (101). What should we put in the table for the two unused states? Present State Next State 000 Q 2 Q 1 Q 0 Q 2 Q 1 Q 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 1 1 0 1 1 1 0 0 1 0 0 1 0 1 1 0 1 0 0 0 1 1 0??? 1 1 1??? 101 100 011 001 010 Registers and Counters 41

Unused states can be don t cares To get the simplest possible circuit, you can fill in don t cares for the next states. This will also result in don t cares for the flip-flop inputs, which can simplify the hardware. If the circuit somehow ends up in one of the unused states (110 or 111), its behavior will depend on exactly what the don t cares were filled in with. Present State Next State 000 Q 2 Q 1 Q 0 Q 2 Q 1 Q 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 1 1 0 1 1 1 0 0 1 0 0 1 0 1 1 0 1 0 0 0 1 1 0 x x x 1 1 1 x x x 101 100 011 001 010 Registers and Counters 42

or maybe you do care To get the safest possible circuit, you can explicitly fill in next states for the unused states 110 and 111. This guarantees that even if the circuit somehow enters an unused state, it will eventually end up in a valid state. This is called a self-starting counter. Present State Next State 110 111 Q 2 Q 1 Q 0 Q 2 Q 1 Q 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 1 1 0 1 1 1 0 0 1 0 0 1 0 1 1 0 1 0 0 0 1 1 0 0 0 0 1 1 1 0 0 0 101 100 000 001 010 011 Registers and Counters 43

Other Counters: Ring Counter A ring counter is a counter with ONLY one flip-flop set to 1 at any particular time, all other are cleared. Registers and Counters 44

Other Counters: Johnson Counter A 4 flip-flop ring counter that produces 8 states (not 4). Where do we use it? Registers and Counters 45

Counters - Summary Counters serve many purposes in sequential logic design. There are lots of variations on the basic counter. Some can increment or decrement. An enable signal can be added. The counter s value may be explicitly set. There are also several ways to make counters. You can follow the sequential design principles from last week to build counters from scratch. You could also modify or combine existing counter devices. Registers and Counters 46

RAM: Random Access Memory Sequential circuits all depend upon the presence of memory. A flip-flop can store one bit of information. A register can store a single word, typically 32-64 bits. Random Access Memory, or RAM, allows us to store even larger amounts of data. The basic interface to memory. How you can implement static RAM chips hierarchically. This is the last piece we need to put together a computer! Registers and Counters 47

Introduction to RAM Random-Access Memory or RAM, provides large quantities of temporary storage in a computer system. Remember the basic capabilities of a memory: It should be able to store a value. You should be able to read the value that was saved. You should be able to change the stored value. A RAM is similar, except that it can store many values. An address will specify which memory value we re interested in. Each value can be a multiple-bit word (e.g., 32 bits). We ll refine the memory properties as follows: A RAM should be able to: - Store many words, one per address - Read the word that was saved at a particular address - Change the word that s saved at a particular address Registers and Counters 48

Picture of memory You can think of computer memory as being one big array of data. Address 00000000 00000001 Data The address serves as an array index. Each address refers to one word of data. 00000002.... You can read or modify the data at any given memory address, just like you can read or modify the contents of an array at any given index....... If you ve worked with pointers in C or C++, then you ve already worked with memory addresses. FFFFFFFD FFFFFFFE FFFFFFFF Registers and Counters 49

Block diagram of RAM k n 2 k x n memory ADRS DATA CS WR OUT n CS WR Memory operation 0 x None 1 0 Read selected word 1 1 Write selected word This block diagram introduces the main interface to RAM. A Chip Select, CS, enables or disables the RAM. ADRS specifies the address or location to read from or write to. WR selects between reading from or writing to the memory. To read from memory, WR should be set to 0. OUT will be the n-bit value stored at ADRS. To write to memory, we set WR = 1. DATA is the n-bit value to save in memory. This interface makes it easy to combine RAMs together, as we ll see. Registers and Counters 50

Memory sizes We refer to this as a 2 k x n memory. There are k address lines, which can specify one of 2 k addresses. Each address contains an n-bit word. k n 2 k x n memory ADRS DATA CS WR OUT n For example, a 2 24 x 16 RAM contains 2 24 = 16M words, each 16 bits long. The RAM would need 24 address lines. The total storage capacity is 2 24 x 16 = 2 28 bits. Registers and Counters 51

Size matters! Memory sizes are usually specified in numbers of bytes (8 bits). The 2 28 -bit memory on the previous page translates into: 2 28 bits / 8 bits per byte = 2 25 bytes With the abbreviations below, this is equivalent to 32 megabytes. Prefix Base 2 Base 10 K Kilo 2 10 = 1,024 10 3 = 1,000 M Mega 2 20 = 1,048,576 10 6 = 1,000,000 G Giga 2 30 = 1,073,741,824 10 9 = 1,000,000,000 To confuse you, RAM size is measured in base 2 units, while hard drive size is measured in base 10 units. In this class, we ll only concern ourselves with the base 2 units. Registers and Counters 52

Typical memory sizes Some typical memory capacities: PCs usually come with 512-4096MB RAM. PDAs have 64-512MB of memory. Digital cameras and MP3 players can have 2GB or more of storage. Many operating systems implement virtual memory, which makes the memory seem larger than it really is. Most systems allow up to 32-bit addresses. This works out to 2 32, or about four billion, different possible addresses. With a data size of one byte, the result is apparently a 4GB memory! The operating system uses hard disk space as a substitute for real memory (VM). Registers and Counters 53

Reading RAM To read from this RAM, the controlling circuit must: Enable the chip by ensuring CS = 1. Select the read operation, by setting WR = 0. Send the desired address to the ADRS input. The contents of that address appear on OUT after a little while. Notice that the DATA input is unused for read operations. 2 k x n memory 1 0 k n ADRS DATA CS WR OUT n Registers and Counters 54

Writing RAM To write to this RAM, you need to: Enable the chip by setting CS = 1. Select the write operation, by setting WR = 1. Send the desired address to the ADRS input. Send the word to store to the DATA input. The output OUT is not needed for memory write operations. 2 k x n memory 1 1 k n ADRS DATA CS WR OUT n Registers and Counters 55

Static memory How can you implement the memory chip? There are many different kinds of RAM. We ll start off discussing static memory, which is most commonly used in caches and video cards. Later we mention a little about dynamic memory, which forms the bulk of a computer s main memory. Static memory is modeled using one latch for each bit of storage. Why use latches instead of flip flops? A latch can be made with only two NAND or two NOR gates, but a flip-flop requires at least twice that much hardware. In general, smaller is faster, cheaper and requires less power. The tradeoff is that getting the timing exactly right is a pain. Registers and Counters 56

Starting with latches To start, we can use one latch to store each bit. A one-bit RAM cell is shown here. Since this is just a one-bit memory, an ADRS input is not needed. Writing to the RAM cell: When CS = 1 and WR = 1, the latch control input will be 1. The DATA input is thus saved in the D latch. Reading from the RAM cell and maintaining the current contents: When CS = 0 or when WR = 0, the latch control input is also 0, so the latch just maintains its present state. The current latch contents will appear on OUT. Registers and Counters 57

My first RAM We can use these cells to make a 4 x 1 RAM. Since there are four words, ADRS is two bits. Each word is only one bit, so DATA and OUT are one bit each. Word selection is done with a decoder attached to the CS inputs of the RAM cells. Only one cell can be read or written at a time. Notice that the outputs are connected together with a single line! Registers and Counters 58

How are multiple outputs combined? Using three-state buffers Registers and Counters 59

Bigger and better Here is the 4 x 1 RAM once again. How can we make a wider memory with more bits per word, like maybe a 4 x 4 RAM? Duplicate the stuff in the yellow box! Registers and Counters 63

A 4 x 4 RAM DATA and OUT are now each four bits long, so you can read and write four-bit words. Registers and Counters 64

Bigger RAMs from smaller RAMs We can use small RAMs as building blocks for making larger memories, by following the same principles as in the previous examples. As an example, suppose we have some 64K x 8 RAMs to start with: 64K = 2 6 x 2 10 = 2 16, so there are 16 address lines. 16 There are 8 data lines. 8 8 Registers and Counters 65

Making a larger memory We can put four 64K x 8 chips together to make a 256K x 8 memory. For 256K words, we need 18 address lines. The two most significant address lines go to the decoder, which selects one of the four 64K x 8 RAM chips. The other 16 address lines are shared by the 64K x 8 chips. The 64K x 8 chips also share WR and DATA inputs. This assumes the 64K x 8 chips have three-state outputs. 16 Registers and Counters 66 8 8

Analyzing the 256K x 8 RAM There are 256K words of memory, spread out among the four smaller 64K x 8 RAM chips. When the two most significant bits of the address are 00, the bottom RAM chip is selected. It holds data for the first 64K addresses. 16 8 The next chip is enabled when the address starts with 01. It holds data for the second 64K addresses. The third chip holds data for the next 64K addresses. The final chip contains the data of the final 64K addresses. 8 Registers and Counters 67

Address ranges 8 16 11 1111 1111 1111 1111 (0x3ffff) to 11 0000 0000 0000 0000 (0x30000) 10 1111 1111 1111 1111 (0x2ffff) to 10 0000 0000 0000 0000 (0x20000) 01 1111 1111 1111 1111 (0x1ffff) to 01 0000 0000 0000 0000 (0x10000) 8 00 1111 1111 1111 1111 (0x0ffff) to 00 0000 0000 0000 0000 (0x00000) Registers and Counters 68

Making a wider memory You can also combine smaller chips to make wider memories, with the same number of addresses but more bits per word. Here is a 64K x 16 RAM, created from two 64K x 8 chips. The left chip contains the most significant 8 bits of the data. The right chip contains the lower 8 bits of the data. 8 8 16 8 8 Registers and Counters 69

Getting to know Murphy Early in the '50s, with the advent of jet aircraft there was a debate as to whether a pilot could safely eject from the aircraft. In order to find out whether a man could survive the stresses of ejection the Air Force undertook a study (USAF project MX981). The study involved shooting a rocket sled down a track, accelerating its passenger to speeds in excess of 630 miles of hour and then suddenly stopping in 1.4 seconds, generating over 40g's. One experiment involved a set of 16 accelerometers mounted in different parts of the subject's body. There were two ways each sensor could be glued to its mount. And of course, each was installed the wrong way! One of the engineers on the project, Edward A. Murphy, made the original pronouncement of Murphy's Law, "If there are two or more ways to do something, and one of those can result in catastrophe, then someone will do it." The test subject, Major John Paul's Stapp an Air Force flight surgeon leading the project, quoted Murphy in a press conference a few days later. Within months, Murphy's Law had spread to various technical cultures connected to aerospace engineering and finally to Webster's dictionary in 1958. excerpt taken from http://www.well.com/user/gjmurphy/murphys_law.html Registers and Counters 70

Error correction Murphy s law: "If anything can go wrong, it will!" Memory is no exception! Some bit will flip once in a while.. Your task, of course if you accept it, is to Detect whether there is an error Correct it, if possible Registers and Counters 71

Use extra bits Error-correction For instance append a parity bit For more interesting methods read the related section of the book. Registers and Counters 72

Summary A RAM looks like a bunch of registers connected together, allowing users to select a particular address to read or write. Much of the hardware in memory chips supports this selection process: Chip select inputs Decoders Tri-state buffers By providing a general interface, it s easy to connect RAMs together to make longer and wider memories. Registers and Counters 73

Other memories Some other kinds of memories. Dynamic RAM is used for the bulk of computer memory. Read-only memories and PLAs are two programmable logic devices, which can be considered as special types of memories. Registers and Counters 74

Dynamic memory in a nutshell Dynamic memory is built with capacitors. A stored charge on the capacitor represents a logical 1. No charge represents a logic 0. However, capacitors lose their charge after a few milliseconds. The memory requires constant refreshing to recharge the capacitors. (That s what s dynamic about it.) Dynamic RAMs tend to be physically smaller than static RAMs. A single bit of data can be stored with just one capacitor and one transistor, while static RAM cells typically require 4-6 transistors. This means dynamic RAM is cheaper and denser more bits can be stored in the same physical area. Registers and Counters 75

SDRAM Synchronous DRAM, or SDRAM, is one of the most common types of PC memory now. Memory chips are organized into modules that are connected to the CPU via a 64-bit (8-byte) bus. Speeds are rated in megahertz: PC66, PC100 and PC133 memory run at 66MHz, 100MHz and 133MHz respectively. The memory bandwidth can be computed by multiplying the number of transfers per second by the size of each transfer. PC100 can transfer up to 800MB per second (100MHz x 8 bytes/cycle). PC133 can get over 1 GB per second. Registers and Counters 76

DDR-RAM A newer type of memory is Double Data Rate, or DDR-RAM. It s very similar to regular SDRAM, except data can be transferred on both the positive and negative clock edges. For 100-133MHz buses, the effective memory speeds appear to be 200-266MHz. This memory is confusingly called PC1600 and PC2100 RAM, because 200MHz x 8 bytes/cycle = 1600MB/s 266MHz x 8 bytes/cycle = 2100MB/s. DDR-RAM has lower power consumption, using 2.5V instead of 3.3V like SDRAM. This makes it good for notebooks and other mobile devices. Registers and Counters 77

RDRAM (Rambus DRAM) Another new type of memory called RDRAM is used in the Playstation 2 as well as some Pentium 4 computers. The data bus is only 16 bits wide. But the memory runs at 400MHz, and data can be transferred on both the positive and negative clock edges. That works out to a maximum transfer rate of 1.6GB per second. You can also implement two channels of memory, resulting in up to 3.2GB/s of bandwidth. Registers and Counters 78

Dynamic vs. static memory In practice, dynamic RAM is used for a computer s main memory, since it s cheap and you can pack a lot of storage into a small space. These days you can buy 2GB of memory for as little as $70. You can also load a system with 4GB or more of memory. Registers and Counters 79

Dynamic vs. static memory The disadvantage of dynamic RAM is its speed. Transfer rates are 800MHz at best, which can be much slower than the processor itself. You also have to consider latency, or the time it takes data to travel from RAM to the processor. Real systems augment dynamic memory with small but fast sections of static memory called caches. Typical processor caches range in size from 512KB to 2MB. That s small compared to a 2GB main memory, but it s enough to significantly increase a computer s overall speed. You ll study caches later on in CENG331 next semester. Registers and Counters 80

Read-only memory A read-only memory, or ROM, is a special kind of memory whose contents cannot be easily modified. The WR and DATA inputs that we saw in RAMs are not needed. Data is stored onto a ROM chip using special hardware tools. ROMs are useful for holding data that never changes. Arithmetic circuits might use tables to speed up computations of logarithms or divisions. Many computers use a ROM to store important programs that should not be modified, such as the system BIOS. PDAs, game machines, cell phones, vending machines and other electronic devices may also contain non-modifiable programs. k 2 k x n ROM ADRS OUT CS n Registers and Counters 81

Memories and functions ROMs are actually combinational devices, not sequential ones! You can t store arbitrary data into a ROM, so the same address will always contain the same data. You can think of a ROM as a combinational circuit that takes an address as input, and produces some data as the output. A ROM table is basically just a truth table. The table shows what data is stored at each ROM address. You can generate that data combinationally, using the address as the input. Address A 2 A 1 A 0 Data V 2 V 1 V 0 000 000 001 100 010 110 011 100 100 101 101 000 110 011 111 011 Registers and Counters 82

ROM setup ROMs are based on this decoder implementation of functions. A blank ROM just provides a decoder and several OR gates. The connections between the decoder and the OR gates are programmable, so different functions can be implemented. To program a ROM, you just make the desired connections between the decoder outputs and the OR gate inputs. Registers and Counters 83

ROM example Here are three functions, V 2 V 1 V 0, implemented with an 8 x 3 ROM. Blue crosses (X) indicate connections between decoder outputs and OR gates. Otherwise there is no connection. A 2 A 1 A 0 V 2 = m(1,2,3,4) V 1 = m(2,6,7) V 0 = m(4,6,7) Registers and Counters 84

The same example again Here is an alternative presentation of the same 8 x 3 ROM, using abbreviated OR gates to make the diagram neater. A 2 A 1 A 0 V 2 = m(1,2,3,4) V 1 = m(2,6,7) V 0 = m(4,6,7) V 2 V 1 V 0 Registers and Counters 85

Why is this a memory? This combinational circuit can be considered a read-only memory. It stores eight words of data, each consisting of three bits. The decoder inputs form an address, which refers to one of the eight available words. So every input combination corresponds to an address, which is read to produce a 3-bit data output. A 2 A 1 A 0 Address A 2 A 1 A 0 Data V 2 V 1 V 0 000 000 001 100 010 110 011 100 100 101 101 000 110 011 111 011 V 2 V 1 V 0 Registers and Counters 86

ROMs vs. RAMs There are some important differences between ROM and RAM. ROMs are non-volatile data is preserved even without power. On the other hand, RAM contents disappear once power is lost. ROMs require special (and slower) techniques for writing, so they re considered to be read-only devices. Some newer types of ROMs do allow for easier writing, although the speeds still don t compare with regular RAMs. MP3 players, digital cameras and other toys use CompactFlash, Secure Digital, or MemoryStick cards for non-volatile storage. Many devices allow you to upgrade programs stored in flash ROM. Registers and Counters 87

Programmable logic arrays A ROM is potentially inefficient because it uses a decoder, which generates all possible minterms. No circuit minimization is done. Using a ROM to implement an n-input function requires: An n-to-2 n decoder, with n inverters and 2 n n-input AND gates. An OR gate with up to 2 n inputs. The number of gates roughly doubles for each additional ROM input. A programmable logic array, or PLA, makes the decoder part of the ROM programmable too. Instead of generating all minterms, you can choose which products (not necessarily minterms) to generate. Registers and Counters 88

A blank 3 x 4 x 3 PLA This is a 3 x 4 x 3 PLA (3 inputs, up to 4 product terms, and 3 outputs), ready to be programmed. The left part of the diagram replaces the decoder used in a ROM. Connections can be made in the AND array to produce four arbitrary products, instead of 8 minterms as with a ROM. Those products can then be summed together in the OR array. Inputs AND array OR array Outputs Registers and Counters 89

Regular K-map minimization The normal K-map approach is to minimize the number of product terms for each individual function. For our three functions, this would result in a total of six different product terms. V 2 V 1 V 0 Y 0 1 1 1 X 1 0 0 0 Z Y 0 0 0 1 X 0 0 1 1 Z Y 0 0 0 0 X 1 0 1 1 Z V 2 = m(1,2,3,4) V 1 = m(2,6,7) V 0 = m(4,6,7) Registers and Counters 90

PLA minimization For a PLA, we should minimize the number of product terms for all functions together. We could express V 2, V 1 and V 0 with just four total products: V 2 = xy z + x z + x yz V 1 = x yz + xy V 0 = xy z + xy Y 0 1 1 1 X 1 0 0 0 Z Y 0 0 0 1 X 0 0 1 1 Z Y 0 0 0 0 X 1 0 1 1 Z V 2 = m(1,2,3,4) V 1 = m(2,6,7) V 0 = m(4,6,7) Registers and Counters 91

PLA example So we can implement these three functions using a 3 x 4 x 3 PLA: A 2 A 1 A 0 xy z xy x z x yz V 2 = m(1,2,3,4) = xy z + x z + x yz V 1 = m(2,6,7) = x yz + xy V 0 = m(4,6,7) = xy z + xy V 2 V 1 V 0 Registers and Counters 92

PLA evaluation A k x m x n PLA can implement up to n functions of k inputs, each of which must be expressible with no more than m product terms. Unlike ROMs, PLAs allow you to choose which products are generated. This can significantly reduce the fan-in (number of inputs) of gates, as well as the total number of gates. However, a PLA is less general than a ROM. Not all functions may be expressible with the limited number of AND gates in a given PLA. In terms of memory, a k x m x n PLA has k address lines, and each of the 2 k addresses references an n-bit data value. But again, not all possible data values can be stored. Registers and Counters 93

Functions and memories ROMs and PLAs give us two more ways to implement functions. One difference between expressions/circuits and truth tables: A circuit implies that some calculation has to be done on the inputs in order to arrive at the output. If the same inputs are given again, we have to repeat that calculation. A truth table lists all possible combinations of inputs and their corresponding outputs. Instead of doing a potentially lengthy calculation, we can just look up the result of a function. The idea behind using a ROM or PLA to implement a function is to store the function s truth table, so we don t have to do any (well, very little) computation. This is like memorization or caching techniques in programming. Registers and Counters 94

Summary There are two main kinds of random access memory. Static RAM costs more, but the memory is faster. Static RAM is often used to implement cache memories. Dynamic RAM costs less and requires less physical space, making it ideal for larger-capacity memories. However, access times are also slower. ROMs and PLAs are programmable devices that can implement arbitrary functions, which is equivalent to acting as a read-only memory. ROMs are simpler to program, but contain more gates. PLAs use less hardware, but it requires some effort to minimize a set of functions. Also, the number of AND gates available can limit the number of expressible functions. Registers and Counters 95

You are given Quizzzzzzz two 1K byte and, one 2K byte memories. The word size is 8 bits. Implement a 4K byte memory. Registers and Counters 96