[Principles of Computer Composition] Knowledge Point Consolidation - Memory Overview

Table of contents

1. Memory classification

1.1. Classification by storage media

1.2. Classification by access method

1.3. Classification according to the rewriteability of information

1.4. Classification according to the storability of information

1.5. Classification by function and access speed

2. Memory technical indicators

2.1. Storage capacity

2.2. Access speed 

3. Storage system hierarchy

4. Basic structure of main memory

5. Storage of data in main memory

5.1. The concept of storage word length and data word length

5.2. Address access mode

5.3. Big endian and little endian methods

5.4. Data boundary alignment


 

1. Memory classification

        Due to the continuous development of information carriers and electronic components, the functions and structures of memories have undergone great changes. Various types of memories have appeared, which can be classified from the following different perspectives.

1.1. Classification by storage media

  1. Magnetic memory: Magnetic memory uses magnetic materials as storage media and uses different magnetization directions of the residual magnetism of the magnetized unit to store data 0 and 1. It mainly includes magnetic cores, magnetic disks, tape memories, etc. The currently widely used disks and tapes contain mechanical devices, so they are large in size and have slow access speeds, but magnetic memory has the lowest unit capacity cost.
  2. Semiconductor memory: Memory composed of semiconductor devices is called semiconductor memory. There are currently two major categories: one is bipolar memory, which mainly includes TTL type and ECL type; the other is metal oxide semiconductor memory, referred to as MOS memory, which can be divided into static MOS memory (SRAM) and dynamic memory. MOS memory (DRAM). Semiconductor memory is small in size and fast in storage speed, but the cost per unit capacity is relatively high.
  3. Optical storage: Optical storage uses the optical properties of the medium to read data. For example, CD-ROM and DVD-ROM store data on the disk in the form of scratches. The laser beam irradiates the disk surface and reads information based on the different reflectivity of the disk surface. The magneto-optical disk uses laser heating to assist magnetization to write data, and the information is read out based on the polarization direction of the reflected light. Optical disc storage is portable, low-cost, and suitable for the distribution of electronic publications.

1.2. Classification by access method

  1. Random Access Memory: Random Access Memory (RAM) can randomly read and write data storage units according to addresses, and the access time has nothing to do with the location of the storage unit. Early magnetic core memories and currently widely used semiconductor memories are both random access memories.
  2. Sequential Memory: Sequential Access Memory (SAM) means that the contents of the storage unit can only be accessed in address order, and the access speed is related to the location of the storage unit. Storage, typically such as tape storage.
  3. Direct Memory: Direct Access Memory (DAM) refers to a memory that can directly access information in the memory without sequential search. This type of memory has both random and Access characteristics of memory and sequential memory, typically disk memory. Due to the mechanical seek and rotation delay of the disk, the data access time is related to the distance between the disk head and the target sector.

1.3. Classification according to the rewriteability of information

A memory that can both read and write information is calledread-write memory. The contents of some memories are not allowed to be changed.
can only read the contents. This kind of memory is called read-only memory< a i=5> (Read Only Memory, ROM), common ones include semiconductor read-only memory and optical disk memory, such as CD-ROM, DVD-ROM, etc.

1.4. Classification according to the storability of information

According to the different time and conditions of information storage, memory is divided into volatile memory and non-volatile memory. Volatile memory refers to memory that loses its stored information when the power is turned off, such as semiconductor RAM. Non-volatile memory refers to memory that does not lose the stored information after a power outage. Common examples include semiconductor ROM, flash memory, magnetic disks, optical disk memories, etc.

1.5. Classification by function and access speed

  1. Register memory: It is a memory composed of multiple registers, such as the general register group inside the CPU. It generally consists of several or dozens of registers, and its word length is generally The word length is the same as that of the computer. It is mainly used to store addresses, data and intermediate results of operations. The speed matches the CPU and the capacity is very small.
  2. Cache memory: It is also called cache cache. It is a high-speed, small-capacity memory hidden between the register and the main memory. It is used to store the data that the CPU will use soon or frequently. instructions and data. It is generally composed of static RAM, which is used to buffer the performance difference between the CPU and slow main memory and improve the access speed of the storage system.
  3. Main memory: The abbreviation of main memoryMain memory is the only direct memory in the CPU besides registers. Accessed memory for storing instructions and data. The CPU reads and writes main memory directly and randomly via main memory addresses. Main memory is generally composed of semiconductor memory, but note that main memory is not a single memory, but also includes BIOS, hardware ports, etc.
  4. External memory: The memory outside the computer host is called external memory, referred to asexternal memory or < /span>. The external memory capacity is large, but the access speed is relatively slow. Currently widely used external memories include disks, tapes, optical disk storage, disk arrays and network storage systems. External storage is used to store programs and data that are not currently running, as well as some data information that needs to be saved permanently. Auxiliary storage

2. Memory technical indicators

The characteristics of memory are described by its technical indicators. Common technical indicators include storage capacity, access speed (including access
time, storage cycle, storage bandwidth), etc.

2.1. Storage capacity

