Method for implementing single-port SRAM pseudo dual-port operation

By introducing a temporary register and a dynamic arbitration mechanism into a single-port SRAM, pseudo-dual-port operation of a single SRAM is achieved, resolving the read-write concurrency conflict, improving read efficiency in FIFO applications, and avoiding increased hardware cost and complexity.

CN123182728APending Publication Date: 2026-11-27SHENZHEN CHIPSAILING TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611397570.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-09
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

In FIFO applications, the read speed of single-port SRAM is much lower than the write speed. Existing technologies increase storage resources and complex mapping tables, resulting in high hardware costs and increased design complexity, and have failed to effectively solve the contradiction between read and write concurrency.

Method used

By using dynamic arbitration and data temporary storage mechanisms, pseudo-dual-port operation is achieved using a single block of single-port SRAM. The temporary storage register is used to store and read data, and the external interface retrieves data one by one. Read and write operations alternately occupy the SRAM port, avoiding additional storage resources and complex mapping.

Benefits of technology

It achieves efficient concurrent read and write access, ensures the continuity and stability of the read data stream, avoids increased chip area and design complexity, and improves the read efficiency of single-port SRAM.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123182728A_ABST
    Figure CN123182728A_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of digital circuit design, and especially relates to a single-port SRAM pseudo-dual-port operation implementation method, which stores N data units read into a temporary register for external reading interface to take one by one, and can realize efficient reading based on a single single-port SRAM, the temporary register plays a decoupling role between the reading operation and the data output, so that the reading data flow is not disturbed during the period of occupying the SRAM access port in the writing operation, the continuity and stability of the reading data flow are ensured, and the problems of the increase of chip area and the rise of design complexity caused by the adoption of multiple SRAMs and address mapping tables in the prior art are avoided, and the method is suitable for the application scene of the single-port SRAM with faster writing speed, slower reading speed and reading occupying most of the time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of digital circuit design technology, and in particular to a method for implementing pseudo-dual-port operation of a single-port SRAM. Background Technology

[0002] Single-port SRAM (Static Random Access Memory) is a fundamental volatile memory device. Its core characteristic is that it has only one access port, allowing only one operation—either reading or writing—to be performed at any given time. Due to its simple structure, small chip area, and low power consumption, single-port SRAM is widely used in digital circuit designs such as ASICs (Application-Specific Integrated Circuits) and FPGAs (Field-Programmable Gate Arrays). However, the single-port characteristic of single-port SRAM prevents it from supporting true concurrent read and write access like dual-port SRAM. In many practical applications, especially in FIFO (First-In-First-Out) designs, there is often a situation where write rates are high, read rates are low, and read operations take a long time. The read and write operations overlap in time, placing higher demands on the access efficiency of single-port SRAM.

[0003] To address the read / write conflict issue in single-port SRAM, relevant technical solutions employ two single-port SRAM memories, storing data in the two memories according to odd and even addresses respectively. Concurrent read / write operations are achieved through independent access to odd and even addresses. Alternatively, two ports are provided externally for reading and writing data respectively. Internally, this consists of three single-port SRAMs, an address mapping table, three fully associative data valid registers, and three free address registers, implementing pseudo-dual-port functionality through more complex hardware logic.

[0004] While the aforementioned existing technologies can alleviate the read / write concurrency conflict of single-port SRAM to some extent, they still have the following shortcomings: First, both require additional storage resources (two or three SRAMs) and supporting auxiliary logic such as mapping tables and registers, resulting in a significant increase in chip area and higher hardware costs; Second, the introduced multi-memory structure and complex mapping mechanism significantly increase design complexity, impose more stringent timing constraints and verification requirements, and are difficult to apply to resource-constrained or area-sensitive design scenarios; Third, for FIFO-type applications with the typical characteristics of "fast write and slow read," existing solutions do not provide a dedicated optimization strategy that balances hardware overhead and access efficiency. Summary of the Invention

[0005] In view of this, in order to address the problem of insufficient access efficiency of single-port SRAM when the read speed is much lower than the write speed in FIFO application scenarios, the purpose of this invention is to provide a method for implementing pseudo dual-port operation of single-port SRAM, which aims to achieve efficient concurrent read and write access through dynamic arbitration and data temporary storage mechanisms without increasing additional storage resources.

