Multi-channel memory switching method, switching circuit and system

By detecting the channel selection signal and clock conditions, the memory channel is dynamically switched, which solves the problem of inability to dynamically switch and asynchronous clock domain access in the existing technology, realizes efficient multi-channel memory switching, simplifies circuit design and improves switching efficiency. .

CN118860918APending Publication Date: 2024-10-29SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410840507.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-10-29

AI Technical Summary

Technical Problem

Existing memory switching circuits cannot dynamically switch paths when the system is powered off or data transmission is incomplete, and do not support asynchronous clock domain access between different modules, making it impossible to meet the dynamic switching requirements of complex systems for memory paths.

Method used

By detecting changes in the channel selection signal, the memory service data reading and writing conditions are determined, and data processing and clock switching are performed according to preset rules to ensure that the switching circuit realizes channel switching under different clock conditions and supports dynamic switching and asynchronous clock domain access.

Benefits of technology

It realizes dynamic switching of multi-channel memory, simplifies circuit design, improves channel switching efficiency and success rate, supports asynchronous clock domain switching between different modules, and meets the business needs of complex systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118860918A_ABST
    Figure CN118860918A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of circuits, and particularly discloses a multi-channel memory switching method, switching circuit and system, which are applied to a switching circuit, and the switching method comprises the following steps: when a path selection signal is detected to change, determining that a first module reads and writes service data of a memory by using a first channel, discarding or pre-configuring the access data of the first channel according to a preset rule based on the business data read-write condition; if it is detected that the clock corresponding to the first channel is different from the clock corresponding to the second channel of the memory requested to be accessed by the second module, the clock for reading and writing data in the switching circuit and the clock corresponding to the first channel are switched into the clock corresponding to the second channel; according to the method, the access channel is switched from the first channel to the second channel, dynamic switching of the channels of different modules accessing the memory under multiple channels is realized, a scheme of asynchronous clock domain switching between the two access channels and the memory is supported, and the channel switching efficiency and success rate are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of circuit technology, and in particular to a multi-channel memory switching method, switching circuit and system. Background Art

[0002] With the development of integrated circuits, circuit functions are becoming more and more complex, and bus lines and functions are becoming more and more complex. In complex system on chip (SOC), multiple modules often share a memory. And multiple modules access the same memory in different scenarios, and the path of the shared memory needs to be switched.

[0003] In the general switching mode, for example, when both module 1 and module 2 initiate data access to the memory, but only one module can access the memory at the same time, when the path selection signal sel transmitted to the memory changes, the switching circuit switches on the access bus. However, the current switching circuit only supports the switching of the access path after the transmission of the original access module is completed, and does not support switching with services. For example, when the system is powered off, when the memory receives the changed sel signal, it cannot switch the path immediately, resulting in failure to meet the demand for dynamic switching of access paths.

[0004] In addition, in the current switching solution, all modules have the same clock and do not consider the situation of different clocks. Therefore, in a real system, there may be multiple different clocks. How to solve the channel switching problem when different modules request to access the memory. Summary of the invention

[0005] The present invention provides a multi-channel memory switching method, switching circuit and system to solve the problem of dynamic switching of paths for different modules to access the memory.

[0006] In a first aspect, the present invention provides a multi-channel memory switching method, which is applied to a switching circuit, wherein the switching circuit is connected between a memory and at least two modules, and the method comprises:

[0007] When a change in the path selection signal is detected, determining whether the first module reads and writes the service data of the memory using the first channel, wherein the clock corresponding to the first channel is the same as the clock of the switching circuit;

[0008] Based on the reading and writing status of the business data, the access data of the first channel is discarded or pre-configured according to preset rules;

[0009] If detecting that a clock corresponding to the first channel is different from a clock corresponding to a second channel for which the second module requests to access the memory, switching the clock for reading and writing data in the switching circuit and the clock corresponding to the first channel to a clock corresponding to the second channel;

[0010] The access channel is switched from the first channel to the second channel, so that the second module accesses the memory according to the clock corresponding to the second channel, and the access data of the first module in the first channel is discarded or pre-configured according to the preset rule.

[0011] In combination with the first aspect, in an optional implementation, based on the reading and writing status of the business data, the access data of the first channel is discarded or pre-configured according to preset rules, including: if the access data to the memory is write data, the write data received through the first channel is discarded, and the data currently written to the write cache continues to be written to the memory until all the data in the write cache is written; if the access data to the memory is read data, the data returned to the first module is concatenated to a constant value and transmitted to the first module, and all data from the read cache is read out and discarded.

[0012] In combination with the first aspect, in another optional implementation, the switching circuit includes a cache module;

[0013] The switching of the switching circuit and the clock corresponding to the first channel to the clock corresponding to the second channel includes: switching the clock corresponding to the cache module in the switching circuit and the clock corresponding to the first channel to the clock corresponding to the second channel, wherein the clock corresponding to the cache module includes a read data clock and a write data clock.

[0014] In combination with the first aspect, in another optional implementation, the method further includes: if the clock corresponding to the first channel is the same as the clock corresponding to the second channel, directly switching the access channel from the first channel to the second channel; and using the second channel to perform business access to the memory.

[0015] In combination with the first aspect, in yet another optional implementation, the method further includes: in the static switching mode, if it is detected that the path selection signal changes and the access data currently in the first channel has not been transmitted, waiting for the access data of the first channel to be transmitted;