The total amount of binary information that a memory can store is called storage capacity. Storage capacity can be expressed in bits or bytes.

  1. Bit representation: Expressed by the product of the total number of storage units in the memory and the number of storage words. For example, 1K×4 bits means that the chip has 1K units (1K = 1024 ), the length of each storage unit is 4 binary bits.
  2. Byte representation: Expressed by the total number of units in the memory (a storage unit consists of 8 binary bits, called a byte, represented by B), such as 128B Indicates that the chip has 128 units.

2.2. Access speed 

  1. Access time: Also known as memory access time, it refers to the time from starting a memory operation (reading or writing corresponds to access and storage respectively) to the completion of the operation. , note that the read and write times may be different, DRAM reads slowly and writes quickly, and flash memory reads quickly and writes slowly.
  2. Access cycle: The shortest time interval between two consecutive access operations; for main memory, the storage cycle includes not only the access time, but also the memory status Stable recovery time, so the storage cycle is slightly larger than the access time.
  3. Memory bandwidth: The amount of information that the memory can transmit per unit time. Commonly used units include bits/second or bytes/second; bandwidth is an important indicator to measure the data transmission rate. , related to the length of access time and the number of data bits transmitted at one time; generally speaking, the shorter the access time, the larger the data bit width, and the higher the storage bandwidth.

3. Storage system hierarchy

        When a certain type of memory is surpassed by another type of memory in terms of storage speed, storage capacity, and price, that is when the memory is eliminated. For example, traditional floppy disks are replaced by U disks. People have been pursuing ideal memories with fast storage speed, large storage capacity and low cost. However, under the current technical conditions, these performance indicators are often contradictory, and it is not possible for a single memory to have these characteristics at the same time. This is why there are currently many different types of memory. The storage system hierarchy utilizes the principle of program locality to organically combine memories with different speeds, capacities, and costs from a system-level perspective to comprehensively optimize various performance indicators of the storage system.

        A typical storage system hierarchy is shown in Figure 4.1. This is a typical pyramid structure, from top to bottom are registers, cache, main memory, disk, tape, etc. The closer you go to the CPU, the faster the access speed, and the higher the unit capacity cost; from top to bottom, the storage capacity becomes larger and larger. The figure shows the approximate access time delay and capacity magnitude unit of different levels of storage devices. .

        Due to the locality of program access, the upper-layer memory can buffer the lower-layer memory and schedule copies of the most frequently used data to the upper layer, so that the CPU only needs to access the upper-layer fast, small-capacity memory to obtain most of the data. This method effectively improves the system access speed and greatly alleviates the performance differences between the CPU and main memory, and main memory and auxiliary memory. In addition, the use of large-capacity auxiliary memory also greatly alleviates the problem of insufficient main memory capacity. Based on this hierarchical structure, an ideal storage system with fast storage speed, large storage capacity, and low cost is formed to meet application requirements.​ 

4. Basic structure of main memory

        The main memory is a memory directly operated by machine instructions. The main memory address is used for random access. The entire main memory can be viewed as a one-dimensional array mem[] from the spatial logic. Each array element stores an m-bit data unit. The main memory The address addr is the subscript index of the array, and the value of the array element mem[addr] is the storage content corresponding to the main memory address. The pointer learned in C language is essentially the main memory address.

        The hardware internal structure of main memory is shown in Figure 4.2. It consists of a memory bank plus some peripheral circuits. Peripheral circuits include address decoders, data registers and read and write control circuits.

        The address decoder receives n-bit address signals from the CPU, and after decoding and driving, 2n address decoding signals are formed. Each address decoding signal is connected to a storage unit. Each time an address is given, only the signal corresponding to the address value among the 2n address decoding signals is valid, and the memory unit connected to it is selected and m-bit data is output.

        The data register temporarily stores m-bit data sent from the CPU, or temporarily stores m-bit data read from the memory bank.

        The read-write control circuit receives the read-write control signal from the CPU and generates a control signal inside the memory. It reads the information at the specified address from the memory bank and sends it to the data register for use by the CPU, or sends the information from the CPU and has been stored in the data register. The information is written to the specified location in the memory bank.

        When the CPU executes a certain machine instruction, if it needs to access the main memory, it should first generate the address of the data in the main memory. After the address is passed through the address decoder, the memory unit corresponding to the address in the memory bank is selected, and then the read and write control circuit controls the reading or writing. When reading, the data stored in the selected storage unit is sent to the data register, and the contents of the storage unit remain unchanged. The CPU takes the data from the data register and performs the processing required by the instruction. When writing, the data sent by the CPU and stored in the data register is written into the selected storage unit, and the original data in the storage unit is rewritten.

5. Storage of data in main memory

5.1. The concept of storage word length and data word length

  1. Storage word length: the number of binary digits stored in a storage unit of main memory.
  2. Data word length (word length for short): The number of binary digits that the computer can process at one time. The storage word length is not necessarily the same as the data word length. For example, the storage word length used by a computer with a word length of 32 bits can be 16 bits, 32 bits or 64 bits.