[0006] In a first aspect, embodiments of the present invention provide a method for implementing pseudo-dual-port operation of a single-port SRAM. This method implements FIFO read / write access based on a single block of single-port SRAM, including: In response to a read operation, obtain the current read address of the single-port SRAM; Determine if the current read address is on an edge; If so, take the current read address of the single-port SRAM as the read start address, perform one read operation, read N data units continuously from the single-port SRAM and store them in the temporary register, where N is a positive integer; The external read interface retrieves data units one by one from the temporary register, until all N data units have been retrieved. The read address then increments by N and falls on the next address edge.

[0007] In conjunction with the first aspect, determining whether the current read address is on an edge also includes: If not, wait until the data in the temporary register has been completely used by the external read interface before performing a read operation using the current read address of the single-port SRAM as the start address.

[0008] In conjunction with the first aspect, the temporary register has N storage locations, and each storage bit is used to store one data unit; N data units are stored in the temporary register in ascending order of address, and the external read interface retrieves the data units in the same order.

[0009] In conjunction with the first aspect, prior to the step of obtaining the current read address of the single-port SRAM in response to a read operation, the method further includes: The read enable signal and read address signal are issued at least one operating clock cycle in advance of the single-port SRAM to ensure that the data read from the single-port SRAM remains stable in the temporary register.

[0010] In conjunction with the first aspect, the method also includes: In response to a write operation request, obtain the current read address of the single-port SRAM; Determine if the current read address is located at the start boundary of the read operation; If not, maintain the operating clock frequency unchanged and execute the write operation corresponding to the write operation request during the idle period between two adjacent read operations; If so, the operating clock of the single-port SRAM is divided to execute the write operation register corresponding to the read operation and write operation requests in a time-division manner within the divided clock cycle.

[0011] In conjunction with the first aspect, the steps for frequency division processing of the operating clock of a single-port SRAM include: The operating clock frequency is divided by two. Each clock cycle after division contains two time slices. The first time slice is allocated to the read operation and the second time slice is allocated to the write operation. The read and write operations alternately occupy the access port of the single-port SRAM within the two time slices.

[0012] In conjunction with the first aspect, the steps for determining whether the current read address is located on the starting boundary of the read operation include: If the result of taking the address value of the current read address modulo N is equal to the preset value M, then the current read address is determined to be on the starting boundary of the read operation; where M = 0 ~ N-1.

[0013] In conjunction with the first aspect, the write address of the write operation is indicated by the FIFO write address pointer, which increments after each write operation. The FIFO write address pointer and the FIFO read address pointer are used together to generate the empty and full flags of the FIFO, and the FIFO read address pointer is the indicator pointer for the current read address.

[0014] In conjunction with the first aspect, the external read interface is an SPI interface. The SPI interface write operation writes to the single-port SRAM at the granularity of a single data unit; the read operation reads N data units continuously from the single-port SRAM and stores them in a temporary register. The SPI interface reads single data units sequentially from the temporary register according to their address order.

[0015] The embodiments of the present invention bring the following beneficial effects: This application provides a method for implementing pseudo-dual-port operation of a single-port SRAM. The method is based on a single single-port SRAM to implement FIFO read and write access, including: in response to a read operation, obtaining the current read address of the single-port SRAM; determining whether the current read address is on an edge; if so, using the current read address of the single-port SRAM as the read start address, performing a read operation to continuously read N data units from the single-port SRAM and store them in a temporary register, where N is a positive integer; the external read interface retrieves data units one by one from the temporary register in units of single data units until all N data units are used up, the read address increments by N, and falls on the next address edge.

[0016] This invention achieves efficient reading by temporarily storing N read data units in a register for sequential access by an external read interface. This is based on a single-port SRAM. The temporary register decouples the read operation from the data output, ensuring that the read data stream is not disturbed while the write operation occupies the SRAM access port. This guarantees the continuity and stability of the read data stream and avoids the problems of increased chip area and design complexity caused by using multiple SRAMs and address mapping tables in the prior art.

[0017] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings.