[0016] When the access data transmission of the first channel is completed, based on the reading and writing status of the access data, the access data of the first channel is discarded or pre-configured according to a preset rule;

[0017] If the access data to the memory is write data, the data subsequently received on the first channel is discarded, because in the static switching mode, there is no business transmission during the switching, and at this time, all the data in the write cache are read empty;

[0018] If the access data to the memory is read data, the subsequent data from the memory is connected to a constant value and transmitted to the first module. At this time, all the data in the read cache is read empty, and no business transmission occurs during the switching.

[0019] Detecting whether a clock corresponding to the first channel is the same as a clock corresponding to a second channel for the second module to request access to the memory;

[0020] If they are not the same, switching the clock for reading and writing data in the switching circuit, the clock corresponding to the first channel, and the clock of the memory to the clock corresponding to the second channel;

[0021] The access channel is switched from the first channel to the second channel, so that the second module accesses the memory according to the clock corresponding to the second channel, and the access data of the first module in the first channel is discarded or pre-configured according to the preset rule.

[0022] In combination with the first aspect, in another optional implementation, the switching circuit includes a clock glitch-free switching circuit, and the clock for reading and writing data in the switching circuit and the clock corresponding to the first channel are switched to the clock corresponding to the second channel, including: after the cached read data and / or write data are cleared, the clock glitch-free switching circuit is used to switch the clock for reading and writing data in the switching circuit and the clock corresponding to the first channel to the clock corresponding to the second channel.

[0023] In combination with the first aspect, in yet another optional implementation, if the clock corresponding to the first channel is different from the clock of the switching circuit.

[0024] The step of switching the clock for reading and writing data in the switching circuit and the clock corresponding to the first channel to the clock corresponding to the second channel further includes: switching the clock of the memory to the clock corresponding to the second channel.

[0025] In a second aspect, the present invention further provides a switching circuit, the switching circuit comprising:

[0026] A switching module, configured to determine, when receiving a change in the path selection signal, whether the first module reads and writes the service data of the memory using the first channel, wherein the clock corresponding to the first channel is the same as the clock of the switching circuit;

[0027] A data processing module, used for discarding or pre-configuring the access data of the first channel according to preset rules based on the reading and writing status of the business data;

[0028] A clock detection module, used to detect whether a clock corresponding to the first channel is the same as a clock corresponding to a second channel requested by the second module to access the memory;

[0029] The switching module is also used to switch the switching circuit and the clock corresponding to the first channel to the clock corresponding to the second channel when the clock detection module detects that the clocks are different; and to switch the access channel from the first channel to the second channel so that the second module accesses the memory according to the clock corresponding to the second channel, and the access data of the first module in the first channel is discarded or pre-configured according to the preset rules.

[0030] In combination with the second aspect, in an optional implementation, the switching module includes a clock glitch-free switching circuit and a cache module; the cache module is used to cache read data and / or write data during access to the memory through the first channel; the clock glitch-free switching circuit is used to switch the clock of the read and write data in the switching circuit and the clock corresponding to the first channel to the clock corresponding to the second channel after the read data and / or write data cached in the cache module are cleared.

[0031] In a third aspect, the present invention further provides a multi-channel memory switching system, the system comprising: a switching circuit, a memory and at least two modules, the at least two modules comprising a first module and a second module;

[0032] Wherein, the first module is connected to the switching circuit and the memory through a first channel, and the second module is connected to the switching circuit and the memory through a second channel;

[0033] The first module is used to access the memory for reading and writing data through the first channel;

[0034] The switching circuit is used to execute the multi-channel memory switching method described in the first aspect or any one of the embodiments of the first aspect;

[0035] The second module is configured to access the memory according to a clock corresponding to the second channel when the switching circuit switches the access channel from the first channel to the second channel;

[0036] The first module is further used to discard or pre-configure the access data of the first channel according to the preset rule.

[0037] The present invention provides a multi-channel memory switching method, switching circuit and system, which realizes dynamic switching of paths for different modules to access the memory under multiple paths by switching on the memory transmission protocol. Compared with improving and switching on the bus protocol, the method greatly simplifies the circuit design.

[0038] In addition, before the switching of the memory access between the two channels of the first module and the second module, when it is detected that the clocks of the first channel and the second channel are different, the clock for reading and writing data in the switching circuit and the clock corresponding to the first channel are first switched to the clock corresponding to the second channel by using the switching circuit, and after the clocks are the same, the access data channel is switched, thereby supporting the asynchronous clock domain switching scheme between the two access paths and the memory, thereby improving the path switching efficiency and success rate. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0040] Figure 1 is a structural diagram of a switching circuit provided by an embodiment of the present invention;

[0041] Figure 2 It is a schematic diagram of an AXI protocol write handshake provided by an embodiment of the present invention;

[0042] Figure 3 is a structural diagram of a multi-channel memory switching system provided by an embodiment of the present invention;

[0043] Figure 4 is a schematic diagram of the internal structure of a switching circuit provided by an embodiment of the present invention;

[0044] Figure 5 is a schematic diagram of a memory write timing provided by an embodiment of the present invention;

[0045] Figure 6 is a schematic diagram of a memory read timing provided by an embodiment of the present invention;

[0046] Figure 7 is a flow chart of a multi-channel memory switching method provided by an embodiment of the present invention;

