What is Harvard Architecture?
Why separate memory for instructions and data?
The articles written on this blog were created with the goal of teaching. Also, the information in the article may be incorrect, so please be careful.
A computer must store program instructions and the data used by the program somewhere and read them. At this time, the structure of storing instructions and data separately in different memories is called Harvard Architecture.
Instructions and data are separate
In the Harvard architecture, instruction memory and data memory are physically separated. The bus, which is the passage leading to the CPU, is also used separately.
Instruction memory ── Instruction bus ──┐
CPU
Data memory ── Data bus ───┘
While the CPU fetches the next instruction, the data required for the current instruction can also be read at the same time. Bottlenecks can be reduced compared to a structure in which instructions and data alternately use one path.
Additionally, the specifications of the two memories may be designed differently. Instructions can be placed in read-only memory and data can be stored in read-and-write memory, or the bit widths of instructions and data can be different.
How is it different from the von Neumann structure?
Von Neumann Architecture places instructions and data in the same memory and bus.
harvard structure
Instruction memory ─┐
CPU
Data memory ─┘
von neumann structure
Instruction + data memory ── CPU
The von Neumann structure has only one memory space, so programming and hardware configuration are relatively simple. However, fetching instructions and reading data use the same path, so it is difficult to process them simultaneously.
Conversely, the Harvard structure is good for simultaneous access, but it is difficult to utilize space flexibly by using data instead of empty instruction memory. Since the memory and bus must be created separately, the hardware becomes more complex.
Where to use it?
The Harvard structure can be easily seen in microcontrollers or DSPs that need to respond quickly to input. It is well suited to environments where the program is defined and simultaneous processing of commands and data is important.
It is difficult to pinpoint one CPU in a modern PC. Main memory stores instructions and data together, but near the CPU, the Modified Harvard Architecture, which separates the instruction cache and data cache, is often used.
In other words, the core of the Harvard architecture is not simply that there are two memories. It can be understood as a structure that allows the CPU to perform two tasks simultaneously by using different storage spaces and paths for instructions and data.