5.2. Address access mode

        The storage word length is an integral multiple of bytes, and main memory is usually addressed by bytes. Taking a 32-bit computer as an example, the main memory can be accessed in bytes, 16-bit halfwords, or 32-bit words. According to the size of the accessed storage unit, the main memory address can be divided into byte address and halfword address. Figure 4.3 shows a schematic diagram of different main memory address access modes. The main memory space in the figure can be accessed according to different addresses, and the size of the storage unit accessed by different addresses is different. word address,

        ​​​​The byte address is logically shifted one bit to the right to get the half-word address, and the byte address is logically shifted to the right by two bits to get the word address. In the figure, the half-word address corresponding to byte address No. 8 is 4, and the word address is 2. Note that the starting positions of these three addresses in the logical space are byte unit No. 8. The only difference is the size of the storage unit. The following program is an example of Intel x86 assembler accessing different storage units, assuming that the value of the data segment register DS is 0.

5.3. Big endian and little endian methods

  1. When using multi-byte access to main memory, the order of bytes in the main memory is very important, and the data obtained by accessing in different orders is completely different. When the lowest byte of data is stored in the low-byte address unit of the memory, this data storage method is called Little-Endian (Little-Endian ) method; conversely, when the highest byte of data is stored in the low-byte address unit of the memory, this data storage method is called Big Endian (Big-Endian) way.
  2. When accessing word storage unit No. 2 in Figure 4.3, if the data is accessed in little endian mode, the data obtained is 0x78563412, while if the data is accessed in big endian mode, the data obtained is 0x12345678. The main difference between using big and little endian methods to store data is It depends on the order in which bytes are stored. The use of big-endian method for data storage is in line with normal human thinking, while the use of little-endian method for data storage is conducive to computer processing.
  3. Mainstream processors generally use little endian mode for data storage, such as Intel x86, IA64 processors, and RISC-V processors. Some processor systems use big-endian mode for data storage, such as PowerPC processors; other processors support both big-endian and little-endian modes, such as ARM and MIPS processors. In addition to the processor, the choice of data storage method exists in the design of peripheral devices, TCIP/IP data transmission, audio and video files. When the data storage method in the computer is inconsistent with it, data byte order conversion needs to be performed.
  4. The difference between big-endian and little-endian methods is not only reflected in the registers and memories of the processor, but also in various levels such as the instruction set and system bus. Readers must have a thorough understanding of the above differences between big-endian and little-endian methods.

5.4. Data boundary alignment

        The main memory space in modern computers is addressed in bytes, and variables of different data types in high-level languages ​​correspond to different byte lengths. The byte lengths of variables of different data types in C language are shown in Table 4.1.

        As can be seen from the table, variables of different data types will contain one or more byte units. When allocating the main memory address space, these variables can theoretically start from any byte address, but when a multi-byte variable is distributed When in different word storage locations, accessing the variable requires multiple storage cycles. In order to improve data access efficiency, it is usually necessary to consider the boundary alignment of data variables and data structures in the main memory space.

The so-called boundary alignment means boundary alignment according to the size of the data type. The specific rules are as follows.

  1. The last 3 bits of the starting byte address of double word data are 000, and the address is an integer multiple of 8.
  2. The lowest two bits of the starting byte address of single-word data are 00, and the address is an integer multiple of 4.
  3. The lowest bit of the starting byte address of half-word data is 0, and the address is an integer multiple of 2.
  4. Single-byte data does not have boundary alignment issues (main memory is byte-addressed).

Figure 4.4 shows the unaligned space allocation mode of variables in 32-bit main memory. This method has the highest utilization rate of storage space. However, the 8 bytes of the double-precision floating point number x are distributed in 3 storage words. Accessing the The variable requires 3 storage cycles; in addition, the data of the last short variable k also spans two storage words, which will cause access performance problems.

        The pattern shown in Figure 4.5 follows the boundary alignment rules. The variables x and k only occupy the minimum machine words. It only takes two storage cycles to access x, and only one storage cycle to access k, which effectively improves the storage speed. However, please note that this method will cause a waste of space and requires compromise. Currently, mainstream compilers not only perform boundary alignment on data variables, but also perform boundary alignment on complex data structures.

 

Blogger recommendation:

 [JavaSE] Basic Notes - Library Management System (Nanny Tutorial, including source code) - CSDN Blogicon-default.png?t=N7T8https://blog.csdn.net/zzzzzhxxx/article/details/134467911 ?spm=1001.2014.3001.5502

[JavaSE] Basic Notes - Classes and Objects (Part 2) - CSDN Blogicon-default.png?t=N7T8https://blog.csdn.net/zzzzzhxxx/article/details/134248822?spm=1001.2014 .3001.5502

[JavaSE] Basic Notes - Classes and Objects (Part 1) - CSDN Blogicon-default.png?t=N7T8https://blog.csdn.net/zzzzzhxxx/article/details/134232584?spm=1001.2014 .3001.5502 

If you think the author's writing is good, please give the blogger a big like and support. Your support is my biggest motivation for updating!

If you think the author's writing is good, please give the blogger a big like and support. Your support is my biggest motivation for updating!

If you think the author's writing is good, please give the blogger a big like and support. Your support is my biggest motivation for updating!

 

Guess you like

Origin blog.csdn.net/zzzzzhxxx/article/details/134482974