[0047] Figure 8 is a flow chart of dynamic channel switching provided by an embodiment of the present invention;

[0048] Fig. 9 is a flow chart of static channel switching provided by an embodiment of the present invention;

[0049] Fig.10 It is a structural block diagram of a switching circuit provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0050] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0051] First, the application scenario of the technical solution of the embodiment of the present invention is described.

[0052] The technical solution provided by the embodiment of the present invention is applied to the technical field of electronic circuits. A specific example is as follows: Figure 1 As shown, in a system on chip SOC, when two or more modules access memory through a bus, for example, when a first module (module 1) and a second module (module 2) access memory through their respective buses at the same time, only one module can access the memory at the same time.

[0053] When sel changes, the module currently accessing the memory completes the current transmission, and the switch module performs bus switching. After the bus switching is completed, another module can access the memory. Figure 1 The function of the bridge module is to convert the bus protocol into the memory protocol.

[0054] Since the switch module switches on the access bus, the bus protocol must be met during the switch and the timing of the bus protocol must be followed, otherwise the bus will be hung. The implementation of the bus requires handshake signals, such as the AXI (Advanced Extensible Interface) protocol. AXI is a bus protocol, which is the most important part of the AMBA (Advanced Microcontroller Bus Architecture) 3.0 protocol proposed by ARM. It is an on-chip bus for high performance, high bandwidth, and low latency.

[0055] During data transmission, the ready and valid signals of the data channel need to be handshaked. Figure 2The figure shows the handshake signal of the write data channel under the axi protocol. At the first moment T1, the host pulls up the w valid signal (becomes a high level), and then waits for the w ready signal of the slave to be pulled up (becomes a high level). At the second moment T2, the host samples the w ready signal of the slave as a high level. At this moment, the valid and ready signals are both high levels, and the handshake is successful. At the third moment T3, the wvalid signal is pulled down (becomes a low level).

[0056] It should be noted that the ready and valid handshake of the data channel is a protocol that is sent through the valid control signal and received through the ready control signal. It can ensure that data is transmitted when both parties are ready. It has the characteristics and advantages of effective data transmission, flow control and synchronization.

[0057] The technical solution provided in this embodiment mainly solves the problem that the access path can be switched only after the transmission of the original access module is completed, and does not support switching with services. For example, when the system is powered off and a changed sel signal is received, although the original path service is still in progress, it needs to be switched immediately. At this time, dynamic switching cannot be performed immediately.

[0058] In addition, if the clocks of multiple modules in the system are different, for example, the clocks of two transmission channels are different from the clocks of the memory, the different clocks need to be synchronized before switching the memory access channel.

[0059] In order to solve the above technical problems, the embodiment of the present invention proposes a memory switching method for multiple channels supporting dynamic multi-clock. The scenario structure of the method is as follows: Figure 3 shown.

[0060] This scenario includes at least two modules, such as module 1 and module 2, and module 1 and module 2 can perform bus service access to the memory, and a switching circuit (switch) is connected between module 1 and module 2 and the memory. The switching circuit is used to receive a path selection signal sel (select) and select two bus accesses according to the instruction of the sel signal. The switching circuit outputs the memory access of the selected path, so as to read and write data to the memory.

[0061] It should be understood that Figure 3 In the example shown, only two modules, module 1 and module 2, are shown requesting to access the memory, and more modules may be included to establish more transmission channels with the switching circuit and the memory, which will not be described in detail in this embodiment.

[0062] See also Figure 4 , is a schematic diagram of the internal structure of a switching circuit provided in this embodiment, that is, Figure 3 The switching circuit includes: data processing module A and data processing module B, bridge module A and bridge module B, monitoring module A and monitoring module B, synchronization module A and synchronization module B, switching module, buffer module (buffer) and clock detection module. The specific connection relationship between each module is as follows: Figure 4 shown.

[0063] Among them, the first channel is formed by the transmission path from module 1, bridge module A, data processing module A, switching module, and cache module to the memory; the second channel is formed by the transmission path from module 2, bridge module B, data processing module B, switching module, and cache module to the memory.

[0064] Monitoring module A and monitoring module B are used to monitor whether the current transmission of their respective channels is completed. Optionally, the monitoring module A is bus_monA, and the monitoring module B is bus_monB.

[0065] The function of bridge module A (bridgeA) and bridge module B (bridgeB) is to convert the bus protocol into the memory protocol, so that a relatively complex bus access can be converted into a relatively simple memory protocol, because the read and write timing of the memory protocol is fixed. In this embodiment, the read and write timing of the memory is executed according to the following protocol regulations.

[0066] The write timing of the memory protocol is as follows Figure 5 As shown, in at least one transmission cycle, the csb signal is a low-effective signal, the write enable signal wen is a high-effective signal, addr is an address signal, and data is a data signal. The csb signal is one of the signals output by the switching circuit to the memory; the w / r signal (write / read signal) is one of the signals output by the switching circuit to the memory; addr is the address information, and data writes / reads data to the addr address.

[0067] like Figure 5 As shown in the figure, at time T1, the csb signal is pulled low (low level), the w / r signal is high level, that is, write is enabled, the addr signal changes to A (A is the valid address, the address written to the memory), and the data signal changes to D. At time T2, the sampled csb signal is low, the sampled w / r signal is high level, the sampled addr signal is A, and the sampled data signal is D. After time T2, the csb signal changes to a high level, that is, it changes to an invalid signal. The memory protocol will sample the w / r, addr, and data signals only when the csb signal is low.

