Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AXI DMAC: Add Framelock, AutoRun, fsync, tlast #1332

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

gastmaier
Copy link
Contributor

@gastmaier gastmaier commented May 20, 2024

PR Description

General

Adds option for a port default value on adi_if_ports

AXI DMAC features

Framelock

Operates in two modes:

  • Writer mode - available in s2mm configuration, the writer DMAC will always skip the current in use reader buffer
  • Reader mode - available in mm2s configuration, the reader DMAC will try to stay behind the writer buffer by either repeating or skipping buffers according to the speed relationship of the two cores.
    In summary, allows to lock a framerate, by either skipping or repeating frames, depending on the rate of the incoming data (e.g. AXI HDMI RX, VTPG) and how fast it is consumed (e.g. AXI HDMI TX).
    The MSB of the framelock interface indicates if the [MSB-1:0] frame is valid.

TLast

In 2D mode, the assertion of TLAST on the AXI Stream source interface signalizes the end of frame, but Xilinx IP cores use this to signalize then end of line.
Allow to select TLAST to signalize End of Frame and End of Line.

FSync

A transfer will start only after the assertion of the external sync signal.
The sync signal can be either in source or destination clock domain or both.
This feature does not ensures fixed latency from the assertion of external sync signal and the availability of the data at the destination interface.

AutoRun

In cases where software is not available, the autorun feature can be used to set up a single transfer that will be executed after reset deassertion. This is mostly useful together with the CYCLIC mode.

How was this tested?

Last tested commit: 9d44ba3
Test projects are available at branch dmac_framelock.
The tested carrier is ZedBoard.
The project instantiates a video test pattern generator (VTPG), which feeds the AXI DMACs in framelock configuration.
The reader side outputs AXI-Stream to the AXI HDMI TX.
The VTPG, AXI CLKGEN, SYNC Generator (AXI TMR) and AXI HDMI TX were configured directly:

# AXI HDMI CLKGEN
busybox devmem 0x79000040 32 3