[0018] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0019] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0020] Figure 1 This is a flowchart illustrating the implementation method of single-port SRAM pseudo-dual-port operation provided in Embodiment 1 of the present invention. Figure 2 This is a schematic diagram illustrating the reading operation principle in the method provided in Embodiment 1 of the present invention; Figure 3 This is a flowchart illustrating the implementation method of single-port SRAM pseudo-dual-port operation provided in Embodiment 2 of the present invention. Figure 4 This is a schematic diagram illustrating the reading operation principle in the method provided in Embodiment 2 of the present invention. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0022] To facilitate understanding of this embodiment, the technical terms used in this application will be briefly introduced below.

[0023] A single-port SRAM (Single-Port Static Random Access Memory) has only one access port, allowing only one operation at a time—either a read or a write operation—to be performed simultaneously. Physically, this port is represented by a shared set of signal lines, including an address bus, a data bus, and a control bus.

[0024] FIFO (First-In-First-Out) is a storage structure that reads data in the order it is written.

[0025] Reading is a method of continuously reading N data units from a single-port SRAM, starting from the address indicated by the current FIFO read address pointer.

[0026] Temporary storage registers are cache structures used to temporarily store multiple data units read at once from a single-port SRAM. They decouple read operations from data output, making the read data unaffected by write operations, resulting in more stable data and ensuring the continuity of the read data stream.

[0027] SPI (Serial Peripheral Interface) is a synchronous serial communication interface.

[0028] Address Bus: Used to specify the location of the memory cell to be accessed.

[0029] Data Bus: Used to transmit data to be written or read; it is shared for both input and output.

[0030] Control Bus: Contains read / write enable, chip select, and other signals used to control the operation type.

[0031] After introducing the technical terms used in this application, the application scenarios and design concepts of the embodiments of this application will be briefly described below.

[0032] In FIFO design, a common challenge is achieving high write speeds, low read speeds, and long read operation durations, resulting in overlapping read and write operations. Traditional solutions divide the SRAM clock by two to evenly distribute time between reads and writes. However, write operations typically occupy only a small portion of the time, with most of the time spent reading data. Directly reducing the clock frequency would severely degrade read efficiency.

[0033] Based on this, this application provides a method for implementing pseudo-dual-port operation of a single-port SRAM.

[0034] Example 1 This application provides a method for implementing pseudo-dual-port operation of a single-port SRAM. This method implements FIFO read / write access based on a single block of single-port SRAM. The embodiments of this application illustrate this using a single-port SRAM as a FIFO, with reads and writes in units of N bytes, each byte being 11 bits. (Combined with...) Figure 1 As shown, the method includes: S110, in response to a read operation, obtains the current read address of the single-port SRAM.

[0035] S120, determine if the address being read is on an edge.

[0036] If so, proceed with steps S130~S140.

[0037] S130 uses the current read address of the single-port SRAM as the read start address, performs a read operation, reads N data units continuously from the single-port SRAM and stores them into the temporary register, where N is a positive integer.

[0038] S140: The external read interface retrieves data units one by one from the temporary register, until all N data units have been retrieved. The read address is incremented by N and falls exactly on the edge of the next address.

[0039] This application temporarily stores N data units read consecutively from a single-port SRAM in a temporary register during a single read operation. This allows the external read interface to retrieve data one by one from the temporary register. Since the temporary register decouples the read operation from the data output, the read data is unaffected during the write operation that occupies the SRAM access port, resulting in more stable data output and ensuring the continuity of the read data stream. Furthermore, this application achieves the above-mentioned efficient reading based on a single single-port SRAM without the need for additional memory or complex mapping logic. This avoids the problems of increased chip area and design complexity caused by using multiple SRAMs and address mapping tables in the prior art, thereby improving the read efficiency of single-port SRAM.

[0040] In step S110, when the FIFO read interface initiates a read operation, the current read address of the single-port SRAM is first obtained, and it is directly determined whether the read address is on an address edge. An address edge refers to the starting boundary of the read operation, that is, the address position corresponding to the current read address value modulo N equal to M. For example, when N=8 and M=0, the read address is 0, 8, 16... that is, a multiple of 8. The current read address being on an address edge is the trigger condition for the read operation, indicating that the current address is at the address node where a read operation needs to be performed; an empty temporary register is the data preparation condition for the read operation, indicating that there is no data available in the temporary register and new data needs to be filled in.