[0068] Similarly, see Figure 6, is a read timing diagram in the memory protocol. In each transmission cycle, when the csb signal is low, the command is read, that is, w / r, addr and data are read. At T1, the csb signal is low and the w / r signal is low. At T2, the w / r signal is sampled as low, that is, this operation is a read operation. When addr is sampled as A, the memory address A is read. In the next cycle after T2, that is, T3, the sampled data data changes from A to D.

[0069] The functions of data processing module A and data processing module B are: they can determine the behavior of writing data and reading data according to the value of sel. For example, when the sel signal is 1, it means that the A channel is selected to access the memory; when the sel signal becomes 0, it means that the B channel is selected to access the memory.

[0070] According to an embodiment of the present invention, a multi-channel memory switching method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0071] Figure 7 is a flowchart of a memory switching method for multiple channels according to an embodiment of the present invention, which is applied to a switching circuit. The switching circuit is applied to the aforementioned Figure 3 or Figure 4 The system structure shown in Figure 1 is as follows. Figure 7 As shown, the process includes the following steps:

[0072] Step S101, when it is detected that the path selection signal changes, determining the reading and writing status of the service data of the memory by the first module using the first channel.

[0073] The business data read and write status of the memory includes data read and data write business. In addition, the clock corresponding to the first channel is the same as the clock of the switching circuit, and the clock of the switching circuit is the clock for reading and writing data in the cache module in the switching circuit.

[0074] Step S102: based on the reading and writing status of the business data, the access data of the first channel is discarded or pre-configured according to preset rules.

[0075] Specifically, a possible implementation is that if the access data to the memory is write data, the write data received through the first channel is discarded, and the data currently written to the write cache continues to be written to the memory until all the data in the write cache is written.

[0076] If the access data to the memory is read data, the data returned to the first module is concatenated into a constant value and transmitted to the first module, and all the data from the read cache is read out and discarded.

[0077] Assume that when the sel signal is "1", the first channel is selected to access the memory, and when the sel signal is "0", the second channel accesses the memory. When sel = 1, the first module (module 1) is accessing the memory through the first channel. When the sel signal becomes 0, the access service of the first channel is partially completed and has not been completed. According to the memory protocol, the service will continue. According to the service scenario, the data processing module has different processing methods.

[0078] Specifically, the preset rules include read data service operation rules and write data service operation rules. If it is necessary to switch channels immediately, that is, in the dynamic switching mode, the write data service is being executed on the first channel. For example, the write data is numbered from 1 to 60 data in total. When the sel signal changes, it happens to be the 30th data. At this time, the 1st to 30th data have been written into the write cache (w_buffer). The 1st to 30th data will continue to be written to the memory until all 30 data in the write cache are written empty. At the same time, the 31st to 60th write data continue to be written through the first channel in the first module, and the 31st to 60th write data are discarded in the data processing module A.

[0079] If the currently executed service is a data read service, for example, when the sel signal changes, the 30th data is transmitted, that is, the data numbered from the 1st to the 30th data from the memory has been transmitted to the first module by the data processing module A, and the data from the 31st to the 60th data is the data that needs to be returned to the first module, and the 31st to the 60th read data are tied into a constant value, such as the constant "0", that is, the 31st to the 60th data of 0 are sent to the first module, so that the first path will not hang the bus, and at this time the signal protocol output by the data processing module A is the memory protocol, and the control signal and the data signal are both invalid signals. In addition, after the data processing module A continues to receive the 31st to the 60th read data from the memory, all these read data are read out and discarded, so that the read data in the read buffer (r_buffer) is cleared.

[0080] Step S103, detecting whether the clock corresponding to the first channel is the same as the clock corresponding to the second channel, wherein the second channel is the channel through which the second module requests to access the memory.

[0081] Specifically, the clock detection module may be used to detect whether the clocks of the various channels are the same. In addition, the clock of the memory may be detected to be the same as the clocks corresponding to the first channel and the second channel.

[0082] If it is detected in this step that the clocks corresponding to the first channel and the second channel are different, step S104 is executed.

[0083] Step S104: if the clock corresponding to the first channel is different from the clock corresponding to the second channel, the clock for reading and writing data in the switching circuit, the clock corresponding to the first channel, is switched to the clock corresponding to the second channel.

[0084] The clock corresponding to the first channel can be understood as the system clock for the first module to perform read and write data operations on the memory. Similarly, the second channel is the system clock for the second module to perform read and write operations on the memory. In addition, the memory also has its own clock.

[0085] In this embodiment, it is assumed that the clock of the memory follows the clock corresponding to the first channel, that is, the clock corresponding to the first channel is the same as the clock of the memory. When the clock corresponding to the first channel is different from the clock corresponding to the second channel, the clock of the memory is also different from the clock corresponding to the second channel.

[0086] Specifically, one implementation is that the switching circuit includes a cache module; the cache module includes a read cache and a write cache, wherein the read cache is used to store read data in the access service, and the write cache is used to store write data in the access service. In the above step S104, switching the switching circuit and the clock corresponding to the first channel to the clock corresponding to the second channel specifically includes: switching the clock corresponding to the cache module in the switching circuit and the clock corresponding to the first channel to the clock corresponding to the second channel, and the clock corresponding to the cache module includes a read data clock and a write data clock.