# ADI AXI HDMI TX
# https://wiki.analog.com/resources/fpga/docs/axi_hdmi_tx
busybox devmem 0x70E00040 32 1 # Enable core
busybox devmem 0x70E00400 32 $((16#07800898)) # 1920,2200
busybox devmem 0x70E00404 32 44
busybox devmem 0x70E00408 32 $((16#084000C0)) # 2112,192
busybox devmem 0x70E00440 32 $((16#04380465)) # 1080,1125
busybox devmem 0x70E00444 32 5 # 5
busybox devmem 0x70E00448 32 $((16#04610029)) # 1121,41
busybox devmem 0x70E00048 32 1 # Input
busybox devmem 0x70E00054 32 # REG_CLK_FREQ RO

# XILINX VTPG
# https://docs.amd.com/r/en-US/pg103-v-tpg/Register-Space
busybox devmem 0x43C00000 32 # Control
busybox devmem 0x43C00010 32 1080 # Height
busybox devmem 0x43C00018 32 1920 # Width
busybox devmem 0x43C00020 32 1 # Background Pattern
busybox devmem 0x43C00000 32  $((16#81)) # Control Start with Auto restart

# AXI TMR (For TPG DMA src ext sync)
# PWM of 10 clocks with 5 high and 5 low
# https://docs.amd.com/v/u/en-US/pg079-axi-timer
busybox devmem 0x43C10004 32 $((16#8))   # TRL0
busybox devmem 0x43C10014 32 $((16#3))   # TRL1
busybox devmem 0x43C10000 32 $((16#206)) # TCSR0
busybox devmem 0x43C10010 32 $((16#606)) # TCSR1

For the DMACs, I used adi-axi-fb.c as a module, with updated register addresses.
Instead of using devmem, devicetree bindings for each IP could have been used;
also, to init the ADV7511, the qv4l2 tool seem to used;
I didn't test the HDMI output in a display, I only sampled the stream with ILAs, *framelock* bus signals.

Testbenches are available at branch axi_dmac_flock.

The original hw tests (5 years ago) were done using an FMC-IMAGEON board.

Resource usage

Resource usage for the Framelock module, followed by the percentile of the total used by the DMA.

Writer

LUTs: 91 (13.2%)
Registers: 35 (3.3%)
Slice: 32 (9.6%)

Reader

LUTs: 57 (9.5%)
Registers: 41 (5.4%)
Slice: 25 (10.54%)

Notes for reviewers

Check if the used registers are adequate, since it collided with the Scather-Gather at rebase.
See if the test in hw suffice or if some other test is required.

PR Type

  • Bug fix (change that fixes an issue)
  • New feature (change that adds new functionality)
  • Breaking change (has dependencies in other repos or will cause CI to fail)

PR Checklist

  • I have followed the code style guidelines
  • I have performed a self-review of changes
  • I have compiled all hdl projects and libraries affected by this PR
  • I have tested in hardware affected projects, at least on relevant boards
  • I have commented my code, at least hard-to-understand parts
  • I have signed off all commits from this PR
  • I have updated the documentation (wiki pages, ReadMe files, Copyright etc)
  • I have not introduced new Warnings/Critical Warnings on compilation
  • I have added new hdl testbenches or updated existing ones

The 'framelock' mechanism ensures no buffer is accessed by two DMACs
in the same time.

The core can operate in two modes:
* Writer mode - available in s2mm configuration, the writer DMAC will
                always skip the current in use reader buffer
* Reader mode - available in mm2s configuration, the reader DMAC will
                try to stay behind the writer buffer by either repeating or
                skipping buffers according to the speed relationship of the
                two cores.

The tx and rx DMAC cores must be connected through the dedicated
'framelock' interface. They must be programmed with similar settings
regarding the buffers size, start address and stride.

In 2D mode, the assertion of TLAST on the AXI Stream source interface
signalizes the end of frame, but Xilinx IP cores use this to signalize
then end of line.
Allow to select TLAST to signalize End of Frame and End of Line.

Add external synchronization to be able to throttle the consumption of
descriptors queued by the software.

A transfer will start only after the assertion of the external sync
signal.
The sync signal can be either in source or destination clock domain or
both.
This feature does not ensures fixed latency from the assertion of
external sync signal and the availability of the data at the destination
interface.

In cases where software is not available, the autorun feature can be
used to set up a single transfer that will be executed after reset
deassertion. This is mostly useful together with the CYCLIC mode.

Signed-off-by: Jorge Marques <[email protected]>
Sanitize bitwise operators and combinational logic to avoid mixing them
in the same statement.

Signed-off-by: Jorge Marques <[email protected]>
@gastmaier gastmaier marked this pull request as ready for review July 18, 2024 17:08
@bia1708
Copy link
Collaborator

bia1708 commented Jul 19, 2024

RetriggerCI

Remove dangling signal
Rename signal from *_w to *_s.
Redo assign logic.
Revert BYTES_PER_BURST_WIDTH registers 1-bit increase.

Signed-off-by: Jorge Marques <[email protected]>
Add AUTORUN option to Scather-Gather.
Move Framelock enable register from FLAGS to CONTROL.
Changes Framelock flag bit from 3 to 4, to allocate 3 for the SG.

Signed-off-by: Jorge Marques <[email protected]>
Allow to setup initial/autorun value for SG_ADDRESS register.

Signed-off-by: Jorge Marques <[email protected]>
Copy link
Contributor

@IuliaCMoldovan IuliaCMoldovan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just non-functional changes:

docs/library/axi_dmac/index.rst Outdated Show resolved Hide resolved
docs/library/axi_dmac/index.rst Outdated Show resolved Hide resolved
docs/library/axi_dmac/index.rst Outdated Show resolved Hide resolved
docs/library/axi_dmac/index.rst Outdated Show resolved Hide resolved
docs/regmap/adi_regmap_dmac.txt Outdated Show resolved Hide resolved
library/axi_dmac/axi_dmac_response_manager.v Outdated Show resolved Hide resolved
library/axi_dmac/axi_dmac_transfer.v Outdated Show resolved Hide resolved
library/axi_dmac/dmac_2d_transfer.v Outdated Show resolved Hide resolved
library/interfaces/interfaces_ip.tcl Outdated Show resolved Hide resolved
library/scripts/adi_ip_xilinx.tcl Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants