Harvard architecture: Difference between revisions

From Wikipedia, the free encyclopedia
Jump to: navigation, search
(Contrast with other computer architectures: better subsections)
(Contrast von Neumann architectures: add missing word)
Line 4: Line 4:
 
In a Harvard architecture, there is no need to make the two memories share characteristics. In particular, the [[word (computer science)|word]] width, timing, implementation technology, and [[memory address]] structure can differ. In some systems, instructions can be stored in [[read-only memory]] while data memory generally requires [[random access memory|read-write memory]]. In some systems, there is much more instruction memory than data memory so instruction addresses are wider than data addresses.
 
In a Harvard architecture, there is no need to make the two memories share characteristics. In particular, the [[word (computer science)|word]] width, timing, implementation technology, and [[memory address]] structure can differ. In some systems, instructions can be stored in [[read-only memory]] while data memory generally requires [[random access memory|read-write memory]]. In some systems, there is much more instruction memory than data memory so instruction addresses are wider than data addresses.
   
===Contrast von Neumann architectures===
+
===Contrast with von Neumann architectures===
   
 
In a computer with the contrasting [[von Neumann architecture]] (and no [[CPU cache]]), the [[Central processing unit|CPU]] can be either reading an instruction or reading/writing data from/to the memory. Both cannot occur at the same time since the instructions and data use the same bus system. In a computer using the Harvard architecture, the CPU can both read an instruction and perform a data memory access at the same time, even without a cache. A Harvard architecture computer can thus be faster for a given circuit complexity because instruction fetches and data access do not contend for a single memory pathway.
 
In a computer with the contrasting [[von Neumann architecture]] (and no [[CPU cache]]), the [[Central processing unit|CPU]] can be either reading an instruction or reading/writing data from/to the memory. Both cannot occur at the same time since the instructions and data use the same bus system. In a computer using the Harvard architecture, the CPU can both read an instruction and perform a data memory access at the same time, even without a cache. A Harvard architecture computer can thus be faster for a given circuit complexity because instruction fetches and data access do not contend for a single memory pathway.

Revision as of 09:38, 22 December 2009

The Harvard architecture is a computer architecture with physically separate storage and signal pathways for instructions and data. The term originated from the Harvard Mark I relay-based computer, which stored instructions on punched tape (24 bits wide) and data in electro-mechanical counters . These early machines had limited data storage, entirely contained within the central processing unit, and provided no access to the instruction storage as data, making loading and modifying programs an entirely offline process.

Memory details

In a Harvard architecture, there is no need to make the two memories share characteristics. In particular, the word width, timing, implementation technology, and memory address structure can differ. In some systems, instructions can be stored in read-only memory while data memory generally requires read-write memory. In some systems, there is much more instruction memory than data memory so instruction addresses are wider than data addresses.

Contrast with von Neumann architectures

In a computer with the contrasting von Neumann architecture (and no CPU cache), the CPU can be either reading an instruction or reading/writing data from/to the memory. Both cannot occur at the same time since the instructions and data use the same bus system. In a computer using the Harvard architecture, the CPU can both read an instruction and perform a data memory access at the same time, even without a cache. A Harvard architecture computer can thus be faster for a given circuit complexity because instruction fetches and data access do not contend for a single memory pathway.

Modified Harvard architecture

A Modified Harvard architecture machine is very much like a Harvard architecture machine, but it relaxes the strict separation between instruction and code while still letting the CPU concurrently access two (or more) memory busses.

  • The most common modification includes separate instruction and data caches backed by a common address space. While the CPU executes from cache, it acts as a pure Harvard machine. When accessing backing memory, it acts like a von Neumann machine (where code can be moved around like data, a powerful technique). This modification is widespread in modern processors such as the ARM architecture and X86 processors. It is sometimes loosely called a Harvard architecture, overlooking the fact that it is actually "modified".
  • Another modification provides a pathway between the instruction memory (such as ROM or flash) and the CPU to allow words from the instruction memory to be treated as read-only data. This technique is used in some microcontrollers, including the Atmel AVR. This allows constant data, such as text strings or function tables, to be accessed without first having to be copied into data memory, preserving scarce (and power-hungry) data memory for read/write variables. Special machine language instructions are provided to read data from the instruction memory. (This is distinct from instructions which themselves embed constant data, although for individual constants the two mechanisms can substitute for each other.)

Speed

In recent years, the speed of the CPU has grown many times in comparison to the access speed of the main memory. Care needs to be taken to reduce the number of times main memory is accessed in order to maintain performance. If, for instance, every instruction run in the CPU requires an access to memory, the computer gains nothing for increased CPU speed — a problem referred to as being memory bound.

It is possible to make extremely fast memory but this is only practical for small amounts of memory for both cost and signal routing reasons. The solution is to provide a small amount of very fast memory known as a CPU cache which holds recently accessed data. As long as the memory that the CPU needs is in the cache, the performance hit is much smaller than it is when the cache has to turn around and get the data from the main memory. Cache tuning is an important aspect of computer design.

Internal vs. external design

Modern high performance CPU chip designs incorporate aspects of both Harvard and von Neumann architecture. In particular, the Modified Harvard architecture is very common. CPU cache memory is divided into an instruction cache and a data cache. Harvard architecture is used as the CPU accesses the cache. In the case of a cache miss, however, the data is retrieved from the main memory, which is not formally divided into separate instruction and data sections ... although it may well have separate memory controllers used for concurrent access to RAM, ROM, and (NOR) flash memory.

Thus, while a von Neumann architecture is visible in some contexts, such as when data and code come through the same memory controller, the hardware implementation gains the efficiencies of the Harvard architecture for cache accesses and at least some main memory accesses.

In addition, CPUs often have write buffers which let CPUs proceed after writes to non-cached regions. The von Neumann nature of memory is then visible when instructions are written as data by the CPU, and software must ensure that the caches (data and instruction) and write buffer are synchronized before trying to execute those just-written instructions.

Uses

Harvard architectures are also frequently used in:

  • Specialized digital signal processors (DSPs), commonly used in audio or video processing products.
  • Small microcontrollers used in electronics applications, such as ARM based products from many vendors, the PIC by Microchip Technology, Inc., and AVR by Atmel Corp. These processors are characterized by having small amounts of program (flash memory) and data (SRAM) memory, and take advantage of the Harvard architecture to speed processing by supporting concurrent instruction and data access. The separate storage means the program and data memories can have different bit depths. Example: some PICs have an 8-bit data word but (depending on specific range of PICs) a 12-, 14-, 16- or 32-bit program word.

See also

External links