A configurable SDIO master-slave hardware architecture and driver method between CPU and FPGA
By introducing a configurable SDIO master-slave hardware architecture between the CPU and FPGA, combined with DMA, asynchronous FIFO, and interrupt reporting mechanisms, the problems of insufficient bandwidth and high resource consumption in CPU-FPGA interaction are solved, achieving efficient control and unified data interaction, and improving the real-time performance and portability of the system.
Patent Information
- Application Number
- CN202611442665.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-17
- Publication Date
- 2026-11-17
AI Technical Summary
In embedded systems, the interaction interface between the CPU and FPGA suffers from insufficient bandwidth, high resource consumption, and high system integration complexity. Existing SDIO interfaces have poor portability, incomplete register architecture, unstable cross-clock domain buffers, and imperfect interrupt mechanisms.
It employs a configurable SDIO master controller and FPGA-side SDIO slave logic, and achieves unified interaction between the control plane and data plane through standard SDIO commands, data lines and interrupt lines. Combined with DMA, asynchronous FIFO, register mapping and interrupt reporting mechanisms, it improves system bandwidth, real-time performance and portability.
In a system architecture that implements CPU-FPGA interaction, the control channel and data channel are separated, reducing CPU involvement, improving system bandwidth and real-time performance, enhancing the scalability of FPGA business logic, reducing resource consumption and power consumption, and supporting standard driver compatibility.
Smart Images