[0087] After switching, the read data clock and write data clock in the cache module are the same as the clock corresponding to the second channel, and the clock corresponding to the first channel is also the same as the clock corresponding to the second channel, thereby ensuring clock matching and improving the transmission accuracy after switching channels.

[0088] Step S105, switching the access channel from the first channel to the second channel.

[0089] Specifically, the switching operation between the first channel and the second channel can be implemented through a switching module, so that the second module accesses the memory according to the clock corresponding to the second channel, and the access data of the first module in the first channel is discarded or pre-configured according to preset rules.

[0090] Optionally, in a possible implementation, the method further includes: if the clock corresponding to the first channel is the same as the clock corresponding to the second channel, directly switching the access channel from the first channel to the second channel; and using the second channel to access the memory. In this implementation, since the clocks of the first channel and the second channel are the same, there is no need to switch, and the channel switching can be performed directly.

[0091] Optionally, in this embodiment, the above-mentioned switching circuit includes a clock glitch-free switching circuit. In step S104, the clock for reading and writing data in the switching circuit and the clock corresponding to the first channel are switched to the clock corresponding to the second channel, including: after the cached read data and / or write data are cleared, the clock glitch-free switching circuit is used to switch the clock for reading and writing data in the switching circuit and the clock corresponding to the first channel to the clock corresponding to the second channel.

[0092] Among them, the glitch-free clock switching circuit, also known as the seamless switching circuit, is a circuit designed to switch the clock source through gating when the chip is running while avoiding the glitch phenomenon. The glitch phenomenon refers to the process of clock switching, which may cause short unstable pulses or truncate the clock cycle due to the asynchronous switching timing, and may cause metastable problems in the driving circuit.

[0093] The present invention provides a memory switching method for multiple channels, which is a method for dynamically switching channels, that is, the current transmission channel must be switched during the transmission process. Based on the above steps, this embodiment describes that by switching on the memory transmission protocol, dynamic switching of the channels for different modules to access the memory under multiple channels is achieved. Compared with making improvements and switching on the bus protocol, this method greatly simplifies the circuit design.

[0094] In addition, before the switching of the memory access between the two channels of the first module and the second module, when it is detected that the clocks of the first channel and the second channel are different, the clock for reading and writing data in the switching circuit and the clock corresponding to the first channel are first switched to the clock corresponding to the second channel by using the switching circuit, and after the clocks are the same, the access data channel is switched, thereby supporting the asynchronous clock domain switching scheme between the two access paths and the memory, thereby improving the path switching efficiency and success rate.

[0095] In a specific embodiment, see Figure 8 , is a dynamic channel switching method provided by another embodiment of the present invention, corresponding to the aforementioned Figure 7 The method flow shown. The method includes:

[0096] According to the instructions of the sel signal, according to the instructions of the data processing module A (bus_monA) or the data processing module B (bus_monB) in the switching circuit on the completion of this transmission, according to the instructions of the remaining data in the w_buffer (write cache) or r_buffer (read cache) and the clock situation, the access path selection and clock switching are completed.

[0097] When the first channel (A channel) is accessing data, the switching circuit detects that the sel signal has changed, and first determines whether the access service currently transmitted on the first channel is a read data or write data operation. The processing method is different according to the operation:

[0098] When the first channel is performing a write operation, the data in the cache module w_buffer is continued to be written to clear the stored data in w_buffer. If there is data that needs to be written to the memory later, a delete operation is performed. When the first channel is performing a read operation, the data in the cache module r_buffer is continued to be read out, and this part of the data is discarded. Since there is no business afterwards, the subsequent read data tie is set to a constant value of 0.

[0099] In addition, the dynamic switching process also includes determining whether the clocks of various systems are the same, for example, determining whether the clock corresponding to the first channel, the clock corresponding to the second channel, and the clock of the memory are the same.

[0100] In the first case, if the clocks of the three are the same, when the sel signal changes, the switching circuit does not need to consider the clock switching problem. When the first channel performs write business, it continues to write the data in the write cache w_buffer. When w_buffer is empty, since there is no business at this time, the switching module selects the outputs of data processing module A and data processing module B, and selects the second channel for channel switching.

[0101] When the first channel performs a read service, the data in r_buffer is read out and discarded. When w_buffer is empty, since there is no service at this time, the outputs of data processing module A and data processing module B are selected, and the output of data processing module B is selected, that is, the second channel performs channel switching. Due to the channel switching, the second channel has been selected, and the second channel can perform services only after it is selected.

[0102] In the second case, when the system has two clocks, that is, the clock corresponding to the first channel is different from the clock corresponding to the second channel, assuming that the clock of the memory is the same as the clock corresponding to the first channel, when w_buffer is written to empty or r_buffer is read to empty, since there is no business at this time, the clock glitch-free switching circuit is used to switch the clocks of w_buffer, r_buffer and memory to the same clock corresponding to the second channel. w_buffer (write data clock) and r_buffer (read data clock) are two clocks in the cache module, which can be the same or different, but no matter whether the two write data clocks and read data clocks are the same, the two clocks must be synchronized before the second channel is switched.

[0103] It should be noted that, because the clock waveform output by the clock switching circuit is: first output the clock of the first channel, then after a period of low level (which can be called "empty window"), output the clock of the second channel. In addition, the switching circuit is also used to switch other signals in the path, which is not limited in this embodiment. The signal clock switching of the access path is completed during the empty window period, that is, the switching of the path is completed during the period when there is no clock output, which can avoid the burrs of the switching circuit.

