Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

CDBUS (Controller Distributed Bus) Protocol and IP Core

NotificationsYou must be signed in to change notification settings

dukelec/cdbus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

(This is an 8-bit version, please switch to the corresponding branch for the 32-bit version.)

  1. CDBUS Protocol
  2. Block Diagram
  3. Registers
  4. Interface
  5. Examples
  6. Simulation
  7. Ready To Use Devices
  8. License

CDBUS is a simple protocol designed for serial ports and serial bus communication, commonly employed in RS-485 buses.It utilizes hardware arbitration and other mechanisms to avoid data conflicts, allowing nodes to freely transmit and receive data packets,thereby overcoming the limitations of single-master polling.

CDBUS Protocol

CDBUS has a 3-byte header:[src_addr, dst_addr, data_len], followed by user data, and concluding with a 2-byte CRC (identical to MODBUS CRC).

The CDBUS protocol at the byte level can be directly used for traditional serial communication,such as traditional UART, RS-232, RS-485, and USB virtual serial ports.

The full CDBUS protocol at the bit level requires dedicated hardware controllers (or software emulation)to achieve conflict avoidance, higher speeds, and strong real-time performance.

Arbitration Mode (CDBUS-A)

  • It introduces an arbitration mechanism, similar to the CAN bus, to automatically avoid conflicts.
  • Supporting dual baud rates achieves high-speed communication,with the maximum baud rate during the high-speed phase up to:sysclk ÷ 3. (e.g. 50 Mbps for 150 MHzsysclk.)
  • Supports unicast, multicast and broadcast.
  • The maximum user data size is 253 bytes.
  • Hardware packing, unpacking, verification and filtering, saving your time and CPU usage.
  • Compatible with traditional RS-485 hardware (arbitration function remains effective).

The protocol timing example, consisting of only one byte of user data:
(You can configure the lengths of idle time and transmission permit time.)

protocol

Tips:

  • When a high-priority node needs to send unimportant data, we can dynamically increase the transmission permit time (TX_PERMIT_LEN).

Arbitration example:

arbitration

Example waveforms for TX output and TX_EN pins:

arbitration

The RX data sampling point for reception is at 1/2 bit; for TX readback, it's at 3/4 bit.

Break Sync Mode (CDBUS-BS)

In CDBUS-A mode, if the low-speed portion takes longer, it can become a bottleneck for communication efficiency.

To address this, single-rate peer-to-peer bus communication can be achieved using CDBUS-BS mode:

  • Different nodes have different configurations for the TX_PERMIT_LEN parameter, requiring sufficiently large differences to avoid conflicts.
  • If any node has pending data frames waiting to be sent before the transmission permit point, transmission starts from that point.
  • Otherwise, wait until the idle time exceeds MAX_IDLE_LEN. When there are pending data frames waiting for transmission,first send a break character to bring the bus out of the idle state.

arbitration

The CDBUS-BS mode is suitable for high-speed applications with few nodes, and it is also suitable for software implementation.

Block Diagram

block_diagram

Operation

operation

Registers

Register NameAddrAccessDefaultDescription (8-bit width by default if not specified)
VERSION0x00RD0x0eHardware version
SETTING0x02RD/WR0x10Configs
IDLE_WAIT_LEN0x04RD/WR0x0aWaiting time to enter idle
TX_PERMIT_LEN_L0x05RD/WR0x14Waiting time to allows sending (10 bits)
TX_PERMIT_LEN_H0x06RD/WR0x00
MAX_IDLE_LEN_L0x07RD/WR0xc8Max idle waiting time in BS mode (10 bits)
MAX_IDLE_LEN_H0x08RD/WR0x00
TX_PRE_LEN0x09RD/WR0x01Enable TX_EN how long ahead than TX output (2 bits)
FILTER0x0bRD/WR0xffLocal address
DIV_LS_L0x0cRD/WR0x5aLow-speed rate setting (16 bits)
DIV_LS_H0x0dRD/WR0x01
DIV_HS_L0x0eRD/WR0x5aHigh-speed rate setting (16 bits)
DIV_HS_H0x0fRD/WR0x01
INT_FLAG0x10RDn/aStatus
INT_MASK0x11RD/WR0x00Interrupt mask
RX0x14RDn/aRead RX page
TX0x15WRn/aWrite TX page
RX_CTRL0x16WRn/aRX control
TX_CTRL0x17WRn/aTX control
RX_ADDR0x18RD/WR0x00RX page read pointer (rarely used)
RX_PAGE_FLAG0x19RDn/aRX page flag
FILTER_M00x1aRD/WR0xffMulticast filter0
FILTER_M10x1bRD/WR0xffMulticast filter1

SETTING:

