generated from maddiebusig/vivado-template-hog
Compare commits
6 Commits
51f3102fae
...
53aee5878e
| Author | SHA1 | Date | |
|---|---|---|---|
| 53aee5878e | |||
| cff5b413e7 | |||
| ca6826d53d | |||
| cf43ac49d3 | |||
| 49723910d8 | |||
| e42d640083 |
@ -16,7 +16,6 @@ ENABLEMENT_DEPENDENCY
|
||||
INFER=false
|
||||
MODE=slave
|
||||
PORT.CLK=s_axi_aclk
|
||||
PARAMETER.FREQ_HZ=100000000
|
||||
PARAMETER.ASSOCIATED_RESET=s_axi_aresetn
|
||||
PARAMETER.ASSOCIATED_BUSIF=s_axi
|
||||
|
||||
@ -25,3 +24,8 @@ INTERFACE=xilinx.com:signal:reset_rtl:1.0
|
||||
INFER=true
|
||||
PORTS=s_axi_aresetn
|
||||
|
||||
[memmap.s_axi]
|
||||
BLOCKS=reg_base
|
||||
BLOCK.reg_base.BASE_ADDRESS=0
|
||||
BLOCK.reg_base.RANGE=32
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ proc DictValueOr { dict key default } {
|
||||
if { [dict exists $dict $key] } {
|
||||
return [dict get $dict $key]
|
||||
} else {
|
||||
return default
|
||||
return $default
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +30,48 @@ proc SplitSub { str startword } {
|
||||
}
|
||||
}
|
||||
|
||||
# Gets all the values whose key starts with 'startword.*', returns a
|
||||
# dictionary with the same values, but the keys are instead '*'.
|
||||
#
|
||||
# EX: With the dictionary d = { param.foo one param.bar two biz three }
|
||||
#
|
||||
# Calling [GetSubValues $d "param"] would result in the dictionary:
|
||||
#
|
||||
# { foo one bar two }
|
||||
proc GetSubValues {map subcat} {
|
||||
set res_map [dict create]
|
||||
|
||||
foreach {key val} $map {
|
||||
set new_key [SplitSub $key $subcat]
|
||||
|
||||
if { $new_key != "" } {
|
||||
dict append res_map $new_key $val
|
||||
}
|
||||
}
|
||||
|
||||
return $res_map
|
||||
}
|
||||
|
||||
proc InterfaceAddParameters {iface params} {
|
||||
foreach {param_name val} $params {
|
||||
puts "Setting parameter $param_name"
|
||||
|
||||
ipx::add_bus_parameter $param_name $iface
|
||||
set param [ipx::get_bus_parameters $param_name -of_objects $iface]
|
||||
set_property value $val $param
|
||||
}
|
||||
}
|
||||
|
||||
proc InterfaceAddPortMaps {iface port_maps} {
|
||||
foreach {logical_port physical_port} $port_maps {
|
||||
puts "Mapping logical port $logical_port"
|
||||
|
||||
ipx::add_port_map $logical_port $iface
|
||||
set port_map [ipx::get_port_maps $logical_port -of_objects $iface]
|
||||
set_property physical_name $physical_port $port_map
|
||||
}
|
||||
}
|
||||
|
||||
# Parse the interface configuration and create a new interface
|
||||
# in the current core
|
||||
#
|
||||
@ -93,35 +135,42 @@ proc ParseInterfaceConf { iface_name iface_conf } {
|
||||
set_property INTERFACE_MODE [dict get $iface_conf "MODE"] $iface
|
||||
}
|
||||
|
||||
# Create user parameters
|
||||
foreach {key val} $iface_conf {
|
||||
set param_name [SplitSub $key "PARAMETER"]
|
||||
set params [GetSubValues $iface_conf "PARAMETER"]
|
||||
set port_maps [GetSubValues $iface_conf "PORT"]
|
||||
|
||||
if { $param_name == "" } {
|
||||
continue
|
||||
}
|
||||
InterfaceAddParameters $iface $params
|
||||
InterfaceAddPortMaps $iface $port_maps
|
||||
}
|
||||
|
||||
puts "Setting parameter $param_name"
|
||||
proc AddMemoryMapBlock {memmap block_name block_conf} {
|
||||
set disp_name [DictValueOr $block_conf "DISPLAY_NAME" ""]
|
||||
set description [DictValueOr $block_conf "DESCRIPTION" ""]
|
||||
set base_addr [DictValueOr $block_conf "BASE_ADDRESS" "0"]
|
||||
set range [DictValueOr $block_conf "RANGE" "4096"]
|
||||
set width [DictValueOr $block_conf "WIDTH" "0"]
|
||||
|
||||
ipx::add_bus_parameter $param_name $iface
|
||||
set param [ipx::get_bus_parameters $param_name -of_objects $iface]
|
||||
set_property value $val $param
|
||||
}
|
||||
set block [ipx::add_address_block $block_name $memmap]
|
||||
|
||||
# Create port mappings
|
||||
foreach {key val} $iface_conf {
|
||||
set logical_port [SplitSub $key "PORT"]
|
||||
set physical_port $val
|
||||
set_property DISPLAY_NAME $disp_name $block
|
||||
set_property DESCRIPTION $description $block
|
||||
set_property BASE_ADDRESS $base_addr $block
|
||||
set_property RANGE $range $block
|
||||
set_property WIDTH $width $block
|
||||
}
|
||||
|
||||
if { $logical_port == "" } {
|
||||
continue
|
||||
}
|
||||
|
||||
puts "Mapping logical port $logical_port"
|
||||
proc ParseMemoryMapConf {iface_name memmap_conf} {
|
||||
set memmap_name "${iface_name}_mem"
|
||||
set blocks [dict get $memmap_conf "BLOCKS"]
|
||||
|
||||
ipx::add_port_map $logical_port $iface
|
||||
set port_map [ipx::get_port_maps $logical_port -of_objects $iface]
|
||||
set_property physical_name $physical_port $port_map
|
||||
set memmap [ipx::add_memory_map $memmap_name [ipx::current_core]]
|
||||
set associated_iface [ipx::get_bus_interfaces $iface_name -of_objects [ipx::current_core]]
|
||||
set_property SLAVE_MEMORY_MAP_REF $memmap_name $associated_iface
|
||||
|
||||
foreach block_name $blocks {
|
||||
puts "Parsing block $block_name of $memmap_name"
|
||||
|
||||
set block_conf [GetSubValues $memmap_conf $block_name]
|
||||
AddMemoryMapBlock $memmap $block_name $block_conf
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,17 +249,6 @@ foreach memmap [ipx::get_memory_maps -of_objects [ipx::current_core]] {
|
||||
ipx::remove_memory_map $memmap_name [ipx::current_core]
|
||||
}
|
||||
|
||||
foreach param [ipx::get_user_parameters -of_objects [ipx::current_core]] {
|
||||
set param_name [lindex $param 2]
|
||||
|
||||
if { $param_name == "Component_Name" } {
|
||||
continue
|
||||
}
|
||||
|
||||
puts "Removing inferred user parameter $param_name"
|
||||
ipx::remove_user_parameter $param_name [ipx::current_core]
|
||||
}
|
||||
|
||||
puts "Parsing interfaces"
|
||||
|
||||
foreach {key val} $ip_conf {
|
||||
@ -224,6 +262,17 @@ foreach {key val} $ip_conf {
|
||||
}
|
||||
}
|
||||
|
||||
puts "Parsing memory maps"
|
||||
|
||||
set memmaps [GetSubValues $ip_conf "memmap"]
|
||||
|
||||
puts "Memmaps: $memmaps"
|
||||
|
||||
foreach {associated_iface memmap_conf} $memmaps {
|
||||
puts "Parsing memory map for iface $associated_iface, conf: $memmap_conf"
|
||||
ParseMemoryMapConf $associated_iface $memmap_conf
|
||||
}
|
||||
|
||||
puts "Packaging IP"
|
||||
|
||||
# Increment revision
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user