[0104] After the clock is switched to be the same as the clock corresponding to the second channel, the second module accesses data to the memory on the new channel (the second channel).

[0105] In the third case, when the system has three clocks, the clock corresponding to the first channel, the clock corresponding to the second channel, and the clock of the memory are all different.

[0106] Similar to the second case mentioned above, but the difference is that in this case, the clock of the memory does not need to be switched, that is, the clock of the memory still uses its own clock, but the w_buffer write data clock and the r_buffer read data clock in the buffer of the switching circuit need to be switched so that they are the same as the clock of the second channel.

[0107] Specifically, when w_buffer is written to empty or r_buffer is read to empty, since there is no business at this time, a clock glitch-free switching circuit is used to switch the write clock of w_buffer and the read clock of r_buffer to the clock corresponding to the second channel, and the switching of the access path is completed during the window period.

[0108] The switching method provided in this embodiment supports dynamic switching of data transmission scenarios, and ensures that when different clocks exist in the system, each clock is switched so that the clock of the first channel, the clock of the memory and the clock corresponding to the second channel are the same, thereby improving the efficiency and success rate of channel switching.

[0109] In another embodiment, a multi-channel memory switching method is provided. The difference from the above embodiment is that the switching method is a static switching method, that is, when sel changes, the switching channel needs to wait until the data transmission is completed before switching, that is, static switching.

[0110] For example, when the first channel accesses the memory for writing data, the second module needs to read the write data of the first channel, and static switching is used at this time. Static switching still supports the system with one, two and three clocks as mentioned above. Specifically, the method includes:

[0111] In the static switching mode, if it is detected that the path selection signal changes and the access data currently in the first channel has not been transmitted completely, the access data transmission of the first channel is waited to be completed.

[0112] When the access data transmission of the first channel is completed, if the access data to the memory is write data, the subsequent data received on the first channel is discarded; if the access data to the memory is read data, the subsequent data from the memory is connected to a constant value and transmitted to the first module.

[0113] Detect whether the clock corresponding to the first channel is the same as the clock corresponding to the second channel of the memory requested by the second module. If they are not the same, switch the clocks for reading and writing data in the switching circuit, the clock corresponding to the first channel, and the clock of the memory to the clock corresponding to the second channel. For the specific process, refer to steps S103 and S104 of the aforementioned embodiment, which will not be described in detail in this embodiment.

[0114] The access channel is switched from the first channel to the second channel, so that the second module accesses the memory according to the clock corresponding to the second channel, and the access data of the first module in the first channel is discarded or pre-configured according to the preset rules. For the specific process, refer to step S105 of the above embodiment.

[0115] In addition, the above method also includes: if the clock corresponding to the first channel is different from the clock of the switching circuit; then the clock for reading and writing data in the switching circuit and the clock corresponding to the first channel are switched to the clock corresponding to the second channel, and also includes: switching the clock of the memory to the clock corresponding to the second channel.

[0116] In a specific implementation, the static switching process is as follows: Fig. 9 As shown, including:

[0117] When the first module is accessing the memory using the first path, it is detected that the sel signal changes, and it is necessary to wait for the completion of this transmission. If the current transmission is a write data operation, the switching circuit receives the monitoring module A indicating that the transmission is completed. For example, the first module needs to write 60 write data numbered 1-60 to the memory. When the sel signal changes, the current write data is the 30th, then the data processing module A needs to write all the remaining 31st-60th write data to w_buffer (write cache), and wait until the 31st-60th write data in w_buffer are all written to the memory, and the current transmission is completed. At this time, w_buffer is written empty, and if the data processing module A receives write data from the first module after this, it will delete it, that is, it will no longer write the received data into w_buffer. Then the clock and access path are switched. After the switching is completed, the second module performs business access to the memory in the second channel.

[0118] Similarly, if this transmission is a read operation, for example, when the sel signal changes, the current write data is the 30th, then the data processing module A continues to receive the 31st-60th read data from the memory through the first channel, and these 31st-60th read data are transmitted to the data processing module A after passing through r_buffer, and the data processing module A continues to transmit the 31st-60th read data to the first module to complete this data read service. At this time, the data in r_buffer is read empty. If there is more read data from the memory to be transmitted to the data processing module A, the data processing module A will connect the following data to a constant value of 0.

[0119] One possible implementation is that when data processing module A receives an indication from monitoring module A indicating that the transmission is complete, indicating that the read data in r_buffer (read cache) has been cleared, the clock and access path can be switched. After the switch is completed, the second module accesses the memory through the second channel.

[0120] Among them, w_buffer is a cache for writing to the memory. When w_buffer is written to empty, the memory has no business at this time, and the switching module switches the clock and channel. Specifically, the clock is switched first and then the access channel is switched. Similarly, r_buffer is a cache for reading from the memory. When the r_buffer read data is empty, the memory has no business at this time, and the switching module switches the clock and channel. The specific clock detection process and channel switching process refer to the description of the aforementioned embodiment, which will not be repeated here.

[0121] It should be noted that, since the memory is a single-interface memory, only one service can be performed at the same time, and two services of reading and writing cannot be performed at the same time. In addition, the judgment and switching process of each clock in the system by the above switching circuit is the same as the first to third cases of the aforementioned embodiment, and refer to the description of the aforementioned embodiment, which will not be repeated here in this embodiment.

