diff --git a/gowin/arch.cc b/gowin/arch.cc index e4dce329..0bc0ef56 100644 --- a/gowin/arch.cc +++ b/gowin/arch.cc @@ -485,8 +485,9 @@ DelayQuad Arch::getWireTypeDelay(IdString wire) void Arch::read_cst(std::istream &in) { std::regex iobre = std::regex("IO_LOC +\"([^\"]+)\" +([^ ;]+) *;.*"); - std::regex portre = std::regex("IO_PORT +\"([^\"]+)\" +([^ =;]+=[^ =;]+) *;.*"); - std::smatch match; + std::regex portre = std::regex("IO_PORT +\"([^\"]+)\" +([^;]+;).*"); + std::regex port_attrre = std::regex("([^ =;]+=[^ =;]+) *([^;]*;)"); + std::smatch match, match_attr; std::string line; bool io_loc; while (!in.eof()) { @@ -517,10 +518,14 @@ void Arch::read_cst(std::istream &in) std::string bel = IdString(belname->src_id).str(this); it->second->attrs[IdString(ID_BEL)] = bel; } else { // IO_PORT attr=value - std::string attr = "&"; - attr += match[2]; - boost::algorithm::to_upper(attr); - it->second->attrs[id(attr)] = 1; + std::string attr_val = match[2]; + while (std::regex_match(attr_val, match_attr, port_attrre)) { + std::string attr = "&"; + attr += match_attr[1]; + boost::algorithm::to_upper(attr); + it->second->attrs[id(attr)] = 1; + attr_val = match_attr[2]; + } } } } diff --git a/gowin/pack.cc b/gowin/pack.cc index ac5e5ff4..213889f5 100644 --- a/gowin/pack.cc +++ b/gowin/pack.cc @@ -229,8 +229,10 @@ static void pack_io(Context *ctx) iob = net_only_drives(ctx, ci->ports.at(id_O).net, is_nextpnr_iob, id_I); break; case ID_IOBUF: + iob = net_driven_by(ctx, ci->ports.at(id_IO).net, is_nextpnr_iob, id_O); + break; case ID_TBUF: - log_error("untested tristate stuff"); + iob = net_only_drives(ctx, ci->ports.at(id_O).net, is_nextpnr_iob, id_I); break; default: break;