[0041] This condition is a necessary condition for triggering the read operation. If met, steps S130-S140 are executed. Using the address indicated by the current FIFO read address pointer as the starting address, a read operation is initiated on the single-port SRAM, continuously reading N data units (e.g., N=8), and storing these N data units into a temporary register at once. In this embodiment, both reading and writing are done in units of N bytes, each byte being 11 bits. For example, when N=8, eight 11-bit data units are temporarily stored in an array of 11 bits × 8 = 88 bits, with each data unit being one byte (11 bits), and the read time is much longer. The N read data units are stored into the temporary register at once for subsequent reading.

[0042] After the temporary register is filled, the external read interface (i.e., the FIFO read interface) retrieves data units one by one from the temporary register in ascending address order. After retrieving each data unit, the current read pointer increments by 1. This read pointer indicates which memory location in the temporary register the external read interface should currently retrieve; its value ranges from 0 to N-1, corresponding one-to-one with the N memory locations in the temporary register. When the external read interface has retrieved the (N-1)th memory location (i.e., the last data unit) from the temporary register, it indicates that all N data units read in the current read operation have been retrieved. At this point, the read address automatically increments by N and falls precisely on the address edge, triggering the next read operation. After retrieval, this process described above is repeated cyclically, meaning that a read operation is triggered again when the SRAM address meets the address edge condition.

[0043] In conjunction with the first aspect, after determining whether the current read address is on an edge in step S120, the following is also included: S150: After the data in the temporary register has been completely used by the external read interface, a read operation is performed using the current read address of the single-port SRAM as the read start address.

[0044] If the above conditions are not met, it indicates that there is still valid data that has not been retrieved, so the read operation will not be performed and the system will enter a waiting state.

[0045] Specifically, in the waiting state, if the current read address is not located on an address edge, it indicates that there is still valid data in the temporary register that has not been fetched. Therefore, there is no need to immediately access the single-port SRAM; instead, the system waits for the external read interface to finish fetching all N data units in the temporary register. During this period, the external read interface fetches data from the temporary register one data unit at a time, in address order. After fetching each data unit, the current read pointer increments by 1. When all N data units in the temporary register have been fetched, and the current read address happens to be located on an address edge, a read operation is performed, continuously reading N data units from the single-port SRAM and storing them in the temporary register for further use by the external read interface.

[0046] It should be noted that during the above waiting process, the current read address increments by N with each completed read operation; that is, the read address jumps between "edges". When the read address is not on an edge, it indicates that it is currently in the middle of a read cycle. The read address will only fall on the next edge after the external read interface has finished retrieving the data from the temporary register, thus triggering the next read operation. Furthermore, in Figure 1 The read process also includes the implicit condition of "and not in a write state". That is, when a write operation occupies an SRAM access port, the read operation must wait for the write operation to be completed before it can be executed, so as to ensure that the read operation and the write operation do not conflict with each other.

[0047] Through the above reading process, the external reading interface does not need to access the SRAM when retrieving data from the temporary register, and is not affected by the occupancy status of the SRAM access port; even when the write operation occupies the SRAM access port, the data stored in the temporary register can still be continuously supplied to the external reading interface, ensuring the continuity and stability of the read data stream.

[0048] In conjunction with the first aspect, the temporary register has N storage locations, each storage bit is used to store one data unit; the N data units are stored into the temporary register in ascending order of address, and the external read interface retrieves the data units in the same order.

[0049] The temporary register has N storage locations, each storing one data unit. The total width of the temporary register is N×W bits (where W is the width of each data unit). In the read operation of step S120, the N data units read consecutively from the single-port SRAM are stored sequentially in ascending order of address into the 0th to the (N-1th)th storage location of the temporary register. That is, the data unit corresponding to the starting address is stored in the 0th location, the data unit corresponding to the starting address + 1 is stored in the 1st location, and so on, with the data unit corresponding to the starting address + N-1 being stored in the (N-1th)th location. In step S130, the external read interface retrieves data units from the temporary register in the same order as the storage order (i.e., from the 0th to the (N-1th)th location). After retrieving each data unit, the current read pointer is incremented by 1. This sequential consistency ensures that the FIFO read operation outputs data from the temporary register in a first-in-first-out order, consistent with the data order during FIFO writing.

[0050] In conjunction with the first aspect, prior to step S110, the following also includes: S010, issue the read enable signal and read address signal at least one operating clock cycle ahead of the single-port SRAM, so that the data read from the single-port SRAM remains stable in the temporary register.

[0051] In conjunction with the first aspect, the current read pointer is incremented by 1 each time the external read interface retrieves a data unit from the temporary register; when all N data units in the temporary register have been retrieved, the temporary register is marked as empty to trigger the next read operation.

[0052] In step S130, the external read interface retrieves data units one by one from the temporary register: when the FIFO reads data, it retrieves the data byte by byte from the temporary register according to the SRAM address. After retrieving each data unit, the current read pointer increments by 1, pointing to the next storage bit in the temporary register. The value of this read pointer ranges from 0 to N-1, corresponding one-to-one with the N storage bits of the temporary register.

[0053] When the external read interface retrieves the last storage bit (i.e., bit N-1) of data from the temporary register, it indicates that all N data units read in the current read operation have been used, and the read address is now at an address edge. This address edge is used for the judgment in step S110: when it is at an address edge, the next read operation is triggered, that is, the address indicated by the current FIFO read address pointer is used as the read start address (i.e., when the condition is met after 3 bits of the next SRAM read address), and N data units are read continuously from the single-port SRAM and stored in the temporary register. This cycle repeats, with the temporary register alternating between filling and depletion, and the read process is executed continuously and automatically until all data in the FIFO has been read.

[0054] Combination Figure 2 As shown, after the read process begins, a condition check is first performed to determine whether the condition "SRAM read address [2:0] == 0 or SRAM read address == other fixed addresses 1~7" is met. This condition is used to determine whether the current time is when a read operation needs to be performed. The last 3 bits of the read address correspond to the result of modulo 8; the number of rows is the number of data units written each time; and the multiple of the number of rows is the boundary address of the write cycle. When the read address is at this boundary, it indicates that the next batch of data needs to be read from the SRAM. During reading, if the current state is not in a write state, it reads directly at full speed; otherwise, it reads at a reduced frequency (divided by 2), with half the time spent writing and half the time spent reading. In fact, when the read address is at an edge, it is highly unlikely to fall into a write state.

[0055] When the above conditions are met, the "read SRAM operation, read 8 bytes of data at a time" is executed. Since 8 data bytes are read out at once, these 8 11-bit data bytes need to be temporarily stored in an array of 11 bits × 8 = 88 bits. That is, the read operation is performed to continuously read 8 data units (each data unit is 11 bits) from the single-port SRAM.

[0056] Reading requires one SRAM cycle in advance because the SRAM read result takes one cycle to be generated. Therefore, after the read operation is executed, wait for one SRAM clock cycle until the data read from the SRAM is stable before storing the data into the temporary register array. This ensures that the data stored in the temporary register is stable, valid, and correct, avoiding data errors caused by SRAM read delay.

[0057] After the data is stored in the temporary register, when reading data from the FIFO, the data is retrieved from the temporary register byte by byte according to the SRAM address. That is, the external read interface (FIFO read interface) retrieves data units one by one from the temporary register in units of single data units (1 byte, 11 bits).

[0058] Next, determine whether a FIFO read operation is needed, i.e., whether there is still a need to read from the FIFO: If further reading from the FIFO is needed (the result is Y), the process returns to the initial condition and repeats. After each round of filling, sequential reading, and complete reading cycle, the process automatically returns to the initial condition, waiting for the next read address to be at the read start boundary before triggering another read operation to update the data in the temporary register. This cycle repeats continuously, with FIFO read operations performed in a first-in, first-out order, until all data has been read and the FIFO is empty.

[0059] If it is no longer necessary to read the FIFO (the result is N), then the reading process ends.

[0060] Example 2 In this embodiment, the implementation method of the single-port SRAM pseudo-dual-port operation is combined with... Figure 3 As shown, it includes: S210, in response to a write operation request, obtains the current read address of the single-port SRAM.

[0061] S220, determine whether the current read address is located on the starting boundary of the read operation.

[0062] If yes, proceed to step S240; otherwise, proceed to step S230.

[0063] S230: Maintain the operating clock frequency unchanged, and execute the write operation corresponding to the write operation request during the idle period between two adjacent read operations.

