Skip to content

Commit

Permalink
axi_dmac: Add Cache Coherency support
Browse files Browse the repository at this point in the history
This commit implements Cache Coherency through dedicated parameters.

The AxCACHE/AxPROT parameters are automatically set to the most commonly
used values unless otherwise specified. Their default values are:
AxCACHE = CACHE_COHERENT ? 4'b1111 : 4'b0011
AxPROT  = CACHE_COHERENT ? 3'b010  : 3'b000

If Cache Coherency is enabled, the AxCACHE/AxPROT values can be changed
to support systems with different caching policies.

Signed-off-by: Ionut Podgoreanu <[email protected]>
  • Loading branch information
podgori committed Apr 30, 2024
1 parent 7e84c25 commit 107047e
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 59 deletions.
11 changes: 5 additions & 6 deletions library/axi_dmac/address_generator.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ***************************************************************************
// ***************************************************************************
// Copyright (C) 2014-2023 Analog Devices, Inc. All rights reserved.
// Copyright (C) 2014-2024 Analog Devices, Inc. All rights reserved.
//
// In this HDL repository, there are many different and unique modules, consisting
// of various HDL (Verilog or VHDL) components. The individual modules are
Expand Down Expand Up @@ -43,7 +43,8 @@ module address_generator #(
parameter BEATS_PER_BURST_WIDTH = 4,
parameter BYTES_PER_BEAT_WIDTH = $clog2(DMA_DATA_WIDTH/8),
parameter LENGTH_WIDTH = 8,
parameter CACHE_COHERENT = 0
parameter [3:0] AXI_AXCACHE = 4'b0011,
parameter [2:0] AXI_AXPROT = 3'b000
) (
input clk,
input resetn,
Expand Down Expand Up @@ -80,10 +81,8 @@ module address_generator #(
`include "inc_id.vh"

assign burst = 2'b01;
assign prot = 3'b000;
// If CACHE_COHERENT is set, signal downstream that this transaction must be
// looked up in cache. Otherwise default to "normal non-cachable bufferable".
assign cache = CACHE_COHERENT ? 4'b1110 : 4'b0011;
assign prot = AXI_AXPROT;
assign cache = AXI_AXCACHE;
assign size = DMA_DATA_WIDTH == 1024 ? 3'b111 :
DMA_DATA_WIDTH == 512 ? 3'b110 :
DMA_DATA_WIDTH == 256 ? 3'b101 :
Expand Down
13 changes: 9 additions & 4 deletions library/axi_dmac/axi_dmac.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ***************************************************************************
// ***************************************************************************
// Copyright (C) 2014-2023 Analog Devices, Inc. All rights reserved.
// Copyright (C) 2014-2024 Analog Devices, Inc. All rights reserved.
//
// In this HDL repository, there are many different and unique modules, consisting
// of various HDL (Verilog or VHDL) components. The individual modules are
Expand Down Expand Up @@ -70,7 +70,9 @@ module axi_dmac #(
parameter DISABLE_DEBUG_REGISTERS = 0,
parameter ENABLE_DIAGNOSTICS_IF = 0,
parameter ALLOW_ASYM_MEM = 0,
parameter CACHE_COHERENT_DEST = 0
parameter CACHE_COHERENT = 0,
parameter [3:0] AXI_AXCACHE = 4'b0011,
parameter [2:0] AXI_AXPROT = 3'b000
) (

// Slave AXI interface
Expand Down Expand Up @@ -447,7 +449,9 @@ module axi_dmac #(
.DMA_2D_TRANSFER(DMA_2D_TRANSFER),
.DMA_SG_TRANSFER(DMA_SG_TRANSFER),
.SYNC_TRANSFER_START(SYNC_TRANSFER_START),
.CACHE_COHERENT_DEST(CACHE_COHERENT_DEST)
.CACHE_COHERENT(CACHE_COHERENT),
.AXI_AXCACHE(AXI_AXCACHE),
.AXI_AXPROT(AXI_AXPROT)
) i_regmap (
.s_axi_aclk(s_axi_aclk),
.s_axi_aresetn(s_axi_aresetn),
Expand Down Expand Up @@ -537,7 +541,8 @@ module axi_dmac #(
.AXI_LENGTH_WIDTH_SG(8-(4*DMA_AXI_PROTOCOL_SG)),
.ENABLE_DIAGNOSTICS_IF(ENABLE_DIAGNOSTICS_IF),
.ALLOW_ASYM_MEM(ALLOW_ASYM_MEM),
.CACHE_COHERENT_DEST(CACHE_COHERENT_DEST)
.AXI_AXCACHE(AXI_AXCACHE),
.AXI_AXPROT(AXI_AXPROT)
) i_transfer (
.ctrl_clk(s_axi_aclk),
.ctrl_resetn(s_axi_aresetn),
Expand Down
81 changes: 74 additions & 7 deletions library/axi_dmac/axi_dmac_hw.tcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
## Copyright (C) 2014-2023 Analog Devices, Inc. All rights reserved.
## Copyright (C) 2014-2024 Analog Devices, Inc. All rights reserved.
### SPDX short identifier: ADIBSD
###############################################################################

Expand Down Expand Up @@ -92,6 +92,46 @@ set_parameter_property DMA_AXI_ADDR_WIDTH HDL_PARAMETER true
set_parameter_property DMA_AXI_ADDR_WIDTH ALLOWED_RANGES {16:64}
set_parameter_property DMA_AXI_ADDR_WIDTH GROUP $group

add_parameter AXI_AXCACHE_AUTO BOOLEAN 1
set_parameter_property AXI_AXCACHE_AUTO DISPLAY_NAME "ARCACHE/AWCACHE Automatically Set"
set_parameter_property AXI_AXCACHE_AUTO HDL_PARAMETER false
set_parameter_property AXI_AXCACHE_AUTO GROUP $group

add_parameter AXI_AXPROT_AUTO BOOLEAN 1
set_parameter_property AXI_AXPROT_AUTO DISPLAY_NAME "ARPROT/AWPROT Automatically Set"
set_parameter_property AXI_AXPROT_AUTO HDL_PARAMETER false
set_parameter_property AXI_AXPROT_AUTO GROUP $group

add_parameter AXI_AXCACHE_MANUAL STD_LOGIC_VECTOR
set_parameter_property AXI_AXCACHE_MANUAL WIDTH 4
set_parameter_property AXI_AXCACHE_MANUAL DISPLAY_NAME "ARCACHE/AWCACHE"
set_parameter_property AXI_AXCACHE_MANUAL HDL_PARAMETER false
set_parameter_property AXI_AXCACHE_MANUAL ALLOWED_RANGES {0x0:0xF}
set_parameter_property AXI_AXCACHE_MANUAL GROUP $group

add_parameter AXI_AXPROT_MANUAL STD_LOGIC_VECTOR
set_parameter_property AXI_AXPROT_MANUAL WIDTH 3
set_parameter_property AXI_AXPROT_MANUAL DISPLAY_NAME "ARPROT/AWPROT"
set_parameter_property AXI_AXPROT_MANUAL HDL_PARAMETER false
set_parameter_property AXI_AXPROT_MANUAL ALLOWED_RANGES {0x0:0x7}
set_parameter_property AXI_AXPROT_MANUAL GROUP $group

add_parameter AXI_AXCACHE STD_LOGIC_VECTOR
set_parameter_property AXI_AXCACHE WIDTH 4
set_parameter_property AXI_AXCACHE DISPLAY_NAME "ARCACHE/AWCACHE"
set_parameter_property AXI_AXCACHE HDL_PARAMETER true
set_parameter_property AXI_AXCACHE ALLOWED_RANGES {0x0:0xF}
set_parameter_property AXI_AXCACHE DERIVED true
set_parameter_property AXI_AXCACHE GROUP $group

add_parameter AXI_AXPROT STD_LOGIC_VECTOR
set_parameter_property AXI_AXPROT WIDTH 3
set_parameter_property AXI_AXPROT DISPLAY_NAME "ARPROT/AWPROT"
set_parameter_property AXI_AXPROT HDL_PARAMETER true
set_parameter_property AXI_AXPROT ALLOWED_RANGES {0x0:0x7}
set_parameter_property AXI_AXPROT DERIVED true
set_parameter_property AXI_AXPROT GROUP $group

foreach {suffix group} { \
"SRC" "Source" \
"DEST" "Destination" \
Expand Down Expand Up @@ -153,24 +193,31 @@ set_parameter_property CYCLIC DISPLAY_HINT boolean
set_parameter_property CYCLIC HDL_PARAMETER true
set_parameter_property CYCLIC GROUP $group

add_parameter DMA_2D_TRANSFER INTEGER 0
set_parameter_property DMA_2D_TRANSFER DISPLAY_NAME "2D Transfer Support"
set_parameter_property DMA_2D_TRANSFER DISPLAY_HINT boolean
set_parameter_property DMA_2D_TRANSFER HDL_PARAMETER true
set_parameter_property DMA_2D_TRANSFER GROUP $group

add_parameter DMA_SG_TRANSFER INTEGER 0
set_parameter_property DMA_SG_TRANSFER DISPLAY_NAME "SG Transfer Support"
set_parameter_property DMA_SG_TRANSFER DISPLAY_HINT boolean
set_parameter_property DMA_SG_TRANSFER HDL_PARAMETER true
set_parameter_property DMA_SG_TRANSFER GROUP $group

add_parameter DMA_2D_TRANSFER INTEGER 0
set_parameter_property DMA_2D_TRANSFER DISPLAY_NAME "2D Transfer Support"
set_parameter_property DMA_2D_TRANSFER DISPLAY_HINT boolean
set_parameter_property DMA_2D_TRANSFER HDL_PARAMETER true
set_parameter_property DMA_2D_TRANSFER GROUP $group

add_parameter SYNC_TRANSFER_START INTEGER 0
set_parameter_property SYNC_TRANSFER_START DISPLAY_NAME "Transfer Start Synchronization Support"
set_parameter_property SYNC_TRANSFER_START DISPLAY_HINT boolean
set_parameter_property SYNC_TRANSFER_START HDL_PARAMETER true
set_parameter_property SYNC_TRANSFER_START GROUP $group

add_parameter CACHE_COHERENT BOOLEAN 0
set_parameter_property CACHE_COHERENT DISPLAY_NAME "Cache Coherent"
set_parameter_property CACHE_COHERENT DESCRIPTION "Assume DMA ports ensure cache coherence"
set_parameter_property CACHE_COHERENT DISPLAY_HINT boolean
set_parameter_property CACHE_COHERENT HDL_PARAMETER true
set_parameter_property CACHE_COHERENT GROUP $group

set group "Clock Domain Configuration"

add_parameter AUTO_ASYNC_CLK BOOLEAN 1
Expand Down Expand Up @@ -328,6 +375,26 @@ proc axi_dmac_validate {} {
}

set_parameter_property MAX_BYTES_PER_BURST ALLOWED_RANGES "1:$max_burst"

set cache_coherent [get_parameter_value CACHE_COHERENT]
set axcache_auto [get_parameter_value AXI_AXCACHE_AUTO]
set axprot_auto [get_parameter_value AXI_AXPROT_AUTO]
set axcache_manual [get_parameter_value AXI_AXCACHE_MANUAL]
set axprot_manual [get_parameter_value AXI_AXPROT_MANUAL]
set axcache_default [expr {$cache_coherent == true} ? 0xF : 0x3]
set axprot_default [expr {$cache_coherent == true} ? 0x2 : 0x0]

set_parameter_property AXI_AXCACHE_AUTO ENABLED $cache_coherent
set_parameter_property AXI_AXPROT_AUTO ENABLED $cache_coherent
set_parameter_property AXI_AXCACHE_MANUAL ENABLED $cache_coherent
set_parameter_property AXI_AXPROT_MANUAL ENABLED $cache_coherent
set_parameter_property AXI_AXCACHE_MANUAL VISIBLE [expr {$cache_coherent == true} ? [expr {$axcache_auto == true} ? false : true] : false]
set_parameter_property AXI_AXPROT_MANUAL VISIBLE [expr {$cache_coherent == true} ? [expr {$axprot_auto == true} ? false : true] : false]
set_parameter_property AXI_AXCACHE VISIBLE [expr {$cache_coherent == true} ? $axcache_auto : true]
set_parameter_property AXI_AXPROT VISIBLE [expr {$cache_coherent == true} ? $axprot_auto : true]

set_parameter_value AXI_AXCACHE [expr {$cache_coherent == true} ? [expr {$axcache_auto == true} ? $axcache_default : $axcache_manual] : $axcache_default]
set_parameter_value AXI_AXPROT [expr {$cache_coherent == true} ? [expr {$axprot_auto == true} ? $axprot_default : $axprot_manual] : $axprot_default]
}

# conditional interfaces
Expand Down
54 changes: 35 additions & 19 deletions library/axi_dmac/axi_dmac_ip.tcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
## Copyright (C) 2014-2023 Analog Devices, Inc. All rights reserved.
## Copyright (C) 2014-2024 Analog Devices, Inc. All rights reserved.
### SPDX short identifier: ADIBSD
###############################################################################

Expand Down Expand Up @@ -274,14 +274,14 @@ foreach {k v} { \
"ASYNC_CLK_SRC_SG" "true" \
"ASYNC_CLK_DEST_SG" "true" \
"CYCLIC" "false" \
"DMA_2D_TRANSFER" "false" \
"DMA_SG_TRANSFER" "false" \
"DMA_2D_TRANSFER" "false" \
"SYNC_TRANSFER_START" "false" \
"AXI_SLICE_SRC" "false" \
"AXI_SLICE_DEST" "false" \
"DISABLE_DEBUG_REGISTERS" "false" \
"ENABLE_DIAGNOSTICS_IF" "false" \
"CACHE_COHERENT_DEST" "false" \
"CACHE_COHERENT" "false" \
} { \
set_property -dict [list \
"value_format" "bool" \
Expand Down Expand Up @@ -369,18 +369,6 @@ set_property -dict [list \
"enablement_tcl_expr" "\$DMA_TYPE_SRC != 0" \
] [ipx::get_user_parameters SYNC_TRANSFER_START -of_objects $cc]

set p [ipgui::get_guiparamspec -name "CACHE_COHERENT_DEST" -component $cc]
ipgui::move_param -component $cc -order 4 $p -parent $dest_group
set_property -dict [list \
"tooltip" "Assume destination port ensures cache coherency (e.g. Ultrascale HPC port)" \
] $p
set_property -dict [list \
"display_name" "Assume cache coherent" \
"enablement_tcl_expr" "\$DMA_TYPE_DEST == 0 && \$DMA_AXI_PROTOCOL_DEST == 0" \
"value_tcl_expr" "\$DMA_TYPE_DEST == 0 && \$DMA_AXI_PROTOCOL_DEST == 0" \
"enablement_value" "false" \
] [ipx::get_user_parameters CACHE_COHERENT_DEST -of_objects $cc]

set p [ipgui::get_guiparamspec -name "DMA_AXI_PROTOCOL_SG" -component $cc]
ipgui::move_param -component $cc -order 0 $p -parent $sg_group
set_property -dict [list \
Expand Down Expand Up @@ -441,6 +429,24 @@ set_property -dict [list \
"display_name" "DMA AXI Address Width" \
] $p

set p [ipgui::get_guiparamspec -name "AXI_AXCACHE" -component $cc]
ipgui::move_param -component $cc -order 5 $p -parent $general_group
set_property -dict [list \
"display_name" "ARCACHE/AWCACHE" \
] $p
set_property -dict [list \
"enablement_tcl_expr" "\$CACHE_COHERENT == true" \
] [ipx::get_user_parameters AXI_AXCACHE -of_objects $cc]

set p [ipgui::get_guiparamspec -name "AXI_AXPROT" -component $cc]
ipgui::move_param -component $cc -order 6 $p -parent $general_group
set_property -dict [list \
"display_name" "ARPROT/AWPROT" \
] $p
set_property -dict [list \
"enablement_tcl_expr" "\$CACHE_COHERENT == true" \
] [ipx::get_user_parameters AXI_AXPROT -of_objects $cc]

set feature_group [ipgui::add_group -name "Features" -component $cc \
-parent $page0 -display_name "Features"]

Expand All @@ -450,17 +456,27 @@ set_property -dict [list \
"display_name" "Cyclic Transfer Support" \
] $p

set p [ipgui::get_guiparamspec -name "DMA_2D_TRANSFER" -component $cc]
set p [ipgui::get_guiparamspec -name "DMA_SG_TRANSFER" -component $cc]
ipgui::move_param -component $cc -order 1 $p -parent $feature_group
set_property -dict [list \
"display_name" "2D Transfer Support" \
"display_name" "SG Transfer Support" \
] $p

set p [ipgui::get_guiparamspec -name "DMA_SG_TRANSFER" -component $cc]
set p [ipgui::get_guiparamspec -name "DMA_2D_TRANSFER" -component $cc]
ipgui::move_param -component $cc -order 2 $p -parent $feature_group
set_property -dict [list \
"display_name" "SG Transfer Support" \
"display_name" "2D Transfer Support" \
] $p

set p [ipgui::get_guiparamspec -name "CACHE_COHERENT" -component $cc]
ipgui::move_param -component $cc -order 3 $p -parent $feature_group
set_property -dict [list \
"tooltip" "Assume DMA ports ensure cache coherence (e.g. Ultrascale HPC port)" \
] $p
set_property -dict [list \
"display_name" "Cache Coherent" \
"enablement_tcl_expr" "\$DMA_TYPE_SRC == 0 || \$DMA_TYPE_DEST == 0" \
] [ipx::get_user_parameters CACHE_COHERENT -of_objects $cc]

set clk_group [ipgui::add_group -name {Clock Domain Configuration} -component $cc \
-parent $page0 -display_name {Clock Domain Configuration}]
Expand Down
13 changes: 9 additions & 4 deletions library/axi_dmac/axi_dmac_regmap.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ***************************************************************************
// ***************************************************************************
// Copyright (C) 2014-2023 Analog Devices, Inc. All rights reserved.
// Copyright (C) 2014-2024 Analog Devices, Inc. All rights reserved.
//
// In this HDL repository, there are many different and unique modules, consisting
// of various HDL (Verilog or VHDL) components. The individual modules are
Expand Down Expand Up @@ -53,7 +53,9 @@ module axi_dmac_regmap #(
parameter DMA_2D_TRANSFER = 0,
parameter DMA_SG_TRANSFER = 0,
parameter SYNC_TRANSFER_START = 0,
parameter CACHE_COHERENT_DEST = 0
parameter CACHE_COHERENT = 0,
parameter [3:0] AXI_AXCACHE = 4'b0011,
parameter [2:0] AXI_AXPROT = 3'b000
) (

// Slave AXI interface
Expand Down Expand Up @@ -121,7 +123,7 @@ module axi_dmac_regmap #(
input [31:0] dbg_ids1
);

localparam PCORE_VERSION = 'h00040561;
localparam PCORE_VERSION = 'h00040562;
localparam HAS_ADDR_HIGH = DMA_AXI_ADDR_WIDTH > 32;
localparam ADDR_LOW_MSB = HAS_ADDR_HIGH ? 31 : DMA_AXI_ADDR_WIDTH-1;

Expand Down Expand Up @@ -223,7 +225,10 @@ module axi_dmac_regmap #(
4'b0,BYTES_PER_BURST_WIDTH[3:0],
2'b0,DMA_TYPE_SRC[1:0],BYTES_PER_BEAT_WIDTH_SRC[3:0],
2'b0,DMA_TYPE_DEST[1:0],BYTES_PER_BEAT_WIDTH_DEST[3:0]};
9'h005: up_rdata <= {31'd0, CACHE_COHERENT_DEST};
9'h005: up_rdata <= {20'b0,
1'b0,AXI_AXPROT,
AXI_AXCACHE,
3'b0,CACHE_COHERENT};
9'h020: up_rdata <= up_irq_mask;
9'h021: up_rdata <= up_irq_pending;
9'h022: up_rdata <= up_irq_source;
Expand Down
12 changes: 8 additions & 4 deletions library/axi_dmac/axi_dmac_transfer.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ***************************************************************************
// ***************************************************************************
// Copyright (C) 2014-2023 Analog Devices, Inc. All rights reserved.
// Copyright (C) 2014-2024 Analog Devices, Inc. All rights reserved.
//
// In this HDL repository, there are many different and unique modules, consisting
// of various HDL (Verilog or VHDL) components. The individual modules are
Expand Down Expand Up @@ -64,7 +64,8 @@ module axi_dmac_transfer #(
parameter AXI_LENGTH_WIDTH_SG = 8,
parameter ENABLE_DIAGNOSTICS_IF = 0,
parameter ALLOW_ASYM_MEM = 0,
parameter CACHE_COHERENT_DEST = 0
parameter [3:0] AXI_AXCACHE = 4'b0011,
parameter [2:0] AXI_AXPROT = 3'b000
) (
input ctrl_clk,
input ctrl_resetn,
Expand Down Expand Up @@ -321,7 +322,9 @@ module axi_dmac_transfer #(
.BYTES_PER_BEAT_WIDTH_DEST(BYTES_PER_BEAT_WIDTH_DEST),
.BYTES_PER_BEAT_WIDTH_SRC(BYTES_PER_BEAT_WIDTH_SRC),
.BYTES_PER_BEAT_WIDTH_SG(BYTES_PER_BEAT_WIDTH_SG),
.ASYNC_CLK_REQ_SG(ASYNC_CLK_REQ_SG)
.ASYNC_CLK_REQ_SG(ASYNC_CLK_REQ_SG),
.AXI_AXCACHE(AXI_AXCACHE),
.AXI_AXPROT(AXI_AXPROT)
) i_dmac_sg (
.req_clk(req_clk),
.req_resetn(req_resetn),
Expand Down Expand Up @@ -500,7 +503,8 @@ module axi_dmac_transfer #(
.AXI_LENGTH_WIDTH_SRC (AXI_LENGTH_WIDTH_SRC),
.ENABLE_DIAGNOSTICS_IF(ENABLE_DIAGNOSTICS_IF),
.ALLOW_ASYM_MEM (ALLOW_ASYM_MEM),
.CACHE_COHERENT_DEST(CACHE_COHERENT_DEST)
.AXI_AXCACHE(AXI_AXCACHE),
.AXI_AXPROT(AXI_AXPROT)
) i_request_arb (
.req_clk (req_clk),
.req_resetn (req_resetn),
Expand Down
9 changes: 8 additions & 1 deletion library/axi_dmac/bd/bd.tcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
## Copyright (C) 2015-2023 Analog Devices, Inc. All rights reserved.
## Copyright (C) 2015-2024 Analog Devices, Inc. All rights reserved.
### SPDX short identifier: ADIBSD
###############################################################################

Expand Down Expand Up @@ -203,4 +203,11 @@ proc post_propagate {cellpath otherinfo} {
}

set_property "CONFIG.DMA_AXI_ADDR_WIDTH" $addr_width $ip

# AXCACHE/AXPROT configuration
set cache_coherent [get_property "CONFIG.CACHE_COHERENT" $ip]
set axcache [expr {$cache_coherent == true} ? 0b1111 : 0b0011]
set axprot [expr {$cache_coherent == true} ? 0b010 : 0b000]
set_property "CONFIG.AXI_AXCACHE" $axcache $ip
set_property "CONFIG.AXI_AXPROT" $axprot $ip
}
Loading

0 comments on commit 107047e

Please sign in to comment.