Taixin Semiconductor

News detail

Knowledge Sharing | How Exactly Is an MCU Structured?

2021-03-26

Nowadays, many appliances in our lives use MCUs. For example: mobile phones, TVs, refrigerators, washing machines, and children's toys whose LEDs blink when a switch is pressed. So,MCUwhat exactly does it do in these appliances?
MCUis the key to the operation of these appliances and commands the hardware to run. For example, it receives input signals from buttons or keys and, according to preprogrammed instructions, commands peripheral functional circuits such as motors and LCDs to operate.
So,MCUhow is it structured?
As shown in Figure 1.
MCUis composed of parts such as the CPU, memory, and peripheral functions. IfMCUis compared to a person, then the CPU is responsible for thinking, memory is responsible for remembering, and peripheral functions correspond to the sensory system for vision and the nervous system that controls the movements of the hands and feet.


Figure 1:MCUComponents

Although we say the CPU is equivalent to the human brain, it cannot think consciously and spontaneously like the human brain. The CPU can only sequentially read and execute combinations of instructions (programs) pre-stored in memory. Of course, the instructions executed by the CPU are not high-level commands such as “walking” or “speaking”; they are very simple instructions, such as “reading data” from somewhere in memory, “writing data” to somewhere in memory, or performing addition, multiplication, and logical operations. However, combinations of these simple instructions can implement many complex functions.

The Thinking CPU
Let us understand its role by looking at the structure of the CPU, as shown in Figure 2.


Figure 2: The Role of the CPU

◇ Program Counter
When the CPU reads an instruction, it needs to know where in memory the instruction to be executed is stored. This location information is called an address (equivalent to a home address). The program counter (PC) is the register that stores addresses. Normally, the PC is designed to increment by 1; that is, after the CPU executes the instruction at address 0000, the PC automatically increments by 1 to become address 0001. Each time an instruction is executed, the PC automatically increments by 1 and points to the address of the next instruction. It can be said that the PC determines the order in which the program is executed.

◇ Instruction Decoder Circuit
The instruction decoder circuit interprets the meaning of instructions read from memory. The arithmetic circuit operates according to the decoding result. Strictly speaking, the instruction decoder circuit is the decoder circuit we learned in “Introduction to Digital Circuits (2),” except that its circuit structure is slightly more complex. Therefore, the working principle of the instruction decoder circuit is to restore the instruction from the symbolized (encrypted) instruction.

◇ Arithmetic Circuit
The arithmetic circuit, also called the ALU (Arithmetic and Logic Unit), is the circuit that performs operations. It can perform arithmetic operations such as addition and multiplication, as well as logical operations such as AND, OR, and BIT-SHIFT. Operations are performed under the control of the instruction decoder circuit. Normally, the configuration of the arithmetic circuit is relatively complex.

◇CPU Internal Registers
CPU internal registers are locations for storing temporary information. There are general-purpose registers that store operands and operation results, as well as some special registers, such as the flag register that stores operation flags. In other words, when the arithmetic circuit performs an operation, it does not operate directly in memory; instead, it copies data from memory to general-purpose registers and performs the operation in those general-purpose registers.

How the CPU Works
Let us use a concrete calculation, 3+4, to explain the CPU's operation process.
Suppose the program and data stored in memory are as follows.

◇ Step 1: When the program is executed, the CPU reads the instruction at address 0000 currently pointed to by the PC (this operation is called instruction fetch). After the decode circuit interprets it, the instruction means 'read the contents of address 0100 and then save them to register 1.' The CPU then executes the instruction, reads the data from address 0100, and stores it in register 1.
Register 1: 0→3 (changes from 0 to 3) 
Because one instruction has been executed, the PC value becomes 0001 

◇ Step 2: Since the PC value is 0001, the CPU reads the instruction at address 0001. After the decode circuit decodes it, the CPU executes the instruction. The PC is then incremented by 1.
Register 2: 0→4 (changes from 0 to 4) 
PC: 0001→0000 

◇ Step 3: Since the PC value is 0002, the CPU reads the instruction from address 0002 and sends it to the instruction decode circuit. The decoding result is: add register 1 and register 2, then store the result in register 1.
Register 1: 3→7
PC: 2→3
Thus, the result of 3+4, namely 7, is stored in register 1, and the addition operation is complete. This is how the CPU processes each simple instruction in sequence.

Memory That Stores Information
Memory is the storage device of the microcontroller. It mainly stores programs and data and is broadly divided into two major categories: ROM and RAM.

◇ ROM
ROM (Read Only Memory) is short for read-only memory. Data stored in ROM cannot be deleted and will not be lost when power is turned off. ROM is mainly used to store user programs and constants that remain unchanged during program execution.
Most Renesas microcontrollers use flash memory as ROM. This is because flash memory not only retains data even when power is turned off, like ROM, but also allows data to be modified.

◇ RAM
RAM (Random Access Memory) is short for random-access read/write memory. Data can be read from and written to it at any time, but when power is turned off, the data stored in RAM is also lost. It is mainly used to store variables in programs.
In single-chip microcontrollers (*1), SRAM is often used as internal RAM. SRAM allows high-speed access; however, its internal structure is too complex to achieve high-density integration, making it unsuitable for large-capacity memory.
In addition to SRAM, DRAM is also a common type of RAM. DRAM's structure makes high-density integration relatively easy, so it has larger capacity than SRAM. However, it is relatively difficult to mount high-speed logic circuits and DRAM on the same die; therefore, DRAM is generally rarely used in single-chip microcontrollers and is mostly used as peripheral circuitry.
(*1) A single-chip microcontroller refers to a microprocessor that integrates a CPU, ROM, RAM, oscillator circuit, timer, serial I/F, etc. into a single LSI. A large-scale integrated circuit formed by adding some of the system's main peripheral circuits to a single-chip microcontroller is called a system LSI.

Disclaimer:This article is reproduced from the Internet.The purpose of reposting this article is to convey more information, and the copyright belongs to the original author.

Zhuhai Taixin Semiconductor Co., Ltd.

Zhuhai Taixin Semiconductor Co., Ltd. was founded in 2016 and is a high-tech enterprise integrating IC design and wireless intelligent communication solutions. We have successively launched long-range, low-power IoT Wi-Fi chips, low-power motor controller chips, and product solutions. The company adheres to a market-oriented and technology-centered approach, providing customers with high-quality chips and product technical solutions.

The company's core product: long-range, low-power IoT Wi-Fi communication chips. These chips can be used in product fields such as smart homes, security surveillance, UAV image transmission, smart meter reading, smart door locks, smart grids, smart hospitals, and logistics robots.