[0064] S240 divides the operating clock of the single-port SRAM to perform time-division multiplexing of the read and write operations corresponding to the write operation requests within the divided clock cycle.

[0065] When the FIFO write interface initiates a write operation request, it first obtains the current read address of the single-port SRAM, that is, the address node of the SRAM that is currently reading data, which is used to determine whether there is a conflict state and to determine the execution strategy of the write operation.

[0066] The read start boundary refers to the address position where the current read address value modulo N (length) equals M, where M is equal to the lower log2N bit value of the number of rows (i.e., the result of taking the number of rows modulo N). For example, when N=8 and M=0, the read address is 0, 8, 16... that is, a multiple of 8.

[0067] Wherein, step S220 specifically includes: if the result of the address value of the current read address modulo N is equal to the preset value M (M=0~N-1), then it is determined that the current read address is located on the start boundary of the read operation. In other words, the preset value M=0, when the address value of the read address is 0, N, 2N, 3N..., it indicates that the current read address is exactly the start address of the next read operation; if the number of rows is 3, then M=3, and the read addresses are 3, 11, 19..., that is, the address positions whose modulo 8 result is equal to 3..

[0068] When N takes the power of 2 (for example, N=8), the judgment of modulo N can be simplified to judging the low K bits of the read address, where 2 K =N. For example, when N=8, it is only necessary to judge whether the lower 3 bits of the read address are all M (that is, the last 3 bits of the read address are M). If they are all M, it is determined that the current read address is located on the read start boundary.

[0069] It should be noted that when the number of data units written in the last time is less than N (for example, the number of data written in one row is not exactly a multiple of N, resulting in the last write not being N data), the above judgment method of the start boundary needs to be adjusted accordingly. Specifically, for the last written M data units (M<N), the condition for judging whether the current read address is located on the read start boundary is adjusted to: the result of the address value of the current read address modulo N is equal to the result of M modulo N, or the current read address is equal to a multiple of the number of rows. For example, when N=8, if there are only M=3 data units left in the last write, then when the last 3 bits of the SRAM read address are equal to 3, it is determined that the current read address is located on the read start boundary, triggering the frequency-reduced write mode; otherwise, full-speed write is performed. This adjustment ensures that the frequency reduction conflict judgment can still be accurately executed in the special scenario where the write length is less than N.

[0070] This judgment method is used to determine whether the current read address is located on the read start boundary, and then decide whether the write operation adopts the full-speed mode or the frequency-reduced mode: if the read address modulo N is not equal to M, it indicates that the current read address is not located on the start boundary, and is currently at the middle position of a read cycle, then execute step S230; if the read address modulo N is equal to the fixed value M, it indicates that the current read address is located on the start boundary, and if the write operation is executed at this time, it will cause an access conflict with the read operation that may occur there, then execute step S240.

[0071] If the current read address is not located on the read start boundary, it indicates that the current read address is at the middle position of a read cycle, and there is still a margin within N addresses from the next read start boundary. If the current read address is not equal to a multiple of 8, then perform full-speed write, that is, execute the write operation during the idle period between two adjacent read operations, without any interference to the read process.

[0072] If the current read address is located on the read start boundary, it means that the current read address is exactly a multiple of 8 or equal to a multiple of the number of rows to be written. In this case, performing a write operation will cause an access conflict with the read operation. To avoid conflicts, the operating clock of the single-port SRAM is divided (e.g., by 2). Within the divided clock cycle, time is divided into two time slices. Read and write operations alternately access the single-port SRAM in different time slices, thereby achieving time-division multiplexing of read and write operations.

[0073] The operation clock of the single-port SRAM is divided by two. Each clock cycle after division contains two time slices: the first time slice is allocated to read operations, and the second time slice is allocated to write operations. Read and write operations alternately occupy the access port of the single-port SRAM within these two time slices. In essence, dividing the SRAM clock by two resolves the conflict between read and write operations by reducing the frequency. Within a complete clock cycle after division, one half-cycle is used for read operations, and the other half-cycle is used for write operations, with read and write operations alternating to occupy the access port of the single-port SRAM.