[0122] In addition, it should be understood that the method flow of static switching in this embodiment, the method for switching different clocks and channels is the same as the method for dynamic switching mentioned above, so this embodiment will not be repeated. After the clock corresponding to the first channel in the system, the clock of the buffer and / or the clock of the memory are switched, the switching operation of the second channel is performed. After the second channel is switched, the second module can use the second channel to access data to the memory.

[0123] The method provided in this embodiment realizes static switching of a multi-channel memory and can also support switching of multiple clocks.

[0124] In summary, compared with switching on the bus protocol, the technical solution provided by the present invention not only switches on the memory protocol, which greatly simplifies the circuit design, but also supports both static switching and dynamic switching scenarios. For different clock situations, it also supports channel switching in asynchronous clock domains, thereby improving the flexibility of multi-way switching and meeting different business needs and switching requirements.

[0125] In addition, the present invention can also support the switching of the path clock domain for accessing the memory to always be the same as the memory clock domain.

[0126] In this embodiment, a switching circuit is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0127] This embodiment provides a switching circuit, such as Fig.10 As shown, the switching circuit includes: a switching module 110, a data processing module 120, a clock detection module 130 and a cache module 140. In addition, the circuit may also include other more or fewer modules, such as a synchronization module, a monitoring module, etc.

[0128] The switching module 110 is used to determine the reading and writing of the service data of the memory by the first module using the first channel when receiving a change in the path selection signal, and the clock corresponding to the first channel is the same as the clock of the switching circuit;

[0129] The data processing module 120 is used to discard or pre-configure the access data of the first channel according to preset rules based on the reading and writing status of the business data.

[0130] The clock detection module 130 is used to detect whether the clock corresponding to the first channel is the same as the clock corresponding to the second channel of the memory requested by the second module to access the memory. In addition, the clock detection module 130 is also used to detect the clock of the memory, and the data reading clock and data writing clock in the cache module.

[0131] The switching module 110 is also used to switch the clock corresponding to the first channel to the clock corresponding to the second channel when the clock detection module 130 detects that the clocks are different; and to switch the access channel from the first channel to the second channel so that the second module accesses the memory according to the clock corresponding to the second channel, and the access data of the first module in the first channel is discarded or pre-configured according to preset rules.

[0132] Optionally, in a possible implementation, the switching module includes a clock glitch-free switching circuit 1101; and a cache module 140, configured to cache read data and / or write data during access to the memory through the first channel.

[0133] The clock glitch-free switching circuit is used to switch the clock of the read and write data in the switching circuit and the clock corresponding to the first channel to the clock corresponding to the second channel after the read data and / or write data cached in the cache module 140 are cleared.

[0134] In this embodiment, further functional descriptions of each module are the same as those in the above corresponding embodiments and will not be repeated here.

[0135] The present invention provides a switching circuit, which realizes dynamic switching of paths for different modules to access memories under multiple paths by switching on the memory transmission protocol. Compared with improving and switching on the bus protocol, this method greatly simplifies circuit design.

[0136] In addition, before the switching of the memory access between the two channels of the first module and the second module, when it is detected that the clocks of the first channel and the second channel are different, the clock for reading and writing data in the switching circuit and the clock corresponding to the first channel are first switched to the clock corresponding to the second channel by using the switching circuit, and after the clocks are the same, the access data channel is switched, thereby supporting the asynchronous clock domain switching scheme between the two access paths and the memory, thereby improving the path switching efficiency and success rate.

[0137] In addition, the present invention also provides a multi-channel memory switching system, the structure of which can be similar to the above-mentioned Figure 3 or Figure 4The structure shown is the same. The system comprises: a switching circuit, a memory and at least two modules, wherein the at least two modules comprise a first module and a second module. The first module and the second module are connected to the switching circuit via a bus.

[0138] The first module is connected to the switching circuit and the memory through a first channel, and the second module is connected to the switching circuit and the memory through a second channel. Furthermore, the first module is used to read and write data access to the memory through the first channel.

[0139] The switching circuit is as described above Figure 4 or Fig.10 The circuit shown is used to perform Figures 7 to 9 The memory switching method of multiple channels is shown.

[0140] The second module is used to access the memory according to the clock corresponding to the second channel when the switching circuit switches the access channel from the first channel to the second channel; the first module is also used to discard or pre-configured process the access data in the first channel according to preset rules.

[0141] In addition, the memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, and access data, such as read data or write data. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. The memory may also include a non-volatile memory, such as a ROM (Read-Only Memory), a PROM (Programmable Read-Only Memory), an EPROM (Erasable Programmable Read Only Memory), a Flash Memory, a hard disk or a solid-state hard disk; the memory may also include a combination of the above-mentioned types of memory.

[0142] The multi-channel memory switching system may be a packaged chip circuit, and the chip circuit may further include one or more interfaces for connecting to a bus or other unit modules.

[0143] The memory switching system provided in this embodiment realizes the channel switching function of multiple modules to the shared memory.

[0144] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium and stored in a local storage medium, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor or hardware, the method shown in the above embodiment is implemented.

