From 77c5c67adeda21d24eff78ece6aefeb8a35ded46 Mon Sep 17 00:00:00 2001 From: Justin Date: Fri, 13 Mar 2026 21:01:10 -1000 Subject: [PATCH] fix: handle string DRIVE property in pack_io without crashing (#1668) * fix: handle string DRIVE property in pack_io without crashing The XDC parser stores all set_property values as string Properties, but pack_io.cc called as_int64() on DRIVE which asserts !is_string. Rather than converting numeric values to integer Properties in the XDC parser (which risks breaking properties like LOC that downstream code reads via to_string()/as_string()), fix the consumption site in pack_io.cc to convert string values to integers when needed. * refactor: use int_or_default for DRIVE property parsing Replace manual is_string/as_int64 branching with int_or_default(), which already handles both Property types with proper error reporting. --- himbaechel/uarch/xilinx/pack_io.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/himbaechel/uarch/xilinx/pack_io.cc b/himbaechel/uarch/xilinx/pack_io.cc index b485ba49..d6d2f11c 100644 --- a/himbaechel/uarch/xilinx/pack_io.cc +++ b/himbaechel/uarch/xilinx/pack_io.cc @@ -470,11 +470,10 @@ void XC7Packer::check_valid_pad(CellInfo *ci, std::string type) if (!boost::starts_with(iostandard, "LVTTL") && !boost::starts_with(iostandard, "LVCMOS")) return; - auto drive_attr = ci->attrs.find(id_DRIVE); // no drive strength attribute: use default - if (drive_attr == ci->attrs.end()) + if (!ci->attrs.count(id_DRIVE)) return; - auto drive = drive_attr->second.as_int64(); + auto drive = int_or_default(ci->attrs, id_DRIVE, 0); bool is_iob33 = boost::starts_with(type, "IOB33"); if (is_iob33) { @@ -491,7 +490,7 @@ void XC7Packer::check_valid_pad(CellInfo *ci, std::string type) return; } - log_error("unsupported DRIVE strength property %s for port %s", drive_attr->second.c_str(), ci->name.c_str(ctx)); + log_error("unsupported DRIVE strength %d for port %s", drive, ci->name.c_str(ctx)); } SiteIndex XC7Packer::get_ologic_site(BelId io_bel)