[0074] The frequency reduction process (dividing by two) is triggered only when the current read address is at the read start boundary and a write operation request is pending. The reduction duration only covers the current conflict cycle, and full-speed operation resumes immediately after the write operation is completed. Since write operations are typically very short, and simulation results show that the probability of the read address falling into the conflict boundary is only 1 / N, the system operates at full speed in most cases. This is equivalent to implementing the functionality of a dual-port SRAM with a single-port SRAM, significantly improving the read and write efficiency of the single-port SRAM.

[0075] In downclocked write mode, the temporary register is stored in the temporary register array only after the data read from the SRAM has stabilized after one SRAM clock cycle. This means that the data update and write operation of the temporary register are staggered in time. Because the temporary register has already temporarily stored the data, the read data is not affected by the write operation, resulting in more stable data. While the write operation occupies the SRAM access port, the data already temporarily stored in the temporary register is continuously supplied to the external read interface, ensuring an uninterrupted data flow.

[0076] Before the actual write operation, a judgment is made: if the current address is on the SRAM that needs to read data (i.e., the read address is exactly a multiple of 8), and data needs to be written at that moment, then the frequency is reduced, with half the time allocated to reading and half to writing. Conversely, if the current read address is not a multiple of 8, then full-speed writing is performed. Since read / write operations can be performed at full speed in most cases, frequency reduction is rare, thus greatly improving the read / write efficiency of a single-port SRAM.

[0077] The write address for a write operation is indicated by the FIFO write address pointer, which increments after each write operation. The FIFO write address pointer and the FIFO read address pointer are used together to generate the FIFO's empty and full flags, while the FIFO read address pointer serves as an indicator of the current read address.

[0078] In FIFO read / write access, the write address and read address are independently indicated by the FIFO write address pointer and FIFO read address pointer, respectively. The FIFO write address pointer and FIFO read address pointer are used together to generate the FIFO's empty and full flags: when the FIFO read address pointer catches up with the FIFO write address pointer (i.e., they are equal), it indicates that there is no readable data in the FIFO, and an empty flag is generated; when the FIFO write address pointer catches up with the FIFO read address pointer (i.e., the write address pointer is ahead of the read address pointer by one full FIFO depth), it indicates that there is no free storage space in the FIFO, and a full flag is generated. Through this pointer management, the FIFO's write and read processes are ensured to work collaboratively in a first-in, first-out (FIFO) order, jointly maintaining the orderliness of the FIFO data.

[0079] Combination Figure 4 As shown, after the write process begins, the last 3 bits of the read address are used to determine whether it is an edge, that is, to determine whether the current read address is located on the starting boundary of the read operation (whether the last 3 bits of the read address are equal to the last 3 bits of the number of rows, or whether the read address is a multiple of the number of rows).

[0080] In practical applications, the number of numbers written in a row may not be a multiple of 8, resulting in the last write not containing 8 numbers. In this case, the last 3 bits of the SRAM read address should be exactly equal to the last 3 bits of the number of numbers written in a row, or the SRAM read address should be exactly equal to a multiple of the number of rows. Here, the number of rows represents the number of data units written in each cycle, and the multiple of the number of rows represents the boundary address of the write cycle. When the read address is at this boundary, it indicates that the current position is at the beginning of a read operation; performing a write operation at this point would cause an access conflict with the read operation at that location.

[0081] If the above conditions are met (the judgment result is Y), then a reduced-frequency write operation is performed: the frequency is reduced when writing data, with half reading and half writing, writing 8 bytes of data at a time. That is, the operating clock of the single-port SRAM is divided by 2. Within a complete clock cycle after the frequency division, one half-cycle is used for reading operations and the other half-cycle is used for writing operations. Reading and writing alternately occupy the access port of the single-port SRAM, thereby completing the read and write operations in a time-division manner at the conflict boundary.

[0082] If the above conditions are not met (the judgment result is N), then write at full speed, that is, maintain the frequency of the operation clock unchanged, and perform the write operation during the idle period between two adjacent read operations, without interfering with the read process.

[0083] Typically, read / write operations can operate at full speed most of the time, with very few instances of frequency reduction where the read address is exactly a multiple of 8 during a write operation. This is because write operations usually occur at read addresses that are not multiples of 8. In this way, it's equivalent to implementing the functionality of a dual-port SRAM using a single-port SRAM, thus improving the read / write efficiency of the SRAM.

