Memory operation method, memory, and electronic device
By pre-reading the existing data at the next incrementing address in memory and using low-order address mapping, the problem of reduced memory read/write efficiency caused by unaligned writes is solved, and efficient memory operation under the read/write parallel protocol is achieved.
Patent Information
- Application Number
- CN202310171643.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-27
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-02-27
AI Technical Summary
In application scenarios where unaligned writes occur frequently, the read and write efficiency of existing memory is reduced due to additional read operations, especially during ECC encoding operations which require additional clock cycles, resulting in an overall performance degradation.
By pre-reading the existing data at the next incrementing address in the current clock cycle, the extra clock cycles required for unaligned writes are avoided. Low-bit address mapping is used to map consecutive logical addresses to different memory banks, and the write controller performs encoding operations in the next clock cycle, thus achieving efficient execution of the read-write parallel protocol.
It improves the execution efficiency of the memory's read-write parallel protocol, avoids the additional impact of unaligned writes on memory performance, ensures that prefetching operations and current write operations are performed on different memory banks, and reduces the impact of write request prefetching operations on regular read operations.
Smart Images

Figure CN118550850B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of storage, and more particularly to a memory operation method, a memory, and an electronic device. Background Technology
[0002] Improving memory read / write efficiency is a major direction for memory performance optimization. Compared to serial protocols (e.g., I2C) or parallel protocols (e.g., AHB or APB) where read and write operations can only be performed one at a time, parallel read / write protocols for memory (e.g., AXI) can further improve the interaction efficiency between the host and the memory.
[0003] However, for encoding operations such as ECC (Error Correction Code), if the memory needs to perform unaligned writes, the additional read operation will cause each unaligned write to require an extra clock cycle. In applications where unaligned writes occur frequently, unaligned writes that require two clock cycles to complete will reduce the overall read / write efficiency of the memory.
[0004] Therefore, a method is needed to improve the read and write efficiency of memory. Summary of the Invention
[0005] One technical problem this disclosure aims to solve is to provide a memory operation method, a memory, and an electronic device. This invention accelerates the next possible encoding operation by pre-reading the existing data corresponding to the next incrementing address in the current clock cycle, thereby improving the execution efficiency of a read-write parallel protocol.
[0006] According to a first aspect of this disclosure, a memory operation method is proposed, the memory following a read-write parallel protocol and comprising multiple memory banks, the method comprising: writing current data to be written to a designated location in a first memory bank corresponding to the current logical address of a write request in the current clock cycle via a write controller; pre-reading existing data at a designated location in a second memory bank corresponding to the next logical address of the write request via the write controller in the current clock cycle; and encoding the pre-read existing data and the next data to be written via an encoder when the write controller receives an instruction to encode the pre-read existing data in the next clock cycle; and...
[0007] The write controller writes the encoded data to a designated location in the second memory bank in the next clock cycle.
[0008] Optionally, the pre-reading of the original data at a specified location of the second memory bank corresponding to the next logical address of the write request by the write controller in the current clock cycle includes: sending an indication to the write controller whether the second memory bank is occupied in the current clock cycle by the read controller, so that the write controller can determine whether to perform the pre-reading in the current clock cycle.
[0009] Optionally, the pre-reading of the original data at a specified location of the second memory corresponding to the next logical address of the write request by the write controller in the current clock cycle includes: when the read controller instructs that no read request be made to the second memory in the current clock cycle, the pre-reading of the original data at a specified location of the second memory by the write controller in the current clock cycle.
[0010] Optionally, the method further includes: when the read controller instructs a read request to the second memory bank in the current clock cycle, and the write controller obtains the instruction that encoding based on the pre-read original data is required in the next clock cycle, then: the write controller reads the original data at a specified location in the second memory bank in the next clock cycle; and the encoder encodes the read original data and the next data to be written in the write request in the next clock cycle; and the write controller writes the encoded data to a specified location in the second memory bank in the next clock cycle.
[0011] Optionally, the pre-reading of the original data at a specified location of the second memory bank corresponding to the next logical address of the write request by the write controller in the current clock cycle further includes: sending an occupation indication to the read controller regarding whether the pre-reading of the second memory bank should be performed in the current clock cycle, so that the read controller can determine whether to delay the execution of the read operation of the current logical address of the read request in the current clock cycle.
[0012] Optionally, the method further includes: when the read address decoder maps the current logical address of the read request to the second memory bank in the current clock cycle, the read controller delays the read operation of the current logical address of the read request to the second memory bank based on the occupancy indication.
[0013] Optionally, the pre-read data is placed into the pre-read data buffer by the write controller in the current clock cycle, and retrieved from the pre-read data buffer by the encoder in the next clock cycle to be encoded with the next data to be written.
[0014] Optionally, when the current data to be written is the data to be written at the last logical address of the write request, the write controller does not perform the pre-read operation in the current clock cycle.
[0015] Optionally, when an indication is received in the next clock cycle that encoding is not based on the pre-read original data, the encoder encodes only the next data to be written.
[0016] Optionally, the method further includes: mapping consecutive read requests for logical addresses to different memory banks according to a predetermined transmission bit width using a read address decoder; mapping consecutive write requests for logical addresses to different memory banks according to the predetermined transmission bit width using a write address decoder; and arbitrating read requests and write requests mapped to the same memory bank in the current clock cycle using an arbitration circuit, wherein if a specific low address bit of the logical address is the same, then the read request and / or the write request is mapped to the same memory bank.
[0017] Optionally, each write request or read request is a transport transaction of the read-write parallel protocol. Each write request includes multiple write transfers, each write transfer corresponds to a different logical address and is used to write a copy of data to be written. Each read request includes multiple read transfers, each read transfer corresponds to a different logical address and is used to read a copy of data.
[0018] Optionally, the encoding is ECC encoding, and the encoder is an ECC encoder.
[0019] According to a second aspect of this disclosure, a memory is provided, wherein data access of the memory follows a read-write parallel protocol, and the memory includes: a plurality of memory banks; a write controller configured to: write current data to be written to a designated location in a first memory bank corresponding to the current logical address of a write request in the current clock cycle; pre-read existing data at a designated location in a second memory bank corresponding to the next logical address of the write request in the current clock cycle; a second memory bank; and an encoder configured to: encode the pre-read existing data and the next data to be written when an indication for encoding based on the pre-read existing data is obtained in the next clock cycle; and encode only the next data to be written when an indication for encoding not based on the pre-read existing data is obtained in the next clock cycle, wherein the write controller writes the encoded data to the designated location in the second memory bank in the next clock cycle.
[0020] Optionally, the memory further includes a read controller, configured to: send an indication to the write controller whether a read request is made to the second memory in the current clock cycle, so that the write controller can determine whether to perform the pre-read in the current clock cycle; or receive an indication from the write controller whether the pre-read is made to the second memory in the current clock cycle, and the read controller determines whether to delay the read operation of the current logical address of the read request in the current clock cycle based on the indication.
[0021] Optionally, the memory further includes a pre-read data cache for caching the original data to be pre-read.
[0022] Optionally, the memory further includes: a read address decoder for sequentially mapping read requests for consecutive logical addresses to different memory banks; a write address decoder for sequentially mapping write requests for consecutive logical addresses to different memory banks; and an arbitration circuit for arbitrating read requests and write requests mapped to the same memory bank in the current clock cycle, wherein if a specific low address bit of the logical address is the same, then the read request and / or the write request is mapped to the same memory bank.
[0023] Optionally, the arbitration circuit includes: a plurality of arbitration sub-circuits corresponding one-to-one with a plurality of memory banks, wherein each arbitration sub-circuit performs read / write arbitration on its corresponding memory bank for each read data transmission included in the read request or each write data transmission included in the write request.
[0024] Optionally, the indication of encoding based on pre-read existing data comes from a bus signal received by the write controller, the bus signal indicating that in the next clock cycle, the write request performs an unaligned write operation on the next logical address.
[0025] Optionally, the write controller increments the current logical address of the current clock cycle to obtain the next logical address for performing the pre-read.
[0026] According to a third aspect of this disclosure, an electronic device is proposed, comprising: a control unit; and a memory, wherein the control unit and the memory interact via a bus following a parallel read / write protocol, and the memory performs the operations described in the first aspect.
[0027] This invention avoids the extra clock cycle required for unaligned writes by pre-reading existing data within the next address. This approach is particularly suitable for memories that use specific low-address bit decoding to stagger the physical memory banks targeted by the read / write increment addresses, thereby ensuring that the pre-read operation and the current write operation are performed on different memory banks, and reducing the impact of the write request pre-read operation on the regular read operation through feedback from the read controller to the write controller (or vice versa). Attached Figure Description
[0028] The above and other objects, features and advantages of this disclosure will become more apparent from the more detailed description of exemplary embodiments thereof taken in conjunction with the accompanying drawings, wherein like reference numerals generally denote like parts.
[0029] Figure 1 An implementation example of a memory comprising multiple memory banks based on high-order address mapping is shown.
[0030] Figure 2 An example of a memory implementation according to the present invention, comprising multiple memory banks based on low-order address mapping, is shown.
[0031] Figure 3A -B shows examples of operations for aligned and unaligned writes, respectively.
[0032] Figure 4 A schematic flowchart of a memory operation method according to an embodiment of the present invention is shown.
[0033] Figure 5 A schematic diagram of a memory circuit according to an embodiment of the present invention is shown.
[0034] Figure 6 A schematic diagram of a memory circuit conforming to the AXI protocol according to an embodiment of the present invention is shown.
[0035] Figure 7A -B illustrates a channel diagram in the write and read transport transactions of the AXI protocol.
[0036] Figure 8 An example of a timing diagram for AXI parallel read / write operations including a read-ahead operation according to the present invention is shown.
[0037] Figure 9 An example of a timing diagram for AXI parallel read / write operations including a read-ahead operation according to the present invention is shown.
[0038] Figure 10 An example of a timing diagram for AXI parallel read / write operations including a read-ahead operation according to the present invention is shown.
[0039] Figure 11An example of a timing diagram for AXI parallel read / write operations including a read-ahead operation according to the present invention is shown. Detailed Implementation
[0040] Preferred embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While preferred embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that the present disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0041] A memory typically comprises multiple memory banks. For example, a 512k SRAM can be divided into four physical memory banks, i.e., four macros (corresponding to macros 0 to 3), with each macro having a storage capacity of 128k. Each memory bank can include multiple memory cells, and each memory cell can include multiple storage units (e.g., cells storing "0" or "1").
[0042] Figure 1 An implementation example is shown that includes multiple memory banks based on high-order address mapping. For example... Figure 1 As shown, the memory may include four memory banks macros 0 to 3, each with the same storage capacity, such as 128k (i.e., 128KB). Each memory bank may include multiple storage cells, such as the 64-bit (8-byte) storage cells shown in the figure, each storage cell may include 64 minimum storage units. The size of the storage cells in the memory can typically be set. In one embodiment, the memory communicates with the control unit (i.e., the bus master) via a bus following a read-write parallel protocol. Figure 1 (Not shown) In communication, the storage cell bit width of the memory bank can be set to correspond to the physical bus bit width of the bus. In other embodiments, each memory bank may be composed of n physical memory banks, then the physical bus bit width of the bus is n*64 bits.
[0043] It should be understood that in the read-write parallel protocol, the so-called read-write "parallelism" refers to different memory banks of the same memory. That is, it is allowed to perform a write operation on one memory bank while performing a read operation on another different memory bank at the same time, but it is not allowed to perform read and write operations on the same memory bank at the same time (for example, within one clock cycle) (because the same physical memory bank has only one physical access interface).
[0044] Figure 1The example shown uses high-data-bit address decoding. That is, the four macros 0 to 3 correspond to four consecutive logical address ranges. The high 16 bits of the address are represented in hexadecimal as 0x2000 (corresponding to the consecutive logical address range of 0x2000,0000 to 0x2000,ffff), 0x2001 (corresponding to the consecutive logical address range of 0x2001,0000 to 0x2001,ffff), 0x2002 (corresponding to the consecutive logical address range of 0x2002,0000 to 0x2002,ffff), and 0x2003 (corresponding to the consecutive logical address range of 0x2003,0000 to 0x2003,ffff).
[0045] Therefore, during high-order decoding, consecutive logical addresses (e.g., 8 consecutive logical addresses in the example below) correspond to the same macro. When a consecutive read operation occurs for these 8 consecutive logical addresses, the macro needs to be continuously occupied (e.g., occupied for 8 consecutive clock cycles). If a write request for the same macro occurs during this period, it is necessary to wait for the current read operation to finish, thereby reducing the overall parallel efficiency of the memory.
[0046] like Figure 1 As shown, a storage unit is 64 bits in size. Within each macro, consecutive physical addresses correspond to consecutive logical addresses (the smallest addressing unit for a logical address is usually one byte of data, while the storage unit above is 64 bits, or 8 bytes, so the actual interval between consecutive logical addresses is 8). The only difference is that the high 16 bits of the addresses corresponding to macros 0-3 are hexadecimal 0x2000, 0x2001, 0x2002, and 0x2003, respectively. That is, the high data bits [17:16] of the logical address are respectively... Figure 1 The binary numbers shown are 00, 01, 10, and 11.
[0047] When reading data “1…1; 2…2; 3…3; 4…4” from consecutive logical addresses (e.g., the lower 8 bits [7:0] represented in hexadecimal as 00, 08, 10, 18), as shown in the figure, the data occupies the first four memory cells of macro 0 to complete the read. Since the read-write parallel protocol allows simultaneous reads and writes to different memory banks of the same memory (e.g., writing to macro 0 while reading data from macro 2), but does not allow simultaneous reads and writes to the same memory bank, one of the read and write requests addressing the same memory bank simultaneously will be delayed. For example, while reading data "1…1; 2…2; 3…3; 4…4", if a request is made to write data "a…a; b…b; c…c (hexadecimal representation)" to an address within the same logical address range of 0x2000,0000 to 0x2000,ffff, a conflict will occur because both read and write operations need to be performed simultaneously on the same macro. This forces the write request to wait for the read operation to complete before writing the data. Assuming the memory completes one data transfer per clock cycle, if the read and write requests arrive simultaneously, the write request will have to wait at least four clock cycles (i.e., until the read operation completes) before writing the data "a…a; b…b; c…c" to the specified address on macro 0. If such read-write conflicts occur frequently, the overall read / write efficiency of the memory will be significantly reduced.
[0048] The above problem can be solved by using a specific low-address bit decoding method to map the incrementing address to different memory banks, so that concurrent read and write requests can be staggered and performed on different memory banks. Figure 2 An example memory implementation including multiple memory banks based on low-order address mapping is shown. For example... Figure 2 As shown, the memory can also include four memory banks macros 0 to 3, each with the same storage capacity, such as 128k (i.e., 128KB). Each memory bank also includes multiple storage cells, such as the 64-bit (i.e., 8-byte) storage cells shown in the figure. This memory and control unit ( Figure 2 (Not shown) The physical bus width of the communication bus is 64 bits, where the memory is the slave of the bus and the control unit is the master of the bus.
[0049] To align with the physical bit width of the aforementioned bus, consecutive logical address accesses are typically encoded with 8-byte intervals of data (the smallest addressing unit of a logical address is 1 byte of data). For example, the lower 8 bits of 8 consecutive logical addresses (each 4 bits represented by a hexadecimal number) are 0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, and 0x38 (0x represents hexadecimal). If the aforementioned logical addresses are represented in binary, then the lower 8 address bits [7:0] are: 0b'000 00 000, 0b '000 01 000, 0b '000 10 000, 0b '000 11 000, 0b '001 00 000, 0b'001 01 000, 0b '001 10 000, 0b '00111000( 0b (This represents binary).
[0050] When the memory uses specific low address bits for decoding, the four macros 0 to 3 no longer correspond to four consecutive logical address ranges respectively. Instead, the consecutive logical addresses are mapped sequentially to different memory banks with a predetermined transmission bit width (for example, the address interval in the figure is 8. Since the smallest addressing unit of a logical address is 1 byte of data, the interval between two consecutive logical addresses is 8 addressing units, so the corresponding data interval is 8 bytes of data, i.e., 64 bits of data).
[0051] Specifically, each of macros 0 to 3 has a capacity of 128k. However, within each macro, the logical addresses between adjacent physical addresses are no longer consecutive addresses spaced 8 addresses apart, but rather non-consecutive addresses spaced 32 addresses apart (predetermined transmission bit width 8 × number of memory blocks 4 = 32). In this case, when reading data “1…1; 2…2; 3…3; 4…4 (hexadecimal representation)” from a four-bit consecutive logical address (e.g., the lower 8 bits are represented in hexadecimal as bits 00, 08, 10, 18), the decoding of the lower data bits [4:3] in this embodiment is performed through specific address lower bits. Figure 2In the memory, macro 0 corresponds to "00", macro 1 corresponds to "01", macro 2 corresponds to "10", and macro 3 corresponds to "11", and macro 0, macro 1, macro 2, and macro 3 are addressed respectively. Therefore, when the memory receives a request to read 4 bytes of data starting from logical address 0000, the read channel can, for example, read "1…1" stored on macro 0 in the first clock cycle, "2…2" stored on macro 1 in the second clock cycle, "3…3" stored on macro 2 in the third clock cycle, and "4…4" stored on macro 3 in the fourth clock cycle. Thus, the data can be combined according to big-endian rules into "1…1; 2…2; 3…3; 4…4 (hexadecimal representation)" for reading.
[0052] At this point, if a request to read 4 bytes of data starting from logical address 00000 is received simultaneously with a request to write data to three memory locations starting from logical address ...0...00000 (corresponding to an address in the middle of macro 0), namely "a...a; b...b; c...c", then the read-write conflict can be resolved according to specific rules. For example, in a simple implementation, it can be specified that read always takes precedence, write always takes precedence, or read always takes precedence or write always takes precedence within a threshold waiting time range. In one embodiment, for read-write conflicts, an arbitration circuit can be used to arbitrate the conflict, and by delaying, for example, the write operation by one clock cycle (here, one clock cycle can be called a "clock"), subsequent read and write operations can proceed smoothly. For example, the arbitration circuit can arbitrate read requests and write requests for the same memory bank in the same clock cycle. For example, the arbitration circuit can arbitrate read requests first (or write requests in other arbitration rules), and delay the delayed write transmission in the write request by one clock cycle, thereby staggering subsequent read and write operations for different memory banks when the logical addresses of the read and write operations are consecutive. Therefore, the read data channel can still read "1…1" stored on macro 0 in the first clock cycle, "2…2" stored on macro 1 in the second clock cycle, "3…3" stored on macro 2 in the third clock cycle, and "4…4" stored on macro 3 in the fourth clock cycle; the write data channel can write "a…a" to macro 0 in the second clock cycle, "b…b" to macro 1 in the third clock cycle, and "c…c" to macro 2 in the fourth clock cycle, after a one-clock-clock delay in the first clock cycle. Thus, efficient read-write parallelism is achieved by delaying the write request by one clock cycle (i.e., data read and write operations are performed simultaneously on different macros during the second to fourth clock cycles). Of course, it should be understood that if a request to read data from 4 memory cells starting from logical address 00000 is received at the same time as a request to write data to 2 memory cells starting from logical address ...1...01000, “b...b;c...c”, then no delay operation is required because there is no situation where the same clock cycle is used to read or write data to the same memory cell.
[0053] It is worth noting that the aforementioned embodiments all use a "predetermined transmission bit width" of 64 bits as an example. In other embodiments, other "predetermined transmission bit widths" can also be used, such as 32 bits (assuming the bus physical bit width is 32 bits = 4 bytes). Then the data interval between two consecutive logical addresses is 4 bytes of data, that is, the interval between two consecutive logical addresses is 4 addressing units (assuming the addressing unit of the logical address is still 1 byte of data). Then the "specific address low bit" is the address low data bit [3:2] (assuming the memory still includes 4 memory banks).
[0054] In ECC-enabled memories, ECC re-encoding is required due to non-aligned write data, necessitating a read-modify-write operation. Since this read-modify-write operation requires reading the original data at the write address, it takes at least two clock cycles to complete.
[0055] In AXI data transmission, when the data bit width in this transmission is smaller than the data bit width of the channel itself, it is called narrow bit width data transmission, or narrow transmission. In narrow bit width write transmission (i.e., in unaligned write), the master needs to inform the slave which bytes in the data channel are valid, which requires the use of the WSTRB signal in the write data channel. A single bit in the WSTRB signal being set indicates that the byte at the corresponding position is valid. For example, in an implementation that transmits 64 bits per cycle (i.e., 8 bytes), the WSTRB signal corresponds to 8 bits, and the value of the corresponding bit is used to indicate the validity of the corresponding byte. For example, a WSTRB signal value of ff indicates an aligned write where all 8 bytes are valid, and a value of 0f indicates that the first 4 bytes of the currently written 8 bytes are invalid. In read transmission, the slave's operating logic is the same as the master's in write transmission, but the slave does not have a signal similar to WSTRB.
[0056] For ease of understanding, Figure 3A -B illustrates examples of aligned and unaligned write operations. To avoid overcomplication, the diagram shows an example of writing 64-bit data in hexadecimal. The data to be written, "aaaaaaaaaaaaaaaaa", actually corresponds to the 64-bit binary data "1010…1010", while the existing data "00000000000000000" corresponds to the 64-bit binary data "0000…0000".
[0057] Specifically, Figure 3AAn example of aligned write is shown. In protocols such as AXI, Wstrb is used to indicate the validity of transmitted data. Here, wstrb = ff (i.e., wstrb = ob'11111111) indicates that all 8 bytes (i.e., 64 bits) of data are valid. In this case, there is no need to care about the value of the original data; the 64-bit binary data "1010…1010" is directly written, and the written data is used for ECC encoding.
[0058] Figure 3B This corresponds to the example of unaligned write. In this case, since wstrb ≠ ff (wstrb = 0f = ob'00001111), it indicates an unaligned write, meaning that only the last 32 bits of the transmitted 64-bit binary data "1010…1010" are valid (in other embodiments, only 32 bits of data can be transmitted). In this case, in order to perform overall ECC encoding on the 64-bit data, an additional clock cycle is needed to read the original data, i.e., the 64-bit binary data "0000…0000" ((in other embodiments, only the first 32 bits of data can be read)). Subsequently, the original data and the data to be written can be concatenated to form "000000000aaaaaaaa" (i.e., the 64-bit binary data "0000…00001010…1010"), and the data is written and ECC encoded in the next cycle.
[0059] In applications where unaligned writes are frequent, the aforementioned unaligned writes, which require two clock cycles to complete, reduce memory read / write efficiency. Therefore, this invention proposes a method to improve memory read / write efficiency by pre-reading the next incrementing address in the current clock cycle to accelerate the next possible encoding operation that requires additional rewriting, thereby improving the execution efficiency of the read / write parallel protocol. In this invention, completing the unaligned write encoding operation still requires two clock cycles, but since the reading of the original data and the writing to the previous logical address occur simultaneously (or the write operation to the current logical address and the reading of the original data at the next logical address occur simultaneously), unaligned writes (especially unaligned writes that are not at the beginning of the write request) no longer require an additional clock cycle for reading the original data, but only occupy one clock cycle. Furthermore, to achieve pre-reading of the original data corresponding to the next logical address in the current write cycle, the incrementing address and the current address need to be located in different memory banks. Figure 1 The high-order address mapping of consecutive logical addresses in the same memory bank, as shown, cannot implement the incremental address prefetching operation proposed in this application, but instead adopts... Figure 2The memory with the shown low-order address mapping can implement the incremental address prefetching scheme of the present invention. Furthermore, it should be understood that, in addition to addressing schemes that map low-order addresses to different memory banks, memories employing other addressing schemes with incremental addresses located on different memory banks can also implement the incremental address prefetching scheme of the present invention. For example, as long as prefetching and writing to different memory banks can be performed in the same cycle, the prefetching scheme of the present invention can also be used for addressing schemes that map high-order addresses to different memory banks.
[0060] Figure 4 A schematic flowchart of a memory operation method according to an embodiment of the present invention is shown. The memory capable of implementing the memory operation method of the present invention follows a read-write parallel protocol (e.g., the AXI protocol, which will be detailed below) and includes multiple memory banks.
[0061] In step S410, the write controller writes the data to be written to the specified location of the first memory bank corresponding to the current logical address of the write request in the current clock cycle. In step S420, the write controller pre-reads the existing data at the specified location of the second memory bank corresponding to the next logical address of the write request in the current clock cycle.
[0062] Although two steps, S410 and S420, are used here to represent two operations within one clock cycle, namely, the write operation to the current logical address and the read-ahead operation to the next incrementing logical address, it should be understood that these two operations are actually performed within the same clock cycle. Furthermore, since the current logical address and the next logical address correspond to different memory banks (e.g., the memory uses...),... Figure 2 (As shown in the low-order address mapping), therefore write and read-ahead operations occurring within the same clock cycle will not conflict. Furthermore, although "first" and "second" memory banks are used here to distinguish different memory banks, it should be understood that "first" and "second" memory banks here are only used to represent one memory and one memory bank respectively performing write and read-ahead operations within the same clock cycle.
[0063] Subsequently, in step S430, when the write controller receives an indication in the next clock cycle that encoding based on the pre-read original data is required (e.g., when wstrb≠ff is read in that clock cycle, i.e., non-aligned write), the pre-read original data and the next data to be written can be encoded by an encoder (e.g., an ECC encoder). Figure 3B(The original data and the data to be written are encoded as a whole, as shown in step S440). Simultaneously, in step S440, the write controller writes the encoded data to a specified location in the second memory bank in the next clock cycle. Since the data originally stored in that specified location has already been read in step S420, the write controller can directly complete the writing of the next logical address content in the next cycle after step S410 without waiting for an additional clock cycle.
[0064] It should be understood that during the prefetch of existing data in step S420, the write controller is unaware of whether an unaligned write will occur in the next clock cycle (this is because the wstrb signal for the write operation to the next logical address needs to arrive in the next clock cycle). Therefore, as long as the prefetch function is enabled, the memory implementing the present invention will accelerate the next potentially unaligned write by prefetching the next incrementing address in a parallel read / write structure. Of course, if the next write is an aligned write, this prefetch is useless and will generate unnecessary power consumption. However, although the prefetch scheme generates unnecessary dynamic power consumption and circuit overhead, it is still acceptable compared to the performance improvement.
[0065] Specifically, if the pre-read in step S420 has been performed, and the next clock cycle corresponds to an unaligned write (received wstrb ≠ ff, for example, wstrb = 0f), the existing data read in step S420 can be used to encode the data to be written together with the data to be written in step S430. However, if the next clock cycle corresponds to a normal write (for example, received wstrb = ff), the existing data read in step S420 can be ignored, and data writing can be performed directly without involving the encoding of the existing data. The latter case corresponds to: when an indication is obtained in the next clock cycle that encoding is not based on the pre-read existing data, the encoder only encodes the next data to be written.
[0066] Here, the encoder that needs to encode the pre-read original data during non-aligned writes can be an ECC encoder, and the encoding mentioned in step S430 can be ECC encoding. In the case of ECC encoding, the encoding in step S430 can be used to encode 8 bytes of data to generate an additional ECC code, for example, 8 bytes of data generate 1 byte of ECC checksum, and then all 9 bytes of data are written to the target memory. Thus, Figure 6The internal WDATA[63:0] shown is actually a 9-byte wide WDATA[71:0], and the read data is also 9 bytes wide, i.e., RDATA[71:0]. However, of the 9 bytes of data written and read, only 8 bytes are the target data to be written or read, and the other byte is verification data used to verify the correctness of the accessed data. In other embodiments of the present invention, the pre-read original data can also be used for other encodings besides ECC, such as CRC or Parity's overall encoding algorithm.
[0067] Furthermore, since the original data stored in the incrementing address of the current cycle's prefetch needs to be used for encoding (e.g., ECC encoding) in the next cycle during non-aligned writes, enabling the prefetch function of this invention requires setting up an additional prefetch data buffer. Thus, the original prefetch data is placed into the prefetch data buffer by the write controller in the current clock cycle and retrieved from the prefetch data buffer by the encoder in the next clock cycle. Since prefetching is performed under the control of the write controller, in a preferred embodiment, the prefetch data buffer can be located within the write controller (as described below). Figure 5 The cache shown is 5222).
[0068] Furthermore, since the prefetch scheme of the present invention is implemented under a read-write parallel protocol, the prefetch scheme of the present invention preferably needs to include a dispute resolution mechanism when a prefetch conflictes with a normal memory read operation. In one embodiment, a read-priority scheme can be adopted. In this case, the read controller can inform the write controller of the memory bank corresponding to the current cycle of the read operation. If there is a conflict with the prefetch operation, the prefetch operation will be delayed. Specifically, the read controller can send an indication to the write controller indicating whether a read request for the second memory bank is required in the current clock cycle, so that the write controller can determine whether to perform the prefetch in the current clock cycle. In another embodiment, a prefetch-priority scheme can be adopted. In this case, the write controller can inform the read controller of the memory bank corresponding to the prefetch in the current cycle. If there is a conflict with a normal read operation, the read operation will be delayed. Specifically, the write controller can send an indication to the read controller indicating whether a prefetch request for the second memory bank is required in the current clock cycle, so that the read controller can determine whether to perform the read operation in the current clock cycle.
[0069] Furthermore, as mentioned earlier, the prerequisite for read-ahead operation is that the incrementing address of the write operation corresponds to different memory banks. Therefore, the memory implementing the read-ahead scheme of this invention preferably uses low-order address mapping to ensure that the next write address is located in a different memory bank. Even so, conflicts between write and read operations can still occur, so the memory operation scheme also needs to include solutions for read-write conflicts. Although, as mentioned earlier, a simple read or write priority rule can be used to resolve conflicts, in a preferred embodiment, an arbitration circuit can be introduced to arbitrate read conflicts.
[0070] To facilitate understanding of the present invention, the pre-read scheme and read / write arbitration principle of the present invention will be described below in conjunction with a memory module diagram.
[0071] Figure 5 A schematic diagram of a memory circuit according to an embodiment of the present invention is shown. The memory circuit 500 may include a plurality of memory banks 510, corresponding to macros 0 to 3 shown in the figure, and the data access of the memory circuit 500 follows a read-write parallel protocol, such as the AXI protocol.
[0072] The memory circuit 500 may include a control circuit 520 and an address decoding circuit 530. The control circuit 520 is used to control reading and writing, while the address decoding circuit 530 is used to address the control signals to the physical address corresponding to the logical address.
[0073] Specifically, the control circuit 520 includes a read controller 521 and a write controller 522. The read controller 521 sends read control signals to the memory bank 510, while the write controller 522 sends write control signals and the data to be written to the memory bank 510. To achieve parallel read and write operations, the address decoding circuit 530 may include a read address decoder 531 and a write address decoder 532. Figure 2 During the low-order address mapping shown, the read address decoder 531 is used to sequentially map consecutive read requests for logical addresses from the read controller 521 to different memory banks according to a predetermined transmission bit width. Correspondingly, the write address decoder 532 is used to sequentially map consecutive write requests for logical addresses from the write controller 522 to different memory banks according to the predetermined transmission bit width.
[0074] If a specific low address bit of the logical address is the same, the read request and / or the write request are mapped to the same memory bank. In this case, the memory circuit 500 also needs to include an arbitration circuit 540 for arbitrating read and write data transfers for the same memory bank during the same clock cycle. The arbitration circuit 540 can be connected between the address decoding circuit 530 and the memory bank 510, and arbitrates whether read or write priority is given before sending the read or write request output by the address decoding circuit 530 to a specific memory bank.
[0075] To implement ECC encoding, an additional ECC encoder is required. Since the ECC encoder is typically located inside the write controller 522, it is shown as encoder 5221 in the figure. If the ECC encoder is located outside the write controller 522, it needs to be able to communicate with the write controller 522 to perform ECC encoding on the data to be written. Furthermore, since during non-aligned writes, the existing data stored in the incrementing address of the current cycle's prefetch needs to be used for encoding (e.g., ECC encoding) in the next cycle, enabling the prefetch function of this invention requires setting up an additional prefetch data cache. Since prefetching is performed under the control of the write controller, in a preferred embodiment, the prefetch data cache 5222 can be as follows: Figure 5 The example shown is located within the write controller 522. Of course, it can also be located in other locations, and the invention is not limited to this.
[0076] The write controller 522 can be used to: write the currently to-be-written data to a specified location in the first memory bank corresponding to the current logical address of the write request in the current clock cycle; and pre-read the existing data at a specified location in the second memory bank corresponding to the next logical address of the write request in the current clock cycle. Thus, the pre-read existing data can be placed into the pre-read data buffer 5222 by the write controller 522 in the current clock cycle and retrieved by the ECC encoder 5221 in the next clock cycle. Therefore, the ECC encoder 5221 can construct the actual data stored at the corresponding address based on the to-be-written data and the existing data, and thereby calculate the error correction code. Thus, the write controller 522 can write the encoded data to the specified location in the second memory bank in the next clock cycle.
[0077] The indication, encoded based on the pre-read existing data, comes from a bus signal received by the write controller. This bus signal indicates that, in the next clock cycle, the write request will perform an unaligned write operation to the next logical address. The write controller then increments the current logical address in the current clock cycle to obtain the next logical address for which the pre-read will be performed.
[0078] It should be understood that, although Figure 5 The illustration shows an example where the encoder is an ECC encoder 5221 located inside the write controller, and the prefetch data cache is a prefetch data cache 5222 located inside the write controller 522. However, in other embodiments, the encoder may perform encoding other than error correction code encoding, and the encoder and the prefetch data cache may be located outside the write controller 522.
[0079] In the illustrated example, the arbitration circuit 540 includes multiple arbitration sub-circuits corresponding one-to-one with multiple memory banks, namely, Arbiter 0 (arbiter 0) for arbitrating read and write access to macro 0, Arbiter 1 for arbitrating read and write access to macro 1, Arbiter 2 for arbitrating read and write access to macro 2, and Arbiter 3 for arbitrating read and write access to macro 3, as shown in the figure.
[0080] For example, when Arbiter 0 receives both a read request from read address decoder 521 and a write address decoder 522 for macro 0 during the current clock cycle, Arbiter 0 can arbitrate whether macro 0 should perform a read data transfer or a write data transfer during the current clock cycle according to a predetermined arbitration rule. As shown in the figure, if the arbitration result is to perform a read data transfer, Arbiter 0 sends RD0-ack to macro 0, i.e., a read data transfer notification for macro 0; and if the arbitration result is to perform a write data transfer, Arbiter 0 sends WR0-ack to macro 0, i.e., a write data transfer notification for macro 0. Similarly, Arbiters 1 to 3 can each send RD-ack or WR-ack to macros 1 to 3 to inform them of the arbitration result.
[0081] Therefore, based on the arbitration result, read or write data transfer operations can be performed directly on the memory bank in the current clock cycle. In the implementation using RD-ack or WR-ack to inform of the arbitration result, the memory bank receiving the RD-ack, such as macro 1 of the memory bank receiving RD-ack 1, can select the read control signal sent by the read controller 521, and the memory bank receiving the WR-ack, such as macro 0 of the memory bank receiving RD-ack 0, can select the write control signal sent by the write controller 522 and write data. Thus, parallel data reading and writing (for different memory banks) can be completed in the current clock cycle.
[0082] To ensure that requests delayed based on arbitration results can be executed normally, the arbitration result needs to be notified to the control circuit 520, allowing the delayed requests to be transmitted in the next predetermined transmission bit width time (typically the next clock cycle). Therefore, when the arbitration circuit 550 arbitrates the priority of a read or write request for a memory bank in the current clock cycle, the arbitration circuit 550 can notify the control circuit 520 of the arbitration result. This notification can be made only to the read controller or write controller corresponding to the non-prioritized request, or to both. Accordingly, the read controller or write controller corresponding to the non-prioritized request will retransmit the non-prioritized request in the next clock cycle. For example, if there are both read and write requests for macro0 in the current clock cycle, Arbiter 0 sends RD0-ack to macro 0, and macro 0 receives the read control signal from the read controller 521 and performs the read operation. At the same time, the RD0-ack can be sent to the write controller 522, so that the write controller 522 knows that the write control signal and write data sent to macro 0 in the current clock cycle have not been processed by macro 0. Therefore, in the next clock cycle, the write controller 522 can repeatedly send the write control signal and write data that were delayed in the current cycle.
[0083] The arbitration circuit can arbitrate according to predetermined arbitration rules. For example, since write operations may involve delays, when there are read and write requests for the same memory bank in the current clock cycle, the arbitration circuit will arbitrate the read request first.
[0084] Furthermore, to prevent excessive delays for any particular request, when read and write requests for the same memory bank exist in the current clock cycle, the arbitration circuit prioritizes requests of a different category than the data transmission operation in the previous clock cycle. For example, if the arbitration subcircuit for a particular memory bank did not perform a read / write decision in the previous clock cycle, it can prioritize read requests in the current clock cycle; however, if a read / write decision was performed in the previous clock cycle, it will not simply prioritize read requests in the current clock cycle, but will prioritize requests of a different category than those previously prioritized. That is, if the arbitration subcircuit performed a write operation in the previous clock cycle, it will perform a read operation in the current clock cycle; if the arbitration subcircuit performed a read operation in the previous clock cycle, it will perform a write operation in the current clock cycle. In some embodiments, the arbitration subcircuit can also arbitrate individual read or write requests. For example, if only a read request is received, the arbitration subcircuit performs a read operation and sends an RD-ack; if only a write request is received, the arbitration subcircuit performs a write operation and sends a WR-ack.
[0085] The above arbitration rules are particularly suitable for situations where arbitration is performed at a finer granularity. For example, in the AXI protocol, arbitration is performed once for each transfer, thereby maximizing the parallelism of read and write operations.
[0086] To further explain the principles of this invention, Figure 6 The illustrated memory circuitry conforms to the AXI protocol. Furthermore, memory circuitry 600 also shows a sub-controller 670 connected between the control circuitry and the memory bank, and a multiplexing circuit (MUX) 680 (ECC encoder and...) Figure 6 (Not shown in the diagram). The sub-control circuit 680 includes multiple sub-controllers 0 to 3, each of which controls the writing and reading of data from a memory bank.
[0087] The AXI bus connects the master and slave devices. In this invention, the memory circuit acts as a slave in the AXI protocol, receiving instructions from the master (e.g., a CPU / DMA controller or other module that needs to access memory 500) to perform data read or write operations. The AXI bus has five independent channels: write address (AXIWADDR), write data (AXIWDATA), write reply (AXIWRESP), read address (AXIRADDR), and read data (AXIRDATA). The write address, write data, and write reply channels can interact with the write controller 622 in the control circuit 620, while the read address and read data channels interact with the read controller 621 in the control circuit 620. Each channel is a bidirectional signal supporting handshake.
[0088] These five channels operate independently but share a common VALID / READY handshake mechanism for information transmission. The VALID / READY mechanism is a bidirectional flow control mechanism that allows both the sender and receiver to control the transmission rate. In the handshake, the two communicating parties act as the sender (Source) and receiver (Destination), respectively, and their operations differ. The sender sets the VALID signal high to indicate that it has prepared data, address, or control information and is holding it on the message bus. The receiver sets the READY signal high to indicate that it is ready to receive data. When both parties' VALID / READY signals are high simultaneously, a data transmission is completed on the rising edge of the clock ACLK. After all data transmissions are complete, both parties simultaneously set their signals low.
[0089] The unit of information exchange between the master and slave is a transmission transaction (also known as a "transaction"). Figure 7A -B illustrates a channel diagram for write and read transfer transactions in the AXI protocol. The host interface 1 in the diagram could be, for example, an interface where a CPU is connected to a bus, and the slave interface 2 could be an interface where a memory circuit is connected to a bus.
[0090] first Figure 7A This illustrates the operations on three channels during a write transfer transaction. For example... Figure 7A As shown, the master first informs the slave of the characteristics of this transfer transaction on the write address (WADDR) channel, including the write address of the data to be written and control information. Subsequently, the master can write data to the slave on the write data (WDATA) channel. A single transfer transaction may include multiple data transfers, corresponding to multiple write data frames in the figure.
[0091] After receiving all the write data for this transmission transaction, the slave device sends a response to the master device via the Write Reply (WRESP) channel. The master device uses the receipt of the slave device's response signal as a marker of the end of this transmission transaction. The write reply is for the entire transmission transaction, not for each individual data transmission. Writing data typically occurs after writing the address, but the AXI protocol allows writing data first or writing data and the address in the same clock cycle.
[0092] Figure 7B This illustrates the operations on two channels during a read transfer transaction. For example... Figure 7B As shown, the host writes the address of the data to be read in this transmission transaction and control information to the read address (RADDR) channel. After receiving the address, the slave transmits the data at that address to the host through the read data (RDATA) channel. It should be understood that the read address (RADDR) channel is actually still written by the host, except that it is the address of the data to be read that is written.
[0093] Since the data transmission direction of the read data channel is from slave to master, the slave can directly use the read data channel to make a read reply after the read operation is completed, so a separate read reply channel is not needed.
[0094] In the field of data transmission, Burst refers to a transmission mode that continuously transmits multiple (addressed adjacent) data items over a period of time. Two AXI components ( Figure 7A The interactions between the master and slave (shown in -B) to transfer a set of data are called an AXI transfer transaction. In an AXI transfer transaction, data is organized in bursts. A single burst can contain one or more data transfers. Each data transfer, because it uses one clock cycle, is also called a beat. After both parties have signaled readiness, one data transfer is completed per cycle; therefore, an AXI transfer is also called an AXI beat.
[0095] When the memory circuit of the present invention performs data transmission using the AXI protocol, the predetermined transmission bit width can be set to the size of data that can be transmitted in a data transmission, for example, 8 bytes, i.e., 64 bits.
[0096] In a burst transfer, the host can write information such as the starting address and the length of the burst. The slave device, starting from the starting address, sequentially receives write data transmitted by the host, or reads data from consecutive addresses and transmits it to the host as read data. Therefore, as... Figure 7A and 7B As shown, a single transmission transaction includes one address and control message and multiple data transfers.
[0097] During the entire transmission transaction, the master first transmits the control information for the upcoming burst transmission, along with the address of the first byte of data, to the slave. This address is called the start address. During subsequent transmissions within this burst, the slave calculates the addresses of subsequent data based on the control information. The control information and the start address are transmitted via the read / write address channel.
[0098] The control information transmitted in the address channel includes three burst transmission-related signals (the same for both read and write address channels; here we will use the burst transmission-related signals in the read address channel as an example).
[0099] (1) Burst length: refers to the number of data transfers contained in a single burst, controlled by the AxLen signal in the protocol. The AxLen signal in the protocol starts from zero, and the actual length value is AxLen+1.
[0100] (2) Burst size: refers to the data bit width during transmission, specifically the number of bytes of data transmitted per cycle, controlled by the AXSIZE signal in the protocol. The burst data width cannot exceed the bit width of the data bus itself.
[0101] (3) Burst transmission type (AxBURST), which has three types: FIXED, INCR, and WRAP. It is represented using 2 bits.
[0102] The FIXED type is suitable for FIFO and cache applications. This invention uses the most commonly used INCR and WRAP types. In INCR and WRAP types, the address of subsequent data is incremented based on the initial address, and the increment is usually set to be the same as the transmission width (WRAP type will loop back if it exceeds the boundary).
[0103] To achieve efficient data access under the AXI protocol, the memory circuit of this invention can set the predetermined transmission bit width to be the same as the data unit that can be transmitted in a single AXI data transmission, i.e., the same as the maximum number of data bits that can be transmitted in a single AXI data transmission (considering the possibility of narrow bit width transmission). The arbitration circuit can then arbitrate read / write access for each memory bank in each AXI data transmission. This transforms the host's access to consecutive logical addresses into reading different memory banks one by one. In the following example of this invention, it can be assumed that one AXI data transmission corresponds to a 64-bit (i.e., 8-byte) signal for one memory cell, i.e., the same as the predetermined transmission bit width.
[0104] Because under the AXI protocol, read or write instructions from the host indicate the logical address to be accessed in the form of starting address + length, the address decoder can first determine the macro to be accessed by the target low address bit of the starting address, and then perform address decoding by accessing different transfers one by one incrementally.
[0105] For example, when the slave receives a command from the WADDR channel with a starting address of [4:3] of 10 (corresponding to Marco 2) and control information including INCR 4 (i.e., the burst transfer type is write address increment and includes 4 transfers), the decoder can decode according to the starting address [4:3] and increment the memory corresponding to the subsequent transfers one by one, so that the first transfer corresponds to Marco 2, the second transfer corresponds to Marco 3, the third transfer corresponds to Marco 0, and the fourth transfer corresponds to Marco 1.
[0106] Furthermore, since the write address was not known beforehand, the pre-read operation of this invention cannot be performed on the first transfer. However, when writing to the first transfer, since the mapping rule of the incrementing address already indicates that the second transfer corresponds to Marco 3, pre-reading can be performed simultaneously on Marco 3; while writing to the second transfer on Marco 3, pre-reading is performed on Marco 0; while writing to the third transfer on Marco 0, pre-reading is performed on Marco 1. Since the transfer transaction ends after the fourth transfer, no pre-reading is performed while writing to the fourth transfer on Marco 1.
[0107] A write address decoder can be implemented as Figure 6The write transfer request decoder 632 shown is used to decode the write request for each transfer. To this end, the write address decoder can map consecutive logically addressed write requests to different memory banks with a predetermined transfer bit width. This can include: the write transfer request decoder 632 determining the initial memory bank to be accessed based on the value of a specific low-address bit of the starting address in the write request, and incrementally determining the memory banks to be accessed for subsequent transfers based on the transfer length information of the write request. Similarly, the read address decoder can be implemented as follows: Figure 6 The read transfer request decoder 631 shown is used to decode read requests for each transfer. To this end, the read address decoder can map consecutive read requests with logical addresses to different memory banks sequentially with a predetermined transmission bit width. This can include: the read transfer request decoder 631 determining the initial memory bank to be accessed based on the value of a specific low-address bit of the starting address in the read request, and incrementally determining the memory banks to be accessed for subsequent transfers based on the transmission length information of the read request. Thus, the memory circuit of the present invention, through an address mapping strategy that alternately maps consecutive logical addresses to multiple memory banks in units of the data size that can be transmitted in a single data transfer, achieves staggered read and write operations for different memory banks during bursty transactions involving multiple data transfers.
[0108] The memory circuit 600 is particularly well-suited for implementation as an on-chip SRAM. Figure 6 The modules 620, 630, 640, 670, and 680 shown can be considered as control circuits for the on-chip SRAM. The numbers 0-3 in the signals MEM_SEL[3:0], MEM_WE[3:0], MEM_ADDR[3:0], and MEM_WDATA[3:0] on the right side of sub-controller circuit 670 represent four sub-controllers 0-3, all of which are signals conforming to the SRAM read / write interface timing. These signals are sent by the sub-controllers to the corresponding memory banks (i.e., microcontrollers 0-3) to enable efficient read / write operations under the control of read / write control circuit 540 and arbitration circuit 530. The MUX680 can multiplex the read data returned by memory modules 0-3 (the data returned by 0-3 correspond to RDATA_0[63:0], RDATA_1[63:0], RDATA_2[63:0], and RDATA_3[63:0] in the diagram, respectively) (because at most one MAC operation is performed per clock cycle), and return it to the read controller 621. The read controller 621 can then return the read data to the host (using...). Figure 6 (Channels other than the five AXI channels shown on the left).
[0109] The AXI protocol supports address-unaligned transmissions, allowing the first byte address of a burst transmission (i.e., the starting address) to be misaligned with the burst transmission width. To address this, padding data can be added to the first data transmission to bring it into alignment. This padding data is marked as invalid using the WSTRB signal.
[0110] Therefore, in one effective embodiment, the memory operation method of the present invention (preferably a memory access management method) decodes by aligning the lowest two bits of the address after 64 bits, i.e., addr[4:3], thereby enabling simultaneous access to consecutive read and write addresses. If the read and write addresses are not consecutive and the lowest two bits of the address after 64 bits do not conflict, they can be accessed in parallel. If there is an address conflict, the read is usually not affected, and the write can be accessed in parallel with the read after being blocked for one cycle.
[0111] Figure 6 The smallest unit of arbitration for each arbitration subunit shown is a data transfer; that is, arbitration is performed for each transfer. In one embodiment, arbitration can be based on the following arbitration rules:
[0112] If there was no read / write response in the previous cycle, then if there is a read / write transfer request in this cycle, the read / write transfer request will be responded to.
[0113] If there was no read / write response in the previous cycle, then if there is a read / write transfer request in this cycle, the read / transfer request will be responded to.
[0114] • If the previous read has already been responded to, this write transfer has higher priority; similarly,
[0115] If the previous write transfer has been responded to, this read transfer has higher priority.
[0116] Furthermore, since this invention relates to a read-ahead scheme, in addition to read-write arbitration, a dispute resolution mechanism is needed to address conflicts between read-ahead operations and normal memory read operations. In one embodiment, a read-priority scheme can be adopted. In this case, the read controller informs the write controller of the memory bank corresponding to the current read operation cycle; if a conflict exists with a read-ahead operation, the read-ahead operation will be delayed. In another embodiment, a read-ahead-priority scheme can be adopted. In this case, the write controller informs the read controller of the memory bank corresponding to the read-ahead operation in the current cycle; if a conflict exists with a normal read operation, the read operation will be delayed.
[0117] In other words, the read controller in the memory implementing the pre-read scheme of the present invention can be used to: send an indication to the write controller whether the current clock cycle is used to request the occupancy of the other memory bank, so that the write controller can determine whether to perform the pre-read in the current clock cycle (corresponding to read priority); or receive the indication sent by the write controller whether the current clock cycle is used to request the pre-read occupancy of the other memory bank, and determine whether to delay the read operation of the current logical address of the read request in the current clock cycle (corresponding to pre-read priority) based on the occupancy indication.
[0118] The following will be combined with AXI timing. Figure 8-11 Different embodiments of the present invention are described below.
[0119] Figure 8 An example timing diagram for AXI parallel read / write operations, including prefetching, according to the present invention is shown. Figure 8 In the example, when there is a conflict between pre-reading and reading, the reading takes priority.
[0120] When the AXI write channel (WADDR) receives an INCR4 instruction (i.e., write data to 4 consecutive logical address cells starting from the specified starting address, i.e., the current transaction includes 4 write transfers), the AXI read channel (RADDR) receives an INCR3 instruction (similarly, the current transaction includes 3 read transfers).
[0121] The clock indicates the bus clock. As shown in the figure, write requests arrive before read requests. The master (e.g., CPU) gives the awvalid signal on the write address channel (WADDR channel), and the slave (e.g., the memory of this invention) gives the awready signal on the write address channel. Both are high at the same time (on the rising edge of the 3rd clock cycle) to indicate that the write address channel handshake is successful. Since the memory pulls wvalid high to indicate that the write data is ready and the master also goes high on wready on the 3rd clock cycle, the handshake of the write data channel (WDATA) is completed simultaneously on the rising edge of the 3rd clock cycle. At the same time, on the 3rd clock cycle, the write address decoder addresses to Marco 0 according to the value of awaddr[4:3] being 00 (according to the addressing rules, this means that the burst_awaddr[4:3] corresponding to the first transfer is 00, and the burst_awaddr[4:3] corresponding to the last three transfers are 01, 10 and 11 respectively).
[0122] AXI write requests are "aligned writes" in 64-bit units by default, corresponding to wstrb being ff. When wstrb is any other value, it indicates that only a portion of the currently transmitted 64 bits (8 bytes) of data is valid. The write transaction shown in the diagram includes four write transfers, all of which are unaligned writes. The first transfer corresponds to wstrb 0f, indicating that the last 4 bytes are valid, meaning only the lower 4 bytes need to be rewritten; the following three transfers correspond to wstrb f0, indicating that the first 4 bytes are valid, meaning only the upper 4 bytes need to be rewritten.
[0123] When the memory has ECC functionality, ECC encoding only modifies a few bits, but the entire 64 bits need to be re-encoded, requiring a read-modify-write cycle. If wstrb is an unaligned write, because the macro port is serial and cannot be read and written simultaneously, an extra clock cycle is required in existing technologies for processing. However, in the implementation of this invention, pre-reading can be performed on transfers other than the first transfer, making the unaligned write effectively a single clock cycle.
[0124] As shown in the figure, data transmission begins after the two channels successfully handshake in the third cycle. However, since the wstrb value in the third cycle is 0f, indicating that the first transfer is an unaligned write, wready is pulled low in the fourth cycle (because it is the first transfer, pre-reading cannot be performed). The data for the first transfer is written through a regular two-cycle read-modify-write operation (burst_awaddr[4:3] is 00, that is, it is addressed on macro 0; although the pre-read address burst_awaddr_preread[4:3] is also 00 at this time, "pre-reading" is not performed at this time), and the transmission for the second transfer in INCR4 is performed in the fifth cycle.
[0125] However, while writing the first transfer data on Marco 0 for burst_awaddr[4:3] which is 00 in the 4th cycle, the incrementing address can be pre-read (i.e., when the write address of the current cycle is 00 plus 8 addressing units equals 01, corresponding to burst_awaddr_preread[4:3] being 01 in the diagram), that is, the original data on Marco 1 is pre-read for the second transfer write address in the 4th cycle. Therefore, in the 5th cycle, although wstrb is f0 indicating an unaligned write, since the original data has already been read, the second transfer write operation on Marco 1 can be completed in one cycle, and the corresponding ECC encoding calculation is completed in the 5th cycle (as shown in the diagram).
[0126] Also on the 5th clock cycle, the read request begins. The master (e.g., the CPU) sends an arvalid signal on the read address channel (RADDR channel), and the slave (e.g., the memory of this invention) sends an ready signal on the read address channel. Both signals going high simultaneously (on the rising edge of the 5th clock cycle) indicates that the read address channel handshake has been successful. The memory then pulls rvalid high on the 6th clock cycle to indicate that the read data is ready.
[0127] In the 5th cycle, the read address decoder addresses Marco2 based on the value of aradix[4:3] being 10 (according to the addressing rules, this means that the burst_araddr[4:3] corresponding to the first transfer is 10, and the burst_araddr[4:3] corresponding to the latter two transfers are 11 and 00 respectively). At this time, if there is no conflict with the normal read, in the 5th cycle, the write controller will attempt to pre-read the data corresponding to the address of the third transfer, that is, it will also attempt to access Marco2.
[0128] exist Figure 8 In the read-first scheme, the pre-read operation is delayed when it conflicts with the read operation. This means that when the read controller instructs that no read request be made to the second memory bank in the current clock cycle, the write controller performs the pre-read operation on the existing data at a specified location in the second memory bank in the current clock cycle (corresponding to the pre-read operation for the second transfer that occurs in the 4th clock cycle); while when the read controller instructs that a read request be made to the second memory bank in the current clock cycle, the write controller does not perform the pre-read operation in the current cycle, and the next write operation resumes the normal write operation, that is, a one-clock aligned write or a two-clock unaligned write.
[0129] like Figure 8As shown, due to read priority, the read controller notifies the write controller to access Marco 2 in clock cycle 5. Pre-reading is not possible at this time, corresponding to burst_awaddr_preread[4:3] being idle. In clock cycle 6, the read controller notifies the write controller to access Marco 3. Since wstrb≠ff indicates an unaligned write, the write controller instructs to read the existing data stored in Marco 2 and completes the writing of the third transfer in clock cycle 7. This corresponds to: when an indication is received in the next clock cycle that encoding based on the pre-read existing data is required (e.g., wstrb≠ff), a normal two-clock unaligned write operation is performed, i.e.: the write controller reads the existing data at a specified location in the second memory bank in the next clock cycle (clock cycle 6 in this example); the encoder encodes the pre-read existing data and the next data to be written in the next clock cycle (clock cycle 7 in this example); and the write controller writes the encoded data to a specified location in the second memory bank in the next clock cycle. At this point, a standard two-cycle "read-modify-write" operation is performed, without "pre-read". Additionally, although no such example is shown in the diagram, if the next clock cycle receives an indication that encoding based on the existing data from the pre-read is unnecessary (e.g., wstrb = ff), a standard one-cycle write operation is performed in that clock cycle.
[0130] Subsequently, since there are no conflicts between reads and writes, read and write transfer transactions proceed smoothly independently. The read transfer transaction completes the reading of three transfers in phase 7, and in phase 8, rlast is pulled high to signal the completion of the INCR3 read operation. Also in phase 7, the write transfer transaction completes a two-phase regular unaligned write operation, begins pre-reading the data at the address corresponding to the fourth transfer, and completes the write in phase 8. In phase 8, the wlast signal indicates the end of the write transfer; therefore, no pre-read is performed in this phase to reduce power consumption. bvalid is the handshake signal given by the slave on the Write Reply (WRESP) channel, typically immediately following wlast (e.g., in phase 9). The master keeps bready high on the Write Reply (WRESP) channel, indicating that the current transaction is complete and the master is ready to begin sending the next write command after bvalid goes high.
[0131] Therefore, in Figure 8In the example, the read transfer transactions of three transfers are completed within 3 clock cycles, while the write transfer transactions of four transfers (including four non-aligned writes) are completed in 6 clock cycles (the first transfer cannot be read in advance, and the third transfer is delayed by one clock cycle due to a read conflict), which is two clock cycles less than the conventional two-clock method (which requires a total of 8 clock cycles).
[0132] Figure 8 An example of a conflict between reading and pre-reading is given. If no conflict occurs, the pre-reading scheme of this invention is more efficient. Figure 9 An example timing diagram for AXI parallel read / write operations, including prefetching, according to the present invention is shown. Figure 8 similar, Figure 9 An example is also shown where the write instruction INCR4 is received in the 3rd cycle and the read instruction INCR3 is received in the 5th cycle. The difference is that the starting address of the read transfer transaction corresponds to raddr[4:3] being 00. Therefore, no conflict occurs between read and write, or between read and pre-read, during their respective read and write operations. In this case, the pre-read scheme of the present invention, except for the first transfer non-aligned write which takes two cycles, completes the subsequent three transfer non-aligned writes in one cycle through pre-read, achieving the effect of completing four non-aligned write transfers in 5 cycles. Compared with the conventional two-cycle method (which requires a total of 8 cycles), it uses three fewer clock cycles.
[0133] Figure 10 An example timing diagram of AXI parallel read / write operations including prefetching is shown according to the present invention. Further, the diagram illustrates the case where the first transfer is not an unaligned write.
[0134] and Figure 9 similar, Figure 10The diagram also shows an example where a write instruction (INCR4) is received in the 3rd cycle and a read instruction (INCR3) is received in the 5th cycle. The difference is that this diagram shows the case where the first transfer is not an unaligned write. Therefore, for a write transfer transaction, a write operation to the first address (write address burst_awaddr[4:3] is 00) and a read operation to the next incrementing address (preread address burst_awaddr_preread[4:3] is 01) can be performed in the first cycle (i.e., the 3rd cycle in the diagram). Since the second transfer is an unaligned write (i.e., in the 4th cycle, wstrb = 0f, i.e., partially writing the lower 4 bytes of burst_awaddr[4:3] = 01), the read-modify-write process can be performed directly in the 4th cycle (in the diagram below, wready will not be pulled low in the 5th cycle). Regardless of whether this cycle is an unaligned write, the data at the next incrementing address will be read, i.e., the next incrementing address will be preread in the write cycle. This process is repeated until the last cycle, at which point prereading will cease to reduce power consumption.
[0135] As described above Figure 8-10 An example of a read-first approach is presented when read and read-lookup conflict. Figure 11 An example timing diagram for AXI parallel read / write operations, including prefetching, according to the present invention is shown. Figure 8 similar, Figure 11 It also shows an example where a write command (INCR4) is received in phase 3 and a read command (INCR3) is received in phase 5, the difference being the different handling methods for conflicts between read and pre-read operations. Figure 11 In the example, a read-first approach is used.
[0136] As shown in the figure, in the 5th cycle, the read address decoder, based on the value of aradix[4:3] being 10, attempts to address Marco 2 (according to the addressing rules, this means that the burst_araddr[4:3] corresponding to the first transfer is 10, and the burst_araddr[4:3] corresponding to the latter two transfers are 11 and 00 respectively). At the same time, also in the 5th cycle, the write controller, while writing the data of the second transfer to Marco1, also attempts to pre-read the data corresponding to the address of the third transfer, that is, it also attempts to access Marco 2.
[0137] At this point, due to read-first priority, the write controller notifies the read controller that Marco 2 needs to be read in the current cycle (i.e., the 5th cycle) (shown as idle in burst_araddr[4:3] in the 5th cycle). After receiving the notification that Marco 2 is occupied, the read controller will suspend reading Marco 2. Thus, in the 5th cycle, the write controller completes the unaligned write of the 2nd transfer and performs a data read-first for the 3rd transfer.
[0138] Subsequently, on the 6th clock cycle, the write controller will still attempt to access Marco 2 to complete the data write for the 3rd transfer. This occurs after the read and pre-read events of the previous clock cycle, leading to a read-write conflict. Figure 11 In the example, the read operation can be delayed by one more clock cycle (burst_araddr[4:3] is still shown as idle in the 6th clock cycle). Figure 11 The gray box illustrates the impact of a two-step delay on the relevant signal. By using a two-step delay for read operations, the read operation can be completely staggered from write and pre-read operations. In this case, compared to... Figure 8 For example, reading is two steps slower, but the four unaligned writes in the write transfer operation are compressed from 8 steps to 5 steps.
[0139] In actual memory chip execution programs, since the number of memory banks is typically four or more (e.g., eight, sixteen), read-write conflicts or read-write prefetch conflicts are less frequent than non-conflict situations. Even when conflicts do occur, subsequent read-write transfer conflicts can be avoided by, for example, through a simple write prefetch operation that pulls the address width low. Typically, read and write operations increment by the same address width each time; therefore, once staggered during the burst process, subsequent conflicts are avoided due to continuous increments, thus improving read and write efficiency. Even if the read and write address widths differ, this can be resolved by pulling the address width low when catching up. Since unaligned writes are a scenario-based operation, the prefetch operation of this invention can significantly improve the efficiency of unaligned writes.
[0140] The memory operation method and memory according to the present invention have been described in detail above with reference to the accompanying drawings.
[0141] This invention avoids two-step operations caused by misaligned write encoding by pre-reading the original data at the incrementing address during the write operation. This operation, combined with a scheme that uses low-bit decoding to stagger the memory bank targeted by the read / write incrementing address, improves the execution efficiency of the read / write parallel protocol. The operating scheme of this invention is particularly suitable for memories conforming to the AXI protocol, and it performs transfer-by-transfer arbitration and pre-reading of the original data at the incrementing address to maximize memory access efficiency.
[0142] This invention can also be implemented as an electronic device comprising a host and a memory, the host and memory communicating according to a read-write parallel protocol, such as a master and slave in the AXI protocol. The memory can perform the operation method described above, avoiding the extra clock cycle required for unaligned writes by pre-reading existing data in the next address. The memory of this invention is particularly suitable for implementation as an on-chip memory, such as on-chip SRAM.
[0143] Furthermore, it should be understood that the operating method of this invention is also applicable to other read-write parallel protocols besides the AXI protocol, and to other memories besides SRAM. Additionally, the prefetch data can be used not only for ECC, but also for other encoding processes that require two read / write cycles due to the read-modify-write operation. Furthermore, although particularly suitable for combination with low-order address mapping schemes, the prefetch scheme of this invention is also applicable to other address mapping schemes, as long as the memory bank corresponding to the incrementing address is different from the memory bank corresponding to the current address. Furthermore, although... Figure 5 and Figure 6 An arbitration circuit is shown, but in other embodiments, read / write conflict arbitration can be performed based on predetermined rules without the need for an arbitration circuit.
[0144] The various embodiments of the present invention have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or improvement of the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.
Claims
1. A method for operating a memory for unaligned writes, the memory following a read-write parallel protocol and comprising a plurality of memory banks, wherein the plurality of memory banks includes at least a first memory bank and a second memory bank, the method comprising: The write controller writes the data to be written to the specified location of the first memory bank corresponding to the current logical address of the write request in the current clock cycle. The write controller pre-reads the existing data at a specified location in the second memory bank corresponding to the next logical address of the write request during the current clock cycle. as well as When the write controller receives an unaligned write instruction based on the pre-read original data in the next clock cycle, the encoder encodes the pre-read original data and the next data to be written, and the write request performs an unaligned write operation on the next logical address in the next clock cycle. as well as The write controller writes the encoded data to a designated location in the second memory bank in the next clock cycle.
2. The method as described in claim 1, wherein, The write controller pre-reads the existing data at a specified location in the second memory bank corresponding to the next logical address of the write request during the current clock cycle, including: The read controller sends an indication to the write controller regarding whether to request a read from the second memory bank during the current clock cycle, so that the write controller can determine whether to perform the pre-read during the current clock cycle.
3. The method as described in claim 1, wherein, The write controller pre-reads the existing data at a specified location in the second memory bank corresponding to the next logical address of the write request during the current clock cycle, including: When the read controller instructs that no read request be made to the second memory bank during the current clock cycle, the write controller performs the pre-read of the existing data at a specified location in the second memory bank during the current clock cycle.
4. The method of claim 3, further comprising: When the read controller instructs a read request to the second memory bank in the current clock cycle, and the write controller receives the instruction in the next clock cycle that encoding based on the pre-read existing data is required, then: The write controller reads the existing data at a specified location in the second memory bank in the next clock cycle. as well as The encoder encodes the original data being read and the next data to be written in the write request in the next clock cycle. The write controller writes the encoded data to a designated location in the second memory bank in the next clock cycle.
5. The method of claim 1, wherein, The pre-reading of the existing data at a specified location in the second memory bank corresponding to the next logical address of the write request by the write controller in the current clock cycle also includes: The write controller sends an indication to the read controller regarding whether to perform the pre-read operation on the second memory bank during the current clock cycle, so that the read controller can determine whether to delay the read operation of the current logical address of the read request during the current clock cycle.
6. The method of claim 5, further comprising: While the read address decoder maps the current logical address of the read request to the second memory bank in the current clock cycle, the read controller delays the read operation of the current logical address of the read request to the second memory bank based on the occupancy indication.
7. The method of claim 1, wherein, The pre-read data is placed into the pre-read data buffer by the write controller in the current clock cycle, and retrieved from the pre-read data buffer by the encoder in the next clock cycle to be encoded with the next data to be written.
8. The method of claim 1, wherein, When the current data to be written is the data to be written to the last logical address of the write request, the write controller does not perform the pre-read operation in the current clock cycle.
9. The method of claim 1, wherein, When an indication is received in the next clock cycle that encoding is not based on the pre-read original data, the encoder encodes only the next data to be written.
10. The method of claim 1, further comprising: The read address decoder maps consecutive read requests for logical addresses to different memory banks sequentially according to a predetermined transmission bit width. The write address decoder maps consecutive write requests for logical addresses to different memory banks sequentially according to the predetermined transmission bit width. as well as The arbitration circuit arbitrates read and write requests mapped to the same memory bank during the current clock cycle. If the specific low address bits of the logical addresses are the same, then the read request and / or the write request are mapped to the same memory bank.
11. The method of claim 2 or 5, wherein, Each write request or read request is a transmission transaction of the read-write parallel protocol. Each write request contains multiple write data transmissions, each write data transmission corresponds to a different logical address and is used to write a copy of data to be written. Each read request contains multiple read data transmissions, each read data transmission corresponds to a different logical address and is used to read a copy of data to be read.
12. The method of claim 1, wherein, The encoding is ECC encoding, and the encoder is an ECC encoder.
13. A memory, wherein data access of the memory follows a read-write parallel protocol, the memory is configured to perform unaligned write operations, and the memory comprises: Multiple storage units, including at least a first storage unit and a second storage unit; Write the controller for: Write the data to be written to the specified location of the first memory bank corresponding to the current logical address of the write request in the current clock cycle; In the current clock cycle, the existing data at a specified location in the second memory bank corresponding to the next logical address of the write request is pre-read; as well as Encoder, used for: When an unaligned write instruction based on the pre-read original data is obtained in the next clock cycle, the pre-read original data and the next data to be written are encoded, and the write request performs an unaligned write operation on the next logical address in the next clock cycle. as well as When an indication is received in the next clock cycle that encoding will not be based on the pre-read existing data, only the next data to be written will be encoded. The write controller writes encoded data to a designated location in the second memory bank during the next clock cycle.
14. The memory of claim 13, further comprising a read controller, configured to: Send an indication to the write controller whether a read request is made to the second memory bank in the current clock cycle, so that the write controller can determine whether to perform the pre-read in the current clock cycle; or The write controller receives a pre-read occupancy indication sent by the write controller regarding whether to perform the read operation of the current logical address of the read request in the current clock cycle.
15. The memory of claim 13, further comprising: A prefetch data cache is used to cache the original data that is being prefetched.
16. The memory of claim 13, further comprising: A read address decoder is used to map read requests for consecutive logical addresses to different memory banks sequentially. A write address decoder is used to map write requests for consecutive logical addresses to different memory banks sequentially. An arbitration circuit is used to arbitrate read and write requests that are mapped to the same memory bank during the current clock cycle. Where the specific low address bits of the logical addresses are the same, the read request and / or the write request are mapped to the same memory bank.
17. The memory of claim 16, wherein, The arbitration circuit includes: Multiple arbitration sub-circuits, each corresponding to a different memory bank. Each arbitration subcircuit performs read / write arbitration on its corresponding memory bank for each read data transmission included in the read request or each write data transmission included in the write request.
18. The memory of claim 13, wherein, The indication that the original data is encoded based on the pre-read data comes from a bus signal received by the write controller, the bus signal indicating that in the next clock cycle, the write request will perform the unaligned write operation on the next logical address.
19. The memory of claim 13, wherein, The write controller increments the current logical address in the current clock cycle to obtain the next logical address for the pre-read.
20. An electronic device, comprising: Control unit; as well as A memory, wherein the control unit and the memory interact via a bus following a parallel read / write protocol, the memory is used to perform unaligned write operations, and the memory performs the operations of any one of claims 1-12.
Citation Information
Patent Citations
Multiport memory emulation using single-port memory devices
US20140047197A1