[0145] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A memory switching method for multiple channels, characterized in that: Applied to a switching circuit, the switching circuit is connected between a memory and at least two modules, the method comprising: When a change in the path selection signal is detected, determining whether the first module reads and writes the service data of the memory using the first channel, wherein the clock corresponding to the first channel is the same as the clock of the switching circuit; Based on the reading and writing status of the business data, the access data of the first channel is discarded or pre-configured according to preset rules; If it is detected that the clock corresponding to the first channel is different from the clock corresponding to the second channel for the second module to access the memory, the clock corresponding to the first channel and the clock corresponding to the data read and write in the switching circuit are switched to the clock corresponding to the second channel; The access channel is switched from the first channel to the second channel, so that the second module accesses the memory according to the clock corresponding to the second channel, and the access data of the first module in the first channel is discarded or pre-configured according to the preset rule.

2. The method according to claim 1, characterized in that Based on the reading and writing status of the business data, the access data of the first channel is discarded or pre-configured according to a preset rule, including: If the access data to the memory is write data, discard the write data received through the first channel, and continue to write the data currently written to the write cache to the memory until all the data in the write cache is written; If the access data to the memory is read data, the data returned to the first module is concatenated into a constant value and transmitted to the first module, and all the data from the read cache is read out and discarded.

3. The method according to claim 1, characterized in that: The switching circuit includes a cache module; The step of switching the switching circuit and the clock corresponding to the first channel to the clock corresponding to the second channel includes: The clock corresponding to the cache module in the switching circuit and the clock corresponding to the first channel are switched to the clock corresponding to the second channel, and the clock corresponding to the cache module includes a data reading clock and a data writing clock.

4. The method according to claim 1, characterized in that: The method further comprises: If the clock corresponding to the first channel is the same as the clock corresponding to the second channel, directly switching the access channel from the first channel to the second channel; The second channel is used to access the memory.

5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: In the static switching mode, if it is detected that the path selection signal changes and the access data currently in the first channel has not been transmitted completely, then the access data transmission of the first channel is waited to be completed; When the access data transmission of the first channel is completed, based on the reading and writing status of the access data, the access data of the first channel is discarded or pre-configured according to a preset rule; If the access data to the memory is write data, discarding the data subsequently received on the first channel; If the access data to the memory is read data, then the subsequent data from the memory is connected to a constant value and transmitted to the first module; Detecting whether a clock corresponding to the first channel is the same as a clock corresponding to a second channel through which the second module requests to access the memory, wherein the clock of the memory is the same as the clock corresponding to the first channel; If they are not the same, the clock for reading and writing data in the switching circuit, the clock corresponding to the first channel and the clock of the memory are switched to the clock corresponding to the second channel, and the access channel is switched from the first channel to the second channel, If they are the same, the access channel is directly switched from the first channel to the second channel, so that the second module accesses the memory according to the clock corresponding to the second channel, and the access data of the first module in the first channel is discarded or pre-configured according to the preset rules.

6. The method according to claim 1, characterized in that The switching circuit includes a clock glitch-free switching circuit, and the switching circuit switches the clock for reading and writing data in the switching circuit and the clock corresponding to the first channel to the clock corresponding to the second channel, including: After the cached read data and / or write data is cleared, the clock glitch-free switching circuit is used to switch the clock for reading and writing data in the switching circuit and the clock corresponding to the first channel to the clock corresponding to the second channel.

7. The method according to claim 6, characterized in that If the clock corresponding to the first channel is different from the clock of the switching circuit; The step of switching the clock for reading and writing data in the switching circuit and the clock corresponding to the first channel to the clock corresponding to the second channel further includes: The clock of the memory is switched to a clock corresponding to the second channel.

8. A switching circuit, characterized in that: The switching circuit comprises: A switching module, configured to determine, when receiving a change in the path selection signal, whether the first module reads and writes service data of the memory using the first channel, wherein the clock corresponding to the first channel is the same as the clock of the switching circuit; A data processing module, used for discarding or pre-configuring the access data of the first channel according to preset rules based on the reading and writing status of the business data; A clock detection module, used to detect whether a clock corresponding to the first channel is the same as a clock corresponding to a second channel requested by the second module to access the memory; The switching module is also used to switch the switching circuit and the clock corresponding to the first channel to the clock corresponding to the second channel when the clock detection module detects that the clocks are different; and to switch the access channel from the first channel to the second channel so that the second module accesses the memory according to the clock corresponding to the second channel, and the access data of the first module in the first channel is discarded or pre-configured according to the preset rules.

9. The switching circuit according to claim 8, characterized in that: The switching circuit further includes a cache module, and the switching module includes a clock glitch-free switching circuit; The cache module is used to cache read data and / or write data during access to the memory through the first channel; The clock glitch-free switching circuit is used to switch the clock of the read and write data in the switching circuit and the clock corresponding to the first channel to the clock corresponding to the second channel after the read data and / or write data cached in the cache module are cleared.

10. A multi-channel memory switching system, characterized in that: The system comprises: a switching circuit, a memory and at least two modules, wherein the at least two modules comprise a first module and a second module; Wherein, the first module is connected to the switching circuit and the memory through a first channel, and the second module is connected to the switching circuit and the memory through a second channel; The first module is used to access the memory for reading and writing data through the first channel; The switching circuit is used to execute the memory switching method of multiple channels according to any one of claims 1 to 7; The second module is configured to access the memory according to a clock corresponding to the second channel when the switching circuit switches the access channel from the first channel to the second channel; The first module is further used to discard or pre-configure the access data of the first channel according to the preset rule.