Figure SMS_1
Abstract
Description
Technical Field
[0001] This invention relates to PGA, specifically a configurable SDIO master-slave hardware architecture and driving method between CPU and FPGA. Background Technology
[0002] In scenarios where embedded systems and FPGAs work together, the main control CPU needs to issue control commands, read back status, report events, and exchange batch data with the FPGA. Traditional low-speed interface protocols such as UART, I2C, and SPI are simple, but their interface width and clock frequency are limited, making it difficult to meet the requirements of high-speed acquisition, real-time control, and large-block data transmission. Although high-speed parallel interfaces such as PCIe and AXI have higher bandwidth, they consume more resources on the FPGA side, have higher I / O usage, and have greater system integration complexity.
[0003] The SDIO interface combines a standardized protocol, a small number of pins, high effective throughput, and a mature host-side driver ecosystem, making it suitable as a universal interaction interface between the CPU and FPGA. Existing solutions typically rely on vendor-specific IP cores or simple porting of SD card-based logic on the FPGA side, resulting in poor portability, incomplete register architecture, unstable cross-clock domain buffering, inadequate interrupt mechanisms, and insufficient DMA capability utilization. Summary of the Invention
[0004] To address the shortcomings of the prior art, this invention provides a configurable SDIO master-slave hardware architecture and driving method between CPU and FPGA. This invention employs a configurable SDIO master controller on the CPU side and constructs standard SDIO slave logic on the FPGA side. It achieves unified interaction between the control plane and the data plane through standard SDIO commands, data lines, and interrupt lines, and improves system bandwidth, real-time performance, and portability by combining DMA, asynchronous FIFO, register mapping, and interrupt reporting mechanisms.
[0005] To achieve the above technical objectives, the present invention adopts the following technical solution: a configurable SDIO master-slave hardware architecture between CPU and FPGA, comprising: The SDIO host controller is located on the system-on-chip (SoC) side and is connected to the SoC. The SDIO slave device top-level encapsulation module is located on the FPGA side and is connected to the SDIO host controller via the SDIO bus; The SDIO slave device top-level encapsulation module includes: The command parsing module is configured to convert CMD52 commands and CMD53 commands into access operations to FPGA registers and access operations to FPGA data, respectively. The register mapping module, connected to the command parsing module, is configured to map the FPGA's internal control registers and status registers to the SDIO protocol address space, and carry the control flow through the AHB Slave configuration interface; The data transceiver module, connected to the command parsing module, the sending FIFO, and the receiving FIFO, is configured to realize data exchange between the CPU and the FPGA through CMD53 block transmission and FIFO buffering, and to carry the data stream through the AXI Master data interface. An asynchronous FIFO / buffer module, connected to the data transceiver module and the FPGA business logic, is configured to achieve data isolation between the SDIO clock domain and the FPGA business clock domain; The CRC check module, connected to the data transceiver module, is configured to perform cyclic redundancy check on the transmitted data. The interrupt control module is connected to the FPGA business logic, FIFO threshold detection logic, and error detection logic. It is configured to use the DAT1 signal to implement SDIO card interrupts. When an event arrives on the FPGA side, the cache threshold is triggered, or an error occurs, it actively sends an interrupt request to the CPU.
[0006] The SDIO host controller includes: The DWC_mshc controller is configured to transform the SDIO host controller from a storage access controller into an FPGA high-speed communication controller. The AHB configuration interface is configured to receive AHB bus transactions from the CPU and perform read / write operations on the internal registers of the DWC_mshc controller to configure the operating parameters of the SDIO host controller. The AXI Master data interface is configured to connect to DDR memory; The DMA descriptor / data buffer logic is configured to establish a data path between the DMA controller and the FPGA. The card clock generation and receiving clock sampling logic is configured to control the SDIO output clock, sample input data, and synchronously receive data; The reset synchronization logic is configured to synchronize the CPU clock domain, SDIO clock domain, and FPGA service clock domain after reset. Interruption reporting logic.
[0007] The command parsing module includes: The CMD sampling unit is configured to acquire the SDIO_CMD signal and output it to the command shift register; The command shift register is configured to convert the SDIO_CMD signal into parallel command frames; The command decoding unit is configured to parse CMD52 / CMD53 commands based on the Command Index and output transmission parameters, including access address, read / write direction and data length. The parameter register is configured to buffer transmitted parameters; The CRC check module is configured to output the check result; The command state machine is configured to control the command execution flow.
[0008] The register mapping module includes: The address decoding unit is configured to receive the access address output by the command parsing module and generate a register selection signal; The control register is configured to receive configuration data from the CPU and output it to the FPGA business logic. The status register is configured to acquire the FPGA status and return it to the CPU; The read / write control logic is configured to control access to registers.
[0009] The data transceiver module includes: The data shift register is configured to connect to the SDIO DAT data line to enable the conversion between serial and parallel commands; The data FIFO is configured to connect the SDIO data path and the FPGA service interface to achieve data caching; The data counter is configured to count the transmission length based on the CMD53 parameter; The transmission state machine is configured to control the data sending and receiving process.
[0010] The asynchronous FIFO / caching module includes: The dual-port RAM is configured to connect the SDIO clock domain and the FPGA service clock domain for caching data. The read and write pointers are configured to control data access in the SDIO clock domain and the FPGA service clock domain, respectively. The cross-clock synchronization circuit is configured for cross-clock domain state transfer; The status detection logic is configured to output an empty / full FIFO signal.
[0011] The CRC check module includes: The CRC register is configured to store the calculation result; The shift calculation logic is configured to perform CRC7 / CRC16 calculations according to the SDIO protocol; The comparison unit is configured to output either a pass or error signal.
[0012] The interrupt control module includes: The event detection unit is configured to collect events within the FPGA; The interrupt status register is configured to save the event status based on internal FPGA events; The interrupt mask register is configured to control the event reporting conditions based on the event status; The DAT1 driver unit is configured to actively output SDIO interrupt signals to the CPU.
[0013] It also includes configuration links, read data links, write data links, and event reporting links; The configuration link is configured as follows: the CPU accesses the SDIO master control register through the AHB Slave interface to complete master control initialization, card clock setting, bus width switching, rate mode switching, interrupt enable, and DMA parameter configuration; and accesses the FPGA-side CCCR and custom registers through CMD52. The read data link is configured as follows: the FPGA business logic writes the data to be uploaded into the asynchronous FIFO or data cache; the CPU side configures an ADMA2 or SDMA transmission task, the SDIO host controller initiates a CMD53 read operation, the FPGA side outputs data according to the SDIO protocol and includes CRC16 verification, and the SDIO host controller writes the data into the system DDR via the AXI Master interface. The write data link is configured as follows: the CPU puts the data to be sent into the system DDR and configures the DMA descriptor; the SDIO host controller sends the data to the FPGA through the CMD53 write operation; the FPGA side completes the CRC check and writes the data into the receive FIFO, and then the FPGA service clock domain reads and processes the data. The event reporting link is configured such that when an event arrives on the FPGA side, a cache threshold is triggered, or an error state occurs, an SDIO card interrupt is initiated via the DAT1 driver unit; after the CPU responds to the interrupt, it reads the status register via CMD52 and initiates CMD53 data transmission as needed.
[0014] A driver method for a configurable SDIO master-slave hardware architecture between CPU and FPGA includes the following steps: After the hardware is powered on, the SOC releases the relevant clocks and resets of the SDIO host controller to ensure the stability of the aclk, hclk, tmclk, cclk_tx / cclk_rx clocks; The CPU initializes the DWC_mshc controller, configuring the Card Interface Type to SD class interface, 4-bit data width, SDMA / ADMA2 capability, AXI / AHB bus parameters, buffer depth, and interrupt enable; The CPU executes the SDIO device enumeration process to complete FPGA-side slave device identification, CCCR reading, bus width switching, function enabling, and rate mode switching. The CPU configures the FPGA user registers via CMD52, including data window, transfer direction, block size, threshold, interrupt enable, and service startup parameters. During batch data transfer, the CPU establishes an SDMA or ADMA2 transfer task, the SDIO master controller initiates a CMD53 read / write operation, and interacts with the DDR via the AXI Master interface; The FPGA side notifies the CPU via DAT1 interrupt when data preparation is complete, reception is complete, or an exception occurs. The CPU reads the status and clears the interrupt.
[0015] In summary, the present invention has achieved the following technical effects: 1. This application proposes a system architecture that utilizes SDIO host controller and FPGA-side SDIO slave device logic to realize CPU-FPGA interaction, unifying register configuration, batch data transmission and event interrupt on the standard SDIO bus, solving the problems of insufficient bandwidth of traditional low-speed interfaces and high resource consumption of high-speed parallel interfaces.
[0016] 2. This application completes master control register access through the AHB Slave configuration interface and data transfer between the DDR and SDIO data channels through the AXI Master DMA interface. On the FPGA side, the control flow and data flow are respectively carried by the register window of the register mapping module and the data FIFO of the data transceiver module, reducing the CPU's handling burden and realizing the separation of the configuration channel and the DMA data channel. By adding a register window and a data FIFO on the FPGA side, this application expands the SDIO access object into a programmable resource inside the FPGA. The register window is used to carry the control flow, realizing the CPU's configuration and status query of the FPGA's internal modules. The data FIFO is used to carry the data flow, realizing high-speed caching and transmission of FPGA business data. This decouples the control channel and the data channel, and combines DMA to realize batch data transfer, reducing CPU involvement, improving system bandwidth and real-time performance, and enhancing the scalability of FPGA business logic.
[0017] 3. This application configures DWC_mshc as an SDIO / SD class interface, with 4-bit data width, SDMA / ADMA2 support, ADMA3 disabled, configurable AXI ID width and Outstanding parameter, and asynchronous FIFO and DMA clock gating enabled, to balance bandwidth, area, and power consumption. DWC_mshc implements the above configuration through a protocol control module, 4-bit data channel logic, DMA controller, ADMA descriptor parser, AXI transaction management unit, asynchronous FIFO, and clock gating unit. The SDIO / SD mode configuration is completed by the protocol control module, and the 4-bit data width is increased by using the DAT[3:0] parallel data channel to improve the amount of data transmitted in a single transaction. SDMA / ADMA2 is implemented by the DMA state machine and descriptor parsing logic, enabling automatic data transfer between DDR and SDIO FIFO. AXI... The ID width and Outstanding parameter are adjusted through AXI transaction management logic to improve bus concurrency access capabilities; the asynchronous FIFO achieves isolation between the SDIO clock domain and the DMA clock domain through dual-port RAM and cross-clock synchronization circuitry, ensuring stable high-speed data transmission; disabling ADMA3 reduces additional hardware logic, while enabling DMA clock gating reduces idle state power consumption. Through this configuration, data throughput is improved while avoiding unnecessary hardware resource consumption, achieving a balance between bandwidth, area, and power consumption.
[0018] 4. In this application, the FPGA side actively reports data readability, reception completion, error status and service events through the SDIO DAT1 card interrupt mechanism, eliminating the need for continuous polling on the CPU side, thereby improving real-time performance and reducing system load.
[0019] 5. This application sets up an asynchronous FIFO between the SDIO clock domain and the FPGA service clock domain, and synchronously cancels the reset signals of each clock domain to ensure stable data transmission between clock domains with different frequencies and phases.
[0020] 6. This application also provides a slave device register system that combines standard registers and user registers. The FPGA side simultaneously implements the CCCR standard register and user-defined registers, enabling the CPU to complete device enumeration and function enable according to the standard SDIO process, and to complete business parameter configuration and status query through the user-defined registers.
[0021] 7. This application also provides a low-resource-capable SDIO connection method without dedicated PHY. Within the target rate range, the SDIO low-speed / high-speed connection method without dedicated PHY is used, and the logic of the FPGA slave device is directly interacted with through SDIO_CLK, CMD, DAT[3:0], reducing PHY dependency and porting costs.
[0022] 8. This application defines a complete driver flow from controller initialization, device enumeration, CMD52 configuration, CMD53 DMA transfer to DAT1 interrupt handling, and provides supporting test cases for functional, exception, stress and long-term stability verification to ensure that the solution can be implemented in engineering. Detailed Implementation
[0023] The present invention will now be described in further detail.
[0024] This specific embodiment is merely an explanation of the present invention and is not intended to limit the invention. After reading this specification, those skilled in the art can make modifications to this embodiment without contributing any inventive step, but such modifications are protected by patent law as long as they are within the scope of the claims of the present invention.
[0025] Example: A configurable SDIO master-slave hardware architecture between CPU and FPGA includes: The SDIO host controller (SDIO_WRAPPER) is located on the system-on-chip (SoC) side and is connected to the SoC. The SDIO slave device top-level encapsulation module (SDIO_DEVICE_WRAPPER) is located on the FPGA side and is connected to the SDIO master controller via the SDIO bus.
[0026] This application integrates an SDIO host controller as an SDIO host subsystem on the SOC side, which connects to the SOC's AHB / AXI bus, clock reset network and interrupt controller externally, and connects to the SDIO pins internally; at the same time, an SDIO slave device top-level encapsulation module is set on the FPGA side, which connects to SDIO_CLK, CMD, DAT[3:0] externally, and connects to the FPGA business logic, register group, data FIFO and event interrupt source internally.
[0027] On the CPU side, this application employs a configurable SDIO host controller. On the FPGA side, this application constructs standard SDIO slave logic, realizing unified interaction between the control plane and the data plane through standard SDIO commands, data lines, and interrupt lines. It also combines DMA, asynchronous FIFO, register mapping, and interrupt reporting mechanisms to improve system bandwidth, real-time performance, and portability.
[0028] Specifically, the CPU uses Synopsys DWC_mshc (Mobile Storage Host Controller) as the SDIO host controller, and the SDIO host control function is implemented through SD interface type configuration.
[0029] The SDIO host controller includes: The DWC_mshc controller is configured to transform the SDIO host controller from a storage access controller into an FPGA high-speed communication controller. The AHB configuration interface is configured to receive AHB bus transactions from the CPU and perform read and write operations on the internal registers of the DWC_mshc controller to configure the operating parameters of the SDIO host controller. The AXI Master data interface is configured to connect to DDR memory; The DMA descriptor / data buffer logic is configured to establish a data path between the DMA controller and the FPGA; The card clock generation and receiving clock sampling logic is configured to control the SDIO output clock, sample input data, and synchronously receive data; The reset synchronization logic is configured to synchronize the CPU clock domain, SDIO clock domain, and FPGA service clock domain after reset. Interruption reporting logic.
[0030] In this application, dwc_mshc is no longer a storage device, but rather transforms the SDIO Host from a storage access controller into an FPGA high-speed communication controller, enabling unified SDIO interaction between the CPU and FPGA, and leveraging mature Host capabilities to reduce development costs and avoid redesigning the SDIO Host.
[0031] Meanwhile, this application uses the AHB configuration interface for the CPU—AHB—SDIO_WRAPPER register space—DWC_mshc, and further integrates it with the FPGA-side register mapping to form an integrated path for CPU configuration of the SDIO Host and CPU control of the FPGA device. This achieves unified control channels, reduces additional GPIO / SPI control interfaces, and improves system integration. An AXI DMA interface is also provided to implement the link between FPGA—SDIO—AXI DMA—DDR, thereby enabling high-speed data transfer of FPGA services, reducing CPU involvement in data copying, increasing effective bandwidth, and supporting continuous transmission of large data volumes. In existing technologies, DMA descriptors / data buffer related logic are typically used to describe data addresses, lengths, and chained transmissions. This application uses them to connect DMA and FPGA real-time data streams, improving continuous data transmission efficiency, avoiding frequent CPU involvement, and enhancing system throughput. In existing technologies, card clock generation and receive clock sampling logic are typically used to ensure SD card communication. This application redesigns the clock adaptation, including SDIO output clock control, input data sampling, and receive data synchronization, solving clock skew, data setup and hold time, and high-speed sampling issues when the FPGA acts as an SDIO slave device. It also improves the stability of high-speed SDIO communication, supports 4-bit high-speed mode, and enhances the system's real-time data exchange capability. Since it needs to manage the CPU clock domain, SDIO clock domain, and FPGA service clock domain simultaneously, this application sets up reset synchronization logic to achieve reset input—synchronization circuit—reset output for each clock domain, avoiding cross-clock domain anomalies, improving system startup reliability, and supporting dynamic loading of FPGA service logic. DWC_mshc supports SDIO card interrupts and Host interrupts. This application uses the interrupt mechanism for data completion, task completion, and exception events. This application utilizes the FPGA to actively notify the CPU, reducing CPU polling overhead and improving real-time response capabilities.
[0032] This application, based on an SDIO host controller, implements an interaction architecture design between a CPU, an SDIO host controller, and an FPGA SDIO slave device. Existing methods typically use DWC_mshc for CPU control of SD cards / eMMC. This application utilizes it to implement the CPU—DWC_mshc (SDIO Host)—SDIO bus—FPGA (SDIO Device)—FPGA business logic, reconfiguring a mature storage controller as a high-speed CPU-FPGA communication master controller. Traditional DWC_mshc only addresses the CPU-side host, lacking an FPGA SDIO device. This application sets up a command parsing module, register mapping module, data transceiver module, asynchronous FIFO, CRC module, and interrupt control module on the FPGA side. Traditional CPU access to FPGA typically uses SPI, which is slow, and UART is unsuitable for large datasets, while AXI consumes significant resources. This application utilizes a unified design for the SDIO configuration channel, DMA data channel, and interrupt channel, using CMD52 for register access, CMD53 for DMA transfer, and DAT1 for interrupt notification.
[0033] The SDIO host controller provides standard SDIO protocol master control capabilities, realizing unified carrying of control, data, and events. Traditional CPU-FPGA interaction usually requires multiple interfaces: (1) SPI / UART / I2C for control; (2) AXI / PCIe for high-speed data; and (3) GPIO for event notification. The above interfaces have the problems of a large number of interfaces and scattered software drivers. This application uses the SDIO host controller to map control configuration, data transmission, and event notification onto the SDIO bus. At the same time, SDIO uses multi-bit parallel data lines to increase the transmission volume per unit clock, DMA reduces CPU participation, and improves effective throughput. The CPU is only responsible for configuring DMA and does not participate in the handling of each data byte. In addition, the SDIO interrupt mechanism supports FPGA active notification. The traditional polling method is for the CPU to continuously read the FPGA status, discover the event, and process it. The disadvantage is poor real-time performance. This application adopts the method of FPGA event occurrence - DAT1 interrupt - SDIO Host response - CPU read status, avoiding periodic CPU polling and improving event response speed. At the same time, due to the adoption of the standard SDIO protocol, the CPU side has standard driver compatibility, improving system portability.
[0034] On the FPGA side, this application no longer relies on dedicated vendor IP cores, but instead uses portable RTL to implement the SDIO slave device protocol stack, which specifically includes a command parsing module, a register mapping module, a data transceiver module, an asynchronous FIFO / buffer module, a CRC check module, and an interrupt control module.
[0035] (1) The command parsing module is configured to convert CMD52 commands and CMD53 commands into access operations to FPGA registers and access operations to FPGA data, respectively; In this application, the command parsing module can parse SDIO standard commands and necessary basic SD commands, with a focus on supporting CMD52 single-byte / register access and CMD53 multi-byte / block transfer commands. The command parsing module converts SDIO commands into FPGA internal register access and data transfer control, and improves data transfer efficiency and response speed through CMD53 parameter buffering and hardware state machine.
[0036] Furthermore, the command parsing module includes: The CMD sampling unit is configured to acquire the SDIO_CMD signal and output it to the command shift register; The command shift register is configured to convert the SDIO_CMD signal into parallel command frames; The command decoding unit is configured to parse CMD52 / CMD53 commands based on the Command Index and output transmission parameters, including access address, read / write direction and data length. The parameter register is configured to buffer transmitted parameters; The CRC check module is configured to output the check result; The command state machine is configured to control the command execution flow.
[0037] The command parsing module of this application not only parses standard SDIO commands, but also adds CMD52 register access parsing, CMD53 data window access parsing, and command type mapping to FPGA internal operations based on FPGA interaction requirements. Furthermore, this application uses RTL for in-house implementation of the state machine FSM, command field parsing logic, response generation logic, and CRC interface, eliminating the need to call FPGA vendor SDIO IP or specific device SDIO controllers. Therefore, the command parsing module of this application only relies on the publicly available SDIO protocol specification and can be migrated to different FPGAs.
[0038] (2) Register mapping module, connected to command parsing module, is configured to map the FPGA’s internal control registers and status registers to the SDIO protocol address space and carry the control flow through the AHB Slave configuration interface; In this application, the register mapping module can implement standard registers such as CCCR and user-defined function registers for device enumeration, function enabling, data window selection, status readback, and interrupt control. The register mapping module establishes a mapping between the SDIO address space and the internal resources of the FPGA, enabling unified configuration and status access of the FPGA by the CPU, and improving interactive flexibility through register window design.
[0039] Furthermore, the register mapping module includes: The address decoding unit is configured to receive the access address output by the command parsing module and generate a register selection signal; The control register is configured to receive configuration data from the CPU and output it to the FPGA business logic. The status register is configured to acquire the FPGA status and return it to the CPU; The read / write control logic is configured to control access to registers.
[0040] This application's register mapping module establishes a register window mechanism for FPGA service control, which not only includes the CCCR standard registers but also extends to user control registers, status registers, data window registers, and interrupt configuration registers. It is implemented autonomously through RTL register groups, address decoding logic, and status register mapping. FPGA internal services only need to connect to the register bus and control signal, eliminating the need for a vendor-manufactured SDIO controller.
[0041] In terms of hardware connectivity, the register mapping module is connected to the command parsing module: signals such as reg_addr, wr_data, rd_data, reg_wr_en / reg_rd_en, and reg_valid are transmitted through the register access interface. After parsing the CMD52, the command parsing module outputs the access address, read / write direction, and data, and the register mapping module selects the corresponding register through address decoding.
[0042] The register mapping module is connected to the FPGA business logic: the output of the control register of the register mapping module is connected to the algorithm module, data processing module, FIFO control logic and interrupt control module; the status register of the register mapping module is connected to the busy / done / error status signals inside the FPGA.
[0043] Additionally, the AHBSlave configuration interface is located on the SoC side and is used by the CPU to configure the SDIO master controller DWC_mshc. The CPU's access path to the FPGA registers is: CPU → AHBSlave → SDIO master controller → SDIO_CMD (CMD52) → FPGA command parsing module → address decoding / register mapping module → FPGA business logic.
[0044] (3) Data transceiver module, connected to command parsing module, send FIFO, receive FIFO, is configured to realize data exchange between CPU and FPGA through CMD53 block transmission and FIFO buffer, and carry data stream through AXI Master data interface; The data transceiver module in this application supports 1-bit and 4-bit data line modes, provides byte-mode and block-mode data transmission and reception capabilities for CMD53, and interfaces with the FPGA's internal data buffer. The data transceiver module achieves high-speed data exchange between the CPU and FPGA through CMD53 block transmission and FIFO buffering, improving system bandwidth. Data flow is controlled by a hardware state machine, enhancing real-time performance.
[0045] Furthermore, the data transceiver module includes: The data shift register is configured to connect to the SDIO DAT data line to enable the conversion between serial and parallel commands; The data FIFO is configured to connect the SDIO data path and the FPGA service interface to achieve data caching; The data counter is configured to count the transmission length based on the CMD53 parameter; The transmission state machine is configured to control the data sending and receiving process.
[0046] In terms of hardware connection, the data transceiver module is connected to the command parsing module on the FPGA side through internal control signals such as address, read / write direction, transmission length, and data transceiver enable, and is connected to the transmit / receive FIFO through signals such as read / write enable, data, and FIFO empty / full status; the AXIMaster data interface is located on the SoC side, and the AXIMaster data interface and the FPGA side data transceiver module indirectly form a data path through the SDIO bus. The specific hardware connection path is: FPGA data transceiver module—SDIO_DAT[3:0]—SDIO master controller—internal FIFO / DMA controller—AXIMaster interface—system DDR, where CMD53 is responsible for starting and controlling block data transmission.
[0047] This application's data transceiver module is designed for high-speed data exchange on FPGAs, supporting CMD53 byte mode, CMD53 block mode, and FPGA TX / RX FIFO connection. It utilizes an independently developed RTL to implement DAT[3:0] status control, bit / byte / block counters, data shift registers, and flow control (FSM), eliminating the need for FPGA vendor SDIO interface IP.
[0048] (4) Asynchronous FIFO / buffer module, connected to the data transceiver module and FPGA business logic, is configured to achieve data isolation between the SDIO clock domain and the FPGA business clock domain; In this application, the asynchronous FIFO / buffer module provides cross-clock domain buffering between the SDIO clock domain and the FPGA system clock domain, avoiding sampling instability and data loss, realizing data isolation between the SDIO clock domain and the FPGA service clock domain, improving the stability of high-speed data transmission, and enhancing continuous transmission capability through the caching mechanism.
[0049] Furthermore, the asynchronous FIFO / caching module includes: Dual-port RAM is configured to connect the SDIO clock domain and the FPGA business clock domain for data caching; it is used to cache data transmitted across clock domains, and the write and read ends can be driven by different clocks. The read and write pointers are configured to control data access in the SDIO clock domain and the FPGA service clock domain, respectively. This includes: a write address pointer generation circuit (operating in the SDIO_CLK domain to record the current write position); a read address pointer generation circuit (operating in the FPGA service clock domain to record the current read position); and a Gray code conversion circuit (converting binary read and write pointers to Gray code to reduce the risk of metastability caused by simultaneous changes in multiple bits during cross-clock transmission). The cross-clock synchronization circuit is configured for cross-clock domain state transfer, synchronizing the read / write pointer to another clock domain to determine the FIFO empty / full status; The status detection logic is configured to output FIFO empty / full signals. Specifically, it generates empty, full, and other status signals based on the read / write pointer relationship to control data read and write.
[0050] The asynchronous FIFO / buffer module is positioned between the data transceiver module and the FPGA business logic. It is connected via internal hardware signals such as write data, write enable, read data, read enable, and FIFO empty / full, data valid. In the receiving direction, the data transceiver module writes data received in the SDIO_CLK clock domain into the receive FIFO, which is then read by the FPGA business logic in the business clock domain. In the transmitting direction, the FPGA business logic writes data into the transmit FIFO, which is then read by the data transceiver module in the SDIO_CLK clock domain and transmitted via SDIO_DAT[3:0]. Internally, the FIFO employs dual-port RAM, read / write pointers, Gray code conversion, and dual-flip-flop synchronization circuitry to achieve isolation between the two clock domains and reliable cross-domain transmission.
[0051] Since the FPGA has two asynchronous clock domains, SDIO_CLK and FPGA service clock, this application adds an isolation design between the SDIO protocol domain and the FPGA service domain. It employs standard RTL dual-port RAM, write pointers, read pointers, Gray code synchronization, and cross-domain synchronizers, without relying on Xilinx FIFO Generator or Intel FIFO IP.
[0052] (5) CRC check module, connected to the data transceiver module, is configured to perform cyclic redundancy check on the transmitted data; The CRC verification module in this application implements CRC7 command verification and CRC16 data verification. When the verification fails, it rejects the data or returns an error status, thereby improving the reliability of the link. Hardware verification ensures the reliability of data transmission and improves real-time processing capabilities.
[0053] Furthermore, the CRC check module includes: The CRC register is configured to store the calculation result; The shift calculation logic is configured to perform CRC7 / CRC16 calculations according to the SDIO protocol; The comparison unit is configured to output either a pass or error signal.
[0054] The CRC check module is connected to the data transceiver module inside the FPGA via hardware signals such as data bus, data valid / enabled, check start, check result and error indication. When sending, the data transceiver module synchronously sends the data to be sent to the CRC check module, which calculates CRC16 in real time and sends the check result along with the data via SDIO_DAT[3:0]. When receiving, the CRC check module performs CRC check on the data received from SDIO_DAT[3:0] by the data transceiver module and feeds back the check pass or error status to the data transceiver module and related status registers.
[0055] This application treats the CRC check module as an independent reliability module on the FPGA side, including: CMD CRC7 for command integrity checking and DATA CRC16 for data integrity checking, which are integrated with data reception, error status, and interrupt mechanisms. The LFSR shift register, CRC polynomial logic, and check comparison logic are implemented independently, based solely on the SDIO protocol definition.
[0056] (6) Interrupt control module, connected to FPGA business logic, FIFO threshold detection logic and error detection logic, is configured to use DAT1 signal to implement SDIO card interrupt. When an event arrives on the FPGA side, the cache threshold is triggered or an error state occurs, it actively sends an interrupt request to the CPU. This application's interrupt control module reuses the DAT1 signal to implement SDIO card interrupts. When an event arrives on the FPGA side, a cache threshold is triggered, or an error state occurs, it can actively initiate an interrupt request to the CPU, enabling the FPGA to actively notify the CPU, replacing the traditional polling method, improving system real-time performance, and enhancing interactive capabilities through unified event management.
[0057] Furthermore, the interrupt control module includes: The event detection unit is configured to collect events within the FPGA; The interrupt status register is configured to save the event status based on internal FPGA events; The interrupt mask register is configured to control the event reporting conditions based on the event status; The DAT1 driver unit is configured to actively output SDIO interrupt signals to the CPU.
[0058] On the FPGA side, the interrupt control module is connected to the FPGA business logic, FIFO threshold detection logic, and error detection logic through event status signals. It receives event interrupt status, enable, and mask configuration through interrupt status registers and interrupt mask registers, and is connected to the DAT1 driver unit through the interrupt control state machine. When the interrupt triggering condition is met, the DAT1 driver unit pulls the SDIO_DAT1 signal low and sends a card interrupt to the SoC-side SDIO master controller via the SDIO bus. The interrupt output of the master controller is then connected to the SoC interrupt controller and notifies the CPU to process the interrupt.
[0059] The SDIO DAT1 card interrupt uses a level-triggered method, typically involving pulling the DAT1 line low for a certain period until the host detects the interrupt and completes the response, rather than sending a momentary pulse. The FPGA side controls DAT1 via open-drain; when an event needs to be reported, DAT1 is pulled low, and when no event occurs, DAT1 is released, and the host-side pull-up resistor restores it to a high level. During 4-bit SDIO data transmission, DAT[3:0] are used for data transmission, and DAT1 cannot be used to generate a card interrupt. Therefore, the FPGA-side interrupt control logic needs to be arbitrated in conjunction with the SDIO data transmission state machine and bus idle detection logic: only when the SDIO bus is detected to be idle (not in the CMD53 data transmission phase) and there is an event to be reported, is the DAT1 driver allowed to pull DAT1 low; during data transmission, interrupt requests are first buffered in the interrupt suspend register, waiting for the current data transmission to complete before initiating the DAT1 interrupt.
[0060] This application reuses DAT1 as an active event reporting channel for the FPGA. The triggering sources are data preparation completion, FIFO reaching the threshold, FPGA service exception, and task completion. RTL implements the interrupt status register, interrupt mask register, event merging logic, and DAT1 driver control, eliminating the need for interrupt IP from the FPGA vendor.
[0061] This application transforms SDIO from a traditional fixed-function peripheral into a programmable business interaction interface for FPGAs, replacing it with a top-level encapsulation module. A command parsing module converts CMD52 / CMD53 into FPGA register access and FPGA data access, thus SDIO commands are no longer used to access fixed peripherals but instead to access the FPGA's internal expandable logic. Simultaneously, SDIO responses are dynamically generated based on the FPGA's internal state, data transmission state, and error state, improving the efficiency of the CPU in acquiring FPGA status, reducing polling, and enhancing real-time interaction. The data channel of this application connects SDIO DAT—data channel—FPGA business logic, supporting FPGA-generated data upload and CPU-sent data to the FPGA, changing the data object from traditional "peripheral data" to "FPGA computational data." This application designs CRC as an independent RTL module, including a CRC register, polynomial calculation logic, and check comparison logic, integrating it with data status, error feedback, and interrupt mechanisms to improve high-speed data reliability, reduce the risk of erroneous data entering the FPGA business logic, and eliminate reliance on vendor-specific CRC IP. This application also expands the SDIO register space by adding FPGA control registers, status registers, and data window registers, achieving a unified control interface, reducing additional control buses, and improving system integration. This application adds an isolation structure between the SDIO clock domain and the FPGA service clock domain, including dual-port RAM, read / write pointers, and cross-clock synchronization. Unlike traditional single-clock devices, this application supports FPGA multi-clock service systems. This application uses DAT1 for FPGA-initiated event notification to the CPU. Events include data preparation completion, task completion, and abnormal states. Unlike traditional CPU-initiated queries, this application uses FPGA-initiated push notifications.
[0062] This application also includes configuration links, read data links, write data links, and event reporting links.
[0063] (1) The configuration link is configured as follows: the CPU accesses the SDIO master control register through the AHB Slave interface to complete master control initialization, card clock setting, bus width switching, rate mode switching, interrupt enable and DMA parameter configuration; and accesses the FPGA-side CCCR and custom registers through CMD52. Specifically, after DMA configuration, the CPU does not actively move data in this application; instead, data transfer is automatically initiated by the internal DMA controller or DMA state machine of the DWC_mshc. The main buffers include: an internal data FIFO in the DWC_mshc, buffered SDIO bus data, and a FIFO that matches the SDIO clock with the AXI / DDR access speed. An asynchronous FIFO on the FPGA side isolates the SDIO_CLK from the FPGA service CLK to prevent data loss across clock domains, and a DDR cache supports large-volume DMA data exchange.
[0064] SDIO rate mode switching mainly involves adjusting the clock frequency and sampling timing, not simply switching the clock edge. For example, the default mode clk is 25MHz, while the default mode is 50MHz. The switching process involves the CPU configuring the host register, changing the clk divider, re-dividing the SDIO clk generator, outputting a new SDIO clk, and adjusting the input sampling logic.
[0065] User-defined registers are connected to the internal business modules of the FPGA via the register interface bus, specifically including: The control register is connected to the service state machine or algorithm core and outputs control signals such as start / stop / enable to start or stop service processing; The parameter register connects to the algorithm module and the data processing module, and outputs configuration parameters such as sampling parameters, working mode, and threshold. The status register is connected to the status output terminal of the service module, collects status signals such as busy / done / error, and feeds them back to the CPU; The FIFO configuration register is connected to the transmit / receive FIFO control logic to configure the FIFO operating mode, data length, or threshold parameters. The interrupt control register connects the event detection logic and the DAT1 interrupt control state machine, and is used to set event masking and interrupt enabling.
[0066] User-defined registers map the internal hardware resources of the FPGA to an address space accessible to the CPU via SDIO, enabling the CPU to control and read the status of the FPGA module.
[0067] User-defined registers are register mapping spaces designed on the FPGA side for business logic. These may include, for example, service control registers, parameter configuration registers, status query registers, data length registers, and interrupt control registers. Their hardware implementation mainly includes register storage units, address decoding logic, read / write control logic, and a register mapping table. When the CPU accesses an FPGA register address via CMD52, the SDIO command parsing module outputs a register access request, which, after address decoding, selects the corresponding register. The written data is latched into the control register to control the start, stop, or parameter adjustment of internal FPGA modules. The status register collects internal FPGA status signals for the CPU to read. For example, the algorithm start register is connected to the enable input of the FPGA algorithm state machine to control the operation of the algorithm core; the data length register is connected to the DMA / FIFO control logic to configure the amount of data transferred in a single operation; and the interrupt enable register is connected to the event interrupt control module to control which business events are allowed to trigger the DAT1 interrupt.
[0068] The custom registers mentioned in this application include, for example: the algorithm control register, address 0x1000, bit 0 for algorithm startup, bit 1 for reset, and bit 2 for working mode, which ultimately controls the startup and working mode switching of the FPGA algorithm core. Another example is the data acquisition configuration register, address 0x1004, bits [7:0] for sampling length and bits [15:8] for trigger mode, which configures the data sampling length and data buffering method.
[0069] Compared to traditional configuration methods, which configure SDIO peripherals, this application configures the internal programmable resources of the FPGA. It extends SDIO from a peripheral configuration interface to a unified CPU-FPGA control interface, unifying control and data configuration. All control, data, and event interactions are completed through a single standard interface. Furthermore, this application's DMA link is optimized for FPGA data flow, while traditional DMA serves storage devices. Therefore, this application reduces CPU handling load and improves data throughput.
[0070] (2) The data read link is configured as follows: the FPGA business logic writes the data to be uploaded into the asynchronous FIFO or data buffer; the CPU side configures the ADMA2 or SDMA transmission task, the SDIO host controller initiates the CMD53 read operation, the FPGA side outputs the data according to the SDIO protocol and attaches CRC16 verification, and the SDIO host controller writes the data into the system DDR through the AXI Master interface. The FPGA business logic in this application is not the SDIO protocol itself, but rather the logic module inside the FPGA that actually executes user functions. Depending on the application scenario, it can be an algorithm processing module, a data acquisition module, an image processing module, a signal processing module, a control state machine, etc.
[0071] In this application, the CPU does not directly configure FPGA data; instead, it configures the DMA registers and descriptors within the SDIO Host controller. Specifically, the configuration includes: for example, when configuring ADMA2, the CPU configures the DMA descriptor address, informing the SDIO Host controller of the storage location of the descriptor. Similarly, when configuring the data target address, it specifies the location where the DMAFPGA data is written to DDR, for example, DDR_ADDR = 0x80000000. Furthermore, when configuring the data length (Transfer Length = 4096 Bytes), the DMA startup control is set to DMA Enable = 1. After configuration, the CPU does not directly handle the data transfer. The process in this application is: DMA state machine — read ADMA descriptor — start CMD53 — receive SDIO data — write to DDR.
[0072] When a CMD53 read request arrives at the FPGA side, the command parsing module parses the command type, address, and transmission length, and generates a data read enable signal to control the data channel to read data from the asynchronous FIFO or data buffer. Subsequently, the data is converted by a data shift register and output through the SDIO DAT[3:0] interface. Simultaneously, the CRC16 module performs real-time verification of the transmitted data. This process is automatically completed by the FPGA's internal hardware state machine, enabling the CPU to read FPGA service data through the standard SDIO interface, thus improving data transmission efficiency and real-time performance.
[0073] CRC16 is a hardware verification mechanism used to detect errors in SDIO data transmission. During data transmission, the FPGA-side CRC verification module performs bit-by-bit calculations on the data to be transmitted according to the CRC16 polynomial specified in the SDIO protocol. Internally, this is achieved through a CRC register, a shift register, and XOR feedback logic: for each input bit, the CRC register performs an XOR operation with the input data based on the current highest bit, and then shifts and updates according to the set polynomial. After all data is calculated, a 16-bit verification result is obtained. This result is sent along with the data via the SDIO bus. The CPU-side SDIO master controller receives the data and recalculates the CRC16 using the same algorithm, comparing it with the received verification value to determine if the data is correct. Hardware CRC16 calculation enables high-speed data integrity verification without consuming CPU resources, improving the reliability of SDIO transmission.
[0074] Compared to the traditional SDIO method of reading data from fixed peripherals, this application directly connects FPGA business data to the SDIO data channel. Data generated by the business logic is first buffered in an asynchronous FIFO. After the CPU initiates a CMD53 read operation, the FPGA-side hardware state machine automatically reads the FIFO and continuously outputs it via DAT[3:0], while simultaneously performing real-time verification using CRC16. The CPU then uses ADMA2 / SDMA to directly write the data to DDR. The high-speed data link set up in this application—FPGA business logic—asynchronous FIFO—CMD53 block transfer—DMA—DDR—reduces CPU involvement and cross-clock domain impact, thereby improving transmission bandwidth and real-time performance.
[0075] (3) The write data link is configured as follows: the CPU puts the data to be sent into the system DDR and configures the DMA descriptor. The SDIO host controller sends the data to the FPGA through the CMD53 write operation. After the FPGA completes the CRC check, it writes the data into the receive FIFO and then reads and processes it by the FPGA service clock domain. In this application, the CPU configures the internal DMA-related registers of DWC_mshc via the AHB configuration interface and establishes an ADMA2 descriptor table in the system DDR. The descriptor records the DDR address of the data to be sent, the transfer length, and control information such as valid / end control. Then, the starting address of the descriptor table is written to the DMA address register of the SDIO master controller, and CMD53 write transfer is initiated. Subsequently, the internal DMA controller of DWC_mshc automatically reads the descriptor and the corresponding DDR data through the AXI Master interface and sends it to the SDIO data channel via the master controller's internal FIFO, eliminating the need for the CPU to handle data byte by byte. If SDMA is used, the DMA buffer address and transfer length are mainly configured, and the DMA controller automatically transfers data according to the configuration.
[0076] This application's data writing link differs from the traditional SDIO method of writing data to fixed-function peripherals or storage space. It directly sends CPU-side DDR data to the FPGA programmable processing module via DMA—CMD53—FPGA receive FIFO—FPGA business logic. By utilizing DMA and CMD53 block transmission, CPU involvement is reduced and continuous transmission bandwidth is increased. CRC check is used to ensure data reliability, and asynchronous FIFO is used to decouple the SDIO clock domain from the FPGA business clock domain, allowing data to be directly processed by algorithm cores or state machines under different business clocks, thus balancing bandwidth, real-time performance, and scalability.
[0077] (4) The event reporting link is configured as follows: when an event arrives on the FPGA side, the cache threshold is triggered, or an error state is generated, the SDIO card interrupt is initiated through the DAT1 driver unit; after the CPU responds to the interrupt, it reads the status register through CMD52 and initiates CMD53 data transmission as needed.
[0078] In traditional technologies, interrupt control is an existing functional mechanism within the SDIO protocol, and traditional SDIO devices can implement card interrupts via DAT1. Unlike traditional technologies, this application applies the SDIO card interrupt mechanism to a CPU-FPGA interaction scenario, where FPGA service events actively trigger SDIO interrupts. The specific hardware includes FPGA-side event detection logic, an interrupt status register, an interrupt mask register, an interrupt control state machine, and a DAT1 driver circuit. When an event signal is generated by an internal FPGA service module (such as data acquisition completion, algorithm calculation completion, FIFO reaching a threshold, or an abnormal state), the event detection logic sets the corresponding event bit to 1 and writes it to the interrupt status register. The interrupt control state machine reads the event status and, in conjunction with the interrupt mask register, determines whether reporting is allowed. If the conditions are met, it controls the DAT1 driver circuit to pull the DAT1 signal low to generate a card interrupt. After detecting the DAT1 interrupt, the CPU-side SDIO master controller reads the FPGA status register through the interrupt service routine to further obtain specific event information.
[0079] This application's event reporting link differs from the traditional SDIO device approach of the CPU actively polling peripheral status. It extends the SDIO DAT1 card interrupt mechanism to allow the FPGA to proactively notify the CPU of service events. Traditional methods typically involve the CPU periodically reading device registers to determine status, resulting in response latency and CPU usage issues. This application, through a link of FPGA service event detection—interrupt status register—interrupt control logic—DAT1 card interrupt—CPU response, enables the FPGA to proactively notify the CPU when data preparation is complete, task completion occurs, or an exception occurs. This application combines the standard SDIO interrupt channel with the FPGA's internal service status to achieve unified interaction of control, data, and events, improving the system's real-time response capability. Furthermore, it employs a proprietary RTL implementation for event detection, interrupt management, and DAT1 driver logic, eliminating reliance on FPGA vendor-specific SDIO interrupt IP and enhancing system portability.
[0080] This application also includes a clock and reset mechanism that configures, isolates, and resets multiple independent clock domains according to the high-speed CPU-FPGA interaction requirements.
[0081] The specific clock and reset parameters are shown in Table 1 below: Table 1 Specific Clock and Reset Signals On the FPGA side, the SDIO_CLK clock domain and the FPGA service clock domain are independent of each other, and data cross-domain communication between them is achieved through an asynchronous FIFO. Specifically, the data cross-domain communication between the SDIO_CLK clock domain and the FPGA service clock domain is implemented through an asynchronous FIFO hardware unit. The data receiving logic of the SDIO_CLK domain writes the received data into the dual-port RAM, and the write pointer records the write position. The FPGA service clock domain generates a read pointer based on its own clock, reads data from the dual-port RAM, and outputs it to the service processing module. Since the two clock domains are independent, the read and write pointers are converted to Gray code and then transmitted to the other clock domain through a dual-flip-flop synchronization circuit for FIFO empty / full state judgment, avoiding metastability caused by direct cross-clock sampling. The reset section adopts independent synchronous release logic for each clock domain. The reset synchronizer generates reset signals for the SDIO transmit domain, receive domain, and FPGA service domain respectively, ensuring that each module exits the reset after the corresponding clock stabilizes, thereby achieving reliable data transmission and state consistency between different frequency clock domains.
[0082] The reset signal is released synchronously according to the clock domain to avoid metastability caused by cross-clock domain reset. The reset release of each functional module inside the DWC_mshc main controller cannot be earlier than the corresponding working clock, otherwise it may cause abnormal register status or data path initialization failure. Therefore, the main controller soft reset is only executed after the relevant clock is stable to ensure that the controller register and data channel status are consistent.
[0083] This application also sets up an interface adaptation mechanism: the SDIO host controller side uses the AXI Master interface to connect to the SOCDDR for DMA read and write; and uses the AHB Slave interface to connect to the CPU configuration bus for register access. The SDIO physical interface exposes SDIO_CLK, SDIO_CMD, and SDIO_DAT[3:0], where DAT1 is multiplexed as a card interrupt signal. On the FPGA side, the same SDIO pins are used to connect to the slave device logic, and the internal business interface is abstracted into four types of interfaces: register access interface, transmit FIFO interface, receive FIFO interface, and event interrupt interface.
[0084] Specifically, the SDIO pins for the FPGA-side SDIO slave device logic connection mainly include: SDIO_CLK: Clock input pin, output by the CPU-side SDIO master controller, used to drive the timing of the FPGA-side SDIO interface; SDIO_CMD: Bidirectional command pin, used to receive commands such as CMD52 / CMD53 sent by the CPU and return a response; SDIO_DAT[3:0]: Four bidirectional data pins used for data transmission and reception; SDIO_DAT1: Also used for SDIO interrupt notification; The SDIO_CLK pin is connected to the FPGA's internal clock sampling logic, providing a timing reference for command parsing and data reception; The SDIO_CMD pin is connected to the command parsing module after passing through the input buffer. It is used to parse CMD52 / CMD53 and is connected to the response generation module to output the response. The SDIO_DAT[3:0] pins are connected to the data transceiver module, and the parallel-to-serial conversion is completed through the data shift register and FIFO; The SDIO_DAT1 pin is connected to the interrupt control module, and the FPGA generates a card interrupt signal to notify the CPU.
[0085] In addition, the following interfaces are also included: Configuration interface: AHB Slave, used for CPU configuration of SDIO master control registers; DMA interface: AXI Master, used for batch data transfer between the SDIO controller and DDR; FPGA register interface: CCCR and user registers, used for device enumeration, function configuration, status query and interrupt control; FPGA data interface: TX FIFO / RX FIFO, used to interface with the FPGA's internal business data source and data consumer; Interrupt interfaces: DAT1 card interrupt, SOC interrupt input, used for FPGA event reporting and CPU interrupt response.
[0086] It is worth noting that the purpose of this abstract design is to abstract the internal business interfaces of the FPGA into register access interfaces, transmit FIFO interfaces, receive FIFO interfaces, and event interrupt interfaces, thereby decoupling the SDIO protocol processing layer from the specific business logic layer. Through this interface abstraction, the top-level encapsulation module of the SDIO slave device is only responsible for completing SDIO command parsing, data transmission and reception, and interrupt management, while different functional modules inside the FPGA only need to access them according to a unified interface, without needing to concern themselves with the details of the CMD52 / CMD53 protocol. This allows the same SDIO communication framework to adapt to different algorithm cores, control logic, and data processing modules, improving system scalability and portability.
[0087] The hardware composition, connection relationship, clock domain, and interrupt masking method of the four types of interfaces are as follows: (1) The register access interface mainly consists of the address signal reg_aDDR, the write data signal wr_data, the read data signal rd_data, the read / write enable signals reg_wr_en / reg_rd_en, and the access completion signal reg_valid. This interface connects to the command parsing module, address decoding module, and register mapping module in the top-level encapsulation module of the SDIO slave device. After the CMD52 command is parsed, a register access request is generated, and the corresponding control register or status register is selected through address decoding. This interface usually operates in the FPGA business clock domain and is isolated from the SDIO_CLK domain through register synchronous or asynchronous FIFO, and does not directly transmit across clock domains.
[0088] (2) The transmit FIFO interface mainly consists of signals such as write data tx_data, write enable tx_wr_en, and FIFO full status tx_full, connecting the FPGA business logic and the transmit FIFO in the top-level encapsulation module of the SDIO slave device. Data generated by the FPGA business module is written to the FIFO through this interface. After receiving the CMD53 read request on the SDIO side, the data channel module generates the FIFO read enable and converts the buffered data into the SDIO DAT[3:0] format for output. Since the FPGA business clock and SDIO_CLK are usually different, this interface realizes cross-clock domain data transmission through asynchronous FIFO.
[0089] (3) The receiving FIFO interface mainly consists of signals such as output data rx_data, read enable rx_rd_en, data valid rx_valid, and FIFO empty state rx_empty, connecting the SDIO data receiving module and the FPGA service processing module. When the CPU writes data to the FPGA via CMD53, the SDIO data channel receives the data and writes it to the receiving FIFO. The FPGA service logic reads the FIFO data according to its own clock and processes it. This interface also uses an asynchronous FIFO to isolate the SDIO_CLK domain and the FPGA service clock domain, avoiding cross-clock domain data errors.
[0090] (4) The event interrupt interface mainly consists of the event status signal event_flag, the interrupt enable signal irq_en, the interrupt mask signal irq_mask, and the interrupt output signal DAT1_irq, connecting the FPGA business logic, the interrupt status register, the interrupt control state machine, and the DAT1 driver circuit. When the business module generates an event, the event detection logic sets the corresponding status register. The interrupt control module determines whether the event is allowed to be reported based on irq_mask. If enabled, it drives the DAT1 signal to send an SDIO card interrupt to the CPU. Interrupt masking is implemented through the interrupt mask register, that is, the register bits are used to control whether different events can trigger an interrupt.
[0091] All four types of interfaces reside between the SDIO protocol layer and the business logic layer. The business side is only aware of address access, data read / write, and event notifications, and is unaware of CMD52 / CMD53 format, CRC checksum, SDIO timing, and DAT signal protocol. Therefore, as long as the business module meets the above interface definitions, it can access this SDIO communication framework, thus being protocol-independent.
[0092] Traditional SDIO devices typically bind SDIO protocol processing logic directly to fixed functional modules, with external interfaces primarily targeting specific chip internal resources, making it difficult to directly adapt to different FPGA business logic. This application adds an interface adaptation layer between the SDIO protocol layer and the FPGA business layer, converting SDIO commands, data, and interrupt events into a unified register access interface, TX / RX FIFO data interface, and event interrupt interface, respectively. This allows FPGA internal algorithm modules, state machines, or data processing units to access the system without needing to be aware of CMD52 / CMD53 protocol details. This application decouples the protocol layer from the business layer through interface abstraction, utilizes FIFOs for high-speed data caching and cross-clock domain isolation, uses register mapping for unified CPU control of FPGA resources, and enables FPGA-initiated event reporting via DAT1 interrupts, thereby improving system bandwidth, real-time performance, and scalability.
[0093] A driver method for a configurable SDIO master-slave hardware architecture between CPU and FPGA includes the following steps: (1) After the hardware is powered on, the SOC releases the relevant clocks and resets of the SDIO host controller to ensure the stability of the aclk, hclk, tmclk, cclk_tx / cclk_rx clocks; Related clocks include, for example: aclk (AXI Master interface clock): Used to drive the data DMA transfer logic between the SDIO master controller and DDR, including AXI bus access, DMA state machine and data transfer path; hclk (AHB Slave interface clock): Used to drive the CPU's configuration access to the SDIO master control register, including control register read / write, working mode configuration, etc. tmclk (timer clock): Used to drive the SDIO master controller's internal timers, timeout detection, and exception monitoring logic; clk_div_ref (frequency divider reference clock): Used in the SDIO clock divider module to provide a reference for SDIO interface clock generation; cclk_tx (SDIO transmit clock): Used to drive the SDIO_CLK output and control the timing of CMD / DAT signal transmission; cclk_rx (SDIO receive sampling clock): Used to sample the SDIO CMD / DAT input signals to ensure correct timing of received data; Related resets include, for example: aresetn: AXI DMA and AXI interface logic reset; hresetn: Resets the AHB configuration interface and register access logic; tresetn: Resets the timer and timeout detection logic; bresetn: SDIO master control core logic reset; cresetn_tx: SDIO transmit clock domain reset, used to reset the transmit state machine and data transmission logic; cresetn_rx: SDIO receive clock domain reset, used to reset the receive sampling logic and command parsing logic.
[0094] (2) The CPU initializes the DWC_mshc controller, and configures the Card Interface Type to SD class interface, 4-bit data width, SDMA / ADMA2 capability, AXI / AHB bus parameters, buffer depth and interrupt enable; (3) The CPU executes the SDIO device enumeration process to complete the FPGA-side slave device identification, CCCR reading, bus width switching, function enabling and rate mode switching; (4) The CPU configures the FPGA user registers via CMD52, including data window, transmission direction, block size, threshold, interrupt enable and service startup parameters; (5) During batch data transmission, the CPU establishes an SDMA or ADMA2 transmission task, the SDIO master controller initiates a CMD53 read / write operation, and interacts with the DDR through the AXI Master interface; (6) When the FPGA side completes data preparation, reception, or an exception occurs, it notifies the CPU via the DAT1 interrupt. The CPU reads the status and clears the interrupt.
[0095] Traditional SDIO device initialization processes primarily target fixed-function peripherals. After the host side completes card identification and protocol configuration, data access can begin, with the driver mainly responsible for device enumeration and data read / write control. However, this application's initialization and driver processes are designed for high-speed interaction between the CPU and FPGA. Building upon standard SDIO device enumeration, bus configuration, and rate switching, it further adds steps such as FPGA-side custom register initialization, FIFO channel establishment, DMA parameter configuration, and event interrupt enabling. This allows the CPU to achieve unified management of FPGA internal resources through the standard SDIO driver. This application integrates the SDIO initialization process with the FPGA business logic startup process, synchronizing device status through CCCR and user registers, establishing a high-speed data channel through DMA and FIFO configuration, and enabling proactive event reporting through the DAT1 interrupt mechanism, thus achieving the integration of the standard SDIO protocol and programmable FPGA services.
[0096] This application omits the traditional SDIO PHY layer, and instead uses the FPGA's internal programmable I / O resources and the RTL-implemented SDIODevice logic to jointly handle the PHY functions. Specifically: the SDIO_CLK, CMD, and DAT[3:0] signals are directly connected to the FPGA I / O pins, and level conversion and input / output driving are completed through the FPGA's built-in I / O buffer; the SDIO protocol logic in SDIO_DEVICE_WRAPPER is responsible for CMD / DAT signal sampling, command parsing, response generation, data shifting, and CRC calculation; the clock sampling logic uses the FPGA's internal flip-flops and edge sampling circuits to achieve SDIO data acquisition; and the data output logic controls the DAT[3:0] drive through the output register to achieve SDIO data transmission.
[0097] In summary, the main features of this application are: (1) Configure DWC_mshc as the CPU-FPGA communication host and change the controller application object; (2) FPGA is used as an SDIO slave device to build a non-storage SDIO device; (3) FPGA-side SDIO Device RTL, replacing vendor-specific IP; (4) Design of CMD52 register window to implement control channel; (5) CMD53 DMA data window design to realize high-speed data channel; (6) DAT1 event interrupt mechanism, FPGA actively notifies CPU; (7) SDIO clock domain - FPGA service clock domain asynchronous FIFO to solve the cross clock domain problem; (8) CPU-FPGA unified SDIO interaction architecture to replace traditional interfaces.
[0098] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A configurable SDIO master-slave hardware architecture between CPU and FPGA, characterized in that, include: The SDIO host controller is located on the system-on-chip (SoC) side and is connected to the SoC. The SDIO slave device top-level encapsulation module is located on the FPGA side and is connected to the SDIO host controller via the SDIO bus; The SDIO slave device top-level encapsulation module includes: The command parsing module is configured to convert CMD52 commands and CMD53 commands into access operations to FPGA registers and access operations to FPGA data, respectively. The register mapping module, connected to the command parsing module, is configured to map the FPGA's internal control registers and status registers to the SDIO protocol address space, and carry the control flow through the AHB Slave configuration interface; The data transceiver module, connected to the command parsing module, the sending FIFO, and the receiving FIFO, is configured to realize data exchange between the CPU and the FPGA through CMD53 block transmission and FIFO buffering, and to carry the data stream through the AXI Master data interface. An asynchronous FIFO / buffer module, connected to the data transceiver module and the FPGA business logic, is configured to achieve data isolation between the SDIO clock domain and the FPGA business clock domain; The CRC check module, connected to the data transceiver module, is configured to perform cyclic redundancy check on the transmitted data. The interrupt control module is connected to the FPGA business logic, FIFO threshold detection logic, and error detection logic. It is configured to use the DAT1 signal to implement SDIO card interrupts. When an event arrives on the FPGA side, the cache threshold is triggered, or an error occurs, it actively sends an interrupt request to the CPU.
2. The CPU-FPGA configurable SDIO master-slave hardware architecture according to claim 1, characterized in that, The SDIO host controller includes: The DWC_mshc controller is configured to transform the SDIO host controller from a storage access controller into an FPGA high-speed communication controller. The AHB configuration interface is configured to receive AHB bus transactions from the CPU and perform read / write operations on the internal registers of the DWC_mshc controller to configure the operating parameters of the SDIO host controller. The AXI Master data interface is configured to connect to DDR memory; The DMA descriptor / data buffer logic is configured to establish a data path between the DMA controller and the FPGA. The card clock generation and receiving clock sampling logic is configured to control the SDIO output clock, sample input data, and synchronously receive data; The reset synchronization logic is configured to synchronize the CPU clock domain, SDIO clock domain, and FPGA service clock domain after reset. Interruption reporting logic.
3. The CPU-FPGA configurable SDIO master-slave hardware architecture according to claim 1, characterized in that, The command parsing module includes: The CMD sampling unit is configured to acquire the SDIO_CMD signal and output it to the command shift register; The command shift register is configured to convert the SDIO_CMD signal into parallel command frames; The command decoding unit is configured to parse CMD52 / CMD53 commands based on the Command Index and output transmission parameters, including access address, read / write direction and data length. The parameter register is configured to buffer transmitted parameters; The CRC check module is configured to output the check result; The command state machine is configured to control the command execution flow.
4. The CPU-FPGA configurable SDIO master-slave hardware architecture according to claim 1, characterized in that, The register mapping module includes: The address decoding unit is configured to receive the access address output by the command parsing module and generate a register selection signal; The control register is configured to receive configuration data from the CPU and output it to the FPGA business logic. The status register is configured to acquire the FPGA status and return it to the CPU; The read / write control logic is configured to control access to registers.
5. A configurable SDIO master-slave hardware architecture between CPU and FPGA according to claim 1, characterized in that, The data transceiver module includes: The data shift register is configured to connect to the SDIO DAT data line to enable the conversion between serial and parallel commands; The data FIFO is configured to connect the SDIO data path and the FPGA service interface to achieve data caching; The data counter is configured to count the transmission length based on the CMD53 parameter; The transmission state machine is configured to control the data sending and receiving process.
6. A configurable SDIO master-slave hardware architecture between CPU and FPGA according to claim 1, characterized in that, The asynchronous FIFO / caching module includes: Dual-port RAM is configured to connect the SDIO clock domain and the FPGA service clock domain for data caching. The read and write pointers are configured to control data access in the SDIO clock domain and the FPGA service clock domain, respectively. The cross-clock synchronization circuit is configured for cross-clock domain state transfer; The status detection logic is configured to output an empty / full FIFO signal.
7. A configurable SDIO master-slave hardware architecture between CPU and FPGA according to claim 1, characterized in that, The CRC check module includes: The CRC register is configured to store the calculation result; The shift calculation logic is configured to perform CRC7 / CRC16 calculations according to the SDIO protocol; The comparison unit is configured to output either a pass or error signal.
8. A configurable SDIO master-slave hardware architecture between CPU and FPGA according to claim 1, characterized in that, The interrupt control module includes: The event detection unit is configured to collect events within the FPGA; The interrupt status register is configured to save the event status based on internal FPGA events; The interrupt mask register is configured to control the event reporting conditions based on the event status; The DAT1 driver unit is configured to actively output SDIO interrupt signals to the CPU.
9. A configurable SDIO master-slave hardware architecture between CPU and FPGA according to claim 1, characterized in that, It also includes configuration links, read data links, write data links, and event reporting links; The configuration link is configured as follows: the CPU accesses the SDIO master control register through the AHB Slave interface to complete master control initialization, card clock setting, bus width switching, rate mode switching, interrupt enable, and DMA parameter configuration; and accesses the FPGA-side CCCR and custom registers through CMD52. The read data link is configured as follows: the FPGA business logic writes the data to be uploaded into the asynchronous FIFO or data cache; the CPU side configures an ADMA2 or SDMA transmission task, the SDIO host controller initiates a CMD53 read operation, the FPGA side outputs data according to the SDIO protocol and includes CRC16 verification, and the SDIO host controller writes the data into the system DDR via the AXI Master interface. The write data link is configured as follows: the CPU puts the data to be sent into the system DDR and configures the DMA descriptor; the SDIO host controller sends the data to the FPGA through the CMD53 write operation; the FPGA side completes the CRC check and writes the data into the receive FIFO, and then the FPGA service clock domain reads and processes the data. The event reporting link is configured such that when an event arrives on the FPGA side, a cache threshold is triggered, or an error state occurs, an SDIO card interrupt is initiated via the DAT1 driver unit; after the CPU responds to the interrupt, it reads the status register via CMD52 and initiates CMD53 data transmission as needed.
10. A driving method for a configurable SDIO master-slave hardware architecture between CPU and FPGA, characterized in that, Applied to a CPU-FPGA configurable SDIO master-slave hardware architecture as described in any one of claims 1-9, the method includes the following steps: After the hardware is powered on, the SOC releases the relevant clocks and resets of the SDIO host controller to ensure the stability of the aclk, hclk, tmclk, cclk_tx / cclk_rx clocks; The CPU initializes the DWC_mshc controller, configuring the Card Interface Type to SD class interface, 4-bit data width, SDMA / ADMA2 capability, AXI / AHB bus parameters, buffer depth, and interrupt enable; The CPU executes the SDIO device enumeration process to complete FPGA-side slave device identification, CCCR reading, bus width switching, function enabling, and rate mode switching. The CPU configures the FPGA user registers via CMD52, including data window, transfer direction, block size, threshold, interrupt enable, and service startup parameters. During batch data transfer, the CPU establishes an SDMA or ADMA2 transfer task, the SDIO master controller initiates a CMD53 read / write operation, and interacts with the DDR via the AXIMaster interface; The FPGA side notifies the CPU via DAT1 interrupt when data preparation is complete, reception is complete, or an exception occurs. The CPU reads the status and clears the interrupt.