[0084] In conjunction with the first aspect, the external read interface is an SPI interface. The read operation reads N data units continuously from the single-port SRAM and stores them in the temporary register. The SPI interface reads single data units sequentially from the temporary register according to their address order.

[0085] In this solution, the external read interface can be an SPI interface. When reading, the SPI interface can only read 1 byte at a time, and when writing, it writes N bytes at a time, that is, it writes directly to the single-port SRAM with N data units (1 byte, 11 bits) as the granularity, without the need for data concatenation.

[0086] When reading, the SPI interface reuses the read and buffering mechanism of the FIFO operating mode, reading 8 bytes at a time and placing them into a temporary register. Then, during SPI read operations, these bytes are retrieved one by one. That is, N data units are continuously read from the single-port SRAM and stored in the temporary register. The SPI interface then reads these single data units sequentially from the temporary register according to their address order. During SPI write and read operations, direct SPI read / write access operations do not occur simultaneously with FIFO operations; they are implemented in a time-sharing manner and do not interfere with each other.

[0087] Finally, it should be noted that the above embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A method for implementing pseudo-dual-port operation of a single-port SRAM, characterized in that, The method implements FIFO read / write access based on a single block of single-port SRAM, including: In response to a read operation, the current read address of the single-port SRAM is obtained; Determine if the current read address is on an edge; If so, using the current read address of the single-port SRAM as the read start address, perform a read operation to continuously read N data units from the single-port SRAM and store them in a temporary register, where N is a positive integer; The external read interface retrieves data units one by one from the temporary register until all N data units have been retrieved. The read address is incremented by N and falls on the next address edge.

2. The method according to claim 1, characterized in that, The address edge is the address position corresponding to the address value of the current read address modulo N equal to 0.

3. The method according to claim 1, characterized in that, After determining whether the current read address is on an edge, the following steps are also included: If not, wait until the data in the temporary register has been completely used by the external read interface, and then, with the current read address on the edge, use the current read address of the single-port SRAM as the read start address to perform a read operation.

4. The method according to claim 1, characterized in that, The temporary storage register has N storage locations, and each storage bit is used to store a data unit; The N data units are stored in the temporary register in ascending order of address, and the external read interface retrieves the data units in the same order.

5. The method according to claim 1, characterized in that, Before the step of obtaining the current read address of the single-port SRAM in response to a read operation, the method further includes: The read enable signal and read address signal are issued at least one operating clock cycle in advance to ensure that the data read from the single-port SRAM remains stable when stored in the temporary register.

6. The method according to claim 1, characterized in that, The method further includes: In response to a write operation request, the current read address of the single-port SRAM is obtained; Determine whether the current read address is located at the start boundary of the read operation; If not, maintain the operating clock frequency unchanged and execute the write operation corresponding to the write operation request during the idle period between two adjacent read operations; If so, the operating clock of the single-port SRAM is divided to perform read operations and write operations corresponding to the write operation requests in a time-division manner within the divided clock cycle.

7. The method according to claim 6, characterized in that, The step of dividing the operating clock of the single-port SRAM includes: The frequency of the operating clock is divided by two, and each clock cycle after division contains two time slices. The first time slice is allocated to the read operation, and the second time slice is allocated to the write operation. The read operation and the write operation alternately occupy the access port of the single-port SRAM in the two time slices.

8. The method according to claim 6, characterized in that, The step of determining whether the current read address is located on the starting boundary of the read operation includes: If the result of taking the address value of the current read address modulo N is equal to the preset value M, then the current read address is determined to be located on the starting boundary of the read operation; where M = 0 to N-1.

9. The method according to claim 6, characterized in that, The write address of the write operation is indicated by the FIFO write address pointer, which increments after each write operation. The FIFO write address pointer and the FIFO read address pointer are used together to generate the empty and full flags of the FIFO. The FIFO read address pointer is an indicator pointer for the current read address.

10. The method according to claim 1, characterized in that, The method further includes: In response to a mode switching command, the current working mode is switched; the external read interface is an SPI interface, and the SPI interface write operation writes to the single-port SRAM at the granularity of a single data unit; the read operation reads N data units continuously from the single-port SRAM and stores them in the temporary storage register, and the SPI interface reads the single data unit registers from the temporary storage register in address order.