Flash memory chip access methods, apparatus, devices and media
By reading access requests and determining the target operating mode and address in a RISC-V architecture chip, and then performing state machine transitions, the problem of inflexible access to flash memory chips in existing technologies is solved, achieving more efficient access mode switching and data processing.
Patent Information
- Application Number
- CN202310952789.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-31
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2043-07-31
AI Technical Summary
The existing RISC-V architecture chip's flash controller is in a black box state, unable to flexibly switch access modes according to access requests, resulting in insufficient flexibility in accessing flash memory chips.
By reading the current access requests in the preset first-in-first-out queue, the target operation mode and operation address are determined, and a state machine transition is performed in the target operation mode to generate processed data and return it to the host.
This improves the access flexibility of flash memory chips, enabling the host to select the target operating mode based on the current access request and return the processed data, thus enhancing access flexibility.
Smart Images

Figure CN116974480B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to flash memory chip access methods, apparatus, devices, and media. Background Technology
[0002] The field of chip design is gaining increasing attention. Application-Specific Integrated Circuits (ASICs) offer advantages such as high density, high speed, and low cost. RISC (Reduced Instruction Set Computer) is characterized by its open-source instruction set, while ARM (Arm Chip) is not. RISC-V architecture chips also require external memory chips for storing information and booting. Serial Peripheral Interface (SPI) NOR Flash (non-volatile flash memory) chips are commonly used for storing the chip's boot program because data is retained even when power is off, and the program can be directly booted from the Flash. SPI NOR Flash can be connected to the system bus as a regular peripheral or to the AHB (Advanced High Performance Bus) instruction bus as an instruction bus peripheral for chip program booting. Currently, Flash controllers for RISC-V architecture chips are essentially black boxes, only able to access the flash chip according to the initially provided access method and unable to flexibly switch based on access requests.
[0003] In summary, improving the access flexibility of flash memory chips is a problem that needs to be solved in this field. Summary of the Invention
[0004] In view of this, the purpose of this invention is to provide a flash memory chip access method, apparatus, device, and medium that can improve the access flexibility of flash memory chips. The specific solution is as follows:
[0005] In a first aspect, this application discloses a method for accessing a flash memory chip, including:
[0006] Read the current access request stored in the first preset first-in-first-out queue, and determine the target operation mode corresponding to the current access request and the target operation address of the current access request;
[0007] In the target operation mode, a state machine transition is performed based on the target operation address to complete the processing of the current access request and generate processed data corresponding to the current access request;
[0008] The processed data is sent to a second preset first-in-first-out queue so that the second preset first-in-first-out queue returns the processed data to the host.
[0009] Optionally, before reading the current access request stored in the first preset first-in-first-out queue, the method further includes:
[0010] The host sends the current access request to the first preset first-in-first-out queue so that the first preset first-in-first-out queue saves the current access request locally.
[0011] Optionally, sending the current access request to the first preset first-in-first-out queue via the host includes:
[0012] The host receives the current access request sent by the host computer and determines whether the interrupt priority of the current access request meets the preset priority condition. If it does, the current access request is sent to the first preset first-in-first-out queue.
[0013] Optionally, reading the current access request stored in the first preset first-in-first-out queue includes:
[0014] Obtain the current status signal of the slave device and determine whether the current status signal is at a high level;
[0015] If so, the slave device is determined to be in an idle state, the current access request stored in the first preset first-in-first-out queue is read, and the current state signal is set to a low potential; wherein, the current access request is any one or more of the following: read memory request, write memory request, whole erase request, sector erase request, read register request, and write register request;
[0016] If not, the slave device is determined to be in a busy state. The next state signal of the slave device is obtained and used as the current state signal. Then, the process jumps back to the step of determining whether the current state signal is at a high level.
[0017] Optionally, the step of performing a state machine transition based on the target operation address in the target operation mode to complete the processing of the current access request includes:
[0018] In the target operation mode, the current sub-access operation corresponding to the target operation address is determined, and the current state machine is determined based on the current sub-access operation;
[0019] Determine the corresponding operation thread in the current state machine to complete the current sub-access operation corresponding to the current state machine;
[0020] Determine whether there is a next sub-access operation corresponding to the target operation address. If there is, update the next sub-access operation to the current sub-access operation and jump back to the step of determining the current state machine based on the current sub-access operation, until there is no next sub-access operation corresponding to the target operation address.
[0021] Optionally, determining the corresponding operation thread in the current state machine to complete the current sub-access operation corresponding to the current state machine includes:
[0022] Obtain the current command prompt category value corresponding to the current access request, and determine the current operation thread in the current state machine that corresponds to the current command prompt category value;
[0023] Execute the current operation thread and set the operation state of the current operation thread to a preset completion state;
[0024] Obtain the next command prompt category value corresponding to the current access request, use the next command prompt category value as the current command prompt category value, and jump back to the step of determining the current operation thread corresponding to the current command prompt category value in the current state machine.
[0025] Optionally, the step of reading the current access request stored in the first preset first-in-first-out queue and determining the target operation mode corresponding to the current access request and the target operation address of the current access request includes:
[0026] Read the current access request and its original operation address stored in the first preset first-in-first-out queue;
[0027] The target operation mode corresponding to the current access request is determined from multiple preset operation modes, and the original operation address is truncated based on preset address bits to obtain the target operation address; wherein, the multiple preset operation modes include single-line operation mode and four-line operation mode;
[0028] Accordingly, the state machine transition based on the target operation address in the target operation mode includes:
[0029] In the target operation mode, the target operation address is compared with the preset addresses of each state machine to perform state machine transitions.
[0030] Secondly, this application discloses a flash memory chip access device, comprising:
[0031] The address determination module is used to read the current access request stored in the first preset first-in-first-out queue, and determine the target operation mode corresponding to the current access request and the target operation address of the current access request.
[0032] The data generation module is used to perform state machine transitions based on the target operation address in the target operation mode to complete the processing of the current access request and generate processed data corresponding to the current access request.
[0033] The data return module is used to send the processed data to a second preset first-in-first-out queue, so that the second preset first-in-first-out queue will return the processed data to the host.
[0034] Thirdly, this application discloses an electronic device, including:
[0035] Memory, used to store computer programs;
[0036] A processor is configured to execute the computer program to implement the steps of the aforementioned disclosed flash memory chip access method.
[0037] Fourthly, this application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the steps of the aforementioned disclosed flash memory chip access method.
[0038] The beneficial effects of this application are as follows: It reads the current access request stored in a first preset first-in-first-out (FIFO) queue, determines the target operation mode corresponding to the current access request, and determines the target operation address of the current access request; under the target operation mode, it performs a state machine transition based on the target operation address to complete the processing of the current access request and generates processed data corresponding to the current access request; it sends the processed data to a second preset FIFO queue so that the second preset FIFO queue returns the processed data to the host. Therefore, this application can determine the corresponding target operation mode based on the current access request, instead of being unable to select the target operation mode corresponding to the current access request in a black-box state. Under the target operation mode, it performs a state machine transition based on the target operation address to complete the processing of the current access request. In this way, the host can obtain the processed data corresponding to the current access request, improving the access flexibility of the flash memory chip. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0040] Figure 1 This is a flowchart of a flash memory chip access method disclosed in this application;
[0041] Figure 2 This is a schematic diagram of a specific access request processing flow disclosed in this application;
[0042] Figure 3 This is a schematic diagram of a specific operation thread disclosed in this application;
[0043] Figure 4 This is a flowchart of a specific flash memory chip access method disclosed in this application;
[0044] Figure 5 This is a schematic diagram illustrating a specific access request and address correspondence disclosed in this application;
[0045] Figure 6 This is a flowchart of another specific flash memory chip access method disclosed in this application;
[0046] Figure 7 This is a schematic diagram of a specific access hierarchy disclosed in this application;
[0047] Figure 8 This is a schematic diagram of the structure of a flash memory chip access device disclosed in this application;
[0048] Figure 9 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0049] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0050] The field of chip design is gaining increasing attention. Application-specific integrated circuits (ASICs) offer advantages such as high density, high speed, and low cost. RISC architecture is characterized by its open-source instruction set, while ARM is not. RISC-V architecture chips also require external memory chips for storing information and booting. NOR Flash chips with serial peripheral interfaces (SPIs) retain data even when power is off, allowing programs to boot directly from the Flash memory. Therefore, they are typically used for storing the chip's boot program. NOR Flash chips with SPIs can be connected to the system bus as ordinary peripherals or to the AHB instruction bus as instruction bus peripherals for booting the chip's program. Currently, Flash controllers for RISC-V architecture chips are essentially black boxes, only able to access the flash memory chip according to the initially provided access method and unable to flexibly switch based on access requests.
[0051] Therefore, this application provides a flash memory chip access scheme that can improve the access flexibility of flash memory chips.
[0052] See Figure 1 As shown in the figure, this application discloses a flash memory chip access method, including:
[0053] Step S11: Read the current access request stored in the first preset first-in-first-out queue, and determine the target operation mode corresponding to the current access request and the target operation address of the current access request.
[0054] In this embodiment, before reading the current access request stored in the first preset first-in-first-out queue, the method further includes: sending the current access request to the first preset first-in-first-out queue via the host, so that the first preset first-in-first-out queue saves the current access request locally. When the host sends the current access request to the first preset first-in-first-out queue (First Input First Output, i.e., FIFO), if the Flash controller is currently idle, the target operation address of the current access request and the target operation mode corresponding to the current access request can be read from the first preset first-in-first-out queue.
[0055] In this embodiment, sending the current access request to the first preset first-in-first-out queue via the host includes: receiving the current access request sent by the host computer via the host computer, and determining whether the interrupt priority of the current access request meets the preset priority condition. If it does, the current access request is sent to the first preset first-in-first-out queue.
[0056] For example Figure 2The diagram illustrates a specific access request processing flow. The specific process for determining the target operation mode corresponding to the current access request and the target operation address of the current access request is as follows:
[0057] A101: The host computer initiates the current access request and sends the current access request to the host, i.e., the E906 processor core;
[0058] A102: After receiving the current access request, the host needs to determine whether the interrupt priority of the current access request meets the preset priority condition. If it does, the host sends the current access request to the first preset first-in-first-out queue via the AHB bus. It can be understood that the first preset first-in-first-out queue is an asynchronous first-in-first-out queue.
[0059] A103: If the Flash controller (i.e., the slave device) is currently in an idle state, it can read the target operation address of the current access request from the first preset first-in-first-out queue and determine the target operation mode corresponding to the current access request.
[0060] Step S12: In the target operation mode, perform a state machine transition based on the target operation address to complete the processing of the current access request and generate processed data corresponding to the current access request.
[0061] In this embodiment, the step of performing state machine transitions based on the target operation address in the target operation mode to complete the processing of the current access request includes: in the target operation mode, determining the current sub-access operation corresponding to the target operation address, and determining the current state machine based on the current sub-access operation; determining the corresponding operation thread in the current state machine to complete the current sub-access operation corresponding to the current state machine; determining whether there is a next sub-access operation corresponding to the target operation address, and if so, updating the next sub-access operation to the current sub-access operation, and re-jumping to the step of determining the current state machine based on the current sub-access operation, until there is no next sub-access operation corresponding to the target operation address. It can be understood that an access request may correspond to multiple sub-access operations, which need to be completed sequentially. Completing the current sub-access operation means completing the operation thread corresponding to the current state machine in order to perform the next sub-access operation, i.e., jumping to the next state machine, until there is no next sub-access operation. In other words, when the current sub-access operation is the last sub-access operation, completing the current sub-access operation completes the current access request. For example, if the current access request is a write memory request, the state machines corresponding to completing the write memory request are state machine d0, state machine d1, state machine d2, state machine d3, state machine d4, and state machine d5. That is, it is necessary to jump sequentially from state machine d0 to state machine d5. The specific process is as follows:
[0062] State machine d0: In the idle state, the data in the relevant registers is cleared, i.e., initialization is performed;
[0063] State machine d1: Enables write operation. Once write operation is enabled, Done_sig (feedback signal) is set to 1, and the system enters state machine d2.
[0064] State machine d2: This is a fast memory write operation in quad mode. After the memory write operation is completed, Done_sig is set to 1, and the process enters state machine d3.
[0065] State machine d3: Reads the status register. By querying the value of the status register, it determines whether the memory write is complete. If the operation is complete, it enters state machine d4.
[0066] State machine d4: disable write enable, set Done_sig to 1, and enter state machine d5;
[0067] State machine d5: This is the state register that clears errors, making it easier to perform the next operation.
[0068] In this embodiment, determining the corresponding operation thread in the current state machine to complete the current sub-access operation corresponding to the current state machine includes: obtaining the current command prompt category value corresponding to the current access request, and determining the current operation thread in the current state machine corresponding to the current command prompt category value; executing the current operation thread and setting the operation state of the current operation thread to a preset completion state; obtaining the next command prompt category value corresponding to the current access request, using the next command prompt category value as the current command prompt category value, and jumping back to the step of determining the current operation thread in the current state machine corresponding to the current command prompt category value. Completing the current state machine means completing all operation threads corresponding to the current state machine. It can be understood that different current access requests correspond to different current command prompt category (cmd_type) values, and therefore their corresponding current operation threads are also different. For example... Figure 3 The diagram illustrates a specific operation thread. In four-wire operation mode, the operation thread is started, and when the status is idle, the register is cleared, and the following operation thread is initiated:
[0069] B111: If cmd_type[3] is 0, wait in this state; if cmd_type[3] is 1, jump to the state cmd_send (command prompt sent); in the cmd_send state, send an 8-bit instruction to the Flash controller;
[0070] B112: Determine if cmd_type[2:0] is 001 or 100;
[0071] B121: If so, it means that the write enable or write enable operation is enabled or disabled. After the operation is completed, the thread enters the finish_done state (the default completion state) and ends.
[0072] B122: If not, then it is necessary to check whether cmd_type[2:0] is 011;
[0073] B131: If so, it means reading the status register, entering the read_wait (waiting to read) state, and after reading the data back from Flash, entering the finish done state.
[0074] B132: If not, then it is necessary to check whether cmd_type[2:0] is 000;
[0075] B141: If so, it means reading the Flash register, and the operation is complete and the device enters the finish_done state;
[0076] B142: If not, then it is necessary to check whether cmd_type[2:0] is 111;
[0077] B151: If so, it means writing to the Flash register, and the operation is complete and the device enters the finish_done state;
[0078] B152: If not, then it is necessary to enter the address_send state, send the 24-bit memory address to Flash, and check whether cmd_type[2:0] is 010;
[0079] B161: If so, perform a sector erase operation, and enter the finish_done state after the operation is completed;
[0080] B162: If not, then it is necessary to check whether cmd_type[2:0] is 101;
[0081] B171: If so, a memory write (page program) operation is performed, and the process enters the finish_done state after the operation is completed;
[0082] B172: If not, perform a memory read operation, and enter the finish_done state after the operation is completed.
[0083] It is important to note that the finish_done state indicates that the current Physical (port physical layer) logic has been completed and can transition to the next state machine. The finish_done state transitions to the idle state, waiting for the next operation.
[0084] Step S13: Send the processed data to the second preset first-in-first-out queue so that the second preset first-in-first-out queue returns the processed data to the host.
[0085] For example Figure 2 As shown, when the processed data is generated, it needs to be sent to the second preset first-in-first-out queue. Then, the second preset first-in-first-out queue returns the processed data to the host via the AHB bus, so that the host can return the processed data to the host computer. The second preset first-in-first-out queue is also an asynchronous first-in-first-out queue.
[0086] The beneficial effects of this application are as follows: It reads the current access request stored in a first preset first-in-first-out (FIFO) queue, determines the target operation mode corresponding to the current access request, and determines the target operation address of the current access request; under the target operation mode, it performs a state machine transition based on the target operation address to complete the processing of the current access request and generates processed data corresponding to the current access request; it sends the processed data to a second preset FIFO queue so that the second preset FIFO queue returns the processed data to the host. Therefore, this application can determine the corresponding target operation mode based on the current access request, instead of being unable to select the target operation mode corresponding to the current access request in a black-box state. Under the target operation mode, it performs a state machine transition based on the target operation address to complete the processing of the current access request. In this way, the host can obtain the processed data corresponding to the current access request, improving the access flexibility of the flash memory chip.
[0087] See Figure 4 As shown in the figure, this application discloses a specific method for accessing a flash memory chip, including:
[0088] Step S21: Obtain the current status signal of the slave device and determine whether the current status signal is at a high potential.
[0089] Step S22: If yes, then determine that the slave device is in an idle state, read the current access request stored in the first preset first-in-first-out queue, and set the current state signal to a low potential; wherein, the current access request is any one or more of the following: read memory request, write memory request, whole-slice erase request, sector erase request, read register request, and write register request.
[0090] It is understood that the access requests that can be implemented in this embodiment can be any one or more of the following: read memory request, write memory request, bulk erase request, sector erase request, read register request, and write register request.
[0091] Step S23: If not, determine that the slave device is in a busy state, obtain the next state signal of the slave device, use the next state signal as the current state signal, and then jump back to the step of determining whether the current state signal is a high potential.
[0092] Step S24: Determine the target operation mode corresponding to the current access request and the target operation address of the current access request.
[0093] In this embodiment, for example Figure 5 The diagram illustrates a specific mapping between access requests and addresses. If the target operation address is 100, it indicates a register read request; if the target operation address is 101, it indicates a register write request; if the target operation address is 110, it indicates a sector erase request; if the target operation address is 010, it indicates a memory read request; if the target operation address is 001, it indicates a memory write request; if the target operation address is 011, it indicates a sector erase request; if the target operation address is 111 or 000, it enters an idle state.
[0094] Step S25: In the target operation mode, perform a state machine transition based on the target operation address to complete the processing of the current access request and generate processed data corresponding to the current access request.
[0095] Step S26: Send the processed data to the second preset first-in-first-out queue so that the second preset first-in-first-out queue returns the processed data to the host.
[0096] Therefore, the access request in this application can be any one or more of the following: read memory request, write memory request, whole-chip erase request, sector erase request, read register request, and write register request. In other words, the access request can be changed according to the specific scenario, which greatly reduces the inability to flexibly change the access request according to the scenario due to the black box state of the flash memory chip in the prior art, and greatly improves the access flexibility of the flash memory chip.
[0097] See Figure 6 As shown in the figure, this application discloses a specific method for accessing a flash memory chip, including:
[0098] Step S31: Read the current access request and its original operation address stored in the first preset first-in-first-out queue; determine the target operation mode corresponding to the current access request from multiple preset operation modes, and truncate the original operation address based on the preset address bits to obtain the target operation address; wherein, the multiple preset operation modes include single-line operation mode and four-line operation mode.
[0099] In this embodiment, multiple preset operation modes include single-line operation mode and quad-line operation mode, which can be selected according to the current access request. The original operation address is 32 bits. Since the flash memory chip is 24 bits, the lower 25 bits of the address need to be extracted from the 32-bit address as the target operation address. The extra bit is used to store additional information.
[0100] For example Figure 7 The diagram illustrates a specific access hierarchy. The host computer sends a current access request. After receiving the current access request, the host computer sends the current access request to the first preset first-in-first-out queue via the AHB instruction bus. The Flash controller obtains the current access request and its original operation address from the first preset first-in-first-out queue and determines the corresponding target operation mode and target operation address.
[0101] Step S32: In the target operation mode, the target operation address is compared with the preset address of each state machine to perform a state machine transition, so as to complete the processing of the current access request and generate the processed data corresponding to the current access request.
[0102] For example Figure 7 As shown, in the target operation mode, the target operation address is compared with the preset addresses of each state machine, and a state machine transition is performed. It should be noted that when transitioning from the current state machine to the next state machine, the operation thread of the current state machine needs to be completed, that is, the Flash PHY logic transmission and reception processing is completed according to the command prompt category to realize the interaction with the external Flash chip. For example, if the current access request is a write request and a read request, the data is written to the corresponding position and the read data, i.e., the processed data, is returned.
[0103] Step S33: Send the processed data to the second preset first-in-first-out queue so that the second preset first-in-first-out queue returns the processed data to the host.
[0104] The processed data is returned to the second preset first-in-first-out queue step by step. The second preset first-in-first-out queue then feeds the processed data back to the host computer, so that the host computer can return the processed data to the host computer.
[0105] Therefore, this application can select the target operation mode corresponding to the current access request from multiple preset operation modes according to the current access request. This allows for flexible selection of single-line operation mode and four-line operation mode, increasing its flexibility and making it convenient for users to use in different scenarios.
[0106] See Figure 8 As shown in the figure, this application discloses a flash memory chip access device, including:
[0107] Address determination module 11 is used to read the current access request stored in the first preset first-in-first-out queue, and determine the target operation mode corresponding to the current access request and the target operation address of the current access request.
[0108] The data generation module 12 is used to perform state machine transitions based on the target operation address in the target operation mode to complete the processing of the current access request and generate processed data corresponding to the current access request.
[0109] The data return module 13 is used to send the processed data to the second preset first-in-first-out queue so that the second preset first-in-first-out queue returns the processed data to the host.
[0110] The beneficial effects of this application are as follows: It reads the current access request stored in a first preset first-in-first-out (FIFO) queue, determines the target operation mode corresponding to the current access request, and determines the target operation address of the current access request; under the target operation mode, it performs a state machine transition based on the target operation address to complete the processing of the current access request and generates processed data corresponding to the current access request; it sends the processed data to a second preset FIFO queue so that the second preset FIFO queue returns the processed data to the host. Therefore, this application can determine the corresponding target operation mode based on the current access request, instead of being unable to select the target operation mode corresponding to the current access request in a black-box state. Under the target operation mode, it performs a state machine transition based on the target operation address to complete the processing of the current access request. In this way, the host can obtain the processed data corresponding to the current access request, improving the access flexibility of the flash memory chip.
[0111] Furthermore, embodiments of this application also provide an electronic device. Figure 9 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0112] Figure 9This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Specifically, it may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the following steps:
[0113] Read the current access request stored in the first preset first-in-first-out queue, and determine the target operation mode corresponding to the current access request and the target operation address of the current access request;
[0114] In the target operation mode, a state machine transition is performed based on the target operation address to complete the processing of the current access request and generate processed data corresponding to the current access request;
[0115] The processed data is sent to a second preset first-in-first-out queue so that the second preset first-in-first-out queue returns the processed data to the host.
[0116] In some specific embodiments, the processor executes a computer program stored in the memory, specifically implementing the following steps:
[0117] The host sends the current access request to the first preset first-in-first-out queue so that the first preset first-in-first-out queue saves the current access request locally.
[0118] In some specific embodiments, the processor executes a computer program stored in the memory, specifically implementing the following steps:
[0119] The host receives the current access request sent by the host computer and determines whether the interrupt priority of the current access request meets the preset priority condition. If it does, the current access request is sent to the first preset first-in-first-out queue.
[0120] In some specific embodiments, the processor executes a computer program stored in the memory, specifically implementing the following steps:
[0121] Obtain the current status signal of the slave device and determine whether the current status signal is at a high level;
[0122] If so, the slave device is determined to be in an idle state, the current access request stored in the first preset first-in-first-out queue is read, and the current state signal is set to a low potential; wherein, the current access request is any one or more of the following: read memory request, write memory request, whole erase request, sector erase request, read register request, and write register request;
[0123] If not, the slave device is determined to be in a busy state. The next state signal of the slave device is obtained and used as the current state signal. Then, the process jumps back to the step of determining whether the current state signal is at a high level.
[0124] In some specific embodiments, the processor executes a computer program stored in the memory, specifically implementing the following steps:
[0125] In the target operation mode, the current sub-access operation corresponding to the target operation address is determined, and the current state machine is determined based on the current sub-access operation;
[0126] Determine the corresponding operation thread in the current state machine to complete the current sub-access operation corresponding to the current state machine;
[0127] Determine whether there is a next sub-access operation corresponding to the target operation address. If there is, update the next sub-access operation to the current sub-access operation and jump back to the step of determining the current state machine based on the current sub-access operation, until there is no next sub-access operation corresponding to the target operation address.
[0128] In some specific embodiments, the processor executes a computer program stored in the memory, specifically implementing the following steps:
[0129] Obtain the current command prompt category value corresponding to the current access request, and determine the current operation thread in the current state machine that corresponds to the current command prompt category value;
[0130] Execute the current operation thread and set the operation state of the current operation thread to a preset completion state;
[0131] Obtain the next command prompt category value corresponding to the current access request, use the next command prompt category value as the current command prompt category value, and jump back to the step of determining the current operation thread corresponding to the current command prompt category value in the current state machine.
[0132] In some specific embodiments, the processor, by executing a computer program stored in the memory, may further include the following steps:
[0133] Read the current access request and its original operation address stored in the first preset first-in-first-out queue;
[0134] The target operation mode corresponding to the current access request is determined from multiple preset operation modes, and the original operation address is truncated based on preset address bits to obtain the target operation address; wherein, the multiple preset operation modes include single-line operation mode and four-line operation mode;
[0135] Accordingly, the state machine transition based on the target operation address in the target operation mode includes:
[0136] In the target operation mode, the target operation address is compared with the preset addresses of each state machine to perform state machine transitions.
[0137] In this embodiment, the power supply 23 is used to provide operating voltage for various hardware devices on the electronic device; the communication interface 24 can create a data transmission channel between the electronic device and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0138] The processor 21 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 21 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0139] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored on it include operating system 221, computer program 222 and data 223, etc., and the storage method can be temporary storage or permanent storage.
[0140] The operating system 221 manages and controls the various hardware devices and computer programs 222 on the electronic device to enable the processor 21 to perform calculations and processing on the massive amounts of data 223 in the memory 22. The operating system can be Windows, Unix, Linux, etc. The computer program 222, in addition to including a computer program capable of performing the flash memory chip access method executed by the electronic device as disclosed in any of the foregoing embodiments, may further include computer programs capable of performing other specific tasks. The data 223 may include data received by the electronic device from external devices, as well as data collected by its own input / output interface 25.
[0141] Furthermore, embodiments of this application also disclose a computer-readable storage medium storing a computer program. When the computer program is loaded and executed by a processor, it implements the method steps executed during access by a flash memory chip as disclosed in any of the foregoing embodiments.
[0142] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0143] The present invention provides a detailed description of a flash memory chip access method, apparatus, device, and medium. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for accessing a flash memory chip, characterized in that, include: Read the current access request stored in the first preset first-in-first-out queue, and determine the target operation mode corresponding to the current access request and the target operation address of the current access request; In the target operation mode, a state machine transition is performed based on the target operation address to complete the processing of the current access request and generate processed data corresponding to the current access request; The processed data is sent to a second preset first-in-first-out queue so that the second preset first-in-first-out queue returns the processed data to the host. The step of performing a state machine transition based on the target operation address in the target operation mode to complete the processing of the current access request includes: In the target operation mode, the current sub-access operation corresponding to the target operation address is determined, and the current state machine is determined based on the current sub-access operation; the corresponding operation thread in the current state machine is determined to complete the current sub-access operation corresponding to the current state machine; it is determined whether there is a next sub-access operation corresponding to the target operation address. If there is, the next sub-access operation is updated to the current sub-access operation, and the process jumps back to the step of determining the current state machine based on the current sub-access operation, until there is no next sub-access operation corresponding to the target operation address. The step of determining the corresponding operation thread in the current state machine to complete the current sub-access operation corresponding to the current state machine includes: Obtain the current command prompt category value corresponding to the current access request, and determine the current operation thread in the current state machine corresponding to the current command prompt category value; execute the current operation thread, and set the operation state of the current operation thread to a preset completion state; obtain the next command prompt category value corresponding to the current access request, use the next command prompt category value as the current command prompt category value, and jump back to the step of determining the current operation thread in the current state machine corresponding to the current command prompt category value.
2. The flash memory chip access method according to claim 1, characterized in that, Before reading the current access request stored in the first preset first-in-first-out queue, the method further includes: The host sends the current access request to the first preset first-in-first-out queue so that the first preset first-in-first-out queue saves the current access request locally.
3. The flash memory chip access method according to claim 2, characterized in that, Sending the current access request to the first preset first-in-first-out queue via the host includes: The host receives the current access request sent by the host computer and determines whether the interrupt priority of the current access request meets the preset priority condition. If it does, the current access request is sent to the first preset first-in-first-out queue.
4. The flash memory chip access method according to claim 1, characterized in that, The step of reading the current access request stored in the first preset first-in-first-out queue includes: Obtain the current status signal of the slave device and determine whether the current status signal is at a high level; If so, the slave device is determined to be in an idle state, the current access request stored in the first preset first-in-first-out queue is read, and the current state signal is set to a low potential; wherein, the current access request is any one or more of the following: read memory request, write memory request, whole erase request, sector erase request, read register request, and write register request; If not, the slave device is determined to be in a busy state. The next state signal of the slave device is obtained and used as the current state signal. Then, the process jumps back to the step of determining whether the current state signal is at a high level.
5. The flash memory chip access method according to any one of claims 1 to 4, characterized in that, The step of reading the current access request stored in the first preset first-in-first-out queue and determining the target operation mode corresponding to the current access request and the target operation address of the current access request includes: Read the current access request and its original operation address stored in the first preset first-in-first-out queue; The target operation mode corresponding to the current access request is determined from multiple preset operation modes, and the original operation address is truncated based on preset address bits to obtain the target operation address; wherein, the multiple preset operation modes include single-line operation mode and four-line operation mode; Accordingly, the state machine transition based on the target operation address in the target operation mode includes: In the target operation mode, the target operation address is compared with the preset addresses of each state machine to perform state machine transitions.
6. A flash memory chip access device, characterized in that, The steps for implementing the flash memory chip access method as described in any one of claims 1 to 5 include: The address determination module is used to read the current access request stored in the first preset first-in-first-out queue, and determine the target operation mode corresponding to the current access request and the target operation address of the current access request. The data generation module is used to perform state machine transitions based on the target operation address in the target operation mode to complete the processing of the current access request and generate processed data corresponding to the current access request. The data return module is used to send the processed data to a second preset first-in-first-out queue, so that the second preset first-in-first-out queue will return the processed data to the host.
7. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the flash memory chip access method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, Used for storing computer programs; wherein, when the computer program is executed by a processor, it implements the steps of the flash memory chip access method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
QSPI controller, image processor and flash memory access method
CN112463651A
