Application of CPLD in CAN Communication Cards
Efficient data exchange between a CAN communication card and a host PC requires a low-latency bridge. One of the most effective methods to achieve this is through memory mapping, where the hardware registers of the communication card are mapped directly into the host’s memory space. This allows the software to interact with the CAN controller using standard memory read and write instructions rather than complex I/O port calls.
🏗️ Hardware Architecture and Memory Mapping #
The core of the communication card’s logic relies on a memory mapping scheme. This approach facilitates a direct path for data packets moving between the CAN bus and the system bus. By utilizing this method, the host CPU treats the CAN card’s buffers as local memory addresses, reducing the overhead associated with software-driven data transfers.
In high-performance embedded systems, such as those running on VxWorks, this direct memory access is vital for maintaining deterministic timing when processing high-frequency CAN frames.
⚡ CPLD Implementation with Xilinx XC9500 #
To implement the control logic for this architecture, the Xilinx XC9500 series CPLD is a standard choice. The CPLD acts as the “glue logic” that manages the timing and synchronization between the PC’s bus and the CAN controller’s internal registers.
Dual-Port RAM Control #
A critical component of this design is the dual-port RAM. This memory module allows simultaneous access from two different sources:
- The host PC (via the system bus).
- The CAN controller (via the internal bus).
The CPLD manages the write-enable signals and address decoding for this dual-port RAM. It ensures that data written by the host is correctly buffered and ready for the CAN controller to transmit, and conversely, that incoming CAN data is correctly stored for the host to read.
VHDL Logic Design #
The control circuits are defined using VHDL. The VHDL code defines the state machines and logic gates required to:
- Decode the memory addresses provided by the host.
- Manage the arbitration logic for the dual-port RAM.
- Synchronize the asynchronous clocks of the PC bus and the CAN controller.
By offloading these tasks to the CPLD, the host processor is freed from managing low-level hardware timing, allowing it to focus on the application layer of the CAN protocol. This hardware-level handling ensures that the data exchange remains consistent and fast, even under heavy bus loads.