generated from maddiebusig/vivado-template-hog
Refactor IP parameter and port mapping into separate proc
This commit is contained in:
parent
51f3102fae
commit
e42d640083
@ -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
|
# Parse the interface configuration and create a new interface
|
||||||
# in the current core
|
# in the current core
|
||||||
#
|
#
|
||||||
@ -93,36 +135,11 @@ proc ParseInterfaceConf { iface_name iface_conf } {
|
|||||||
set_property INTERFACE_MODE [dict get $iface_conf "MODE"] $iface
|
set_property INTERFACE_MODE [dict get $iface_conf "MODE"] $iface
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create user parameters
|
set params [GetSubValues $iface_conf "PARAMETER"]
|
||||||
foreach {key val} $iface_conf {
|
set port_maps [GetSubValues $iface_conf "PORT"]
|
||||||
set param_name [SplitSub $key "PARAMETER"]
|
|
||||||
|
|
||||||
if { $param_name == "" } {
|
InterfaceAddParameters $iface $params
|
||||||
continue
|
InterfaceAddPortMaps $iface $port_maps
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create port mappings
|
|
||||||
foreach {key val} $iface_conf {
|
|
||||||
set logical_port [SplitSub $key "PORT"]
|
|
||||||
set physical_port $val
|
|
||||||
|
|
||||||
if { $logical_port == "" } {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set gitroot [exec git rev-parse --show-toplevel]
|
set gitroot [exec git rev-parse --show-toplevel]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user