From a6e86c8f3c053bb0d956602f99302603c07958d3 Mon Sep 17 00:00:00 2001 From: Madeline Busig Date: Mon, 10 Nov 2025 19:50:08 -0800 Subject: [PATCH] Implement interface inferring --- tcl/package_ip.tcl | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tcl/package_ip.tcl b/tcl/package_ip.tcl index 504df1e..a32860c 100644 --- a/tcl/package_ip.tcl +++ b/tcl/package_ip.tcl @@ -1,3 +1,38 @@ +# Parse the interface configuration and create a new interface +# in the current core +# +# @param iface_name Name of the interface to crate +# @param iface_conf Dictionary containing the interface configuration, parsed +# from hog.tcl ReadConf +# +proc ParseInterfaceConf { iface_name iface_conf } { + puts "Parsing interface $iface_name" + + set iface_protocol [dict get $iface_conf "INTERFACE"] + variable infer false + + if { [dict exists $iface_conf "INFER"] } { + set infer [dict get $iface_conf "INFER"] + } + + if { $infer } { + puts "Inferring interface" + + set ports [split [dict get $iface_conf "PORTS"]] + + puts "Using ports: $ports" + + set result [ipx::infer_bus_interface $ports $iface_protocol [ipx::current_core]] + + # Inferred name could differ from the desired name, so set it + set inferred_name [lindex $result 2] + set created_iface [ipx::get_bus_interfaces $inferred_name -of_objects [ipx::current_core]] + set_property NAME $iface_name $created_iface + } else { + puts "Manually creating interface" + } +} + set gitroot [exec git rev-parse --show-toplevel] set hogroot "$gitroot/Hog" @@ -84,6 +119,19 @@ foreach param [ipx::get_user_parameters -of_objects [ipx::current_core]] { ipx::remove_user_parameter $param_name [ipx::current_core] } +puts "Parsing interfaces" + +foreach {key val} $ip_conf { + if { [string first "interface" "$key"] == 0 } { + set sepidx [string first "." "$key"] + set iface_name [string range "$key" [expr $sepidx + 1] [string length "$key"]] + + ParseInterfaceConf "$iface_name" $val + } else { + puts "$key is not an interface" + } +} + puts "Packaging IP" # Increment revision