FIELDDESCRIPTION
[6]Full duplex mode
[5]Break Sync mode
[4]Enable arbitration
[3]Save broken frame
[2]CRC maintained by user
[1]Invert tx pin output
[0]Enable push-pull output for tx and tx_en pin
[6][5][4]DESCRIPTION
001CDBUS-A mode (default)
010CDBUS-BS mode
100Full-duplex mode
000Traditional half-duplex mode

TX_PRE_LEN:

Example waveforms for TX output and TX_EN pins (TX_PRE_LEN = 1 bit):

arbitration

Unused for Arbitration mode and the break character automatically generated by BS mode.

FILTERS:

Match from top to bottom:

SRC_ADDRDST_ADDRFILTERFILTER_MxReceive or notRemarks
not carenot care255not careReceivePromiscuous mode
= FILTERnot care!= 255not careDropAvoid loopback
!= FILTER255not carenot careReceiveBroadcast
!= FILTER!= 255not careany = DST_ADDRReceiveMulticast
!= FILTER!= 255= DST_ADDRnot careReceiveUnicast
not care!= 255!= DST_ADDRall != DST_ADDRDrop

For example, addresses from 0xe0 to 0xfe can be reserved for multicast address.

The default value 0xff of FILTER_Mx means not enabled.

DIV_xx_x:

Baud rate divider value:DIV_xx[15:0] = sysclk ÷ baud_rate − 1

The minimum value is 2.

For single rate, DIV_HS needs to be set to the same value as DIV_LS.

INT_FLAG:

FIELDDESCRIPTION
[7]1: TX error: TX is 0, but RX is sampled as 1
[6]1: TX collision detected
[5]1: TX page released by hardware
[4]1: RX error: frame broken
[3]1: RX lost: no empty page for RX
[2]1: Break character received
[1]1: RX page ready for read
[0]1: Bus in IDLE mode

Reading this register will automatically clear bit7, bit6, bit4, bit3 and bit2.

INT_MASK:

Output of irq = ((INT_FLAG & INT_MASK) != 0).

RX_CTRL:

FIELDDESCRIPTION
[4]Reset RX block
[1]Switch RX page
[0]Reset RX page read pointer

TX_CTRL:

FIELDDESCRIPTION
[5]Send break character
[4]Abort TX
[1]Switch TX page
[0]Reset TX page write pointer

RX_PAGE_FLAG:

A value of zero indicates that the frame in the current RX page is correct;
Non-zero indicates the pointer to the last received byte of the disrupted frame, including CRC.

Always zero ifsave broken frame is not enabled.

Interface

parameter DIV_LS=346,// default: 115200 bps for 40MHz clkparameter DIV_HS=346input           clk,// core clockinput           reset_n,// async active-low resetinput           chip_select,output          irq,// interrupt output// avalon-mm slave interface, read and write without latency// support burst read and write (normally for REG_TX and REG_RX)input   [4:0]   csr_address,input           csr_read,output  [7:0]   csr_readdata,input           csr_write,input   [7:0]   csr_writedata,// connect to external PHY chip, e.g. MAX3485input           rx,output          tx,output          tx_en

Examples

# Configurationwrite(REG_SETTING, [0x11])# Enable push-pull output# TXwrite(REG_TX, [0x0c,0x0d,0x01,0xcd])# Write frame without CRCwhile (read(REG_INT_FLAG)&0x20)==0:# Make sure we can successfully switch to the next pagepasswrite(REG_TX_CTRL, [0x03])# Trigger sending by switching TX page# RXwhile (read(REG_INT_FLAG)&0x02)==0:# Wait for RX page readypassheader=read(REG_RX,len=3)data=read(REG_RX,len=header[2])write(REG_RX_CTRL, [0x03])# Release RX page

Test

Installiverilog (>= v10) andcocotb, gototests/ folder, run./test_all.sh or./test_all.sh test_xxx.py.(You can checkout the waveformcdbus.vcd by GTKWave.)

Ready To Use Devices

The CDCTL controllers family incorporates the CDBUS IP Core, providing peripheral interfaces such as SPI, I2C, and PCIe.
E.g. The tiny CDCTL-Bx module supports SPI and I2C interfaces:
(The source code and gerber files for this module are fully open-source and located in theexample/ directory.)
cdctl_bx

For a list of CDBUS-related ASIC chips, please refer to thewiki page.

More relevant projects that may interest you:

License

This Source Code Form is subject to the terms of the MozillaPublic License, v. 2.0. If a copy of the MPL was not distributedwith this file, You can obtain one at https://mozilla.org/MPL/2.0/.Notice: The scope granted to MPL excludes the ASIC industry.The CDBUS protocol is royalty-free for everyone except chip manufacturers.Copyright (c) 2017 DUKELEC, All rights reserved.

About

CDBUS (Controller Distributed Bus) Protocol and IP Core

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp