element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs Using DMA with an AXI stream on a CMOD-S7
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: tcmichals
  • Date Created: 24 Aug 2020 2:01 AM Date Created
  • Views 997 views
  • Likes 1 like
  • Comments 1 comment
Related
Recommended

Using DMA with an AXI stream on a CMOD-S7

tcmichals
tcmichals
24 Aug 2020

Vivado example (Also includes other AXI slaves, PWM decode and DSHOT150 generation)


For the past several weeks been working on using DMA (microblaze softcore ) with an AXI Stream interface connected to the FTDI serial interface.  Here is a diagram from Vivado:

image

 

The AXI stream wraps an UART, (From nandland) and supports 12M baud.  The AXI stream also supports TLAST on RX stream.  TLAST is used to terminate the DMA and start a new transaction.  Instead of the processor handling each byte using interrupts or polling, there will be one interrupt per packet, i.e. like an Ethernet packet.  The serial protocol uses a similar encoding as SLIP or PPP, so, there is a unique SOP byte (start of packet) and EOP byte (end of packet).  At this time the current rate is 3.4Mbps total or 1.7Mpbs for each RX/TX line.

 

Currently working on moving packet encoding, CRC handling to the FPGA to increase performance and off load the soft-core processor. The code is on github.  in the axi_dma_stream_microblaze directory.  The top level, resource is a modified libftdi library, added an API to allow reading what ever is in the current buffer.  FTDI library API ftdi_set_event_char is used to assist in flushing the USB buffer when an EOP is received.  There is a simple example, loopback_test.cpp that sends a "ping" packet that is echo'ed back to measure round trip time.  Also, an async message to toggle the board LEDs.

 

Microblaze software

The microblaze is configured to run FreeRTOS and in the vitis directory there is a DMA driver that has 4 RX buffer descriptors and 8 RX buffers.  The other 4 are used to swap between the driver and user application, allowing a zero-copy.  For TX there is two buffers that can be allocated at the app level to allow zero-copy usage.

 

For example of processing an RX DMA buffer at the application level:

static void prvRxTask( [[maybe_unused]]  void *pvParameters )

{

    for( ;; )

    {

        uint8_t *rxPkt;

        size_t lenOfPkt;

        if ( true == wait_rx_pkt( rxPkt, lenOfPkt,portMAX_DELAY )) <-- DMA packet buffer is queued to the application

        {

            gProtocol.onRecv(rxPkt, lenOfPkt);

            freeRxPkt(rxPkt); <-- DMA packet is queued back to the DMA buffer...

        }

    }

}

 

 

For TX:

.....

if (allocTx(gpTxPkt, gTxPktMaxSize))  <-- allocate a TX DMA buffer with a requested size..

...

rc = wait_tx_pkt(gpTxPkt, gTxPktSize); <- queue the packet to DMA driver.. in this case it blocks until sent.

 

 

  • Sign in to reply
  • Fred27
    Fred27 over 4 years ago

    That looks really useful. Thanks for sharing.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube