From 9f382d56c6f979e3a3e8d795349ea3a9696128b6 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 24 Mar 2017 18:25:47 +0100 Subject: [PATCH] scripts/adi_ip.pl: Infer register map range from address width Currently the register map range of a peripheral is hardcoded to 64k. Not all peripherals need that much space though and reducing the size of the address can reduce the amount of logic required, both in the interconnect as well as in the peripheral. Let adi_ip_properties() infer the size of the register map from the number of bits of the address when creating the register map. For backwards compatibility limit the register map size to 64k since currently peripherals have a address width of 32 bits, event if they use less. Signed-off-by: Lars-Peter Clausen --- library/scripts/adi_ip.tcl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/library/scripts/adi_ip.tcl b/library/scripts/adi_ip.tcl index e874caf7b..7fd459fdf 100644 --- a/library/scripts/adi_ip.tcl +++ b/library/scripts/adi_ip.tcl @@ -241,10 +241,25 @@ proc adi_ip_properties {ip_name} { ipx::infer_bus_interface s_axi_aclk xilinx.com:signal:clock_rtl:1.0 [ipx::current_core] ipx::infer_bus_interface s_axi_aresetn xilinx.com:signal:reset_rtl:1.0 [ipx::current_core] + + set raddr_width [expr [get_property SIZE_LEFT [ipx::get_ports -nocase true s_axi_araddr -of_objects [ipx::current_core]]] + 1] + set waddr_width [expr [get_property SIZE_LEFT [ipx::get_ports -nocase true s_axi_awaddr -of_objects [ipx::current_core]]] + 1] + + if {$raddr_width != $waddr_width} { + puts [format "WARNING: AXI address width mismatch for %s (r=%d, w=%d)" $ip_name $raddr_width, $waddr_width] + set range 65536 + } else { + if {$raddr_width >= 16} { + set range 65536 + } else { + set range [expr 1 << $raddr_width] + } + } + ipx::add_memory_map {s_axi} [ipx::current_core] set_property slave_memory_map_ref {s_axi} [ipx::get_bus_interfaces s_axi -of_objects [ipx::current_core]] ipx::add_address_block {axi_lite} [ipx::get_memory_maps s_axi -of_objects [ipx::current_core]] - set_property range {65536} [ipx::get_address_blocks axi_lite \ + set_property range $range [ipx::get_address_blocks axi_lite \ -of_objects [ipx::get_memory_maps s_axi -of_objects [ipx::current_core]]] ipx::add_bus_parameter ASSOCIATED_BUSIF [ipx::get_bus_interfaces s_axi_aclk \ -of_objects [ipx::current_core]]